Subversion Repositories SmartDukaan

Rev

Rev 36017 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36017 Rev 36057
Line 19... Line 19...
19
import java.util.ArrayList;
19
import java.util.ArrayList;
20
import java.util.List;
20
import java.util.List;
21
import java.util.Map;
21
import java.util.Map;
22
import java.util.concurrent.ConcurrentHashMap;
22
import java.util.concurrent.ConcurrentHashMap;
23
 
23
 
-
 
24
/**
-
 
25
 * DEPRECATED: This service is no longer actively used.
-
 
26
 * <p>
-
 
27
 * Live agent status is now retrieved from Redis via KnowlarityCallMonitorService in profitmandi-dao.
-
 
28
 * Break logs are now persisted by KnowlarityCallMonitorService via WebSocket in profitmandi-cron.
-
 
29
 * <p>
-
 
30
 * Use the following for live status:
-
 
31
 * - REST API: /api/agent-live-status endpoints in profitmandi-web (AgentLiveStatusController)
-
 
32
 * - DAO Service: KnowlarityCallMonitorService.getAgentStatusesFromRedis()
-
 
33
 * <p>
-
 
34
 * This service is kept for backward compatibility but should not be used for new features.
-
 
35
 */
-
 
36
@Deprecated
24
@Service
37
@Service
25
public class AgentLiveStatusService {
38
public class AgentLiveStatusService {
26
 
39
 
27
    private static final Logger LOGGER = LogManager.getLogger(AgentLiveStatusService.class);
40
    private static final Logger LOGGER = LogManager.getLogger(AgentLiveStatusService.class);
28
 
41
 
Line 165... Line 178...
165
        srNumberToAuthIdMap.clear();
178
        srNumberToAuthIdMap.clear();
166
        agentNameToAuthIdMap.clear();
179
        agentNameToAuthIdMap.clear();
167
    }
180
    }
168
 
181
 
169
    public void updateStatus(int authId, String srNumber, String agentName, String agentStatus, String timeInStatus, String customerNumber) {
182
    public void updateStatus(int authId, String srNumber, String agentName, String agentStatus, String timeInStatus, String customerNumber) {
170
        // Get previous status to detect change
183
        // DISABLED: Break log persistence is now handled by profitmandi-cron via WebSocket
171
        AgentStatus previousStatus = agentStatusMap.get(authId);
184
        // This method only updates in-memory status map (also deprecated - use Redis via KnowlarityCallMonitorService)
172
 
185
 
173
        // Check if status has changed
-
 
174
        if (previousStatus != null && previousStatus.getAgentStatus() != null) {
-
 
175
            String prevStatusStr = previousStatus.getAgentStatus();
-
 
176
            String newStatusStr = agentStatus != null ? agentStatus : "";
-
 
177
 
-
 
178
            // If status changed, save the previous status duration to RbmBreakLog
-
 
179
            if (!prevStatusStr.equalsIgnoreCase(newStatusStr)) {
-
 
180
                // Only track Available and Break statuses
-
 
181
                if (isTrackableStatus(prevStatusStr)) {
-
 
182
                    String prevTimeInStatus = previousStatus.getTimeInStatus();
-
 
183
                    int durationSeconds = parseTimeInStatusToSeconds(prevTimeInStatus);
-
 
184
 
-
 
185
                    // Calculate the START TIME when agent entered this status
-
 
186
                    // startTime = now - duration
-
 
187
                    LocalDateTime statusStartTime = LocalDateTime.now().minusSeconds(durationSeconds);
-
 
188
 
-
 
189
                    LOGGER.info("Status changed for {} (authId={}): '{}' -> '{}', started at: {}, duration: {} ({}s)",
-
 
190
                            agentName, authId, prevStatusStr, newStatusStr, statusStartTime, prevTimeInStatus, durationSeconds);
-
 
191
 
-
 
192
                    // Save to RbmBreakLog with START TIME
-
 
193
                    saveStatusDuration(authId, agentName, srNumber, prevStatusStr, prevTimeInStatus, durationSeconds, statusStartTime);
-
 
194
                }
-
 
195
            }
-
 
196
        }
-
 
197
 
-
 
198
        // Update current status
186
        // Update current status (in-memory only, no persistence)
199
        AgentStatus status = new AgentStatus(authId, srNumber, agentName, agentStatus, timeInStatus, customerNumber);
187
        AgentStatus status = new AgentStatus(authId, srNumber, agentName, agentStatus, timeInStatus, customerNumber);
200
        agentStatusMap.put(authId, status);
188
        agentStatusMap.put(authId, status);
201
    }
189
    }
202
 
190
 
203
    /**
191
    /**