| Line 153... |
Line 153... |
| 153 |
LocalDateTime hygieneStartDate = curDate.withDayOfMonth(1).minusMonths(1);
|
153 |
LocalDateTime hygieneStartDate = curDate.withDayOfMonth(1).minusMonths(1);
|
| 154 |
LocalDateTime hygieneEndDate = curDate.plusMonths(1).withDayOfMonth(1);
|
154 |
LocalDateTime hygieneEndDate = curDate.plusMonths(1).withDayOfMonth(1);
|
| 155 |
Map<Integer, Long> validHygieneCountMap = hygieneDataRepository.selectHygieneCountByFofoIds(fofoIds, true, hygieneStartDate, hygieneEndDate);
|
155 |
Map<Integer, Long> validHygieneCountMap = hygieneDataRepository.selectHygieneCountByFofoIds(fofoIds, true, hygieneStartDate, hygieneEndDate);
|
| 156 |
Map<Integer, Long> invalidHygieneCountMap = hygieneDataRepository.selectHygieneCountByFofoIds(fofoIds, false, hygieneStartDate, hygieneEndDate);
|
156 |
Map<Integer, Long> invalidHygieneCountMap = hygieneDataRepository.selectHygieneCountByFofoIds(fofoIds, false, hygieneStartDate, hygieneEndDate);
|
| 157 |
|
157 |
|
| - |
|
158 |
// Bulk fetch partner types to avoid N+1 queries
|
| - |
|
159 |
Map<Integer, PartnerType> partnerTypeMap = partnerTypeChangeService.getTypesForFofoIds(new ArrayList<>(fofoIds), LocalDate.now());
|
| - |
|
160 |
|
| 158 |
for (FofoStore store : fofoStores) {
|
161 |
for (FofoStore store : fofoStores) {
|
| 159 |
int fofoId = store.getId();
|
162 |
int fofoId = store.getId();
|
| 160 |
|
163 |
|
| 161 |
// Use batch-fetched hygiene counts instead of N+1 queries
|
164 |
// Use batch-fetched hygiene counts instead of N+1 queries
|
| 162 |
int hygieneCount = validHygieneCountMap.getOrDefault(fofoId, 0L).intValue();
|
165 |
int hygieneCount = validHygieneCountMap.getOrDefault(fofoId, 0L).intValue();
|
| 163 |
int invalidHygieneCount = invalidHygieneCountMap.getOrDefault(fofoId, 0L).intValue();
|
166 |
int invalidHygieneCount = invalidHygieneCountMap.getOrDefault(fofoId, 0L).intValue();
|
| 164 |
int totalHygieneCount = hygieneCount + invalidHygieneCount;
|
167 |
int totalHygieneCount = hygieneCount + invalidHygieneCount;
|
| 165 |
// Note: getTypeOnDate is @Cacheable, so repeated calls are fast
|
- |
|
| 166 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
|
168 |
PartnerType partnerType = partnerTypeMap.get(fofoId);
|
| 167 |
|
169 |
|
| 168 |
Map<EscalationType, AuthUser> authuserEsclationTypeMap = csService
|
170 |
Map<EscalationType, AuthUser> authuserEsclationTypeMap = csService
|
| 169 |
.getAuthUserAndEsclationByPartnerId(fofoId);
|
171 |
.getAuthUserAndEsclationByPartnerId(fofoId);
|
| 170 |
PartnerDetailModel pm = new PartnerDetailModel();
|
172 |
PartnerDetailModel pm = new PartnerDetailModel();
|
| 171 |
pm.setFofoId(fofoId);
|
173 |
pm.setFofoId(fofoId);
|