| Line 183... |
Line 183... |
| 183 |
}
|
183 |
}
|
| 184 |
|
184 |
|
| 185 |
|
185 |
|
| 186 |
@Override
|
186 |
@Override
|
| 187 |
public void assignTicket(Ticket ticket) throws ProfitMandiBusinessException {
|
187 |
public void assignTicket(Ticket ticket) throws ProfitMandiBusinessException {
|
| - |
|
188 |
this.assignTicket(ticket,0);
|
| - |
|
189 |
}
|
| - |
|
190 |
|
| - |
|
191 |
@Override
|
| - |
|
192 |
public void assignTicket(Ticket ticket,int currentUserId) throws ProfitMandiBusinessException {
|
| 188 |
TicketAssigned ticketAssigned = null;
|
193 |
TicketAssigned ticketAssigned = null;
|
| 189 |
EscalationType newEscalationType = EscalationType.L1;
|
194 |
EscalationType newEscalationType = EscalationType.L1;
|
| 190 |
if (ticket.getAssignmentId() > 0) {
|
195 |
if (ticket.getAssignmentId() > 0) {
|
| 191 |
ticketAssigned = ticketAssignedRepository.selectById(ticket.getAssignmentId());
|
196 |
ticketAssigned = ticketAssignedRepository.selectById(ticket.getAssignmentId());
|
| 192 |
newEscalationType = ticketAssigned.getEscalationType().next();
|
197 |
newEscalationType = ticketAssigned.getEscalationType().next();
|
| Line 261... |
Line 266... |
| 261 |
TicketAssigned ticketAssignedNew = new TicketAssigned();
|
266 |
TicketAssigned ticketAssignedNew = new TicketAssigned();
|
| 262 |
ticketAssignedNew.setTicketId(ticket.getId());
|
267 |
ticketAssignedNew.setTicketId(ticket.getId());
|
| 263 |
ticketAssignedNew.setAssineeId(assigneeAuthId);
|
268 |
ticketAssignedNew.setAssineeId(assigneeAuthId);
|
| 264 |
ticketAssignedNew.setEscalationType(assigneeEscalationType);
|
269 |
ticketAssignedNew.setEscalationType(assigneeEscalationType);
|
| 265 |
ticketAssignedNew.setManagerId(managerAuthId);
|
270 |
ticketAssignedNew.setManagerId(managerAuthId);
|
| - |
|
271 |
ticketAssignedNew.setAssignedBy(currentUserId);
|
| 266 |
ticketAssignedNew.setCreateTimestamp(LocalDateTime.now());
|
272 |
ticketAssignedNew.setCreateTimestamp(LocalDateTime.now());
|
| 267 |
ticketAssignedRepository.persist(ticketAssignedNew);
|
273 |
ticketAssignedRepository.persist(ticketAssignedNew);
|
| 268 |
LOGGER.info(ticketAssigned);
|
274 |
LOGGER.info(ticketAssigned);
|
| 269 |
|
275 |
|
| 270 |
AuthUser authUser = authRepository.selectById(ticketAssignedNew.getAssineeId());
|
276 |
AuthUser authUser = authRepository.selectById(ticketAssignedNew.getAssineeId());
|
| Line 277... |
Line 283... |
| 277 |
ticket.setAssignmentId(ticketAssignedNew.getId());
|
283 |
ticket.setAssignmentId(ticketAssignedNew.getId());
|
| 278 |
|
284 |
|
| 279 |
List<Activity> activities = activityRepository.selectAll(ticket.getId());
|
285 |
List<Activity> activities = activityRepository.selectAll(ticket.getId());
|
| 280 |
this.sendAssignedTicketMail(authUser, Arrays.asList(authUserManager), ticket, ticketAssigned != null, activities);
|
286 |
this.sendAssignedTicketMail(authUser, Arrays.asList(authUserManager), ticket, ticketAssigned != null, activities);
|
| 281 |
if (!ticketAssignedNew.getEscalationType().equals(EscalationType.L1)) {
|
287 |
if (!ticketAssignedNew.getEscalationType().equals(EscalationType.L1)) {
|
| 282 |
this.addActivity(ticket, this.createActivity(ActivityType.ESCALATED, "Ticket ecalated and assigned to " + authUser.getName(), 0));
|
288 |
this.addActivity(ticket, this.createActivity(ActivityType.ESCALATED, "Ticket ecalated and assigned to " + authUser.getName(), currentUserId));
|
| 283 |
} else {
|
289 |
} else {
|
| 284 |
this.addActivity(ticket, this.createActivity(ActivityType.ASSIGNED, "Ticket assigned to " + authUser.getName(), 0));
|
290 |
this.addActivity(ticket, this.createActivity(ActivityType.ASSIGNED, "Ticket assigned to " + authUser.getName(), currentUserId));
|
| 285 |
}
|
291 |
}
|
| 286 |
}
|
292 |
}
|
| 287 |
|
293 |
|
| 288 |
public void updateTicket(int categoryId, int subCategoryId, Ticket ticket, int authUserId, EscalationType escalationType) throws ProfitMandiBusinessException {
|
294 |
public void updateTicket(int categoryId, int subCategoryId, Ticket ticket, int authUserId, EscalationType escalationType) throws ProfitMandiBusinessException {
|
| 289 |
this.updateTicket(categoryId, subCategoryId, ticket, authUserId, escalationType, null);
|
295 |
this.updateTicket(categoryId, subCategoryId, ticket, authUserId, escalationType, null,0);
|
| 290 |
}
|
296 |
}
|
| 291 |
|
297 |
|
| 292 |
@Override
|
298 |
@Override
|
| 293 |
public void updateTicket(int categoryId, int subCategoryId, Ticket ticket, int authUserId, EscalationType escalationType, ActivityMediaModel recording) throws ProfitMandiBusinessException {
|
299 |
public void updateTicket(int categoryId, int subCategoryId, Ticket ticket, int authUserId, EscalationType escalationType, ActivityMediaModel recording,int currentUserId) throws ProfitMandiBusinessException {
|
| 294 |
LOGGER.info("subCategoryId {}",subCategoryId);
|
300 |
LOGGER.info("subCategoryId {}",subCategoryId);
|
| 295 |
TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.getTicketSubCategoryMap().get(subCategoryId);
|
301 |
TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.getTicketSubCategoryMap().get(subCategoryId);
|
| 296 |
if (ticketSubCategory == null) {
|
302 |
if (ticketSubCategory == null) {
|
| 297 |
throw new ProfitMandiBusinessException("Could not find subCategoryId " + subCategoryId + "- " + categoryId, "Problem", "Problem");
|
303 |
throw new ProfitMandiBusinessException("Could not find subCategoryId " + subCategoryId + "- " + categoryId, "Problem", "Problem");
|
| 298 |
}
|
304 |
}
|
| Line 322... |
Line 328... |
| 322 |
|
328 |
|
| 323 |
|
329 |
|
| 324 |
}
|
330 |
}
|
| 325 |
|
331 |
|
| 326 |
if (authUserId > 0) {
|
332 |
if (authUserId > 0) {
|
| 327 |
|
- |
|
| - |
|
333 |
LOGGER.info("authUserId--1111444 {}",authUserId);
|
| 328 |
this.assignTicketByAuthId(ticket, authUserId, escalationType);
|
334 |
this.assignTicketByAuthId(ticket, authUserId, escalationType);
|
| 329 |
|
335 |
|
| 330 |
} else {
|
336 |
} else {
|
| - |
|
337 |
LOGGER.info("authUserId--11113355 {}",authUserId);
|
| 331 |
ticket.setAssignmentId(0);
|
338 |
ticket.setAssignmentId(0);
|
| 332 |
this.assignTicket(ticket);
|
339 |
this.assignTicket(ticket,currentUserId);
|
| 333 |
}
|
340 |
}
|
| 334 |
|
341 |
|
| 335 |
}
|
342 |
}
|
| 336 |
|
343 |
|
| 337 |
private void assignTicketByAuthId(Ticket ticket, int authUserId, EscalationType escalationType) throws ProfitMandiBusinessException {
|
344 |
private void assignTicketByAuthId(Ticket ticket, int authUserId, EscalationType escalationType) throws ProfitMandiBusinessException {
|
| Line 1892... |
Line 1899... |
| 1892 |
} catch (Exception e) {
|
1899 |
} catch (Exception e) {
|
| 1893 |
LOGGER.error("Failed to send partner notification email for ticket {}", ticket.getId(), e);
|
1900 |
LOGGER.error("Failed to send partner notification email for ticket {}", ticket.getId(), e);
|
| 1894 |
}
|
1901 |
}
|
| 1895 |
}
|
1902 |
}
|
| 1896 |
|
1903 |
|
| 1897 |
@Override
|
- |
|
| 1898 |
public Set<Integer> getPartnerIdsByAuthUserId(int authUserId) throws ProfitMandiBusinessException {
|
- |
|
| 1899 |
Set<Integer> partnerIds = new HashSet<>();
|
- |
|
| 1900 |
|
- |
|
| 1901 |
// Get all positions for this auth user
|
- |
|
| 1902 |
List<Position> userPositions = positionRepository.selectAllByAuthUserId(authUserId);
|
- |
|
| 1903 |
|
- |
|
| 1904 |
// Filter to relevant categories (SALES, RBM, ABM, BI, TRAINING)
|
- |
|
| 1905 |
List<Integer> relevantCategoryIds = Arrays.asList(
|
- |
|
| 1906 |
ProfitMandiConstants.TICKET_CATEGORY_SALES,
|
- |
|
| 1907 |
ProfitMandiConstants.TICKET_CATEGORY_RBM,
|
- |
|
| 1908 |
ProfitMandiConstants.TICKET_CATEGORY_ABM,
|
- |
|
| 1909 |
ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT,
|
- |
|
| 1910 |
ProfitMandiConstants.TICKET_CATEGORY_TRAINING);
|
- |
|
| 1911 |
|
- |
|
| 1912 |
List<Position> filteredPositions = userPositions.stream()
|
- |
|
| 1913 |
.filter(p -> relevantCategoryIds.contains(p.getCategoryId()))
|
- |
|
| 1914 |
.collect(Collectors.toList());
|
- |
|
| 1915 |
|
- |
|
| 1916 |
if (filteredPositions.isEmpty()) {
|
- |
|
| 1917 |
return partnerIds;
|
- |
|
| 1918 |
}
|
- |
|
| 1919 |
|
- |
|
| 1920 |
// Get position IDs
|
- |
|
| 1921 |
List<Integer> positionIds = filteredPositions.stream()
|
- |
|
| 1922 |
.map(Position::getId)
|
- |
|
| 1923 |
.collect(Collectors.toList());
|
- |
|
| 1924 |
|
- |
|
| 1925 |
// Get partner positions for these positions
|
- |
|
| 1926 |
List<PartnerPosition> partnerPositions = partnerPositionRepository.selectByPositionIds(positionIds);
|
- |
|
| 1927 |
|
- |
|
| 1928 |
// Check if any position has partnerId = 0 (means all active partners)
|
- |
|
| 1929 |
boolean hasAllPartnersAccess = partnerPositions.stream().anyMatch(pp -> pp.getFofoId() == 0);
|
- |
|
| 1930 |
|
- |
|
| 1931 |
if (hasAllPartnersAccess) {
|
- |
|
| 1932 |
// Return all active partner IDs
|
- |
|
| 1933 |
partnerIds = fofoStoreRepository.selectActiveStores().stream()
|
- |
|
| 1934 |
.map(FofoStore::getId)
|
- |
|
| 1935 |
.collect(Collectors.toSet());
|
- |
|
| 1936 |
} else {
|
- |
|
| 1937 |
// Get partner IDs from direct assignments
|
- |
|
| 1938 |
Set<Integer> directPartnerIds = partnerPositions.stream()
|
- |
|
| 1939 |
.filter(pp -> pp.getFofoId() != 0)
|
- |
|
| 1940 |
.map(PartnerPosition::getFofoId)
|
- |
|
| 1941 |
.collect(Collectors.toSet());
|
- |
|
| 1942 |
partnerIds.addAll(directPartnerIds);
|
- |
|
| 1943 |
|
- |
|
| 1944 |
// Get partner IDs from region assignments
|
- |
|
| 1945 |
Set<Integer> regionIds = partnerPositions.stream()
|
- |
|
| 1946 |
.filter(pp -> pp.getRegionId() > 0)
|
- |
|
| 1947 |
.map(PartnerPosition::getRegionId)
|
- |
|
| 1948 |
.collect(Collectors.toSet());
|
- |
|
| 1949 |
|
- |
|
| 1950 |
if (!regionIds.isEmpty()) {
|
- |
|
| 1951 |
List<PartnerRegion> partnerRegions = partnerRegionRepository.selectAllByRegionIds(new ArrayList<>(regionIds));
|
- |
|
| 1952 |
Set<Integer> regionPartnerIds = partnerRegions.stream()
|
- |
|
| 1953 |
.map(PartnerRegion::getFofoId)
|
- |
|
| 1954 |
.collect(Collectors.toSet());
|
- |
|
| 1955 |
partnerIds.addAll(regionPartnerIds);
|
- |
|
| 1956 |
}
|
- |
|
| 1957 |
}
|
- |
|
| 1958 |
|
- |
|
| 1959 |
// Filter to only active partners
|
- |
|
| 1960 |
Set<Integer> activeFofoIds = fofoStoreRepository.selectActiveStores().stream()
|
- |
|
| 1961 |
.map(FofoStore::getId)
|
- |
|
| 1962 |
.collect(Collectors.toSet());
|
- |
|
| 1963 |
partnerIds.retainAll(activeFofoIds);
|
- |
|
| 1964 |
|
- |
|
| 1965 |
return partnerIds;
|
- |
|
| 1966 |
}
|
- |
|
| 1967 |
|
- |
|
| 1968 |
}
|
1904 |
}
|