| 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, fofoId);
|
714 |
currentMonthStartDate, currentMonthEndDate.plusDays(1), 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 722... |
Line 722... |
| 722 |
|
722 |
|
| 723 |
LOGGER.info("fofoTotalMtdTertiaryMap- {}",fofoTotalMtdTertiaryMap);
|
723 |
LOGGER.info("fofoTotalMtdTertiaryMap- {}",fofoTotalMtdTertiaryMap);
|
| 724 |
LOGGER.info("fofoBrandMtdTertiaryMap- {}",fofoBrandMtdTertiaryMap);
|
724 |
LOGGER.info("fofoBrandMtdTertiaryMap- {}",fofoBrandMtdTertiaryMap);
|
| 725 |
|
725 |
|
| 726 |
|
726 |
|
| 727 |
List<BrandWiseModel> brandWiseMtdSecondary = orderRepository.selectAllBilledOrderGroupByBrandFofoId(fofoId, currentMonthStartDate);
|
727 |
List<BrandWiseModel> brandWiseMtdSecondary = orderRepository.selectAllBilledByCategoryOrderGroupByBrandFofoId(fofoId, currentMonthStartDate,Arrays.asList(10006,10009,10010));
|
| 728 |
Map<String,Long> brandWiseMtdSecondaryMap = brandWiseMtdSecondary.stream().collect(Collectors.toMap(BrandWiseModel::getBrand,BrandWiseModel::getAmount));
|
728 |
Map<String,Long> brandWiseMtdSecondaryMap = brandWiseMtdSecondary.stream().collect(Collectors.toMap(BrandWiseModel::getBrand,BrandWiseModel::getAmount));
|
| 729 |
fofoBrandWiseMtdSecondaryMap.put(fofoId,brandWiseMtdSecondaryMap);
|
729 |
fofoBrandWiseMtdSecondaryMap.put(fofoId,brandWiseMtdSecondaryMap);
|
| 730 |
|
730 |
|
| 731 |
long mtdTotalSecondary = brandWiseMtdSecondary.stream().mapToLong(x -> x.getAmount() != 0 ? x.getAmount() : 0L).sum();
|
731 |
long mtdTotalSecondary = brandWiseMtdSecondary.stream().mapToLong(x -> x.getAmount() != 0 ? x.getAmount() : 0L).sum();
|
| 732 |
|
732 |
|
| Line 888... |
Line 888... |
| 888 |
"Secondary Target", "Secondary Achieved", "Returns", "Net Secondary", "Secondary %",
|
888 |
"Secondary Target", "Secondary Achieved", "Returns", "Net Secondary", "Secondary %",
|
| 889 |
"Tertiary Sale", "Unbilled",
|
889 |
"Tertiary Sale", "Unbilled",
|
| 890 |
"Counter Potential", "Short investment", "Default", "INVESTMENT LEVEL", "Loan", "PO value", "Agreed investment",
|
890 |
"Counter Potential", "Short investment", "Default", "INVESTMENT LEVEL", "Loan", "PO value", "Agreed investment",
|
| 891 |
"Wallet", "po+bill", "MONTH BEGINNING DRR", "REQ DRR", "Drr %", "Last billing Done", "Slab",
|
891 |
"Wallet", "po+bill", "MONTH BEGINNING DRR", "REQ DRR", "Drr %", "Last billing Done", "Slab",
|
| 892 |
|
892 |
|
| 893 |
"Total Stock", "Apple","Xiaomi", "Vivo", "Tecno", "Samsung", "Realme", "Oppo", "OnePlus", "Poco", "Lava", "Itel", "Almost New",
|
893 |
"Total Stock", "Apple","Xiaomi", "Vivo", "Tecno", "Samsung", "Realme", "Oppo", "OnePlus", "POCO", "Lava", "Itel", "Almost New",
|
| 894 |
"Total Secondary", "Apple", "Xiaomi", "Vivo", "Tecno", "Samsung", "Realme", "Oppo", "OnePlus", "Poco", "Lava", "Itel", "Almost New",
|
894 |
"Total Secondary", "Apple", "Xiaomi", "Vivo", "Tecno", "Samsung", "Realme", "Oppo", "OnePlus", "POCO", "Lava", "Itel", "Almost New",
|
| 895 |
"Total Tertiary", "Apple", "Xiaomi", "Vivo", "Tecno", "Samsung", "Realme", "Oppo", "OnePlus", "Poco", "Lava", "Itel", "Almost New"
|
895 |
"Total Tertiary", "Apple", "Xiaomi", "Vivo", "Tecno", "Samsung", "Realme", "Oppo", "OnePlus", "POCO", "Lava", "Itel", "Almost New"
|
| 896 |
);
|
896 |
);
|
| 897 |
|
897 |
|
| 898 |
headerGroup.add(headers1);
|
898 |
headerGroup.add(headers1);
|
| 899 |
headerGroup.add(headers2);
|
899 |
headerGroup.add(headers2);
|
| 900 |
|
900 |
|
| Line 989... |
Line 989... |
| 989 |
brandStockMap.get("Tecno") != null ? brandStockMap.get("Tecno").getTotalValue() : 0.0,
|
989 |
brandStockMap.get("Tecno") != null ? brandStockMap.get("Tecno").getTotalValue() : 0.0,
|
| 990 |
brandStockMap.get("Samsung") != null ? brandStockMap.get("Samsung").getTotalValue() : 0.0,
|
990 |
brandStockMap.get("Samsung") != null ? brandStockMap.get("Samsung").getTotalValue() : 0.0,
|
| 991 |
brandStockMap.get("Realme") != null ? brandStockMap.get("Realme").getTotalValue() : 0.0,
|
991 |
brandStockMap.get("Realme") != null ? brandStockMap.get("Realme").getTotalValue() : 0.0,
|
| 992 |
brandStockMap.get("Oppo") != null ? brandStockMap.get("Oppo").getTotalValue() : 0.0,
|
992 |
brandStockMap.get("Oppo") != null ? brandStockMap.get("Oppo").getTotalValue() : 0.0,
|
| 993 |
brandStockMap.get("OnePlus") != null ? brandStockMap.get("OnePlus").getTotalValue() : 0.0,
|
993 |
brandStockMap.get("OnePlus") != null ? brandStockMap.get("OnePlus").getTotalValue() : 0.0,
|
| 994 |
brandStockMap.get("Poco") != null ? brandStockMap.get("Poco").getTotalValue() : 0.0,
|
994 |
brandStockMap.get("POCO") != null ? brandStockMap.get("POCO").getTotalValue() : 0.0,
|
| 995 |
brandStockMap.get("Lava") != null ? brandStockMap.get("Lava").getTotalValue() : 0.0,
|
995 |
brandStockMap.get("Lava") != null ? brandStockMap.get("Lava").getTotalValue() : 0.0,
|
| 996 |
brandStockMap.get("Itel") != null ? brandStockMap.get("Itel").getTotalValue() : 0.0,
|
996 |
brandStockMap.get("Itel") != null ? brandStockMap.get("Itel").getTotalValue() : 0.0,
|
| 997 |
brandStockMap.get("Almost New") != null ? brandStockMap.get("Almost New").getTotalValue() : 0.0
|
997 |
brandStockMap.get("Almost New") != null ? brandStockMap.get("Almost New").getTotalValue() : 0.0
|
| 998 |
));
|
998 |
));
|
| 999 |
|
999 |
|
| Line 1006... |
Line 1006... |
| 1006 |
brandSecondaryMap.getOrDefault("Tecno", 0L),
|
1006 |
brandSecondaryMap.getOrDefault("Tecno", 0L),
|
| 1007 |
brandSecondaryMap.getOrDefault("Samsung", 0L),
|
1007 |
brandSecondaryMap.getOrDefault("Samsung", 0L),
|
| 1008 |
brandSecondaryMap.getOrDefault("Realme", 0L),
|
1008 |
brandSecondaryMap.getOrDefault("Realme", 0L),
|
| 1009 |
brandSecondaryMap.getOrDefault("Oppo", 0L),
|
1009 |
brandSecondaryMap.getOrDefault("Oppo", 0L),
|
| 1010 |
brandSecondaryMap.getOrDefault("OnePlus", 0L),
|
1010 |
brandSecondaryMap.getOrDefault("OnePlus", 0L),
|
| 1011 |
brandSecondaryMap.getOrDefault("Poco", 0L),
|
1011 |
brandSecondaryMap.getOrDefault("POCO", 0L),
|
| 1012 |
brandSecondaryMap.getOrDefault("Lava", 0L),
|
1012 |
brandSecondaryMap.getOrDefault("Lava", 0L),
|
| 1013 |
brandSecondaryMap.getOrDefault("Itel", 0L),
|
1013 |
brandSecondaryMap.getOrDefault("Itel", 0L),
|
| 1014 |
brandSecondaryMap.getOrDefault("Almost New", 0L)
|
1014 |
brandSecondaryMap.getOrDefault("Almost New", 0L)
|
| 1015 |
));
|
1015 |
));
|
| 1016 |
|
1016 |
|
| Line 1023... |
Line 1023... |
| 1023 |
brandTertiaryMap.getOrDefault("Tecno", 0d),
|
1023 |
brandTertiaryMap.getOrDefault("Tecno", 0d),
|
| 1024 |
brandTertiaryMap.getOrDefault("Samsung", 0d),
|
1024 |
brandTertiaryMap.getOrDefault("Samsung", 0d),
|
| 1025 |
brandTertiaryMap.getOrDefault("Realme", 0d),
|
1025 |
brandTertiaryMap.getOrDefault("Realme", 0d),
|
| 1026 |
brandTertiaryMap.getOrDefault("Oppo", 0d),
|
1026 |
brandTertiaryMap.getOrDefault("Oppo", 0d),
|
| 1027 |
brandTertiaryMap.getOrDefault("OnePlus", 0d),
|
1027 |
brandTertiaryMap.getOrDefault("OnePlus", 0d),
|
| 1028 |
brandTertiaryMap.getOrDefault("Poco", 0d),
|
1028 |
brandTertiaryMap.getOrDefault("POCO", 0d),
|
| 1029 |
brandTertiaryMap.getOrDefault("Lava", 0d),
|
1029 |
brandTertiaryMap.getOrDefault("Lava", 0d),
|
| 1030 |
brandTertiaryMap.getOrDefault("Itel", 0d),
|
1030 |
brandTertiaryMap.getOrDefault("Itel", 0d),
|
| 1031 |
brandTertiaryMap.getOrDefault("Almost New", 0d)
|
1031 |
brandTertiaryMap.getOrDefault("Almost New", 0d)
|
| 1032 |
));
|
1032 |
));
|
| 1033 |
rows.add(row);
|
1033 |
rows.add(row);
|
| 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 |
}
|
| Line 1149... |
Line 1149... |
| 1149 |
brandStyles.put("Tecno", createStyle(workbook, IndexedColors.LIGHT_BLUE));
|
1149 |
brandStyles.put("Tecno", createStyle(workbook, IndexedColors.LIGHT_BLUE));
|
| 1150 |
brandStyles.put("Samsung", createStyle(workbook, IndexedColors.ROYAL_BLUE));
|
1150 |
brandStyles.put("Samsung", createStyle(workbook, IndexedColors.ROYAL_BLUE));
|
| 1151 |
brandStyles.put("Realme", createStyle(workbook, IndexedColors.YELLOW));
|
1151 |
brandStyles.put("Realme", createStyle(workbook, IndexedColors.YELLOW));
|
| 1152 |
brandStyles.put("Oppo", createStyle(workbook, IndexedColors.LIGHT_GREEN));
|
1152 |
brandStyles.put("Oppo", createStyle(workbook, IndexedColors.LIGHT_GREEN));
|
| 1153 |
brandStyles.put("OnePlus", createStyle(workbook, IndexedColors.RED));
|
1153 |
brandStyles.put("OnePlus", createStyle(workbook, IndexedColors.RED));
|
| 1154 |
brandStyles.put("Poco", createStyle(workbook, IndexedColors.ORANGE));
|
1154 |
brandStyles.put("POCO", createStyle(workbook, IndexedColors.ORANGE));
|
| 1155 |
brandStyles.put("Lava", createStyle(workbook, IndexedColors.LIGHT_YELLOW));
|
1155 |
brandStyles.put("Lava", createStyle(workbook, IndexedColors.LIGHT_YELLOW));
|
| 1156 |
brandStyles.put("Itel", createStyle(workbook, IndexedColors.LIGHT_YELLOW));
|
1156 |
brandStyles.put("Itel", createStyle(workbook, IndexedColors.LIGHT_YELLOW));
|
| 1157 |
brandStyles.put("Almost New", createStyle(workbook, IndexedColors.WHITE));
|
1157 |
brandStyles.put("Almost New", createStyle(workbook, IndexedColors.WHITE));
|
| 1158 |
|
1158 |
|
| 1159 |
|
1159 |
|