| Line 10... |
Line 10... |
| 10 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
10 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 11 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
11 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 12 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
12 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
| 13 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
13 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 14 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
14 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| - |
|
15 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 15 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
16 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
| 16 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
17 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 17 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
18 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 18 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
19 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
| 19 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
20 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| Line 71... |
Line 72... |
| 71 |
AuthRepository authRepository;
|
72 |
AuthRepository authRepository;
|
| 72 |
|
73 |
|
| 73 |
@Autowired
|
74 |
@Autowired
|
| 74 |
PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
75 |
PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| 75 |
|
76 |
|
| - |
|
77 |
@Autowired
|
| - |
|
78 |
PositionRepository positionRepository;
|
| - |
|
79 |
|
| 76 |
@Override
|
80 |
@Override
|
| 77 |
// @Cacheable(value = "partnerStats", cacheManager =
|
81 |
// @Cacheable(value = "partnerStats", cacheManager =
|
| 78 |
// "thirtyMinsTimeOutCacheManager")
|
82 |
// "thirtyMinsTimeOutCacheManager")
|
| 79 |
public Map<Integer, PartnerDetailModel> getAllPartnerStats() throws ProfitMandiBusinessException {
|
83 |
public Map<Integer, PartnerDetailModel> getAllPartnerStats() throws ProfitMandiBusinessException {
|
| 80 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
84 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| Line 129... |
Line 133... |
| 129 |
}).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
133 |
}).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 130 |
|
134 |
|
| 131 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMappingByCategoryIds(Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_RBM), true);
|
135 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMappingByCategoryIds(Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_RBM), true);
|
| 132 |
Map<Integer, AuthUser> authUserMap = authRepository.selectAllAuthUserByIds(storeGuyMap.values().stream().flatMap(x->x.stream()).filter(Utils.distinctByKey(x->x)).collect(Collectors.toList())).stream().collect(Collectors.toMap(x->x.getId(),x->x));
|
136 |
Map<Integer, AuthUser> authUserMap = authRepository.selectAllAuthUserByIds(storeGuyMap.values().stream().flatMap(x->x.stream()).filter(Utils.distinctByKey(x->x)).collect(Collectors.toList())).stream().collect(Collectors.toMap(x->x.getId(),x->x));
|
| 133 |
|
137 |
|
| - |
|
138 |
Set<Integer> l1Rbms = positionRepository.selectPositionbyCategoryIdAndEscalationType(
|
| - |
|
139 |
ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L1).stream().map(x -> x.getAuthUserId()).collect(Collectors.toSet());
|
| - |
|
140 |
|
| 134 |
for (FofoStore store : fofoStores) {
|
141 |
for (FofoStore store : fofoStores) {
|
| 135 |
int fofoId = store.getId();
|
142 |
int fofoId = store.getId();
|
| 136 |
|
143 |
|
| 137 |
int hygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
|
144 |
int hygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
|
| 138 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
|
145 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
|
| Line 173... |
Line 180... |
| 173 |
}
|
180 |
}
|
| 174 |
pm.setTotalHygiene(totalHygieneCount);
|
181 |
pm.setTotalHygiene(totalHygieneCount);
|
| 175 |
|
182 |
|
| 176 |
pm.setTicket(ticketMap.get(fofoId) == null ? 0 : ticketMap.get(fofoId).intValue());
|
183 |
pm.setTicket(ticketMap.get(fofoId) == null ? 0 : ticketMap.get(fofoId).intValue());
|
| 177 |
Set<Integer> rbmUserIds = storeGuyMap.get(fofoId);
|
184 |
Set<Integer> rbmUserIds = storeGuyMap.get(fofoId);
|
| 178 |
if (rbmUserIds == null) {
|
185 |
if (rbmUserIds == null || rbmUserIds.stream().noneMatch(x -> l1Rbms.contains(x))) {
|
| 179 |
pm.setRbms("-");
|
186 |
pm.setRbms("-");
|
| 180 |
} else {
|
187 |
} else {
|
| - |
|
188 |
rbmUserIds = rbmUserIds.stream().filter(x -> l1Rbms.contains(x)).collect(Collectors.toSet());
|
| 181 |
String commaSeperatedRbms = rbmUserIds.stream().map(x->authUserMap.get(x).getFullName()).collect(Collectors.joining(","));
|
189 |
String commaSeperatedRbms = rbmUserIds.stream().map(x->authUserMap.get(x).getFullName()).collect(Collectors.joining(","));
|
| 182 |
pm.setRbms(commaSeperatedRbms);
|
190 |
pm.setRbms(commaSeperatedRbms);
|
| 183 |
}
|
191 |
}
|
| 184 |
allPartnerStats.put(fofoId, pm);
|
192 |
allPartnerStats.put(fofoId, pm);
|
| 185 |
LOGGER.info("pm {}", pm);
|
193 |
LOGGER.info("pm {}", pm);
|