Subversion Repositories SmartDukaan

Rev

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

Rev 35920 Rev 35968
Line 945... Line 945...
945
                if (!allAuthIds.isEmpty()) {
945
                if (!allAuthIds.isEmpty()) {
946
                    authUserMap = authRepository.selectByIds(new ArrayList<>(allAuthIds)).stream()
946
                    authUserMap = authRepository.selectByIds(new ArrayList<>(allAuthIds)).stream()
947
                            .collect(Collectors.toMap(AuthUser::getId, x -> x));
947
                            .collect(Collectors.toMap(AuthUser::getId, x -> x));
948
                }
948
                }
949
 
949
 
-
 
950
                // Fetch BM/ASM/RBM for all partners
-
 
951
                Map<Integer, Map<String, Integer>> bmAsmRbmMap = csService.getBmAsmRbmAuthUserIdsByFofoIds(new HashSet<>(fofoIdList));
-
 
952
                LOGGER.info("PERF: getBmAsmRbmAuthUserIdsByFofoIds took {} ms", System.currentTimeMillis() - lapTime);
-
 
953
                lapTime = System.currentTimeMillis();
-
 
954
 
-
 
955
                // Collect all BM/ASM/RBM auth IDs to batch fetch AuthUser names
-
 
956
                Set<Integer> bmAsmRbmAuthIds = bmAsmRbmMap.values().stream()
-
 
957
                        .flatMap(m -> m.values().stream())
-
 
958
                        .filter(id -> id != null && id > 0)
-
 
959
                        .collect(Collectors.toSet());
-
 
960
 
-
 
961
                Map<Integer, AuthUser> bmAsmRbmAuthUserMap = new HashMap<>();
-
 
962
                if (!bmAsmRbmAuthIds.isEmpty()) {
-
 
963
                    bmAsmRbmAuthUserMap = authRepository.selectByIds(new ArrayList<>(bmAsmRbmAuthIds)).stream()
-
 
964
                            .collect(Collectors.toMap(AuthUser::getId, x -> x, (a, b) -> a));
-
 
965
                }
-
 
966
                LOGGER.info("PERF: fetch BM/ASM/RBM AuthUsers took {} ms", System.currentTimeMillis() - lapTime);
-
 
967
                lapTime = System.currentTimeMillis();
-
 
968
 
950
                LOGGER.info("partnerSecondayPlans {}", partnerSecondaryPlans);
969
                LOGGER.info("partnerSecondayPlans {}", partnerSecondaryPlans);
-
 
970
                final Map<Integer, AuthUser> finalBmAsmRbmAuthUserMap = bmAsmRbmAuthUserMap;
951
                for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailers.entrySet()) {
971
                for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailers.entrySet()) {
952
                    int fofoId = customRetailerEntry.getKey();
972
                    int fofoId = customRetailerEntry.getKey();
953
                    CustomRetailer customRetailer = customRetailerEntry.getValue();
973
                    CustomRetailer customRetailer = customRetailerEntry.getValue();
954
                    float totalSecondaryPlan = 0;
974
                    float totalSecondaryPlan = 0;
955
                    float totalSecondaryAchivement = 0;
975
                    float totalSecondaryAchivement = 0;
Line 957... Line 977...
957
                    PartnerTargetAchievementModel ptam = new PartnerTargetAchievementModel();
977
                    PartnerTargetAchievementModel ptam = new PartnerTargetAchievementModel();
958
                    ptam.setFofoId(fofoId);
978
                    ptam.setFofoId(fofoId);
959
                    ptam.setBusinessName(customRetailer.getBusinessName());
979
                    ptam.setBusinessName(customRetailer.getBusinessName());
960
                    ptam.setMobile(customRetailer.getMobileNumber());
980
                    ptam.setMobile(customRetailer.getMobileNumber());
961
 
981
 
-
 
982
                    // Set ASM/RBM/BM names
-
 
983
                    Map<String, Integer> roleMap = bmAsmRbmMap.get(fofoId);
-
 
984
                    if (roleMap != null) {
-
 
985
                        Integer asmId = roleMap.get("ASM");
-
 
986
                        if (asmId != null && asmId > 0 && finalBmAsmRbmAuthUserMap.get(asmId) != null) {
-
 
987
                            ptam.setAsmName(finalBmAsmRbmAuthUserMap.get(asmId).getFullName());
-
 
988
                        }
-
 
989
                        Integer rbmId = roleMap.get("RBM");
-
 
990
                        if (rbmId != null && rbmId > 0 && finalBmAsmRbmAuthUserMap.get(rbmId) != null) {
-
 
991
                            ptam.setRbmName(finalBmAsmRbmAuthUserMap.get(rbmId).getFullName());
-
 
992
                        }
-
 
993
                        Integer bmId = roleMap.get("BM");
-
 
994
                        if (bmId != null && bmId > 0 && finalBmAsmRbmAuthUserMap.get(bmId) != null) {
-
 
995
                            ptam.setBmName(finalBmAsmRbmAuthUserMap.get(bmId).getFullName());
-
 
996
                        }
-
 
997
                    }
-
 
998
 
962
                    if (partnerDailyInvestmentMap.get(fofoId) != null) {
999
                    if (partnerDailyInvestmentMap.get(fofoId) != null) {
963
                        ptam.setWalletAmount(partnerDailyInvestmentMap.get(fofoId).getWalletAmount());
1000
                        ptam.setWalletAmount(partnerDailyInvestmentMap.get(fofoId).getWalletAmount());
964
                        ptam.setShortInvestment(partnerDailyInvestmentMap.get(fofoId).getShortInvestment());
1001
                        ptam.setShortInvestment(partnerDailyInvestmentMap.get(fofoId).getShortInvestment());
965
                    }
1002
                    }
966
 
1003