| Line 10... |
Line 10... |
| 10 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
10 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 11 |
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
|
11 |
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
|
| 12 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
12 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 13 |
import com.spice.profitmandi.dao.model.ActivityMediaModel;
|
13 |
import com.spice.profitmandi.dao.model.ActivityMediaModel;
|
| 14 |
import com.spice.profitmandi.dao.model.FofoReportingModel;
|
14 |
import com.spice.profitmandi.dao.model.FofoReportingModel;
|
| - |
|
15 |
import com.spice.profitmandi.dao.model.FofoRBMReportingModel;
|
| 15 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
16 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 16 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
17 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 17 |
import com.spice.profitmandi.service.user.RetailerService;
|
18 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 18 |
import org.apache.commons.collections4.map.HashedMap;
|
19 |
import org.apache.commons.collections4.map.HashedMap;
|
| 19 |
import org.apache.commons.lang.RandomStringUtils;
|
20 |
import org.apache.commons.lang.RandomStringUtils;
|
| Line 964... |
Line 965... |
| 964 |
return "SaleRoles [l1=" + l1 + ", l2=" + l2 + ", l3=" + l3 + ", l4=" + l4 + "]";
|
965 |
return "SaleRoles [l1=" + l1 + ", l2=" + l2 + ", l3=" + l3 + ", l4=" + l4 + "]";
|
| 965 |
}
|
966 |
}
|
| 966 |
|
967 |
|
| 967 |
}
|
968 |
}
|
| 968 |
|
969 |
|
| - |
|
970 |
|
| - |
|
971 |
|
| 969 |
@Override
|
972 |
@Override
|
| 970 |
@Cacheable(value = "partnerSaleHeader", cacheManager = "oneDayCacheManager")
|
973 |
@Cacheable(value = "partnerSaleHeader", cacheManager = "oneDayCacheManager")
|
| 971 |
public Map<Integer, FofoReportingModel> getPartnerIdSalesHeaders() {
|
974 |
public Map<Integer, FofoReportingModel> getPartnerIdSalesHeaders() {
|
| 972 |
Map<String, SaleRoles> partnerEmailSalesMap = new HashMap<>();
|
975 |
Map<String, SaleRoles> partnerEmailSalesMap = new HashMap<>();
|
| 973 |
|
976 |
|
| Line 1037... |
Line 1040... |
| 1037 |
}
|
1040 |
}
|
| 1038 |
return partnerIdSalesHeadersMap;
|
1041 |
return partnerIdSalesHeadersMap;
|
| 1039 |
|
1042 |
|
| 1040 |
}
|
1043 |
}
|
| 1041 |
|
1044 |
|
| - |
|
1045 |
|
| - |
|
1046 |
private class RBMRoles {
|
| - |
|
1047 |
|
| - |
|
1048 |
private List<String> l1;
|
| - |
|
1049 |
private List<String> l2;
|
| - |
|
1050 |
private List<String> l3;
|
| - |
|
1051 |
private List<String> l4;
|
| - |
|
1052 |
|
| - |
|
1053 |
public RBMRoles() {
|
| - |
|
1054 |
l1 = new ArrayList<>();
|
| - |
|
1055 |
l2 = new ArrayList<>();
|
| - |
|
1056 |
l3 = new ArrayList<>();
|
| - |
|
1057 |
l4 = new ArrayList<>();
|
| - |
|
1058 |
}
|
| - |
|
1059 |
|
| - |
|
1060 |
public List<String> getL1() {
|
| - |
|
1061 |
return l1;
|
| - |
|
1062 |
}
|
| - |
|
1063 |
|
| - |
|
1064 |
public List<String> getL2() {
|
| - |
|
1065 |
return l2;
|
| - |
|
1066 |
}
|
| - |
|
1067 |
|
| - |
|
1068 |
public List<String> getL3() {
|
| - |
|
1069 |
return l3;
|
| - |
|
1070 |
}
|
| - |
|
1071 |
|
| - |
|
1072 |
public List<String> getL4() {
|
| - |
|
1073 |
return l4;
|
| - |
|
1074 |
}
|
| - |
|
1075 |
|
| - |
|
1076 |
@Override
|
| - |
|
1077 |
public String toString() {
|
| - |
|
1078 |
return "RBMRoles [l1=" + l1 + ", l2=" + l2 + ", l3=" + l3 + ", l4=" + l4 + "]";
|
| - |
|
1079 |
}
|
| - |
|
1080 |
|
| - |
|
1081 |
}
|
| - |
|
1082 |
|
| - |
|
1083 |
@Override
|
| - |
|
1084 |
@Cacheable(value = "partnerRBMHeader", cacheManager = "oneDayCacheManager")
|
| - |
|
1085 |
public Map<Integer, FofoRBMReportingModel> getPartnerIdRBMHeaders() {
|
| - |
|
1086 |
Map<String, RBMRoles> partnerEmailRbmMap = new HashMap<>();
|
| - |
|
1087 |
|
| - |
|
1088 |
List<Position> positions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM);
|
| - |
|
1089 |
Map<Integer, AuthUser> authUsersMap = authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
1090 |
Map<Integer, List<CustomRetailer>> positionIdRetailerMap = this.getPositionCustomRetailerMap(positions);
|
| - |
|
1091 |
for (Position position : positions) {
|
| - |
|
1092 |
List<CustomRetailer> crList = positionIdRetailerMap.get(position.getId());
|
| - |
|
1093 |
if (crList == null)
|
| - |
|
1094 |
continue;
|
| - |
|
1095 |
for (CustomRetailer cr : crList) {
|
| - |
|
1096 |
if (!partnerEmailRbmMap.containsKey(cr.getEmail())) {
|
| - |
|
1097 |
partnerEmailRbmMap.put(cr.getEmail(), new RBMRoles());
|
| - |
|
1098 |
}
|
| - |
|
1099 |
RBMRoles rbmRole = partnerEmailRbmMap.get(cr.getEmail());
|
| - |
|
1100 |
AuthUser authUser = authUsersMap.get(position.getAuthUserId());
|
| - |
|
1101 |
if (authUser == null) {
|
| - |
|
1102 |
continue;
|
| - |
|
1103 |
}
|
| - |
|
1104 |
String name = authUser.getFirstName() + " " + authUser.getLastName();
|
| - |
|
1105 |
if (position.getEscalationType().equals(EscalationType.L1)) {
|
| - |
|
1106 |
rbmRole.getL1().add(name);
|
| - |
|
1107 |
} else if (position.getEscalationType().equals(EscalationType.L2)) {
|
| - |
|
1108 |
rbmRole.getL2().add(name);
|
| - |
|
1109 |
}
|
| - |
|
1110 |
|
| - |
|
1111 |
}
|
| - |
|
1112 |
}
|
| - |
|
1113 |
|
| - |
|
1114 |
Set<CustomRetailer> allCrList = new HashSet<>();
|
| - |
|
1115 |
for (List<CustomRetailer> cr : positionIdRetailerMap.values()) {
|
| - |
|
1116 |
allCrList.addAll(cr);
|
| - |
|
1117 |
}
|
| - |
|
1118 |
|
| - |
|
1119 |
Map<Integer, FofoStore> fofoStoresMap = fofoStoreRepository.selectActiveStores().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
1120 |
|
| - |
|
1121 |
Map<Integer, FofoRBMReportingModel> partnerIdRbmHeadersMap = new HashMap<>();
|
| - |
|
1122 |
|
| - |
|
1123 |
for (CustomRetailer cr : allCrList) {
|
| - |
|
1124 |
FofoStore fofoStore = fofoStoresMap.get(cr.getPartnerId());
|
| - |
|
1125 |
if (fofoStore == null) {
|
| - |
|
1126 |
LOGGER.info("Could not find Store {} in active Store", cr.getBusinessName());
|
| - |
|
1127 |
continue;
|
| - |
|
1128 |
}
|
| - |
|
1129 |
String code = fofoStore.getCode();
|
| - |
|
1130 |
// String storeName = "SmartDukaan-" +
|
| - |
|
1131 |
// fofoStore.getCode().replaceAll("[a-zA-Z]", "");
|
| - |
|
1132 |
String businessName = cr.getBusinessName();
|
| - |
|
1133 |
try {
|
| - |
|
1134 |
String L2User = StringUtils.join(partnerEmailRbmMap.get(cr.getEmail()).getL2(), ", ");
|
| - |
|
1135 |
String L1USer = StringUtils.join(partnerEmailRbmMap.get(cr.getEmail()).getL1(), ", ");
|
| - |
|
1136 |
|
| - |
|
1137 |
if (StringUtils.isEmpty(L1USer)) {
|
| - |
|
1138 |
L1USer = StringUtils.join(partnerEmailRbmMap.get(cr.getEmail()).getL2(), ", ");
|
| - |
|
1139 |
}
|
| - |
|
1140 |
|
| - |
|
1141 |
FofoRBMReportingModel reportingModel = new FofoRBMReportingModel();
|
| - |
|
1142 |
reportingModel.setBusinessName(businessName);
|
| - |
|
1143 |
reportingModel.setCode(code);
|
| - |
|
1144 |
reportingModel.setFofoId(fofoStore.getId());
|
| - |
|
1145 |
reportingModel.setL1Manager(L2User);
|
| - |
|
1146 |
reportingModel.setL2Manager(L1USer);
|
| - |
|
1147 |
partnerIdRbmHeadersMap.put(fofoStore.getId(), reportingModel);
|
| - |
|
1148 |
} catch (Exception e) {
|
| - |
|
1149 |
LOGGER.warn("Could not find partner with email - {}", cr.getEmail());
|
| - |
|
1150 |
}
|
| - |
|
1151 |
}
|
| - |
|
1152 |
return partnerIdRbmHeadersMap;
|
| - |
|
1153 |
|
| - |
|
1154 |
}
|
| - |
|
1155 |
|
| 1042 |
@Override
|
1156 |
@Override
|
| 1043 |
public Map<Integer, TicketCategory> getSubCategoryIdAndCategoryMap(List<Integer> subCategoryIds) {
|
1157 |
public Map<Integer, TicketCategory> getSubCategoryIdAndCategoryMap(List<Integer> subCategoryIds) {
|
| 1044 |
Map<Integer, TicketCategory> subCategoryIdAndCategoryMap = new HashMap<>();
|
1158 |
Map<Integer, TicketCategory> subCategoryIdAndCategoryMap = new HashMap<>();
|
| 1045 |
|
1159 |
|
| 1046 |
List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository.selectByIds(subCategoryIds);
|
1160 |
List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository.selectByIds(subCategoryIds);
|