Subversion Repositories SmartDukaan

Rev

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

Rev 34066 Rev 34069
Line 149... Line 149...
149
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
149
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
150
        LocalDateTime currentDate = LocalDate.now().atStartOfDay();
150
        LocalDateTime currentDate = LocalDate.now().atStartOfDay();
151
        LocalDateTime currentStartMonth = currentDate.minusDays(30).toLocalDate().atStartOfDay();
151
        LocalDateTime currentStartMonth = currentDate.minusDays(30).toLocalDate().atStartOfDay();
152
        List<CollectionSummary> collectionSummaryList = orderRepository.selectCollectionSummary(fofoDetails.getFofoId(), currentStartMonth, currentDate);
152
        List<CollectionSummary> collectionSummaryList = orderRepository.selectCollectionSummary(fofoDetails.getFofoId(), currentStartMonth, currentDate);
153
        Logger.info("CollectionSummaryList {}", collectionSummaryList);
153
        Logger.info("CollectionSummaryList {}", collectionSummaryList);
-
 
154
        boolean isRBM = false;
-
 
155
        if (isAdmin) {
154
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
156
            AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
155
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
157
            List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
156
        boolean isRBM = positions.stream()
158
            isRBM = positions.stream()
157
                .anyMatch(position ->
159
                    .anyMatch(position ->
158
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
160
                            ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
159
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
161
            Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
160
        if (isRBM && pp.containsKey(authUser.getId())) {
162
            if (isRBM && pp.containsKey(authUser.getId())) {
161
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
163
                Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
162
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
164
                Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
163
                try {
165
                    try {
164
                    return retailerService.getFofoRetailers(true).get(x);
166
                        return retailerService.getFofoRetailers(true).get(x);
165
                } catch (ProfitMandiBusinessException e) {
167
                    } catch (ProfitMandiBusinessException e) {
166
                    // TODO Auto-generated catch block
168
                        // TODO Auto-generated catch block
167
                    return null;
169
                        return null;
168
                }
170
                    }
169
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
171
                }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
170
            model.addAttribute("customRetailersMap", customRetailersMap);
172
                model.addAttribute("customRetailersMap", customRetailersMap);
-
 
173
            }
171
        }
174
        }
172
        model.addAttribute("isRBM", isRBM);
175
        model.addAttribute("isRBM", isRBM);
173
        model.addAttribute("startDate", currentDate.minusDays(30).toLocalDate());
176
        model.addAttribute("startDate", currentDate.minusDays(30).toLocalDate());
174
        model.addAttribute("endDate", LocalDate.now());
177
        model.addAttribute("endDate", LocalDate.now());
175
        model.addAttribute("collectionSummaryList", collectionSummaryList);
178
        model.addAttribute("collectionSummaryList", collectionSummaryList);
Line 187... Line 190...
187
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
190
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
188
        if (isAdmin) {
191
        if (isAdmin) {
189
            startDate = LocalDate.now().minusDays(30);
192
            startDate = LocalDate.now().minusDays(30);
190
            endDate = LocalDate.now();
193
            endDate = LocalDate.now();
191
        }
194
        }
-
 
195
        boolean isRBM = false;
-
 
196
        if (isAdmin) {
192
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
197
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
193
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
198
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
194
        boolean isRBM = positions.stream()
199
            isRBM = positions.stream()
195
                .anyMatch(position ->
200
                .anyMatch(position ->
196
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
201
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
197
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
202
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
198
        if (isRBM && pp.containsKey(authUser.getId())) {
203
            if (isRBM && pp.containsKey(authUser.getId())) {
199
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
204
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
200
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
205
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
201
                try {
206
                try {
202
                    return retailerService.getFofoRetailers(true).get(x);
207
                    return retailerService.getFofoRetailers(true).get(x);
203
                } catch (ProfitMandiBusinessException e) {
208
                } catch (ProfitMandiBusinessException e) {
204
                    // TODO Auto-generated catch block
209
                    // TODO Auto-generated catch block
205
                    return null;
210
                    return null;
206
                }
211
                }
207
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
212
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
208
            model.addAttribute("customRetailersMap", customRetailersMap);
213
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
214
            }
209
        }
215
        }
210
        model.addAttribute("isRBM", isRBM);
216
        model.addAttribute("isRBM", isRBM);
211
        model.addAttribute("startDate", startDate);
217
        model.addAttribute("startDate", startDate);
212
        model.addAttribute("endDate", endDate);
218
        model.addAttribute("endDate", endDate);
213
        model.addAttribute("isAdmin", isAdmin);
219
        model.addAttribute("isAdmin", isAdmin);
Line 276... Line 282...
276
        if (startDate == null) {
282
        if (startDate == null) {
277
            startDate = LocalDate.now().minusDays(30);
283
            startDate = LocalDate.now().minusDays(30);
278
 
284
 
279
        }
285
        }
280
        endDate = LocalDate.now();
286
        endDate = LocalDate.now();
-
 
287
        boolean isRBM = false;
-
 
288
        if (isAdmin) {
281
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
289
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
282
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
290
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
283
        boolean isRBM = positions.stream()
291
            isRBM = positions.stream()
284
                .anyMatch(position ->
292
                .anyMatch(position ->
285
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
293
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
286
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
294
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
287
        if (isRBM && pp.containsKey(authUser.getId())) {
295
            if (isRBM && pp.containsKey(authUser.getId())) {
288
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
296
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
289
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
297
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
290
                try {
298
                try {
291
                    return retailerService.getFofoRetailers(true).get(x);
299
                    return retailerService.getFofoRetailers(true).get(x);
292
                } catch (ProfitMandiBusinessException e) {
300
                } catch (ProfitMandiBusinessException e) {
293
                    // TODO Auto-generated catch block
301
                    // TODO Auto-generated catch block
294
                    return null;
302
                    return null;
295
                }
303
                }
296
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
304
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
297
            model.addAttribute("customRetailersMap", customRetailersMap);
305
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
306
            }
298
        }
307
        }
299
        model.addAttribute("isRBM", isRBM);
308
        model.addAttribute("isRBM", isRBM);
300
        model.addAttribute("startDate", startDate);
309
        model.addAttribute("startDate", startDate);
301
        model.addAttribute("endDate", endDate);
310
        model.addAttribute("endDate", endDate);
302
        model.addAttribute("isAdmin", isAdmin);
311
        model.addAttribute("isAdmin", isAdmin);
Line 331... Line 340...
331
        if (startDate == null) {
340
        if (startDate == null) {
332
 
341
 
333
            startDate = LocalDate.now().minusDays(30);
342
            startDate = LocalDate.now().minusDays(30);
334
            endDate = LocalDate.now();
343
            endDate = LocalDate.now();
335
        }
344
        }
-
 
345
        boolean isRBM = false;
-
 
346
        if (isAdmin) {
336
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
347
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
337
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
348
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
338
        boolean isRBM = positions.stream()
349
            isRBM = positions.stream()
339
                .anyMatch(position ->
350
                .anyMatch(position ->
340
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
351
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
341
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
352
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
342
        if (isRBM && pp.containsKey(authUser.getId())) {
353
            if (isRBM && pp.containsKey(authUser.getId())) {
343
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
354
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
344
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
355
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
345
                try {
356
                try {
346
                    return retailerService.getFofoRetailers(true).get(x);
357
                    return retailerService.getFofoRetailers(true).get(x);
347
                } catch (ProfitMandiBusinessException e) {
358
                } catch (ProfitMandiBusinessException e) {
348
                    // TODO Auto-generated catch block
359
                    // TODO Auto-generated catch block
349
                    return null;
360
                    return null;
350
                }
361
                }
351
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
362
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
352
            model.addAttribute("customRetailersMap", customRetailersMap);
363
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
364
            }
353
        }
365
        }
354
        model.addAttribute("isRBM", isRBM);
366
        model.addAttribute("isRBM", isRBM);
355
        model.addAttribute("startDate", startDate);
367
        model.addAttribute("startDate", startDate);
356
        model.addAttribute("endDate", endDate);
368
        model.addAttribute("endDate", endDate);
357
        model.addAttribute("isAdmin", isAdmin);
369
        model.addAttribute("isAdmin", isAdmin);
Line 530... Line 542...
530
                LOGGER.info("endDate - " + endDate.atTime(LocalTime.MAX));
542
                LOGGER.info("endDate - " + endDate.atTime(LocalTime.MAX));
531
            }
543
            }
532
        } else {
544
        } else {
533
            walletSummartList = fofoOrderRepository.selectWalletSummaryReport(loginDetails.getFofoId(), startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
545
            walletSummartList = fofoOrderRepository.selectWalletSummaryReport(loginDetails.getFofoId(), startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
534
        }
546
        }
-
 
547
        boolean isRBM = false;
-
 
548
        if (isAdmin) {
535
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
549
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
536
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
550
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
537
        boolean isRBM = positions.stream()
551
            isRBM = positions.stream()
538
                .anyMatch(position ->
552
                .anyMatch(position ->
539
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
553
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
540
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
554
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
541
        if (isRBM && pp.containsKey(authUser.getId())) {
555
            if (isRBM && pp.containsKey(authUser.getId())) {
542
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
556
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
543
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
557
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
544
                try {
558
                try {
545
                    return retailerService.getFofoRetailers(true).get(x);
559
                    return retailerService.getFofoRetailers(true).get(x);
546
                } catch (ProfitMandiBusinessException e) {
560
                } catch (ProfitMandiBusinessException e) {
547
                    // TODO Auto-generated catch block
561
                    // TODO Auto-generated catch block
548
                    return null;
562
                    return null;
549
                }
563
                }
550
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
564
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
551
            model.addAttribute("customRetailersMap", customRetailersMap);
565
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
566
            }
552
        }
567
        }
553
        model.addAttribute("isRBM", isRBM);
568
        model.addAttribute("isRBM", isRBM);
554
 
569
 
555
        LOGGER.info("walletSummartList {}", walletSummartList);
570
        LOGGER.info("walletSummartList {}", walletSummartList);
556
        model.addAttribute("walletSummartList", walletSummartList);
571
        model.addAttribute("walletSummartList", walletSummartList);
Line 570... Line 585...
570
        List<WalletSummaryReportModel> walletSummartList = new ArrayList<>();
585
        List<WalletSummaryReportModel> walletSummartList = new ArrayList<>();
571
        if (!isAdmin) {
586
        if (!isAdmin) {
572
            walletSummartList = fofoOrderRepository
587
            walletSummartList = fofoOrderRepository
573
                    .selectWalletSummaryReport(fofoDetails.getFofoId(), startDate, endDate);
588
                    .selectWalletSummaryReport(fofoDetails.getFofoId(), startDate, endDate);
574
        }
589
        }
-
 
590
        boolean isRBM = false;
-
 
591
        if (isAdmin) {
575
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
592
            AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
576
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
593
            List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
577
        boolean isRBM = positions.stream()
594
            isRBM = positions.stream()
578
                .anyMatch(position ->
595
                    .anyMatch(position ->
579
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
596
                            ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
580
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
597
            Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
581
        if (isRBM && pp.containsKey(authUser.getId())) {
598
            if (isRBM && pp.containsKey(authUser.getId())) {
582
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
599
                Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
583
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
600
                Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
584
                try {
601
                    try {
585
                    return retailerService.getFofoRetailers(true).get(x);
602
                        return retailerService.getFofoRetailers(true).get(x);
586
                } catch (ProfitMandiBusinessException e) {
603
                    } catch (ProfitMandiBusinessException e) {
587
                    // TODO Auto-generated catch block
604
                        // TODO Auto-generated catch block
588
                    return null;
605
                        return null;
589
                }
606
                    }
590
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
607
                }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
591
            model.addAttribute("customRetailersMap", customRetailersMap);
608
                model.addAttribute("customRetailersMap", customRetailersMap);
-
 
609
            }
592
        }
610
        }
593
        model.addAttribute("isRBM", isRBM);
611
        model.addAttribute("isRBM", isRBM);
594
 
612
 
595
        LOGGER.info("walletSummartList {}", walletSummartList);
613
        LOGGER.info("walletSummartList {}", walletSummartList);
596
        model.addAttribute("startDate", startDate.toLocalDate());
614
        model.addAttribute("startDate", startDate.toLocalDate());
Line 603... Line 621...
603
 
621
 
604
    @RequestMapping(value = "/pendingIndentReport", method = RequestMethod.GET)
622
    @RequestMapping(value = "/pendingIndentReport", method = RequestMethod.GET)
605
    public String getPendingIndentReport(HttpServletRequest request, Model model) throws Exception {
623
    public String getPendingIndentReport(HttpServletRequest request, Model model) throws Exception {
606
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
624
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
607
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
625
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
-
 
626
        boolean isRBM = false;
-
 
627
        if (isAdmin) {
608
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
628
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
609
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
629
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
610
        boolean isRBM = positions.stream()
630
            isRBM = positions.stream()
611
                .anyMatch(position ->
631
                .anyMatch(position ->
612
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
632
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
613
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
633
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
614
        if (isRBM && pp.containsKey(authUser.getId())) {
634
            if (isRBM && pp.containsKey(authUser.getId())) {
615
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
635
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
616
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
636
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
617
                try {
637
                try {
618
                    return retailerService.getFofoRetailers(true).get(x);
638
                    return retailerService.getFofoRetailers(true).get(x);
619
                } catch (ProfitMandiBusinessException e) {
639
                } catch (ProfitMandiBusinessException e) {
620
                    // TODO Auto-generated catch block
640
                    // TODO Auto-generated catch block
621
                    return null;
641
                    return null;
622
                }
642
                }
623
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
643
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
624
            model.addAttribute("customRetailersMap", customRetailersMap);
644
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
645
            }
625
        }
646
        }
626
        model.addAttribute("isRBM", isRBM);
647
        model.addAttribute("isRBM", isRBM);
627
 
648
 
628
        LocalDateTime currentDate = LocalDate.now().atStartOfDay();
649
        LocalDateTime currentDate = LocalDate.now().atStartOfDay();
629
        LocalDateTime currentStartMonth = currentDate.minusMonths(2).toLocalDate().atStartOfDay();
650
        LocalDateTime currentStartMonth = currentDate.minusMonths(2).toLocalDate().atStartOfDay();
Line 653... Line 674...
653
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
674
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
654
        if (startDate == null) {
675
        if (startDate == null) {
655
            startDate = LocalDate.now().minusDays(30);
676
            startDate = LocalDate.now().minusDays(30);
656
            endDate = LocalDate.now();
677
            endDate = LocalDate.now();
657
        }
678
        }
-
 
679
        boolean isRBM = false;
-
 
680
        if (isAdmin) {
658
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
681
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
659
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
682
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
660
        boolean isRBM = positions.stream()
683
            isRBM = positions.stream()
661
                .anyMatch(position ->
684
                .anyMatch(position ->
662
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
685
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
663
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
686
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
664
        if (isRBM && pp.containsKey(authUser.getId())) {
687
            if (isRBM && pp.containsKey(authUser.getId())) {
665
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
688
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
666
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
689
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
667
                try {
690
                try {
668
                    return retailerService.getFofoRetailers(true).get(x);
691
                    return retailerService.getFofoRetailers(true).get(x);
669
                } catch (ProfitMandiBusinessException e) {
692
                } catch (ProfitMandiBusinessException e) {
670
                    // TODO Auto-generated catch block
693
                    // TODO Auto-generated catch block
671
                    return null;
694
                    return null;
672
                }
695
                }
673
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
696
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
674
            model.addAttribute("customRetailersMap", customRetailersMap);
697
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
698
            }
675
        }
699
        }
676
        model.addAttribute("isRBM", isRBM);
700
        model.addAttribute("isRBM", isRBM);
677
 
701
 
678
        model.addAttribute("startDate", startDate);
702
        model.addAttribute("startDate", startDate);
679
        model.addAttribute("endDate", endDate);
703
        model.addAttribute("endDate", endDate);
Line 753... Line 777...
753
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
777
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
754
        if (startDate == null) {
778
        if (startDate == null) {
755
            startDate = LocalDate.now().minusDays(30);
779
            startDate = LocalDate.now().minusDays(30);
756
            endDate = LocalDate.now();
780
            endDate = LocalDate.now();
757
        }
781
        }
-
 
782
        boolean isRBM = false;
-
 
783
        if (isAdmin) {
758
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
784
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
759
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
785
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
760
        boolean isRBM = positions.stream()
786
            isRBM = positions.stream()
761
                .anyMatch(position ->
787
                .anyMatch(position ->
762
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
788
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
763
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
789
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
764
        if (isRBM && pp.containsKey(authUser.getId())) {
790
            if (isRBM && pp.containsKey(authUser.getId())) {
765
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
791
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
766
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
792
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
767
                try {
793
                try {
768
                    return retailerService.getFofoRetailers(true).get(x);
794
                    return retailerService.getFofoRetailers(true).get(x);
769
                } catch (ProfitMandiBusinessException e) {
795
                } catch (ProfitMandiBusinessException e) {
770
                    // TODO Auto-generated catch block
796
                    // TODO Auto-generated catch block
771
                    return null;
797
                    return null;
772
                }
798
                }
773
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
799
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
774
            model.addAttribute("customRetailersMap", customRetailersMap);
800
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
801
            }
775
        }
802
        }
776
        model.addAttribute("isRBM", isRBM);
803
        model.addAttribute("isRBM", isRBM);
777
        model.addAttribute("startDate", startDate);
804
        model.addAttribute("startDate", startDate);
778
        model.addAttribute("endDate", endDate);
805
        model.addAttribute("endDate", endDate);
779
        model.addAttribute("isAdmin", isAdmin);
806
        model.addAttribute("isAdmin", isAdmin);
Line 798... Line 825...
798
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
825
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
799
        if (startDate == null) {
826
        if (startDate == null) {
800
            startDate = LocalDate.now().minusDays(30);
827
            startDate = LocalDate.now().minusDays(30);
801
            endDate = LocalDate.now();
828
            endDate = LocalDate.now();
802
        }
829
        }
-
 
830
        boolean isRBM = false;
-
 
831
        if (isAdmin) {
803
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
832
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
804
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
833
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
805
        boolean isRBM = positions.stream()
834
            isRBM = positions.stream()
806
                .anyMatch(position ->
835
                .anyMatch(position ->
807
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
836
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
808
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
837
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
809
        if (isRBM && pp.containsKey(authUser.getId())) {
838
            if (isRBM && pp.containsKey(authUser.getId())) {
810
            List<Integer> fofoIds = pp.get(authUser.getId());
839
            List<Integer> fofoIds = pp.get(authUser.getId());
811
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
840
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
812
                try {
841
                try {
813
                    return retailerService.getFofoRetailers(true).get(x);
842
                    return retailerService.getFofoRetailers(true).get(x);
814
                } catch (ProfitMandiBusinessException e) {
843
                } catch (ProfitMandiBusinessException e) {
815
                    // TODO Auto-generated catch block
844
                    // TODO Auto-generated catch block
816
                    return null;
845
                    return null;
817
                }
846
                }
818
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
847
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
819
            model.addAttribute("customRetailersMap", customRetailersMap);
848
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
849
            }
820
        }
850
        }
821
 
851
 
822
        model.addAttribute("isRBM", isRBM);
852
        model.addAttribute("isRBM", isRBM);
823
        model.addAttribute("startDate", startDate);
853
        model.addAttribute("startDate", startDate);
824
        model.addAttribute("endDate", endDate);
854
        model.addAttribute("endDate", endDate);
Line 852... Line 882...
852
 
882
 
853
    @RequestMapping(value = "/offerPayoutReport", method = RequestMethod.GET)
883
    @RequestMapping(value = "/offerPayoutReport", method = RequestMethod.GET)
854
    public String getOfferPayoutReport(HttpServletRequest request, Model model, @RequestParam(required = false) LocalDate startDate, @RequestParam(required = false) LocalDate endDate) throws Exception {
884
    public String getOfferPayoutReport(HttpServletRequest request, Model model, @RequestParam(required = false) LocalDate startDate, @RequestParam(required = false) LocalDate endDate) throws Exception {
855
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
885
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
856
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
886
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
-
 
887
        boolean isRBM = false;
-
 
888
        if (isAdmin) {
857
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
889
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
858
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
890
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
859
        boolean isRBM = positions.stream()
891
            isRBM = positions.stream()
860
                .anyMatch(position ->
892
                .anyMatch(position ->
861
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
893
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
862
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
894
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
863
        if (isRBM && pp.containsKey(authUser.getId())) {
895
            if (isRBM && pp.containsKey(authUser.getId())) {
864
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
896
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
865
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
897
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
866
                try {
898
                try {
867
                    return retailerService.getFofoRetailers(true).get(x);
899
                    return retailerService.getFofoRetailers(true).get(x);
868
                } catch (ProfitMandiBusinessException e) {
900
                } catch (ProfitMandiBusinessException e) {
869
                    // TODO Auto-generated catch block
901
                    // TODO Auto-generated catch block
870
                    return null;
902
                    return null;
871
                }
903
                }
872
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
904
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
873
            model.addAttribute("customRetailersMap", customRetailersMap);
905
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
906
            }
874
        }
907
        }
875
        model.addAttribute("isRBM", isRBM);
908
        model.addAttribute("isRBM", isRBM);
876
        if (startDate == null) {
909
        if (startDate == null) {
877
            startDate = LocalDate.now().minusDays(30);
910
            startDate = LocalDate.now().minusDays(30);
878
            endDate = LocalDate.now();
911
            endDate = LocalDate.now();
Line 900... Line 933...
900
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
933
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
901
        if (startDate == null) {
934
        if (startDate == null) {
902
            startDate = LocalDate.now().minusDays(30);
935
            startDate = LocalDate.now().minusDays(30);
903
            endDate = LocalDate.now();
936
            endDate = LocalDate.now();
904
        }
937
        }
-
 
938
        boolean isRBM = false;
-
 
939
        if (isAdmin) {
905
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
940
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
906
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
941
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
907
        boolean isRBM = positions.stream()
942
            isRBM = positions.stream()
908
                .anyMatch(position ->
943
                .anyMatch(position ->
909
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
944
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
910
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
945
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
911
        if (isRBM && pp.containsKey(authUser.getId())) {
946
            if (isRBM && pp.containsKey(authUser.getId())) {
912
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
947
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
913
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
948
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
914
                try {
949
                try {
915
                    return retailerService.getFofoRetailers(true).get(x);
950
                    return retailerService.getFofoRetailers(true).get(x);
916
                } catch (ProfitMandiBusinessException e) {
951
                } catch (ProfitMandiBusinessException e) {
917
                    // TODO Auto-generated catch block
952
                    // TODO Auto-generated catch block
918
                    return null;
953
                    return null;
919
                }
954
                }
920
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
955
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
921
            model.addAttribute("customRetailersMap", customRetailersMap);
956
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
957
            }
922
        }
958
        }
923
        model.addAttribute("isRBM", isRBM);
959
        model.addAttribute("isRBM", isRBM);
924
        model.addAttribute("startDate", startDate);
960
        model.addAttribute("startDate", startDate);
925
        model.addAttribute("endDate", endDate);
961
        model.addAttribute("endDate", endDate);
926
        model.addAttribute("isAdmin", isAdmin);
962
        model.addAttribute("isAdmin", isAdmin);
Line 978... Line 1014...
978
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
1014
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
979
        if (startDate == null) {
1015
        if (startDate == null) {
980
            startDate = LocalDate.now().minusDays(30);
1016
            startDate = LocalDate.now().minusDays(30);
981
            endDate = LocalDate.now();
1017
            endDate = LocalDate.now();
982
        }
1018
        }
-
 
1019
        boolean isRBM = false;
-
 
1020
        if (isAdmin) {
983
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
1021
            AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
984
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
1022
            List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
985
        boolean isRBM = positions.stream()
1023
            isRBM = positions.stream()
986
                .anyMatch(position ->
1024
                    .anyMatch(position ->
987
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
1025
                            ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
988
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
1026
            Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
989
        if (pp.containsKey(authUser.getId())) {
1027
            if (pp.containsKey(authUser.getId())) {
990
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
1028
                Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
991
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
1029
                Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
992
                try {
1030
                    try {
993
                    return retailerService.getFofoRetailer(x);
1031
                        return retailerService.getFofoRetailer(x);
994
                } catch (ProfitMandiBusinessException e) {
1032
                    } catch (ProfitMandiBusinessException e) {
995
                    // TODO Auto-generated catch block
1033
                        // TODO Auto-generated catch block
996
                    return null;
1034
                        return null;
997
                }
1035
                    }
998
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
1036
                }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
999
            model.addAttribute("customRetailersMap", customRetailersMap);
1037
                model.addAttribute("customRetailersMap", customRetailersMap);
-
 
1038
            }
1000
        }
1039
        }
1001
 
-
 
1002
        model.addAttribute("isRBM", isRBM);
1040
        model.addAttribute("isRBM", isRBM);
1003
        model.addAttribute("startDate", startDate);
1041
        model.addAttribute("startDate", startDate);
1004
        model.addAttribute("endDate", endDate);
1042
        model.addAttribute("endDate", endDate);
1005
        model.addAttribute("isAdmin", isAdmin);
1043
        model.addAttribute("isAdmin", isAdmin);
1006
        List<PriceDropReportModel> priceDropReports = orderRepository.selectPriceDropReport(fofoDetails.getFofoId(),
1044
        List<PriceDropReportModel> priceDropReports = orderRepository.selectPriceDropReport(fofoDetails.getFofoId(),
Line 1022... Line 1060...
1022
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
1060
        boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
1023
        if (startDate == null) {
1061
        if (startDate == null) {
1024
            startDate = LocalDate.now().minusDays(30);
1062
            startDate = LocalDate.now().minusDays(30);
1025
            endDate = LocalDate.now();
1063
            endDate = LocalDate.now();
1026
        }
1064
        }
-
 
1065
        boolean isRBM = false;
-
 
1066
        if (isAdmin) {
1027
        AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
1067
            AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
1028
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
1068
            List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
1029
        boolean isRBM = positions.stream()
1069
            isRBM = positions.stream()
1030
                .anyMatch(position ->
1070
                    .anyMatch(position ->
1031
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
1071
                            ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
1032
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
1072
            Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
1033
        if (pp.containsKey(authUser.getId())) {
1073
            if (pp.containsKey(authUser.getId())) {
1034
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
1074
                Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
1035
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
1075
                Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
1036
                try {
1076
                    try {
1037
                    return retailerService.getFofoRetailer(x);
1077
                        return retailerService.getFofoRetailer(x);
1038
                } catch (ProfitMandiBusinessException e) {
1078
                    } catch (ProfitMandiBusinessException e) {
1039
                    // TODO Auto-generated catch block
1079
                        // TODO Auto-generated catch block
1040
                    return null;
1080
                        return null;
1041
                }
1081
                    }
1042
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
1082
                }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
1043
            model.addAttribute("customRetailersMap", customRetailersMap);
1083
                model.addAttribute("customRetailersMap", customRetailersMap);
-
 
1084
            }
1044
        }
1085
        }
1045
 
-
 
1046
        model.addAttribute("isRBM", isRBM);
1086
        model.addAttribute("isRBM", isRBM);
1047
        model.addAttribute("startDate", startDate);
1087
        model.addAttribute("startDate", startDate);
1048
        model.addAttribute("endDate", endDate);
1088
        model.addAttribute("endDate", endDate);
1049
        model.addAttribute("isAdmin", isAdmin);
1089
        model.addAttribute("isAdmin", isAdmin);
1050
        if (isAdmin) {
1090
        if (isAdmin) {
Line 1341... Line 1381...
1341
                                   @RequestParam(required = false) LocalDate endDate)
1381
                                   @RequestParam(required = false) LocalDate endDate)
1342
            throws Exception {
1382
            throws Exception {
1343
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1383
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1344
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
1384
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
1345
 
1385
 
-
 
1386
        boolean isRBM = false;
-
 
1387
        if (isAdmin) {
1346
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
1388
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
1347
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
1389
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
1348
        boolean isRBM = positions.stream()
1390
            isRBM = positions.stream()
1349
                .anyMatch(position ->
1391
                .anyMatch(position ->
1350
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
1392
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
1351
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
1393
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
1352
        if (isRBM && pp.containsKey(authUser.getId())) {
1394
            if (isRBM && pp.containsKey(authUser.getId())) {
1353
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
1395
            Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
1354
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
1396
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
1355
                try {
1397
                try {
1356
                    return retailerService.getFofoRetailers(true).get(x);
1398
                    return retailerService.getFofoRetailers(true).get(x);
1357
                } catch (ProfitMandiBusinessException e) {
1399
                } catch (ProfitMandiBusinessException e) {
1358
                    // TODO Auto-generated catch block
1400
                    // TODO Auto-generated catch block
1359
                    return null;
1401
                    return null;
1360
                }
1402
                }
1361
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
1403
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
1362
            model.addAttribute("customRetailersMap", customRetailersMap);
1404
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
1405
            }
1363
        }
1406
        }
1364
 
1407
 
1365
        model.addAttribute("isAdmin", isAdmin);
1408
        model.addAttribute("isAdmin", isAdmin);
1366
        model.addAttribute("isRBM", isRBM);
1409
        model.addAttribute("isRBM", isRBM);
1367
 
1410
 
Line 1434... Line 1477...
1434
    @RequestMapping(value = "/loan/loan-statement", method = RequestMethod.GET)
1477
    @RequestMapping(value = "/loan/loan-statement", method = RequestMethod.GET)
1435
    public String loanStatement(HttpServletRequest request, Model model)
1478
    public String loanStatement(HttpServletRequest request, Model model)
1436
            throws Exception {
1479
            throws Exception {
1437
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1480
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1438
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
1481
        boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
-
 
1482
        boolean isRBM = false;
-
 
1483
        if (isAdmin) {
1439
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
1484
        AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
1440
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
1485
        List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId());
1441
        boolean isRBM = positions.stream()
1486
            isRBM = positions.stream()
1442
                .anyMatch(position ->
1487
                .anyMatch(position ->
1443
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
1488
                        ProfitMandiConstants.TICKET_CATEGORY_RBM == position.getCategoryId());
1444
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
1489
        Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
1445
        if (isRBM && pp.containsKey(authUser.getId())) {
1490
            if (isRBM && pp.containsKey(authUser.getId())) {
1446
            List<Integer> fofoIds = pp.get(authUser.getId());
1491
                List<Integer> fofoIds = pp.get(authUser.getId());
1447
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(fofoId -> {
1492
            Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(fofoId -> {
1448
                try {
1493
                try {
1449
                    return retailerService.getFofoRetailers(true).get(fofoId);
1494
                    return retailerService.getFofoRetailers(true).get(fofoId);
1450
                } catch (ProfitMandiBusinessException e) {
1495
                } catch (ProfitMandiBusinessException e) {
1451
                    // TODO Auto-generated catch block
1496
                    // TODO Auto-generated catch block
1452
                    return null;
1497
                    return null;
1453
                }
1498
                }
1454
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
1499
            }).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
1455
            model.addAttribute("customRetailersMap", customRetailersMap);
1500
            model.addAttribute("customRetailersMap", customRetailersMap);
-
 
1501
            }
1456
        }
1502
        }
1457
        model.addAttribute("isRBM", isRBM);
1503
        model.addAttribute("isRBM", isRBM);
1458
        model.addAttribute("isAdmin", isAdmin);
1504
        model.addAttribute("isAdmin", isAdmin);
1459
 
1505
 
1460
        return "partner-loan-statement";
1506
        return "partner-loan-statement";