Subversion Repositories SmartDukaan

Rev

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

Rev 35669 Rev 35670
Line 1020... Line 1020...
1020
 
1020
 
1021
        return result;
1021
        return result;
1022
    }
1022
    }
1023
 
1023
 
1024
    @Override
1024
    @Override
-
 
1025
    public List<CalledPartnerDetailModel> getCalledPartnerDetails(int authId) {
-
 
1026
        LocalDate today = LocalDate.now();
-
 
1027
 
-
 
1028
        // Get today's remarks for this RBM
-
 
1029
        List<PartnerCollectionRemark> todayRemarks = partnerCollectionRemarkRepository
-
 
1030
                .selectAllByAuthIdsOnDate(Collections.singletonList(authId), today);
-
 
1031
 
-
 
1032
        if (todayRemarks.isEmpty()) {
-
 
1033
            return Collections.emptyList();
-
 
1034
        }
-
 
1035
 
-
 
1036
        // Get unique fofoIds (keep first/latest remark per fofoId)
-
 
1037
        Map<Integer, PartnerCollectionRemark> uniqueRemarksByFofoId = new LinkedHashMap<>();
-
 
1038
        for (PartnerCollectionRemark remark : todayRemarks) {
-
 
1039
            uniqueRemarksByFofoId.putIfAbsent(remark.getFofoId(), remark);
-
 
1040
        }
-
 
1041
 
-
 
1042
        Set<Integer> fofoIds = uniqueRemarksByFofoId.keySet();
-
 
1043
        Map<Integer, CustomRetailer> retailerMap = Collections.emptyMap();
-
 
1044
        try {
-
 
1045
            retailerMap = retailerService.getFofoRetailers(new ArrayList<>(fofoIds));
-
 
1046
        } catch (ProfitMandiBusinessException e) {
-
 
1047
            LOGGER.error("Error fetching fofo stores", e);
-
 
1048
        }
-
 
1049
 
-
 
1050
        DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("hh:mm a");
-
 
1051
        List<CalledPartnerDetailModel> result = new ArrayList<>();
-
 
1052
 
-
 
1053
        for (PartnerCollectionRemark remark : uniqueRemarksByFofoId.values()) {
-
 
1054
            CustomRetailer retailer = retailerMap.get(remark.getFofoId());
-
 
1055
            String partyName = retailer != null
-
 
1056
                    ? retailer.getBusinessName()
-
 
1057
                    : "Unknown (" + remark.getFofoId() + ")";
-
 
1058
            String code = retailer != null
-
 
1059
                    ? retailer.getCode()
-
 
1060
                    : "-";
-
 
1061
 
-
 
1062
            String remarkValue = remark.getRemark() != null
-
 
1063
                    ? remark.getRemark().getValue()
-
 
1064
                    : "-";
-
 
1065
 
-
 
1066
            String time = remark.getCreateTimestamp() != null
-
 
1067
                    ? remark.getCreateTimestamp().format(timeFormatter)
-
 
1068
                    : "-";
-
 
1069
 
-
 
1070
            result.add(new CalledPartnerDetailModel(partyName, code, remarkValue, time));
-
 
1071
        }
-
 
1072
 
-
 
1073
        return result;
-
 
1074
    }
-
 
1075
 
-
 
1076
    @Override
1025
    public List<List<String>> getRbmCallTargetRawDataByAuthId(int authId) throws Exception {
1077
    public List<List<String>> getRbmCallTargetRawDataByAuthId(int authId) throws Exception {
1026
        List<List<String>> rows = new ArrayList<>();
1078
        List<List<String>> rows = new ArrayList<>();
1027
 
1079
 
1028
        // Get auth user
1080
        // Get auth user
1029
        List<AuthUser> authUsers = authRepository.selectByIds(Collections.singletonList(authId));
1081
        List<AuthUser> authUsers = authRepository.selectByIds(Collections.singletonList(authId));