Subversion Repositories SmartDukaan

Rev

Rev 24638 | Rev 24701 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24638 Rev 24699
Line 8... Line 8...
8
import java.util.Optional;
8
import java.util.Optional;
9
import java.util.Set;
9
import java.util.Set;
10
import java.util.stream.Collectors;
10
import java.util.stream.Collectors;
11
 
11
 
12
import javax.servlet.http.HttpServletRequest;
12
import javax.servlet.http.HttpServletRequest;
-
 
13
import javax.swing.SortOrder;
13
 
14
 
14
import org.apache.logging.log4j.LogManager;
15
import org.apache.logging.log4j.LogManager;
15
import org.apache.logging.log4j.Logger;
16
import org.apache.logging.log4j.Logger;
16
import org.springframework.beans.factory.annotation.Autowired;
17
import org.springframework.beans.factory.annotation.Autowired;
17
import org.springframework.mail.javamail.JavaMailSender;
18
import org.springframework.mail.javamail.JavaMailSender;
Line 32... Line 33...
32
import com.spice.profitmandi.dao.entity.cs.Position;
33
import com.spice.profitmandi.dao.entity.cs.Position;
33
import com.spice.profitmandi.dao.entity.cs.Region;
34
import com.spice.profitmandi.dao.entity.cs.Region;
34
import com.spice.profitmandi.dao.entity.cs.Ticket;
35
import com.spice.profitmandi.dao.entity.cs.Ticket;
35
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
36
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
36
import com.spice.profitmandi.dao.entity.cs.TicketCategory;
37
import com.spice.profitmandi.dao.entity.cs.TicketCategory;
-
 
38
import com.spice.profitmandi.dao.entity.cs.TicketSearchType;
37
import com.spice.profitmandi.dao.entity.cs.TicketSubCategory;
39
import com.spice.profitmandi.dao.entity.cs.TicketSubCategory;
38
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
40
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
39
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
41
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
-
 
42
import com.spice.profitmandi.dao.enumuration.cs.TicketStatus;
40
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
43
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
41
import com.spice.profitmandi.dao.repository.cs.ActivityRepository;
44
import com.spice.profitmandi.dao.repository.cs.ActivityRepository;
42
import com.spice.profitmandi.dao.repository.cs.CsService;
45
import com.spice.profitmandi.dao.repository.cs.CsService;
43
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
46
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
44
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
47
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
Line 59... Line 62...
59
public class CsController {
62
public class CsController {
60
 
63
 
61
	private static final Logger LOGGER = LogManager.getLogger(CsController.class);
64
	private static final Logger LOGGER = LogManager.getLogger(CsController.class);
62
 
65
 
63
	private static final String ACTIVITY_SUBJECT = "Message related ticketId#%s";
66
	private static final String ACTIVITY_SUBJECT = "Message related ticketId#%s";
64
	private static final String PARTNER_RESOLVED_TICKET_MAIL="Dear Partner , we have resolved your ticket # %s , request to kindly accept the same. In case you still have any concerns regarding the same pls click on %s so that we can help you.Regards\nSmartdukaan";
67
	private static final String PARTNER_RESOLVED_TICKET_MAIL = "Dear Partner , we have resolved your ticket # %s , request to kindly accept the same. In case you still have any concerns regarding the same pls click on %s so that we can help you.Regards\nSmartdukaan";
65
	private static final String PARTNER_REOPEN="Dear Partner , Your ticket # %s has been re-opened as per your confirmation & we are committed to resolve it on priority.Regards\nSmartdukaan";
68
	private static final String PARTNER_REOPEN = "Dear Partner , Your ticket # %s has been re-opened as per your confirmation & we are committed to resolve it on priority.Regards\nSmartdukaan";
66
	private static final String INTERNAL_REOPEN_MAIL="Hi, Pls note that the ticket # %s has been re-opened by %s , pls respond on priority.";
69
	private static final String INTERNAL_REOPEN_MAIL = "Hi, Pls note that the ticket # %s has been re-opened by %s , pls respond on priority.";
67
	private static final String INTERNAL_REOPEN_ACTIVITY_MESSAGE="Hi,My ticket is not resolved yet,so I am reopenning ticket";
70
	private static final String INTERNAL_REOPEN_ACTIVITY_MESSAGE = "Hi,My ticket is not resolved yet,so I am reopenning ticket";
68
	
71
 
69
	@Autowired
72
	@Autowired
70
	JavaMailSender mailSender;
73
	JavaMailSender mailSender;
71
 
74
 
72
	@Autowired
75
	@Autowired
73
	private CsService csService;
76
	private CsService csService;
Line 318... Line 321...
318
	@PostMapping(value = "/cs/createTicket")
321
	@PostMapping(value = "/cs/createTicket")
319
	public String createTicket(HttpServletRequest request, @RequestParam(name = "categoryId") int categoryId,
322
	public String createTicket(HttpServletRequest request, @RequestParam(name = "categoryId") int categoryId,
320
			@RequestParam(name = "subCategoryId") int subCategoryId, @RequestParam(name = "message") String message,
323
			@RequestParam(name = "subCategoryId") int subCategoryId, @RequestParam(name = "message") String message,
321
			Model model) throws Exception {
324
			Model model) throws Exception {
322
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
325
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
323
		List<Ticket> tickets = ticketRepository.selectAllByCreator(loginDetails.getFofoId(), Optional.of(true), 0, 10);
326
		List<Ticket> tickets = ticketRepository.selectAllByCreator(loginDetails.getFofoId(), Optional.of(true),SortOrder.DESCENDING,0, 10);
324
		if (tickets.size() > 3 || tickets.size() == 3) {
327
		if (tickets.size() > 3 || tickets.size() == 3) {
325
			model.addAttribute("response", mvcResponseSender.createResponseString(false));
328
			model.addAttribute("response", mvcResponseSender.createResponseString(false));
326
		} else {
329
		} else {
327
			csService.createTicket(loginDetails.getFofoId(), categoryId, subCategoryId, message);
330
			csService.createTicket(loginDetails.getFofoId(), categoryId, subCategoryId, message);
328
			model.addAttribute("response", mvcResponseSender.createResponseString(true));
331
			model.addAttribute("response", mvcResponseSender.createResponseString(true));
329
		}
332
		}
330
		return "response";
333
		return "response";
331
	}
334
	}
332
 
335
 
333
	@GetMapping(value = "/cs/myticket")
336
	@GetMapping(value = "/cs/myticket")
-
 
337
	public String getTicket(HttpServletRequest request,
-
 
338
			@RequestParam(name = "orderby", defaultValue = "DESCENDING") SortOrder sortOrder,
-
 
339
			@RequestParam(name = "ticketStatus", defaultValue = "OPENED") TicketStatus ticketStatus,
334
	public String getMyTicket(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
340
			@RequestParam(name = "offset", defaultValue = "0") int offset,
335
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
341
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
336
			throws ProfitMandiBusinessException {
342
			throws ProfitMandiBusinessException {
337
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
343
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
338
		List<Ticket> tickets = null;
344
		List<Ticket> tickets = null;
339
		List<TicketAssigned> ticketAssigneds = null;
345
		List<TicketAssigned> ticketAssigneds = null;
340
		List<Integer> ticketIds = null;
346
		//List<Integer> ticketIds = null;
341
		long size = 0;
347
		long size = 0;
342
		Map<Integer, AuthUser> authUserIdAndAuthUserMap = null;
348
		Map<Integer, AuthUser> authUserIdAndAuthUserMap = null;
343
		// LOGGER.info(roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))));
349
		// LOGGER.info(roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))));
344
		if (roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))) {
350
		if (roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))) {
345
			AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
351
			AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
346
			ticketAssigneds = ticketAssignedRepository.selectByAssigneeId(authUser.getId(), offset, limit);
352
			LOGGER.info(ticketStatus);
347
			ticketIds = ticketAssigneds.stream().map(x -> x.getTicketId()).collect(Collectors.toList());
353
			LOGGER.info(sortOrder);
348
			tickets = ticketRepository.selectAllByTicketIds(ticketIds);
354
			tickets = ticketRepository.selectAllByAssignee(authUser.getId(),
-
 
355
					Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), sortOrder, offset, limit);
349
			size = ticketAssignedRepository.selectCountByAssigneeId(authUser.getId());
356
			size = ticketRepository.selectAllCountByAssignee(authUser.getId(),Optional.of(TicketStatus.CLOSED.equals(ticketStatus)));
350
			LOGGER.info(size + "size");
357
			LOGGER.info(size + "size");
-
 
358
			ticketAssigneds=ticketAssignedRepository.selectByTicketIds(tickets.stream().map(x->x.getId()).collect(Collectors.toList()));
351
			authUserIdAndAuthUserMap = csService.getAuthUserIdAndAuthUserMap(ticketAssigneds);
359
			authUserIdAndAuthUserMap = csService.getAuthUserIdAndAuthUserMap(ticketAssigneds);
352
			Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
360
			Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
353
			model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
361
			model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
354
 
362
 
355
		} else {
363
		} else {
-
 
364
			LOGGER.info(ticketStatus);
-
 
365
			LOGGER.info(sortOrder);
-
 
366
			LOGGER.info(TicketStatus.CLOSED.equals(ticketStatus));
356
			tickets = ticketRepository.selectAllByCreator(loginDetails.getFofoId(), Optional.empty(), offset, limit);
367
			tickets = ticketRepository.selectAllByCreator(loginDetails.getFofoId(),
357
			authUserIdAndAuthUserMap = csService.getTicketIdAndAuthUserMapUsingTickets(tickets);
368
					Optional.of(TicketStatus.CLOSED.equals(ticketStatus)),sortOrder,offset, limit);
358
			size = ticketRepository.selectAllCountByCreator(loginDetails.getFofoId(), Optional.empty());
369
			size = ticketRepository.selectAllCountByCreator(loginDetails.getFofoId(),
359
 
-
 
-
 
370
					Optional.of(TicketStatus.CLOSED.equals(ticketStatus)));
360
		}
371
		}
-
 
372
		authUserIdAndAuthUserMap = csService.getTicketIdAndAuthUserMapUsingTickets(tickets);
-
 
373
 
361
		if (size < limit) {
374
		if (size < limit) {
362
			model.addAttribute("end", offset + size);
375
			model.addAttribute("end", offset + size);
363
		} else {
376
		} else {
364
			model.addAttribute("end", offset + limit);
377
			model.addAttribute("end", offset + limit);
365
		}
378
		}
Line 372... Line 385...
372
		model.addAttribute("resolved", ActivityType.RESOLVED);
385
		model.addAttribute("resolved", ActivityType.RESOLVED);
373
		model.addAttribute("resolved-accepted", ActivityType.RESOLVED_ACCEPTED);
386
		model.addAttribute("resolved-accepted", ActivityType.RESOLVED_ACCEPTED);
374
		model.addAttribute("resolved-rejected", ActivityType.RESOLVED_REJECTED);
387
		model.addAttribute("resolved-rejected", ActivityType.RESOLVED_REJECTED);
375
		model.addAttribute("authUserIdAndAuthUserMap", authUserIdAndAuthUserMap);
388
		model.addAttribute("authUserIdAndAuthUserMap", authUserIdAndAuthUserMap);
376
		model.addAttribute("subCategoryIdAndSubCategoryMap", subCategoryIdAndSubCategoryMap);
389
		model.addAttribute("subCategoryIdAndSubCategoryMap", subCategoryIdAndSubCategoryMap);
-
 
390
		model.addAttribute("ticketStatusValues", TicketStatus.values());
-
 
391
		model.addAttribute("orderByValues", SortOrder.values());
-
 
392
		model.addAttribute("selectedticketStatus", ticketStatus);
-
 
393
		model.addAttribute("selectedorderby", sortOrder);
377
		return "ticket";
394
		return "ticket";
378
	}
395
	}
379
 
396
 
380
	@GetMapping(value = "/cs/myticketPaginated")
397
	@GetMapping(value = "/cs/myticketPaginated")
381
	public String getMyTicketPaginated(HttpServletRequest request,
398
	public String getMyTicketPaginated(HttpServletRequest request,
-
 
399
			@RequestParam(name = "orderby", defaultValue = "DESCENDING") SortOrder sortOrder,
-
 
400
			@RequestParam(name = "ticketStatus", defaultValue = "OPENED") TicketStatus ticketStatus,
382
			@RequestParam(name = "offset", defaultValue = "0") int offset,
401
			@RequestParam(name = "offset", defaultValue = "0") int offset,
383
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
402
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
384
			throws ProfitMandiBusinessException {
403
			throws ProfitMandiBusinessException {
385
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
404
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
386
		List<Ticket> tickets = null;
405
		List<Ticket> tickets = null;
387
		List<TicketAssigned> ticketAssigneds = null;
406
		List<TicketAssigned> ticketAssigneds = null;
388
		List<Integer> ticketIds = null;
407
		//List<Integer> ticketIds = null;
389
		Map<Integer, AuthUser> authUserIdAndAuthUserMap = null;
408
		Map<Integer, AuthUser> authUserIdAndAuthUserMap = null;
390
		// LOGGER.info(roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))));
409
		// LOGGER.info(roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))));
391
		if (roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))) {
410
		if (roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))) {
392
			AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
411
			AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
393
			ticketAssigneds = ticketAssignedRepository.selectByAssigneeId(authUser.getId(), offset, limit);
412
			tickets = ticketRepository.selectAllByAssignee(authUser.getId(),
394
			ticketIds = ticketAssigneds.stream().map(x -> x.getTicketId()).collect(Collectors.toList());
413
					Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), sortOrder, offset, limit);
395
			tickets = ticketRepository.selectAllByTicketIds(ticketIds);
414
			ticketAssigneds=ticketAssignedRepository.selectByTicketIds(tickets.stream().map(x->x.getId()).collect(Collectors.toList()));
396
			authUserIdAndAuthUserMap = csService.getAuthUserIdAndAuthUserMap(ticketAssigneds);
415
			authUserIdAndAuthUserMap = csService.getAuthUserIdAndAuthUserMap(ticketAssigneds);
397
			Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
416
			Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
398
			model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
417
			model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
399
		} else {
418
		} else {
400
			tickets = ticketRepository.selectAllByCreator(loginDetails.getFofoId(), Optional.empty(), offset, limit);
419
			tickets = ticketRepository.selectAllByCreator(loginDetails.getFofoId(), Optional.of(TicketStatus.CLOSED.equals(ticketStatus)),sortOrder,offset, limit);
401
			authUserIdAndAuthUserMap = csService.getTicketIdAndAuthUserMapUsingTickets(tickets);
420
			authUserIdAndAuthUserMap = csService.getTicketIdAndAuthUserMapUsingTickets(tickets);
402
		}
421
		}
403
		model.addAttribute("roleType", roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds())));
422
		model.addAttribute("roleType", roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds())));
404
		Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = csService
423
		Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = csService
405
				.getSubCategoryIdAndSubCategoryMap(tickets);
424
				.getSubCategoryIdAndSubCategoryMap(tickets);
406
		model.addAttribute("tickets", tickets);
425
		model.addAttribute("tickets", tickets);
407
		model.addAttribute("authUserIdAndAuthUserMap", authUserIdAndAuthUserMap);
426
		model.addAttribute("authUserIdAndAuthUserMap", authUserIdAndAuthUserMap);
408
		model.addAttribute("subCategoryIdAndSubCategoryMap", subCategoryIdAndSubCategoryMap);
427
		model.addAttribute("subCategoryIdAndSubCategoryMap", subCategoryIdAndSubCategoryMap);
-
 
428
		model.addAttribute("resolved", ActivityType.RESOLVED);
-
 
429
		model.addAttribute("resolved-accepted", ActivityType.RESOLVED_ACCEPTED);
-
 
430
		model.addAttribute("resolved-rejected", ActivityType.RESOLVED_REJECTED);
409
		return "ticket-paginated";
431
		return "ticket-paginated";
410
	}
432
	}
411
 
433
 
412
	@GetMapping(value = "/cs/getActivities")
434
	@GetMapping(value = "/cs/getActivities")
413
	public String getActivity(HttpServletRequest request,
435
	public String getActivity(HttpServletRequest request,
Line 495... Line 517...
495
		return "response";
517
		return "response";
496
	}
518
	}
497
 
519
 
498
	@GetMapping(value = "/cs/managerTicket")
520
	@GetMapping(value = "/cs/managerTicket")
499
	public String getL2L3AndL4Tickets(HttpServletRequest request,
521
	public String getL2L3AndL4Tickets(HttpServletRequest request,
-
 
522
			@RequestParam(name = "orderby", defaultValue = "DESCENDING") SortOrder sortOrder,
-
 
523
			@RequestParam(name = "ticketStatus", defaultValue = "OPENED") TicketStatus ticketStatus,
500
			@RequestParam(name = "offset", defaultValue = "0") int offset,
524
			@RequestParam(name = "offset", defaultValue = "0") int offset,
501
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
525
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
502
			throws ProfitMandiBusinessException {
526
			throws ProfitMandiBusinessException {
503
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
527
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
504
		long size = 0;
528
		long size = 0;
Line 508... Line 532...
508
		if (loginDetails.getEmailId().equals("amandeep.singh@smartdukaan.com")) {
532
		if (loginDetails.getEmailId().equals("amandeep.singh@smartdukaan.com")) {
509
			tickets = ticketRepository.selectAll(offset, limit, Optional.empty());
533
			tickets = ticketRepository.selectAll(offset, limit, Optional.empty());
510
			authUserListMap = csService.getAuthUserList(tickets, authUser);
534
			authUserListMap = csService.getAuthUserList(tickets, authUser);
511
			size = ticketRepository.selectAllCount();
535
			size = ticketRepository.selectAllCount();
512
		} else {
536
		} else {
513
			tickets = ticketRepository.selectAllByEscalatedUserType(authUser.getId(), offset, limit);
537
			tickets = ticketRepository.selectAllManagerTicket(authUser.getId(), sortOrder, Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), offset, limit);
514
			authUserListMap = csService.getAuthUserList(tickets, authUser);
538
			authUserListMap = csService.getAuthUserList(tickets, authUser);
515
			size = ticketRepository.selectAllCountByEscalatedUserType(authUser.getId());
539
			size = ticketRepository.selectAllCountByManagerTicket(authUser.getId(), Optional.of(TicketStatus.CLOSED.equals(ticketStatus)));
516
			if (tickets.size() > 0) {
540
			if (tickets.size() > 0) {
517
				Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
541
				Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
518
				model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
542
				model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
519
			}
543
			}
520
		}
544
		}
Line 527... Line 551...
527
		model.addAttribute("size", size);
551
		model.addAttribute("size", size);
528
		model.addAttribute("tickets", tickets);
552
		model.addAttribute("tickets", tickets);
529
 
553
 
530
		Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = csService
554
		Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = csService
531
				.getSubCategoryIdAndSubCategoryMap(tickets);
555
				.getSubCategoryIdAndSubCategoryMap(tickets);
-
 
556
		model.addAttribute("ticketStatusValues", TicketStatus.values());
-
 
557
		model.addAttribute("orderByValues", SortOrder.values());
-
 
558
		model.addAttribute("selectedticketStatus", ticketStatus);
-
 
559
		model.addAttribute("selectedorderby", sortOrder);
532
		model.addAttribute("tickets", tickets);
560
		model.addAttribute("tickets", tickets);
533
		model.addAttribute("authUserListMap", authUserListMap);
561
		model.addAttribute("authUserListMap", authUserListMap);
534
		model.addAttribute("subCategoryIdAndSubCategoryMap", subCategoryIdAndSubCategoryMap);
562
		model.addAttribute("subCategoryIdAndSubCategoryMap", subCategoryIdAndSubCategoryMap);
535
		return "managerTicket";
563
		return "managerTicket";
536
	}
564
	}
537
 
565
 
538
	@GetMapping(value = "/cs/managerTicket-paginated")
566
	@GetMapping(value = "/cs/managerTicket-paginated")
539
	public String getL2L3AndL4TicketsPaginated(HttpServletRequest request,
567
	public String getL2L3AndL4TicketsPaginated(HttpServletRequest request,
-
 
568
			@RequestParam(name = "orderby", defaultValue = "DESCENDING") SortOrder sortOrder,
-
 
569
			@RequestParam(name = "ticketStatus", defaultValue = "OPENED") TicketStatus ticketStatus,
540
			@RequestParam(name = "offset", defaultValue = "0") int offset,
570
			@RequestParam(name = "offset", defaultValue = "0") int offset,
541
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
571
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
542
			throws ProfitMandiBusinessException {
572
			throws ProfitMandiBusinessException {
543
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
573
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
544
		AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
574
		AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
Line 546... Line 576...
546
		List<Ticket> tickets = null;
576
		List<Ticket> tickets = null;
547
		if (loginDetails.getEmailId().equals("amandeep.singh@smartdukaan.com")) {
577
		if (loginDetails.getEmailId().equals("amandeep.singh@smartdukaan.com")) {
548
			tickets = ticketRepository.selectAll(offset, limit, Optional.empty());
578
			tickets = ticketRepository.selectAll(offset, limit, Optional.empty());
549
			authUserListMap = csService.getAuthUserList(tickets, authUser);
579
			authUserListMap = csService.getAuthUserList(tickets, authUser);
550
		} else {
580
		} else {
551
 
581
			
552
			tickets = ticketRepository.selectAllByEscalatedUserType(authUser.getId(), offset, limit);
582
			tickets = ticketRepository.selectAllManagerTicket(authUser.getId(), sortOrder, Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), offset, limit);
553
			authUserListMap = csService.getAuthUserList(tickets, authUser);
583
			authUserListMap = csService.getAuthUserList(tickets, authUser);
554
			if (tickets.size() > 0) {
584
			if (tickets.size() > 0) {
555
				Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
585
				Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
556
				model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
586
				model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
557
			}
587
			}
Line 629... Line 659...
629
		Activity activity = new Activity();
659
		Activity activity = new Activity();
630
		String subject = String.format(ACTIVITY_SUBJECT, ticket.getId());
660
		String subject = String.format(ACTIVITY_SUBJECT, ticket.getId());
631
		if (roleManager.isAdmin(loginDetails.getRoleIds())) {
661
		if (roleManager.isAdmin(loginDetails.getRoleIds())) {
632
			ticket.setLastActivity(lastActivity);
662
			ticket.setLastActivity(lastActivity);
633
			String to = retailerService.getFofoRetailer(ticket.getFofoId()).getEmail();
663
			String to = retailerService.getFofoRetailer(ticket.getFofoId()).getEmail();
634
			String message = String.format(PARTNER_RESOLVED_TICKET_MAIL,ticketId,"REOPEN");
664
			String message = String.format(PARTNER_RESOLVED_TICKET_MAIL, ticketId, "REOPEN");
635
			activity.setMessage(message);
665
			activity.setMessage(message);
636
			activity.setCreatedBy(authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getId());
666
			activity.setCreatedBy(authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getId());
637
			activity.setTicketId(ticketId);
667
			activity.setTicketId(ticketId);
638
			activity.setCreateTimestamp(LocalDateTime.now());
668
			activity.setCreateTimestamp(LocalDateTime.now());
639
			activity.setType(ActivityType.COMMUNICATION_OUT);
669
			activity.setType(ActivityType.COMMUNICATION_OUT);
Line 646... Line 676...
646
				activity.setCreatedBy(0);
676
				activity.setCreatedBy(0);
647
				activity.setTicketId(ticketId);
677
				activity.setTicketId(ticketId);
648
				activity.setType(ActivityType.COMMUNICATION_IN);
678
				activity.setType(ActivityType.COMMUNICATION_IN);
649
				activity.setCreateTimestamp(LocalDateTime.now());
679
				activity.setCreateTimestamp(LocalDateTime.now());
650
			} else {
680
			} else {
-
 
681
				String message = String.format(INTERNAL_REOPEN_MAIL, ticketId,
651
				String message = String.format(INTERNAL_REOPEN_MAIL,ticketId,retailerService.getFofoRetailer(loginDetails.getFofoId()).getBusinessName());
682
						retailerService.getFofoRetailer(loginDetails.getFofoId()).getBusinessName());
652
				String to = authRepository.selectById(ticket.getL1AuthUser()).getEmailId();
683
				String to = authRepository.selectById(ticket.getL1AuthUser()).getEmailId();
653
				String cc[] = { authRepository.selectById(ticket.getL2AuthUser()).getEmailId(),
684
				String cc[] = { authRepository.selectById(ticket.getL2AuthUser()).getEmailId(),
654
						authRepository.selectById(ticket.getL3AuthUser()).getEmailId() };
685
						authRepository.selectById(ticket.getL3AuthUser()).getEmailId() };
655
				ticket.setLastActivity(lastActivity);
686
				ticket.setLastActivity(lastActivity);
656
				ticket.setUpdateTimestamp(LocalDateTime.now());
687
				ticket.setUpdateTimestamp(LocalDateTime.now());
657
				ticket.setL2EscalationTimestamp(ticket.getUpdateTimestamp().plusDays(2));
688
				ticket.setL2EscalationTimestamp(ticket.getUpdateTimestamp().plusDays(2));
658
				ticket.setL3EscalationTimestamp(ticket.getL2EscalationTimestamp().plusDays(2));
689
				ticket.setL3EscalationTimestamp(ticket.getL2EscalationTimestamp().plusDays(2));
659
				ticket.setLastEscalationTimestamp(ticket.getL3EscalationTimestamp().plusDays(2));
690
				ticket.setLastEscalationTimestamp(ticket.getL3EscalationTimestamp().plusDays(2));
660
				ticketAssignedRepository.deleteByTicketId(ticketId);
691
				ticketAssignedRepository.deleteByTicketId(ticketId);
661
				TicketAssigned ticketAssigned=new TicketAssigned();
692
				TicketAssigned ticketAssigned = new TicketAssigned();
662
				ticketAssigned.setAssineeId(ticket.getL1AuthUser());
693
				ticketAssigned.setAssineeId(ticket.getL1AuthUser());
663
				ticketAssigned.setTicketId(ticketId);
694
				ticketAssigned.setTicketId(ticketId);
664
				ticketAssignedRepository.persist(ticketAssigned);
695
				ticketAssignedRepository.persist(ticketAssigned);
665
				activity.setMessage(INTERNAL_REOPEN_ACTIVITY_MESSAGE);
696
				activity.setMessage(INTERNAL_REOPEN_ACTIVITY_MESSAGE);
666
				activity.setCreatedBy(0);
697
				activity.setCreatedBy(0);
667
				activity.setTicketId(ticketId);
698
				activity.setTicketId(ticketId);
668
				activity.setType(ActivityType.COMMUNICATION_IN);
699
				activity.setType(ActivityType.COMMUNICATION_IN);
669
				activity.setCreateTimestamp(LocalDateTime.now());
700
				activity.setCreateTimestamp(LocalDateTime.now());
670
				this.activityRelatedMail(to, cc, subject, message);
701
				this.activityRelatedMail(to, cc, subject, message);
671
				this.activityRelatedMail(retailerService.getFofoRetailer(loginDetails.getFofoId()).getEmail(), null, subject, String.format(PARTNER_REOPEN, ticketId));
702
				this.activityRelatedMail(retailerService.getFofoRetailer(loginDetails.getFofoId()).getEmail(), null,
-
 
703
						subject, String.format(PARTNER_REOPEN, ticketId));
672
			}
704
			}
673
 
705
 
674
		}
706
		}
675
		ticketRepository.persist(ticket);
707
		ticketRepository.persist(ticket);
676
		activityRepository.persist(activity);
708
		activityRepository.persist(activity);