Subversion Repositories SmartDukaan

Rev

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

Rev 26460 Rev 26468
Line 121... Line 121...
121
	@Value("${web.api.port}")
121
	@Value("${web.api.port}")
122
	private int webApiPort;
122
	private int webApiPort;
123
 
123
 
124
	@Autowired
124
	@Autowired
125
	private CookiesProcessor cookiesProcessor;
125
	private CookiesProcessor cookiesProcessor;
126
	
126
 
127
	@Autowired
127
	@Autowired
128
	private PartnerStatsService partnerStatsService;
128
	private PartnerStatsService partnerStatsService;
129
 
129
 
130
	@Autowired
130
	@Autowired
131
	private MenuRepository menuRepository;
131
	private MenuRepository menuRepository;
Line 576... Line 576...
576
			if (positions.size() > 0) {
576
			if (positions.size() > 0) {
577
				if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L3)).count() > 0) {
577
				if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L3)).count() > 0) {
578
 
578
 
579
					authIdAndAuthUserMap = authRepository.selectAllActiveUser().stream()
579
					authIdAndAuthUserMap = authRepository.selectAllActiveUser().stream()
580
							.collect(Collectors.toMap(x -> x.getId(), x -> x));
580
							.collect(Collectors.toMap(x -> x.getId(), x -> x));
-
 
581
					
-
 
582
					AuthUser dummyAuthUser = new AuthUser();
-
 
583
					dummyAuthUser.setFirstName("Total");
-
 
584
					dummyAuthUser.setLastName("Values");
-
 
585
					authIdAndAuthUserMap.put(0, dummyAuthUser);
581
 
586
 
582
					authIdAndallValues = this.getL2AuthUserPartnerDetail();
587
					authIdAndallValues = this.getL2AuthUserPartnerDetail();
583
				}
588
				}
584
			}
589
			}
585
 
590
 
Line 633... Line 638...
633
		LOGGER.info("menu" + menuList);
638
		LOGGER.info("menu" + menuList);
634
		model.addAttribute("menu", menuList);
639
		model.addAttribute("menu", menuList);
635
		return "admin";
640
		return "admin";
636
	}
641
	}
637
 
642
 
-
 
643
	/*
638
/*	@RequestMapping(value = "/getL1AuthUser", method = RequestMethod.GET)
644
	 * @RequestMapping(value = "/getL1AuthUser", method = RequestMethod.GET) public
639
	public String L1AuthUsersDetail(HttpServletRequest request, Model model, @RequestParam int authId)
645
	 * String L1AuthUsersDetail(HttpServletRequest request, Model
640
			throws Exception {
646
	 * model, @RequestParam int authId) throws Exception {
641
 
647
	 * 
642
		Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
648
	 * Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
643
 
649
	 * 
644
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
650
	 * LocalDateTime curDate = LocalDate.now().atStartOfDay(); Map<Integer, Double>
645
		Map<Integer, Double> lmtdSale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(
651
	 * lmtdSale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(
-
 
652
	 * curDate.withDayOfMonth(1).minusMonths(1),
646
				curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), 0, false);
653
	 * curDate.with(LocalTime.MAX).minusMonths(1), 0, false); Map<Integer, Double>
-
 
654
	 * mtdSale =
647
		Map<Integer, Double> mtdSale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(curDate.withDayOfMonth(1),
655
	 * fofoOrderItemRepository.selectSumAmountGroupByRetailer(curDate.withDayOfMonth
648
				curDate.with(LocalTime.MAX), 0, false);
656
	 * (1), curDate.with(LocalTime.MAX), 0, false); Map<Integer, List<Integer>>
649
		Map<Integer, List<Integer>> L2L1Mapping = csService.getL1L2Mapping();
657
	 * L2L1Mapping = csService.getL1L2Mapping();
650
 
658
	 * 
651
		LOGGER.info("L2L1Mapping" + L2L1Mapping);
659
	 * LOGGER.info("L2L1Mapping" + L2L1Mapping); List<Integer> l1authIds =
652
		List<Integer> l1authIds = L2L1Mapping.get(authId);
660
	 * L2L1Mapping.get(authId);
653
 
661
	 * 
654
		Map<Integer, Object> authIdAndallValues = new LinkedHashMap<>();
662
	 * Map<Integer, Object> authIdAndallValues = new LinkedHashMap<>(); Map<Integer,
655
		Map<Integer, Object> authIdAndAuthUserMap = new LinkedHashMap<>();
663
	 * Object> authIdAndAuthUserMap = new LinkedHashMap<>();
656
 
664
	 * 
-
 
665
	 * Map<Integer, Long> ticketMap =
657
		Map<Integer, Long> ticketMap = ticketRepository.selectAllNotClosedTicketsGroupByRetailer();
666
	 * ticketRepository.selectAllNotClosedTicketsGroupByRetailer(); for (Integer
658
		for (Integer l1AuthId : l1authIds) {
667
	 * l1AuthId : l1authIds) {
659
 
668
	 * 
660
			double totallmtdAmount = 0;
669
	 * double totallmtdAmount = 0; double totalmtdAmount = 0; int totalTicketCount =
661
			double totalmtdAmount = 0;
-
 
662
			int totalTicketCount = 0;
-
 
663
			float totalTodayInvestment = 0;
-
 
664
			float totalStockInInvestment = 0;
670
	 * 0; float totalTodayInvestment = 0; float totalStockInInvestment = 0; double
665
			double currentMonthRatingAllPartners = 0;
671
	 * currentMonthRatingAllPartners = 0; Map<Integer, Long> leadCount =
666
			Map<Integer, Long> leadCount = leadRepository.selectByAssignAuthIdAndStatus(l1AuthId, LeadStatus.followUp)
672
	 * leadRepository.selectByAssignAuthIdAndStatus(l1AuthId, LeadStatus.followUp)
667
					.stream().collect(Collectors.groupingBy(Lead::getAssignTo, Collectors.counting()));
673
	 * .stream().collect(Collectors.groupingBy(Lead::getAssignTo,
-
 
674
	 * Collectors.counting()));
668
 
675
	 * 
669
			AuthUser authUser = authRepository.selectById(l1AuthId);
676
	 * AuthUser authUser = authRepository.selectById(l1AuthId);
670
 
677
	 * 
671
			authIdAndAuthUserMap.put(l1AuthId, authUser);
678
	 * authIdAndAuthUserMap.put(l1AuthId, authUser);
672
 
679
	 * 
673
			List<Integer> fofoIds = pp.get(l1AuthId);
680
	 * List<Integer> fofoIds = pp.get(l1AuthId);
674
 
681
	 * 
675
			Map<Integer, PartnerDailyInvestment> partnerInvestentMap = partnerInvestmentService
682
	 * Map<Integer, PartnerDailyInvestment> partnerInvestentMap =
-
 
683
	 * partnerInvestmentService .getInvestment(fofoIds,
676
					.getInvestment(fofoIds, 0).stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
684
	 * 0).stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
677
 
-
 
678
			for (Integer fId : fofoIds) {
-
 
679
				try {
685
	 * 
680
					PartnerDailyInvestment investment = partnerInvestentMap.get(fId);
686
	 * for (Integer fId : fofoIds) { try { PartnerDailyInvestment investment =
681
					totalTodayInvestment += investment.getTotalInvestment();
687
	 * partnerInvestentMap.get(fId); totalTodayInvestment +=
682
					totalStockInInvestment += investment.getInStockAmount();
688
	 * investment.getTotalInvestment(); totalStockInInvestment +=
683
				} catch (Exception e) {
689
	 * investment.getInStockAmount(); } catch (Exception e) { }
684
				}
690
	 * 
685
 
-
 
686
				double currentMonthRating = hygieneDataRepository.selectRatingAvg(fId,
691
	 * double currentMonthRating = hygieneDataRepository.selectRatingAvg(fId,
-
 
692
	 * curDate.withDayOfMonth(1).minusMonths(1),
687
						curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
693
	 * curDate.plusMonths(1).withDayOfMonth(1));
688
 
694
	 * 
689
				currentMonthRatingAllPartners += currentMonthRating;
695
	 * currentMonthRatingAllPartners += currentMonthRating;
690
 
696
	 * 
691
				fofoIds.size();
697
	 * fofoIds.size();
692
 
698
	 * 
693
				Double lmtdAmount = lmtdSale.get(fId);
699
	 * Double lmtdAmount = lmtdSale.get(fId); Double mtdAmount = mtdSale.get(fId);
694
				Double mtdAmount = mtdSale.get(fId);
-
 
695
				Long ticketCount = ticketMap.get(fId);
700
	 * Long ticketCount = ticketMap.get(fId); if (ticketCount != null) {
696
				if (ticketCount != null) {
-
 
697
					totalTicketCount += ticketCount;
701
	 * totalTicketCount += ticketCount; }
698
				}
702
	 * 
699
 
-
 
700
				if (lmtdAmount != null) {
-
 
701
					totallmtdAmount += lmtdAmount;
703
	 * if (lmtdAmount != null) { totallmtdAmount += lmtdAmount; }
702
				}
704
	 * 
703
 
-
 
704
				if (mtdAmount != null) {
-
 
705
					totalmtdAmount += mtdAmount;
705
	 * if (mtdAmount != null) { totalmtdAmount += mtdAmount; }
706
				}
-
 
707
 
-
 
708
			}
706
	 * 
709
			LOGGER.info("currentMonthRatingAllPartners" + currentMonthRatingAllPartners);
707
	 * } LOGGER.info("currentMonthRatingAllPartners" +
710
			LOGGER.info("size" + fofoIds.size());
708
	 * currentMonthRatingAllPartners); LOGGER.info("size" + fofoIds.size()); double
711
			double totalHygieneRating = currentMonthRatingAllPartners / fofoIds.size();
709
	 * totalHygieneRating = currentMonthRatingAllPartners / fofoIds.size();
712
 
710
	 * 
713
			LOGGER.info("totalHygieneRating" + totalHygieneRating);
711
	 * LOGGER.info("totalHygieneRating" + totalHygieneRating);
714
 
712
	 * 
715
			PartnerDetailModel pm = new PartnerDetailModel();
713
	 * PartnerDetailModel pm = new PartnerDetailModel();
716
			pm.setLmtd(totallmtdAmount);
714
	 * pm.setLmtd(totallmtdAmount); pm.setMtd(totalmtdAmount); if
717
			pm.setMtd(totalmtdAmount);
-
 
718
			if (leadCount.get(l1AuthId) != null) {
715
	 * (leadCount.get(l1AuthId) != null) {
719
				pm.setLeads(leadCount.get(l1AuthId).intValue());
716
	 * pm.setLeads(leadCount.get(l1AuthId).intValue()); } else { pm.setLeads(0); }
720
			} else {
-
 
721
				pm.setLeads(0);
-
 
722
			}
717
	 * 
723
 
-
 
724
			pm.setInvestment(totalTodayInvestment);
718
	 * pm.setInvestment(totalTodayInvestment);
725
			pm.setStockInInvestment(totalStockInInvestment);
719
	 * pm.setStockInInvestment(totalStockInInvestment);
726
			pm.setTicket(totalTicketCount);
720
	 * pm.setTicket(totalTicketCount); pm.setHygiene((double)
727
			pm.setHygiene((double) Math.round(totalHygieneRating));
-
 
728
			authIdAndallValues.put(l1AuthId, pm);
721
	 * Math.round(totalHygieneRating)); authIdAndallValues.put(l1AuthId, pm);
729
 
-
 
730
		}
722
	 * 
731
		model.addAttribute("authIdAndallValues", authIdAndallValues);
723
	 * } model.addAttribute("authIdAndallValues", authIdAndallValues);
732
		model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
724
	 * model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
733
		LOGGER.info("authIdAndallValues" + authIdAndallValues);
725
	 * LOGGER.info("authIdAndallValues" + authIdAndallValues);
734
 
726
	 * 
735
		return "auth_user_detail";
727
	 * return "auth_user_detail"; }
736
	}*/
728
	 */
737
 
729
 
738
/*	@RequestMapping(value = "/getAuthUserPartners", method = RequestMethod.GET)
730
	@RequestMapping(value = "/getAuthUserPartners", method = RequestMethod.GET)
739
	public String AuthUserPartnersDetail(HttpServletRequest request, Model model, @RequestParam int authId)
731
	public String AuthUserPartnersDetail(HttpServletRequest request, Model model, @RequestParam int authId)
740
			throws Exception {
732
			throws Exception {
741
 
733
 
742
		Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
734
		Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
743
		List<Integer> fofoIds = pp.get(authId);
-
 
744
		Map<Integer, Long> ticketMap = ticketRepository.selectAllNotClosedTicketsGroupByRetailer();
-
 
745
		Map<Integer, Object> fofoIdAndallValues = new LinkedHashMap<>();
-
 
746
		Map<Integer, Object> fofoIdAndPartnerMap = new LinkedHashMap<>();
-
 
747
		for (Integer fofoId : fofoIds) {
-
 
748
 
735
 
749
			CustomRetailer cr = retailerService.getFofoRetailer(fofoId);
736
		Map<Integer, PartnerDetailModel> fofoIdAndallValues = partnerStatsService.getAllPartnerStats();
750
			fofoIdAndPartnerMap.put(fofoId, cr);
-
 
751
			LocalDateTime curDate = LocalDate.now().atStartOfDay();
-
 
752
			Double lmtdSale = fofoOrderItemRepository
-
 
753
					.selectSumAmountGroupByRetailer(curDate.withDayOfMonth(1).minusMonths(1),
-
 
754
							curDate.with(LocalTime.MAX).minusMonths(1), fofoId, false)
-
 
755
					.get(fofoId);
737
		if (authId != 0) {
756
			Double mtdSale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(curDate.withDayOfMonth(1),
-
 
757
					curDate.with(LocalTime.MAX), fofoId, false).get(fofoId);
-
 
758
			Map<String, Object> investmentMap = this.getInvestments(fofoId);
-
 
759
			double currentMonthRating = hygieneDataRepository.selectRatingAvg(fofoId,
-
 
760
					curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
-
 
761
 
-
 
762
			Long ticketCount = ticketMap.get(fofoId);
738
			List<Integer> fofoIds = pp.get(authId);
763
 
-
 
764
			float totalTodayInvestment = (float) investmentMap.get("today");
-
 
765
			float totalStockInInvestment = (float) investmentMap.get("inStock");
739
			fofoIdAndallValues = fofoIdAndallValues.entrySet().stream().filter(x -> fofoIds.contains(x.getKey()))
766
 
-
 
767
			PartnerDetailModel pm = new PartnerDetailModel();
-
 
768
			pm.setLmtd(lmtdSale);
-
 
769
			pm.setMtd(mtdSale);
-
 
770
			pm.setInvestment(totalTodayInvestment);
-
 
771
			pm.setStockInInvestment(totalStockInInvestment);
-
 
772
			if (ticketCount != null) {
-
 
773
				pm.setTicket(ticketCount.intValue());
740
					.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
774
			} else {
-
 
775
				pm.setTicket(0);
-
 
776
			}
-
 
777
			pm.setHygiene((double) Math.round(currentMonthRating));
-
 
778
			fofoIdAndallValues.put(fofoId, pm);
-
 
779
		}
741
		}
-
 
742
		Map<Integer, Object> fofoIdAndPartnerMap = new LinkedHashMap<>();
780
 
743
 
781
		model.addAttribute("fofoIdAndallValues", fofoIdAndallValues);
744
		model.addAttribute("fofoIdAndallValues", fofoIdAndallValues);
782
		model.addAttribute("fofoIdAndPartnerMap", fofoIdAndPartnerMap);
745
		model.addAttribute("fofoIdAndPartnerMap", fofoIdAndPartnerMap);
783
 
746
 
784
		return "auth_user_partner_detail";
747
		return "auth_user_partner_detail";
785
	}*/
748
	}
786
 
749
 
787
	private String getWarehouses(Set<CustomRetailer> positionRetailers) {
750
	private String getWarehouses(Set<CustomRetailer> positionRetailers) {
788
		Map<Integer, String> warehouses = new HashMap<>();
751
		Map<Integer, String> warehouses = new HashMap<>();
789
		positionRetailers.stream().forEach(x -> {
752
		positionRetailers.stream().forEach(x -> {
790
			if (x.getWarehouseId() != 0) {
753
			if (x.getWarehouseId() != 0) {
Line 985... Line 948...
985
		final InputStreamResource inputStreamResource = new InputStreamResource(file);
948
		final InputStreamResource inputStreamResource = new InputStreamResource(file);
986
		return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
949
		return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
987
	}
950
	}
988
 
951
 
989
	public Map<Integer, PartnerDetailModel> getL2AuthUserPartnerDetail() throws Exception {
952
	public Map<Integer, PartnerDetailModel> getL2AuthUserPartnerDetail() throws Exception {
990
		List<Position> pos = positionRepository.selectPositionbyCategoryIdAndEscalationType(
-
 
991
				ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L2);
-
 
992
 
-
 
993
		LOGGER.info("getL2AuthUserPartnerDetail Started");
953
		LOGGER.info("getL2AuthUserPartnerDetail Started");
994
 
-
 
995
		Map<Integer, List<Integer>> L2L1Mapping = csService.getL2L1Mapping();
954
		Map<Integer, List<Integer>> L2L1Mapping = csService.getL2L1Mapping();
996
		Map<Integer, Integer> authIdAndleadsCountMap = new HashMap<>();
955
		Map<Integer, Integer> authIdAndleadsCountMap = new HashMap<>();
997
		for (Entry<Integer, List<Integer>> l2l1 : L2L1Mapping.entrySet()) {
956
		for (Entry<Integer, List<Integer>> l2l1 : L2L1Mapping.entrySet()) {
998
			List<Integer> authIds = l2l1.getValue();
957
			List<Integer> authIds = l2l1.getValue();
999
			authIds.add(l2l1.getKey());
958
			authIds.add(l2l1.getKey());
Line 1005... Line 964...
1005
				authIdAndleadsCountMap.put(auth.getId(), leads.size());
964
				authIdAndleadsCountMap.put(auth.getId(), leads.size());
1006
			} else {
965
			} else {
1007
				authIdAndleadsCountMap.put(auth.getId(), 0);
966
				authIdAndleadsCountMap.put(auth.getId(), 0);
1008
			}
967
			}
1009
		}
968
		}
1010
		
969
 
1011
		Map<Integer, PartnerDetailModel> partnerStats = partnerStatsService.getAllPartnerStats();
970
		Map<Integer, PartnerDetailModel> partnerStats = partnerStatsService.getAllPartnerStats();
1012
 
971
 
1013
		LOGGER.info("authIdAndleadsCountMap" + authIdAndleadsCountMap);
972
		LOGGER.info("authIdAndleadsCountMap" + authIdAndleadsCountMap);
1014
 
973
 
1015
		Map<Integer, PartnerDetailModel> authIdAndallValues = new LinkedHashMap<>();
974
		Map<Integer, PartnerDetailModel> authIdAndallValues = new LinkedHashMap<>();
1016
 
975
 
1017
		Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
976
		Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
1018
		for (int authUserId : pp.keySet()) {
977
		for (int authUserId : pp.keySet()) {
1019
			if (L2L1Mapping.keySet().contains(authUserId)) {
978
			if (L2L1Mapping.keySet().contains(authUserId)) {
1020
				List<Integer> fofoIds = pp.get(authUserId);
979
				List<Integer> fofoIds = pp.get(authUserId);
1021
				List<PartnerDetailModel> partnerDetails = fofoIds.stream().map(x->partnerStats.get(x)).collect(Collectors.toList());
980
				List<PartnerDetailModel> partnerDetails = fofoIds.stream().map(x -> partnerStats.get(x))
-
 
981
						.collect(Collectors.toList());
1022
				PartnerDetailModel partnerDetailModel = partnerStatsService.getAggregateStats(partnerDetails);
982
				PartnerDetailModel partnerDetailModel = partnerStatsService.getAggregateStats(partnerDetails);
1023
				authIdAndallValues.put(authUserId, partnerDetailModel);
983
				authIdAndallValues.put(authUserId, partnerDetailModel);
1024
			}
984
			}
1025
		}
985
		}
-
 
986
		PartnerDetailModel partnerDetailModel = partnerStatsService
1026
		PartnerDetailModel partnerDetailModel = partnerStatsService.getAggregateStats(new ArrayList<>(partnerStats.values()));
987
				.getAggregateStats(new ArrayList<>(partnerStats.values()));
1027
		authIdAndallValues.put(0, partnerDetailModel);
988
		authIdAndallValues.put(0, partnerDetailModel);
1028
		return authIdAndallValues;
989
		return authIdAndallValues;
1029
	}
990
	}
1030
 
991
 
1031
}
992
}