Subversion Repositories SmartDukaan

Rev

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

Rev 33204 Rev 33244
Line 9... Line 9...
9
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
9
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
10
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
10
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
11
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
11
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
12
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
12
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
13
import com.spice.profitmandi.dao.model.ActivityMediaModel;
13
import com.spice.profitmandi.dao.model.ActivityMediaModel;
14
import com.spice.profitmandi.dao.model.FofoReportingModel;
-
 
15
import com.spice.profitmandi.dao.model.FofoRBMReportingModel;
14
import com.spice.profitmandi.dao.model.FofoRBMReportingModel;
-
 
15
import com.spice.profitmandi.dao.model.FofoReportingModel;
16
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
16
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
17
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
17
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
18
import com.spice.profitmandi.service.user.RetailerService;
18
import com.spice.profitmandi.service.user.RetailerService;
19
import org.apache.commons.collections4.map.HashedMap;
19
import org.apache.commons.collections4.map.HashedMap;
20
import org.apache.commons.lang.RandomStringUtils;
20
import org.apache.commons.lang.RandomStringUtils;
Line 399... Line 399...
399
        activityRepository.persist(activity);
399
        activityRepository.persist(activity);
400
        return activity;
400
        return activity;
401
    }
401
    }
402
 
402
 
403
    @Override
403
    @Override
404
    public int getAuthUserId(int categoryId, EscalationType escalationType, int fofoId) {
404
    public int getAuthUserId(int categoryId, EscalationType escalationType, int fofoId) throws ProfitMandiBusinessException {
405
        int authUserId = 0;
405
        int authUserId = 0;
406
        List<Position> positions = positionRepository.selectPositionbyCategoryIdAndEscalationType(categoryId, escalationType);
406
        List<Position> positions = positionRepository.selectPositionbyCategoryIdAndEscalationType(categoryId, escalationType);
407
        List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
407
        List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
408
        // Add all Partner regions id
408
        // Add all Partner regions id
409
        regionIds.add(ALL_PARTNERS_REGION);
409
        regionIds.add(ALL_PARTNERS_REGION);
Line 483... Line 483...
483
        subCategoryIdAndSubCategoryMap = ticketSubCategoryRepository.selectByIds(subCategoryIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
483
        subCategoryIdAndSubCategoryMap = ticketSubCategoryRepository.selectByIds(subCategoryIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
484
        return subCategoryIdAndSubCategoryMap;
484
        return subCategoryIdAndSubCategoryMap;
485
    }
485
    }
486
 
486
 
487
    @Override
487
    @Override
488
    public Map<Integer, CustomRetailer> getPartnerByFofoIds(List<Ticket> tickets) {
488
    public Map<Integer, CustomRetailer> getPartnerByFofoIds(List<Ticket> tickets) throws ProfitMandiBusinessException {
489
        List<Integer> fofoIds = new ArrayList<>();
489
        List<Integer> fofoIds = new ArrayList<>();
490
        LOGGER.info(tickets);
490
        LOGGER.info(tickets);
491
        if (tickets == null) {
491
        if (tickets == null) {
492
            return null;
492
            return null;
493
        }
493
        }
Line 555... Line 555...
555
            throw new ProfitMandiBusinessException("Ticket Assingment", authUserTo.getEmailId(), "Could not send ticket assignment mail");
555
            throw new ProfitMandiBusinessException("Ticket Assingment", authUserTo.getEmailId(), "Could not send ticket assignment mail");
556
        }
556
        }
557
    }
557
    }
558
 
558
 
559
    @Override
559
    @Override
560
    public Map<Integer, List<CustomRetailer>> getPositionCustomRetailerMap(List<Position> positions) {
560
    public Map<Integer, List<CustomRetailer>> getPositionCustomRetailerMap(List<Position> positions) throws ProfitMandiBusinessException {
561
        Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
561
        Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
562
        Map<Integer, List<CustomRetailer>> positionRetailerMap = new HashMap<>();
562
        Map<Integer, List<CustomRetailer>> positionRetailerMap = new HashMap<>();
563
        for (Position position : positions) {
563
        for (Position position : positions) {
564
            List<Integer> fofoIds = partnerPositionRepository.selectByPositionId(position.getId()).stream().map(x -> x.getFofoId()).collect(Collectors.toList());
564
            List<Integer> fofoIds = partnerPositionRepository.selectByPositionId(position.getId()).stream().map(x -> x.getFofoId()).collect(Collectors.toList());
565
 
565
 
Line 579... Line 579...
579
        }
579
        }
580
        return positionRetailerMap;
580
        return positionRetailerMap;
581
    }
581
    }
582
 
582
 
583
    @Override
583
    @Override
584
    public Map<Integer, List<CustomRetailer>> getRegionPartners(List<Position> positions) {
584
    public Map<Integer, List<CustomRetailer>> getRegionPartners(List<Position> positions) throws ProfitMandiBusinessException {
585
        Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
585
        Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
586
        Map<Integer, List<CustomRetailer>> positionIdAndpartnerRegionMap = new HashedMap<>();
586
        Map<Integer, List<CustomRetailer>> positionIdAndpartnerRegionMap = new HashedMap<>();
587
        for (Position position : positions) {
587
        for (Position position : positions) {
588
            List<Integer> fofoIds = partnerRegionRepository.selectByRegionId(position.getRegionId()).stream().map(x -> x.getFofoId()).collect(Collectors.toList());
588
            List<Integer> fofoIds = partnerRegionRepository.selectByRegionId(position.getRegionId()).stream().map(x -> x.getFofoId()).collect(Collectors.toList());
589
 
589
 
Line 602... Line 602...
602
        return positionIdAndpartnerRegionMap;
602
        return positionIdAndpartnerRegionMap;
603
    }
603
    }
604
 
604
 
605
    @Override
605
    @Override
606
    @Cacheable(value = "authUserEmailMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
606
    @Cacheable(value = "authUserEmailMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
607
    public Map<String, Set<String>> getAuthUserPartnerEmailMapping() {
607
    public Map<String, Set<String>> getAuthUserPartnerEmailMapping() throws ProfitMandiBusinessException {
608
        Map<String, Set<String>> storeGuyMap = new HashMap<>();
608
        Map<String, Set<String>> storeGuyMap = new HashMap<>();
609
        Set<Integer> activeFofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId()).collect(Collectors.toSet());
609
        Set<Integer> activeFofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId()).collect(Collectors.toSet());
610
        List<Position> categoryPositions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
610
        List<Position> categoryPositions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
611
        categoryPositions.addAll(positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM));
611
        categoryPositions.addAll(positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM));
612
        Map<Integer, Position> positionsMap = categoryPositions.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
612
        Map<Integer, Position> positionsMap = categoryPositions.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
Line 627... Line 627...
627
        return storeGuyMap;
627
        return storeGuyMap;
628
    }
628
    }
629
 
629
 
630
    @Override
630
    @Override
631
    @Cacheable(value = "authUserEmailPartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
631
    @Cacheable(value = "authUserEmailPartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
632
    public Map<String, Set<Integer>> getAuthUserPartnerIdMapping() {
632
    public Map<String, Set<Integer>> getAuthUserPartnerIdMapping() throws ProfitMandiBusinessException {
633
        Map<String, Set<Integer>> storeGuyMap = new HashMap<>();
633
        Map<String, Set<Integer>> storeGuyMap = new HashMap<>();
634
        Set<Integer> activeFofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId()).collect(Collectors.toSet());
634
        Set<Integer> activeFofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId()).collect(Collectors.toSet());
635
        List<Position> categoryPositions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
635
        List<Position> categoryPositions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
636
        categoryPositions.addAll(positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM));
636
        categoryPositions.addAll(positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM));
637
        categoryPositions.addAll(positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT));
637
        categoryPositions.addAll(positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT));
Line 653... Line 653...
653
        return storeGuyMap;
653
        return storeGuyMap;
654
    }
654
    }
655
 
655
 
656
    @Override
656
    @Override
657
    @Cacheable(value = "authUserPartnerEmailPartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
657
    @Cacheable(value = "authUserPartnerEmailPartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
658
    public Map<String, Set<Integer>> getAuthUserPartnerIdMappingByCategoryIds(List<Integer> categoryIds, boolean activeOnly) {
658
    public Map<String, Set<Integer>> getAuthUserPartnerIdMappingByCategoryIds(List<Integer> categoryIds, boolean activeOnly) throws ProfitMandiBusinessException {
659
        Map<String, Set<Integer>> authUserPartnerMap = new HashMap<>();
659
        Map<String, Set<Integer>> authUserPartnerMap = new HashMap<>();
660
        Set<Integer> activeFofoIds;
660
        Set<Integer> activeFofoIds;
661
        if (activeOnly) {
661
        if (activeOnly) {
662
            activeFofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId()).collect(Collectors.toSet());
662
            activeFofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId()).collect(Collectors.toSet());
663
 
663
 
Line 684... Line 684...
684
        }
684
        }
685
        return authUserPartnerMap;
685
        return authUserPartnerMap;
686
    }
686
    }
687
 
687
 
688
    @Override
688
    @Override
689
    public List<String> getAuthUserByPartnerId(int fofoId) {
689
    public List<String> getAuthUserByPartnerId(int fofoId) throws ProfitMandiBusinessException {
690
 
690
 
691
        List<String> emails = new ArrayList<>();
691
        List<String> emails = new ArrayList<>();
692
        List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
692
        List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
693
 
693
 
694
        regionIds.add(5);// All partners Id;
694
        regionIds.add(5);// All partners Id;
Line 712... Line 712...
712
 
712
 
713
        return emails;
713
        return emails;
714
    }
714
    }
715
 
715
 
716
    @Override
716
    @Override
717
    public Map<EscalationType, String> getAuthUserAndEsclationTypeByPartnerId(int fofoId) {
717
    public Map<EscalationType, String> getAuthUserAndEsclationTypeByPartnerId(int fofoId) throws ProfitMandiBusinessException {
718
 
718
 
719
        List<String> emails = new ArrayList<>();
719
        List<String> emails = new ArrayList<>();
720
        Map<EscalationType, String> emailEsclationTypeMap = new HashMap<>();
720
        Map<EscalationType, String> emailEsclationTypeMap = new HashMap<>();
721
        List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
721
        List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
722
 
722
 
Line 747... Line 747...
747
        return emailEsclationTypeMap;
747
        return emailEsclationTypeMap;
748
    }
748
    }
749
 
749
 
750
    @Override
750
    @Override
751
    @Cacheable(value = "authUserIdPartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
751
    @Cacheable(value = "authUserIdPartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
752
    public Map<Integer, List<Integer>> getAuthUserIdPartnerIdMapping() {
752
    public Map<Integer, List<Integer>> getAuthUserIdPartnerIdMapping() throws ProfitMandiBusinessException {
753
        Map<Integer, List<Integer>> storeGuyMap = new HashMap<>();
753
        Map<Integer, List<Integer>> storeGuyMap = new HashMap<>();
754
        Set<Integer> activeFofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId()).collect(Collectors.toSet());
754
        Set<Integer> activeFofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId()).collect(Collectors.toSet());
755
        List<Position> categoryPositions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
755
        List<Position> categoryPositions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
756
        categoryPositions.addAll(positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM));
756
        categoryPositions.addAll(positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM));
757
 
757
 
Line 783... Line 783...
783
        return storeGuyMap;
783
        return storeGuyMap;
784
    }
784
    }
785
 
785
 
786
    @Override
786
    @Override
787
    @Cacheable(value = "L1L2Mapping", cacheManager = "thirtyMinsTimeOutCacheManager")
787
    @Cacheable(value = "L1L2Mapping", cacheManager = "thirtyMinsTimeOutCacheManager")
788
    public Map<Integer, List<Integer>> getL2L1Mapping() {
788
    public Map<Integer, List<Integer>> getL2L1Mapping() throws ProfitMandiBusinessException {
789
        List<Position> l1SalesPositions = positionRepository.selectPositionbyCategoryIdAndEscalationType(
789
        List<Position> l1SalesPositions = positionRepository.selectPositionbyCategoryIdAndEscalationType(
790
                ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L1);
790
                ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L1);
791
        List<Position> l2SalesPositions = positionRepository.selectPositionbyCategoryIdAndEscalationType(
791
        List<Position> l2SalesPositions = positionRepository.selectPositionbyCategoryIdAndEscalationType(
792
                ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L2);
792
                ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L2);
793
 
793
 
Line 830... Line 830...
830
        Map<Integer, AuthUser> authUserMap = authRepository.selectAllAuthUserByIds(authUserIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
830
        Map<Integer, AuthUser> authUserMap = authRepository.selectAllAuthUserByIds(authUserIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
831
        return ticketAssignedList.stream().collect(Collectors.groupingBy(x -> x.getTicketId(), Collectors.mapping(x -> authUserMap.get(x.getAssineeId()), Collectors.toList())));
831
        return ticketAssignedList.stream().collect(Collectors.groupingBy(x -> x.getTicketId(), Collectors.mapping(x -> authUserMap.get(x.getAssineeId()), Collectors.toList())));
832
    }
832
    }
833
 
833
 
834
    @Override
834
    @Override
835
    public Map<EscalationType, AuthUser> getAuthUserAndEsclationByPartnerId(int fofoId) {
835
    public Map<EscalationType, AuthUser> getAuthUserAndEsclationByPartnerId(int fofoId) throws ProfitMandiBusinessException {
836
        Map<EscalationType, AuthUser> authuserEsclationTypeMap = new HashMap<>();
836
        Map<EscalationType, AuthUser> authuserEsclationTypeMap = new HashMap<>();
837
        List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
837
        List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
838
 
838
 
839
        regionIds.add(5);// All partners Id;
839
        regionIds.add(5);// All partners Id;
840
        List<Integer> fofoIds = new ArrayList<>();
840
        List<Integer> fofoIds = new ArrayList<>();
Line 862... Line 862...
862
 
862
 
863
        return authuserEsclationTypeMap;
863
        return authuserEsclationTypeMap;
864
    }
864
    }
865
 
865
 
866
    @Override
866
    @Override
867
    public List<AuthUser> getAuthUserIdByPartnerId(int fofoId) {
867
    public List<AuthUser> getAuthUserIdByPartnerId(int fofoId) throws ProfitMandiBusinessException {
868
        return this.getAuthUserIdByPartnerId(fofoId, EscalationType.escalations.toArray(new EscalationType[0]));
868
        return this.getAuthUserIdByPartnerId(fofoId, EscalationType.escalations.toArray(new EscalationType[0]));
869
    }
869
    }
870
 
870
 
871
    @Override
871
    @Override
872
    public List<AuthUser> getAuthUserIdByPartnerId(int fofoId, EscalationType... escalationTypes) {
872
    public List<AuthUser> getAuthUserIdByPartnerId(int fofoId, EscalationType... escalationTypes) throws ProfitMandiBusinessException {
873
        List<AuthUser> authUsers = new ArrayList<>();
873
        List<AuthUser> authUsers = new ArrayList<>();
874
        List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
874
        List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
875
 
875
 
876
        regionIds.add(5);// All partners Id;
876
        regionIds.add(5);// All partners Id;
877
        List<Integer> fofoIds = new ArrayList<>();
877
        List<Integer> fofoIds = new ArrayList<>();
Line 978... Line 978...
978
 
978
 
979
 
979
 
980
 
980
 
981
    @Override
981
    @Override
982
    @Cacheable(value = "partnerSaleHeader", cacheManager = "oneDayCacheManager")
982
    @Cacheable(value = "partnerSaleHeader", cacheManager = "oneDayCacheManager")
983
    public Map<Integer, FofoReportingModel> getPartnerIdSalesHeaders() {
983
    public Map<Integer, FofoReportingModel> getPartnerIdSalesHeaders() throws ProfitMandiBusinessException {
984
        Map<String, SaleRoles> partnerEmailSalesMap = new HashMap<>();
984
        Map<String, SaleRoles> partnerEmailSalesMap = new HashMap<>();
985
 
985
 
986
        List<Position> positions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
986
        List<Position> positions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
987
        Map<Integer, AuthUser> authUsersMap = authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
987
        Map<Integer, AuthUser> authUsersMap = authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
988
        Map<Integer, List<CustomRetailer>> positionIdRetailerMap = this.getPositionCustomRetailerMap(positions);
988
        Map<Integer, List<CustomRetailer>> positionIdRetailerMap = this.getPositionCustomRetailerMap(positions);
Line 1089... Line 1089...
1089
 
1089
 
1090
    }
1090
    }
1091
 
1091
 
1092
    @Override
1092
    @Override
1093
    @Cacheable(value = "partnerRBMHeader", cacheManager = "oneDayCacheManager")
1093
    @Cacheable(value = "partnerRBMHeader", cacheManager = "oneDayCacheManager")
1094
    public Map<Integer, FofoRBMReportingModel> getPartnerIdRBMHeaders() {
1094
    public Map<Integer, FofoRBMReportingModel> getPartnerIdRBMHeaders() throws ProfitMandiBusinessException {
1095
        Map<String, RBMRoles> partnerEmailRbmMap = new HashMap<>();
1095
        Map<String, RBMRoles> partnerEmailRbmMap = new HashMap<>();
1096
 
1096
 
1097
        List<Position> positions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM);
1097
        List<Position> positions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM);
1098
        Map<Integer, AuthUser> authUsersMap = authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
1098
        Map<Integer, AuthUser> authUsersMap = authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
1099
        Map<Integer, List<CustomRetailer>> positionIdRetailerMap = this.getPositionCustomRetailerMap(positions);
1099
        Map<Integer, List<CustomRetailer>> positionIdRetailerMap = this.getPositionCustomRetailerMap(positions);