| 24383 |
amit.gupta |
1 |
package com.spice.profitmandi.dao.repository.cs;
|
| 24500 |
govind |
2 |
|
| 24383 |
amit.gupta |
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 24417 |
govind |
4 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 24439 |
govind |
5 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
|
|
6 |
import com.spice.profitmandi.common.util.Utils;
|
| 24417 |
govind |
7 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 31829 |
amit.gupta |
8 |
import com.spice.profitmandi.dao.entity.cs.*;
|
| 24383 |
amit.gupta |
9 |
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
|
| 30003 |
tejbeer |
10 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 24417 |
govind |
11 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 30003 |
tejbeer |
12 |
import com.spice.profitmandi.dao.model.FofoReportingModel;
|
| 24417 |
govind |
13 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 25570 |
tejbeer |
14 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 24417 |
govind |
15 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 31829 |
amit.gupta |
16 |
import org.apache.commons.collections4.map.HashedMap;
|
|
|
17 |
import org.apache.commons.lang.RandomStringUtils;
|
|
|
18 |
import org.apache.commons.lang.StringUtils;
|
|
|
19 |
import org.apache.logging.log4j.LogManager;
|
|
|
20 |
import org.apache.logging.log4j.Logger;
|
|
|
21 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
22 |
import org.springframework.cache.annotation.Cacheable;
|
|
|
23 |
import org.springframework.mail.javamail.JavaMailSender;
|
|
|
24 |
import org.springframework.stereotype.Component;
|
| 24383 |
amit.gupta |
25 |
|
| 31829 |
amit.gupta |
26 |
import java.time.LocalDateTime;
|
|
|
27 |
import java.util.*;
|
|
|
28 |
import java.util.stream.Collectors;
|
|
|
29 |
|
| 24383 |
amit.gupta |
30 |
@Component
|
|
|
31 |
public class CsServiceImpl implements CsService {
|
| 24417 |
govind |
32 |
|
| 31762 |
tejbeer |
33 |
private static final int ALL_PARTNERS_REGION = 5;
|
| 27124 |
amit.gupta |
34 |
|
| 31762 |
tejbeer |
35 |
private static final Logger LOGGER = LogManager.getLogger(CsServiceImpl.class);
|
| 24439 |
govind |
36 |
|
| 31762 |
tejbeer |
37 |
private static final String ASSIGNED_TICKET = "Dear %s, New ticket #%s #%s created by %s has been assigned to you. Regards\nSmartdukaan";
|
|
|
38 |
private static final String ESCALATED_TICKET = "Dear %s, Ticket #%s #%s created by %s has been escalated to you. Regards\nSmartdukaan";
|
|
|
39 |
private static final String CATEGORY_CHANGED_TICKET = "Dear team, Category of Ticket #%s created by %s has been changed to %s. Regards\nSmartdukaan";
|
|
|
40 |
private static final String ASSINMENT_SUBJECT = "Assignment Ticket";
|
| 24439 |
govind |
41 |
|
| 31762 |
tejbeer |
42 |
@Autowired
|
|
|
43 |
TicketRepository ticketRepository;
|
| 24417 |
govind |
44 |
|
| 31762 |
tejbeer |
45 |
@Autowired
|
|
|
46 |
JavaMailSender mailSender;
|
| 24439 |
govind |
47 |
|
| 31762 |
tejbeer |
48 |
@Autowired
|
|
|
49 |
TicketCategoryRepository ticketCategoryRepository;
|
| 24417 |
govind |
50 |
|
| 31762 |
tejbeer |
51 |
@Autowired
|
|
|
52 |
TicketSubCategoryRepository ticketSubCategoryRepository;
|
| 24417 |
govind |
53 |
|
| 31762 |
tejbeer |
54 |
@Autowired
|
|
|
55 |
ActivityRepository activityRepository;
|
| 24417 |
govind |
56 |
|
| 31762 |
tejbeer |
57 |
@Autowired
|
|
|
58 |
PartnerRegionRepository partnerRegionRepository;
|
| 24417 |
govind |
59 |
|
| 31762 |
tejbeer |
60 |
@Autowired
|
|
|
61 |
private PositionRepository positionRepository;
|
| 24417 |
govind |
62 |
|
| 31762 |
tejbeer |
63 |
@Autowired
|
|
|
64 |
private AuthRepository authRepository;
|
| 24417 |
govind |
65 |
|
| 31762 |
tejbeer |
66 |
@Autowired
|
|
|
67 |
private RetailerService retailerService;
|
| 24500 |
govind |
68 |
|
| 31762 |
tejbeer |
69 |
@Autowired
|
|
|
70 |
private RegionRepository regionRepository;
|
| 24417 |
govind |
71 |
|
| 31762 |
tejbeer |
72 |
@Autowired
|
|
|
73 |
private TicketAssignedRepository ticketAssignedRepository;
|
| 24500 |
govind |
74 |
|
| 31762 |
tejbeer |
75 |
@Autowired
|
|
|
76 |
private PartnersPositionRepository partnersPositionRepository;
|
| 25570 |
tejbeer |
77 |
|
| 31762 |
tejbeer |
78 |
@Autowired
|
|
|
79 |
private FofoStoreRepository fofoStoreRepository;
|
| 25570 |
tejbeer |
80 |
|
| 31762 |
tejbeer |
81 |
@Override
|
|
|
82 |
public void createTicket(int fofoId, int categoryId, int subcategoryId, String message) throws ProfitMandiBusinessException {
|
| 24417 |
govind |
83 |
|
| 31762 |
tejbeer |
84 |
ActivityType type = ActivityType.OPENED;
|
|
|
85 |
Ticket ticket = new Ticket();
|
|
|
86 |
ticket.setSubCategoryId(subcategoryId);
|
|
|
87 |
ticket.setFofoId(fofoId);
|
|
|
88 |
ticket.setCreateTimestamp(LocalDateTime.now());
|
|
|
89 |
ticket.setUpdateTimestamp(LocalDateTime.now());
|
|
|
90 |
ticket.setHappyCode(getRandomString());
|
|
|
91 |
ticketRepository.persist(ticket);
|
|
|
92 |
this.addActivity(ticket, this.createActivity(type, message, 0));
|
|
|
93 |
this.assignTicket(ticket);
|
| 27124 |
amit.gupta |
94 |
|
| 31762 |
tejbeer |
95 |
}
|
| 27124 |
amit.gupta |
96 |
|
| 31762 |
tejbeer |
97 |
@Override
|
|
|
98 |
public void assignTicket(Ticket ticket) throws ProfitMandiBusinessException {
|
|
|
99 |
TicketAssigned ticketAssigned = null;
|
|
|
100 |
EscalationType newEscalationType = EscalationType.L1;
|
|
|
101 |
if (ticket.getAssignmentId() > 0) {
|
|
|
102 |
ticketAssigned = ticketAssignedRepository.selectById(ticket.getAssignmentId());
|
|
|
103 |
newEscalationType = ticketAssigned.getEscalationType().next();
|
|
|
104 |
if (newEscalationType == null || newEscalationType.equals(EscalationType.Final)) {
|
|
|
105 |
LOGGER.info("Cant escalate further");
|
|
|
106 |
return;
|
|
|
107 |
}
|
|
|
108 |
} else {
|
|
|
109 |
ticket.setL1AuthUser(0);
|
|
|
110 |
ticket.setL2AuthUser(0);
|
|
|
111 |
ticket.setL3AuthUser(0);
|
|
|
112 |
ticket.setL4AuthUser(0);
|
|
|
113 |
ticket.setL5AuthUser(0);
|
|
|
114 |
}
|
|
|
115 |
ticket.setUpdateTimestamp(LocalDateTime.now());
|
| 27124 |
amit.gupta |
116 |
|
|
|
117 |
|
| 31762 |
tejbeer |
118 |
TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.selectById(ticket.getSubCategoryId());
|
|
|
119 |
TicketCategory ticketCategory = ticketCategoryRepository.selectById(ticketSubCategory.getCategoryId());
|
|
|
120 |
Map<Integer, EscalationType> escalationUserMap = new HashedMap<>();
|
|
|
121 |
Set<Integer> assigneeUserIds = new LinkedHashSet<>();
|
|
|
122 |
EscalationType escalationTypeNext = newEscalationType;
|
|
|
123 |
do {
|
|
|
124 |
int assigneeUserId = this.getAuthUserId(ticketCategory.getId(), escalationTypeNext, ticket.getFofoId());
|
|
|
125 |
if (assigneeUserId == 0) {
|
|
|
126 |
escalationTypeNext = escalationTypeNext.next();
|
|
|
127 |
LOGGER.info("Escalation type next {}", escalationTypeNext);
|
|
|
128 |
continue;
|
|
|
129 |
}
|
|
|
130 |
assigneeUserIds.add(assigneeUserId);
|
|
|
131 |
escalationUserMap.put(assigneeUserId, escalationTypeNext);
|
|
|
132 |
switch (escalationTypeNext) {
|
|
|
133 |
case L1:
|
|
|
134 |
ticket.setL1AuthUser(assigneeUserId);
|
|
|
135 |
break;
|
|
|
136 |
case L2:
|
|
|
137 |
ticket.setL2AuthUser(assigneeUserId);
|
|
|
138 |
break;
|
|
|
139 |
case L3:
|
|
|
140 |
ticket.setL3AuthUser(assigneeUserId);
|
|
|
141 |
break;
|
|
|
142 |
case L4:
|
|
|
143 |
ticket.setL4AuthUser(assigneeUserId);
|
|
|
144 |
break;
|
|
|
145 |
case L5:
|
|
|
146 |
ticket.setL5AuthUser(assigneeUserId);
|
|
|
147 |
break;
|
| 27545 |
tejbeer |
148 |
|
| 31762 |
tejbeer |
149 |
default:
|
|
|
150 |
break;
|
|
|
151 |
}
|
|
|
152 |
escalationTypeNext = escalationTypeNext.next();
|
|
|
153 |
// LOGGER.info("Escalation type next {}", escalationTypeNext);
|
|
|
154 |
} while (!escalationTypeNext.equals(EscalationType.Final));
|
| 27124 |
amit.gupta |
155 |
|
| 31762 |
tejbeer |
156 |
int assigneeAuthId = assigneeUserIds.stream().findFirst().orElse(0);
|
| 27545 |
tejbeer |
157 |
|
| 31762 |
tejbeer |
158 |
int managerAuthId = 0;
|
|
|
159 |
EscalationType assigneeEscalationType = null;
|
|
|
160 |
if (assigneeAuthId == 0) {
|
|
|
161 |
assigneeAuthId = ProfitMandiConstants.FINAL_AUTH_ID;
|
|
|
162 |
assigneeEscalationType = EscalationType.Final;
|
|
|
163 |
managerAuthId = ProfitMandiConstants.FINAL_AUTH_ID;
|
|
|
164 |
} else {
|
|
|
165 |
assigneeEscalationType = escalationUserMap.get(assigneeAuthId);
|
|
|
166 |
managerAuthId = assigneeUserIds.stream().skip(1).findFirst().orElse(0);
|
|
|
167 |
if (managerAuthId == 0) {
|
|
|
168 |
managerAuthId = ProfitMandiConstants.FINAL_AUTH_ID;
|
|
|
169 |
}
|
|
|
170 |
}
|
| 27545 |
tejbeer |
171 |
|
| 31762 |
tejbeer |
172 |
TicketAssigned ticketAssignedNew = new TicketAssigned();
|
|
|
173 |
ticketAssignedNew.setTicketId(ticket.getId());
|
|
|
174 |
ticketAssignedNew.setAssineeId(assigneeAuthId);
|
|
|
175 |
ticketAssignedNew.setEscalationType(assigneeEscalationType);
|
|
|
176 |
ticketAssignedNew.setManagerId(managerAuthId);
|
|
|
177 |
ticketAssignedNew.setCreateTimestamp(LocalDateTime.now());
|
|
|
178 |
ticketAssignedRepository.persist(ticketAssignedNew);
|
|
|
179 |
LOGGER.info(ticketAssigned);
|
| 24383 |
amit.gupta |
180 |
|
| 31762 |
tejbeer |
181 |
AuthUser authUser = authRepository.selectById(ticketAssignedNew.getAssineeId());
|
|
|
182 |
AuthUser authUserManager = null;
|
| 27124 |
amit.gupta |
183 |
|
| 31762 |
tejbeer |
184 |
// Dont send cc mail if both are same
|
|
|
185 |
if (managerAuthId != assigneeAuthId) {
|
|
|
186 |
authUserManager = authRepository.selectById(managerAuthId);
|
|
|
187 |
}
|
|
|
188 |
ticket.setAssignmentId(ticketAssignedNew.getId());
|
| 27124 |
amit.gupta |
189 |
|
| 31762 |
tejbeer |
190 |
List<Activity> activities = activityRepository.selectAll(ticket.getId());
|
|
|
191 |
this.sendAssignedTicketMail(authUser, Arrays.asList(authUserManager), ticket, ticketAssigned != null, activities);
|
|
|
192 |
if (!ticketAssignedNew.getEscalationType().equals(EscalationType.L1)) {
|
|
|
193 |
this.addActivity(ticket, this.createActivity(ActivityType.ESCALATED, "Ticket ecalated and assigned to " + authUser.getName(), 0));
|
|
|
194 |
} else {
|
|
|
195 |
this.addActivity(ticket, this.createActivity(ActivityType.ASSIGNED, "Ticket assigned to " + authUser.getName(), 0));
|
|
|
196 |
}
|
|
|
197 |
}
|
| 27124 |
amit.gupta |
198 |
|
| 31762 |
tejbeer |
199 |
@Override
|
|
|
200 |
public void updateTicket(int categoryId, int subCategoryId, Ticket ticket, int authUserId, EscalationType escalationType) throws ProfitMandiBusinessException {
|
| 27545 |
tejbeer |
201 |
|
| 31762 |
tejbeer |
202 |
TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.getTicketSubCategoryMap().get(subCategoryId);
|
|
|
203 |
if (ticketSubCategory == null) {
|
|
|
204 |
throw new ProfitMandiBusinessException("Could not find subCategoryId " + subCategoryId + "- " + categoryId, "Problem", "Problem");
|
|
|
205 |
}
|
|
|
206 |
String storeName = retailerService.getAllFofoRetailers().get(ticket.getFofoId()).getBusinessName();
|
|
|
207 |
List<TicketAssigned> oldTicketAssignedList = ticketAssignedRepository.selectByTicketIds(Arrays.asList(ticket.getId()));
|
|
|
208 |
for (TicketAssigned oldTicketAssigned : oldTicketAssignedList) {
|
|
|
209 |
ticketAssignedRepository.delete(oldTicketAssigned);
|
|
|
210 |
}
|
| 27124 |
amit.gupta |
211 |
|
| 31762 |
tejbeer |
212 |
if (ticket.getSubCategoryId() != ticketSubCategory.getId()) {
|
|
|
213 |
ticket.setSubCategoryId(ticketSubCategory.getId());
|
|
|
214 |
List<Integer> oldAssignedAuthUserIds = oldTicketAssignedList.stream().map(x -> x.getAssineeId()).collect(Collectors.toList());
|
|
|
215 |
List<String> oldAssignedEmailIds = authRepository.selectAllAuthUserByIds(oldAssignedAuthUserIds).stream().map(x -> x.getEmailId()).collect(Collectors.toList());
|
|
|
216 |
String mailTo = oldAssignedEmailIds.remove(0);
|
|
|
217 |
String message = String.format(CATEGORY_CHANGED_TICKET, ticket.getId(), storeName, ticketSubCategory.getTicketCategory().getName() + " - " + ticketSubCategory.getName());
|
|
|
218 |
try {
|
|
|
219 |
Utils.sendMailWithAttachments(mailSender, mailTo, oldAssignedEmailIds.toArray(new String[0]), "Ticket Category/Subcategory Changed", message, null);
|
|
|
220 |
} catch (Exception e) {
|
|
|
221 |
LOGGER.info("Could not send mail for ticket {}", ticket.toString());
|
|
|
222 |
}
|
| 24417 |
govind |
223 |
|
| 31762 |
tejbeer |
224 |
Activity categoryChangedActivity = this.createActivity(ActivityType.CATEGORY_CHANGED, "Category changed to " + ticketSubCategory.getTicketCategory().getName() + " - " + ticketSubCategory.getName(), 0);
|
|
|
225 |
this.addActivity(ticket, categoryChangedActivity);
|
| 24439 |
govind |
226 |
|
| 24383 |
amit.gupta |
227 |
|
| 31762 |
tejbeer |
228 |
}
|
| 24383 |
amit.gupta |
229 |
|
| 31762 |
tejbeer |
230 |
if (authUserId > 0) {
|
| 24439 |
govind |
231 |
|
| 31762 |
tejbeer |
232 |
this.assignTicketByAuthId(ticket, authUserId, escalationType);
|
| 24417 |
govind |
233 |
|
| 31762 |
tejbeer |
234 |
} else {
|
|
|
235 |
ticket.setAssignmentId(0);
|
|
|
236 |
this.assignTicket(ticket);
|
|
|
237 |
}
|
| 24417 |
govind |
238 |
|
| 31762 |
tejbeer |
239 |
}
|
| 24500 |
govind |
240 |
|
| 31762 |
tejbeer |
241 |
private void assignTicketByAuthId(Ticket ticket, int authUserId, EscalationType escalationType) throws ProfitMandiBusinessException {
|
| 24500 |
govind |
242 |
|
| 31762 |
tejbeer |
243 |
AuthUser authUser = authRepository.selectById(authUserId);
|
| 24500 |
govind |
244 |
|
| 31762 |
tejbeer |
245 |
LOGGER.info("authUser {}", authUser);
|
| 24417 |
govind |
246 |
|
| 31762 |
tejbeer |
247 |
int managerAuthId = authUser.getManagerId();
|
| 24417 |
govind |
248 |
|
| 31762 |
tejbeer |
249 |
if (escalationType.equals(EscalationType.L1)) {
|
|
|
250 |
ticket.setL1AuthUser(authUserId);
|
|
|
251 |
ticket.setL2AuthUser(0);
|
|
|
252 |
ticket.setL3AuthUser(0);
|
|
|
253 |
ticket.setL4AuthUser(0);
|
|
|
254 |
ticket.setL5AuthUser(0);
|
|
|
255 |
} else if (escalationType.equals(EscalationType.L2)) {
|
|
|
256 |
ticket.setL2AuthUser(authUserId);
|
|
|
257 |
ticket.setL3AuthUser(0);
|
|
|
258 |
ticket.setL4AuthUser(0);
|
|
|
259 |
ticket.setL5AuthUser(0);
|
|
|
260 |
}
|
|
|
261 |
if (escalationType.equals(EscalationType.L3)) {
|
|
|
262 |
ticket.setL3AuthUser(authUserId);
|
|
|
263 |
ticket.setL4AuthUser(0);
|
|
|
264 |
ticket.setL5AuthUser(0);
|
|
|
265 |
}
|
|
|
266 |
if (escalationType.equals(EscalationType.L4)) {
|
| 30426 |
tejbeer |
267 |
|
| 31762 |
tejbeer |
268 |
ticket.setL4AuthUser(authUserId);
|
|
|
269 |
ticket.setL5AuthUser(0);
|
|
|
270 |
}
|
|
|
271 |
if (escalationType.equals(EscalationType.L5)) {
|
|
|
272 |
ticket.setL5AuthUser(authUserId);
|
|
|
273 |
}
|
| 30426 |
tejbeer |
274 |
|
| 24417 |
govind |
275 |
|
| 31762 |
tejbeer |
276 |
TicketAssigned ticketAssignedNew = new TicketAssigned();
|
|
|
277 |
ticketAssignedNew.setTicketId(ticket.getId());
|
|
|
278 |
ticketAssignedNew.setAssineeId(authUserId);
|
|
|
279 |
ticketAssignedNew.setEscalationType(escalationType);
|
|
|
280 |
ticketAssignedNew.setManagerId(managerAuthId);
|
|
|
281 |
ticketAssignedNew.setCreateTimestamp(LocalDateTime.now());
|
|
|
282 |
ticketAssignedRepository.persist(ticketAssignedNew);
|
| 24439 |
govind |
283 |
|
| 31762 |
tejbeer |
284 |
LOGGER.info("ticketAssignedNew {}", ticketAssignedNew);
|
| 24439 |
govind |
285 |
|
| 24500 |
govind |
286 |
|
| 31762 |
tejbeer |
287 |
AuthUser authUserManager = null;
|
| 24439 |
govind |
288 |
|
| 24500 |
govind |
289 |
|
| 31762 |
tejbeer |
290 |
// Dont send cc mail if both are same
|
|
|
291 |
if (managerAuthId != authUserId) {
|
|
|
292 |
authUserManager = authRepository.selectById(managerAuthId);
|
|
|
293 |
}
|
|
|
294 |
ticket.setAssignmentId(ticketAssignedNew.getId());
|
| 27124 |
amit.gupta |
295 |
|
| 25570 |
tejbeer |
296 |
|
| 31762 |
tejbeer |
297 |
List<Activity> activities = activityRepository.selectAll(ticket.getId());
|
| 25570 |
tejbeer |
298 |
|
| 31762 |
tejbeer |
299 |
this.sendAssignedTicketMail(authUser, Arrays.asList(authUserManager), ticket, false, activities);
|
|
|
300 |
if (!ticketAssignedNew.getEscalationType().equals(EscalationType.L1)) {
|
|
|
301 |
this.addActivity(ticket, this.createActivity(ActivityType.ESCALATED, "Ticket ecalated and assigned to " + authUser.getName(), 0));
|
|
|
302 |
} else {
|
|
|
303 |
this.addActivity(ticket, this.createActivity(ActivityType.ASSIGNED, "Ticket assigned to " + authUser.getName(), 0));
|
|
|
304 |
}
|
| 25570 |
tejbeer |
305 |
|
| 31762 |
tejbeer |
306 |
}
|
| 25570 |
tejbeer |
307 |
|
| 31762 |
tejbeer |
308 |
@Override
|
|
|
309 |
public Activity createActivity(ActivityType activityType, String message, int createdBy) {
|
|
|
310 |
Activity activity = new Activity();
|
|
|
311 |
activity.setMessage(message);
|
|
|
312 |
activity.setCreatedBy(createdBy);
|
|
|
313 |
activity.setType(activityType);
|
|
|
314 |
activity.setCreateTimestamp(LocalDateTime.now());
|
|
|
315 |
activityRepository.persist(activity);
|
|
|
316 |
return activity;
|
|
|
317 |
}
|
| 25570 |
tejbeer |
318 |
|
| 31762 |
tejbeer |
319 |
@Override
|
|
|
320 |
public int getAuthUserId(int categoryId, EscalationType escalationType, int fofoId) {
|
|
|
321 |
int authUserId = 0;
|
|
|
322 |
List<Position> positions = positionRepository.selectPositionbyCategoryIdAndEscalationType(categoryId, escalationType);
|
|
|
323 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
|
|
|
324 |
// Add all Partner regions id
|
|
|
325 |
regionIds.add(ALL_PARTNERS_REGION);
|
|
|
326 |
LOGGER.info("Escalation Type {}, Region Ids {}", escalationType, regionIds);
|
|
|
327 |
List<Integer> partnerPositionsIds = partnersPositionRepository.selectByRegionIdAndPartnerId(regionIds, Arrays.asList(0, fofoId)).stream().map(x -> x.getPositionId()).collect(Collectors.toList());
|
| 31829 |
amit.gupta |
328 |
List<Position> positionAssignee = positions.stream().filter(x -> x.isTicketAssignee() && partnerPositionsIds.contains(x.getId())).collect(Collectors.toList());
|
| 31762 |
tejbeer |
329 |
LOGGER.info("User List List {}", positions.stream().map(x -> x.getAuthUserId()).collect(Collectors.toList()));
|
| 31829 |
amit.gupta |
330 |
if (positionAssignee.size() > 0) {
|
| 31762 |
tejbeer |
331 |
List<AuthUser> authUsers = authRepository.selectAllAuthUserByIds(
|
|
|
332 |
positions.stream().map(x -> x.getAuthUserId()).collect(Collectors.toList()));
|
|
|
333 |
authUsers = authUsers.stream().filter(x -> x.isActive()).collect(Collectors.toList());
|
|
|
334 |
if (authUsers.size() > 0) {
|
|
|
335 |
authUserId = authUsers.get(0).getId();
|
|
|
336 |
/*
|
|
|
337 |
* Random rand = new Random(); authUserId =
|
|
|
338 |
* authUsers.get(rand.nextInt(authUsers.size())).getId();
|
|
|
339 |
*/
|
|
|
340 |
}
|
|
|
341 |
}
|
|
|
342 |
return authUserId;
|
| 25570 |
tejbeer |
343 |
|
| 31762 |
tejbeer |
344 |
}
|
| 25597 |
amit.gupta |
345 |
|
| 31762 |
tejbeer |
346 |
@Override
|
|
|
347 |
public void addActivity(Ticket ticket, Activity activity) {
|
|
|
348 |
activity.setTicketId(ticket.getId());
|
|
|
349 |
ticket.setLastActivity(activity.getType());
|
|
|
350 |
ticket.setLastActivityId(activity.getId());
|
|
|
351 |
}
|
| 25597 |
amit.gupta |
352 |
|
| 31762 |
tejbeer |
353 |
private String getRandomString() {
|
|
|
354 |
int length = 4;
|
|
|
355 |
boolean useLetters = false;
|
|
|
356 |
boolean useNumbers = true;
|
|
|
357 |
String generatedString = RandomStringUtils.random(length, useLetters, useNumbers);
|
|
|
358 |
return generatedString;
|
|
|
359 |
}
|
| 25721 |
tejbeer |
360 |
|
| 31762 |
tejbeer |
361 |
@Override
|
|
|
362 |
public void addPartnerToRegion(int regionId, List<Integer> fofoIds) {
|
| 25721 |
tejbeer |
363 |
|
| 31762 |
tejbeer |
364 |
for (int fofoId : fofoIds) {
|
|
|
365 |
PartnerRegion partnerRegion = new PartnerRegion();
|
|
|
366 |
partnerRegion.setFofoId(fofoId);
|
|
|
367 |
partnerRegion.setRegionId(regionId);
|
|
|
368 |
partnerRegionRepository.persist(partnerRegion);
|
|
|
369 |
}
|
|
|
370 |
}
|
| 25721 |
tejbeer |
371 |
|
| 31762 |
tejbeer |
372 |
@Override
|
|
|
373 |
public Map<Integer, AuthUser> getAuthUserIdAndAuthUserMap(List<TicketAssigned> ticketAssigneds) {
|
|
|
374 |
Map<Integer, AuthUser> authUserIdAndAuthUserMap = new HashMap<>();
|
| 31152 |
tejbeer |
375 |
|
| 31762 |
tejbeer |
376 |
for (TicketAssigned ticketAssigned : ticketAssigneds) {
|
|
|
377 |
AuthUser authUser = authRepository.selectById(ticketAssigned.getAssineeId());
|
|
|
378 |
authUserIdAndAuthUserMap.put(ticketAssigned.getTicketId(), authUser);
|
|
|
379 |
}
|
|
|
380 |
return authUserIdAndAuthUserMap;
|
|
|
381 |
}
|
| 31465 |
tejbeer |
382 |
|
| 31762 |
tejbeer |
383 |
@Override
|
|
|
384 |
public Map<Integer, AuthUser> getTicketIdAndAuthUserMapUsingTickets(List<Ticket> tickets) {
|
|
|
385 |
Map<Integer, AuthUser> authUserIdAndAuthUserMap = new HashMap<>();
|
| 31465 |
tejbeer |
386 |
|
| 31762 |
tejbeer |
387 |
for (Ticket ticket : tickets) {
|
|
|
388 |
AuthUser authUser = authRepository.selectById(ticket.getL1AuthUser());
|
|
|
389 |
authUserIdAndAuthUserMap.put(ticket.getId(), authUser);
|
|
|
390 |
}
|
|
|
391 |
return authUserIdAndAuthUserMap;
|
|
|
392 |
}
|
| 31152 |
tejbeer |
393 |
|
| 31762 |
tejbeer |
394 |
@Override
|
|
|
395 |
public Map<Integer, TicketSubCategory> getSubCategoryIdAndSubCategoryMap(List<Integer> subCategoryIds) {
|
|
|
396 |
Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = new HashMap<>();
|
|
|
397 |
subCategoryIdAndSubCategoryMap = ticketSubCategoryRepository.selectByIds(subCategoryIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
|
|
398 |
return subCategoryIdAndSubCategoryMap;
|
|
|
399 |
}
|
| 31152 |
tejbeer |
400 |
|
| 31762 |
tejbeer |
401 |
@Override
|
|
|
402 |
public Map<Integer, CustomRetailer> getPartnerByFofoIds(List<Ticket> tickets) {
|
|
|
403 |
List<Integer> fofoIds = new ArrayList<>();
|
|
|
404 |
LOGGER.info(tickets);
|
|
|
405 |
if (tickets == null) {
|
|
|
406 |
return null;
|
|
|
407 |
}
|
|
|
408 |
for (Ticket ticket : tickets) {
|
|
|
409 |
fofoIds.add(ticket.getFofoId());
|
|
|
410 |
}
|
| 25721 |
tejbeer |
411 |
|
| 31762 |
tejbeer |
412 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| 25721 |
tejbeer |
413 |
|
| 31762 |
tejbeer |
414 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = fofoIds.stream().distinct().map(x -> customRetailerMap.get(x)).filter(x -> x != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
|
|
415 |
return fofoIdsAndCustomRetailer;
|
|
|
416 |
}
|
| 25799 |
tejbeer |
417 |
|
| 31762 |
tejbeer |
418 |
@Override
|
|
|
419 |
public List<TicketCategory> getAllTicketCategotyFromSubCategory() {
|
| 25721 |
tejbeer |
420 |
|
| 31762 |
tejbeer |
421 |
List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository.selectAll();
|
|
|
422 |
HashSet<Integer> categoryIds = new HashSet<>();
|
|
|
423 |
for (TicketSubCategory ticketSubcategory : ticketSubCategories) {
|
|
|
424 |
categoryIds.add(ticketSubcategory.getCategoryId());
|
|
|
425 |
}
|
|
|
426 |
List<TicketCategory> ticketcategories = ticketCategoryRepository.selectAll(new ArrayList<>(categoryIds));
|
|
|
427 |
return ticketcategories;
|
|
|
428 |
}
|
| 25799 |
tejbeer |
429 |
|
| 31762 |
tejbeer |
430 |
@Override
|
|
|
431 |
public Map<Integer, AuthUser> getAuthUserIdAndAuthUserMapUsingPositions(List<Position> positions) {
|
|
|
432 |
Map<Integer, AuthUser> authUserIdAndAuthUserMap = new HashMap<>();
|
|
|
433 |
for (Position position : positions) {
|
|
|
434 |
AuthUser authUser = authRepository.selectById(position.getAuthUserId());
|
|
|
435 |
authUserIdAndAuthUserMap.put(position.getAuthUserId(), authUser);
|
|
|
436 |
}
|
|
|
437 |
return authUserIdAndAuthUserMap;
|
|
|
438 |
}
|
| 25721 |
tejbeer |
439 |
|
| 31762 |
tejbeer |
440 |
@Override
|
|
|
441 |
public Map<Integer, TicketCategory> getCategoryIdAndCategoryUsingPositions(List<Position> positions) {
|
|
|
442 |
Map<Integer, TicketCategory> categoryIdAndCategoryMap = new HashMap<>();
|
|
|
443 |
for (Position position : positions) {
|
|
|
444 |
TicketCategory ticketCategory = ticketCategoryRepository.selectById(position.getCategoryId());
|
|
|
445 |
categoryIdAndCategoryMap.put(position.getCategoryId(), ticketCategory);
|
|
|
446 |
}
|
|
|
447 |
return categoryIdAndCategoryMap;
|
|
|
448 |
}
|
| 29318 |
tejbeer |
449 |
|
| 31762 |
tejbeer |
450 |
@Override
|
|
|
451 |
public Map<Integer, Region> getRegionIdAndRegionMap(List<Position> positions) {
|
|
|
452 |
Map<Integer, Region> regionIdAndRegionMap = new HashMap<>();
|
|
|
453 |
for (Position position : positions) {
|
|
|
454 |
Region region = regionRepository.selectById(position.getRegionId());
|
|
|
455 |
regionIdAndRegionMap.put(position.getRegionId(), region);
|
|
|
456 |
}
|
|
|
457 |
return regionIdAndRegionMap;
|
|
|
458 |
}
|
| 29318 |
tejbeer |
459 |
|
| 31762 |
tejbeer |
460 |
private void sendAssignedTicketMail(AuthUser authUserTo, List<AuthUser> authUsersCc, Ticket ticket, boolean isEscalated, List<Activity> activities) throws ProfitMandiBusinessException {
|
|
|
461 |
try {
|
|
|
462 |
String[] ccTo = authUsersCc.stream().filter(x -> x != null).map(x -> x.getEmailId()).toArray(String[]::new);
|
| 25721 |
tejbeer |
463 |
|
| 31762 |
tejbeer |
464 |
String messageFormat = null;
|
|
|
465 |
if (isEscalated) {
|
|
|
466 |
messageFormat = ESCALATED_TICKET;
|
|
|
467 |
} else {
|
|
|
468 |
messageFormat = ASSIGNED_TICKET;
|
|
|
469 |
}
|
|
|
470 |
String message = String.format(messageFormat, authUserTo.getName(), ticket.getId(), activities.get(0).getMessage(), retailerService.getFofoRetailer(ticket.getFofoId()).getBusinessName());
|
|
|
471 |
Utils.sendMailWithAttachments(mailSender, authUserTo.getEmailId(), ccTo, ASSINMENT_SUBJECT, message, null);
|
|
|
472 |
} catch (Exception e) {
|
|
|
473 |
e.printStackTrace();
|
|
|
474 |
throw new ProfitMandiBusinessException("Ticket Assingment", authUserTo.getEmailId(), "Could not send ticket assignment mail");
|
|
|
475 |
}
|
|
|
476 |
}
|
| 26298 |
tejbeer |
477 |
|
| 31762 |
tejbeer |
478 |
@Override
|
|
|
479 |
public Map<Integer, List<CustomRetailer>> getPositionCustomRetailerMap(List<Position> positions) {
|
|
|
480 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
|
|
481 |
Map<Integer, List<CustomRetailer>> positionRetailerMap = new HashMap<>();
|
|
|
482 |
for (Position position : positions) {
|
|
|
483 |
List<Integer> fofoIds = partnersPositionRepository.selectByPositionId(position.getId()).stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
| 26978 |
tejbeer |
484 |
|
| 31762 |
tejbeer |
485 |
LOGGER.info("fofoIds - {}", fofoIds);
|
|
|
486 |
if (!fofoIds.isEmpty()) {
|
|
|
487 |
if (fofoIds.contains(0)) {
|
|
|
488 |
fofoIds = partnerRegionRepository.selectByRegionId(position.getRegionId()).stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
|
|
489 |
if (fofoIds.contains(0)) {
|
|
|
490 |
fofoIds = new ArrayList<>(customRetailerMap.keySet());
|
|
|
491 |
}
|
| 26978 |
tejbeer |
492 |
|
| 31762 |
tejbeer |
493 |
}
|
|
|
494 |
LOGGER.info("fofoIds - {}", fofoIds);
|
|
|
495 |
positionRetailerMap.put(position.getId(), fofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null).collect(Collectors.toList()));
|
| 26978 |
tejbeer |
496 |
|
| 31762 |
tejbeer |
497 |
}
|
|
|
498 |
}
|
|
|
499 |
return positionRetailerMap;
|
|
|
500 |
}
|
| 26978 |
tejbeer |
501 |
|
| 31762 |
tejbeer |
502 |
@Override
|
|
|
503 |
public Map<Integer, List<CustomRetailer>> getRegionPartners(List<Position> positions) {
|
|
|
504 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
|
|
505 |
Map<Integer, List<CustomRetailer>> positionIdAndpartnerRegionMap = new HashedMap<>();
|
|
|
506 |
for (Position position : positions) {
|
|
|
507 |
List<Integer> fofoIds = partnerRegionRepository.selectByRegionId(position.getRegionId()).stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
| 26978 |
tejbeer |
508 |
|
| 31762 |
tejbeer |
509 |
if (!fofoIds.isEmpty()) {
|
|
|
510 |
if (fofoIds.contains(0)) {
|
|
|
511 |
fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId()).collect(Collectors.toList());
|
| 26978 |
tejbeer |
512 |
|
| 31762 |
tejbeer |
513 |
}
|
| 26978 |
tejbeer |
514 |
|
| 31762 |
tejbeer |
515 |
Map<Integer, CustomRetailer> fofoRetailers = fofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
|
|
516 |
positionIdAndpartnerRegionMap.put(position.getRegionId(), new ArrayList<CustomRetailer>(fofoRetailers.values()));
|
|
|
517 |
}
|
| 26978 |
tejbeer |
518 |
|
| 31762 |
tejbeer |
519 |
}
|
| 26978 |
tejbeer |
520 |
|
| 31762 |
tejbeer |
521 |
return positionIdAndpartnerRegionMap;
|
|
|
522 |
}
|
| 26978 |
tejbeer |
523 |
|
| 31762 |
tejbeer |
524 |
@Override
|
|
|
525 |
@Cacheable(value = "authUserEmailMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
|
|
|
526 |
public Map<String, Set<String>> getAuthUserPartnerEmailMapping() {
|
|
|
527 |
Map<String, Set<String>> storeGuyMap = new HashMap<>();
|
|
|
528 |
Set<Integer> activeFofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId()).collect(Collectors.toSet());
|
|
|
529 |
List<Position> categoryPositions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
|
|
530 |
categoryPositions.addAll(positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM));
|
|
|
531 |
Map<Integer, Position> positionsMap = categoryPositions.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 29229 |
tejbeer |
532 |
|
| 31762 |
tejbeer |
533 |
Map<Integer, List<CustomRetailer>> positonPartnerMap = this.getPositionCustomRetailerMap(categoryPositions);
|
|
|
534 |
for (Map.Entry<Integer, List<CustomRetailer>> positionPartnerEntry : positonPartnerMap.entrySet()) {
|
|
|
535 |
int authUserId = positionsMap.get(positionPartnerEntry.getKey()).getAuthUserId();
|
|
|
536 |
Set<String> partnerEmails = positionPartnerEntry.getValue().stream().filter(x -> activeFofoIds.contains(x.getPartnerId())).map(x -> x.getEmail()).collect(Collectors.toSet());
|
|
|
537 |
AuthUser authUser = authRepository.selectById(authUserId);
|
|
|
538 |
if (authUser.isActive()) {
|
|
|
539 |
if (!storeGuyMap.containsKey(authUser.getEmailId())) {
|
|
|
540 |
storeGuyMap.put(authUser.getEmailId(), partnerEmails);
|
|
|
541 |
} else {
|
|
|
542 |
storeGuyMap.get(authUser.getEmailId()).addAll(partnerEmails);
|
|
|
543 |
}
|
|
|
544 |
}
|
|
|
545 |
}
|
|
|
546 |
return storeGuyMap;
|
|
|
547 |
}
|
| 29229 |
tejbeer |
548 |
|
| 31762 |
tejbeer |
549 |
@Override
|
|
|
550 |
@Cacheable(value = "authUserEmailPartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
|
|
|
551 |
public Map<String, Set<Integer>> getAuthUserPartnerIdMapping() {
|
|
|
552 |
Map<String, Set<Integer>> storeGuyMap = new HashMap<>();
|
|
|
553 |
Set<Integer> activeFofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId()).collect(Collectors.toSet());
|
|
|
554 |
List<Position> categoryPositions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
|
|
555 |
categoryPositions.addAll(positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM));
|
|
|
556 |
categoryPositions.addAll(positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT));
|
|
|
557 |
Map<Integer, Position> positionsMap = categoryPositions.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 31161 |
tejbeer |
558 |
|
| 31762 |
tejbeer |
559 |
Map<Integer, List<CustomRetailer>> positonPartnerMap = this.getPositionCustomRetailerMap(categoryPositions);
|
|
|
560 |
for (Map.Entry<Integer, List<CustomRetailer>> positionPartnerEntry : positonPartnerMap.entrySet()) {
|
|
|
561 |
int authUserId = positionsMap.get(positionPartnerEntry.getKey()).getAuthUserId();
|
|
|
562 |
Set<Integer> partnerIds = positionPartnerEntry.getValue().stream().filter(x -> activeFofoIds.contains(x.getPartnerId())).map(x -> x.getPartnerId()).collect(Collectors.toSet());
|
|
|
563 |
AuthUser authUser = authRepository.selectById(authUserId);
|
|
|
564 |
if (authUser.isActive()) {
|
|
|
565 |
if (!storeGuyMap.containsKey(authUser.getEmailId())) {
|
|
|
566 |
storeGuyMap.put(authUser.getEmailId(), partnerIds);
|
|
|
567 |
} else {
|
|
|
568 |
storeGuyMap.get(authUser.getEmailId()).addAll(partnerIds);
|
|
|
569 |
}
|
|
|
570 |
}
|
|
|
571 |
}
|
|
|
572 |
return storeGuyMap;
|
|
|
573 |
}
|
| 31472 |
tejbeer |
574 |
|
| 31762 |
tejbeer |
575 |
@Override
|
|
|
576 |
@Cacheable(value = "authUserPartnerEmailPartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
|
|
|
577 |
public Map<String, Set<Integer>> getAuthUserPartnerIdMappingByCategoryIds(List<Integer> categoryIds, boolean activeOnly) {
|
|
|
578 |
Map<String, Set<Integer>> authUserPartnerMap = new HashMap<>();
|
|
|
579 |
Set<Integer> activeFofoIds;
|
|
|
580 |
if (activeOnly) {
|
|
|
581 |
activeFofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId()).collect(Collectors.toSet());
|
| 26298 |
tejbeer |
582 |
|
| 31762 |
tejbeer |
583 |
} else {
|
|
|
584 |
activeFofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId()).collect(Collectors.toSet());
|
| 26298 |
tejbeer |
585 |
|
| 31762 |
tejbeer |
586 |
}
|
| 26298 |
tejbeer |
587 |
|
| 31762 |
tejbeer |
588 |
List<Position> categoryPositions = positionRepository.selectPositionByCategoryIds(categoryIds);
|
|
|
589 |
Map<Integer, Position> positionsMap = categoryPositions.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 26298 |
tejbeer |
590 |
|
| 31762 |
tejbeer |
591 |
Map<Integer, List<CustomRetailer>> positonPartnerMap = this.getPositionCustomRetailerMap(categoryPositions);
|
|
|
592 |
for (Map.Entry<Integer, List<CustomRetailer>> positionPartnerEntry : positonPartnerMap.entrySet()) {
|
|
|
593 |
int authUserId = positionsMap.get(positionPartnerEntry.getKey()).getAuthUserId();
|
|
|
594 |
Set<Integer> partnerIds = positionPartnerEntry.getValue().stream().filter(x -> activeFofoIds.contains(x.getPartnerId())).map(x -> x.getPartnerId()).collect(Collectors.toSet());
|
|
|
595 |
AuthUser authUser = authRepository.selectById(authUserId);
|
|
|
596 |
if (authUser.isActive()) {
|
|
|
597 |
if (!authUserPartnerMap.containsKey(authUser.getEmailId())) {
|
|
|
598 |
authUserPartnerMap.put(authUser.getEmailId(), partnerIds);
|
|
|
599 |
} else {
|
|
|
600 |
authUserPartnerMap.get(authUser.getEmailId()).addAll(partnerIds);
|
|
|
601 |
}
|
|
|
602 |
}
|
|
|
603 |
}
|
|
|
604 |
return authUserPartnerMap;
|
|
|
605 |
}
|
| 26298 |
tejbeer |
606 |
|
| 31762 |
tejbeer |
607 |
@Override
|
|
|
608 |
public List<String> getAuthUserByPartnerId(int fofoId) {
|
| 26298 |
tejbeer |
609 |
|
| 31762 |
tejbeer |
610 |
List<String> emails = new ArrayList<>();
|
|
|
611 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
|
| 26298 |
tejbeer |
612 |
|
| 31762 |
tejbeer |
613 |
regionIds.add(5);// All partners Id;
|
| 26298 |
tejbeer |
614 |
|
| 31762 |
tejbeer |
615 |
List<Integer> partnerPositionIds = partnersPositionRepository.selectByRegionIdAndPartnerId(regionIds, Arrays.asList(fofoId, 0)).stream().map(x -> x.getPositionId()).collect(Collectors.toList());
|
| 26448 |
amit.gupta |
616 |
|
| 31762 |
tejbeer |
617 |
LOGGER.info("partnerPositionIds" + partnerPositionIds);
|
| 27205 |
amit.gupta |
618 |
|
| 31762 |
tejbeer |
619 |
List<Position> positions = positionRepository.selectAll(partnerPositionIds);
|
| 27548 |
tejbeer |
620 |
|
| 31762 |
tejbeer |
621 |
positions = positions.stream().filter(x -> (x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_SALES || x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_RBM)).collect(Collectors.toList());
|
| 27548 |
tejbeer |
622 |
|
| 31762 |
tejbeer |
623 |
if (!positions.isEmpty()) {
|
|
|
624 |
for (Position partnerPostionId : positions) {
|
| 27548 |
tejbeer |
625 |
|
| 31762 |
tejbeer |
626 |
AuthUser authUser = authRepository.selectById(partnerPostionId.getAuthUserId());
|
|
|
627 |
LOGGER.info("authUser" + authUser);
|
|
|
628 |
emails.add(authUser.getEmailId());
|
|
|
629 |
}
|
|
|
630 |
}
|
| 27548 |
tejbeer |
631 |
|
| 31762 |
tejbeer |
632 |
return emails;
|
|
|
633 |
}
|
| 27548 |
tejbeer |
634 |
|
| 31762 |
tejbeer |
635 |
@Override
|
|
|
636 |
public Map<EscalationType, String> getAuthUserAndEsclationTypeByPartnerId(int fofoId) {
|
| 27548 |
tejbeer |
637 |
|
| 31762 |
tejbeer |
638 |
List<String> emails = new ArrayList<>();
|
|
|
639 |
Map<EscalationType, String> emailEsclationTypeMap = new HashMap<>();
|
|
|
640 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
|
| 27548 |
tejbeer |
641 |
|
| 31762 |
tejbeer |
642 |
regionIds.add(5);// All partners Id;
|
|
|
643 |
List<Integer> fofoIds = new ArrayList<>();
|
|
|
644 |
fofoIds.add(fofoId);
|
|
|
645 |
fofoIds.add(0);
|
| 27548 |
tejbeer |
646 |
|
| 31762 |
tejbeer |
647 |
LOGGER.info("fofoIds" + fofoIds);
|
|
|
648 |
List<Integer> partnerPositionIds = partnersPositionRepository.selectByRegionIdAndPartnerId(regionIds, fofoIds).stream().map(x -> x.getPositionId()).collect(Collectors.toList());
|
| 27548 |
tejbeer |
649 |
|
| 31762 |
tejbeer |
650 |
LOGGER.info("partnerPositionIds" + partnerPositionIds);
|
| 28377 |
tejbeer |
651 |
|
| 31762 |
tejbeer |
652 |
for (Integer partnerPostionId : partnerPositionIds) {
|
|
|
653 |
Position position = positionRepository.selectByIdAndCategoryId(partnerPostionId, ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
|
|
654 |
LOGGER.info("position" + position);
|
|
|
655 |
if (position != null) {
|
| 28377 |
tejbeer |
656 |
|
| 31762 |
tejbeer |
657 |
AuthUser authUser = authRepository.selectById(position.getAuthUserId());
|
|
|
658 |
LOGGER.info("authUser" + authUser);
|
| 28377 |
tejbeer |
659 |
|
| 31762 |
tejbeer |
660 |
emailEsclationTypeMap.put(position.getEscalationType(), authUser.getEmailId());
|
|
|
661 |
}
|
|
|
662 |
}
|
| 28377 |
tejbeer |
663 |
|
| 31762 |
tejbeer |
664 |
LOGGER.info("emailEsclationTypeMap" + emailEsclationTypeMap);
|
| 28377 |
tejbeer |
665 |
|
| 31762 |
tejbeer |
666 |
return emailEsclationTypeMap;
|
|
|
667 |
}
|
| 31020 |
tejbeer |
668 |
|
| 31762 |
tejbeer |
669 |
@Override
|
|
|
670 |
@Cacheable(value = "authUserIdPartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
|
|
|
671 |
public Map<Integer, List<Integer>> getAuthUserIdPartnerIdMapping() {
|
|
|
672 |
Map<Integer, List<Integer>> storeGuyMap = new HashMap<>();
|
|
|
673 |
Set<Integer> activeFofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId()).collect(Collectors.toSet());
|
|
|
674 |
List<Position> categoryPositions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
|
|
675 |
categoryPositions.addAll(positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM));
|
| 31020 |
tejbeer |
676 |
|
| 31762 |
tejbeer |
677 |
categoryPositions.addAll(positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_CRM));
|
| 31020 |
tejbeer |
678 |
|
| 31762 |
tejbeer |
679 |
categoryPositions.addAll(positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_MARKETING));
|
| 28377 |
tejbeer |
680 |
|
| 31762 |
tejbeer |
681 |
categoryPositions.addAll(positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_TRAINING));
|
| 28377 |
tejbeer |
682 |
|
| 31762 |
tejbeer |
683 |
Map<Integer, Position> positionsMap = categoryPositions.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 29229 |
tejbeer |
684 |
|
| 31762 |
tejbeer |
685 |
Map<Integer, List<CustomRetailer>> positonPartnerMap = this.getPositionCustomRetailerMap(categoryPositions);
|
|
|
686 |
for (Map.Entry<Integer, List<CustomRetailer>> positionPartnerEntry : positonPartnerMap.entrySet()) {
|
|
|
687 |
int authUserId = positionsMap.get(positionPartnerEntry.getKey()).getAuthUserId();
|
|
|
688 |
List<Integer> partnerIds = positionPartnerEntry.getValue().stream().filter(x -> activeFofoIds.contains(x.getPartnerId())).map(x -> x.getPartnerId()).collect(Collectors.toList());
|
|
|
689 |
AuthUser authUser = authRepository.selectById(authUserId);
|
|
|
690 |
if (authUser != null && authUser.isActive()) {
|
|
|
691 |
if (!storeGuyMap.containsKey(authUserId)) {
|
|
|
692 |
storeGuyMap.put(authUserId, partnerIds);
|
|
|
693 |
} else {
|
|
|
694 |
storeGuyMap.get(authUserId).addAll(partnerIds);
|
|
|
695 |
}
|
|
|
696 |
}
|
|
|
697 |
}
|
|
|
698 |
storeGuyMap.keySet().stream().forEach(x -> {
|
|
|
699 |
List<Integer> fofoIds = storeGuyMap.get(x);
|
|
|
700 |
storeGuyMap.put(x, fofoIds.stream().distinct().collect(Collectors.toList()));
|
|
|
701 |
});
|
|
|
702 |
return storeGuyMap;
|
|
|
703 |
}
|
| 28908 |
tejbeer |
704 |
|
| 31762 |
tejbeer |
705 |
@Override
|
|
|
706 |
@Cacheable(value = "L1L2Mapping", cacheManager = "thirtyMinsTimeOutCacheManager")
|
|
|
707 |
public Map<Integer, List<Integer>> getL2L1Mapping() {
|
|
|
708 |
List<Position> l1SalesPositions = positionRepository.selectPositionbyCategoryIdAndEscalationType(
|
|
|
709 |
ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L1);
|
|
|
710 |
List<Position> l2SalesPositions = positionRepository.selectPositionbyCategoryIdAndEscalationType(
|
|
|
711 |
ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L2);
|
| 28908 |
tejbeer |
712 |
|
| 31762 |
tejbeer |
713 |
LOGGER.info("position" + l1SalesPositions);
|
|
|
714 |
Map<Integer, List<Integer>> authUserPartnerListMap = this.getAuthUserIdPartnerIdMapping();
|
|
|
715 |
LOGGER.info("map" + authUserPartnerListMap);
|
| 28908 |
tejbeer |
716 |
|
| 31762 |
tejbeer |
717 |
Map<Integer, List<Integer>> l2l1ListMap = new HashMap<>();
|
| 29318 |
tejbeer |
718 |
|
| 31762 |
tejbeer |
719 |
for (Position l2SalePosition : l2SalesPositions) {
|
|
|
720 |
int l2AuthUserId = l2SalePosition.getAuthUserId();
|
|
|
721 |
if (authUserPartnerListMap.containsKey(l2SalePosition.getAuthUserId())) {
|
|
|
722 |
List<Integer> mappedL1AuthUsers = new ArrayList<>();
|
|
|
723 |
l2l1ListMap.put(l2AuthUserId, mappedL1AuthUsers);
|
|
|
724 |
List<Integer> l2FofoIds = authUserPartnerListMap.get(l2AuthUserId);
|
|
|
725 |
for (Position l1SalePosition : l1SalesPositions) {
|
|
|
726 |
int l1AuthUserId = l1SalePosition.getAuthUserId();
|
|
|
727 |
if (authUserPartnerListMap.containsKey(l1AuthUserId)) {
|
|
|
728 |
List<Integer> l1FofoIds = authUserPartnerListMap.get(l1SalePosition.getAuthUserId());
|
|
|
729 |
if (l2FofoIds.containsAll(l1FofoIds)) {
|
|
|
730 |
mappedL1AuthUsers.add(l1AuthUserId);
|
|
|
731 |
}
|
|
|
732 |
}
|
| 28856 |
manish |
733 |
|
| 31762 |
tejbeer |
734 |
}
|
|
|
735 |
}
|
| 29296 |
manish |
736 |
|
| 31762 |
tejbeer |
737 |
}
|
| 29296 |
manish |
738 |
|
| 31762 |
tejbeer |
739 |
return l2l1ListMap;
|
|
|
740 |
}
|
| 29296 |
manish |
741 |
|
| 31762 |
tejbeer |
742 |
@Override
|
|
|
743 |
public Map<Integer, List<AuthUser>> getAssignedAuthList(List<Ticket> tickets) {
|
|
|
744 |
if (tickets.size() == 0) {
|
|
|
745 |
return new HashMap<>();
|
|
|
746 |
}
|
|
|
747 |
List<TicketAssigned> ticketAssignedList = ticketAssignedRepository.selectByTicketIds(tickets.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
|
|
748 |
List<Integer> authUserIds = ticketAssignedList.stream().map(x -> x.getAssineeId()).distinct().collect(Collectors.toList());
|
|
|
749 |
Map<Integer, AuthUser> authUserMap = authRepository.selectAllAuthUserByIds(authUserIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
|
|
750 |
return ticketAssignedList.stream().collect(Collectors.groupingBy(x -> x.getTicketId(), Collectors.mapping(x -> authUserMap.get(x.getAssineeId()), Collectors.toList())));
|
|
|
751 |
}
|
| 28908 |
tejbeer |
752 |
|
| 31762 |
tejbeer |
753 |
@Override
|
|
|
754 |
public Map<EscalationType, AuthUser> getAuthUserAndEsclationByPartnerId(int fofoId) {
|
|
|
755 |
Map<EscalationType, AuthUser> authuserEsclationTypeMap = new HashMap<>();
|
|
|
756 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
|
| 28908 |
tejbeer |
757 |
|
| 31762 |
tejbeer |
758 |
regionIds.add(5);// All partners Id;
|
|
|
759 |
List<Integer> fofoIds = new ArrayList<>();
|
|
|
760 |
fofoIds.add(fofoId);
|
|
|
761 |
fofoIds.add(0);
|
| 28908 |
tejbeer |
762 |
|
| 31762 |
tejbeer |
763 |
LOGGER.info("fofoIds" + fofoIds);
|
|
|
764 |
List<Integer> partnerPositionIds = partnersPositionRepository.selectByRegionIdAndPartnerId(regionIds, fofoIds).stream().map(x -> x.getPositionId()).collect(Collectors.toList());
|
| 28908 |
tejbeer |
765 |
|
| 31762 |
tejbeer |
766 |
LOGGER.info("partnerPositionIds" + partnerPositionIds);
|
| 30003 |
tejbeer |
767 |
|
| 31762 |
tejbeer |
768 |
for (Integer partnerPostionId : partnerPositionIds) {
|
|
|
769 |
Position position = positionRepository.selectByIdAndCategoryId(partnerPostionId, ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
|
|
770 |
LOGGER.info("position" + position);
|
|
|
771 |
if (position != null) {
|
| 30003 |
tejbeer |
772 |
|
| 31762 |
tejbeer |
773 |
AuthUser authUser = authRepository.selectById(position.getAuthUserId());
|
|
|
774 |
LOGGER.info("authUser" + authUser);
|
| 30003 |
tejbeer |
775 |
|
| 31762 |
tejbeer |
776 |
authuserEsclationTypeMap.put(position.getEscalationType(), authUser);
|
|
|
777 |
}
|
|
|
778 |
}
|
| 30003 |
tejbeer |
779 |
|
| 31762 |
tejbeer |
780 |
LOGGER.info("emailEsclationTypeMap" + authuserEsclationTypeMap);
|
| 30003 |
tejbeer |
781 |
|
| 31762 |
tejbeer |
782 |
return authuserEsclationTypeMap;
|
|
|
783 |
}
|
| 30044 |
tejbeer |
784 |
|
| 31762 |
tejbeer |
785 |
@Override
|
|
|
786 |
public List<AuthUser> getAuthUserIdByPartnerId(int fofoId) {
|
|
|
787 |
List<AuthUser> authUsers = new ArrayList<>();
|
|
|
788 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
|
| 30044 |
tejbeer |
789 |
|
| 31762 |
tejbeer |
790 |
regionIds.add(5);// All partners Id;
|
|
|
791 |
List<Integer> fofoIds = new ArrayList<>();
|
|
|
792 |
fofoIds.add(fofoId);
|
|
|
793 |
fofoIds.add(0);
|
| 30044 |
tejbeer |
794 |
|
| 31762 |
tejbeer |
795 |
LOGGER.info("fofoIds" + fofoIds);
|
|
|
796 |
List<Integer> partnerPositionIds = partnersPositionRepository.selectByRegionIdAndPartnerId(regionIds, fofoIds).stream().map(x -> x.getPositionId()).collect(Collectors.toList());
|
| 30003 |
tejbeer |
797 |
|
| 31762 |
tejbeer |
798 |
LOGGER.info("partnerPositionIds" + partnerPositionIds);
|
| 30003 |
tejbeer |
799 |
|
| 31762 |
tejbeer |
800 |
for (Integer partnerPostionId : partnerPositionIds) {
|
|
|
801 |
Position position = positionRepository.selectByIdAndCategoryId(partnerPostionId, ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
|
|
802 |
LOGGER.info("position" + position);
|
|
|
803 |
if (position != null) {
|
| 30044 |
tejbeer |
804 |
|
| 31762 |
tejbeer |
805 |
AuthUser authUser = authRepository.selectById(position.getAuthUserId());
|
|
|
806 |
LOGGER.info("authUser" + authUser);
|
|
|
807 |
authUsers.add(authUser);
|
|
|
808 |
}
|
| 30003 |
tejbeer |
809 |
|
| 31762 |
tejbeer |
810 |
Position rbmPosition = positionRepository.selectByIdAndCategoryId(partnerPostionId, ProfitMandiConstants.TICKET_CATEGORY_RBM);
|
|
|
811 |
if (rbmPosition != null) {
|
| 30003 |
tejbeer |
812 |
|
| 31762 |
tejbeer |
813 |
AuthUser authUser = authRepository.selectById(rbmPosition.getAuthUserId());
|
|
|
814 |
LOGGER.info("authUser" + authUser);
|
|
|
815 |
authUsers.add(authUser);
|
|
|
816 |
}
|
| 30003 |
tejbeer |
817 |
|
| 31762 |
tejbeer |
818 |
}
|
| 30003 |
tejbeer |
819 |
|
| 31762 |
tejbeer |
820 |
return authUsers;
|
|
|
821 |
}
|
| 30044 |
tejbeer |
822 |
|
| 31762 |
tejbeer |
823 |
@Override
|
|
|
824 |
public List<AuthUser> getAuthUserIds(int categoryId, List<EscalationType> escalationType) {
|
| 30044 |
tejbeer |
825 |
|
| 31762 |
tejbeer |
826 |
List<Position> positions = positionRepository.selectPositionbyCategoryIdAndEscalationTypes(categoryId, escalationType);
|
|
|
827 |
List<Integer> authIds = positions.stream().map(x -> x.getAuthUserId()).distinct().collect(Collectors.toList());
|
| 30003 |
tejbeer |
828 |
|
| 31762 |
tejbeer |
829 |
LOGGER.info("authIds" + authIds);
|
| 30003 |
tejbeer |
830 |
|
| 31762 |
tejbeer |
831 |
List<AuthUser> authUsers = authRepository.selectAllAuthUserByIds(authIds);
|
|
|
832 |
|
|
|
833 |
LOGGER.info("authUsers" + authUsers);
|
|
|
834 |
return authUsers;
|
|
|
835 |
}
|
|
|
836 |
|
|
|
837 |
@Override
|
|
|
838 |
public List<AuthUser> getAuthUserByCategoryId(int categoryId, EscalationType escalationType) {
|
|
|
839 |
|
|
|
840 |
List<Position> positions = positionRepository.selectPositionbyCategoryIdAndEscalationType(categoryId, escalationType);
|
|
|
841 |
List<Integer> authIds = positions.stream().map(x -> x.getAuthUserId()).distinct().collect(Collectors.toList());
|
|
|
842 |
|
|
|
843 |
LOGGER.info("authIds" + authIds);
|
|
|
844 |
List<AuthUser> authUsers = new ArrayList<>();
|
|
|
845 |
if (!authIds.isEmpty()) {
|
|
|
846 |
authUsers = authRepository.selectAllAuthUserByIds(authIds);
|
|
|
847 |
}
|
|
|
848 |
|
|
|
849 |
LOGGER.info("authUsers" + authUsers);
|
|
|
850 |
return authUsers;
|
|
|
851 |
}
|
|
|
852 |
|
|
|
853 |
@Override
|
|
|
854 |
@Cacheable(value = "authUserByCategoryId", cacheManager = "thirtyMinsTimeOutCacheManager")
|
|
|
855 |
public List<AuthUser> getAuthUserByCategoryId(int categoryId) {
|
|
|
856 |
List<Position> positions = positionRepository.selectPositionByCategoryId(categoryId);
|
|
|
857 |
List<Integer> authIds = positions.stream().map(x -> x.getAuthUserId()).distinct().collect(Collectors.toList());
|
|
|
858 |
|
|
|
859 |
LOGGER.info("authIds" + authIds);
|
|
|
860 |
|
|
|
861 |
List<AuthUser> authUsers = authRepository.selectAllAuthUserByIds(authIds).stream().filter(x -> x.getActive()).collect(Collectors.toList());
|
|
|
862 |
|
|
|
863 |
LOGGER.info("authUsers" + authUsers);
|
|
|
864 |
return authUsers;
|
|
|
865 |
}
|
|
|
866 |
|
|
|
867 |
private class SaleRoles {
|
|
|
868 |
|
|
|
869 |
private List<String> l1;
|
|
|
870 |
private List<String> l2;
|
|
|
871 |
private List<String> l3;
|
|
|
872 |
private List<String> l4;
|
|
|
873 |
|
|
|
874 |
public SaleRoles() {
|
|
|
875 |
l1 = new ArrayList<>();
|
|
|
876 |
l2 = new ArrayList<>();
|
|
|
877 |
l3 = new ArrayList<>();
|
|
|
878 |
l4 = new ArrayList<>();
|
|
|
879 |
}
|
|
|
880 |
|
|
|
881 |
public List<String> getL1() {
|
|
|
882 |
return l1;
|
|
|
883 |
}
|
|
|
884 |
|
|
|
885 |
public List<String> getL2() {
|
|
|
886 |
return l2;
|
|
|
887 |
}
|
|
|
888 |
|
|
|
889 |
public List<String> getL3() {
|
|
|
890 |
return l3;
|
|
|
891 |
}
|
|
|
892 |
|
|
|
893 |
public List<String> getL4() {
|
|
|
894 |
return l4;
|
|
|
895 |
}
|
|
|
896 |
|
|
|
897 |
@Override
|
|
|
898 |
public String toString() {
|
|
|
899 |
return "SaleRoles [l1=" + l1 + ", l2=" + l2 + ", l3=" + l3 + ", l4=" + l4 + "]";
|
|
|
900 |
}
|
|
|
901 |
|
|
|
902 |
}
|
|
|
903 |
|
|
|
904 |
@Override
|
|
|
905 |
@Cacheable(value = "partnerSaleHeader", cacheManager = "oneDayCacheManager")
|
|
|
906 |
public Map<Integer, FofoReportingModel> getPartnerIdSalesHeaders() {
|
|
|
907 |
Map<String, SaleRoles> partnerEmailSalesMap = new HashMap<>();
|
|
|
908 |
|
|
|
909 |
List<Position> positions = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
|
|
910 |
Map<Integer, AuthUser> authUsersMap = authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
|
|
911 |
Map<Integer, List<CustomRetailer>> positionIdRetailerMap = this.getPositionCustomRetailerMap(positions);
|
|
|
912 |
for (Position position : positions) {
|
|
|
913 |
List<CustomRetailer> crList = positionIdRetailerMap.get(position.getId());
|
|
|
914 |
if (crList == null)
|
|
|
915 |
continue;
|
|
|
916 |
for (CustomRetailer cr : crList) {
|
|
|
917 |
if (!partnerEmailSalesMap.containsKey(cr.getEmail())) {
|
|
|
918 |
partnerEmailSalesMap.put(cr.getEmail(), new SaleRoles());
|
|
|
919 |
}
|
|
|
920 |
SaleRoles saleRoles = partnerEmailSalesMap.get(cr.getEmail());
|
|
|
921 |
AuthUser authUser = authUsersMap.get(position.getAuthUserId());
|
|
|
922 |
if (authUser == null) {
|
|
|
923 |
continue;
|
|
|
924 |
}
|
|
|
925 |
String name = authUser.getFirstName() + " " + authUser.getLastName();
|
|
|
926 |
if (position.getEscalationType().equals(EscalationType.L1)) {
|
|
|
927 |
saleRoles.getL1().add(name);
|
|
|
928 |
} else if (position.getEscalationType().equals(EscalationType.L2)) {
|
|
|
929 |
saleRoles.getL2().add(name);
|
|
|
930 |
}
|
|
|
931 |
|
|
|
932 |
}
|
|
|
933 |
}
|
|
|
934 |
|
|
|
935 |
Set<CustomRetailer> allCrList = new HashSet<>();
|
|
|
936 |
for (List<CustomRetailer> cr : positionIdRetailerMap.values()) {
|
|
|
937 |
allCrList.addAll(cr);
|
|
|
938 |
}
|
|
|
939 |
|
|
|
940 |
Map<Integer, FofoStore> fofoStoresMap = fofoStoreRepository.selectActiveStores().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
|
|
941 |
|
|
|
942 |
Map<Integer, FofoReportingModel> partnerIdSalesHeadersMap = new HashMap<>();
|
|
|
943 |
|
|
|
944 |
for (CustomRetailer cr : allCrList) {
|
|
|
945 |
FofoStore fofoStore = fofoStoresMap.get(cr.getPartnerId());
|
|
|
946 |
if (fofoStore == null) {
|
|
|
947 |
LOGGER.info("Could not find Store {} in active Store", cr.getBusinessName());
|
|
|
948 |
continue;
|
|
|
949 |
}
|
|
|
950 |
String code = fofoStore.getCode();
|
|
|
951 |
// String storeName = "SmartDukaan-" +
|
|
|
952 |
// fofoStore.getCode().replaceAll("[a-zA-Z]", "");
|
|
|
953 |
String businessName = cr.getBusinessName();
|
|
|
954 |
try {
|
|
|
955 |
String stateManager = StringUtils.join(partnerEmailSalesMap.get(cr.getEmail()).getL2(), ", ");
|
|
|
956 |
String territoryManager = StringUtils.join(partnerEmailSalesMap.get(cr.getEmail()).getL1(), ", ");
|
|
|
957 |
|
|
|
958 |
if (StringUtils.isEmpty(territoryManager)) {
|
|
|
959 |
territoryManager = StringUtils.join(partnerEmailSalesMap.get(cr.getEmail()).getL2(), ", ");
|
|
|
960 |
}
|
|
|
961 |
|
|
|
962 |
FofoReportingModel reportingModel = new FofoReportingModel();
|
|
|
963 |
reportingModel.setBusinessName(businessName);
|
|
|
964 |
reportingModel.setCode(code);
|
|
|
965 |
reportingModel.setFofoId(fofoStore.getId());
|
|
|
966 |
reportingModel.setRegionalManager(stateManager);
|
|
|
967 |
reportingModel.setTerritoryManager(territoryManager);
|
|
|
968 |
partnerIdSalesHeadersMap.put(fofoStore.getId(), reportingModel);
|
|
|
969 |
} catch (Exception e) {
|
|
|
970 |
LOGGER.warn("Could not find partner with email - {}", cr.getEmail());
|
|
|
971 |
}
|
|
|
972 |
}
|
|
|
973 |
return partnerIdSalesHeadersMap;
|
|
|
974 |
|
|
|
975 |
}
|
|
|
976 |
|
|
|
977 |
@Override
|
|
|
978 |
public Map<Integer, TicketCategory> getSubCategoryIdAndCategoryMap(List<Integer> subCategoryIds) {
|
|
|
979 |
Map<Integer, TicketCategory> subCategoryIdAndCategoryMap = new HashMap<>();
|
|
|
980 |
|
|
|
981 |
List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository.selectByIds(subCategoryIds);
|
|
|
982 |
|
|
|
983 |
for (TicketSubCategory ticketSubCategory : ticketSubCategories) {
|
|
|
984 |
|
|
|
985 |
TicketCategory ticketCategory = ticketCategoryRepository.selectById(ticketSubCategory.getCategoryId());
|
|
|
986 |
|
|
|
987 |
subCategoryIdAndCategoryMap.put(ticketSubCategory.getId(), ticketCategory);
|
|
|
988 |
|
|
|
989 |
}
|
|
|
990 |
return subCategoryIdAndCategoryMap;
|
|
|
991 |
}
|
|
|
992 |
|
| 24383 |
amit.gupta |
993 |
}
|