Subversion Repositories SmartDukaan

Rev

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

Rev 26418 Rev 26422
Line 572... Line 572...
572
				if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L3)).count() > 0) {
572
				if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L3)).count() > 0) {
573
 
573
 
574
					authIdAndAuthUserMap = authRepository.selectAllActiveUser().stream()
574
					authIdAndAuthUserMap = authRepository.selectAllActiveUser().stream()
575
							.collect(Collectors.toMap(x -> x.getId(), x -> x));
575
							.collect(Collectors.toMap(x -> x.getId(), x -> x));
576
 
576
 
577
					authIdAndallValues = csService.getL2AuthUserPartnerDetail();
577
					authIdAndallValues = this.getL2AuthUserPartnerDetail();
578
 
578
 
579
					LOGGER.info("authIdAndallValues" + authIdAndallValues);
579
					LOGGER.info("authIdAndallValues" + authIdAndallValues);
580
				}
580
				}
581
			}
581
			}
582
 
582
 
Line 625... Line 625...
625
 
625
 
626
			LOGGER.info("authIdAndallValues1" + authIdAndallValues);
626
			LOGGER.info("authIdAndallValues1" + authIdAndallValues);
627
		} catch (ProfitMandiBusinessException e) {
627
		} catch (ProfitMandiBusinessException e) {
628
		}
628
		}
629
		List<Menu> menuList = (menus != null) ? this.prepareMenu(menus) : new ArrayList<>();
629
		List<Menu> menuList = (menus != null) ? this.prepareMenu(menus) : new ArrayList<>();
630
 
-
 
-
 
630
		LOGGER.info("menu" + menuList);
631
		model.addAttribute("menu", menuList);
631
		model.addAttribute("menu", menuList);
632
		return "admin";
632
		return "admin";
633
	}
633
	}
634
 
634
 
635
	@RequestMapping(value = "/getL1AuthUser", method = RequestMethod.GET)
635
	@RequestMapping(value = "/getL1AuthUser", method = RequestMethod.GET)
Line 980... Line 980...
980
		headers.set("Content-disposition", "inline; filename=" + document.getName());
980
		headers.set("Content-disposition", "inline; filename=" + document.getName());
981
		headers.setContentLength(document.getSize());
981
		headers.setContentLength(document.getSize());
982
		final InputStreamResource inputStreamResource = new InputStreamResource(file);
982
		final InputStreamResource inputStreamResource = new InputStreamResource(file);
983
		return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
983
		return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
984
	}
984
	}
-
 
985
	
-
 
986
	
-
 
987
	public Map<Integer, Object> getL2AuthUserPartnerDetail() throws Exception {
-
 
988
		List<Position> pos = positionRepository.selectPositionbyCategoryIdAndEscalationType(
-
 
989
				ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L2);
-
 
990
 
-
 
991
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
-
 
992
		Map<Integer, Double> lmtdSale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(
-
 
993
				curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), 0, false);
-
 
994
		Map<Integer, Double> mtdSale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(curDate.withDayOfMonth(1),
-
 
995
				curDate.with(LocalTime.MAX), 0, false);
-
 
996
 
-
 
997
		Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
-
 
998
		Map<Integer, Long> ticketMap = ticketRepository.selectAllNotClosedTicketsGroupByRetailer();
-
 
999
		Map<Integer, Integer> authIdAndleadsCountMap = new HashMap<>();
-
 
1000
		Map<Integer, List<Integer>> L2L1Mapping = csService.getL1L2Mapping();
-
 
1001
 
-
 
1002
		for (Entry<Integer, List<Integer>> l2l1 : L2L1Mapping.entrySet()) {
-
 
1003
			List<Integer> authIds = l2l1.getValue();
-
 
1004
			authIds.add(l2l1.getKey());
-
 
1005
 
-
 
1006
			List<Lead> leads = leadRepository.selectByAssignAuthIdsAndStatus(authIds, LeadStatus.followUp);
-
 
1007
 
-
 
1008
			AuthUser auth = authRepository.selectById(l2l1.getKey());
-
 
1009
			authIdAndleadsCountMap.put(auth.getId(), leads.size());
-
 
1010
		}
-
 
1011
 
-
 
1012
		Map<Integer, Object> authIdAndallValues = new LinkedHashMap<>();
-
 
1013
 
-
 
1014
		for (Position po : pos) {
-
 
1015
 
-
 
1016
			double totallmtdAmount = 0;
-
 
1017
			double totalmtdAmount = 0;
-
 
1018
			int totalTicketCount = 0;
-
 
1019
			float totalTodayInvestment = 0;
-
 
1020
			float totalStockInInvestment = 0;
-
 
1021
			double currentMonthRatingAllPartners = 0;
-
 
1022
 
-
 
1023
			AuthUser auth = authRepository.selectById(po.getAuthUserId());
-
 
1024
 
-
 
1025
			List<Integer> fofoIds = pp.get(po.getAuthUserId());
-
 
1026
 
-
 
1027
			for (Integer fId : fofoIds) {
-
 
1028
				Map<String, Object> investmentMap = this.getInvestments(fId);
-
 
1029
 
-
 
1030
				double currentMonthRating = hygieneDataRepository.selectRatingAvg(fId,
-
 
1031
						curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
-
 
1032
 
-
 
1033
				currentMonthRatingAllPartners += currentMonthRating;
-
 
1034
 
-
 
1035
				fofoIds.size();
-
 
1036
 
-
 
1037
				Double lmtdAmount = lmtdSale.get(fId);
-
 
1038
				Double mtdAmount = mtdSale.get(fId);
-
 
1039
				Long ticketCount = ticketMap.get(fId);
-
 
1040
 
-
 
1041
				if (!investmentMap.isEmpty()) {
-
 
1042
					totalTodayInvestment += (float) investmentMap.get("today");
-
 
1043
					totalStockInInvestment += (float) investmentMap.get("inStock");
-
 
1044
 
-
 
1045
				}
-
 
1046
				LOGGER.info("totalTodayInvestment" + totalTodayInvestment);
-
 
1047
				LOGGER.info("totalStockInInvestment" + totalStockInInvestment);
-
 
1048
				if (ticketCount != null) {
-
 
1049
					totalTicketCount += ticketCount;
-
 
1050
				}
-
 
1051
 
-
 
1052
				if (lmtdAmount != null) {
-
 
1053
					totallmtdAmount += lmtdAmount;
-
 
1054
				}
-
 
1055
 
-
 
1056
				if (mtdAmount != null) {
-
 
1057
					totalmtdAmount += mtdAmount;
-
 
1058
				}
-
 
1059
 
-
 
1060
			}
-
 
1061
			LOGGER.info("currentMonthRatingAllPartners" + currentMonthRatingAllPartners);
-
 
1062
			LOGGER.info("size" + fofoIds.size());
-
 
1063
			double totalHygieneRating = currentMonthRatingAllPartners / fofoIds.size();
-
 
1064
 
-
 
1065
			LOGGER.info("totalHygieneRating" + totalHygieneRating);
-
 
1066
 
-
 
1067
			PartnerDetailModel pm = new PartnerDetailModel();
-
 
1068
			pm.setLmtd(totallmtdAmount);
-
 
1069
			pm.setMtd(totalmtdAmount);
-
 
1070
			pm.setLeads(authIdAndleadsCountMap.get(po.getAuthUserId()));
-
 
1071
			pm.setInvestment(totalTodayInvestment);
-
 
1072
			pm.setStockInInvestment(totalStockInInvestment);
-
 
1073
			pm.setTicket(totalTicketCount);
-
 
1074
			pm.setHygiene((double) Math.round(totalHygieneRating));
-
 
1075
			authIdAndallValues.put(auth.getId(), pm);
-
 
1076
 
-
 
1077
		}
-
 
1078
		return authIdAndallValues;
-
 
1079
	}
-
 
1080
 
985
 
1081
 
986
}
1082
}