| Line 458... |
Line 458... |
| 458 |
|
458 |
|
| 459 |
/*Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailersInternalFalse();
|
459 |
/*Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailersInternalFalse();
|
| 460 |
|
460 |
|
| 461 |
List<Integer> retailerIds = customRetailers.values().stream().map(CustomRetailer::getPartnerId).collect(Collectors.toList());*/
|
461 |
List<Integer> retailerIds = customRetailers.values().stream().map(CustomRetailer::getPartnerId).collect(Collectors.toList());*/
|
| 462 |
|
462 |
|
| 463 |
List<Integer> retailerIds = Arrays.asList(175139615,175139391,175135707);
|
463 |
List<Integer> retailerIds = Arrays.asList(175139615,175139391,175135707,175139854,175139302,175139710,175139749);
|
| 464 |
Map<Integer,CustomRetailer> customRetailers = retailerService.getFofoRetailers(retailerIds);
|
464 |
Map<Integer,CustomRetailer> customRetailers = retailerService.getFofoRetailers(retailerIds);
|
| 465 |
|
465 |
|
| 466 |
//partner daily investment
|
466 |
//partner daily investment
|
| 467 |
List<Loan> defaultLoans = sdCreditService.getDefaultLoan();
|
467 |
List<Loan> defaultLoans = sdCreditService.getDefaultLoan();
|
| 468 |
Map<Integer,List<Loan>> defaultLoanMap = defaultLoans.stream().collect(Collectors.groupingBy(Loan::getFofoId));
|
468 |
Map<Integer,List<Loan>> defaultLoanMap = defaultLoans.stream().collect(Collectors.groupingBy(Loan::getFofoId));
|
| Line 477... |
Line 477... |
| 477 |
|
477 |
|
| 478 |
// this month return data
|
478 |
// this month return data
|
| 479 |
YearMonth currentMonth = YearMonth.now();
|
479 |
YearMonth currentMonth = YearMonth.now();
|
| 480 |
String currentMonthStringValue = String.valueOf(currentMonth);
|
480 |
String currentMonthStringValue = String.valueOf(currentMonth);
|
| 481 |
LocalDateTime currentMonthStartDate = YearMonth.now().atDay(1).atStartOfDay();
|
481 |
LocalDateTime currentMonthStartDate = YearMonth.now().atDay(1).atStartOfDay();
|
| 482 |
LocalDateTime currentMonthEndDate = LocalDateTime.now().minusDays(1);
|
482 |
LocalDateTime currentMonthEndDate = LocalDateTime.now().minusDays(1).toLocalDate().atTime(23, 59, 59);
|
| 483 |
|
483 |
|
| 484 |
List<ReturnOrderInfoModel> currentMonthReturnOrderInfoModels = returnOrderInfoRepository.selectAllByBetweenDate(currentMonthStartDate, currentMonthEndDate);
|
484 |
List<ReturnOrderInfoModel> currentMonthReturnOrderInfoModels = returnOrderInfoRepository.selectAllByBetweenDate(currentMonthStartDate, currentMonthEndDate);
|
| 485 |
Map<Integer, Long> currentMonthPartnerReturnOrderInfoModelMap = currentMonthReturnOrderInfoModels.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getRefundAmount()))));
|
485 |
Map<Integer, Long> currentMonthPartnerReturnOrderInfoModelMap = currentMonthReturnOrderInfoModels.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getRefundAmount()))));
|
| 486 |
|
486 |
|
| 487 |
List<Order> currentMonthRtoRefundOrders = orderRepository.selectAllOrderDatesBetweenByStatus(currentMonthStartDate, currentMonthEndDate, OrderStatus.RTO_REFUNDED);
|
487 |
List<Order> currentMonthRtoRefundOrders = orderRepository.selectAllOrderDatesBetweenByStatus(currentMonthStartDate, currentMonthEndDate, OrderStatus.RTO_REFUNDED);
|
| Line 709... |
Line 709... |
| 709 |
double totalStockPrice = brandStockPriceMap.values().stream().mapToDouble(x->x.getTotalValue()).sum();
|
709 |
double totalStockPrice = brandStockPriceMap.values().stream().mapToDouble(x->x.getTotalValue()).sum();
|
| 710 |
|
710 |
|
| 711 |
fofoTotalStockPriceMap.put(fofoId,totalStockPrice);
|
711 |
fofoTotalStockPriceMap.put(fofoId,totalStockPrice);
|
| 712 |
|
712 |
|
| 713 |
Map<String, Double> brandMtdTertiaryAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(
|
713 |
Map<String, Double> brandMtdTertiaryAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(
|
| 714 |
currentMonthStartDate, currentMonthEndDate.plusDays(1), fofoId);
|
714 |
currentMonthStartDate, currentMonthEndDate, fofoId);
|
| 715 |
|
715 |
|
| 716 |
|
716 |
|
| 717 |
fofoBrandMtdTertiaryMap.put(fofoId,brandMtdTertiaryAmount);
|
717 |
fofoBrandMtdTertiaryMap.put(fofoId,brandMtdTertiaryAmount);
|
| 718 |
|
718 |
|
| 719 |
double totalMtdTertiaryAmount = brandMtdTertiaryAmount.values().stream().mapToDouble(Double::doubleValue).sum();
|
719 |
double totalMtdTertiaryAmount = brandMtdTertiaryAmount.values().stream().mapToDouble(Double::doubleValue).sum();
|
| Line 1036... |
Line 1036... |
| 1036 |
|
1036 |
|
| 1037 |
// Send to email
|
1037 |
// Send to email
|
| 1038 |
// ByteArrayOutputStream csvStream = FileUtil.getCSVByteStreamWithMultiHeaders(headerGroup, rows);
|
1038 |
// ByteArrayOutputStream csvStream = FileUtil.getCSVByteStreamWithMultiHeaders(headerGroup, rows);
|
| 1039 |
ByteArrayOutputStream csvStream = getExcelStreamWithMultiHeaders(headerGroup, rows);
|
1039 |
ByteArrayOutputStream csvStream = getExcelStreamWithMultiHeaders(headerGroup, rows);
|
| 1040 |
String fileName = "BI-Retailer-Monthly-Report-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".xlsx";
|
1040 |
String fileName = "BI-Retailer-Monthly-Report-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".xlsx";
|
| 1041 |
// String[] sendToArray = new String[]{"ranu.rajput@smartdukaan.com","ashutosh.verma@smartdukaan.com","sm@smartdukaan.com","raj.singh@smartdukaan.com"};
|
1041 |
String[] sendToArray = new String[]{"ranu.rajput@smartdukaan.com","ashutosh.verma@smartdukaan.com","sm@smartdukaan.com","raj.singh@smartdukaan.com"};
|
| 1042 |
String[] sendToArray = new String[]{"ranu.rajput@smartdukaan.com"};
|
1042 |
// String[] sendToArray = new String[]{"ranu.rajput@smartdukaan.com"};
|
| 1043 |
|
1043 |
|
| 1044 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, new String[]{}, "BI Retailer Monthly Report", "Please find attached the BI retailer secondary/tertiary monthly report.", fileName, new ByteArrayResource(csvStream.toByteArray()));
|
1044 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, new String[]{}, "BI Retailer Monthly Report", "Please find attached the BI retailer secondary/tertiary monthly report.", fileName, new ByteArrayResource(csvStream.toByteArray()));
|
| 1045 |
|
1045 |
|
| 1046 |
|
1046 |
|
| 1047 |
}
|
1047 |
}
|