Subversion Repositories SmartDukaan

Rev

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

Rev 36399 Rev 36802
Line 1118... Line 1118...
1118
    }
1118
    }
1119
 
1119
 
1120
    @Override
1120
    @Override
1121
    @Cacheable(value = "authUserIdPartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
1121
    @Cacheable(value = "authUserIdPartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
1122
    public Map<Integer, List<Integer>> getAuthUserIdPartnerIdMapping() throws ProfitMandiBusinessException {
1122
    public Map<Integer, List<Integer>> getAuthUserIdPartnerIdMapping() throws ProfitMandiBusinessException {
-
 
1123
        return buildAuthUserIdPartnerIdMapping(true);
-
 
1124
    }
-
 
1125
 
-
 
1126
    @Override
-
 
1127
    @Cacheable(value = "authUserIdAllPartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
-
 
1128
    public Map<Integer, List<Integer>> getAuthUserIdAllPartnerIdMapping() throws ProfitMandiBusinessException {
-
 
1129
        return buildAuthUserIdPartnerIdMapping(false);
-
 
1130
    }
-
 
1131
 
-
 
1132
    private Map<Integer, List<Integer>> buildAuthUserIdPartnerIdMapping(boolean activeOnly) throws ProfitMandiBusinessException {
1123
        Map<Integer, List<Integer>> storeGuyMap = new HashMap<>();
1133
        Map<Integer, List<Integer>> storeGuyMap = new HashMap<>();
-
 
1134
        Set<Integer> fofoIdsScope = (activeOnly
-
 
1135
                ? fofoStoreRepository.selectActiveStores()
-
 
1136
                : fofoStoreRepository.selectAllFranchiseStores())
1124
        Set<Integer> activeFofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId()).collect(Collectors.toSet());
1137
                .stream().map(x -> x.getId()).collect(Collectors.toSet());
1125
 
1138
 
1126
        List<Position> categoryPositions = positionRepository.selectAllPosition();
1139
        List<Position> categoryPositions = positionRepository.selectAllPosition();
1127
 
1140
 
1128
        Map<Integer, Position> positionsMap = categoryPositions.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
1141
        Map<Integer, Position> positionsMap = categoryPositions.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
1129
 
1142
 
Line 1137... Line 1150...
1137
                .collect(Collectors.toMap(AuthUser::getId, au -> au, (a, b) -> a));
1150
                .collect(Collectors.toMap(AuthUser::getId, au -> au, (a, b) -> a));
1138
 
1151
 
1139
        Map<Integer, List<CustomRetailer>> positonPartnerMap = this.getPositionCustomRetailerMap(categoryPositions);
1152
        Map<Integer, List<CustomRetailer>> positonPartnerMap = this.getPositionCustomRetailerMap(categoryPositions);
1140
        for (Map.Entry<Integer, List<CustomRetailer>> positionPartnerEntry : positonPartnerMap.entrySet()) {
1153
        for (Map.Entry<Integer, List<CustomRetailer>> positionPartnerEntry : positonPartnerMap.entrySet()) {
1141
            int authUserId = positionsMap.get(positionPartnerEntry.getKey()).getAuthUserId();
1154
            int authUserId = positionsMap.get(positionPartnerEntry.getKey()).getAuthUserId();
1142
            List<Integer> partnerIds = positionPartnerEntry.getValue().stream().filter(x -> activeFofoIds.contains(x.getPartnerId())).map(x -> x.getPartnerId()).collect(Collectors.toList());
1155
            List<Integer> partnerIds = positionPartnerEntry.getValue().stream().filter(x -> fofoIdsScope.contains(x.getPartnerId())).map(x -> x.getPartnerId()).collect(Collectors.toList());
1143
            AuthUser authUser = authUserMap.get(authUserId);
1156
            AuthUser authUser = authUserMap.get(authUserId);
1144
            if (authUser != null && authUser.isActive()) {
1157
            if (authUser != null && authUser.isActive()) {
1145
                if (!storeGuyMap.containsKey(authUserId)) {
1158
                if (!storeGuyMap.containsKey(authUserId)) {
1146
                    storeGuyMap.put(authUserId, partnerIds);
1159
                    storeGuyMap.put(authUserId, partnerIds);
1147
                } else {
1160
                } else {