| Line 969... |
Line 969... |
| 969 |
|
969 |
|
| 970 |
ptam.setRemark(collectionPlan.getRemark());
|
970 |
ptam.setRemark(collectionPlan.getRemark());
|
| 971 |
ptam.setMessage(collectionPlan.getMessage());
|
971 |
ptam.setMessage(collectionPlan.getMessage());
|
| 972 |
ptam.setRemarkTimestamp(collectionPlan.getRemarkTimestamp());
|
972 |
ptam.setRemarkTimestamp(collectionPlan.getRemarkTimestamp());
|
| 973 |
ptam.setRecordingUrl(collectionPlan.getRecordingUrl());
|
973 |
ptam.setRecordingUrl(collectionPlan.getRecordingUrl());
|
| - |
|
974 |
ptam.setScheduledCallTime(collectionPlan.getScheduledCallTime());
|
| 974 |
ptam.setRank(collectionPlan.getRank());
|
975 |
ptam.setRank(collectionPlan.getRank());
|
| 975 |
Integer authId = collectionPlan.getAuthId();
|
976 |
Integer authId = collectionPlan.getAuthId();
|
| 976 |
|
977 |
|
| 977 |
Map<Integer, String> rankColorMap = ProfitMandiConstants.Rank_Color_Map;
|
978 |
Map<Integer, String> rankColorMap = ProfitMandiConstants.Rank_Color_Map;
|
| 978 |
|
979 |
|
| Line 1206... |
Line 1207... |
| 1206 |
tm.setZeroBilledCount(categoryCounts.getOrDefault("ZERO_BILLED", 0L).intValue());
|
1207 |
tm.setZeroBilledCount(categoryCounts.getOrDefault("ZERO_BILLED", 0L).intValue());
|
| 1207 |
tm.setUntouchedCount(categoryCounts.getOrDefault("UNTOUCHED", 0L).intValue());
|
1208 |
tm.setUntouchedCount(categoryCounts.getOrDefault("UNTOUCHED", 0L).intValue());
|
| 1208 |
tm.setNormalCount(categoryCounts.getOrDefault("NORMAL", 0L).intValue());
|
1209 |
tm.setNormalCount(categoryCounts.getOrDefault("NORMAL", 0L).intValue());
|
| 1209 |
|
1210 |
|
| 1210 |
// Sort by: 1) Partners with today's remark go to bottom of entire list
|
1211 |
// Sort by: 1) Partners with today's remark go to bottom of entire list
|
| - |
|
1212 |
// EXCEPT: NO_ANSWER/SCHEDULE_CALL with scheduledCallTime reached → comes back up
|
| 1211 |
// EXCEPT: NO_ANSWER remark older than 2 hours comes back to original position
|
1213 |
// EXCEPT: NO_ANSWER without scheduledCallTime older than 2 hours → comes back up
|
| 1212 |
// 2) Category Priority (PLAN_TODAY=1, CARRY_FORWARD=2, ZERO_BILLED=3, UNTOUCHED=4, NORMAL=5)
|
1214 |
// 2) Category Priority (PLAN_TODAY=1, CARRY_FORWARD=2, ZERO_BILLED=3, UNTOUCHED=4, NORMAL=5)
|
| 1213 |
// 3) Then by rank
|
1215 |
// 3) Then by rank
|
| - |
|
1216 |
LocalDateTime now = LocalDateTime.now();
|
| 1214 |
LocalDateTime twoHoursAgo = LocalDateTime.now().minusHours(2);
|
1217 |
LocalDateTime twoHoursAgo = now.minusHours(2);
|
| 1215 |
tm.setTargetAchievement(filteredPtams.stream()
|
1218 |
tm.setTargetAchievement(filteredPtams.stream()
|
| 1216 |
.sorted(Comparator
|
1219 |
.sorted(Comparator
|
| 1217 |
.comparing((PartnerTargetAchievementModel p) -> {
|
1220 |
.comparing((PartnerTargetAchievementModel p) -> {
|
| 1218 |
if (p.getRemarkTimestamp() == null) {
|
1221 |
if (p.getRemarkTimestamp() == null) {
|
| 1219 |
return false; // No remark → comes first
|
1222 |
return false; // No remark → comes first
|
| 1220 |
}
|
1223 |
}
|
| 1221 |
LocalDate remarkDate = p.getRemarkTimestamp().toLocalDate();
|
1224 |
LocalDate remarkDate = p.getRemarkTimestamp().toLocalDate();
|
| 1222 |
if (!remarkDate.equals(LocalDate.now())) {
|
1225 |
if (!remarkDate.equals(LocalDate.now())) {
|
| 1223 |
return false; // Not today's remark → comes first
|
1226 |
return false; // Not today's remark → comes first
|
| 1224 |
}
|
1227 |
}
|
| 1225 |
// Today's remark - check if NO_ANSWER and older than 2 hours
|
1228 |
// Check if SCHEDULE_CALL or NO_ANSWER with scheduledCallTime
|
| - |
|
1229 |
if (CollectionRemark.SCHEDULE_CALL.equals(p.getRemark()) || CollectionRemark.NO_ANSWER.equals(p.getRemark())) {
|
| - |
|
1230 |
if (p.getScheduledCallTime() != null) {
|
| - |
|
1231 |
// Has scheduled time - come up only when scheduled time is reached
|
| - |
|
1232 |
if (!p.getScheduledCallTime().isAfter(now)) {
|
| - |
|
1233 |
return false; // Scheduled time reached → comes back up
|
| - |
|
1234 |
}
|
| - |
|
1235 |
return true; // Scheduled time not reached → stays at bottom
|
| - |
|
1236 |
}
|
| - |
|
1237 |
// NO_ANSWER without scheduledCallTime - use 2 hour logic
|
| 1226 |
if (CollectionRemark.NO_ANSWER.equals(p.getRemark())
|
1238 |
if (CollectionRemark.NO_ANSWER.equals(p.getRemark())
|
| 1227 |
&& p.getRemarkTimestamp().isBefore(twoHoursAgo)) {
|
1239 |
&& p.getRemarkTimestamp().isBefore(twoHoursAgo)) {
|
| 1228 |
return false; // NO_ANSWER older than 2 hours → comes back up
|
1240 |
return false; // NO_ANSWER older than 2 hours → comes back up
|
| - |
|
1241 |
}
|
| 1229 |
}
|
1242 |
}
|
| 1230 |
return true; // Other today's remarks → goes to bottom
|
1243 |
return true; // Other today's remarks → goes to bottom
|
| 1231 |
}) // false → comes first, true → goes to bottom
|
1244 |
}) // false → comes first, true → goes to bottom
|
| 1232 |
.thenComparing(PartnerTargetAchievementModel::getCategoryPriority)
|
1245 |
.thenComparing(PartnerTargetAchievementModel::getCategoryPriority)
|
| 1233 |
.thenComparing(PartnerTargetAchievementModel::getRank)
|
1246 |
.thenComparing(PartnerTargetAchievementModel::getRank)
|