| Line 439... |
Line 439... |
| 439 |
}
|
439 |
}
|
| 440 |
|
440 |
|
| 441 |
private Map<String, Object> getSales(int fofoId) {
|
441 |
private Map<String, Object> getSales(int fofoId) {
|
| 442 |
|
442 |
|
| 443 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
443 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
| - |
|
444 |
LocalDateTime now = LocalDateTime.now();
|
| 444 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
445 |
LocalDateTime startOfToday= LocalDate.now().atStartOfDay();
|
| 445 |
int monthLength = LocalDate.now().lengthOfMonth();
|
446 |
int monthLength = LocalDate.now().lengthOfMonth();
|
| - |
|
447 |
int daysGone = now.getDayOfMonth() - 1;
|
| - |
|
448 |
int daysRemaining = monthLength - daysGone;
|
| 446 |
Double todaySale = fofoOrderItemRepository
|
449 |
Double todaySale = fofoOrderItemRepository
|
| 447 |
.selectSumMopGroupByRetailer(curDate, curDate.with(LocalTime.MAX), fofoId, false).get(fofoId);
|
450 |
.selectSumMopGroupByRetailer(startOfToday, now, fofoId, false).get(fofoId);
|
| 448 |
Double mtdSale = fofoOrderItemRepository
|
451 |
Double mtdSaleTillYesterDay = fofoOrderItemRepository
|
| 449 |
.selectSumMopGroupByRetailer(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId, false)
|
452 |
.selectSumMopGroupByRetailer(startOfToday.withDayOfMonth(1), startOfToday, fofoId, false)
|
| 450 |
.get(fofoId);
|
453 |
.get(fofoId);
|
| - |
|
454 |
Double mtdSale = mtdSaleTillYesterDay + todaySale;
|
| 451 |
Double lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate.withDayOfMonth(1).minusMonths(1),
|
455 |
Double lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfToday.withDayOfMonth(1).minusMonths(1),
|
| 452 |
curDate.with(LocalTime.MAX).minusMonths(1), fofoId, false).get(fofoId);
|
456 |
now.minusMonths(1), fofoId, false).get(fofoId);
|
| 453 |
|
457 |
|
| 454 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
458 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
| 455 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
459 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
| 456 |
if (partnerTargetDetails.isEmpty()) {
|
460 |
if (partnerTargetDetails.isEmpty()) {
|
| 457 |
partnerTargetDetails = partnerTargetRepository
|
461 |
partnerTargetDetails = partnerTargetRepository
|
| 458 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now().minusMonths(3));
|
462 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now().minusMonths(3));
|
| 459 |
}
|
463 |
}
|
| 460 |
|
464 |
|
| 461 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
|
465 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
|
| 462 |
|
466 |
|
| - |
|
467 |
int currentRate = 0;
|
| - |
|
468 |
if(mtdSaleTillYesterDay> 0) {
|
| 463 |
int currentRate = (int) (mtdSale / curDate.getDayOfMonth());
|
469 |
currentRate = (int) (mtdSaleTillYesterDay / daysGone);
|
| - |
|
470 |
}
|
| 464 |
|
471 |
|
| 465 |
salesMap.put("requiredType", partnerType.next());
|
472 |
salesMap.put("requiredType", partnerType.next());
|
| 466 |
float reqdAmount = partnerTypeChangeService.getMinimumAmount(partnerType.next());
|
473 |
float reqdAmount = partnerTypeChangeService.getMinimumAmount(partnerType.next());
|
| 467 |
int requiredRate = (int) ((reqdAmount - mtdSale) / (monthLength - curDate.getDayOfMonth()));
|
474 |
int requiredRate = (int) ((reqdAmount - mtdSaleTillYesterDay) / daysRemaining);
|
| 468 |
if (partnerType.equals(PartnerType.PLATINUM) && requiredRate < currentRate) {
|
475 |
if (partnerType.equals(PartnerType.PLATINUM) && requiredRate < currentRate) {
|
| 469 |
requiredRate = currentRate;
|
476 |
requiredRate = currentRate;
|
| 470 |
}
|
477 |
}
|
| 471 |
salesMap.put("requiredRate", requiredRate);
|
478 |
salesMap.put("requiredRate", requiredRate);
|
| 472 |
salesMap.put("requiredTypeImage", PartnerType.imageMap.get(partnerType.next()));
|
479 |
salesMap.put("requiredTypeImage", PartnerType.imageMap.get(partnerType.next()));
|
| Line 1504... |
Line 1511... |
| 1504 |
.map(x -> retailerService.getAllFofoRetailers().get(x)).filter(x -> x != null)
|
1511 |
.map(x -> retailerService.getAllFofoRetailers().get(x)).filter(x -> x != null)
|
| 1505 |
.collect(Collectors.toSet());
|
1512 |
.collect(Collectors.toSet());
|
| 1506 |
model.addAttribute("retailers", gson.toJson(positionRetailers));
|
1513 |
model.addAttribute("retailers", gson.toJson(positionRetailers));
|
| 1507 |
model.addAttribute("reporticoProjectMap", ReporticoProject.salesReporticoProjectMap);
|
1514 |
model.addAttribute("reporticoProjectMap", ReporticoProject.salesReporticoProjectMap);
|
| 1508 |
model.addAttribute("warehouses", getWarehouses(positionRetailers));
|
1515 |
model.addAttribute("warehouses", getWarehouses(positionRetailers));
|
| - |
|
1516 |
} else {
|
| - |
|
1517 |
List<Position> warehousePositions = positions.stream()
|
| - |
|
1518 |
.filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_WAREHOUSE)
|
| - |
|
1519 |
.collect(Collectors.toList());
|
| - |
|
1520 |
if (warehousePositions.size() > 0) {
|
| - |
|
1521 |
Set<CustomRetailer> positionRetailers = new HashSet<>();
|
| - |
|
1522 |
csService.getPositionCustomRetailerMap(warehousePositions).values().forEach(customRetailers -> {
|
| - |
|
1523 |
positionRetailers.addAll(customRetailers);
|
| - |
|
1524 |
});
|
| - |
|
1525 |
model.addAttribute("reporticoProjectMap", ReporticoProject.warehouseReporticoMap);
|
| - |
|
1526 |
model.addAttribute("retailers", gson.toJson(positionRetailers));
|
| - |
|
1527 |
model.addAttribute("warehouses", getWarehouses(positionRetailers));
|
| - |
|
1528 |
}
|
| 1509 |
}
|
1529 |
}
|
| 1510 |
|
1530 |
|
| 1511 |
if (positions.size() > 0) {
|
1531 |
if (positions.size() > 0) {
|
| 1512 |
if (positions.stream()
|
1532 |
if (positions.stream()
|
| 1513 |
.filter(x -> x.getEscalationType().equals(EscalationType.L3)
|
1533 |
.filter(x -> x.getEscalationType().equals(EscalationType.L3)
|
| Line 1517... |
Line 1537... |
| 1517 |
authUserTicketCount = ticketRepository.selectAllAuthUserTicketCount(Optional.of(false));
|
1537 |
authUserTicketCount = ticketRepository.selectAllAuthUserTicketCount(Optional.of(false));
|
| 1518 |
}
|
1538 |
}
|
| 1519 |
}
|
1539 |
}
|
| 1520 |
|
1540 |
|
| 1521 |
if (Arrays.asList("amit.gupta@shop2020.in", "tejbeer.kaur@shop2020.in", "manish.tiwari@smartdukaan.com")
|
1541 |
if (Arrays.asList("amit.gupta@shop2020.in", "tejbeer.kaur@shop2020.in", "manish.tiwari@smartdukaan.com")
|
| 1522 |
.contains(email))
|
1542 |
.contains(email)) {
|
| 1523 |
|
- |
|
| 1524 |
{
|
- |
|
| 1525 |
menus = menuRepository.selectAll();
|
1543 |
menus = menuRepository.selectAll();
|
| 1526 |
} else if (positions.size() > 0) {
|
1544 |
} else if (positions.size() > 0) {
|
| 1527 |
if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L5)).count() > 0) {
|
1545 |
if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L5)).count() > 0) {
|
| 1528 |
menus = menuRepository.selectAll();
|
1546 |
menus = menuRepository.selectAll();
|
| 1529 |
} else {
|
1547 |
} else {
|
| Line 1532... |
Line 1550... |
| 1532 |
if (menuIds.size() > 0) {
|
1550 |
if (menuIds.size() > 0) {
|
| 1533 |
menus = menuRepository.selectAllByIds(menuIds);
|
1551 |
menus = menuRepository.selectAllByIds(menuIds);
|
| 1534 |
}
|
1552 |
}
|
| 1535 |
}
|
1553 |
}
|
| 1536 |
}
|
1554 |
}
|
| 1537 |
/*
|
- |
|
| 1538 |
* List<Position> salesPositions = positions.stream() .filter(x ->
|
- |
|
| 1539 |
* x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_SALES)
|
- |
|
| 1540 |
* .collect(Collectors.toList()); if (salesPositions.size() > 0) {
|
- |
|
| 1541 |
* Set<CustomRetailer> positionRetailers = new HashSet<>();
|
- |
|
| 1542 |
* csService.getPositionCustomRetailerMap(salesPositions).values().forEach(
|
- |
|
| 1543 |
* customRetailers -> { positionRetailers.addAll(customRetailers); }); }
|
- |
|
| 1544 |
*/
|
- |
|
| 1545 |
if (fofoIds == null) {
|
- |
|
| 1546 |
List<Position> warehousePositions = positions.stream()
|
- |
|
| 1547 |
.filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_WAREHOUSE)
|
- |
|
| 1548 |
.collect(Collectors.toList());
|
- |
|
| 1549 |
if (warehousePositions.size() > 0) {
|
- |
|
| 1550 |
Set<CustomRetailer> positionRetailers = new HashSet<>();
|
- |
|
| 1551 |
csService.getPositionCustomRetailerMap(warehousePositions).values().forEach(customRetailers -> {
|
- |
|
| 1552 |
positionRetailers.addAll(customRetailers);
|
- |
|
| 1553 |
});
|
- |
|
| 1554 |
model.addAttribute("reporticoProjectMap", ReporticoProject.warehouseReporticoMap);
|
- |
|
| 1555 |
model.addAttribute("retailers", gson.toJson(positionRetailers));
|
- |
|
| 1556 |
model.addAttribute("warehouses", getWarehouses(positionRetailers));
|
- |
|
| 1557 |
}
|
- |
|
| 1558 |
}
|
- |
|
| 1559 |
model.addAttribute("authId", authUser.getId());
|
1555 |
model.addAttribute("authId", authUser.getId());
|
| 1560 |
|
1556 |
|
| 1561 |
model.addAttribute("rctPartneStat", rctPartneStat);
|
1557 |
model.addAttribute("rctPartneStat", rctPartneStat);
|
| 1562 |
|
1558 |
|
| 1563 |
model.addAttribute("reporticoDate", rctSaholic);
|
1559 |
model.addAttribute("reporticoDate", rctSaholic);
|