Subversion Repositories SmartDukaan

Rev

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

Rev 34743 Rev 34749
Line 49... Line 49...
49
import javax.mail.internet.InternetAddress;
49
import javax.mail.internet.InternetAddress;
50
import javax.mail.internet.MimeMessage;
50
import javax.mail.internet.MimeMessage;
51
import java.io.*;
51
import java.io.*;
52
import java.math.BigDecimal;
52
import java.math.BigDecimal;
53
import java.time.*;
53
import java.time.*;
-
 
54
import java.time.format.DateTimeFormatter;
54
import java.time.temporal.ChronoUnit;
55
import java.time.temporal.ChronoUnit;
55
import java.util.*;
56
import java.util.*;
56
import java.util.stream.Collectors;
57
import java.util.stream.Collectors;
57
 
58
 
58
@Component
59
@Component
Line 460... Line 461...
460
            // Otherwise, use today
461
            // Otherwise, use today
461
            startOfToday = LocalDate.now().atStartOfDay();
462
            startOfToday = LocalDate.now().atStartOfDay();
462
            previousDay = startOfToday.with(LocalTime.MAX).minusDays(1);
463
            previousDay = startOfToday.with(LocalTime.MAX).minusDays(1);
463
        }
464
        }
464
 
465
 
465
        Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailersInternalFalse();
466
/*        Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailersInternalFalse();
466
 
467
 
467
        List<Integer> retailerIds = customRetailers.values().stream().map(CustomRetailer::getPartnerId).collect(Collectors.toList());
468
        List<Integer> retailerIds = customRetailers.values().stream().map(CustomRetailer::getPartnerId).collect(Collectors.toList());*/
468
 
469
 
469
/*        List<Integer> retailerIds = Arrays.asList(175139494);
470
        List<Integer> retailerIds = Arrays.asList(175139440,175139441);
470
        Map<Integer,CustomRetailer> customRetailers = retailerService.getFofoRetailers(retailerIds);*/
471
        Map<Integer,CustomRetailer> customRetailers = retailerService.getFofoRetailers(retailerIds);
471
 
472
 
472
        //partner daily investment
473
        //partner daily investment
473
        List<Loan> defaultLoans = sdCreditService.getDefaultLoans();
474
        List<Loan> defaultLoans = sdCreditService.getDefaultLoans();
474
        Map<Integer,List<Loan>> defaultLoanMap = defaultLoans.stream().collect(Collectors.groupingBy(Loan::getFofoId));
475
        Map<Integer,List<Loan>> defaultLoanMap = defaultLoans.stream().collect(Collectors.groupingBy(Loan::getFofoId));
475
 
476
 
Line 507... Line 508...
507
        Map<Integer, Long> currentMonthPartnerReturnOrderInfoModelMap = currentMonthReturnOrderInfoModels.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getRefundAmount()))));
508
        Map<Integer, Long> currentMonthPartnerReturnOrderInfoModelMap = currentMonthReturnOrderInfoModels.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getRefundAmount()))));
508
 
509
 
509
        List<Order> currentMonthRtoRefundOrders = orderRepository.selectAllOrderDatesBetweenByStatus(currentMonthStartDate, currentMonthEndDate, OrderStatus.RTO_REFUNDED);
510
        List<Order> currentMonthRtoRefundOrders = orderRepository.selectAllOrderDatesBetweenByStatus(currentMonthStartDate, currentMonthEndDate, OrderStatus.RTO_REFUNDED);
510
        Map<Integer, Long> currentMonthRtoRefundOrderMap = currentMonthRtoRefundOrders.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getTotalAmount()))));
511
        Map<Integer, Long> currentMonthRtoRefundOrderMap = currentMonthRtoRefundOrders.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getTotalAmount()))));
511
 
512
 
-
 
513
 
-
 
514
        List<ReturnOrderInfoModel> yesterdayReturnOrderInfoModels = returnOrderInfoRepository.selectAllByBetweenDate(previousDay.toLocalDate().atStartOfDay(), previousDay);
-
 
515
        Map<Integer, Long> yesterdayReturnOrderInfoModelMap = yesterdayReturnOrderInfoModels.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getRefundAmount()))));
-
 
516
 
-
 
517
        List<Order> yesterdayRtoRefundOrders = orderRepository.selectAllOrderDatesBetweenByStatus(previousDay.toLocalDate().atStartOfDay(), previousDay, OrderStatus.RTO_REFUNDED);
-
 
518
        Map<Integer, Long> yesterdayRtoRefundOrderMap = yesterdayRtoRefundOrders.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getTotalAmount()))));
-
 
519
 
-
 
520
        List<ReturnOrderInfoModel> dayBeforeYesterdayReturnOrderInfoModels = returnOrderInfoRepository.selectAllByBetweenDate(previousDay.toLocalDate().atStartOfDay().minusDays(1), previousDay.minusDays(1));
-
 
521
        Map<Integer, Long> dayBeforeYesterdayReturnOrderInfoModelMap = dayBeforeYesterdayReturnOrderInfoModels.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getRefundAmount()))));
-
 
522
 
-
 
523
        List<Order> dayBeforeYesterdayRtoRefundOrders = orderRepository.selectAllOrderDatesBetweenByStatus(previousDay.toLocalDate().atStartOfDay().minusDays(1), previousDay.minusDays(1), OrderStatus.RTO_REFUNDED);
-
 
524
        Map<Integer, Long> dayBeforeYesterdayRtoRefundOrderMap = dayBeforeYesterdayRtoRefundOrders.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getTotalAmount()))));
-
 
525
 
-
 
526
 
-
 
527
 
512
    //  last month return data
528
        //  last month return data
513
        YearMonth lastMonth = currentMonth.minusMonths(1);
529
        YearMonth lastMonth = currentMonth.minusMonths(1);
514
        String lastMonthStringValue = String.valueOf(lastMonth);
530
        String lastMonthStringValue = String.valueOf(lastMonth);
515
        LocalDateTime lastMontStartDate = lastMonth.atDay(1).atStartOfDay();
531
        LocalDateTime lastMontStartDate = lastMonth.atDay(1).atStartOfDay();
516
        LocalDateTime lastMonthEndDate = lastMonth.atEndOfMonth().atTime(23, 59, 59);
532
        LocalDateTime lastMonthEndDate = lastMonth.atEndOfMonth().atTime(23, 59, 59);
517
 
533
 
Line 528... Line 544...
528
        LocalDateTime twoMonthsAgoStartDate = twoMonthsAgo.atDay(1).atStartOfDay();
544
        LocalDateTime twoMonthsAgoStartDate = twoMonthsAgo.atDay(1).atStartOfDay();
529
        LocalDateTime twoMonthsAgoEndDate = twoMonthsAgo.atEndOfMonth().atTime(23, 59, 59);
545
        LocalDateTime twoMonthsAgoEndDate = twoMonthsAgo.atEndOfMonth().atTime(23, 59, 59);
530
 
546
 
531
        List<ReturnOrderInfoModel> twoMonthAgoReturnOrderInfoModels = returnOrderInfoRepository.selectAllByBetweenDate(twoMonthsAgoStartDate, twoMonthsAgoEndDate);
547
        List<ReturnOrderInfoModel> twoMonthAgoReturnOrderInfoModels = returnOrderInfoRepository.selectAllByBetweenDate(twoMonthsAgoStartDate, twoMonthsAgoEndDate);
532
        Map<Integer, Long> twoMonthAgoPartnerReturnOrderInfoModelMap = twoMonthAgoReturnOrderInfoModels.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getRefundAmount()))));
548
        Map<Integer, Long> twoMonthAgoPartnerReturnOrderInfoModelMap = twoMonthAgoReturnOrderInfoModels.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getRefundAmount()))));
533
LOGGER.info("twoMonthAgoReturnOrderInfoModels {}",twoMonthAgoReturnOrderInfoModels);
-
 
-
 
549
 
534
        List<Order> twoMonthRtoRefundOrders = orderRepository.selectAllOrderDatesBetweenByStatus(twoMonthsAgoStartDate, twoMonthsAgoEndDate, OrderStatus.RTO_REFUNDED);
550
        List<Order> twoMonthRtoRefundOrders = orderRepository.selectAllOrderDatesBetweenByStatus(twoMonthsAgoStartDate, twoMonthsAgoEndDate, OrderStatus.RTO_REFUNDED);
535
        Map<Integer, Long> twoMonthAgoRtoRefundOrderMap = twoMonthRtoRefundOrders.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getTotalAmount()))));
551
        Map<Integer, Long> twoMonthAgoRtoRefundOrderMap = twoMonthRtoRefundOrders.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getTotalAmount()))));
536
        LOGGER.info("twoMonthRtoRefundOrders {}",twoMonthRtoRefundOrders);
-
 
-
 
552
 
537
 
553
 
538
        Map<Integer , String> assessmentMap = new HashMap<>();
554
        Map<Integer , String> assessmentMap = new HashMap<>();
539
        Map<Integer , String> zeroBillingMap = new HashMap<>();
555
        Map<Integer , String> zeroBillingMap = new HashMap<>();
540
        Map<Integer , Float> billingNeededMap = new HashMap<>();
556
        Map<Integer , Float> billingNeededMap = new HashMap<>();
541
        Map<Integer , Integer> countAMap = new HashMap<>();
557
        Map<Integer , Integer> countAMap = new HashMap<>();
Line 550... Line 566...
550
 
566
 
551
        Map<Integer,Map<String, BrandStockPrice>> fofoBrandStockPriceMap = new HashMap<>();
567
        Map<Integer,Map<String, BrandStockPrice>> fofoBrandStockPriceMap = new HashMap<>();
552
 
568
 
553
        Map<Integer,Long> fofoTotalMtdSecondaryMap = new HashMap<>();
569
        Map<Integer,Long> fofoTotalMtdSecondaryMap = new HashMap<>();
554
 
570
 
-
 
571
        Map<Integer,Long> fofoYesterdaySecondaryMap = new HashMap<>();
-
 
572
 
-
 
573
        Map<Integer,Long> fofoDayBeforeYesterdaySecondaryMap = new HashMap<>();
555
 
574
 
556
        Map<Integer,Map<String, Long>> fofoBrandWiseMtdSecondaryMap = new HashMap<>();
575
        Map<Integer,Map<String, Long>> fofoBrandWiseMtdSecondaryMap = new HashMap<>();
557
 
576
 
558
        Map<Integer,Double> fofoTotalMtdTertiaryMap = new HashMap<>();
577
        Map<Integer,Double> fofoTotalMtdTertiaryMap = new HashMap<>();
559
 
578
 
Line 629... Line 648...
629
 
648
 
630
 
649
 
631
            Map<Integer, Double> secondaryMtd = orderRepository.selectOrderValueBetweenBillingDatesGroupByFofoId(Arrays.asList(fofoId),
650
            Map<Integer, Double> secondaryMtd = orderRepository.selectOrderValueBetweenBillingDatesGroupByFofoId(Arrays.asList(fofoId),
632
                    startOfToday.withDayOfMonth(1), previousDay).stream().collect(Collectors.toMap(x -> x.getId(), x -> x.getAmount()));
651
                    startOfToday.withDayOfMonth(1), previousDay).stream().collect(Collectors.toMap(x -> x.getId(), x -> x.getAmount()));
633
 
652
 
-
 
653
 
-
 
654
            //yesterday secondary
-
 
655
            Map<Integer, Double> dayBeforeYesterdaySecondary = orderRepository.selectOrderValueBetweenBillingDatesGroupByFofoId(Arrays.asList(fofoId),
-
 
656
                    previousDay.toLocalDate().atStartOfDay().minusDays(1), previousDay.minusDays(1)).stream().collect(Collectors.toMap(x -> x.getId(), x -> x.getAmount()));
-
 
657
            double dayBeforeYesterdayAfterReturnSecondary = dayBeforeYesterdaySecondary.getOrDefault(fofoId,0d) - (dayBeforeYesterdayReturnOrderInfoModelMap.getOrDefault(fofoId,0l) + dayBeforeYesterdayRtoRefundOrderMap.getOrDefault(fofoId,0l));
-
 
658
            fofoDayBeforeYesterdaySecondaryMap.put(fofoId, (long) dayBeforeYesterdayAfterReturnSecondary);
-
 
659
 
-
 
660
 
-
 
661
            //day before secondary
-
 
662
            Map<Integer, Double> yesterDaySecondary = orderRepository.selectOrderValueBetweenBillingDatesGroupByFofoId(Arrays.asList(fofoId),
-
 
663
                    previousDay.toLocalDate().atStartOfDay(), previousDay).stream().collect(Collectors.toMap(x -> x.getId(), x -> x.getAmount()));
-
 
664
            double yesterDayAfterReturnSecondary = yesterDaySecondary.getOrDefault(fofoId,0d) - (yesterdayReturnOrderInfoModelMap.getOrDefault(fofoId,0l) + yesterdayRtoRefundOrderMap.getOrDefault(fofoId,0l));
-
 
665
            fofoYesterdaySecondaryMap.put(fofoId, (long) yesterDayAfterReturnSecondary);
-
 
666
 
634
            double secondaryAchievedMtd = secondaryMtd.getOrDefault(fofoId, 0.0);
667
            double secondaryAchievedMtd = secondaryMtd.getOrDefault(fofoId, 0.0);
635
 
668
 
636
            double currentMonthNetSecondary = secondaryAchievedMtd - currentMonthReturn;
669
            double currentMonthNetSecondary = secondaryAchievedMtd - currentMonthReturn;
637
 
670
 
638
            double currentMonthSecondaryPercent = currentSecondaryTarget == 0 ? 0.0 : Math.round(Math.abs((secondaryAchievedMtd / currentSecondaryTarget) * 100));
671
            double currentMonthSecondaryPercent = currentSecondaryTarget == 0 ? 0.0 : Math.round(Math.abs((secondaryAchievedMtd / currentSecondaryTarget) * 100));
Line 913... Line 946...
913
                    zeroBilling = "-";
946
                    zeroBilling = "-";
914
                }
947
                }
915
                zeroBillingMap.put(fofoId,zeroBilling);
948
                zeroBillingMap.put(fofoId,zeroBilling);
916
 
949
 
917
                float billingNeeded = 0f;
950
                float billingNeeded = 0f;
918
                if(drrPercentDisplay >= 110 ){
951
                if(drrPercentDisplay >= 110 && todayRequiredDrr > 0 ){
919
                    billingNeeded = (float) todayRequiredDrr;
952
                    billingNeeded = (float) todayRequiredDrr;
920
                }else {
953
                }else {
921
                    billingNeeded = 0f;
954
                    billingNeeded = 0f;
922
                }
955
                }
923
                billingNeededMap.put(fofoId,billingNeeded);
956
                billingNeededMap.put(fofoId,billingNeeded);
Line 946... Line 979...
946
                currentMonthStringValue, "", "", "", "", "", "",
979
                currentMonthStringValue, "", "", "", "", "", "",
947
 
980
 
948
                "","", "", "", "", "", "", "", "", "", "", "", "", "",
981
                "","", "", "", "", "", "", "", "", "", "", "", "", "",
949
 
982
 
950
                "", "", "", "", "", "", "", "", "", "", "", "", "",
983
                "", "", "", "", "", "", "", "", "", "", "", "", "",
951
                "", "", "", "", "", "", "", "", "", "", "", "", ""
984
                "", "", "", "", "", "", "", "", "", "", "", "", "","",""
952
 
985
 
953
        );
986
        );
954
 
987
 
955
        List<String> headers2 = Arrays.asList(
988
        List<String> headers2 = Arrays.asList(
956
                "Assessment","Zero billing","Billing needed","Counta",
989
                "Assessment","Zero billing","Billing needed","Counta",
Line 964... Line 997...
964
                "Counter Potential", "Short investment", "Default", "INVESTMENT LEVEL", "Loan", "PO value", "Agreed investment",
997
                "Counter Potential", "Short investment", "Default", "INVESTMENT LEVEL", "Loan", "PO value", "Agreed investment",
965
                "Wallet", "po+bill", "MONTH BEGINNING DRR", "REQ DRR", "Drr %", "Last billing Done", "Slab",
998
                "Wallet", "po+bill", "MONTH BEGINNING DRR", "REQ DRR", "Drr %", "Last billing Done", "Slab",
966
 
999
 
967
              "Total Stock",  "Apple","Xiaomi", "Vivo", "Tecno", "Samsung", "Realme", "Oppo", "OnePlus", "POCO", "Lava", "Itel", "Almost New",
1000
              "Total Stock",  "Apple","Xiaomi", "Vivo", "Tecno", "Samsung", "Realme", "Oppo", "OnePlus", "POCO", "Lava", "Itel", "Almost New",
968
              "Total Secondary", "Apple", "Xiaomi", "Vivo", "Tecno", "Samsung", "Realme", "Oppo", "OnePlus", "POCO", "Lava", "Itel", "Almost New",
1001
              "Total Secondary", "Apple", "Xiaomi", "Vivo", "Tecno", "Samsung", "Realme", "Oppo", "OnePlus", "POCO", "Lava", "Itel", "Almost New",
969
              "Total Tertiary",  "Apple", "Xiaomi", "Vivo", "Tecno", "Samsung", "Realme", "Oppo", "OnePlus", "POCO", "Lava", "Itel", "Almost New"
1002
              "Total Tertiary",  "Apple", "Xiaomi", "Vivo", "Tecno", "Samsung", "Realme", "Oppo", "OnePlus", "POCO", "Lava", "Itel", "Almost New",
-
 
1003
                "YesterDay Seconday","Day Before Yesterday Secondary"
970
        );
1004
        );
971
 
1005
 
972
        headerGroup.add(headers1);
1006
        headerGroup.add(headers1);
973
        headerGroup.add(headers2);
1007
        headerGroup.add(headers2);
974
 
1008
 
975
 
1009
 
976
        List<List<?>> rows = new ArrayList<>();
1010
        List<List<?>> rows = new ArrayList<>();
977
        for (Map.Entry<Integer, BIRetailerModel> entry : biRetailerModelMap.entrySet()) {
1011
        for (Map.Entry<Integer, BIRetailerModel> entry : biRetailerModelMap.entrySet()) {
-
 
1012
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
978
            Integer fofoId = entry.getKey();
1013
            Integer fofoId = entry.getKey();
979
            User user = userRepository.selectById(fofoId);
1014
            User user = userRepository.selectById(fofoId);
980
            LocalDateTime walletCreationDate = userWalletHistoryRepository.selectFirstCreatedDate(fofoId);
1015
            LocalDateTime walletCreationDate = userWalletHistoryRepository.selectFirstCreatedDate(fofoId);
981
            BIRetailerModel retailer = entry.getValue();
1016
            BIRetailerModel retailer = entry.getValue();
982
 
1017
 
Line 987... Line 1022...
987
            BiSecondaryModel twoAgo = monthlyData.getOrDefault(currentMonth.minusMonths(2), new BiSecondaryModel(0,0,0,0,0,0,0));
1022
            BiSecondaryModel twoAgo = monthlyData.getOrDefault(currentMonth.minusMonths(2), new BiSecondaryModel(0,0,0,0,0,0,0));
988
 
1023
 
989
            List<Object> row = new ArrayList<>();
1024
            List<Object> row = new ArrayList<>();
990
            row.addAll(Arrays.asList(
1025
            row.addAll(Arrays.asList(
991
                    assessmentMap.get(fofoId),zeroBillingMap.get(fofoId),billingNeededMap.get(fofoId),countAMap.get(fofoId),
1026
                    assessmentMap.get(fofoId),zeroBillingMap.get(fofoId),billingNeededMap.get(fofoId),countAMap.get(fofoId),
992
                    retailer.getBmName(),fofoId ,"https://partners.smartdukaan.com/partnerPerformance?fofoId="+fofoId,walletCreationDate,user.getCreateTimestamp(), retailer.getCode(), retailer.getArea(), retailer.getCity(),  retailer.getStoreName(), retailer.getStatus(),
1027
                    retailer.getBmName(),fofoId ,"https://partners.smartdukaan.com/partnerPerformance?fofoId="+fofoId,walletCreationDate.format(formatter),(user.getCreateTimestamp()).format(formatter), retailer.getCode(), retailer.getArea(), retailer.getCity(),  retailer.getStoreName(), retailer.getStatus(),
993
                    retailer.getCategory(),  retailer.getSalesManager(), retailer.getRbm()
1028
                    retailer.getCategory(),  retailer.getSalesManager(), retailer.getRbm()
994
 
1029
 
995
            ));
1030
            ));
996
 
1031
 
997
 
1032
 
Line 1102... Line 1137...
1102
                    brandTertiaryMap.getOrDefault("POCO", 0d),
1137
                    brandTertiaryMap.getOrDefault("POCO", 0d),
1103
                    brandTertiaryMap.getOrDefault("Lava", 0d),
1138
                    brandTertiaryMap.getOrDefault("Lava", 0d),
1104
                    brandTertiaryMap.getOrDefault("Itel", 0d),
1139
                    brandTertiaryMap.getOrDefault("Itel", 0d),
1105
                    brandTertiaryMap.getOrDefault("Almost New", 0d)
1140
                    brandTertiaryMap.getOrDefault("Almost New", 0d)
1106
            ));
1141
            ));
-
 
1142
 
-
 
1143
            row.addAll(Arrays.asList(
-
 
1144
                    fofoYesterdaySecondaryMap.get(fofoId),
-
 
1145
                    fofoDayBeforeYesterdaySecondaryMap.get(fofoId)
-
 
1146
            ));
1107
            rows.add(row);
1147
            rows.add(row);
1108
        }
1148
        }
1109
 
1149
 
1110
 
1150
 
1111
        // Send to email
1151
        // Send to email
1112
//        ByteArrayOutputStream csvStream = FileUtil.getCSVByteStreamWithMultiHeaders(headerGroup, rows);
1152
//        ByteArrayOutputStream csvStream = FileUtil.getCSVByteStreamWithMultiHeaders(headerGroup, rows);
1113
        ByteArrayOutputStream csvStream = getExcelStreamWithMultiHeaders(headerGroup, rows);
1153
        ByteArrayOutputStream csvStream = getExcelStreamWithMultiHeaders(headerGroup, rows);
1114
        String fileName = "BI-Retailer-Monthly-Report-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".xlsx";
1154
        String fileName = "BI-Retailer-Monthly-Report-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".xlsx";
1115
        String[] sendToArray = new String[]{"ranu.rajput@smartdukaan.com","ashutosh.verma@smartdukaan.com","sm@smartdukaan.com","raj.singh@smartdukaan.com"};
1155
//        String[] sendToArray = new String[]{"ranu.rajput@smartdukaan.com","ashutosh.verma@smartdukaan.com","sm@smartdukaan.com","raj.singh@smartdukaan.com"};
1116
//        String[] sendToArray = new String[]{"ranu.rajput@smartdukaan.com"};
1156
        String[] sendToArray = new String[]{"ranu.rajput@smartdukaan.com"};
1117
 
1157
 
1118
        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()));
1158
        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()));
1119
 
1159
 
1120
 
1160
 
1121
    }
1161
    }
Line 1234... Line 1274...
1234
        CellStyle defaultHeaderStyle = workbook.createCellStyle();
1274
        CellStyle defaultHeaderStyle = workbook.createCellStyle();
1235
        defaultHeaderStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());
1275
        defaultHeaderStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());
1236
        defaultHeaderStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
1276
        defaultHeaderStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
1237
        defaultHeaderStyle.setFont(font1);
1277
        defaultHeaderStyle.setFont(font1);
1238
 
1278
 
-
 
1279
        CellStyle numberStyle = workbook.createCellStyle();
-
 
1280
        DataFormat format = workbook.createDataFormat();
-
 
1281
        numberStyle.setDataFormat(format.getFormat("#,##0")); // or "#,##0.00" for two decimals
-
 
1282
 
-
 
1283
 
1239
 
1284
 
1240
        Map<String, Integer> headerCount = new HashMap<>();
1285
        Map<String, Integer> headerCount = new HashMap<>();
1241
 
1286
 
1242
        for (int headerRowIndex = 0; headerRowIndex < headerGroup.size(); headerRowIndex++) {
1287
        for (int headerRowIndex = 0; headerRowIndex < headerGroup.size(); headerRowIndex++) {
1243
            List<String> headerRow = headerGroup.get(headerRowIndex);
1288
            List<String> headerRow = headerGroup.get(headerRowIndex);
Line 1286... Line 1331...
1286
                    hyperlink.setAddress(value.toString());
1331
                    hyperlink.setAddress(value.toString());
1287
                    cell.setCellValue("View Link"); // Display text
1332
                    cell.setCellValue("View Link"); // Display text
1288
                    cell.setHyperlink(hyperlink);
1333
                    cell.setHyperlink(hyperlink);
1289
                    cell.setCellStyle(hyperlinkStyle);
1334
                    cell.setCellStyle(hyperlinkStyle);
1290
                } else if (value instanceof Number) {
1335
                } else if (value instanceof Number) {
1291
                    cell.setCellValue(((Number) value).doubleValue());
1336
                    double numeric = ((Number) value).doubleValue();
-
 
1337
                    cell.setCellValue(Math.round(numeric));
-
 
1338
                    cell.setCellStyle(numberStyle);
1292
                } else {
1339
                } else {
1293
                    cell.setCellValue(value != null ? value.toString() : "");
1340
                    cell.setCellValue(value != null ? value.toString() : "");
1294
                }
1341
                }
1295
            }
1342
            }
1296
 
1343