| Line 63... |
Line 63... |
| 63 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
63 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
| 64 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
64 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 65 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
65 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 66 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
66 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
| 67 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
67 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| - |
|
68 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
| 68 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
69 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| - |
|
70 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
|
| - |
|
71 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
| 69 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
72 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
| 70 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
73 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
| 71 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
74 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 72 |
import com.spice.profitmandi.dao.repository.auth.MenuCategoryRepository;
|
75 |
import com.spice.profitmandi.dao.repository.auth.MenuCategoryRepository;
|
| 73 |
import com.spice.profitmandi.dao.repository.auth.MenuRepository;
|
76 |
import com.spice.profitmandi.dao.repository.auth.MenuRepository;
|
| 74 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
77 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| - |
|
78 |
import com.spice.profitmandi.dao.repository.cs.PartnersPositionRepository;
|
| 75 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
79 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 76 |
import com.spice.profitmandi.dao.repository.cs.TicketCategoryRepository;
|
80 |
import com.spice.profitmandi.dao.repository.cs.TicketCategoryRepository;
|
| - |
|
81 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
| 77 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
82 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
| 78 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
83 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| - |
|
84 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
| 79 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
85 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 80 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
86 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
| 81 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
87 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 82 |
import com.spice.profitmandi.dao.repository.dtr.UserCampaignRepository;
|
88 |
import com.spice.profitmandi.dao.repository.dtr.UserCampaignRepository;
|
| 83 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
89 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| Line 177... |
Line 183... |
| 177 |
|
183 |
|
| 178 |
@Autowired
|
184 |
@Autowired
|
| 179 |
private PositionRepository positionRepository;
|
185 |
private PositionRepository positionRepository;
|
| 180 |
|
186 |
|
| 181 |
@Autowired
|
187 |
@Autowired
|
| - |
|
188 |
private PartnersPositionRepository partnerPositionRepository;
|
| - |
|
189 |
|
| - |
|
190 |
@Autowired
|
| 182 |
private UserAccountRepository userAccountRepository;
|
191 |
private UserAccountRepository userAccountRepository;
|
| 183 |
|
192 |
|
| 184 |
@Autowired
|
193 |
@Autowired
|
| 185 |
private NotificationCampaignRepository notificationCampaignRepository;
|
194 |
private NotificationCampaignRepository notificationCampaignRepository;
|
| 186 |
|
195 |
|
| Line 194... |
Line 203... |
| 194 |
private FofoOrderRepository fofoOrderRepository;
|
203 |
private FofoOrderRepository fofoOrderRepository;
|
| 195 |
|
204 |
|
| 196 |
@Autowired
|
205 |
@Autowired
|
| 197 |
private Gson gson;
|
206 |
private Gson gson;
|
| 198 |
|
207 |
|
| - |
|
208 |
@Autowired
|
| - |
|
209 |
TicketRepository ticketRepository;
|
| - |
|
210 |
|
| - |
|
211 |
@Autowired
|
| - |
|
212 |
private LeadRepository leadRepository;
|
| - |
|
213 |
|
| 199 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
214 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 200 |
|
215 |
|
| 201 |
@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
|
216 |
@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
|
| 202 |
public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
|
217 |
public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
|
| 203 |
boolean isAdmin = false;
|
218 |
boolean isAdmin = false;
|
| Line 544... |
Line 559... |
| 544 |
|
559 |
|
| 545 |
return cm;
|
560 |
return cm;
|
| 546 |
|
561 |
|
| 547 |
}
|
562 |
}
|
| 548 |
|
563 |
|
| 549 |
private String adminPanel(int fofoId, String email, Model model) throws ProfitMandiBusinessException {
|
564 |
private String adminPanel(int fofoId, String email, Model model) throws Exception {
|
| 550 |
List<Menu> menus = null;
|
565 |
List<Menu> menus = null;
|
| 551 |
try {
|
566 |
try {
|
| 552 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
567 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
| 553 |
List<Position> positions = positionRepository.selectAll(authUser.getId());
|
568 |
List<Position> positions = positionRepository.selectAll(authUser.getId());
|
| - |
|
569 |
Map<Integer, AuthUser> authIdAndAuthUserMap = null;
|
| - |
|
570 |
Map<Integer, Object> authIdAndallValues = null;
|
| - |
|
571 |
if (positions.size() > 0) {
|
| - |
|
572 |
if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L3)).count() > 0) {
|
| - |
|
573 |
|
| - |
|
574 |
authIdAndAuthUserMap = authRepository.selectAllActiveUser().stream()
|
| - |
|
575 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
576 |
|
| - |
|
577 |
authIdAndallValues = csService.getL2AuthUserPartnerDetail();
|
| - |
|
578 |
|
| - |
|
579 |
LOGGER.info("authIdAndallValues" + authIdAndallValues);
|
| - |
|
580 |
}
|
| - |
|
581 |
}
|
| - |
|
582 |
|
| 554 |
if (Arrays.asList("amit.gupta@shop2020.in", "tejbeer.kaur@shop2020.in").contains(email)) {
|
583 |
if (Arrays.asList("amit.gupta@shop2020.in", "tejbeer.kaur@shop2020.in").contains(email)) {
|
| 555 |
menus = menuRepository.selectAll();
|
584 |
menus = menuRepository.selectAll();
|
| 556 |
} else if (positions.size() > 0) {
|
585 |
} else if (positions.size() > 0) {
|
| 557 |
if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L4)).count() > 0) {
|
586 |
if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L4)).count() > 0) {
|
| 558 |
menus = menuRepository.selectAll();
|
587 |
menus = menuRepository.selectAll();
|
| Line 589... |
Line 618... |
| 589 |
model.addAttribute("warehouses", getWarehouses(positionRetailers));
|
618 |
model.addAttribute("warehouses", getWarehouses(positionRetailers));
|
| 590 |
}
|
619 |
}
|
| 591 |
model.addAttribute("authId", authUser.getId());
|
620 |
model.addAttribute("authId", authUser.getId());
|
| 592 |
|
621 |
|
| 593 |
}
|
622 |
}
|
| - |
|
623 |
model.addAttribute("authIdAndallValues", authIdAndallValues);
|
| - |
|
624 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| - |
|
625 |
|
| - |
|
626 |
LOGGER.info("authIdAndallValues1" + authIdAndallValues);
|
| 594 |
} catch (ProfitMandiBusinessException e) {
|
627 |
} catch (ProfitMandiBusinessException e) {
|
| 595 |
}
|
628 |
}
|
| 596 |
List<Menu> menuList = (menus != null) ? this.prepareMenu(menus) : new ArrayList<>();
|
629 |
List<Menu> menuList = (menus != null) ? this.prepareMenu(menus) : new ArrayList<>();
|
| 597 |
|
630 |
|
| 598 |
model.addAttribute("menu", menuList);
|
631 |
model.addAttribute("menu", menuList);
|
| 599 |
return "admin";
|
632 |
return "admin";
|
| 600 |
}
|
633 |
}
|
| 601 |
|
634 |
|
| - |
|
635 |
@RequestMapping(value = "/getL1AuthUser", method = RequestMethod.GET)
|
| - |
|
636 |
public String L1AuthUsersDetail(HttpServletRequest request, Model model, @RequestParam int authId)
|
| - |
|
637 |
throws Exception {
|
| - |
|
638 |
|
| - |
|
639 |
Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
|
| - |
|
640 |
|
| - |
|
641 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
642 |
Map<Integer, Double> lmtdSale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(
|
| - |
|
643 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), 0, false);
|
| - |
|
644 |
Map<Integer, Double> mtdSale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(curDate.withDayOfMonth(1),
|
| - |
|
645 |
curDate.with(LocalTime.MAX), 0, false);
|
| - |
|
646 |
Map<Integer, List<Integer>> L2L1Mapping = csService.getL1L2Mapping();
|
| - |
|
647 |
|
| - |
|
648 |
LOGGER.info("L2L1Mapping" + L2L1Mapping);
|
| - |
|
649 |
List<Integer> l1authIds = L2L1Mapping.get(authId);
|
| - |
|
650 |
|
| - |
|
651 |
Map<Integer, Object> authIdAndallValues = new LinkedHashMap<>();
|
| - |
|
652 |
Map<Integer, Object> authIdAndAuthUserMap = new LinkedHashMap<>();
|
| - |
|
653 |
|
| - |
|
654 |
Map<Integer, Long> ticketMap = ticketRepository.selectAllNotClosedTicketsGroupByRetailer();
|
| - |
|
655 |
for (Integer auth : l1authIds) {
|
| - |
|
656 |
|
| - |
|
657 |
double totallmtdAmount = 0;
|
| - |
|
658 |
double totalmtdAmount = 0;
|
| - |
|
659 |
int totalTicketCount = 0;
|
| - |
|
660 |
float totalTodayInvestment = 0;
|
| - |
|
661 |
float totalStockInInvestment = 0;
|
| - |
|
662 |
double currentMonthRatingAllPartners = 0;
|
| - |
|
663 |
Map<Integer, Long> leadCount = leadRepository.selectByAssignAuthIdAndStatus(auth, LeadStatus.followUp)
|
| - |
|
664 |
.stream().collect(Collectors.groupingBy(Lead::getAssignTo, Collectors.counting()));
|
| - |
|
665 |
|
| - |
|
666 |
AuthUser authUser = authRepository.selectById(auth);
|
| - |
|
667 |
|
| - |
|
668 |
authIdAndAuthUserMap.put(auth, authUser);
|
| - |
|
669 |
|
| - |
|
670 |
List<Integer> fofoIds = pp.get(auth);
|
| - |
|
671 |
|
| - |
|
672 |
for (Integer fId : fofoIds) {
|
| - |
|
673 |
Map<String, Object> investmentMap = this.getInvestments(fId);
|
| - |
|
674 |
|
| - |
|
675 |
double currentMonthRating = hygieneDataRepository.selectRatingAvg(fId,
|
| - |
|
676 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
|
| - |
|
677 |
|
| - |
|
678 |
currentMonthRatingAllPartners += currentMonthRating;
|
| - |
|
679 |
|
| - |
|
680 |
fofoIds.size();
|
| - |
|
681 |
|
| - |
|
682 |
Double lmtdAmount = lmtdSale.get(fId);
|
| - |
|
683 |
Double mtdAmount = mtdSale.get(fId);
|
| - |
|
684 |
Long ticketCount = ticketMap.get(fId);
|
| - |
|
685 |
|
| - |
|
686 |
if (!investmentMap.isEmpty()) {
|
| - |
|
687 |
totalTodayInvestment += (float) investmentMap.get("today");
|
| - |
|
688 |
totalStockInInvestment += (float) investmentMap.get("inStock");
|
| - |
|
689 |
|
| - |
|
690 |
}
|
| - |
|
691 |
LOGGER.info("totalTodayInvestment" + totalTodayInvestment);
|
| - |
|
692 |
LOGGER.info("totalStockInInvestment" + totalStockInInvestment);
|
| - |
|
693 |
if (ticketCount != null) {
|
| - |
|
694 |
totalTicketCount += ticketCount;
|
| - |
|
695 |
}
|
| - |
|
696 |
|
| - |
|
697 |
if (lmtdAmount != null) {
|
| - |
|
698 |
totallmtdAmount += lmtdAmount;
|
| - |
|
699 |
}
|
| - |
|
700 |
|
| - |
|
701 |
if (mtdAmount != null) {
|
| - |
|
702 |
totalmtdAmount += mtdAmount;
|
| - |
|
703 |
}
|
| - |
|
704 |
|
| - |
|
705 |
}
|
| - |
|
706 |
LOGGER.info("currentMonthRatingAllPartners" + currentMonthRatingAllPartners);
|
| - |
|
707 |
LOGGER.info("size" + fofoIds.size());
|
| - |
|
708 |
double totalHygieneRating = currentMonthRatingAllPartners / fofoIds.size();
|
| - |
|
709 |
|
| - |
|
710 |
LOGGER.info("totalHygieneRating" + totalHygieneRating);
|
| - |
|
711 |
|
| - |
|
712 |
PartnerDetailModel pm = new PartnerDetailModel();
|
| - |
|
713 |
pm.setLmtd(totallmtdAmount);
|
| - |
|
714 |
pm.setMtd(totalmtdAmount);
|
| - |
|
715 |
if (leadCount.get(auth) != null) {
|
| - |
|
716 |
pm.setLeads(leadCount.get(auth).intValue());
|
| - |
|
717 |
} else {
|
| - |
|
718 |
pm.setLeads(0);
|
| - |
|
719 |
}
|
| - |
|
720 |
|
| - |
|
721 |
pm.setInvestment(totalTodayInvestment);
|
| - |
|
722 |
pm.setStockInInvestment(totalStockInInvestment);
|
| - |
|
723 |
pm.setTicket(totalTicketCount);
|
| - |
|
724 |
pm.setHygiene((double) Math.round(totalHygieneRating));
|
| - |
|
725 |
authIdAndallValues.put(auth, pm);
|
| - |
|
726 |
|
| - |
|
727 |
}
|
| - |
|
728 |
model.addAttribute("authIdAndallValues", authIdAndallValues);
|
| - |
|
729 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| - |
|
730 |
LOGGER.info("authIdAndallValues" + authIdAndallValues);
|
| - |
|
731 |
|
| - |
|
732 |
return "auth_user_detail";
|
| - |
|
733 |
}
|
| - |
|
734 |
|
| - |
|
735 |
@RequestMapping(value = "/getAuthUserPartners", method = RequestMethod.GET)
|
| - |
|
736 |
public String AuthUserPartnersDetail(HttpServletRequest request, Model model, @RequestParam int authId)
|
| - |
|
737 |
throws Exception {
|
| - |
|
738 |
|
| - |
|
739 |
Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
|
| - |
|
740 |
List<Integer> fofoIds = pp.get(authId);
|
| - |
|
741 |
Map<Integer, Long> ticketMap = ticketRepository.selectAllNotClosedTicketsGroupByRetailer();
|
| - |
|
742 |
Map<Integer, Object> fofoIdAndallValues = new LinkedHashMap<>();
|
| - |
|
743 |
Map<Integer, Object> fofoIdAndPartnerMap = new LinkedHashMap<>();
|
| - |
|
744 |
for (Integer fofoId : fofoIds) {
|
| - |
|
745 |
|
| - |
|
746 |
CustomRetailer cr = retailerService.getFofoRetailer(fofoId);
|
| - |
|
747 |
fofoIdAndPartnerMap.put(fofoId, cr);
|
| - |
|
748 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
749 |
Double lmtdSale = fofoOrderItemRepository
|
| - |
|
750 |
.selectSumAmountGroupByRetailer(curDate.withDayOfMonth(1).minusMonths(1),
|
| - |
|
751 |
curDate.with(LocalTime.MAX).minusMonths(1), fofoId, false)
|
| - |
|
752 |
.get(fofoId);
|
| - |
|
753 |
Double mtdSale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(curDate.withDayOfMonth(1),
|
| - |
|
754 |
curDate.with(LocalTime.MAX), fofoId, false).get(fofoId);
|
| - |
|
755 |
Map<String, Object> investmentMap = this.getInvestments(fofoId);
|
| - |
|
756 |
double currentMonthRating = hygieneDataRepository.selectRatingAvg(fofoId,
|
| - |
|
757 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
|
| - |
|
758 |
|
| - |
|
759 |
Long ticketCount = ticketMap.get(fofoId);
|
| - |
|
760 |
|
| - |
|
761 |
float totalTodayInvestment = (float) investmentMap.get("today");
|
| - |
|
762 |
float totalStockInInvestment = (float) investmentMap.get("inStock");
|
| - |
|
763 |
|
| - |
|
764 |
PartnerDetailModel pm = new PartnerDetailModel();
|
| - |
|
765 |
pm.setLmtd(lmtdSale);
|
| - |
|
766 |
pm.setMtd(mtdSale);
|
| - |
|
767 |
pm.setInvestment(totalTodayInvestment);
|
| - |
|
768 |
pm.setStockInInvestment(totalStockInInvestment);
|
| - |
|
769 |
if (ticketCount != null) {
|
| - |
|
770 |
pm.setTicket(ticketCount.intValue());
|
| - |
|
771 |
} else {
|
| - |
|
772 |
pm.setTicket(0);
|
| - |
|
773 |
}
|
| - |
|
774 |
pm.setHygiene((double) Math.round(currentMonthRating));
|
| - |
|
775 |
fofoIdAndallValues.put(fofoId, pm);
|
| - |
|
776 |
}
|
| - |
|
777 |
|
| - |
|
778 |
model.addAttribute("fofoIdAndallValues", fofoIdAndallValues);
|
| - |
|
779 |
model.addAttribute("fofoIdAndPartnerMap", fofoIdAndPartnerMap);
|
| - |
|
780 |
|
| - |
|
781 |
return "auth_user_partner_detail";
|
| - |
|
782 |
}
|
| - |
|
783 |
|
| 602 |
private String getWarehouses(Set<CustomRetailer> positionRetailers) {
|
784 |
private String getWarehouses(Set<CustomRetailer> positionRetailers) {
|
| 603 |
Map<Integer, String> warehouses = new HashMap<>();
|
785 |
Map<Integer, String> warehouses = new HashMap<>();
|
| 604 |
positionRetailers.stream().forEach(x -> {
|
786 |
positionRetailers.stream().forEach(x -> {
|
| 605 |
if (x.getWarehouseId() != 0) {
|
787 |
if (x.getWarehouseId() != 0) {
|
| 606 |
warehouses.put(x.getWarehouseId(), ProfitMandiConstants.WAREHOUSE_MAP.get(x.getWarehouseId()));
|
788 |
warehouses.put(x.getWarehouseId(), ProfitMandiConstants.WAREHOUSE_MAP.get(x.getWarehouseId()));
|