| Line 322... |
Line 322... |
| 322 |
int fofoId = loginDetails.getFofoId();
|
322 |
int fofoId = loginDetails.getFofoId();
|
| 323 |
Map<Integer, MonthSaleModel> monthSaleMap = new HashMap<>();
|
323 |
Map<Integer, MonthSaleModel> monthSaleMap = new HashMap<>();
|
| 324 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
324 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 325 |
int dayOfMonth = curDate.getDayOfMonth();
|
325 |
int dayOfMonth = curDate.getDayOfMonth();
|
| 326 |
YearMonth yearMonth = YearMonth.now();
|
326 |
YearMonth yearMonth = YearMonth.now();
|
| 327 |
for (int i = 1; i <= 6; i++) {
|
327 |
for (int i = 0; i <= 6; i++) {
|
| 328 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
328 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| 329 |
int lengthOfMonth = YearMonth.from(startOfMonth).lengthOfMonth();
|
329 |
int lengthOfMonth = YearMonth.from(startOfMonth).lengthOfMonth();
|
| 330 |
LOGGER.info("Start of previous Month {}, start of next month Month {}", startOfMonth, startOfMonth.plusMonths(1));
|
330 |
LOGGER.info("Start of previous Month {}, start of next month Month {}", startOfMonth, startOfMonth.plusMonths(1));
|
| 331 |
double monthSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth, startOfMonth.plusMonths(1), loginDetails.getFofoId(), false).get(fofoId);
|
331 |
double monthSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth, startOfMonth.plusMonths(1), loginDetails.getFofoId(), false).get(fofoId);
|
| 332 |
|
- |
|
| - |
|
332 |
LOGGER.info("Month sales - {}", monthSales);
|
| 333 |
double mtdSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth, startOfMonth.plusDays(Math.min(dayOfMonth, lengthOfMonth)), loginDetails.getFofoId(), false).get(fofoId);
|
333 |
double mtdSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth, startOfMonth.plusDays(Math.min(dayOfMonth, lengthOfMonth)), loginDetails.getFofoId(), false).get(fofoId);
|
| 334 |
|
334 |
|
| 335 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnMonth(fofoId, yearMonth.minusMonths(i));
|
335 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnMonth(fofoId, yearMonth.minusMonths(i));
|
| 336 |
|
336 |
|
| 337 |
MonthSaleModel ms = new MonthSaleModel();
|
337 |
MonthSaleModel ms = new MonthSaleModel();
|
| Line 346... |
Line 346... |
| 346 |
return "monthSales";
|
346 |
return "monthSales";
|
| 347 |
}
|
347 |
}
|
| 348 |
|
348 |
|
| 349 |
@RequestMapping(value = "/getBrandwisePartnerSale", method = RequestMethod.GET)
|
349 |
@RequestMapping(value = "/getBrandwisePartnerSale", method = RequestMethod.GET)
|
| 350 |
@ResponseBody
|
350 |
@ResponseBody
|
| - |
|
351 |
public List<Map<String, Object>> getBrandwisePartnerSale(
|
| - |
|
352 |
HttpServletRequest request,
|
| 351 |
public List<Map<String, Object>> getBrandwisePartnerSale(HttpServletRequest request, @RequestParam(name = "month", required = true, defaultValue = "0") int month, Model model) throws Exception {
|
353 |
@RequestParam(name = "month", required = true, defaultValue = "0") int month,
|
| - |
|
354 |
Model model) throws Exception {
|
| - |
|
355 |
|
| 352 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
356 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 353 |
if (month < 1 || month > 12) {
|
- |
|
| 354 |
throw new IllegalArgumentException("Month must be between 1 and 12");
|
- |
|
| 355 |
}
|
- |
|
| 356 |
int fofoId = loginDetails.getFofoId();
|
357 |
int fofoId = loginDetails.getFofoId();
|
| - |
|
358 |
|
| - |
|
359 |
List<BrandWisePartnerSaleModel> mobileList =
|
| 357 |
List<BrandWisePartnerSaleModel> brandWisePartnerSaleModels = fofoStoreRepository.selectBrandWiseMonthlyPartnerSale(Collections.singletonList(fofoId), month);
|
360 |
fofoStoreRepository.selectBrandWiseMonthlyPartnerSale(Collections.singletonList(fofoId), month);
|
| - |
|
361 |
|
| - |
|
362 |
List<BrandWisePartnerSaleModel> accList =
|
| - |
|
363 |
fofoStoreRepository.selectBrandWiseMonthlyPartnerAccessoriesSale(Collections.singletonList(fofoId), month);
|
| - |
|
364 |
|
| 358 |
List<Map<String, Object>> response = new ArrayList<>();
|
365 |
List<Map<String, Object>> response = new ArrayList<>();
|
| - |
|
366 |
|
| 359 |
for (BrandWisePartnerSaleModel m : brandWisePartnerSaleModels) {
|
367 |
for (BrandWisePartnerSaleModel m : mobileList) {
|
| 360 |
Map<String, Object> row = new HashMap<>();
|
368 |
Map<String, Object> row = new HashMap<>();
|
| 361 |
row.put("brand", m.getBrand());
|
369 |
row.put("brand", m.getBrand());
|
| 362 |
row.put("lms", fofoUser.format(m.getLms()));
|
370 |
row.put("lms", fofoUser.format(m.getLms()));
|
| 363 |
row.put("lmsQty", m.getLmsQty());
|
371 |
row.put("lmsQty", m.getLmsQty());
|
| 364 |
row.put("mtd", fofoUser.format(m.getMtd()));
|
372 |
row.put("mtd", fofoUser.format(m.getMtd()));
|
| 365 |
row.put("mtdQty", m.getMtdQty());
|
373 |
row.put("mtdQty", m.getMtdQty());
|
| 366 |
row.put("lmtd", fofoUser.format(m.getLmtd()));
|
- |
|
| 367 |
row.put("lmtdQty", m.getLmtdQty());
|
- |
|
| 368 |
row.put("amtd", fofoUser.format(m.getAmtd()));
|
- |
|
| 369 |
response.add(row);
|
374 |
response.add(row);
|
| 370 |
}
|
375 |
}
|
| 371 |
|
376 |
|
| - |
|
377 |
long accLms = 0;
|
| - |
|
378 |
long accLmtd = 0;
|
| - |
|
379 |
long accMtd = 0;
|
| - |
|
380 |
long accMtdQty = 0;
|
| - |
|
381 |
for (BrandWisePartnerSaleModel a : accList) {
|
| - |
|
382 |
accLms += a.getLms();
|
| - |
|
383 |
accLmtd += a.getLmtd();
|
| - |
|
384 |
accMtd += a.getMtd();
|
| - |
|
385 |
accMtdQty += a.getMtdQty();
|
| - |
|
386 |
}
|
| - |
|
387 |
if (!accList.isEmpty()) {
|
| - |
|
388 |
Map<String, Object> accRow = new HashMap<>();
|
| - |
|
389 |
accRow.put("brand", "Accessories");
|
| - |
|
390 |
accRow.put("lms", fofoUser.format(accLms));
|
| - |
|
391 |
accRow.put("lmtd", fofoUser.format(accLmtd));
|
| - |
|
392 |
accRow.put("mtd", fofoUser.format(accMtd));
|
| - |
|
393 |
accRow.put("mtdQty", accMtdQty);
|
| - |
|
394 |
response.add(accRow);
|
| - |
|
395 |
}
|
| 372 |
|
396 |
|
| 373 |
LOGGER.info("brandItemWisePartnerSaleModels {}", response);
|
- |
|
| 374 |
return response;
|
397 |
return response;
|
| 375 |
}
|
398 |
}
|
| 376 |
|
399 |
|
| - |
|
400 |
|
| 377 |
@RequestMapping(value = "/getBrandItemwisePartnerSale", method = RequestMethod.GET)
|
401 |
@RequestMapping(value = "/getBrandItemwisePartnerSale", method = RequestMethod.GET)
|
| 378 |
@ResponseBody
|
402 |
@ResponseBody
|
| 379 |
public List<BrandItemWisePartnerSaleModel> getBrandItemwisePartnerSale(HttpServletRequest request, @RequestParam(name = "month", required = true, defaultValue = "0") int month, @RequestParam(name = "brand") String brand, @RequestParam(name = "fofoId") Integer fofoId, Model model) throws Exception {
|
403 |
public List<BrandItemWisePartnerSaleModel> getBrandItemwisePartnerSale(HttpServletRequest request, @RequestParam(name = "month", required = true, defaultValue = "0") int month, @RequestParam(name = "brand") String brand, @RequestParam(name = "fofoId") Integer fofoId, Model model) throws Exception {
|
| 380 |
if (month < 1 || month > 12) {
|
- |
|
| 381 |
throw new IllegalArgumentException("Month must be between 1 and 12");
|
- |
|
| 382 |
}
|
- |
|
| 383 |
List<BrandItemWisePartnerSaleModel> brandItemWisePartnerSaleModels = fofoStoreRepository.selectPartnerBrandItemMonthlySale(Collections.singletonList(fofoId), month, brand);
|
404 |
List<BrandItemWisePartnerSaleModel> brandItemWisePartnerSaleModels = fofoStoreRepository.selectPartnerBrandItemMonthlySale(Collections.singletonList(fofoId), month, brand);
|
| 384 |
LOGGER.info("brandItemWisePartnerSaleModels {}", brandItemWisePartnerSaleModels);
|
405 |
LOGGER.info("brandItemWisePartnerSaleModels {}", brandItemWisePartnerSaleModels);
|
| 385 |
return brandItemWisePartnerSaleModels;
|
406 |
return brandItemWisePartnerSaleModels;
|
| 386 |
}
|
407 |
}
|
| 387 |
|
408 |
|