Subversion Repositories SmartDukaan

Rev

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

Rev 33505 Rev 35394
Line 147... Line 147...
147
        Set<Integer> l1Rbms = positionRepository.selectPositionbyCategoryIdAndEscalationType(
147
        Set<Integer> l1Rbms = positionRepository.selectPositionbyCategoryIdAndEscalationType(
148
                ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L1).stream().map(x -> x.getAuthUserId()).collect(Collectors.toSet());
148
                ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L1).stream().map(x -> x.getAuthUserId()).collect(Collectors.toSet());
149
        Set<Integer> l2Rbms = positionRepository.selectPositionbyCategoryIdAndEscalationType(
149
        Set<Integer> l2Rbms = positionRepository.selectPositionbyCategoryIdAndEscalationType(
150
                ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L2).stream().map(x -> x.getAuthUserId()).collect(Collectors.toSet());
150
                ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L2).stream().map(x -> x.getAuthUserId()).collect(Collectors.toSet());
151
 
151
 
-
 
152
        // Batch fetch hygiene counts for all fofoIds at once (performance optimization)
-
 
153
        LocalDateTime hygieneStartDate = curDate.withDayOfMonth(1).minusMonths(1);
-
 
154
        LocalDateTime hygieneEndDate = curDate.plusMonths(1).withDayOfMonth(1);
-
 
155
        Map<Integer, Long> validHygieneCountMap = hygieneDataRepository.selectHygieneCountByFofoIds(fofoIds, true, hygieneStartDate, hygieneEndDate);
-
 
156
        Map<Integer, Long> invalidHygieneCountMap = hygieneDataRepository.selectHygieneCountByFofoIds(fofoIds, false, hygieneStartDate, hygieneEndDate);
-
 
157
 
152
        for (FofoStore store : fofoStores) {
158
        for (FofoStore store : fofoStores) {
153
            int fofoId = store.getId();
159
            int fofoId = store.getId();
154
 
160
 
155
            int hygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
161
            // Use batch-fetched hygiene counts instead of N+1 queries
156
                    curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
162
            int hygieneCount = validHygieneCountMap.getOrDefault(fofoId, 0L).intValue();
157
            int invalidHygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
163
            int invalidHygieneCount = invalidHygieneCountMap.getOrDefault(fofoId, 0L).intValue();
158
                    curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
-
 
159
            int totalHygieneCount = hygieneCount + invalidHygieneCount;
164
            int totalHygieneCount = hygieneCount + invalidHygieneCount;
-
 
165
            // Note: getTypeOnDate is @Cacheable, so repeated calls are fast
160
            PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
166
            PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
161
 
167
 
162
            Map<EscalationType, AuthUser> authuserEsclationTypeMap = csService
168
            Map<EscalationType, AuthUser> authuserEsclationTypeMap = csService
163
                    .getAuthUserAndEsclationByPartnerId(fofoId);
169
                    .getAuthUserAndEsclationByPartnerId(fofoId);
164
            PartnerDetailModel pm = new PartnerDetailModel();
170
            PartnerDetailModel pm = new PartnerDetailModel();