Subversion Repositories SmartDukaan

Rev

Rev 35720 | Rev 35730 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35720 Rev 35721
Line 1056... Line 1056...
1056
                            || t.getL5AuthUser() == authId)
1056
                            || t.getL5AuthUser() == authId)
1057
                    .map(Ticket::getFofoId)
1057
                    .map(Ticket::getFofoId)
1058
                    .distinct()
1058
                    .distinct()
1059
                    .collect(Collectors.toList());
1059
                    .collect(Collectors.toList());
1060
 
1060
 
1061
            // For L2, all escalated tickets are target
-
 
1062
            Set<Integer> targetFofoIds = new HashSet<>(fofoIdList);
-
 
1063
 
-
 
1064
            // Get today's remarks
1061
            // Get today's remarks created by L2
1065
            List<PartnerCollectionRemark> todayRemarks = partnerCollectionRemarkRepository
1062
            List<PartnerCollectionRemark> todayRemarks = partnerCollectionRemarkRepository
1066
                    .selectAllByAuthIdsOnDate(Collections.singletonList(authId), today);
1063
                    .selectAllByAuthIdsOnDate(Collections.singletonList(authId), today);
1067
 
1064
 
1068
            // Filter to only target partners and deduplicate
1065
            // Deduplicate by fofoId - keep latest remark per partner (list is ordered by id DESC)
1069
            Map<Integer, PartnerCollectionRemark> uniqueRemarksByFofoId = new LinkedHashMap<>();
1066
            Map<Integer, PartnerCollectionRemark> uniqueRemarksByFofoId = new LinkedHashMap<>();
1070
            for (PartnerCollectionRemark remark : todayRemarks) {
1067
            for (PartnerCollectionRemark remark : todayRemarks) {
1071
                if (targetFofoIds.contains(remark.getFofoId())) {
-
 
1072
                    uniqueRemarksByFofoId.putIfAbsent(remark.getFofoId(), remark);
1068
                uniqueRemarksByFofoId.putIfAbsent(remark.getFofoId(), remark);
1073
                }
-
 
1074
            }
1069
            }
1075
 
1070
 
1076
            return buildCalledPartnerResult(uniqueRemarksByFofoId);
1071
            return buildCalledPartnerResult(uniqueRemarksByFofoId);
1077
        }
1072
        }
1078
 
1073
 
Line 1161... Line 1156...
1161
                targetFofoIds.add(fofoId);
1156
                targetFofoIds.add(fofoId);
1162
            }
1157
            }
1163
            // rank 4 (FuturePlan) and rank 5 (Normal) are NOT in target
1158
            // rank 4 (FuturePlan) and rank 5 (Normal) are NOT in target
1164
        }
1159
        }
1165
 
1160
 
1166
        // Get today's remarks
1161
        // Get today's remarks created by L1
1167
        List<PartnerCollectionRemark> todayRemarks = partnerCollectionRemarkRepository
1162
        List<PartnerCollectionRemark> todayRemarks = partnerCollectionRemarkRepository
1168
                .selectAllByAuthIdsOnDate(Collections.singletonList(authId), today);
1163
                .selectAllByAuthIdsOnDate(Collections.singletonList(authId), today);
1169
 
1164
 
1170
        // Filter to only target partners and deduplicate
1165
        // Deduplicate by fofoId - keep latest remark per partner (list is ordered by id DESC)
1171
        Map<Integer, PartnerCollectionRemark> uniqueRemarksByFofoId = new LinkedHashMap<>();
1166
        Map<Integer, PartnerCollectionRemark> uniqueRemarksByFofoId = new LinkedHashMap<>();
1172
        for (PartnerCollectionRemark remark : todayRemarks) {
1167
        for (PartnerCollectionRemark remark : todayRemarks) {
1173
            if (targetFofoIds.contains(remark.getFofoId())) {
-
 
1174
                uniqueRemarksByFofoId.putIfAbsent(remark.getFofoId(), remark);
1168
            uniqueRemarksByFofoId.putIfAbsent(remark.getFofoId(), remark);
1175
            }
-
 
1176
        }
1169
        }
1177
 
1170
 
1178
        return buildCalledPartnerResult(uniqueRemarksByFofoId);
1171
        return buildCalledPartnerResult(uniqueRemarksByFofoId);
1179
    }
1172
    }
1180
 
1173
 
Line 1190... Line 1183...
1190
        } catch (ProfitMandiBusinessException e) {
1183
        } catch (ProfitMandiBusinessException e) {
1191
            LOGGER.error("Error fetching fofo stores", e);
1184
            LOGGER.error("Error fetching fofo stores", e);
1192
        }
1185
        }
1193
 
1186
 
1194
        // Fetch call logs for remarks that have agentCallLogId
1187
        // Fetch call logs for remarks that have agentCallLogId
1195
        List<Long> callLogIds = uniqueRemarksByFofoId.values().stream()
-
 
1196
                .filter(r -> r.getAgentCallLogId() > 0)
-
 
1197
                .map(PartnerCollectionRemark::getAgentCallLogId)
-
 
1198
                .collect(Collectors.toList());
-
 
1199
 
-
 
1200
        Map<Long, com.spice.profitmandi.dao.entity.cs.AgentCallLog> callLogMap = new HashMap<>();
1188
        Map<Long, com.spice.profitmandi.dao.entity.cs.AgentCallLog> callLogMap = new HashMap<>();
-
 
1189
        try {
-
 
1190
            List<Long> callLogIds = uniqueRemarksByFofoId.values().stream()
-
 
1191
                    .filter(r -> r.getAgentCallLogId() > 0)
-
 
1192
                    .map(PartnerCollectionRemark::getAgentCallLogId)
1201
        if (!callLogIds.isEmpty()) {
1193
                    .collect(Collectors.toList());
-
 
1194
 
1202
            try {
1195
            if (!callLogIds.isEmpty()) {
1203
                List<com.spice.profitmandi.dao.entity.cs.AgentCallLog> callLogs = agentCallLogRepository.findByIds(callLogIds);
1196
                List<com.spice.profitmandi.dao.entity.cs.AgentCallLog> callLogs = agentCallLogRepository.findByIds(callLogIds);
-
 
1197
                if (callLogs != null) {
1204
                callLogMap = callLogs.stream()
1198
                    callLogMap = callLogs.stream()
1205
                        .collect(Collectors.toMap(com.spice.profitmandi.dao.entity.cs.AgentCallLog::getId, c -> c, (a, b) -> a));
1199
                            .collect(Collectors.toMap(com.spice.profitmandi.dao.entity.cs.AgentCallLog::getId, c -> c, (a, b) -> a));
1206
            } catch (Exception e) {
1200
                }
1207
                LOGGER.error("Error fetching call logs by ids", e);
-
 
1208
            }
1201
            }
-
 
1202
        } catch (Exception e) {
-
 
1203
            LOGGER.error("Error fetching call logs by ids", e);
1209
        }
1204
        }
1210
 
1205
 
1211
        DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("hh:mm a");
1206
        DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("hh:mm a");
1212
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy hh:mm a");
1207
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy hh:mm a");
1213
        List<CalledPartnerDetailModel> result = new ArrayList<>();
1208
        List<CalledPartnerDetailModel> result = new ArrayList<>();
Line 1237... Line 1232...
1237
            String recordingUrl = null;
1232
            String recordingUrl = null;
1238
            String callStatus = null;
1233
            String callStatus = null;
1239
            String callDuration = null;
1234
            String callDuration = null;
1240
            String callDateTime = null;
1235
            String callDateTime = null;
1241
 
1236
 
-
 
1237
            try {
1242
            if (remark.getAgentCallLogId() > 0 && callLogMap.containsKey(remark.getAgentCallLogId())) {
1238
                if (remark.getAgentCallLogId() > 0 && callLogMap.containsKey(remark.getAgentCallLogId())) {
1243
                com.spice.profitmandi.dao.entity.cs.AgentCallLog callLog = callLogMap.get(remark.getAgentCallLogId());
1239
                    com.spice.profitmandi.dao.entity.cs.AgentCallLog callLog = callLogMap.get(remark.getAgentCallLogId());
1244
                recordingUrl = callLog.getRecordingUrl();
1240
                    recordingUrl = callLog.getRecordingUrl();
1245
                callStatus = callLog.getCallStatus();
1241
                    callStatus = callLog.getCallStatus();
1246
                callDuration = callLog.getCallDuration();
1242
                    callDuration = callLog.getCallDuration();
1247
                if (callLog.getCallDate() != null && callLog.getCallTime() != null) {
1243
                    if (callLog.getCallDate() != null && callLog.getCallTime() != null) {
1248
                    LocalDateTime callDateTimeObj = LocalDateTime.of(callLog.getCallDate(), callLog.getCallTime());
1244
                        LocalDateTime callDateTimeObj = LocalDateTime.of(callLog.getCallDate(), callLog.getCallTime());
1249
                    callDateTime = callDateTimeObj.format(dateTimeFormatter);
1245
                        callDateTime = callDateTimeObj.format(dateTimeFormatter);
-
 
1246
                    }
1250
                }
1247
                }
-
 
1248
            } catch (Exception e) {
-
 
1249
                LOGGER.error("Error processing call log for remark id: {}", remark.getId(), e);
1251
            }
1250
            }
1252
 
1251
 
1253
            result.add(new CalledPartnerDetailModel(partyName, code, remarkValue, messageValue, time,
1252
            result.add(new CalledPartnerDetailModel(partyName, code, remarkValue, messageValue, time,
1254
                    recordingUrl, callStatus, callDuration, callDateTime));
1253
                    recordingUrl, callStatus, callDuration, callDateTime));
1255
        }
1254
        }