| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.service;
|
1 |
package com.spice.profitmandi.service;
|
| 2 |
|
2 |
|
| 3 |
import java.time.LocalDate;
|
3 |
import java.time.LocalDate;
|
| 4 |
import java.time.LocalDateTime;
|
4 |
import java.time.LocalDateTime;
|
| 5 |
import java.time.LocalTime;
|
5 |
import java.time.LocalTime;
|
| 6 |
import java.util.ArrayList;
|
- |
|
| 7 |
import java.util.HashMap;
|
6 |
import java.util.HashMap;
|
| 8 |
import java.util.List;
|
7 |
import java.util.List;
|
| 9 |
import java.util.Map;
|
8 |
import java.util.Map;
|
| 10 |
import java.util.stream.Collectors;
|
9 |
import java.util.stream.Collectors;
|
| 11 |
|
10 |
|
| Line 14... |
Line 13... |
| 14 |
import org.springframework.beans.factory.annotation.Autowired;
|
13 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 15 |
import org.springframework.cache.annotation.Cacheable;
|
14 |
import org.springframework.cache.annotation.Cacheable;
|
| 16 |
import org.springframework.stereotype.Component;
|
15 |
import org.springframework.stereotype.Component;
|
| 17 |
|
16 |
|
| 18 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
17 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
18 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 19 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
19 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 20 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
20 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
| 21 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
21 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 22 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
22 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
| - |
|
23 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 23 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
24 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 24 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
25 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
| 25 |
import com.spice.profitmandi.service.user.RetailerService;
|
26 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 26 |
|
27 |
|
| 27 |
@Component
|
28 |
@Component
|
| Line 31... |
Line 32... |
| 31 |
|
32 |
|
| 32 |
@Autowired
|
33 |
@Autowired
|
| 33 |
RetailerService retailerService;
|
34 |
RetailerService retailerService;
|
| 34 |
|
35 |
|
| 35 |
@Autowired
|
36 |
@Autowired
|
| - |
|
37 |
FofoStoreRepository fofoStoreRepository;
|
| - |
|
38 |
|
| - |
|
39 |
@Autowired
|
| 36 |
FofoOrderItemRepository fofoOrderItemRepository;
|
40 |
FofoOrderItemRepository fofoOrderItemRepository;
|
| 37 |
|
41 |
|
| 38 |
@Autowired
|
42 |
@Autowired
|
| 39 |
CsService csService;
|
43 |
CsService csService;
|
| 40 |
|
44 |
|
| Line 56... |
Line 60... |
| 56 |
Map<Integer, Double> mtdSale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(curDate.withDayOfMonth(1),
|
60 |
Map<Integer, Double> mtdSale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(curDate.withDayOfMonth(1),
|
| 57 |
curDate.with(LocalTime.MAX), 0, false);
|
61 |
curDate.with(LocalTime.MAX), 0, false);
|
| 58 |
|
62 |
|
| 59 |
Map<Integer, Long> ticketMap = ticketRepository.selectAllOpenTicketsGroupByRetailer();
|
63 |
Map<Integer, Long> ticketMap = ticketRepository.selectAllOpenTicketsGroupByRetailer();
|
| 60 |
|
64 |
|
| 61 |
Map<Integer, String> fofoRetailerMap = retailerService.getAllFofoRetailerIdNameMap();
|
65 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
| 62 |
Map<Integer, PartnerDetailModel> allPartnerStats = new HashMap<>();
|
66 |
Map<Integer, PartnerDetailModel> allPartnerStats = new HashMap<>();
|
| 63 |
|
67 |
|
| 64 |
Map<Integer, PartnerDailyInvestment> investmentMap = fofoRetailerMap.keySet().stream()
|
68 |
Map<Integer, PartnerDailyInvestment> investmentMap = fofoStores.stream()
|
| 65 |
.map(x-> {
|
69 |
.map(x-> {
|
| 66 |
PartnerDailyInvestment pdi = new PartnerDailyInvestment();
|
70 |
PartnerDailyInvestment pdi = new PartnerDailyInvestment();
|
| 67 |
pdi.setFofoId(x);
|
71 |
pdi.setFofoId(x.getId());
|
| 68 |
return pdi;
|
72 |
return pdi;
|
| 69 |
})
|
73 |
})
|
| 70 |
/*.map(x->{
|
74 |
/*.map(x->{
|
| 71 |
try {
|
75 |
try {
|
| 72 |
return partnerInvestmentService.getInvestment(x,0);
|
76 |
return partnerInvestmentService.getInvestment(x,0);
|
| Line 75... |
Line 79... |
| 75 |
return new PartnerDailyInvestment();
|
79 |
return new PartnerDailyInvestment();
|
| 76 |
}
|
80 |
}
|
| 77 |
})*/
|
81 |
})*/
|
| 78 |
.collect(Collectors.toMap(x->x.getFofoId(), x->x));
|
82 |
.collect(Collectors.toMap(x->x.getFofoId(), x->x));
|
| 79 |
|
83 |
|
| - |
|
84 |
for (FofoStore store: fofoStores) {
|
| 80 |
for (int fofoId : fofoRetailerMap.keySet()) {
|
85 |
int fofoId = store.getId();
|
| 81 |
int hygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
|
86 |
int hygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
|
| 82 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
|
87 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
|
| 83 |
int invalidHygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
|
88 |
int invalidHygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
|
| 84 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
|
89 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
|
| 85 |
int totalHygieneCount = hygieneCount + invalidHygieneCount;
|
90 |
int totalHygieneCount = hygieneCount + invalidHygieneCount;
|