| 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.LocalDate;
|
- |
|
| 4 |
import java.time.LocalDateTime;
|
3 |
import java.time.LocalDateTime;
|
| 5 |
import java.time.LocalTime;
|
- |
|
| 6 |
import java.util.ArrayList;
|
4 |
import java.util.ArrayList;
|
| 7 |
import java.util.Arrays;
|
- |
|
| 8 |
import java.util.Collection;
|
- |
|
| 9 |
import java.util.HashMap;
|
5 |
import java.util.HashMap;
|
| 10 |
import java.util.HashSet;
|
6 |
import java.util.HashSet;
|
| 11 |
import java.util.LinkedHashMap;
|
- |
|
| 12 |
import java.util.List;
|
7 |
import java.util.List;
|
| 13 |
import java.util.Map;
|
8 |
import java.util.Map;
|
| 14 |
import java.util.Map.Entry;
|
- |
|
| 15 |
import java.util.Set;
|
9 |
import java.util.Set;
|
| 16 |
import java.util.stream.Collectors;
|
10 |
import java.util.stream.Collectors;
|
| 17 |
|
11 |
|
| 18 |
import org.apache.commons.collections4.map.HashedMap;
|
12 |
import org.apache.commons.collections4.map.HashedMap;
|
| 19 |
import org.apache.commons.lang.RandomStringUtils;
|
13 |
import org.apache.commons.lang.RandomStringUtils;
|
| Line 22... |
Line 16... |
| 22 |
import org.springframework.beans.factory.annotation.Autowired;
|
16 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23 |
import org.springframework.cache.annotation.Cacheable;
|
17 |
import org.springframework.cache.annotation.Cacheable;
|
| 24 |
import org.springframework.mail.javamail.JavaMailSender;
|
18 |
import org.springframework.mail.javamail.JavaMailSender;
|
| 25 |
import org.springframework.stereotype.Component;
|
19 |
import org.springframework.stereotype.Component;
|
| 26 |
|
20 |
|
| 27 |
import com.google.common.collect.HashMultimap;
|
- |
|
| 28 |
import com.google.common.collect.Multimap;
|
- |
|
| 29 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
21 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 30 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
22 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 31 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
23 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 32 |
import com.spice.profitmandi.common.util.Utils;
|
24 |
import com.spice.profitmandi.common.util.Utils;
|
| 33 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
25 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| Line 38... |
Line 30... |
| 38 |
import com.spice.profitmandi.dao.entity.cs.Ticket;
|
30 |
import com.spice.profitmandi.dao.entity.cs.Ticket;
|
| 39 |
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
|
31 |
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
|
| 40 |
import com.spice.profitmandi.dao.entity.cs.TicketCategory;
|
32 |
import com.spice.profitmandi.dao.entity.cs.TicketCategory;
|
| 41 |
import com.spice.profitmandi.dao.entity.cs.TicketSubCategory;
|
33 |
import com.spice.profitmandi.dao.entity.cs.TicketSubCategory;
|
| 42 |
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
|
34 |
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
|
| 43 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
- |
|
| 44 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
- |
|
| 45 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
35 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 46 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
|
- |
|
| 47 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
- |
|
| 48 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
36 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 49 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
37 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 50 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
38 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
| 51 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
39 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 52 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
40 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
| Line 633... |
Line 621... |
| 633 |
}
|
621 |
}
|
| 634 |
|
622 |
|
| 635 |
@Override
|
623 |
@Override
|
| 636 |
@Cacheable(value = "L1L2Mapping", cacheManager = "thirtyMinsTimeOutCacheManager")
|
624 |
@Cacheable(value = "L1L2Mapping", cacheManager = "thirtyMinsTimeOutCacheManager")
|
| 637 |
public Map<Integer, List<Integer>> getL1L2Mapping() {
|
625 |
public Map<Integer, List<Integer>> getL1L2Mapping() {
|
| - |
|
626 |
List<Position> l1SalesPositions = positionRepository.selectPositionbyCategoryIdAndEscalationType(
|
| - |
|
627 |
ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L1);
|
| 638 |
List<Position> positions = positionRepository.selectPositionsByEscalationType(EscalationType.L1);
|
628 |
List<Position> l2SalesPositions = positionRepository.selectPositionbyCategoryIdAndEscalationType(
|
| - |
|
629 |
ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L2);
|
| - |
|
630 |
|
| 639 |
LOGGER.info("position" + positions);
|
631 |
LOGGER.info("position" + l1SalesPositions);
|
| 640 |
Map<Integer, List<Integer>> map = this.getAuthUserIdPartnerIdMapping();
|
632 |
Map<Integer, List<Integer>> authUserPartnerListMap = this.getAuthUserIdPartnerIdMapping();
|
| 641 |
LOGGER.info("map" + map);
|
633 |
LOGGER.info("map" + authUserPartnerListMap);
|
| 642 |
|
634 |
|
| 643 |
Map<Integer, Integer> l1andl2Map = new HashMap<>();
|
635 |
Map<Integer, List<Integer>> l2l1ListMap = new HashMap<>();
|
| 644 |
|
636 |
|
| 645 |
for (Position position : positions) {
|
637 |
for (Position l2SalePosition : l2SalesPositions) {
|
| 646 |
|
- |
|
| 647 |
if (map.containsKey(position.getAuthUserId())) {
|
638 |
int l2AuthUserId = l2SalePosition.getAuthUserId();
|
| 648 |
LOGGER.info("authId" + position.getAuthUserId());
|
639 |
if (authUserPartnerListMap.containsKey(l2SalePosition.getAuthUserId())) {
|
| 649 |
LOGGER.info("Vals" + map.get(position.getAuthUserId()));
|
640 |
List<Integer> mappedL1AuthUsers = new ArrayList<>();
|
| 650 |
List<Integer> fofoIds = map.get(position.getAuthUserId());
|
641 |
l2l1ListMap.put(l2AuthUserId, mappedL1AuthUsers);
|
| 651 |
Integer fofoId = fofoIds.get(0);
|
642 |
List<Integer> l2FofoIds = authUserPartnerListMap.get(l2AuthUserId);
|
| 652 |
LOGGER.info("fofo" + fofoId);
|
- |
|
| 653 |
List<Position> l2position = new ArrayList<>();
|
643 |
for (Position l1SalePosition : l1SalesPositions) {
|
| 654 |
|
- |
|
| 655 |
List<Position> finall2position = new ArrayList<>();
|
644 |
int l1AuthUserId = l1SalePosition.getAuthUserId();
|
| 656 |
|
- |
|
| 657 |
for (Map.Entry<Integer, List<Integer>> bs : map.entrySet()) {
|
645 |
if (authUserPartnerListMap.containsKey(l1AuthUserId)) {
|
| 658 |
if (!bs.getKey().equals(position.getAuthUserId())) {
|
646 |
List<Integer> l1FofoIds = authUserPartnerListMap.get(l1SalePosition.getAuthUserId());
|
| 659 |
|
- |
|
| 660 |
if (bs.getValue().contains(fofoId)) {
|
647 |
if (l2FofoIds.containsAll(l1FofoIds)) {
|
| 661 |
|
- |
|
| 662 |
LOGGER.info("key" + bs.getKey());
|
- |
|
| 663 |
|
- |
|
| 664 |
l2position = positionRepository.selectPositionsByAuthUserAndEscalationType(bs.getKey(),
|
- |
|
| 665 |
EscalationType.L2);
|
- |
|
| 666 |
|
- |
|
| 667 |
finall2position.addAll(l2position);
|
648 |
mappedL1AuthUsers.add(l1AuthUserId);
|
| 668 |
|
- |
|
| 669 |
}
|
649 |
}
|
| - |
|
650 |
|
| 670 |
}
|
651 |
}
|
| 671 |
}
|
- |
|
| 672 |
LOGGER.info("alll2position" + finall2position);
|
- |
|
| 673 |
|
652 |
|
| 674 |
l1andl2Map.put(position.getAuthUserId(), finall2position.get(0).getAuthUserId());
|
- |
|
| - |
|
653 |
}
|
| 675 |
}
|
654 |
}
|
| 676 |
|
655 |
|
| 677 |
}
|
656 |
}
|
| 678 |
|
657 |
|
| 679 |
Map<Integer, List<Integer>> l2andl1Map = l1andl2Map.entrySet().stream().collect(
|
- |
|
| 680 |
Collectors.groupingBy(Map.Entry::getValue, Collectors.mapping(Map.Entry::getKey, Collectors.toList())));
|
- |
|
| 681 |
return l2andl1Map;
|
658 |
return l2l1ListMap;
|
| 682 |
}
|
659 |
}
|
| 683 |
|
660 |
|
| 684 |
}
|
661 |
}
|