Subversion Repositories SmartDukaan

Rev

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

Rev 31285 Rev 31287
Line 2207... Line 2207...
2207
 
2207
 
2208
	@RequestMapping(value = "/getMonthWiseSale", method = RequestMethod.GET)
2208
	@RequestMapping(value = "/getMonthWiseSale", method = RequestMethod.GET)
2209
	public String getPartnerSaleByMonth(HttpServletRequest request, @RequestParam List<Integer> fofoIds, Model model)
2209
	public String getPartnerSaleByMonth(HttpServletRequest request, @RequestParam List<Integer> fofoIds, Model model)
2210
			throws Exception {
2210
			throws Exception {
2211
 
2211
 
-
 
2212
		YearMonth now = YearMonth.now();
-
 
2213
		YearMonth ym = YearMonth.now().minusMonths(12);
-
 
2214
		List<YearMonth> list = new ArrayList<>();
-
 
2215
		while (!ym.isAfter(now)) {
-
 
2216
			list.add(ym);
-
 
2217
			ym = ym.plusMonths(1);
-
 
2218
		}
-
 
2219
 
-
 
2220
		model.addAttribute("yearMonth", list);
-
 
2221
 
2212
		List<PartnerMonthlySaleModel> partnerMonthlySaleModels = fofoOrderItemRepository
2222
		List<PartnerMonthlySaleModel> partnerMonthlySaleModels = fofoOrderItemRepository
2213
				.selectPartnerMonthlySale(fofoIds, LocalDateTime.now().minusMonths(12));
2223
				.selectPartnerMonthlySale(fofoIds, LocalDateTime.now().minusMonths(12));
2214
		LOGGER.info("partnerMonthlySaleModels" + partnerMonthlySaleModels);
2224
		LOGGER.info("partnerMonthlySaleModels" + partnerMonthlySaleModels);
-
 
2225
 
-
 
2226
		DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
-
 
2227
		Map<Integer, Map<YearMonth, Double>> partnerMonthSaleMap = new HashMap<>();
-
 
2228
		if (!partnerMonthlySaleModels.isEmpty()) {
-
 
2229
 
-
 
2230
			partnerMonthSaleMap = partnerMonthlySaleModels.stream()
-
 
2231
					.collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.toMap(
-
 
2232
							x -> YearMonth.parse(x.getYearMonth(), dateTimeFormatter), x -> (double) x.getAmount())));
-
 
2233
		}
-
 
2234
 
-
 
2235
		Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailerUserId(fofoIds);
-
 
2236
 
-
 
2237
		model.addAttribute("customRetailerMap", customRetailerMap);
-
 
2238
 
-
 
2239
		model.addAttribute("customRetailerMap", customRetailerMap);
-
 
2240
 
-
 
2241
		model.addAttribute("partnerMonthSaleMap", partnerMonthSaleMap);
2215
		return "response";
2242
		return "monthly-partner-sale";
2216
 
2243
 
2217
	}
2244
	}
2218
}
2245
}