| Line 1886... |
Line 1886... |
| 1886 |
|
1886 |
|
| 1887 |
return result;
|
1887 |
return result;
|
| 1888 |
}
|
1888 |
}
|
| 1889 |
|
1889 |
|
| 1890 |
@Override
|
1890 |
@Override
|
| - |
|
1891 |
public Map<Integer, Integer> getAuthUserIdsWithoutTicketAssigneeByFofoIds(int categoryId, EscalationType escalationType, Set<Integer> fofoIds) throws ProfitMandiBusinessException {
|
| - |
|
1892 |
Map<Integer, Integer> result = new HashMap<>();
|
| - |
|
1893 |
if (fofoIds == null || fofoIds.isEmpty()) {
|
| - |
|
1894 |
return result;
|
| - |
|
1895 |
}
|
| - |
|
1896 |
for (Integer fofoId : fofoIds) {
|
| - |
|
1897 |
result.put(fofoId, 0);
|
| - |
|
1898 |
}
|
| - |
|
1899 |
|
| - |
|
1900 |
List<Position> positions = positionRepository.selectPositionbyCategoryIdAndEscalationType(categoryId, escalationType);
|
| - |
|
1901 |
if (positions.isEmpty()) {
|
| - |
|
1902 |
return result;
|
| - |
|
1903 |
}
|
| - |
|
1904 |
Set<Integer> positionIds = positions.stream().map(Position::getId).collect(Collectors.toSet());
|
| - |
|
1905 |
Map<Integer, Integer> positionToAuthUser = new HashMap<>();
|
| - |
|
1906 |
positions.forEach(p -> positionToAuthUser.put(p.getId(), p.getAuthUserId()));
|
| - |
|
1907 |
|
| - |
|
1908 |
List<Integer> fofoIdList = new ArrayList<>(fofoIds);
|
| - |
|
1909 |
fofoIdList.add(0);
|
| - |
|
1910 |
List<PartnerRegion> allPartnerRegions = partnerRegionRepository.selectByfofoIds(fofoIdList);
|
| - |
|
1911 |
|
| - |
|
1912 |
Map<Integer, Set<Integer>> fofoRegionMap = new HashMap<>();
|
| - |
|
1913 |
for (Integer fofoId : fofoIds) {
|
| - |
|
1914 |
Set<Integer> regions = new HashSet<>();
|
| - |
|
1915 |
regions.add(ALL_PARTNERS_REGION);
|
| - |
|
1916 |
fofoRegionMap.put(fofoId, regions);
|
| - |
|
1917 |
}
|
| - |
|
1918 |
for (PartnerRegion pr : allPartnerRegions) {
|
| - |
|
1919 |
int fofoId = pr.getFofoId();
|
| - |
|
1920 |
if (fofoId == 0) {
|
| - |
|
1921 |
for (Integer fid : fofoIds) {
|
| - |
|
1922 |
fofoRegionMap.get(fid).add(pr.getRegionId());
|
| - |
|
1923 |
}
|
| - |
|
1924 |
} else if (fofoIds.contains(fofoId)) {
|
| - |
|
1925 |
fofoRegionMap.get(fofoId).add(pr.getRegionId());
|
| - |
|
1926 |
}
|
| - |
|
1927 |
}
|
| - |
|
1928 |
|
| - |
|
1929 |
Set<Integer> allRegionIds = fofoRegionMap.values().stream()
|
| - |
|
1930 |
.flatMap(Set::stream).collect(Collectors.toSet());
|
| - |
|
1931 |
List<PartnerPosition> allPartnerPositions = partnerPositionRepository.selectByRegionIdAndPostionId(
|
| - |
|
1932 |
new ArrayList<>(allRegionIds), new ArrayList<>(positionIds));
|
| - |
|
1933 |
|
| - |
|
1934 |
Set<Integer> allAuthUserIds = positions.stream().map(Position::getAuthUserId).collect(Collectors.toSet());
|
| - |
|
1935 |
Set<Integer> activeAuthUserIds = authRepository.selectByIds(new ArrayList<>(allAuthUserIds))
|
| - |
|
1936 |
.stream().filter(AuthUser::isActive).map(AuthUser::getId).collect(Collectors.toSet());
|
| - |
|
1937 |
|
| - |
|
1938 |
for (Integer fofoId : fofoIds) {
|
| - |
|
1939 |
Set<Integer> regionIds = fofoRegionMap.get(fofoId);
|
| - |
|
1940 |
for (PartnerPosition pp : allPartnerPositions) {
|
| - |
|
1941 |
if (!regionIds.contains(pp.getRegionId())) continue;
|
| - |
|
1942 |
if (pp.getFofoId() != 0 && pp.getFofoId() != fofoId) continue;
|
| - |
|
1943 |
Integer authUserId = positionToAuthUser.get(pp.getPositionId());
|
| - |
|
1944 |
if (authUserId != null && activeAuthUserIds.contains(authUserId)) {
|
| - |
|
1945 |
result.put(fofoId, authUserId);
|
| - |
|
1946 |
break;
|
| - |
|
1947 |
}
|
| - |
|
1948 |
}
|
| - |
|
1949 |
}
|
| - |
|
1950 |
return result;
|
| - |
|
1951 |
}
|
| - |
|
1952 |
|
| - |
|
1953 |
@Override
|
| 1891 |
public Map<Integer, Boolean> getUnreadStatusForTickets(List<Ticket> tickets, int userId, TicketReadStatus.UserType userType) {
|
1954 |
public Map<Integer, Boolean> getUnreadStatusForTickets(List<Ticket> tickets, int userId, TicketReadStatus.UserType userType) {
|
| 1892 |
Map<Integer, Boolean> unreadMap = new HashMap<>();
|
1955 |
Map<Integer, Boolean> unreadMap = new HashMap<>();
|
| 1893 |
if (tickets == null || tickets.isEmpty()) {
|
1956 |
if (tickets == null || tickets.isEmpty()) {
|
| 1894 |
return unreadMap;
|
1957 |
return unreadMap;
|
| 1895 |
}
|
1958 |
}
|