| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.dao.repository.cs;
|
1 |
package com.spice.profitmandi.dao.repository.cs;
|
| 2 |
|
2 |
|
| 3 |
import java.time.LocalDateTime;
|
- |
|
| 4 |
import java.util.ArrayList;
|
- |
|
| 5 |
import java.util.Arrays;
|
- |
|
| 6 |
import java.util.HashMap;
|
- |
|
| 7 |
import java.util.HashSet;
|
- |
|
| 8 |
import java.util.LinkedHashSet;
|
- |
|
| 9 |
import java.util.List;
|
- |
|
| 10 |
import java.util.Map;
|
- |
|
| 11 |
import java.util.Set;
|
- |
|
| 12 |
import java.util.stream.Collectors;
|
- |
|
| 13 |
|
- |
|
| 14 |
import org.apache.commons.collections4.map.HashedMap;
|
- |
|
| 15 |
import org.apache.commons.lang.RandomStringUtils;
|
- |
|
| 16 |
import org.apache.commons.lang.StringUtils;
|
- |
|
| 17 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 18 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 19 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 20 |
import org.springframework.cache.annotation.Cacheable;
|
- |
|
| 21 |
import org.springframework.mail.javamail.JavaMailSender;
|
- |
|
| 22 |
import org.springframework.stereotype.Component;
|
- |
|
| 23 |
|
- |
|
| 24 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 25 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
4 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 26 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
5 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 27 |
import com.spice.profitmandi.common.util.Utils;
|
6 |
import com.spice.profitmandi.common.util.Utils;
|
| 28 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
7 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 29 |
import com.spice.profitmandi.dao.entity.cs.Activity;
|
- |
|
| 30 |
import com.spice.profitmandi.dao.entity.cs.PartnerRegion;
|
- |
|
| 31 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
- |
|
| 32 |
import com.spice.profitmandi.dao.entity.cs.Region;
|
8 |
import com.spice.profitmandi.dao.entity.cs.*;
|
| 33 |
import com.spice.profitmandi.dao.entity.cs.Ticket;
|
- |
|
| 34 |
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
|
- |
|
| 35 |
import com.spice.profitmandi.dao.entity.cs.TicketCategory;
|
- |
|
| 36 |
import com.spice.profitmandi.dao.entity.cs.TicketSubCategory;
|
- |
|
| 37 |
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
|
9 |
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
|
| 38 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
10 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 39 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
11 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 40 |
import com.spice.profitmandi.dao.model.FofoReportingModel;
|
12 |
import com.spice.profitmandi.dao.model.FofoReportingModel;
|
| 41 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
13 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 42 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
14 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 43 |
import com.spice.profitmandi.service.user.RetailerService;
|
15 |
import com.spice.profitmandi.service.user.RetailerService;
|
| - |
|
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;
|
| - |
|
25 |
|
| - |
|
26 |
import java.time.LocalDateTime;
|
| - |
|
27 |
import java.util.*;
|
| - |
|
28 |
import java.util.stream.Collectors;
|
| 44 |
|
29 |
|
| 45 |
@Component
|
30 |
@Component
|
| 46 |
public class CsServiceImpl implements CsService {
|
31 |
public class CsServiceImpl implements CsService {
|
| 47 |
|
32 |
|
| 48 |
private static final int ALL_PARTNERS_REGION = 5;
|
33 |
private static final int ALL_PARTNERS_REGION = 5;
|
| Line 338... |
Line 323... |
| 338 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
|
323 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
|
| 339 |
// Add all Partner regions id
|
324 |
// Add all Partner regions id
|
| 340 |
regionIds.add(ALL_PARTNERS_REGION);
|
325 |
regionIds.add(ALL_PARTNERS_REGION);
|
| 341 |
LOGGER.info("Escalation Type {}, Region Ids {}", escalationType, regionIds);
|
326 |
LOGGER.info("Escalation Type {}, Region Ids {}", escalationType, regionIds);
|
| 342 |
List<Integer> partnerPositionsIds = partnersPositionRepository.selectByRegionIdAndPartnerId(regionIds, Arrays.asList(0, fofoId)).stream().map(x -> x.getPositionId()).collect(Collectors.toList());
|
327 |
List<Integer> partnerPositionsIds = partnersPositionRepository.selectByRegionIdAndPartnerId(regionIds, Arrays.asList(0, fofoId)).stream().map(x -> x.getPositionId()).collect(Collectors.toList());
|
| 343 |
positions = positions.stream().filter(x -> partnerPositionsIds.contains(x.getId())).collect(Collectors.toList());
|
328 |
List<Position> positionAssignee = positions.stream().filter(x -> x.isTicketAssignee() && partnerPositionsIds.contains(x.getId())).collect(Collectors.toList());
|
| 344 |
LOGGER.info("User List List {}", positions.stream().map(x -> x.getAuthUserId()).collect(Collectors.toList()));
|
329 |
LOGGER.info("User List List {}", positions.stream().map(x -> x.getAuthUserId()).collect(Collectors.toList()));
|
| 345 |
if (positions.size() > 0) {
|
- |
|
| 346 |
|
- |
|
| 347 |
List<Position> positionAssignee = positions.stream().filter(x -> x.isTicketAssignee()).collect(Collectors.toList());
|
- |
|
| 348 |
|
- |
|
| 349 |
|
- |
|
| 350 |
if (positionAssignee.size() > 0) {
|
330 |
if (positionAssignee.size() > 0) {
|
| 351 |
|
- |
|
| 352 |
positions = positionAssignee;
|
- |
|
| 353 |
}
|
- |
|
| 354 |
List<AuthUser> authUsers = authRepository.selectAllAuthUserByIds(
|
331 |
List<AuthUser> authUsers = authRepository.selectAllAuthUserByIds(
|
| 355 |
positions.stream().map(x -> x.getAuthUserId()).collect(Collectors.toList()));
|
332 |
positions.stream().map(x -> x.getAuthUserId()).collect(Collectors.toList()));
|
| 356 |
authUsers = authUsers.stream().filter(x -> x.isActive()).collect(Collectors.toList());
|
333 |
authUsers = authUsers.stream().filter(x -> x.isActive()).collect(Collectors.toList());
|
| 357 |
if (authUsers.size() > 0) {
|
334 |
if (authUsers.size() > 0) {
|
| 358 |
authUserId = authUsers.get(0).getId();
|
335 |
authUserId = authUsers.get(0).getId();
|