| Line 8... |
Line 8... |
| 8 |
import com.spice.profitmandi.dao.entity.cs.*;
|
8 |
import com.spice.profitmandi.dao.entity.cs.*;
|
| 9 |
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
|
9 |
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
|
| 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.*;
|
| 14 |
import com.spice.profitmandi.dao.model.AuthUserPartnerMapModel;
|
- |
|
| 15 |
import com.spice.profitmandi.dao.model.FofoRBMReportingModel;
|
- |
|
| 16 |
import com.spice.profitmandi.dao.model.FofoReportingModel;
|
- |
|
| 17 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
14 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 18 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
15 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 19 |
import com.spice.profitmandi.service.user.RetailerService;
|
16 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 20 |
import org.apache.commons.collections4.map.HashedMap;
|
17 |
import org.apache.commons.collections4.map.HashedMap;
|
| 21 |
import org.apache.commons.lang.RandomStringUtils;
|
18 |
import org.apache.commons.lang.RandomStringUtils;
|
| Line 760... |
Line 757... |
| 760 |
|
757 |
|
| 761 |
LOGGER.info("partnerPositionIds" + partnerPositionIds);
|
758 |
LOGGER.info("partnerPositionIds" + partnerPositionIds);
|
| 762 |
|
759 |
|
| 763 |
List<Position> positions = positionRepository.selectAll(partnerPositionIds);
|
760 |
List<Position> positions = positionRepository.selectAll(partnerPositionIds);
|
| 764 |
|
761 |
|
| 765 |
positions = positions.stream().filter(x -> (x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_SALES || x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_RBM)).collect(Collectors.toList());
|
762 |
positions = positions.stream().filter(x -> (x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_SALES || x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_RBM || x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_ABM)).collect(Collectors.toList());
|
| 766 |
|
763 |
|
| 767 |
if (!positions.isEmpty()) {
|
764 |
if (!positions.isEmpty()) {
|
| 768 |
for (Position partnerPostionId : positions) {
|
765 |
for (Position partnerPostionId : positions) {
|
| 769 |
|
766 |
|
| 770 |
AuthUser authUser = authRepository.selectById(partnerPostionId.getAuthUserId());
|
767 |
AuthUser authUser = authRepository.selectById(partnerPostionId.getAuthUserId());
|
| Line 937... |
Line 934... |
| 937 |
|
934 |
|
| 938 |
//LOGGER.info("fofoIds" + fofoIds);
|
935 |
//LOGGER.info("fofoIds" + fofoIds);
|
| 939 |
List<Integer> partnerPositionIds = partnerPositionRepository.selectByRegionIdAndPartnerId(regionIds, fofoIds).stream().map(x -> x.getPositionId()).collect(Collectors.toList());
|
936 |
List<Integer> partnerPositionIds = partnerPositionRepository.selectByRegionIdAndPartnerId(regionIds, fofoIds).stream().map(x -> x.getPositionId()).collect(Collectors.toList());
|
| 940 |
|
937 |
|
| 941 |
//LOGGER.info("partnerPositionIds" + partnerPositionIds);
|
938 |
//LOGGER.info("partnerPositionIds" + partnerPositionIds);
|
| 942 |
List<Integer> allowedTicketCategoryIds = Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_RBM);
|
939 |
List<Integer> allowedTicketCategoryIds = Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_RBM,ProfitMandiConstants.TICKET_CATEGORY_ABM);
|
| 943 |
|
940 |
|
| 944 |
|
941 |
|
| 945 |
List<Position> escalationBasedPositions = positionRepository.selectAll(partnerPositionIds).stream().filter(x -> allowedTicketCategoryIds.contains(x.getCategoryId()) &&
|
942 |
List<Position> escalationBasedPositions = positionRepository.selectAll(partnerPositionIds).stream().filter(x -> allowedTicketCategoryIds.contains(x.getCategoryId()) &&
|
| 946 |
Arrays.stream(escalationTypes)
|
943 |
Arrays.stream(escalationTypes)
|
| 947 |
.anyMatch(y -> y.equals(x.getEscalationType()))).collect(Collectors.toList());
|
944 |
.anyMatch(y -> y.equals(x.getEscalationType()))).collect(Collectors.toList());
|
| Line 1105... |
Line 1102... |
| 1105 |
return partnerIdSalesHeadersMap;
|
1102 |
return partnerIdSalesHeadersMap;
|
| 1106 |
|
1103 |
|
| 1107 |
}
|
1104 |
}
|
| 1108 |
|
1105 |
|
| 1109 |
|
1106 |
|
| - |
|
1107 |
private class ABMRoles {
|
| - |
|
1108 |
|
| - |
|
1109 |
private List<String> l1;
|
| - |
|
1110 |
private List<String> l2;
|
| - |
|
1111 |
private List<String> l3;
|
| - |
|
1112 |
private List<String> l4;
|
| - |
|
1113 |
|
| - |
|
1114 |
public ABMRoles() {
|
| - |
|
1115 |
l1 = new ArrayList<>();
|
| - |
|
1116 |
l2 = new ArrayList<>();
|
| - |
|
1117 |
l3 = new ArrayList<>();
|
| - |
|
1118 |
l4 = new ArrayList<>();
|
| - |
|
1119 |
}
|
| - |
|
1120 |
|
| - |
|
1121 |
public List<String> getL1() {
|
| - |
|
1122 |
return l1;
|
| - |
|
1123 |
}
|
| - |
|
1124 |
|
| - |
|
1125 |
public List<String> getL2() {
|
| - |
|
1126 |
return l2;
|
| - |
|
1127 |
}
|
| - |
|
1128 |
|
| - |
|
1129 |
public List<String> getL3() {
|
| - |
|
1130 |
return l3;
|
| - |
|
1131 |
}
|
| - |
|
1132 |
|
| - |
|
1133 |
public List<String> getL4() {
|
| - |
|
1134 |
return l4;
|
| - |
|
1135 |
}
|
| - |
|
1136 |
|
| - |
|
1137 |
@Override
|
| - |
|
1138 |
public String toString() {
|
| - |
|
1139 |
return "SaleRoles [l1=" + l1 + ", l2=" + l2 + ", l3=" + l3 + ", l4=" + l4 + "]";
|
| - |
|
1140 |
}
|
| - |
|
1141 |
|
| - |
|
1142 |
}
|
| - |
|
1143 |
|
| - |
|
1144 |
|
| - |
|
1145 |
@Override
|
| - |
|
1146 |
@Cacheable(value = "partnerABMHeader", cacheManager = "oneDayCacheManager")
|
| - |
|
1147 |
public Map<Integer, FofoAbmReportingModel> getPartnerIdABMHeaders() throws ProfitMandiBusinessException {
|
| - |
|
1148 |
Map<String, ABMRoles> partnerEmailABMMap = new HashMap<>();
|
| - |
|
1149 |
|
| - |
|
1150 |
List<Position> positions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_ABM);
|
| - |
|
1151 |
Map<Integer, AuthUser> authUsersMap = authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
1152 |
Map<Integer, List<CustomRetailer>> positionIdRetailerMap = this.getPositionCustomRetailerMap(positions);
|
| - |
|
1153 |
for (Position position : positions) {
|
| - |
|
1154 |
List<CustomRetailer> crList = positionIdRetailerMap.get(position.getId());
|
| - |
|
1155 |
if (crList == null)
|
| - |
|
1156 |
continue;
|
| - |
|
1157 |
for (CustomRetailer cr : crList) {
|
| - |
|
1158 |
if (!partnerEmailABMMap.containsKey(cr.getEmail())) {
|
| - |
|
1159 |
partnerEmailABMMap.put(cr.getEmail(), new ABMRoles());
|
| - |
|
1160 |
}
|
| - |
|
1161 |
ABMRoles abmRoles = partnerEmailABMMap.get(cr.getEmail());
|
| - |
|
1162 |
AuthUser authUser = authUsersMap.get(position.getAuthUserId());
|
| - |
|
1163 |
if (authUser == null) {
|
| - |
|
1164 |
continue;
|
| - |
|
1165 |
}
|
| - |
|
1166 |
String name = authUser.getFirstName() + " " + authUser.getLastName();
|
| - |
|
1167 |
if (position.getEscalationType().equals(EscalationType.L1)) {
|
| - |
|
1168 |
abmRoles.getL1().add(name);
|
| - |
|
1169 |
} else if (position.getEscalationType().equals(EscalationType.L2)) {
|
| - |
|
1170 |
abmRoles.getL2().add(name);
|
| - |
|
1171 |
}
|
| - |
|
1172 |
|
| - |
|
1173 |
}
|
| - |
|
1174 |
}
|
| - |
|
1175 |
|
| - |
|
1176 |
Set<CustomRetailer> allCrList = new HashSet<>();
|
| - |
|
1177 |
for (List<CustomRetailer> cr : positionIdRetailerMap.values()) {
|
| - |
|
1178 |
allCrList.addAll(cr);
|
| - |
|
1179 |
}
|
| - |
|
1180 |
|
| - |
|
1181 |
Map<Integer, FofoStore> fofoStoresMap = fofoStoreRepository.selectActiveStores().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
1182 |
|
| - |
|
1183 |
Map<Integer, FofoAbmReportingModel> partnerIdAbmHeadersMap = new HashMap<>();
|
| - |
|
1184 |
|
| - |
|
1185 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| - |
|
1186 |
for (Map.Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
|
| - |
|
1187 |
|
| - |
|
1188 |
CustomRetailer customRetailer = customRetailerEntry.getValue();
|
| - |
|
1189 |
|
| - |
|
1190 |
String code = customRetailer.getCode();
|
| - |
|
1191 |
// String storeName = "SmartDukaan-" +
|
| - |
|
1192 |
// fofoStore.getCode().replaceAll("[a-zA-Z]", "");
|
| - |
|
1193 |
String businessName = customRetailer.getBusinessName();
|
| - |
|
1194 |
try {
|
| - |
|
1195 |
String l2Manager = StringUtils.join(new HashSet(partnerEmailABMMap.get(customRetailer.getEmail()).getL2()), ", ");
|
| - |
|
1196 |
String l1Manager = StringUtils.join(new HashSet(partnerEmailABMMap.get(customRetailer.getEmail()).getL1()), ", ");
|
| - |
|
1197 |
|
| - |
|
1198 |
if (StringUtils.isEmpty(l1Manager)) {
|
| - |
|
1199 |
l2Manager = StringUtils.join(new HashSet(partnerEmailABMMap.get(customRetailer.getEmail()).getL2()), ", ");
|
| - |
|
1200 |
}
|
| - |
|
1201 |
|
| - |
|
1202 |
FofoAbmReportingModel reportingModel = new FofoAbmReportingModel();
|
| - |
|
1203 |
reportingModel.setBusinessName(businessName);
|
| - |
|
1204 |
reportingModel.setCode(code);
|
| - |
|
1205 |
reportingModel.setFofoId(customRetailer.getPartnerId());
|
| - |
|
1206 |
reportingModel.setL1Manager(l2Manager);
|
| - |
|
1207 |
reportingModel.setL2Manager(l1Manager);
|
| - |
|
1208 |
partnerIdAbmHeadersMap.put(customRetailer.getPartnerId(), reportingModel);
|
| - |
|
1209 |
} catch (Exception e) {
|
| - |
|
1210 |
LOGGER.warn("Could not find partner with email - {}", customRetailer.getEmail());
|
| - |
|
1211 |
}
|
| - |
|
1212 |
}
|
| - |
|
1213 |
return partnerIdAbmHeadersMap;
|
| - |
|
1214 |
|
| - |
|
1215 |
}
|
| - |
|
1216 |
|
| - |
|
1217 |
|
| 1110 |
private class RBMRoles {
|
1218 |
private class RBMRoles {
|
| 1111 |
|
1219 |
|
| 1112 |
private List<String> l1;
|
1220 |
private List<String> l1;
|
| 1113 |
private List<String> l2;
|
1221 |
private List<String> l2;
|
| 1114 |
private List<String> l3;
|
1222 |
private List<String> l3;
|