| Line 594... |
Line 594... |
| 594 |
@RequestParam(name = "assigneeId", defaultValue = "0") int assigneeId,
|
594 |
@RequestParam(name = "assigneeId", defaultValue = "0") int assigneeId,
|
| 595 |
@RequestParam(name = "internal", defaultValue = "true") boolean internal,
|
595 |
@RequestParam(name = "internal", defaultValue = "true") boolean internal,
|
| 596 |
@RequestParam(name = "message", defaultValue = "") String message, Model model) throws Exception {
|
596 |
@RequestParam(name = "message", defaultValue = "") String message, Model model) throws Exception {
|
| 597 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
597 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 598 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
598 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
| - |
|
599 |
List<TicketAssigned> ticketAssignedList = ticketAssignedRepository.selectByTicketIds(Arrays.asList(ticketId));
|
| - |
|
600 |
List<Integer>authUserIds = Arrays.asList(ticket.getId());
|
| - |
|
601 |
authUserIds.add(assigneeId);
|
| - |
|
602 |
Map<Integer, AuthUser> authUsersMap = authRepository.selectAllAuthUserByIds(authUserIds).stream().collect(Collectors.toMap(x->x.getId(), x->x));
|
| 599 |
if (ticket.getCloseTimestamp() == null) {
|
603 |
if (ticket.getCloseTimestamp() == null) {
|
| 600 |
Activity activity = new Activity();
|
604 |
Activity activity = new Activity();
|
| 601 |
activity.setCreatedBy(0);
|
605 |
activity.setCreatedBy(0);
|
| 602 |
activity.setCreateTimestamp(LocalDateTime.now());
|
606 |
activity.setCreateTimestamp(LocalDateTime.now());
|
| 603 |
activity.setMessage(message);
|
607 |
String subject = null;
|
| 604 |
if (!roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))) {
|
608 |
if (!roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))) {
|
| - |
|
609 |
CustomRetailer customRetailer = retailerService.getFofoRetailers(true).get(loginDetails.getFofoId());
|
| 605 |
activity.setType(ActivityType.COMMUNICATION_IN);
|
610 |
activity.setType(ActivityType.COMMUNICATION_IN);
|
| 606 |
AuthUser authUser = authRepository.selectById(ticket.getL1AuthUser());
|
611 |
subject = String.format("Ticket Update #%s by franchisee %s", ticket.getId(), customRetailer.getBusinessName() + "("+customRetailer.getCode()+")");
|
| 607 |
String subject = String.format(ACTIVITY_SUBJECT, ticket.getId());
|
612 |
message = String.format("Franchisee message - %s", message);
|
| 608 |
String[] cc = { authRepository.selectById(ticket.getL2AuthUser()).getEmailId(),
|
- |
|
| 609 |
authRepository.selectById(ticket.getL3AuthUser()).getEmailId() };
|
- |
|
| 610 |
// LOGGER.info(authUser.getEmailId()+" "+cc+" "+subject+" "+message);
|
- |
|
| 611 |
// this.activityRelatedMail(authUser.getEmailId(), cc, subject, message);
|
613 |
activity.setMessage(message);
|
| 612 |
model.addAttribute("response", mvcResponseSender.createResponseString(authUser));
|
- |
|
| 613 |
} else {
|
614 |
} else {
|
| 614 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
615 |
AuthUser authUser = authUsersMap.remove(assigneeId);
|
| 615 |
activity.setCreatedBy(authUser.getId());
|
616 |
activity.setCreatedBy(assigneeId);
|
| - |
|
617 |
subject = String.format("Ticket Update #%s by %s", ticket.getId(), authUser.getName());
|
| - |
|
618 |
message = String.format("%s's message - %s", authUser.getFirstName(), message);
|
| 616 |
if (internal) {
|
619 |
if (internal) {
|
| 617 |
activity.setType(ActivityType.COMMUNICATION_INTERNAL);
|
620 |
activity.setType(ActivityType.COMMUNICATION_INTERNAL);
|
| 618 |
// String subject = String.format(ACTIVITY_SUBJECT, ticket.getId());
|
621 |
// String subject = String.format(ACTIVITY_SUBJECT, ticket.getId());
|
| 619 |
} else {
|
622 |
} else {
|
| 620 |
activity.setType(ActivityType.COMMUNICATION_OUT);
|
623 |
activity.setType(ActivityType.COMMUNICATION_OUT);
|
| 621 |
}
|
624 |
}
|
| 622 |
model.addAttribute("response", mvcResponseSender.createResponseString(authUser));
|
- |
|
| 623 |
}
|
625 |
}
|
| 624 |
activityRepository.persist(activity);
|
626 |
activityRepository.persist(activity);
|
| 625 |
csService.addActivity(ticket, activity);
|
627 |
csService.addActivity(ticket, activity);
|
| - |
|
628 |
AuthUser authUser = authUsersMap.remove(authUserIds.get(0));
|
| - |
|
629 |
model.addAttribute("response", mvcResponseSender.createResponseString(authUser));
|
| - |
|
630 |
String [] cc = authUsersMap.entrySet().stream().map(x->x.getValue().getEmailId()).toArray(String[]::new);
|
| - |
|
631 |
this.activityRelatedMail(authUser.getEmailId(), cc, subject, message);
|
| 626 |
} else {
|
632 |
} else {
|
| 627 |
throw new ProfitMandiBusinessException("Ticket", ticket.getId(), "Already closed ticket");
|
633 |
throw new ProfitMandiBusinessException("Ticket", ticket.getId(), "Already closed ticket");
|
| 628 |
}
|
634 |
}
|
| 629 |
return "response";
|
635 |
return "response";
|
| 630 |
}
|
636 |
}
|