Subversion Repositories SmartDukaan

Rev

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

Rev 34379 Rev 34383
Line 1028... Line 1028...
1028
 
1028
 
1029
    public void test() throws Exception {
1029
    public void test() throws Exception {
1030
        //List<TotalLoanAmountDueModel> totalLoanAmountDueModels = loanRepository.getDueLoansByFofoId(175139438);
1030
        //List<TotalLoanAmountDueModel> totalLoanAmountDueModels = loanRepository.getDueLoansByFofoId(175139438);
1031
        //System.out.println(totalLoanAmountDueModels);
1031
        //System.out.println(totalLoanAmountDueModels);
1032
        //runOnceTasks.findCNDiff();
1032
        //runOnceTasks.findCNDiff();
1033
        this.updatePartnerLimit();
1033
        /*this.updatePartnerLimit();
1034
        System.out.println(getSuggestedLimit(300000d));
1034
        System.out.println(getSuggestedLimit(300000d));
1035
        System.out.println(getSuggestedLimit(400000d));
1035
        System.out.println(getSuggestedLimit(400000d));
1036
        System.out.println(getSuggestedLimit(500000d));
1036
        System.out.println(getSuggestedLimit(500000d));
1037
        System.out.println(getSuggestedLimit(600000d));
1037
        System.out.println(getSuggestedLimit(600000d));
1038
        System.out.println(getSuggestedLimit(700000d));
1038
        System.out.println(getSuggestedLimit(700000d));
1039
        System.out.println(getSuggestedLimit(1500000d));
1039
        System.out.println(getSuggestedLimit(1500000d));
1040
        System.out.println(getSuggestedLimit(2000000d));
1040
        System.out.println(getSuggestedLimit(2000000d));
1041
        System.out.println(getSuggestedLimit(2500000d));
1041
        System.out.println(getSuggestedLimit(2500000d));*/
1042
        //Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@smartdukaan.com"}, null, "DTDC AWb", "PFA");
1042
        //Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@smartdukaan.com"}, null, "DTDC AWb", "PFA");
1043
    }
1043
    }
1044
 
1044
 
1045
    public void test4() throws Exception {
1045
    public void test4() throws Exception {
1046
        List<Integer> offerIds = Arrays.asList(2882, 2881, 2880, 2879, 2878, 2877, 2876, 2875, 2874, 2873, 2872, 2871, 2870, 2869, 2868, 2867, 2866, 2865, 2864, 2863, 2862, 2861, 2860, 2859, 2858, 2857, 2856, 2855, 2854, 2853, 2852, 2851, 2850, 2849, 2847, 2846, 2845, 2844, 2843, 2842, 2841, 2840, 2839, 2838, 2837, 2836, 2835, 2834, 2833, 2832, 2831, 2830, 2829, 2828, 2827, 2826, 2825, 2824, 2823, 2822, 2821, 2820, 2819, 2818, 2817, 2816, 2815, 2814, 2813, 2812, 2811, 2810, 2809, 2808, 2807, 2806, 2805, 2804, 2803, 2802, 2801, 2800, 2799, 2798, 2797, 2796, 2795, 2794, 2793, 2792, 2791, 2790, 2789, 2788, 2787, 2786, 2785, 2784, 2783, 2782, 2781, 2780, 2777, 2776, 2775, 2774, 2773, 2772, 2771, 2770, 2769, 2768, 2767, 2766, 2765, 2764, 2763, 2762, 2761, 2760, 2759, 2758, 2757, 2756, 2755, 2754, 2753, 2752, 2751, 2750, 2749, 2748, 2747, 2746, 2745, 2744, 2723, 2722, 2721, 2720, 2719, 2718, 2717, 2716, 2715, 2714, 2713, 2712, 2711, 2710, 2709, 2708, 2707, 2706, 2705, 2704, 2703, 2702, 2701, 2700, 2699, 2698, 2697, 2696, 2695, 2694, 2693, 2692, 2691, 2690, 2494, 2493, 2492, 2491, 2490, 2489, 2488, 2487, 2486, 2485, 2484, 2483, 2482, 2481, 2480, 2479, 2478, 2477, 2476, 2475, 2474, 2473, 2472, 2471, 2470, 2469, 2466, 2465, 2464, 2463, 2462, 2461, 2460, 2459, 2458, 2457, 2456, 2455, 2454, 2453, 2452, 2451, 2450, 2449, 2448, 2447, 2446, 2445, 2444, 2443, 2442, 2441, 2440, 2439, 2407, 2406, 2405, 2404, 2403, 2402, 2401, 2400, 2399, 2398, 2397, 2396, 2395, 2394, 2393, 2392, 2391, 2390, 2389, 2388, 2387, 2386, 2385, 2384, 2383, 2382, 2381, 2117, 2116, 2115, 2114, 2113, 2112, 2111, 2110, 2109, 2108, 2107, 2106, 2105, 2104, 2103, 2102, 2101, 2100, 2099, 2098, 2077);
1046
        List<Integer> offerIds = Arrays.asList(2882, 2881, 2880, 2879, 2878, 2877, 2876, 2875, 2874, 2873, 2872, 2871, 2870, 2869, 2868, 2867, 2866, 2865, 2864, 2863, 2862, 2861, 2860, 2859, 2858, 2857, 2856, 2855, 2854, 2853, 2852, 2851, 2850, 2849, 2847, 2846, 2845, 2844, 2843, 2842, 2841, 2840, 2839, 2838, 2837, 2836, 2835, 2834, 2833, 2832, 2831, 2830, 2829, 2828, 2827, 2826, 2825, 2824, 2823, 2822, 2821, 2820, 2819, 2818, 2817, 2816, 2815, 2814, 2813, 2812, 2811, 2810, 2809, 2808, 2807, 2806, 2805, 2804, 2803, 2802, 2801, 2800, 2799, 2798, 2797, 2796, 2795, 2794, 2793, 2792, 2791, 2790, 2789, 2788, 2787, 2786, 2785, 2784, 2783, 2782, 2781, 2780, 2777, 2776, 2775, 2774, 2773, 2772, 2771, 2770, 2769, 2768, 2767, 2766, 2765, 2764, 2763, 2762, 2761, 2760, 2759, 2758, 2757, 2756, 2755, 2754, 2753, 2752, 2751, 2750, 2749, 2748, 2747, 2746, 2745, 2744, 2723, 2722, 2721, 2720, 2719, 2718, 2717, 2716, 2715, 2714, 2713, 2712, 2711, 2710, 2709, 2708, 2707, 2706, 2705, 2704, 2703, 2702, 2701, 2700, 2699, 2698, 2697, 2696, 2695, 2694, 2693, 2692, 2691, 2690, 2494, 2493, 2492, 2491, 2490, 2489, 2488, 2487, 2486, 2485, 2484, 2483, 2482, 2481, 2480, 2479, 2478, 2477, 2476, 2475, 2474, 2473, 2472, 2471, 2470, 2469, 2466, 2465, 2464, 2463, 2462, 2461, 2460, 2459, 2458, 2457, 2456, 2455, 2454, 2453, 2452, 2451, 2450, 2449, 2448, 2447, 2446, 2445, 2444, 2443, 2442, 2441, 2440, 2439, 2407, 2406, 2405, 2404, 2403, 2402, 2401, 2400, 2399, 2398, 2397, 2396, 2395, 2394, 2393, 2392, 2391, 2390, 2389, 2388, 2387, 2386, 2385, 2384, 2383, 2382, 2381, 2117, 2116, 2115, 2114, 2113, 2112, 2111, 2110, 2109, 2108, 2107, 2106, 2105, 2104, 2103, 2102, 2101, 2100, 2099, 2098, 2077);
Line 2407... Line 2407...
2407
                        Map.Entry::getValue,
2407
                        Map.Entry::getValue,
2408
                        Collectors.mapping(Map.Entry::getKey, Collectors.toList())
2408
                        Collectors.mapping(Map.Entry::getKey, Collectors.toList())
2409
                ));
2409
                ));
2410
        LOGGER.info("regionPartnerMap  - {}", regionPartnerMap.keySet());
2410
        LOGGER.info("regionPartnerMap  - {}", regionPartnerMap.keySet());
2411
        for (Map.Entry<Set<Integer>, List<Integer>> regionPartnerEntry : regionPartnerMap.entrySet()) {
2411
        for (Map.Entry<Set<Integer>, List<Integer>> regionPartnerEntry : regionPartnerMap.entrySet()) {
2412
            LOGGER.info("regionPartnerEntry - {}", regionPartnerEntry.getKey());
2412
            //LOGGER.info("regionPartnerEntry - {}", regionPartnerEntry.getKey());
2413
            Set<Integer> regionIds = regionPartnerEntry.getKey();
2413
            Set<Integer> regionIds = regionPartnerEntry.getKey();
2414
            List<Integer> partnerIds = regionPartnerEntry.getValue();
2414
            List<Integer> partnerIds = regionPartnerEntry.getValue();
2415
            if(regionIds.contains(5)) {
-
 
2416
                partnerIds.addAll(fofoStoreMap.keySet());
-
 
2417
                partnerIds = partnerIds.stream().distinct().collect(toList());
2415
            if(regionIds.stream().anyMatch(x->!regionFocusedModelsMap.containsKey(x))) continue;
2418
            }
2416
 
2419
            LOGGER.info("regionIds" + regionIds);
2417
            LOGGER.info("regionIds" + regionIds);
2420
            if (regionIds == null || regionIds.size() == 0) {
2418
            if (regionIds == null || regionIds.size() == 0) {
2421
                LOGGER.info("No region found for partner {}", partnerIds);
2419
                LOGGER.info("No region found for partner {}", partnerIds);
2422
                continue;
2420
                continue;
2423
            }
2421
            }
-
 
2422
            if(regionIds.contains(5)) {
2424
            regionIds.forEach(regionId -> LOGGER.info("Region: {}, Models: {}", regionId, regionFocusedModelsMap.get(regionId)));
2423
                partnerIds.addAll(fofoStoreMap.keySet());
-
 
2424
            }
2425
            Map<Integer, Optional<Integer>> focusedCatalogIdAndQtyMap = regionIds.stream().map(regionFocusedModelsMap::get).flatMap(x -> x != null ? x.stream() : Stream.empty())
2425
            Map<Integer, Optional<Integer>> focusedCatalogIdAndQtyMap = regionIds.stream().map(regionFocusedModelsMap::get).flatMap(x -> x != null ? x.stream() : Stream.empty())
2426
                    .collect(groupingBy(FocusedModel::getCatalogId, mapping(FocusedModel::getObsMinimumQty, Collectors.maxBy(Integer::compareTo))));
2426
                    .collect(groupingBy(FocusedModel::getCatalogId, mapping(FocusedModel::getObsMinimumQty, Collectors.maxBy(Integer::compareTo))));
2427
            LOGGER.info("focusedCatalogIdAndQtyMap {}",focusedCatalogIdAndQtyMap);
2427
            //LOGGER.info("focusedCatalogIdAndQtyMap {}",focusedCatalogIdAndQtyMap);
2428
            if(focusedCatalogIdAndQtyMap.size() == 0) continue;
2428
            if(focusedCatalogIdAndQtyMap.size() == 0) continue;
2429
            for (int partnerId : partnerIds) {
2429
            for (int partnerId : partnerIds) {
-
 
2430
                if(partnerId==0) continue;
2430
                FofoStore fofoStore = fofoStoreMap.get(partnerId);
2431
                FofoStore fofoStore = fofoStoreMap.get(partnerId);
2431
                List<FocusedModelShortageModel> focusedModelShortageList = new ArrayList<>();
2432
                List<FocusedModelShortageModel> focusedModelShortageList = new ArrayList<>();
2432
                focusedModelShortageReportMap.put(fofoStore.getId(), focusedModelShortageList);
2433
                focusedModelShortageReportMap.put(fofoStore.getId(), focusedModelShortageList);
2433
                LOGGER.info("Before retailerService.getFofoRetailer(fofoId)");
2434
                LOGGER.info("Before retailerService.getFofoRetailer(fofoId)");
2434
                CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoStore.getId());
2435
                CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoStore.getId());
Line 2545... Line 2546...
2545
        LOGGER.info("focusedModelShortageReportMap {}", focusedModelShortageReportMap);
2546
        LOGGER.info("focusedModelShortageReportMap {}", focusedModelShortageReportMap);
2546
        if (!focusedModelShortageReportMap.isEmpty()) {
2547
        if (!focusedModelShortageReportMap.isEmpty()) {
2547
            String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
2548
            String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
2548
            Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
2549
            Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
2549
            Map<String, List<List<?>>> emailRowsMap = new HashMap<>();
2550
            Map<String, List<List<?>>> emailRowsMap = new HashMap<>();
2550
 
-
 
-
 
2551
            //String email = "tarun.verma@smartdukaan.com";
2551
            focusedModelShortageReportMap.entrySet().forEach(x -> {
2552
            focusedModelShortageReportMap.entrySet().forEach(x -> {
2552
                storeGuyMap.entrySet().forEach(y -> {
2553
                storeGuyMap.entrySet().stream()
-
 
2554
                        //.filter(entry->entry.getKey().equals(email))
-
 
2555
                        .forEach(y -> {
2553
 
2556
 
2554
                    if (y.getValue().contains(x.getKey())) {
2557
                    if (y.getValue().contains(x.getKey())) {
2555
                        if (!emailRowsMap.containsKey(y.getKey())) {
2558
                        if (!emailRowsMap.containsKey(y.getKey())) {
2556
                            emailRowsMap.put(y.getKey(), new ArrayList<>());
2559
                            emailRowsMap.put(y.getKey(), new ArrayList<>());
2557
                        }
2560
                        }
Line 2561... Line 2564...
2561
                    }
2564
                    }
2562
 
2565
 
2563
                });
2566
                });
2564
 
2567
 
2565
            });
2568
            });
-
 
2569
            //LOGGER.info("emailRowsMap {}", emailRowsMap);
2566
 
2570
 
2567
            List<String> headers = Arrays.asList("Store Code", "Store Name", "Brand", "Model Name", "Model Number", "DP", "Warehouse Name", "State Manager", "Territory Manager", "Pending Indent", "InStock", "Shortage Qty", "Availability");
2571
            List<String> headers = Arrays.asList("Store Code", "Store Name", "Brand", "Model Name", "Model Number", "DP", "Warehouse Name", "State Manager", "Territory Manager", "Pending Indent", "InStock", "Shortage Qty", "Availability");
2568
            emailRowsMap.entrySet().forEach(entry -> {
2572
            emailRowsMap.entrySet().forEach(entry -> {
2569
 
2573
 
2570
                ByteArrayOutputStream baos = null;
2574
                ByteArrayOutputStream baos = null;