Subversion Repositories SmartDukaan

Rev

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

Rev 35563 Rev 35592
Line 1081... Line 1081...
1081
    @Override
1081
    @Override
1082
    public Map<EscalationType, AuthUser> getAuthUserAndEsclationByPartnerId(int fofoId) throws ProfitMandiBusinessException {
1082
    public Map<EscalationType, AuthUser> getAuthUserAndEsclationByPartnerId(int fofoId) throws ProfitMandiBusinessException {
1083
        Map<EscalationType, AuthUser> authuserEsclationTypeMap = new HashMap<>();
1083
        Map<EscalationType, AuthUser> authuserEsclationTypeMap = new HashMap<>();
1084
        List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
1084
        List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
1085
 
1085
 
1086
        regionIds.add(5);// All partners Id;
1086
        regionIds.add(ALL_PARTNERS_REGION);// All partners Id;
1087
        List<Integer> fofoIds = new ArrayList<>();
1087
        List<Integer> fofoIds = new ArrayList<>();
1088
        fofoIds.add(fofoId);
1088
        fofoIds.add(fofoId);
1089
        fofoIds.add(0);
1089
        fofoIds.add(0);
1090
 
1090
 
1091
        //LOGGER.info("fofoIds" + fofoIds);
-
 
1092
        List<Integer> partnerPositionIds = partnerPositionRepository.selectByRegionIdAndPartnerId(regionIds, fofoIds).stream().map(x -> x.getPositionId()).collect(Collectors.toList());
1091
        List<Integer> partnerPositionIds = partnerPositionRepository.selectByRegionIdAndPartnerId(regionIds, fofoIds).stream().map(x -> x.getPositionId()).collect(Collectors.toList());
1093
 
1092
 
1094
        //LOGGER.info("partnerPositionIds" + partnerPositionIds);
-
 
1095
 
-
 
1096
        for (Integer partnerPostionId : partnerPositionIds) {
1093
        if (partnerPositionIds.isEmpty()) {
1097
            Position position = positionRepository.selectByIdAndCategoryId(partnerPostionId, ProfitMandiConstants.TICKET_CATEGORY_SALES);
-
 
1098
            //LOGGER.info("position" + position);
1094
            return authuserEsclationTypeMap;
1099
            if (position != null) {
1095
        }
1100
 
-
 
1101
                AuthUser authUser = authRepository.selectById(position.getAuthUserId());
-
 
1102
                //LOGGER.info("authUser" + authUser);
-
 
1103
 
1096
 
-
 
1097
        // OPTIMIZED: Batch fetch all positions instead of N+1 queries
-
 
1098
        List<Position> salesPositions = positionRepository.selectByIds(partnerPositionIds).stream()
-
 
1099
                .filter(p -> p.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_SALES)
-
 
1100
                .collect(Collectors.toList());
-
 
1101
 
-
 
1102
        if (salesPositions.isEmpty()) {
-
 
1103
            return authuserEsclationTypeMap;
-
 
1104
        }
-
 
1105
 
-
 
1106
        // OPTIMIZED: Batch fetch all AuthUsers instead of N+1 queries
-
 
1107
        List<Integer> authUserIds = salesPositions.stream()
-
 
1108
                .map(Position::getAuthUserId)
-
 
1109
                .filter(id -> id != null && id > 0)
-
 
1110
                .distinct()
-
 
1111
                .collect(Collectors.toList());
-
 
1112
        Map<Integer, AuthUser> authUserMap = authRepository.selectByIds(authUserIds).stream()
-
 
1113
                .collect(Collectors.toMap(AuthUser::getId, au -> au, (a, b) -> a));
-
 
1114
 
-
 
1115
        for (Position position : salesPositions) {
-
 
1116
            AuthUser authUser = authUserMap.get(position.getAuthUserId());
-
 
1117
            if (authUser != null) {
1104
                authuserEsclationTypeMap.put(position.getEscalationType(), authUser);
1118
                authuserEsclationTypeMap.put(position.getEscalationType(), authUser);
1105
            }
1119
            }
1106
        }
1120
        }
1107
 
1121
 
1108
        //LOGGER.info("emailEsclationTypeMap" + authuserEsclationTypeMap);
-
 
1109
 
-
 
1110
        return authuserEsclationTypeMap;
1122
        return authuserEsclationTypeMap;
1111
    }
1123
    }
1112
 
1124
 
1113
    @Override
1125
    @Override
1114
    public Map<Integer, Map<EscalationType, AuthUser>> getAuthUserAndEsclationByPartnerIds(Set<Integer> fofoIds) throws ProfitMandiBusinessException {
1126
    public Map<Integer, Map<EscalationType, AuthUser>> getAuthUserAndEsclationByPartnerIds(Set<Integer> fofoIds) throws ProfitMandiBusinessException {
Line 1595... Line 1607...
1595
    }
1607
    }
1596
 
1608
 
1597
    @Override
1609
    @Override
1598
    public Map<Integer, TicketCategory> getSubCategoryIdAndCategoryMap(List<Integer> subCategoryIds) {
1610
    public Map<Integer, TicketCategory> getSubCategoryIdAndCategoryMap(List<Integer> subCategoryIds) {
1599
        Map<Integer, TicketCategory> subCategoryIdAndCategoryMap = new HashMap<>();
1611
        Map<Integer, TicketCategory> subCategoryIdAndCategoryMap = new HashMap<>();
-
 
1612
        if (subCategoryIds == null || subCategoryIds.isEmpty()) {
-
 
1613
            return subCategoryIdAndCategoryMap;
-
 
1614
        }
1600
 
1615
 
1601
        List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository.selectByIds(subCategoryIds);
1616
        List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository.selectByIds(subCategoryIds);
1602
 
1617
 
-
 
1618
        // OPTIMIZED: Batch fetch all categories instead of N+1 queries
1603
        for (TicketSubCategory ticketSubCategory : ticketSubCategories) {
1619
        List<Integer> categoryIds = ticketSubCategories.stream()
1604
 
-
 
-
 
1620
                .map(TicketSubCategory::getCategoryId)
-
 
1621
                .distinct()
-
 
1622
                .collect(Collectors.toList());
1605
            TicketCategory ticketCategory = ticketCategoryRepository.selectById(ticketSubCategory.getCategoryId());
1623
        Map<Integer, TicketCategory> categoryMap = ticketCategoryRepository.selectAll(categoryIds).stream()
1606
 
-
 
1607
            subCategoryIdAndCategoryMap.put(ticketSubCategory.getId(), ticketCategory);
1624
                .collect(Collectors.toMap(TicketCategory::getId, tc -> tc, (a, b) -> a));
1608
 
1625
 
-
 
1626
        for (TicketSubCategory ticketSubCategory : ticketSubCategories) {
-
 
1627
            subCategoryIdAndCategoryMap.put(ticketSubCategory.getId(), categoryMap.get(ticketSubCategory.getCategoryId()));
1609
        }
1628
        }
1610
        return subCategoryIdAndCategoryMap;
1629
        return subCategoryIdAndCategoryMap;
1611
    }
1630
    }
1612
 
1631
 
1613
    @Override
1632
    @Override