| Line 1016... |
Line 1016... |
| 1016 |
|
1016 |
|
| 1017 |
Map<Integer, FofoStore> fofoStoresMap = fofoStoreRepository.selectActiveStores().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
1017 |
Map<Integer, FofoStore> fofoStoresMap = fofoStoreRepository.selectActiveStores().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 1018 |
|
1018 |
|
| 1019 |
Map<Integer, FofoReportingModel> partnerIdSalesHeadersMap = new HashMap<>();
|
1019 |
Map<Integer, FofoReportingModel> partnerIdSalesHeadersMap = new HashMap<>();
|
| 1020 |
|
1020 |
|
| 1021 |
for (CustomRetailer cr : allCrList) {
|
1021 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| 1022 |
FofoStore fofoStore = fofoStoresMap.get(cr.getPartnerId());
|
1022 |
for (Map.Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
|
| 1023 |
if (fofoStore == null) {
|
- |
|
| - |
|
1023 |
|
| 1024 |
LOGGER.info("Could not find Store {} in active Store", cr.getBusinessName());
|
1024 |
CustomRetailer customRetailer = customRetailerEntry.getValue();
|
| 1025 |
continue;
|
- |
|
| 1026 |
}
|
1025 |
|
| 1027 |
String code = fofoStore.getCode();
|
1026 |
String code = customRetailer.getCode();
|
| 1028 |
// String storeName = "SmartDukaan-" +
|
1027 |
// String storeName = "SmartDukaan-" +
|
| 1029 |
// fofoStore.getCode().replaceAll("[a-zA-Z]", "");
|
1028 |
// fofoStore.getCode().replaceAll("[a-zA-Z]", "");
|
| 1030 |
String businessName = cr.getBusinessName();
|
1029 |
String businessName = customRetailer.getBusinessName();
|
| 1031 |
try {
|
1030 |
try {
|
| 1032 |
String stateManager = StringUtils.join(partnerEmailSalesMap.get(cr.getEmail()).getL2(), ", ");
|
1031 |
String stateManager = StringUtils.join(partnerEmailSalesMap.get(customRetailer.getEmail()).getL2(), ", ");
|
| 1033 |
String territoryManager = StringUtils.join(partnerEmailSalesMap.get(cr.getEmail()).getL1(), ", ");
|
1032 |
String territoryManager = StringUtils.join(partnerEmailSalesMap.get(customRetailer.getEmail()).getL1(), ", ");
|
| 1034 |
|
1033 |
|
| 1035 |
if (StringUtils.isEmpty(territoryManager)) {
|
1034 |
if (StringUtils.isEmpty(territoryManager)) {
|
| 1036 |
territoryManager = StringUtils.join(partnerEmailSalesMap.get(cr.getEmail()).getL2(), ", ");
|
1035 |
territoryManager = StringUtils.join(partnerEmailSalesMap.get(customRetailer.getEmail()).getL2(), ", ");
|
| 1037 |
}
|
1036 |
}
|
| 1038 |
|
1037 |
|
| 1039 |
FofoReportingModel reportingModel = new FofoReportingModel();
|
1038 |
FofoReportingModel reportingModel = new FofoReportingModel();
|
| 1040 |
reportingModel.setBusinessName(businessName);
|
1039 |
reportingModel.setBusinessName(businessName);
|
| 1041 |
reportingModel.setCode(code);
|
1040 |
reportingModel.setCode(code);
|
| 1042 |
reportingModel.setFofoId(fofoStore.getId());
|
1041 |
reportingModel.setFofoId(customRetailer.getPartnerId());
|
| 1043 |
reportingModel.setRegionalManager(stateManager);
|
1042 |
reportingModel.setRegionalManager(stateManager);
|
| 1044 |
reportingModel.setTerritoryManager(territoryManager);
|
1043 |
reportingModel.setTerritoryManager(territoryManager);
|
| 1045 |
partnerIdSalesHeadersMap.put(fofoStore.getId(), reportingModel);
|
1044 |
partnerIdSalesHeadersMap.put(customRetailer.getPartnerId(), reportingModel);
|
| 1046 |
} catch (Exception e) {
|
1045 |
} catch (Exception e) {
|
| 1047 |
LOGGER.warn("Could not find partner with email - {}", cr.getEmail());
|
1046 |
LOGGER.warn("Could not find partner with email - {}", customRetailer.getEmail());
|
| 1048 |
}
|
1047 |
}
|
| 1049 |
}
|
1048 |
}
|
| 1050 |
return partnerIdSalesHeadersMap;
|
1049 |
return partnerIdSalesHeadersMap;
|
| 1051 |
|
1050 |
|
| 1052 |
}
|
1051 |
}
|