| Line 762... |
Line 762... |
| 762 |
ticket.getL2AuthUser() == currentAuthUser.getId() ||
|
762 |
ticket.getL2AuthUser() == currentAuthUser.getId() ||
|
| 763 |
ticket.getL3AuthUser() == currentAuthUser.getId() ||
|
763 |
ticket.getL3AuthUser() == currentAuthUser.getId() ||
|
| 764 |
ticket.getL4AuthUser() == currentAuthUser.getId() ||
|
764 |
ticket.getL4AuthUser() == currentAuthUser.getId() ||
|
| 765 |
ticket.getL5AuthUser() == currentAuthUser.getId();
|
765 |
ticket.getL5AuthUser() == currentAuthUser.getId();
|
| 766 |
|
766 |
|
| - |
|
767 |
// Check if user is related to this partner (RBM, ASM, BM etc.)
|
| - |
|
768 |
boolean isRelatedToPartner = false;
|
| 767 |
if (!isAssigned && !isInEscalationChain) {
|
769 |
if (!isAssigned && !isInEscalationChain) {
|
| - |
|
770 |
List<AuthUser> relatedUsers = csService.getAuthUserIdByPartnerId(ticket.getFofoId());
|
| - |
|
771 |
isRelatedToPartner = relatedUsers.stream()
|
| - |
|
772 |
.anyMatch(au -> au.getId() == currentAuthUser.getId());
|
| - |
|
773 |
if (!isRelatedToPartner) {
|
| 768 |
throw new ProfitMandiBusinessException("Ticket", ticketId, "You do not have permission to view this ticket");
|
774 |
throw new ProfitMandiBusinessException("Ticket", ticketId, "You do not have permission to view this ticket");
|
| - |
|
775 |
}
|
| 769 |
}
|
776 |
}
|
| - |
|
777 |
|
| - |
|
778 |
// User can view but cannot take action if only related to partner (not assigned/escalation)
|
| - |
|
779 |
model.addAttribute("canTakeAction", isAssigned || isInEscalationChain);
|
| 770 |
}
|
780 |
}
|
| 771 |
}
|
781 |
}
|
| 772 |
|
782 |
|
| 773 |
List<Activity> allactivities = activityRepository.selectAll(ticketId);
|
783 |
List<Activity> allactivities = activityRepository.selectAll(ticketId);
|
| 774 |
|
784 |
|
| Line 1007... |
Line 1017... |
| 1007 |
}
|
1017 |
}
|
| 1008 |
}
|
1018 |
}
|
| 1009 |
|
1019 |
|
| 1010 |
authUserListMap = csService.getAssignedAuthList(tickets);
|
1020 |
authUserListMap = csService.getAssignedAuthList(tickets);
|
| 1011 |
|
1021 |
|
| - |
|
1022 |
// Find which tickets are assigned to or escalated to this user (can take action)
|
| - |
|
1023 |
Set<Integer> actionableTicketIds = new HashSet<>();
|
| 1012 |
if (tickets.size() > 0) {
|
1024 |
if (tickets.size() > 0) {
|
| - |
|
1025 |
List<TicketAssigned> allAssignments = ticketAssignedRepository.selectByTicketIds(
|
| - |
|
1026 |
tickets.stream().map(Ticket::getId).collect(Collectors.toList()));
|
| - |
|
1027 |
for (TicketAssigned ta : allAssignments) {
|
| - |
|
1028 |
if (ta.getAssineeId() == authUser.getId() || ta.getManagerId() == authUser.getId()) {
|
| - |
|
1029 |
actionableTicketIds.add(ta.getTicketId());
|
| - |
|
1030 |
}
|
| - |
|
1031 |
}
|
| - |
|
1032 |
// Also check escalation chain
|
| - |
|
1033 |
for (Ticket t : tickets) {
|
| - |
|
1034 |
if (t.getL1AuthUser() == authUser.getId() || t.getL2AuthUser() == authUser.getId()
|
| - |
|
1035 |
|| t.getL3AuthUser() == authUser.getId() || t.getL4AuthUser() == authUser.getId()
|
| - |
|
1036 |
|| t.getL5AuthUser() == authUser.getId()) {
|
| - |
|
1037 |
actionableTicketIds.add(t.getId());
|
| - |
|
1038 |
}
|
| - |
|
1039 |
}
|
| 1013 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
|
1040 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
|
| 1014 |
model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
|
1041 |
model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
|
| 1015 |
}
|
1042 |
}
|
| - |
|
1043 |
model.addAttribute("actionableTicketIds", actionableTicketIds);
|
| 1016 |
|
1044 |
|
| 1017 |
// Pagination for partner tickets (in-memory since selectAllOpenTickets doesn't support DB-level pagination)
|
1045 |
// Pagination for partner tickets (in-memory since selectAllOpenTickets doesn't support DB-level pagination)
|
| 1018 |
long totalRecords = tickets.size();
|
1046 |
long totalRecords = tickets.size();
|
| 1019 |
int totalPages = totalRecords > 0 ? (int) Math.ceil((double) totalRecords / 25) : 1;
|
1047 |
int totalPages = totalRecords > 0 ? (int) Math.ceil((double) totalRecords / 25) : 1;
|
| 1020 |
model.addAttribute("totalRecords", totalRecords);
|
1048 |
model.addAttribute("totalRecords", totalRecords);
|