Subversion Repositories SmartDukaan

Rev

Rev 37225 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37225 Rev 37233
Line 792... Line 792...
792
 
792
 
793
        // ---- Batch pre-fetch everything else that was previously per-fofo ----
793
        // ---- Batch pre-fetch everything else that was previously per-fofo ----
794
 
794
 
795
        // Auth hierarchy:
795
        // Auth hierarchy:
796
        //   RBM  = TICKET_CATEGORY_RBM   → L1, fallback L2
796
        //   RBM  = TICKET_CATEGORY_RBM   → L1, fallback L2
797
        //   BM   = TICKET_CATEGORY_SALES → L4 (was L2)
797
        //   BM   = TICKET_CATEGORY_SALES → L4
798
        //   Sales Manager = TICKET_CATEGORY_SALES → L1, fallback L2, then L3
798
        //   Sales Manager = TICKET_CATEGORY_SALES → L1, fallback L2, L3, L4, L5
799
        //   ABM  = removed from report
799
        //   ABM  = removed from report
800
        Map<Integer, Integer> rbmL1Map = csService.getAuthUserIdsWithoutTicketAssigneeByFofoIds(ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L1, retailerIdSet);
800
        Map<Integer, Integer> rbmL1Map = csService.getAuthUserIdsWithoutTicketAssigneeByFofoIds(ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L1, retailerIdSet);
801
        Map<Integer, Integer> rbmL2Map = csService.getAuthUserIdsWithoutTicketAssigneeByFofoIds(ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L2, retailerIdSet);
801
        Map<Integer, Integer> rbmL2Map = csService.getAuthUserIdsWithoutTicketAssigneeByFofoIds(ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L2, retailerIdSet);
802
        Map<Integer, Integer> bmMap = csService.getAuthUserIdsWithoutTicketAssigneeByFofoIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L4, retailerIdSet);
802
        Map<Integer, Integer> bmMap = csService.getAuthUserIdsWithoutTicketAssigneeByFofoIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L4, retailerIdSet);
803
        Map<Integer, Integer> salesManagerL1Map = csService.getAuthUserIdsWithoutTicketAssigneeByFofoIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L1, retailerIdSet);
803
        Map<Integer, Integer> salesManagerL1Map = csService.getAuthUserIdsWithoutTicketAssigneeByFofoIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L1, retailerIdSet);
804
        Map<Integer, Integer> salesManagerL2Map = csService.getAuthUserIdsWithoutTicketAssigneeByFofoIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L2, retailerIdSet);
804
        Map<Integer, Integer> salesManagerL2Map = csService.getAuthUserIdsWithoutTicketAssigneeByFofoIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L2, retailerIdSet);
805
        Map<Integer, Integer> salesManagerL3Map = csService.getAuthUserIdsWithoutTicketAssigneeByFofoIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L3, retailerIdSet);
805
        Map<Integer, Integer> salesManagerL3Map = csService.getAuthUserIdsWithoutTicketAssigneeByFofoIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L3, retailerIdSet);
-
 
806
        Map<Integer, Integer> salesManagerL4Map = csService.getAuthUserIdsWithoutTicketAssigneeByFofoIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L4, retailerIdSet);
-
 
807
        Map<Integer, Integer> salesManagerL5Map = csService.getAuthUserIdsWithoutTicketAssigneeByFofoIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L5, retailerIdSet);
806
 
808
 
807
        Set<Integer> allAuthUserIds = new HashSet<>();
809
        Set<Integer> allAuthUserIds = new HashSet<>();
808
        for (Map<Integer, Integer> m : Arrays.asList(rbmL1Map, rbmL2Map, bmMap, salesManagerL1Map, salesManagerL2Map, salesManagerL3Map)) {
810
        for (Map<Integer, Integer> m : Arrays.asList(rbmL1Map, rbmL2Map, bmMap, salesManagerL1Map, salesManagerL2Map, salesManagerL3Map, salesManagerL4Map, salesManagerL5Map)) {
809
            m.values().stream().filter(v -> v != null && v != 0).forEach(allAuthUserIds::add);
811
            m.values().stream().filter(v -> v != null && v != 0).forEach(allAuthUserIds::add);
810
        }
812
        }
811
        Map<Integer, AuthUser> authUserMap = allAuthUserIds.isEmpty() ? new HashMap<>()
813
        Map<Integer, AuthUser> authUserMap = allAuthUserIds.isEmpty() ? new HashMap<>()
812
                : authRepository.selectByIds(new ArrayList<>(allAuthUserIds)).stream()
814
                : authRepository.selectByIds(new ArrayList<>(allAuthUserIds)).stream()
813
                    .collect(Collectors.toMap(AuthUser::getId, u -> u, (a, b) -> a));
815
                    .collect(Collectors.toMap(AuthUser::getId, u -> u, (a, b) -> a));
Line 953... Line 955...
953
            String bmName = "";
955
            String bmName = "";
954
            int bmId = bmMap.getOrDefault(fofoId, 0);
956
            int bmId = bmMap.getOrDefault(fofoId, 0);
955
            if (bmId != 0 && authUserMap.get(bmId) != null) {
957
            if (bmId != 0 && authUserMap.get(bmId) != null) {
956
                bmName = authUserMap.get(bmId).getFullName();
958
                bmName = authUserMap.get(bmId).getFullName();
957
            }
959
            }
958
            // Sales Manager: L1 → L2 → L3 fallback in SALES category
960
            // Sales Manager: L1 → L2 → L3 → L4 → L5 fallback in SALES category
959
            String managerName = "";
961
            String managerName = "";
960
            int managerL1 = salesManagerL1Map.getOrDefault(fofoId, 0);
962
            int managerL1 = salesManagerL1Map.getOrDefault(fofoId, 0);
961
            int managerL2 = salesManagerL2Map.getOrDefault(fofoId, 0);
963
            int managerL2 = salesManagerL2Map.getOrDefault(fofoId, 0);
962
            int managerL3 = salesManagerL3Map.getOrDefault(fofoId, 0);
964
            int managerL3 = salesManagerL3Map.getOrDefault(fofoId, 0);
-
 
965
            int managerL4 = salesManagerL4Map.getOrDefault(fofoId, 0);
-
 
966
            int managerL5 = salesManagerL5Map.getOrDefault(fofoId, 0);
963
            if (managerL1 != 0 && authUserMap.get(managerL1) != null) {
967
            if (managerL1 != 0 && authUserMap.get(managerL1) != null) {
964
                managerName = authUserMap.get(managerL1).getFullName();
968
                managerName = authUserMap.get(managerL1).getFullName();
965
            } else if (managerL2 != 0 && authUserMap.get(managerL2) != null) {
969
            } else if (managerL2 != 0 && authUserMap.get(managerL2) != null) {
966
                managerName = authUserMap.get(managerL2).getFullName();
970
                managerName = authUserMap.get(managerL2).getFullName();
967
            } else if (managerL3 != 0 && authUserMap.get(managerL3) != null) {
971
            } else if (managerL3 != 0 && authUserMap.get(managerL3) != null) {
968
                managerName = authUserMap.get(managerL3).getFullName();
972
                managerName = authUserMap.get(managerL3).getFullName();
-
 
973
            } else if (managerL4 != 0 && authUserMap.get(managerL4) != null) {
-
 
974
                managerName = authUserMap.get(managerL4).getFullName();
-
 
975
            } else if (managerL5 != 0 && authUserMap.get(managerL5) != null) {
-
 
976
                managerName = authUserMap.get(managerL5).getFullName();
969
            }
977
            }
970
 
978
 
971
            AST ast = astMap.get(customRetailers.get(fofoId).getAstId());
979
            AST ast = astMap.get(customRetailers.get(fofoId).getAstId());
972
            PartnerType partnerTypeThisMonth = partnerTypeMap.get(fofoId);
980
            PartnerType partnerTypeThisMonth = partnerTypeMap.get(fofoId);
973
 
981