Subversion Repositories SmartDukaan

Rev

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

Rev 32308 Rev 32313
Line 401... Line 401...
401
 
401
 
402
                Scheme staticScheme = schemeService.getStaticScheme(fofoId);
402
                Scheme staticScheme = schemeService.getStaticScheme(fofoId);
403
                double schemeAchievement = 0;
403
                double schemeAchievement = 0;
404
                String schemeCategory = null;
404
                String schemeCategory = null;
405
                if (staticScheme != null) {
405
                if (staticScheme != null) {
406
                    schemeAchievement = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(staticScheme.getStartDateTime(), staticScheme.getEndDateTime()).get(fofoId);
406
                    Map<Integer, Double> schemeAchievementMap = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(staticScheme.getStartDateTime(), staticScheme.getEndDateTime());
-
 
407
                    if (schemeAchievementMap.get(fofoId) != null) {
-
 
408
                        schemeAchievement = schemeAchievementMap.get(fofoId);
407
                    if (staticScheme.getTarget() >= 2500000 && staticScheme.getTarget() < 3750000) {
409
                        if (staticScheme.getTarget() >= 2500000 && staticScheme.getTarget() < 3750000) {
408
                        schemeCategory = "SD Club";
410
                            schemeCategory = "SD Club";
409
                    } else if (staticScheme.getTarget() < 5000000) {
411
                        } else if (staticScheme.getTarget() < 5000000) {
410
                        schemeCategory = "Silver";
412
                            schemeCategory = "Silver";
411
                    } else if (staticScheme.getTarget() < 7500000) {
413
                        } else if (staticScheme.getTarget() < 7500000) {
412
                        schemeCategory = "Gold - 1";
414
                            schemeCategory = "Gold - 1";
413
                    } else if (staticScheme.getTarget() < 10000000) {
415
                        } else if (staticScheme.getTarget() < 10000000) {
414
                        schemeCategory = "Gold - 2";
416
                            schemeCategory = "Gold - 2";
415
                    } else if (staticScheme.getTarget() < 12500000) {
417
                        } else if (staticScheme.getTarget() < 12500000) {
416
                        schemeCategory = "Diamond";
418
                            schemeCategory = "Diamond";
417
                    } else {
419
                        } else {
418
                        schemeCategory = "Platinum";
420
                            schemeCategory = "Platinum";
-
 
421
                        }
419
                    }
422
                    }
420
                }
423
                }
421
 
424
 
422
 
425
 
423
                model.addAttribute("countOrder", countOrder);
426
                model.addAttribute("countOrder", countOrder);
Line 482... Line 485...
482
                model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
485
                model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
483
                model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
486
                model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
484
                model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
487
                model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
485
 
488
 
486
            } catch (
489
            } catch (
487
                    ProfitMandiBusinessException e) {
490
                ProfitMandiBusinessException e) {
488
                LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
491
                LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
489
 
492
 
490
            }
493
            }
491
            return "dashboard1";
494
            return "dashboard1";
492
        }
495
        }
Line 579... Line 582...
579
 
582
 
580
    @Autowired
583
    @Autowired
581
    OfferPayoutRepository offerPayoutRepository;
584
    OfferPayoutRepository offerPayoutRepository;
582
 
585
 
583
    @RequestMapping(value = "/partnerTotalIncomeByMonth/{yearMonth}", method = RequestMethod.GET)
586
    @RequestMapping(value = "/partnerTotalIncomeByMonth/{yearMonth}", method = RequestMethod.GET)
584
    public String getPartnerTotalIncomeByMonth(HttpServletRequest request, @PathVariable int yearMonth, Model
587
    public String getPartnerTotalIncomeByMonth(HttpServletRequest request, @PathVariable int yearMonth, Model model) throws Exception {
585
            model) throws Exception {
-
 
586
 
588
 
587
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
589
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
588
        long pendingIncome = 0;
590
        long pendingIncome = 0;
589
        long partnerPurchaseIn = 0;
591
        long partnerPurchaseIn = 0;
590
        long partnerCreditedSale = 0;
592
        long partnerCreditedSale = 0;
Line 668... Line 670...
668
 
670
 
669
        return "partner-total-income";
671
        return "partner-total-income";
670
    }
672
    }
671
 
673
 
672
    @RequestMapping(value = "/getMonthsInvestment", method = RequestMethod.GET)
674
    @RequestMapping(value = "/getMonthsInvestment", method = RequestMethod.GET)
673
    public String getMonthsInvestment(HttpServletRequest request,
-
 
674
                                      @RequestParam(name = "month", required = true, defaultValue = "0") int month, Model model) throws Exception {
675
    public String getMonthsInvestment(HttpServletRequest request, @RequestParam(name = "month", required = true, defaultValue = "0") int month, Model model) throws Exception {
675
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
676
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
676
        int fofoId = loginDetails.getFofoId();
677
        int fofoId = loginDetails.getFofoId();
677
        Map<String, Object> investment = fofoUser.getInvestmentsMonths(fofoId, month);
678
        Map<String, Object> investment = fofoUser.getInvestmentsMonths(fofoId, month);
678
 
679
 
679
        LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
680
        LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
Line 752... Line 753...
752
 
753
 
753
        return "bar_chart";
754
        return "bar_chart";
754
    }
755
    }
755
 
756
 
756
    @RequestMapping(value = "/getPriceDropDetails", method = RequestMethod.GET)
757
    @RequestMapping(value = "/getPriceDropDetails", method = RequestMethod.GET)
757
    public String getPriceDropDetails(HttpServletRequest request,
758
    public String getPriceDropDetails(HttpServletRequest request, @RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId, @RequestParam(name = "brand", required = true, defaultValue = "0") String brand, @RequestParam(name = "yearMonth", required = false, defaultValue = "0") String yearMonth, Model model) throws Exception {
758
                                      @RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
-
 
759
                                      @RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
-
 
760
                                      @RequestParam(name = "yearMonth", required = false, defaultValue = "0") String yearMonth, Model model) throws
-
 
761
            Exception {
-
 
762
 
759
 
763
        LOGGER.info("params" + fofoId + brand + yearMonth);
760
        LOGGER.info("params" + fofoId + brand + yearMonth);
764
 
761
 
765
        List<PriceDropWithDetailsByYearMonthModel> priceDropdetailsList = priceDropRepository.selectBrandPendingPriceDropWithDetailsByYearMonth(fofoId, brand, yearMonth);
762
        List<PriceDropWithDetailsByYearMonthModel> priceDropdetailsList = priceDropRepository.selectBrandPendingPriceDropWithDetailsByYearMonth(fofoId, brand, yearMonth);
766
 
763
 
Line 770... Line 767...
770
 
767
 
771
        return "price-drop-details";
768
        return "price-drop-details";
772
    }
769
    }
773
 
770
 
774
    @RequestMapping(value = "/getPriceDropDetailSixMonths", method = RequestMethod.GET)
771
    @RequestMapping(value = "/getPriceDropDetailSixMonths", method = RequestMethod.GET)
775
    public String getPriceDropDetailSixMonths(HttpServletRequest request,
772
    public String getPriceDropDetailSixMonths(HttpServletRequest request, @RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId, @RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model) throws Exception {
776
                                              @RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
-
 
777
                                              @RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model) throws
-
 
778
            Exception {
-
 
779
 
773
 
780
        LOGGER.info("params" + fofoId + brand);
774
        LOGGER.info("params" + fofoId + brand);
781
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
775
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
782
        LocalDateTime startfMonthSixMonth = curDate.withDayOfMonth(1).minusMonths(12);
776
        LocalDateTime startfMonthSixMonth = curDate.withDayOfMonth(1).minusMonths(12);
783
        LocalDateTime endMonthTotal = curDate.withDayOfMonth(1).minusMonths(6);
777
        LocalDateTime endMonthTotal = curDate.withDayOfMonth(1).minusMonths(6);
Line 970... Line 964...
970
        model.addAttribute("fofoId", fofoId);
964
        model.addAttribute("fofoId", fofoId);
971
        return "activation-tabular";
965
        return "activation-tabular";
972
    }
966
    }
973
 
967
 
974
    @RequestMapping(value = "/getMonthlyActivationItemDetail", method = RequestMethod.GET)
968
    @RequestMapping(value = "/getMonthlyActivationItemDetail", method = RequestMethod.GET)
975
    public String getMonthlyActivationItemDetail(HttpServletRequest request,
969
    public String getMonthlyActivationItemDetail(HttpServletRequest request, @RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId, @RequestParam(name = "brand", required = true, defaultValue = "0") String brand, @RequestParam(name = "yearMonth", required = false, defaultValue = "0") String yearMonth, Model model) throws Exception {
976
                                                 @RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
-
 
977
                                                 @RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
-
 
978
                                                 @RequestParam(name = "yearMonth", required = false, defaultValue = "0") String yearMonth, Model model) throws
-
 
979
            Exception {
-
 
980
 
970
 
981
        LOGGER.info("params" + fofoId + brand + yearMonth);
971
        LOGGER.info("params" + fofoId + brand + yearMonth);
982
 
972
 
983
        List<ActivationItemDetailModel> activationItemDetails = schemeInOutRepository.selectBrandPendingActivationItemDetails(fofoId, brand, yearMonth);
973
        List<ActivationItemDetailModel> activationItemDetails = schemeInOutRepository.selectBrandPendingActivationItemDetails(fofoId, brand, yearMonth);
984
 
974
 
Line 1004... Line 994...
1004
 
994
 
1005
        return "activation-pending-item-details";
995
        return "activation-pending-item-details";
1006
    }
996
    }
1007
 
997
 
1008
    @RequestMapping(value = "/getMonthlyActivationBeforeSixMonthsItemDetail", method = RequestMethod.GET)
998
    @RequestMapping(value = "/getMonthlyActivationBeforeSixMonthsItemDetail", method = RequestMethod.GET)
1009
    public String getMonthlyActivationItemDetail(HttpServletRequest request,
999
    public String getMonthlyActivationItemDetail(HttpServletRequest request, @RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId, @RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model) throws Exception {
1010
                                                 @RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
-
 
1011
                                                 @RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model) throws
-
 
1012
            Exception {
-
 
1013
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
1000
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
1014
 
1001
 
1015
        LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
1002
        LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
1016
 
1003
 
1017
        List<ActivationItemDetailModel> activationItemDetails = schemeInOutRepository.selectBrandPendingActivationItemDetailByYearMonth(fofoId, brand, startOfMonth);
1004
        List<ActivationItemDetailModel> activationItemDetails = schemeInOutRepository.selectBrandPendingActivationItemDetailByYearMonth(fofoId, brand, startOfMonth);
Line 1110... Line 1097...
1110
        return "upgrade-offer-tabular";
1097
        return "upgrade-offer-tabular";
1111
 
1098
 
1112
    }
1099
    }
1113
 
1100
 
1114
    @RequestMapping(value = "/getMonthlyUpgradeOfferItemDetail", method = RequestMethod.GET)
1101
    @RequestMapping(value = "/getMonthlyUpgradeOfferItemDetail", method = RequestMethod.GET)
1115
    public String getMonthlyUpgradeOfferItemDetail(HttpServletRequest request,
1102
    public String getMonthlyUpgradeOfferItemDetail(HttpServletRequest request, @RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId, @RequestParam(name = "brand", required = true, defaultValue = "0") String brand, @RequestParam(name = "yearMonth", required = false, defaultValue = "0") String yearMonth, Model model) throws Exception {
1116
                                                   @RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
-
 
1117
                                                   @RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
-
 
1118
                                                   @RequestParam(name = "yearMonth", required = false, defaultValue = "0") String yearMonth, Model model) throws
-
 
1119
            Exception {
-
 
1120
 
1103
 
1121
        LOGGER.info("params" + fofoId + brand + yearMonth);
1104
        LOGGER.info("params" + fofoId + brand + yearMonth);
1122
        List<UpgradeOfferItemDetailModel> offerItems = samsungUpgradeOfferRepository.selectUpgradeOfferItemDetails(fofoId, UpgradeOfferStatus.approved, brand, yearMonth);
1105
        List<UpgradeOfferItemDetailModel> offerItems = samsungUpgradeOfferRepository.selectUpgradeOfferItemDetails(fofoId, UpgradeOfferStatus.approved, brand, yearMonth);
1123
 
1106
 
1124
        model.addAttribute("offerItems", offerItems);
1107
        model.addAttribute("offerItems", offerItems);
1125
 
1108
 
1126
        return "upgrade-offer-item-detail";
1109
        return "upgrade-offer-item-detail";
1127
    }
1110
    }
1128
 
1111
 
1129
    @RequestMapping(value = "/getUpgradeOfferBeforeSixMonthItemDetail", method = RequestMethod.GET)
1112
    @RequestMapping(value = "/getUpgradeOfferBeforeSixMonthItemDetail", method = RequestMethod.GET)
1130
    public String getUpgradeOfferBeforeSixMonthItemDetail(HttpServletRequest request,
1113
    public String getUpgradeOfferBeforeSixMonthItemDetail(HttpServletRequest request, @RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId, @RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model) throws Exception {
1131
                                                          @RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
-
 
1132
                                                          @RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model) throws
-
 
1133
            Exception {
-
 
1134
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
1114
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
1135
 
1115
 
1136
        LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
1116
        LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
1137
 
1117
 
1138
        List<UpgradeOfferItemDetailModel> offerItems = samsungUpgradeOfferRepository.selectUpgradeOfferItemDetailByYearMonth(fofoId, UpgradeOfferStatus.approved, brand, startOfMonth);
1118
        List<UpgradeOfferItemDetailModel> offerItems = samsungUpgradeOfferRepository.selectUpgradeOfferItemDetailByYearMonth(fofoId, UpgradeOfferStatus.approved, brand, startOfMonth);
Line 1141... Line 1121...
1141
 
1121
 
1142
        return "upgrade-offer-item-detail";
1122
        return "upgrade-offer-item-detail";
1143
    }
1123
    }
1144
 
1124
 
1145
    @RequestMapping(value = "/getAuthUserPartners", method = RequestMethod.GET)
1125
    @RequestMapping(value = "/getAuthUserPartners", method = RequestMethod.GET)
1146
    public String AuthUserPartnersDetail(HttpServletRequest request, Model model, @RequestParam int authId) throws
1126
    public String AuthUserPartnersDetail(HttpServletRequest request, Model model, @RequestParam int authId) throws Exception {
1147
            Exception {
-
 
1148
 
1127
 
1149
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
1128
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
1150
        Map<Integer, CustomRetailer> fofoIdAndPartnerMap = retailerService.getFofoRetailers(false);
1129
        Map<Integer, CustomRetailer> fofoIdAndPartnerMap = retailerService.getFofoRetailers(false);
1151
 
1130
 
1152
        Map<Integer, PartnerDetailModel> fofoIdAndallValues = partnerStatsService.getAllPartnerStats();
1131
        Map<Integer, PartnerDetailModel> fofoIdAndallValues = partnerStatsService.getAllPartnerStats();
Line 1161... Line 1140...
1161
 
1140
 
1162
        return "auth_user_partner_detail";
1141
        return "auth_user_partner_detail";
1163
    }
1142
    }
1164
 
1143
 
1165
    @RequestMapping(value = "/getWarehousePartners", method = RequestMethod.GET)
1144
    @RequestMapping(value = "/getWarehousePartners", method = RequestMethod.GET)
1166
    public String warehousePartnersDetail(HttpServletRequest request, Model model, @RequestParam int warehouseId) throws
1145
    public String warehousePartnersDetail(HttpServletRequest request, Model model, @RequestParam int warehouseId) throws Exception {
1167
            Exception {
-
 
1168
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1146
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1169
        String email = loginDetails.getEmailId();
1147
        String email = loginDetails.getEmailId();
1170
 
1148
 
1171
        Set<Integer> authfofoIds = new HashSet<>();
1149
        Set<Integer> authfofoIds = new HashSet<>();
1172
        authfofoIds = csService1.getAuthFofoIds(email, true);
1150
        authfofoIds = csService1.getAuthFofoIds(email, true);
Line 1206... Line 1184...
1206
        return "auth_user_partner_detail";
1184
        return "auth_user_partner_detail";
1207
    }
1185
    }
1208
 
1186
 
1209
 
1187
 
1210
    @RequestMapping(value = "/getWarehouseWiseBrandStock", method = RequestMethod.GET)
1188
    @RequestMapping(value = "/getWarehouseWiseBrandStock", method = RequestMethod.GET)
1211
    public String getWarehouseWiseBrandStock(HttpServletRequest request, Model
1189
    public String getWarehouseWiseBrandStock(HttpServletRequest request, Model model, @RequestParam List<Integer> warehouseId) throws Exception {
1212
            model, @RequestParam List<Integer> warehouseId) throws Exception {
-
 
1213
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1190
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1214
        String email = loginDetails.getEmailId();
1191
        String email = loginDetails.getEmailId();
1215
        Set<Integer> authfofoIds = csService1.getAuthFofoIds(email, true);
1192
        Set<Integer> authfofoIds = csService1.getAuthFofoIds(email, true);
1216
        Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository.selectActivePartnersByRetailerIds(new ArrayList<>(authfofoIds)).stream().collect(Collectors.groupingBy(
1193
        Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository.selectActivePartnersByRetailerIds(new ArrayList<>(authfofoIds)).stream().collect(Collectors.groupingBy(
1217
                FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
1194
                FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
Line 1237... Line 1214...
1237
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
1214
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
1238
        return "response";
1215
        return "response";
1239
    }
1216
    }
1240
 
1217
 
1241
    @RequestMapping(value = "/getWarehouseWiseBrandAndCategory", method = RequestMethod.GET)
1218
    @RequestMapping(value = "/getWarehouseWiseBrandAndCategory", method = RequestMethod.GET)
1242
    public String getWarehouseWiseBrandAndCategory(HttpServletRequest request, Model
-
 
1243
            model, @RequestParam List<Integer> warehouseId, @RequestParam List<String> brands, @RequestParam String
1219
    public String getWarehouseWiseBrandAndCategory(HttpServletRequest request, Model model, @RequestParam List<Integer> warehouseId, @RequestParam List<String> brands, @RequestParam String category) throws Exception {
1244
                                                           category) throws Exception {
-
 
1245
 
1220
 
1246
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1221
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1247
        List<String> listbrands = saholicInventoryCISRepository.selectAllBrand();
1222
        List<String> listbrands = saholicInventoryCISRepository.selectAllBrand();
1248
        List<String> listCategory = saholicInventoryCISRepository.selectAllSubCategory();
1223
        List<String> listCategory = saholicInventoryCISRepository.selectAllSubCategory();
1249
 
1224
 
Line 1257... Line 1232...
1257
 
1232
 
1258
        return "warehouse_brand_item_stock";
1233
        return "warehouse_brand_item_stock";
1259
    }
1234
    }
1260
 
1235
 
1261
    @RequestMapping(value = "/getWarehouseWiseItemStock", method = RequestMethod.GET)
1236
    @RequestMapping(value = "/getWarehouseWiseItemStock", method = RequestMethod.GET)
1262
    public String getWarehouseWiseItemStock(HttpServletRequest request, Model
-
 
1263
            model, @RequestParam List<Integer> warehouseId, @RequestParam List<String> brands, @RequestParam String
1237
    public String getWarehouseWiseItemStock(HttpServletRequest request, Model model, @RequestParam List<Integer> warehouseId, @RequestParam List<String> brands, @RequestParam String category) throws Exception {
1264
                                                    category) throws Exception {
-
 
1265
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1238
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1266
        if (warehouseId.contains(0)) {
1239
        if (warehouseId.contains(0)) {
1267
            warehouseId.addAll(warehouseMap.keySet());
1240
            warehouseId.addAll(warehouseMap.keySet());
1268
        }
1241
        }
1269
        List<WarehouseWiseitemStockModel> warehouseWiseItemStock = saholicInventoryCISRepository.selectWarehouseItemStock(warehouseId, brands, category);
1242
        List<WarehouseWiseitemStockModel> warehouseWiseItemStock = saholicInventoryCISRepository.selectWarehouseItemStock(warehouseId, brands, category);
Line 1272... Line 1245...
1272
        model.addAttribute("warehouseMap", warehouseMap);
1245
        model.addAttribute("warehouseMap", warehouseMap);
1273
        return "warehouse_item_details";
1246
        return "warehouse_item_details";
1274
    }
1247
    }
1275
 
1248
 
1276
    @RequestMapping(value = "/getWarehouseWiseBrandPartnerSale", method = RequestMethod.GET)
1249
    @RequestMapping(value = "/getWarehouseWiseBrandPartnerSale", method = RequestMethod.GET)
1277
    public String getWarehouseWiseBrandPartnerSale(HttpServletRequest request, Model
1250
    public String getWarehouseWiseBrandPartnerSale(HttpServletRequest request, Model model, @RequestParam String brand) throws Exception {
1278
            model, @RequestParam String brand) throws Exception {
-
 
1279
 
1251
 
1280
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1252
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1281
        String email = loginDetails.getEmailId();
1253
        String email = loginDetails.getEmailId();
1282
 
1254
 
1283
        Set<Integer> authfofoIds = csService1.getAuthFofoIds(email, true);
1255
        Set<Integer> authfofoIds = csService1.getAuthFofoIds(email, true);
Line 1314... Line 1286...
1314
        model.addAttribute("selectedbrand", brand);
1286
        model.addAttribute("selectedbrand", brand);
1315
        return "warehousewise_brand_partners_sale";
1287
        return "warehousewise_brand_partners_sale";
1316
    }
1288
    }
1317
 
1289
 
1318
    @RequestMapping(value = "/getWarehouseWiseAccesoriesBrandPartnerSale", method = RequestMethod.GET)
1290
    @RequestMapping(value = "/getWarehouseWiseAccesoriesBrandPartnerSale", method = RequestMethod.GET)
1319
    public String getWarehouseWiseAccesoriesBrandPartnerSale(HttpServletRequest request, Model
1291
    public String getWarehouseWiseAccesoriesBrandPartnerSale(HttpServletRequest request, Model model, @RequestParam String brand) throws Exception {
1320
            model, @RequestParam String brand) throws Exception {
-
 
1321
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1292
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1322
        String email = loginDetails.getEmailId();
1293
        String email = loginDetails.getEmailId();
1323
        Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
1294
        Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
1324
        Set<Integer> authfofoIds = storeGuyMap.get(email);
1295
        Set<Integer> authfofoIds = storeGuyMap.get(email);
1325
 
1296
 
Line 1340... Line 1311...
1340
        model.addAttribute("selectedbrand", brand);
1311
        model.addAttribute("selectedbrand", brand);
1341
        return "warehousewise_accessoriesbrand_sale";
1312
        return "warehousewise_accessoriesbrand_sale";
1342
    }
1313
    }
1343
 
1314
 
1344
    @RequestMapping(value = "/getWarehouseBrandWiseItemSale", method = RequestMethod.GET)
1315
    @RequestMapping(value = "/getWarehouseBrandWiseItemSale", method = RequestMethod.GET)
1345
    public String getWarehouseBrandWiseItemSale(HttpServletRequest request, Model
-
 
1346
            model, @RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
1316
    public String getWarehouseBrandWiseItemSale(HttpServletRequest request, Model model, @RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
1347
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1317
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1348
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1318
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1349
        String email = loginDetails.getEmailId();
1319
        String email = loginDetails.getEmailId();
1350
        Set<Integer> authfofoIds = csService1.getAuthFofoIds(email, true);
1320
        Set<Integer> authfofoIds = csService1.getAuthFofoIds(email, true);
1351
        Map<Integer, WarehouseBrandWiseItemSaleModel> branditemSalesMap = fofoStoreRepository.selectWarehouseBrandItemSale(warehouseId, brand, new ArrayList<>(authfofoIds)).stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x));
1321
        Map<Integer, WarehouseBrandWiseItemSaleModel> branditemSalesMap = fofoStoreRepository.selectWarehouseBrandItemSale(warehouseId, brand, new ArrayList<>(authfofoIds)).stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x));
Line 1380... Line 1350...
1380
        model.addAttribute("warehouseMap", warehouseMap);
1350
        model.addAttribute("warehouseMap", warehouseMap);
1381
        return "warehouse_partner_itemwise_sale";
1351
        return "warehouse_partner_itemwise_sale";
1382
    }
1352
    }
1383
 
1353
 
1384
    @RequestMapping(value = "/getWarehouseAccesoriesBrandWiseItemSale", method = RequestMethod.GET)
1354
    @RequestMapping(value = "/getWarehouseAccesoriesBrandWiseItemSale", method = RequestMethod.GET)
1385
    public String getWarehouseAccesoriesBrandWiseItemSale(HttpServletRequest request, Model
-
 
1386
            model, @RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
1355
    public String getWarehouseAccesoriesBrandWiseItemSale(HttpServletRequest request, Model model, @RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
1387
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1356
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1388
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1357
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1389
        String email = loginDetails.getEmailId();
1358
        String email = loginDetails.getEmailId();
1390
        Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
1359
        Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
1391
        Set<Integer> authfofoIds = storeGuyMap.get(email);
1360
        Set<Integer> authfofoIds = storeGuyMap.get(email);
Line 1400... Line 1369...
1400
        model.addAttribute("appContextPath", request.getContextPath());
1369
        model.addAttribute("appContextPath", request.getContextPath());
1401
        return "contact-us";
1370
        return "contact-us";
1402
    }
1371
    }
1403
 
1372
 
1404
    @RequestMapping(value = "/notifications", method = RequestMethod.GET)
1373
    @RequestMapping(value = "/notifications", method = RequestMethod.GET)
1405
    public String getNotificationsWithType(HttpServletRequest
1374
    public String getNotificationsWithType(HttpServletRequest request, @RequestParam(required = false) MessageType messageType, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "20") int limit, Model model) throws Exception {
1406
                                                   request, @RequestParam(required = false) MessageType messageType,
-
 
1407
                                           @RequestParam(name = "offset", defaultValue = "0") int offset,
-
 
1408
                                           @RequestParam(name = "limit", defaultValue = "20") int limit, Model model) throws Exception {
-
 
1409
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1375
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1410
        int userId = 0;
1376
        int userId = 0;
1411
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
1377
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
1412
        if (isAdmin) {
1378
        if (isAdmin) {
1413
            userId = loginDetails.getFofoId();
1379
            userId = loginDetails.getFofoId();
Line 1425... Line 1391...
1425
        LOGGER.info("notifications" + notifications);
1391
        LOGGER.info("notifications" + notifications);
1426
        return "notification-template";
1392
        return "notification-template";
1427
    }
1393
    }
1428
 
1394
 
1429
    @RequestMapping(value = "/notifyDocument/documentId", method = RequestMethod.GET)
1395
    @RequestMapping(value = "/notifyDocument/documentId", method = RequestMethod.GET)
1430
    public ResponseEntity<?> retailerDocumentById(HttpServletRequest request,
-
 
1431
                                                  @RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId, @RequestParam int cid) throws
1396
    public ResponseEntity<?> retailerDocumentById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId, @RequestParam int cid) throws ProfitMandiBusinessException {
1432
            ProfitMandiBusinessException {
-
 
1433
        Document document = documentRepository.selectById(documentId);
1397
        Document document = documentRepository.selectById(documentId);
1434
        NotificationCampaign nc = notificationCampaignRepository.selectById(cid);
1398
        NotificationCampaign nc = notificationCampaignRepository.selectById(cid);
1435
        if (nc.getDocumentId() == null) {
1399
        if (nc.getDocumentId() == null) {
1436
            throw new ProfitMandiBusinessException("cid", nc.getId(), "not available");
1400
            throw new ProfitMandiBusinessException("cid", nc.getId(), "not available");
1437
        }
1401
        }
Line 1440... Line 1404...
1440
        }
1404
        }
1441
        return responseSender.ok(document);
1405
        return responseSender.ok(document);
1442
    }
1406
    }
1443
 
1407
 
1444
    @RequestMapping(value = "/notifyDocument/download", method = RequestMethod.GET)
1408
    @RequestMapping(value = "/notifyDocument/download", method = RequestMethod.GET)
1445
    public ResponseEntity<?> downloadRetailerDocument(HttpServletRequest request, @RequestParam int cid, Model
1409
    public ResponseEntity<?> downloadRetailerDocument(HttpServletRequest request, @RequestParam int cid, Model model) throws ProfitMandiBusinessException {
1446
            model) throws ProfitMandiBusinessException {
-
 
1447
 
1410
 
1448
        NotificationCampaign nc = notificationCampaignRepository.selectById(cid);
1411
        NotificationCampaign nc = notificationCampaignRepository.selectById(cid);
1449
 
1412
 
1450
        if (nc.getDocumentId() == null) {
1413
        if (nc.getDocumentId() == null) {
1451
            throw new ProfitMandiBusinessException("cid", nc.getId(), "not available");
1414
            throw new ProfitMandiBusinessException("cid", nc.getId(), "not available");
Line 1479... Line 1442...
1479
        final InputStreamResource inputStreamResource = new InputStreamResource(file);
1442
        final InputStreamResource inputStreamResource = new InputStreamResource(file);
1480
        return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
1443
        return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
1481
    }
1444
    }
1482
 
1445
 
1483
    @RequestMapping(value = "/getItemWiseTertiary", method = RequestMethod.GET)
1446
    @RequestMapping(value = "/getItemWiseTertiary", method = RequestMethod.GET)
1484
    public String getItemWiseTertiary(HttpServletRequest request,
-
 
1485
                                      @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws
1447
    public String getItemWiseTertiary(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws ProfitMandiBusinessException {
1486
            ProfitMandiBusinessException {
-
 
1487
        List<ItemWiseTertiaryModel> itemWiseTertiary = fofoOrderRepository.SelectItemWiseTertiary(fofoId);
1448
        List<ItemWiseTertiaryModel> itemWiseTertiary = fofoOrderRepository.SelectItemWiseTertiary(fofoId);
1488
 
1449
 
1489
        LOGGER.info("itemWiseTertiary" + itemWiseTertiary);
1450
        LOGGER.info("itemWiseTertiary" + itemWiseTertiary);
1490
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1451
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1491
        model.addAttribute("customRetailer", customRetailer);
1452
        model.addAttribute("customRetailer", customRetailer);
1492
        model.addAttribute("itemWiseTertiary", itemWiseTertiary);
1453
        model.addAttribute("itemWiseTertiary", itemWiseTertiary);
1493
        return "item-wise-tertiary";
1454
        return "item-wise-tertiary";
1494
    }
1455
    }
1495
 
1456
 
1496
    @RequestMapping(value = "/getItemWiseIndent", method = RequestMethod.GET)
1457
    @RequestMapping(value = "/getItemWiseIndent", method = RequestMethod.GET)
1497
    public String getItemWiseIndent(HttpServletRequest request,
-
 
1498
                                    @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws
1458
    public String getItemWiseIndent(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws ProfitMandiBusinessException {
1499
            ProfitMandiBusinessException {
-
 
1500
 
1459
 
1501
        List<Order> unbilledOrders = transactionService.getInTransitOrders(fofoId);
1460
        List<Order> unbilledOrders = transactionService.getInTransitOrders(fofoId);
1502
        model.addAttribute("unbilledOrders", unbilledOrders);
1461
        model.addAttribute("unbilledOrders", unbilledOrders);
1503
 
1462
 
1504
        return "item-wise-indent";
1463
        return "item-wise-indent";
1505
    }
1464
    }
1506
 
1465
 
1507
    @RequestMapping(value = "/getPartnerInvestment", method = RequestMethod.GET)
1466
    @RequestMapping(value = "/getPartnerInvestment", method = RequestMethod.GET)
1508
    public String getPartnerInvestment(HttpServletRequest request,
-
 
1509
                                       @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
1467
    public String getPartnerInvestment(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
1510
        Map<Integer, PartnerDetailModel> partnerStats = adminUser.getPartnersStatDataFromFile();
1468
        Map<Integer, PartnerDetailModel> partnerStats = adminUser.getPartnersStatDataFromFile();
1511
        PartnerDetailModel partnerDetailModel = partnerStats.get(fofoId);
1469
        PartnerDetailModel partnerDetailModel = partnerStats.get(fofoId);
1512
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1470
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1513
        model.addAttribute("partnerDetailModel", partnerDetailModel);
1471
        model.addAttribute("partnerDetailModel", partnerDetailModel);
1514
        model.addAttribute("customRetailer", customRetailer);
1472
        model.addAttribute("customRetailer", customRetailer);
1515
        return "partner-investment";
1473
        return "partner-investment";
1516
    }
1474
    }
1517
 
1475
 
1518
    @RequestMapping(value = "/getPartnerPendingIndentItem", method = RequestMethod.GET)
1476
    @RequestMapping(value = "/getPartnerPendingIndentItem", method = RequestMethod.GET)
1519
    public String getPartnerPendingIndentItem(HttpServletRequest request, @RequestParam int warehouseId,
1477
    public String getPartnerPendingIndentItem(HttpServletRequest request, @RequestParam int warehouseId, @RequestParam int itemId, Model model) throws ProfitMandiBusinessException {
1520
                                              @RequestParam int itemId, Model model) throws ProfitMandiBusinessException {
-
 
1521
        List<PartnerPendingIndentItemModel> partnerPendingIndent = fofoStoreRepository.selectPartnerPendingIndentItem(itemId, warehouseId);
1478
        List<PartnerPendingIndentItemModel> partnerPendingIndent = fofoStoreRepository.selectPartnerPendingIndentItem(itemId, warehouseId);
1522
 
1479
 
1523
        model.addAttribute("partnerPendingIndent", partnerPendingIndent);
1480
        model.addAttribute("partnerPendingIndent", partnerPendingIndent);
1524
        return "partner-pending-indent-item";
1481
        return "partner-pending-indent-item";
1525
    }
1482
    }
1526
 
1483
 
1527
    @RequestMapping(value = "/getPatnerActivateStock", method = RequestMethod.GET)
1484
    @RequestMapping(value = "/getPatnerActivateStock", method = RequestMethod.GET)
1528
    public String getPartnerActivateStockItem(HttpServletRequest request,
-
 
1529
                                              @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
1485
    public String getPartnerActivateStockItem(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
1530
        List<ActivateItemModel> activateStocks = new ArrayList<>();
1486
        List<ActivateItemModel> activateStocks = new ArrayList<>();
1531
        List<InventoryItem> inventoryItems = inventoryItemRepository.selectByActivatedNotSold(fofoId);
1487
        List<InventoryItem> inventoryItems = inventoryItemRepository.selectByActivatedNotSold(fofoId);
1532
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1488
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1533
 
1489
 
1534
        for (InventoryItem inventoryItem : inventoryItems) {
1490
        for (InventoryItem inventoryItem : inventoryItems) {
Line 1547... Line 1503...
1547
        model.addAttribute("customRetailer", customRetailer);
1503
        model.addAttribute("customRetailer", customRetailer);
1548
        return "partner-activate-stock";
1504
        return "partner-activate-stock";
1549
    }
1505
    }
1550
 
1506
 
1551
    @RequestMapping(value = "/getPatnerBrandWiseMTDSale", method = RequestMethod.GET)
1507
    @RequestMapping(value = "/getPatnerBrandWiseMTDSale", method = RequestMethod.GET)
1552
    public String getPatnerBrandWiseMTDSale(HttpServletRequest request,
-
 
1553
                                            @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
1508
    public String getPatnerBrandWiseMTDSale(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
1554
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
1509
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
1555
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1510
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1556
        Map<String, Double> brandMtdAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId);
1511
        Map<String, Double> brandMtdAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId);
1557
        Map<String, Long> brandMtdQty = fofoOrderItemRepository.selectSumQuantityGroupByBrand(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId);
1512
        Map<String, Long> brandMtdQty = fofoOrderItemRepository.selectSumQuantityGroupByBrand(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId);
1558
        Double accesoriesmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId, curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false)).get(fofoId);
1513
        Double accesoriesmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId, curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false)).get(fofoId);
Line 1567... Line 1522...
1567
        model.addAttribute("customRetailer", customRetailer);
1522
        model.addAttribute("customRetailer", customRetailer);
1568
        return "partner-brand-mtd-sale";
1523
        return "partner-brand-mtd-sale";
1569
    }
1524
    }
1570
 
1525
 
1571
    @RequestMapping(value = "/getPatnerBrandWiseLMTDSale", method = RequestMethod.GET)
1526
    @RequestMapping(value = "/getPatnerBrandWiseLMTDSale", method = RequestMethod.GET)
1572
    public String getPatnerBrandWiseLMTDSale(HttpServletRequest request,
-
 
1573
                                             @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
1527
    public String getPatnerBrandWiseLMTDSale(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
1574
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
1528
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
1575
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1529
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1576
        Map<String, Double> brandLMtdAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(
1530
        Map<String, Double> brandLMtdAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(
1577
                curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), fofoId);
1531
                curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), fofoId);
1578
        Map<String, Long> brandLmtdQty = fofoOrderItemRepository.selectSumQuantityGroupByBrand(
1532
        Map<String, Long> brandLmtdQty = fofoOrderItemRepository.selectSumQuantityGroupByBrand(
Line 1588... Line 1542...
1588
        model.addAttribute("customRetailer", customRetailer);
1542
        model.addAttribute("customRetailer", customRetailer);
1589
        return "partner-brand-lmtd-sale";
1543
        return "partner-brand-lmtd-sale";
1590
    }
1544
    }
1591
 
1545
 
1592
    @RequestMapping(value = "/getPatnerBrandWiseLMSSale", method = RequestMethod.GET)
1546
    @RequestMapping(value = "/getPatnerBrandWiseLMSSale", method = RequestMethod.GET)
1593
    public String getPatnerBrandWiseLMSSale(HttpServletRequest request,
-
 
1594
                                            @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
1547
    public String getPatnerBrandWiseLMSSale(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
1595
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
1548
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
1596
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1549
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1597
        int lengthOfMonth = YearMonth.from(curDate.minusMonths(1)).lengthOfMonth();
1550
        int lengthOfMonth = YearMonth.from(curDate.minusMonths(1)).lengthOfMonth();
1598
 
1551
 
1599
        Map<String, Double> brandLMSAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(
1552
        Map<String, Double> brandLMSAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(
Line 1611... Line 1564...
1611
        model.addAttribute("customRetailer", customRetailer);
1564
        model.addAttribute("customRetailer", customRetailer);
1612
        return "partner-brand-lms-sale";
1565
        return "partner-brand-lms-sale";
1613
    }
1566
    }
1614
 
1567
 
1615
    @RequestMapping(value = "/getPatnerInStock", method = RequestMethod.GET)
1568
    @RequestMapping(value = "/getPatnerInStock", method = RequestMethod.GET)
1616
    public String getPatnerInStock(HttpServletRequest request,
-
 
1617
                                   @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
1569
    public String getPatnerInStock(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
1618
 
1570
 
1619
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1571
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1620
 
1572
 
1621
        List<InStockBrandModel> mobileStocks = currentInventorySnapshotRepository.selectSumInStockMobileGroupByBrand(fofoId);
1573
        List<InStockBrandModel> mobileStocks = currentInventorySnapshotRepository.selectSumInStockMobileGroupByBrand(fofoId);
1622
        List<InStockBrandModel> accesStock = currentInventorySnapshotRepository.selectSumInStockAccessoriesGroupByBrand(fofoId);
1574
        List<InStockBrandModel> accesStock = currentInventorySnapshotRepository.selectSumInStockAccessoriesGroupByBrand(fofoId);
Line 1631... Line 1583...
1631
        model.addAttribute("customRetailer", customRetailer);
1583
        model.addAttribute("customRetailer", customRetailer);
1632
        return "partner-instock-item";
1584
        return "partner-instock-item";
1633
    }
1585
    }
1634
 
1586
 
1635
    @RequestMapping(value = "/getOpenTicketByFofoId", method = RequestMethod.GET)
1587
    @RequestMapping(value = "/getOpenTicketByFofoId", method = RequestMethod.GET)
1636
    public String getOpenTicketByFofoId(HttpServletRequest request,
-
 
1637
                                        @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
1588
    public String getOpenTicketByFofoId(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
1638
        Map<Integer, AuthUser> ticketIdAuthUser = new HashMap<>();
1589
        Map<Integer, AuthUser> ticketIdAuthUser = new HashMap<>();
1639
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1590
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1640
        List<Integer> ticketIds = ticketRepository.selectAllOpenTicketByRetailer(fofoId).stream().map(x -> x.getId()).collect(Collectors.toList());
1591
        List<Integer> ticketIds = ticketRepository.selectAllOpenTicketByRetailer(fofoId).stream().map(x -> x.getId()).collect(Collectors.toList());
1641
        List<TicketAssigned> ticketAssigns = ticketAssignedRepository.selectByTicketIds(ticketIds);
1592
        List<TicketAssigned> ticketAssigns = ticketAssignedRepository.selectByTicketIds(ticketIds);
1642
 
1593
 
Line 1649... Line 1600...
1649
        model.addAttribute("customRetailer", customRetailer);
1600
        model.addAttribute("customRetailer", customRetailer);
1650
        return "open-ticket";
1601
        return "open-ticket";
1651
    }
1602
    }
1652
 
1603
 
1653
    @RequestMapping(value = "/getPartnerSecondarySale", method = RequestMethod.GET)
1604
    @RequestMapping(value = "/getPartnerSecondarySale", method = RequestMethod.GET)
1654
    public String getPartnerSecondarySale(HttpServletRequest request,
-
 
1655
                                          @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, @RequestParam String timeValue, Model model) throws
1605
    public String getPartnerSecondarySale(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, @RequestParam String timeValue, Model model) throws Exception {
1656
            Exception {
-
 
1657
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
1606
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
1658
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1607
        CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1659
        int lengthOfMonth = YearMonth.from(curDate.minusMonths(1)).lengthOfMonth();
1608
        int lengthOfMonth = YearMonth.from(curDate.minusMonths(1)).lengthOfMonth();
1660
        LocalDateTime startDate = null;
1609
        LocalDateTime startDate = null;
1661
        LocalDateTime endDate = null;
1610
        LocalDateTime endDate = null;
Line 1745... Line 1694...
1745
        model.addAttribute("accessoriesBrandSales", accessoriesBrandSales);
1694
        model.addAttribute("accessoriesBrandSales", accessoriesBrandSales);
1746
        return "accessories-brand-wise-report";
1695
        return "accessories-brand-wise-report";
1747
    }
1696
    }
1748
 
1697
 
1749
    @RequestMapping(value = "/getMobileLMSGraph", method = RequestMethod.GET)
1698
    @RequestMapping(value = "/getMobileLMSGraph", method = RequestMethod.GET)
1750
    public String getMobileLMSGraph(HttpServletRequest request, @RequestParam(required = false) int warehouseId,
1699
    public String getMobileLMSGraph(HttpServletRequest request, @RequestParam(required = false) int warehouseId, @RequestParam(required = false) LocalDateTime date, @RequestParam(required = false) LocalDateTime endDate, @RequestParam List<Integer> fofoIds, @RequestParam String filterType, Model model) throws Exception {
1751
                                    @RequestParam(required = false) LocalDateTime date, @RequestParam(required = false) LocalDateTime endDate,
-
 
1752
                                    @RequestParam List<Integer> fofoIds, @RequestParam String filterType, Model model) throws Exception {
-
 
1753
        Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds)).stream().collect(Collectors.groupingBy(
1700
        Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds)).stream().collect(Collectors.groupingBy(
1754
                FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
1701
                FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
1755
 
1702
 
1756
        ChartModel cm;
1703
        ChartModel cm;
1757
        if (warehouseId != 0) {
1704
        if (warehouseId != 0) {
Line 1765... Line 1712...
1765
        model.addAttribute("chartMap", gson.toJson(cm));
1712
        model.addAttribute("chartMap", gson.toJson(cm));
1766
        return "brand-wise-mobile-lms-chart";
1713
        return "brand-wise-mobile-lms-chart";
1767
    }
1714
    }
1768
 
1715
 
1769
    @RequestMapping(value = "/getMobileLMSFilter", method = RequestMethod.GET)
1716
    @RequestMapping(value = "/getMobileLMSFilter", method = RequestMethod.GET)
1770
    public String getMobileLMSFilter(HttpServletRequest request,
1717
    public String getMobileLMSFilter(HttpServletRequest request, @RequestParam(required = false, defaultValue = "0") int warehouseId, @RequestParam(required = false) LocalDateTime date, @RequestParam(required = false) LocalDateTime endDate, Model model) throws Exception {
1771
                                     @RequestParam(required = false, defaultValue = "0") int warehouseId,
-
 
1772
                                     @RequestParam(required = false) LocalDateTime date,
-
 
1773
                                     @RequestParam(required = false) LocalDateTime endDate, Model model) throws Exception {
-
 
1774
 
1718
 
1775
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1719
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1776
        String email = loginDetails.getEmailId();
1720
        String email = loginDetails.getEmailId();
1777
 
1721
 
1778
        if (date == null) {
1722
        if (date == null) {
Line 1795... Line 1739...
1795
 
1739
 
1796
        return "chart-filter-lms";
1740
        return "chart-filter-lms";
1797
    }
1741
    }
1798
 
1742
 
1799
    @RequestMapping(value = "/getMobileLMPGraph", method = RequestMethod.GET)
1743
    @RequestMapping(value = "/getMobileLMPGraph", method = RequestMethod.GET)
1800
    public String getMobileLMPGraph(HttpServletRequest request, @RequestParam(required = false) int warehouseId,
1744
    public String getMobileLMPGraph(HttpServletRequest request, @RequestParam(required = false) int warehouseId, @RequestParam(required = false) LocalDateTime date, @RequestParam(required = false) LocalDateTime endDate, @RequestParam List<Integer> fofoIds, @RequestParam String filterType, Model model) throws Exception {
1801
                                    @RequestParam(required = false) LocalDateTime date, @RequestParam(required = false) LocalDateTime endDate,
-
 
1802
                                    @RequestParam List<Integer> fofoIds, @RequestParam String filterType, Model model) throws Exception {
-
 
1803
        Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds)).stream().collect(Collectors.groupingBy(
1745
        Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds)).stream().collect(Collectors.groupingBy(
1804
                FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
1746
                FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
1805
 
1747
 
1806
        ChartModel cm;
1748
        ChartModel cm;
1807
        if (warehouseId != 0) {
1749
        if (warehouseId != 0) {
Line 1815... Line 1757...
1815
        model.addAttribute("chartMap", gson.toJson(cm));
1757
        model.addAttribute("chartMap", gson.toJson(cm));
1816
        return "brand-wise-mobile-lmp-chart";
1758
        return "brand-wise-mobile-lmp-chart";
1817
    }
1759
    }
1818
 
1760
 
1819
    @RequestMapping(value = "/getSaleCountByMilestone", method = RequestMethod.GET)
1761
    @RequestMapping(value = "/getSaleCountByMilestone", method = RequestMethod.GET)
1820
    public String getSaleCountByMilestone(HttpServletRequest request,
-
 
1821
                                          @RequestParam(required = false, defaultValue = "0") int warehouseId, Model model) throws Exception {
1762
    public String getSaleCountByMilestone(HttpServletRequest request, @RequestParam(required = false, defaultValue = "0") int warehouseId, Model model) throws Exception {
1822
 
1763
 
1823
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1764
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1824
        String email = loginDetails.getEmailId();
1765
        String email = loginDetails.getEmailId();
1825
        Set<Integer> authFofoIds = csService1.getAuthFofoIds(email, true);
1766
        Set<Integer> authFofoIds = csService1.getAuthFofoIds(email, true);
1826
 
1767
 
Line 1894... Line 1835...
1894
        return "sale-milestone";
1835
        return "sale-milestone";
1895
 
1836
 
1896
    }
1837
    }
1897
 
1838
 
1898
    @RequestMapping(value = "/getPurchaseCountByMileStone", method = RequestMethod.GET)
1839
    @RequestMapping(value = "/getPurchaseCountByMileStone", method = RequestMethod.GET)
1899
    public String getPurchaseCountByMileStone(HttpServletRequest request,
-
 
1900
                                              @RequestParam(required = false, defaultValue = "0") int warehouseId, Model model) throws Exception {
1840
    public String getPurchaseCountByMileStone(HttpServletRequest request, @RequestParam(required = false, defaultValue = "0") int warehouseId, Model model) throws Exception {
1901
 
1841
 
1902
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1842
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1903
        String email = loginDetails.getEmailId();
1843
        String email = loginDetails.getEmailId();
1904
 
1844
 
1905
        Set<Integer> authFofoIds = csService1.getAuthFofoIds(email, true);
1845
        Set<Integer> authFofoIds = csService1.getAuthFofoIds(email, true);
Line 1973... Line 1913...
1973
        return "purchase-milestone";
1913
        return "purchase-milestone";
1974
 
1914
 
1975
    }
1915
    }
1976
 
1916
 
1977
    @RequestMapping(value = "/getActivatedModelWarehouseWise", method = RequestMethod.GET)
1917
    @RequestMapping(value = "/getActivatedModelWarehouseWise", method = RequestMethod.GET)
1978
    public String getActivatedModelWarehouseWise(HttpServletRequest request, Model model, @RequestParam String
1918
    public String getActivatedModelWarehouseWise(HttpServletRequest request, Model model, @RequestParam String brand) throws Exception {
1979
            brand) throws Exception {
-
 
1980
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1919
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1981
        List<Integer> fofoIds = getFofoIds(loginDetails);
1920
        List<Integer> fofoIds = getFofoIds(loginDetails);
1982
        List<WarehouseWiseActivatedModel> warehouseWiseActivatedModels = activatedImeiRepository.selectActivatedModelGroupByWarehouse(brand, fofoIds);
1921
        List<WarehouseWiseActivatedModel> warehouseWiseActivatedModels = activatedImeiRepository.selectActivatedModelGroupByWarehouse(brand, fofoIds);
1983
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1922
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1984
 
1923
 
Line 2003... Line 1942...
2003
        model.addAttribute("activatedModels", activatedModels);
1942
        model.addAttribute("activatedModels", activatedModels);
2004
        return "activation-brandwise-report";
1943
        return "activation-brandwise-report";
2005
    }
1944
    }
2006
 
1945
 
2007
    @RequestMapping(value = "/getWarehouseBrandWiseItemActivatedModel", method = RequestMethod.GET)
1946
    @RequestMapping(value = "/getWarehouseBrandWiseItemActivatedModel", method = RequestMethod.GET)
2008
    public String getWarehouseBrandWiseItemActivatedModel(HttpServletRequest request, Model
-
 
2009
            model, @RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
1947
    public String getWarehouseBrandWiseItemActivatedModel(HttpServletRequest request, Model model, @RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
2010
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1948
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
2011
        List<Integer> fofoIds = getFofoIds(loginDetails);
1949
        List<Integer> fofoIds = getFofoIds(loginDetails);
2012
 
1950
 
2013
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1951
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
2014
        List<WarehouseBrandWiseItemActivatedModel> activatedItems = activatedImeiRepository.selectWarehouseBrandActivatedItem(warehouseId, brand, fofoIds);
1952
        List<WarehouseBrandWiseItemActivatedModel> activatedItems = activatedImeiRepository.selectWarehouseBrandActivatedItem(warehouseId, brand, fofoIds);
Line 2050... Line 1988...
2050
        }
1988
        }
2051
        return new ArrayList<>(fofoIds);
1989
        return new ArrayList<>(fofoIds);
2052
    }
1990
    }
2053
 
1991
 
2054
    @RequestMapping(value = "/getMonthWiseSale", method = RequestMethod.GET)
1992
    @RequestMapping(value = "/getMonthWiseSale", method = RequestMethod.GET)
2055
    public String getPartnerSaleByMonth(HttpServletRequest
-
 
2056
                                                request, @RequestParam List<Integer> fofoIds, Model model) throws Exception {
1993
    public String getPartnerSaleByMonth(HttpServletRequest request, @RequestParam List<Integer> fofoIds, Model model) throws Exception {
2057
 
1994
 
2058
        YearMonth now = YearMonth.now();
1995
        YearMonth now = YearMonth.now();
2059
        YearMonth ym = YearMonth.now().minusMonths(12);
1996
        YearMonth ym = YearMonth.now().minusMonths(12);
2060
        List<YearMonth> list = new ArrayList<>();
1997
        List<YearMonth> list = new ArrayList<>();
2061
        while (!now.isBefore(ym)) {
1998
        while (!now.isBefore(ym)) {
Line 2084... Line 2021...
2084
        return "monthly-partner-sale";
2021
        return "monthly-partner-sale";
2085
 
2022
 
2086
    }
2023
    }
2087
 
2024
 
2088
    @RequestMapping(value = "/getMonthWisePurchase", method = RequestMethod.GET)
2025
    @RequestMapping(value = "/getMonthWisePurchase", method = RequestMethod.GET)
2089
    public String getMonthWisePurchase(HttpServletRequest
-
 
2090
                                               request, @RequestParam List<Integer> fofoIds, Model model) throws Exception {
2026
    public String getMonthWisePurchase(HttpServletRequest request, @RequestParam List<Integer> fofoIds, Model model) throws Exception {
2091
 
2027
 
2092
        YearMonth now = YearMonth.now();
2028
        YearMonth now = YearMonth.now();
2093
        YearMonth ym = YearMonth.now().minusMonths(12);
2029
        YearMonth ym = YearMonth.now().minusMonths(12);
2094
        List<YearMonth> list = new ArrayList<>();
2030
        List<YearMonth> list = new ArrayList<>();
2095
        while (!now.isBefore(ym)) {
2031
        while (!now.isBefore(ym)) {