Subversion Repositories SmartDukaan

Rev

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

Rev 35835 Rev 35853
Line 1208... Line 1208...
1208
                tm.setUntouchedCount(categoryCounts.getOrDefault("UNTOUCHED", 0L).intValue());
1208
                tm.setUntouchedCount(categoryCounts.getOrDefault("UNTOUCHED", 0L).intValue());
1209
                tm.setNormalCount(categoryCounts.getOrDefault("NORMAL", 0L).intValue());
1209
                tm.setNormalCount(categoryCounts.getOrDefault("NORMAL", 0L).intValue());
1210
 
1210
 
1211
                // 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
1212
                //          EXCEPT: NO_ANSWER/SCHEDULE_CALL with scheduledCallTime reached → comes back up
1213
                //          EXCEPT: NO_ANSWER without scheduledCallTime older than 2 hours → comes back up
1213
                //          EXCEPT: NO_ANSWER without scheduledCallTime older than 4 hours → comes back up
1214
                //          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)
1215
                //          3) Then by rank
1215
                //          3) Then by rank
1216
                LocalDateTime now = LocalDateTime.now();
1216
                LocalDateTime now = LocalDateTime.now();
1217
                LocalDateTime twoHoursAgo = now.minusHours(2);
1217
                LocalDateTime fourHoursAgo = now.minusHours(4);
1218
                tm.setTargetAchievement(filteredPtams.stream()
1218
                tm.setTargetAchievement(filteredPtams.stream()
1219
                        .sorted(Comparator
1219
                        .sorted(Comparator
1220
                                .comparing((PartnerTargetAchievementModel p) -> {
1220
                                .comparing((PartnerTargetAchievementModel p) -> {
1221
                                    if (p.getRemarkTimestamp() == null) {
1221
                                    if (p.getRemarkTimestamp() == null) {
1222
                                        return false; // No remark → comes first
1222
                                        return false; // No remark → comes first
Line 1232... Line 1232...
1232
                                            if (!p.getScheduledCallTime().isAfter(now)) {
1232
                                            if (!p.getScheduledCallTime().isAfter(now)) {
1233
                                                return false; // Scheduled time reached → comes back up
1233
                                                return false; // Scheduled time reached → comes back up
1234
                                            }
1234
                                            }
1235
                                            return true; // Scheduled time not reached → stays at bottom
1235
                                            return true; // Scheduled time not reached → stays at bottom
1236
                                        }
1236
                                        }
1237
                                        // NO_ANSWER without scheduledCallTime - use 2 hour logic
1237
                                        // NO_ANSWER without scheduledCallTime - use 4 hour logic
1238
                                        if (CollectionRemark.NO_ANSWER.equals(p.getRemark())
1238
                                        if (CollectionRemark.NO_ANSWER.equals(p.getRemark())
1239
                                                && p.getRemarkTimestamp().isBefore(twoHoursAgo)) {
1239
                                                && p.getRemarkTimestamp().isBefore(fourHoursAgo)) {
1240
                                            return false; // NO_ANSWER older than 2 hours → comes back up
1240
                                            return false; // NO_ANSWER older than 4 hours → comes back up
1241
                                        }
1241
                                        }
1242
                                    }
1242
                                    }
1243
                                    return true; // Other today's remarks → goes to bottom
1243
                                    return true; // Other today's remarks → goes to bottom
1244
                                }) // false → comes first, true → goes to bottom
1244
                                }) // false → comes first, true → goes to bottom
1245
                                .thenComparing(PartnerTargetAchievementModel::getCategoryPriority)
1245
                                .thenComparing(PartnerTargetAchievementModel::getCategoryPriority)