Subversion Repositories SmartDukaan

Rev

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

Rev 35683 Rev 35920
Line 836... Line 836...
836
        }
836
        }
837
        return storeGuyMap;
837
        return storeGuyMap;
838
    }
838
    }
839
 
839
 
840
    @Override
840
    @Override
-
 
841
    @Cacheable(value = "authUserEmailInactivePartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
-
 
842
    public Map<String, Set<Integer>> getAuthUserInactivePartnerIdMapping() throws ProfitMandiBusinessException {
-
 
843
        Map<String, Set<Integer>> storeGuyMap = new HashMap<>();
-
 
844
        Set<Integer> activeFofoIds = fofoStoreRepository.selectInActiveStore().stream().map(x -> x.getId()).collect(Collectors.toSet());
-
 
845
 
-
 
846
        // Batch fetch positions by category IDs instead of multiple calls
-
 
847
        List<Position> categoryPositions = positionRepository.selectPositionByCategoryIds(Arrays.asList(
-
 
848
                ProfitMandiConstants.TICKET_CATEGORY_SALES,
-
 
849
                ProfitMandiConstants.TICKET_CATEGORY_RBM,
-
 
850
                ProfitMandiConstants.TICKET_CATEGORY_ABM,
-
 
851
                ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT,
-
 
852
                ProfitMandiConstants.TICKET_CATEGORY_TRAINING));
-
 
853
        Map<Integer, Position> positionsMap = categoryPositions.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
-
 
854
 
-
 
855
        // Batch fetch all AuthUsers upfront to avoid N+1 queries
-
 
856
        Set<Integer> authUserIds = categoryPositions.stream().map(Position::getAuthUserId).collect(Collectors.toSet());
-
 
857
        Map<Integer, AuthUser> authUserMap = authRepository.selectByIds(new ArrayList<>(authUserIds)).stream()
-
 
858
                .collect(Collectors.toMap(AuthUser::getId, x -> x));
-
 
859
 
-
 
860
        Map<Integer, List<CustomRetailer>> positonPartnerMap = this.getPositionCustomRetailerMap(categoryPositions);
-
 
861
        for (Map.Entry<Integer, List<CustomRetailer>> positionPartnerEntry : positonPartnerMap.entrySet()) {
-
 
862
            int authUserId = positionsMap.get(positionPartnerEntry.getKey()).getAuthUserId();
-
 
863
            Set<Integer> partnerIds = positionPartnerEntry.getValue().stream().filter(x -> activeFofoIds.contains(x.getPartnerId())).map(x -> x.getPartnerId()).collect(Collectors.toSet());
-
 
864
            AuthUser authUser = authUserMap.get(authUserId);
-
 
865
            if (authUser != null && authUser.isActive()) {
-
 
866
                if (!storeGuyMap.containsKey(authUser.getEmailId())) {
-
 
867
                    storeGuyMap.put(authUser.getEmailId(), partnerIds);
-
 
868
                } else {
-
 
869
                    storeGuyMap.get(authUser.getEmailId()).addAll(partnerIds);
-
 
870
                }
-
 
871
            }
-
 
872
        }
-
 
873
        return storeGuyMap;
-
 
874
    }
-
 
875
 
-
 
876
    @Override
841
    @Cacheable(value = "authUserPartnerEmailPartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
877
    @Cacheable(value = "authUserPartnerEmailPartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
842
    public Map<String, Set<Integer>> getAuthUserPartnerIdMappingByCategoryIds(List<Integer> categoryIds, boolean activeOnly) throws ProfitMandiBusinessException {
878
    public Map<String, Set<Integer>> getAuthUserPartnerIdMappingByCategoryIds(List<Integer> categoryIds, boolean activeOnly) throws ProfitMandiBusinessException {
843
        Map<String, Set<Integer>> authUserPartnerMap = new HashMap<>();
879
        Map<String, Set<Integer>> authUserPartnerMap = new HashMap<>();
844
        Set<Integer> activeFofoIds;
880
        Set<Integer> activeFofoIds;
845
        if (activeOnly) {
881
        if (activeOnly) {