| 24417 |
govind |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
|
|
3 |
import java.time.LocalDateTime;
|
| 24572 |
amit.gupta |
4 |
import java.util.ArrayList;
|
| 24417 |
govind |
5 |
import java.util.HashSet;
|
|
|
6 |
import java.util.List;
|
|
|
7 |
import java.util.Map;
|
|
|
8 |
import java.util.Optional;
|
| 24572 |
amit.gupta |
9 |
import java.util.Set;
|
| 24500 |
govind |
10 |
import java.util.stream.Collectors;
|
| 24417 |
govind |
11 |
|
|
|
12 |
import javax.servlet.http.HttpServletRequest;
|
| 24699 |
govind |
13 |
import javax.swing.SortOrder;
|
| 24417 |
govind |
14 |
|
|
|
15 |
import org.apache.logging.log4j.LogManager;
|
|
|
16 |
import org.apache.logging.log4j.Logger;
|
|
|
17 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 24620 |
govind |
18 |
import org.springframework.mail.javamail.JavaMailSender;
|
| 24417 |
govind |
19 |
import org.springframework.stereotype.Controller;
|
|
|
20 |
import org.springframework.transaction.annotation.Transactional;
|
|
|
21 |
import org.springframework.ui.Model;
|
| 24471 |
govind |
22 |
import org.springframework.web.bind.annotation.DeleteMapping;
|
| 24417 |
govind |
23 |
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
24 |
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
25 |
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
26 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
27 |
|
|
|
28 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
29 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 24620 |
govind |
30 |
import com.spice.profitmandi.common.util.Utils;
|
| 24417 |
govind |
31 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
|
|
32 |
import com.spice.profitmandi.dao.entity.cs.Activity;
|
|
|
33 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
|
|
34 |
import com.spice.profitmandi.dao.entity.cs.Region;
|
|
|
35 |
import com.spice.profitmandi.dao.entity.cs.Ticket;
|
| 24500 |
govind |
36 |
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
|
| 24417 |
govind |
37 |
import com.spice.profitmandi.dao.entity.cs.TicketCategory;
|
|
|
38 |
import com.spice.profitmandi.dao.entity.cs.TicketSubCategory;
|
|
|
39 |
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
|
|
|
40 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 24699 |
govind |
41 |
import com.spice.profitmandi.dao.enumuration.cs.TicketStatus;
|
| 24417 |
govind |
42 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
|
|
43 |
import com.spice.profitmandi.dao.repository.cs.ActivityRepository;
|
|
|
44 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 24557 |
govind |
45 |
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
|
| 24417 |
govind |
46 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
|
|
47 |
import com.spice.profitmandi.dao.repository.cs.RegionRepository;
|
| 24500 |
govind |
48 |
import com.spice.profitmandi.dao.repository.cs.TicketAssignedRepository;
|
| 24417 |
govind |
49 |
import com.spice.profitmandi.dao.repository.cs.TicketCategoryRepository;
|
|
|
50 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
|
|
51 |
import com.spice.profitmandi.dao.repository.cs.TicketSubCategoryRepository;
|
|
|
52 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
|
|
53 |
import com.spice.profitmandi.service.slab.TargetSlabService;
|
|
|
54 |
import com.spice.profitmandi.service.user.RetailerService;
|
|
|
55 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
56 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
|
|
57 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
|
|
58 |
|
|
|
59 |
@Controller
|
|
|
60 |
@Transactional(rollbackFor = Throwable.class)
|
|
|
61 |
public class CsController {
|
|
|
62 |
|
|
|
63 |
private static final Logger LOGGER = LogManager.getLogger(CsController.class);
|
|
|
64 |
|
| 24620 |
govind |
65 |
private static final String ACTIVITY_SUBJECT = "Message related ticketId#%s";
|
| 24699 |
govind |
66 |
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_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 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_ACTIVITY_MESSAGE = "Hi,My ticket is not resolved yet,so I am reopenning ticket";
|
|
|
70 |
|
| 24417 |
govind |
71 |
@Autowired
|
| 24620 |
govind |
72 |
JavaMailSender mailSender;
|
|
|
73 |
|
|
|
74 |
@Autowired
|
| 24417 |
govind |
75 |
private CsService csService;
|
|
|
76 |
|
|
|
77 |
@Autowired
|
|
|
78 |
private CookiesProcessor cookiesProcessor;
|
|
|
79 |
|
|
|
80 |
@Autowired
|
|
|
81 |
private TicketCategoryRepository ticketCategoryRepository;
|
|
|
82 |
|
|
|
83 |
@Autowired
|
|
|
84 |
private TicketSubCategoryRepository ticketSubCategoryRepository;
|
|
|
85 |
|
|
|
86 |
@Autowired
|
|
|
87 |
private RegionRepository regionRepository;
|
|
|
88 |
|
|
|
89 |
@Autowired
|
|
|
90 |
private TargetSlabService targetSlabService;
|
|
|
91 |
|
|
|
92 |
@Autowired
|
|
|
93 |
private RetailerService retailerService;
|
|
|
94 |
|
|
|
95 |
@Autowired
|
|
|
96 |
private MVCResponseSender mvcResponseSender;
|
|
|
97 |
|
|
|
98 |
@Autowired
|
|
|
99 |
private AuthRepository authRepository;
|
|
|
100 |
|
|
|
101 |
@Autowired
|
|
|
102 |
private PositionRepository positionRepository;
|
|
|
103 |
|
|
|
104 |
@Autowired
|
|
|
105 |
private TicketRepository ticketRepository;
|
|
|
106 |
|
|
|
107 |
@Autowired
|
|
|
108 |
private RoleManager roleManager;
|
|
|
109 |
|
|
|
110 |
@Autowired
|
|
|
111 |
private ActivityRepository activityRepository;
|
|
|
112 |
|
| 24500 |
govind |
113 |
@Autowired
|
|
|
114 |
private TicketAssignedRepository ticketAssignedRepository;
|
| 24569 |
govind |
115 |
|
|
|
116 |
@Autowired
|
| 24557 |
govind |
117 |
private PartnerRegionRepository partnerRegionRepository;
|
| 24500 |
govind |
118 |
|
| 24417 |
govind |
119 |
@GetMapping(value = "/cs/createCategory")
|
|
|
120 |
public String getCreateCategory(HttpServletRequest request, Model model) {
|
|
|
121 |
List<TicketCategory> ticketCategories = ticketCategoryRepository.selectAll();
|
|
|
122 |
model.addAttribute("ticketCategories", ticketCategories);
|
|
|
123 |
return "create-ticket-category";
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
@PostMapping(value = "/cs/createCategory")
|
|
|
127 |
public String createCategory(HttpServletRequest request, @RequestParam(name = "name") String name,
|
|
|
128 |
@RequestParam(name = "description") String description, Model model) throws ProfitMandiBusinessException {
|
|
|
129 |
|
|
|
130 |
TicketCategory ticketCategory = ticketCategoryRepository.selectByName(name);
|
|
|
131 |
if (ticketCategory != null) {
|
|
|
132 |
throw new ProfitMandiBusinessException("name", name, "already exists!");
|
|
|
133 |
}
|
|
|
134 |
ticketCategory = new TicketCategory();
|
|
|
135 |
ticketCategory.setName(name);
|
|
|
136 |
ticketCategory.setDescription(description);
|
|
|
137 |
ticketCategoryRepository.persist(ticketCategory);
|
|
|
138 |
return "create-ticket-category";
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
@GetMapping(value = "/cs/createSubCategory")
|
|
|
142 |
public String getCreateSubCategory(HttpServletRequest request, Model model) {
|
|
|
143 |
List<TicketCategory> ticketCategories = ticketCategoryRepository.selectAll();
|
|
|
144 |
model.addAttribute("ticketCategories", ticketCategories);
|
|
|
145 |
return "create-ticket-sub-category";
|
|
|
146 |
}
|
|
|
147 |
|
|
|
148 |
@GetMapping(value = "/cs/getSubCategoryByCategoryId")
|
|
|
149 |
public String getSubCategoryByCategoryId(HttpServletRequest request,
|
|
|
150 |
@RequestParam(name = "ticketCategoryId", defaultValue = "") int ticketCategoryId, Model model) {
|
|
|
151 |
List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository.selectAll(ticketCategoryId);
|
|
|
152 |
TicketCategory ticketCategory = ticketCategoryRepository.selectById(ticketCategoryId);
|
|
|
153 |
model.addAttribute("ticketSubCategories", ticketSubCategories);
|
|
|
154 |
model.addAttribute("ticketCategory", ticketCategory);
|
|
|
155 |
return "ticket-sub-category";
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
@PostMapping(value = "/cs/createSubCategory")
|
|
|
159 |
public String createSubCategory(HttpServletRequest request,
|
|
|
160 |
@RequestParam(name = "categoryId", defaultValue = "0") int categoryId,
|
|
|
161 |
@RequestParam(name = "name") String name, @RequestParam(name = "description") String description,
|
|
|
162 |
Model model) throws ProfitMandiBusinessException {
|
|
|
163 |
|
|
|
164 |
TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.selectTicketSubCategory(categoryId, name);
|
|
|
165 |
if (ticketSubCategory != null) {
|
|
|
166 |
throw new ProfitMandiBusinessException("name & categoryId", name + " " + categoryId, "already exists!");
|
|
|
167 |
}
|
|
|
168 |
|
|
|
169 |
ticketSubCategory = new TicketSubCategory();
|
|
|
170 |
ticketSubCategory.setcategoryId(categoryId);
|
|
|
171 |
ticketSubCategory.setName(name);
|
|
|
172 |
ticketSubCategory.setDescription(description);
|
|
|
173 |
ticketSubCategoryRepository.persist(ticketSubCategory);
|
|
|
174 |
return "create-ticket-sub-category";
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
@GetMapping(value = "/cs/createRegion")
|
|
|
178 |
public String createRegion(HttpServletRequest request, Model model) {
|
|
|
179 |
List<Region> regions = regionRepository.selectAll();
|
|
|
180 |
model.addAttribute("regions", regions);
|
|
|
181 |
return "create-region";
|
|
|
182 |
}
|
|
|
183 |
|
|
|
184 |
@PostMapping(value = "/cs/createRegion")
|
|
|
185 |
public String createRegion(HttpServletRequest request, @RequestParam(name = "name") String name,
|
|
|
186 |
@RequestParam(name = "description") String description, Model model) throws Exception {
|
|
|
187 |
Region region = regionRepository.selectByName(name);
|
|
|
188 |
if (region != null) {
|
|
|
189 |
throw new ProfitMandiBusinessException("name", name, "already exists!");
|
|
|
190 |
}
|
|
|
191 |
region = new Region();
|
|
|
192 |
region.setName(name);
|
|
|
193 |
region.setDescription(description);
|
|
|
194 |
regionRepository.persist(region);
|
|
|
195 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
196 |
return "response";
|
|
|
197 |
}
|
|
|
198 |
|
| 24557 |
govind |
199 |
@GetMapping(value = "/cs/getPartners")
|
| 24569 |
govind |
200 |
public String getPartners(HttpServletRequest request,
|
|
|
201 |
@RequestParam(name = "regionId", defaultValue = "0") int regionId, Model model) {
|
| 24557 |
govind |
202 |
List<Integer> fofoIds = targetSlabService.getfofoIdsFromfofoStore();
|
| 24569 |
govind |
203 |
List<Integer> addedfofoIds = partnerRegionRepository.selectByRegionId(regionId).stream().map(x -> x.getFofoId())
|
|
|
204 |
.collect(Collectors.toList());
|
| 24557 |
govind |
205 |
Map<Integer, CustomRetailer> fofoRetailers = retailerService.getFofoRetailers(fofoIds);
|
|
|
206 |
model.addAttribute("fofoRetailers", fofoRetailers);
|
|
|
207 |
model.addAttribute("addedfofoIds", addedfofoIds);
|
|
|
208 |
return "added-region-partners";
|
|
|
209 |
}
|
| 24569 |
govind |
210 |
|
| 24417 |
govind |
211 |
@GetMapping(value = "/cs/createPartnerRegion")
|
|
|
212 |
public String createPartnerRegion(HttpServletRequest request, Model model) {
|
|
|
213 |
List<Region> regions = regionRepository.selectAll();
|
|
|
214 |
model.addAttribute("regions", regions);
|
|
|
215 |
return "create-partner-region";
|
|
|
216 |
}
|
|
|
217 |
|
|
|
218 |
@PostMapping(value = "/cs/createPartnerRegion")
|
|
|
219 |
public String createPartnerRegion(HttpServletRequest request, @RequestParam(name = "regionId") int regionId,
|
|
|
220 |
@RequestBody List<Integer> selectedFofoIds, Model model) throws Exception {
|
| 24557 |
govind |
221 |
partnerRegionRepository.delete(regionId);
|
|
|
222 |
LOGGER.info("successfully removed");
|
|
|
223 |
LOGGER.info(selectedFofoIds.size());
|
| 24417 |
govind |
224 |
csService.addPartnerToRegion(regionId, selectedFofoIds);
|
|
|
225 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
226 |
return "response";
|
|
|
227 |
}
|
|
|
228 |
|
|
|
229 |
@GetMapping(value = "/cs/createPosition")
|
| 24500 |
govind |
230 |
public String createPosition(HttpServletRequest request,
|
|
|
231 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 24471 |
govind |
232 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) {
|
| 24417 |
govind |
233 |
List<AuthUser> authUsers = authRepository.selectAll();
|
|
|
234 |
List<TicketCategory> ticketCategories = ticketCategoryRepository.selectAll();
|
|
|
235 |
List<Region> regions = regionRepository.selectAll();
|
|
|
236 |
model.addAttribute("escalationTypes", EscalationType.values());
|
|
|
237 |
model.addAttribute("authUsers", authUsers);
|
|
|
238 |
model.addAttribute("ticketCategories", ticketCategories);
|
|
|
239 |
model.addAttribute("regions", regions);
|
| 24500 |
govind |
240 |
|
|
|
241 |
List<Position> positions = positionRepository.selectAll(offset, limit);
|
|
|
242 |
LOGGER.info(positions);
|
|
|
243 |
Map<Integer, AuthUser> authUserIdAndAuthUserMap = csService
|
|
|
244 |
.getAuthUserIdAndAuthUserMapUsingPositions(positions);
|
|
|
245 |
Map<Integer, TicketCategory> categoryIdAndCategoryMap = csService
|
|
|
246 |
.getCategoryIdAndCategoryUsingPositions(positions);
|
|
|
247 |
Map<Integer, Region> regionIdAndRegionMap = csService.getRegionIdAndRegionMap(positions);
|
|
|
248 |
long size = positionRepository.selectAllCount();
|
|
|
249 |
|
| 24471 |
govind |
250 |
if (size < limit) {
|
|
|
251 |
model.addAttribute("end", offset + size);
|
|
|
252 |
} else {
|
|
|
253 |
model.addAttribute("end", offset + limit);
|
|
|
254 |
}
|
|
|
255 |
model.addAttribute("start", offset + 1);
|
|
|
256 |
model.addAttribute("size", size);
|
|
|
257 |
model.addAttribute("positions", positions);
|
|
|
258 |
model.addAttribute("authUserIdAndAuthUserMap", authUserIdAndAuthUserMap);
|
|
|
259 |
model.addAttribute("categoryIdAndCategoryMap", categoryIdAndCategoryMap);
|
|
|
260 |
model.addAttribute("regionIdAndRegionMap", regionIdAndRegionMap);
|
| 24417 |
govind |
261 |
return "create-position";
|
|
|
262 |
}
|
| 24500 |
govind |
263 |
|
| 24471 |
govind |
264 |
@GetMapping(value = "/cs/position-paginated")
|
| 24500 |
govind |
265 |
public String positionPaginated(HttpServletRequest request,
|
|
|
266 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 24471 |
govind |
267 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) {
|
| 24500 |
govind |
268 |
|
|
|
269 |
List<Position> positions = positionRepository.selectAll(offset, limit);
|
|
|
270 |
Map<Integer, AuthUser> authUserIdAndAuthUserMap = csService
|
|
|
271 |
.getAuthUserIdAndAuthUserMapUsingPositions(positions);
|
|
|
272 |
Map<Integer, TicketCategory> categoryIdAndCategoryMap = csService
|
|
|
273 |
.getCategoryIdAndCategoryUsingPositions(positions);
|
|
|
274 |
Map<Integer, Region> regionIdAndRegionMap = csService.getRegionIdAndRegionMap(positions);
|
| 24471 |
govind |
275 |
model.addAttribute("positions", positions);
|
|
|
276 |
model.addAttribute("authUserIdAndAuthUserMap", authUserIdAndAuthUserMap);
|
|
|
277 |
model.addAttribute("categoryIdAndCategoryMap", categoryIdAndCategoryMap);
|
|
|
278 |
model.addAttribute("regionIdAndRegionMap", regionIdAndRegionMap);
|
|
|
279 |
return "position-paginated";
|
|
|
280 |
}
|
| 24417 |
govind |
281 |
|
|
|
282 |
@PostMapping(value = "/cs/createPosition")
|
|
|
283 |
public String createPosition(HttpServletRequest request, @RequestParam(name = "authUserId") int authUserId,
|
|
|
284 |
@RequestParam(name = "categoryId") int categoryId,
|
|
|
285 |
@RequestParam(name = "escalationType") EscalationType escalationType,
|
|
|
286 |
@RequestParam(name = "regionId") int regionId, Model model) throws Exception {
|
|
|
287 |
|
|
|
288 |
Position position = positionRepository.selectPosition(authUserId, categoryId, regionId, escalationType);
|
|
|
289 |
if (position == null) {
|
|
|
290 |
position = new Position();
|
|
|
291 |
position.setAuthUserId(authUserId);
|
|
|
292 |
position.setCategoryId(categoryId);
|
|
|
293 |
position.setEscalationType(escalationType);
|
|
|
294 |
position.setRegionId(regionId);
|
|
|
295 |
position.setCreateTimestamp(LocalDateTime.now());
|
|
|
296 |
positionRepository.persist(position);
|
|
|
297 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
298 |
} else {
|
|
|
299 |
throw new ProfitMandiBusinessException("Position", authUserId, "already exists!");
|
|
|
300 |
}
|
|
|
301 |
return "response";
|
|
|
302 |
}
|
|
|
303 |
|
|
|
304 |
@GetMapping(value = "/cs/createTicket")
|
|
|
305 |
public String createTicket(HttpServletRequest request, Model model) {
|
| 24500 |
govind |
306 |
List<TicketCategory> ticketCategories = csService.getAllTicketCategotyFromSubCategory();
|
| 24417 |
govind |
307 |
model.addAttribute("ticketCategories", ticketCategories);
|
|
|
308 |
return "create-ticket";
|
|
|
309 |
}
|
|
|
310 |
|
|
|
311 |
@GetMapping(value = "/cs/getSubCategoriesByCategoryId")
|
|
|
312 |
public String getSubCategoriesByCategoryId(HttpServletRequest request,
|
|
|
313 |
@RequestParam(name = "categoryId", defaultValue = "0") int categoryId, Model model) {
|
|
|
314 |
List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository.selectAll(categoryId);
|
|
|
315 |
LOGGER.info(ticketSubCategories);
|
|
|
316 |
model.addAttribute("ticketSubCategories", ticketSubCategories);
|
|
|
317 |
return "ticket-sub-categories";
|
|
|
318 |
}
|
|
|
319 |
|
|
|
320 |
@PostMapping(value = "/cs/createTicket")
|
|
|
321 |
public String createTicket(HttpServletRequest request, @RequestParam(name = "categoryId") int categoryId,
|
|
|
322 |
@RequestParam(name = "subCategoryId") int subCategoryId, @RequestParam(name = "message") String message,
|
|
|
323 |
Model model) throws Exception {
|
|
|
324 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24699 |
govind |
325 |
List<Ticket> tickets = ticketRepository.selectAllByCreator(loginDetails.getFofoId(), Optional.of(true),SortOrder.DESCENDING,0, 10);
|
| 24620 |
govind |
326 |
if (tickets.size() > 3 || tickets.size() == 3) {
|
|
|
327 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
328 |
} else {
|
|
|
329 |
csService.createTicket(loginDetails.getFofoId(), categoryId, subCategoryId, message);
|
|
|
330 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
331 |
}
|
| 24417 |
govind |
332 |
return "response";
|
|
|
333 |
}
|
|
|
334 |
|
|
|
335 |
@GetMapping(value = "/cs/myticket")
|
| 24699 |
govind |
336 |
public String getTicket(HttpServletRequest request,
|
|
|
337 |
@RequestParam(name = "orderby", defaultValue = "DESCENDING") SortOrder sortOrder,
|
|
|
338 |
@RequestParam(name = "ticketStatus", defaultValue = "OPENED") TicketStatus ticketStatus,
|
|
|
339 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 24417 |
govind |
340 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
341 |
throws ProfitMandiBusinessException {
|
|
|
342 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
343 |
List<Ticket> tickets = null;
|
| 24500 |
govind |
344 |
List<TicketAssigned> ticketAssigneds = null;
|
| 24699 |
govind |
345 |
//List<Integer> ticketIds = null;
|
| 24417 |
govind |
346 |
long size = 0;
|
| 24500 |
govind |
347 |
Map<Integer, AuthUser> authUserIdAndAuthUserMap = null;
|
|
|
348 |
// LOGGER.info(roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))));
|
| 24417 |
govind |
349 |
if (roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))) {
|
|
|
350 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
| 24699 |
govind |
351 |
LOGGER.info(ticketStatus);
|
|
|
352 |
LOGGER.info(sortOrder);
|
|
|
353 |
tickets = ticketRepository.selectAllByAssignee(authUser.getId(),
|
|
|
354 |
Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), sortOrder, offset, limit);
|
|
|
355 |
size = ticketRepository.selectAllCountByAssignee(authUser.getId(),Optional.of(TicketStatus.CLOSED.equals(ticketStatus)));
|
| 24620 |
govind |
356 |
LOGGER.info(size + "size");
|
| 24699 |
govind |
357 |
ticketAssigneds=ticketAssignedRepository.selectByTicketIds(tickets.stream().map(x->x.getId()).collect(Collectors.toList()));
|
| 24500 |
govind |
358 |
authUserIdAndAuthUserMap = csService.getAuthUserIdAndAuthUserMap(ticketAssigneds);
|
| 24620 |
govind |
359 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
|
|
|
360 |
model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
|
|
|
361 |
|
| 24417 |
govind |
362 |
} else {
|
| 24699 |
govind |
363 |
LOGGER.info(ticketStatus);
|
|
|
364 |
LOGGER.info(sortOrder);
|
|
|
365 |
LOGGER.info(TicketStatus.CLOSED.equals(ticketStatus));
|
|
|
366 |
tickets = ticketRepository.selectAllByCreator(loginDetails.getFofoId(),
|
|
|
367 |
Optional.of(TicketStatus.CLOSED.equals(ticketStatus)),sortOrder,offset, limit);
|
|
|
368 |
size = ticketRepository.selectAllCountByCreator(loginDetails.getFofoId(),
|
|
|
369 |
Optional.of(TicketStatus.CLOSED.equals(ticketStatus)));
|
|
|
370 |
}
|
|
|
371 |
authUserIdAndAuthUserMap = csService.getTicketIdAndAuthUserMapUsingTickets(tickets);
|
| 24500 |
govind |
372 |
|
| 24417 |
govind |
373 |
if (size < limit) {
|
|
|
374 |
model.addAttribute("end", offset + size);
|
|
|
375 |
} else {
|
|
|
376 |
model.addAttribute("end", offset + limit);
|
|
|
377 |
}
|
|
|
378 |
model.addAttribute("start", offset + 1);
|
|
|
379 |
model.addAttribute("size", size);
|
| 24500 |
govind |
380 |
model.addAttribute("roleType", roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds())));
|
| 24417 |
govind |
381 |
Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = csService
|
|
|
382 |
.getSubCategoryIdAndSubCategoryMap(tickets);
|
|
|
383 |
model.addAttribute("tickets", tickets);
|
| 24620 |
govind |
384 |
model.addAttribute("resolved", ActivityType.RESOLVED);
|
|
|
385 |
model.addAttribute("resolved-accepted", ActivityType.RESOLVED_ACCEPTED);
|
|
|
386 |
model.addAttribute("resolved-rejected", ActivityType.RESOLVED_REJECTED);
|
| 24417 |
govind |
387 |
model.addAttribute("authUserIdAndAuthUserMap", authUserIdAndAuthUserMap);
|
|
|
388 |
model.addAttribute("subCategoryIdAndSubCategoryMap", subCategoryIdAndSubCategoryMap);
|
| 24699 |
govind |
389 |
model.addAttribute("ticketStatusValues", TicketStatus.values());
|
|
|
390 |
model.addAttribute("orderByValues", SortOrder.values());
|
|
|
391 |
model.addAttribute("selectedticketStatus", ticketStatus);
|
|
|
392 |
model.addAttribute("selectedorderby", sortOrder);
|
| 24417 |
govind |
393 |
return "ticket";
|
|
|
394 |
}
|
| 24500 |
govind |
395 |
|
| 24417 |
govind |
396 |
@GetMapping(value = "/cs/myticketPaginated")
|
| 24500 |
govind |
397 |
public String getMyTicketPaginated(HttpServletRequest request,
|
| 24699 |
govind |
398 |
@RequestParam(name = "orderby", defaultValue = "DESCENDING") SortOrder sortOrder,
|
|
|
399 |
@RequestParam(name = "ticketStatus", defaultValue = "OPENED") TicketStatus ticketStatus,
|
| 24500 |
govind |
400 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 24417 |
govind |
401 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
402 |
throws ProfitMandiBusinessException {
|
|
|
403 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
404 |
List<Ticket> tickets = null;
|
| 24500 |
govind |
405 |
List<TicketAssigned> ticketAssigneds = null;
|
| 24699 |
govind |
406 |
//List<Integer> ticketIds = null;
|
| 24500 |
govind |
407 |
Map<Integer, AuthUser> authUserIdAndAuthUserMap = null;
|
|
|
408 |
// LOGGER.info(roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))));
|
| 24417 |
govind |
409 |
if (roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))) {
|
|
|
410 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
| 24699 |
govind |
411 |
tickets = ticketRepository.selectAllByAssignee(authUser.getId(),
|
|
|
412 |
Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), sortOrder, offset, limit);
|
|
|
413 |
ticketAssigneds=ticketAssignedRepository.selectByTicketIds(tickets.stream().map(x->x.getId()).collect(Collectors.toList()));
|
| 24620 |
govind |
414 |
authUserIdAndAuthUserMap = csService.getAuthUserIdAndAuthUserMap(ticketAssigneds);
|
|
|
415 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
|
|
|
416 |
model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
|
| 24417 |
govind |
417 |
} else {
|
| 24699 |
govind |
418 |
tickets = ticketRepository.selectAllByCreator(loginDetails.getFofoId(), Optional.of(TicketStatus.CLOSED.equals(ticketStatus)),sortOrder,offset, limit);
|
| 24500 |
govind |
419 |
authUserIdAndAuthUserMap = csService.getTicketIdAndAuthUserMapUsingTickets(tickets);
|
| 24417 |
govind |
420 |
}
|
| 24500 |
govind |
421 |
model.addAttribute("roleType", roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds())));
|
| 24417 |
govind |
422 |
Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = csService
|
|
|
423 |
.getSubCategoryIdAndSubCategoryMap(tickets);
|
|
|
424 |
model.addAttribute("tickets", tickets);
|
|
|
425 |
model.addAttribute("authUserIdAndAuthUserMap", authUserIdAndAuthUserMap);
|
|
|
426 |
model.addAttribute("subCategoryIdAndSubCategoryMap", subCategoryIdAndSubCategoryMap);
|
| 24699 |
govind |
427 |
model.addAttribute("resolved", ActivityType.RESOLVED);
|
|
|
428 |
model.addAttribute("resolved-accepted", ActivityType.RESOLVED_ACCEPTED);
|
|
|
429 |
model.addAttribute("resolved-rejected", ActivityType.RESOLVED_REJECTED);
|
| 24417 |
govind |
430 |
return "ticket-paginated";
|
|
|
431 |
}
|
|
|
432 |
|
|
|
433 |
@GetMapping(value = "/cs/getActivities")
|
|
|
434 |
public String getActivity(HttpServletRequest request,
|
|
|
435 |
@RequestParam(name = "ticketId", defaultValue = "0") int ticketId, Model model) throws Exception {
|
|
|
436 |
List<Activity> activities = activityRepository.selectAll(ticketId);
|
| 24572 |
amit.gupta |
437 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24620 |
govind |
438 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
|
|
439 |
Set<Integer> authUserIds = activities.stream().map(x -> x.getCreatedBy()).collect(Collectors.toSet());
|
| 24572 |
amit.gupta |
440 |
List<AuthUser> users = authRepository.selectAllAuthUserByIds(new ArrayList<>(authUserIds));
|
| 24620 |
govind |
441 |
Map<Integer, String> authUserNameMap = users.stream()
|
|
|
442 |
.collect(Collectors.toMap(AuthUser::getId, x -> x.getFirstName() + " " + x.getLastName()));
|
|
|
443 |
activities.stream().forEach(x -> x.setName(authUserNameMap.get(x.getCreatedBy())));
|
| 24572 |
amit.gupta |
444 |
}
|
| 24417 |
govind |
445 |
if (activities == null) {
|
|
|
446 |
throw new ProfitMandiBusinessException("Activity", ticketId, "No Activity Found");
|
|
|
447 |
}
|
|
|
448 |
model.addAttribute("response", mvcResponseSender.createResponseString(activities));
|
|
|
449 |
return "response";
|
|
|
450 |
|
|
|
451 |
}
|
|
|
452 |
|
|
|
453 |
@PostMapping(value = "/cs/createActivity")
|
|
|
454 |
public String createActivity(HttpServletRequest request,
|
|
|
455 |
@RequestParam(name = "ticketId", defaultValue = "0") int ticketId,
|
| 24500 |
govind |
456 |
@RequestParam(name = "assigneeId", defaultValue = "0") int assigneeId,
|
| 24417 |
govind |
457 |
@RequestParam(name = "message", defaultValue = "") String message, Model model) throws Exception {
|
|
|
458 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24500 |
govind |
459 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
|
|
460 |
if (ticket.getCloseTimestamp() == null) {
|
|
|
461 |
if (!roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))) {
|
|
|
462 |
Activity activity = new Activity();
|
|
|
463 |
activity.setMessage(message);
|
|
|
464 |
activity.setCreatedBy(0);
|
|
|
465 |
activity.setCreateTimestamp(LocalDateTime.now());
|
|
|
466 |
activity.setType(ActivityType.COMMUNICATION_IN);
|
|
|
467 |
csService.addActivity(ticketId, activity);
|
| 24620 |
govind |
468 |
AuthUser authUser = authRepository.selectById(ticket.getL1AuthUser());
|
|
|
469 |
String subject = String.format(ACTIVITY_SUBJECT, ticket.getId());
|
|
|
470 |
String[] cc = { authRepository.selectById(ticket.getL2AuthUser()).getEmailId(),
|
|
|
471 |
authRepository.selectById(ticket.getL3AuthUser()).getEmailId() };
|
|
|
472 |
// LOGGER.info(authUser.getEmailId()+" "+cc+" "+subject+" "+message);
|
|
|
473 |
this.activityRelatedMail(authUser.getEmailId(), cc, subject, message);
|
| 24500 |
govind |
474 |
model.addAttribute("response", mvcResponseSender.createResponseString(authUser));
|
|
|
475 |
} else {
|
|
|
476 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
|
|
477 |
Activity activity = new Activity();
|
|
|
478 |
activity.setMessage(message);
|
|
|
479 |
activity.setCreatedBy(authUser.getId());
|
|
|
480 |
activity.setCreateTimestamp(LocalDateTime.now());
|
|
|
481 |
activity.setType(ActivityType.COMMUNICATION_OUT);
|
|
|
482 |
csService.addActivity(ticketId, activity);
|
| 24620 |
govind |
483 |
String subject = String.format(ACTIVITY_SUBJECT, ticket.getId());
|
|
|
484 |
LOGGER.info(authUser.getEmailId() + " " + subject + " " + message);
|
|
|
485 |
this.activityRelatedMail(retailerService.getFofoRetailer(ticket.getFofoId()).getEmail(), null, subject,
|
|
|
486 |
message);
|
| 24500 |
govind |
487 |
model.addAttribute("response", mvcResponseSender.createResponseString(authUser));
|
|
|
488 |
}
|
| 24417 |
govind |
489 |
} else {
|
|
|
490 |
throw new ProfitMandiBusinessException("Ticket", ticket.getId(), "Already closed ticket");
|
|
|
491 |
}
|
|
|
492 |
return "response";
|
|
|
493 |
}
|
| 24500 |
govind |
494 |
|
| 24620 |
govind |
495 |
private void activityRelatedMail(String to, String[] cc, String subject, String message)
|
|
|
496 |
throws ProfitMandiBusinessException {
|
|
|
497 |
try {
|
|
|
498 |
Utils.sendMailWithAttachments(mailSender, to, cc, subject, message, null);
|
|
|
499 |
} catch (Exception e) {
|
|
|
500 |
throw new ProfitMandiBusinessException("Ticket Activity", to, "Could not send ticket activity mail");
|
|
|
501 |
}
|
|
|
502 |
}
|
|
|
503 |
|
| 24500 |
govind |
504 |
@PostMapping(value = "/cs/closeTicket")
|
| 24417 |
govind |
505 |
public String closeTicket(HttpServletRequest request,
|
| 24439 |
govind |
506 |
@RequestParam(name = "ticketId", defaultValue = "0") int ticketId,
|
| 24500 |
govind |
507 |
@RequestParam(name = "happyCode") String happyCode, Model model) throws Exception {
|
|
|
508 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
|
|
509 |
if (ticket.getHappyCode().equals(happyCode)) {
|
|
|
510 |
ticket.setCloseTimestamp(LocalDateTime.now());
|
|
|
511 |
ticketRepository.persist(ticket);
|
|
|
512 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
513 |
} else {
|
|
|
514 |
throw new ProfitMandiBusinessException("Ticket", ticketId, "Happy Code can't match");
|
| 24439 |
govind |
515 |
}
|
| 24417 |
govind |
516 |
return "response";
|
|
|
517 |
}
|
| 24500 |
govind |
518 |
|
|
|
519 |
@GetMapping(value = "/cs/managerTicket")
|
|
|
520 |
public String getL2L3AndL4Tickets(HttpServletRequest request,
|
| 24699 |
govind |
521 |
@RequestParam(name = "orderby", defaultValue = "DESCENDING") SortOrder sortOrder,
|
|
|
522 |
@RequestParam(name = "ticketStatus", defaultValue = "OPENED") TicketStatus ticketStatus,
|
| 24500 |
govind |
523 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
524 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
525 |
throws ProfitMandiBusinessException {
|
| 24439 |
govind |
526 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
527 |
long size = 0;
|
| 24500 |
govind |
528 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
|
|
529 |
List<Ticket> tickets = null;
|
| 24569 |
govind |
530 |
Map<Integer, List<AuthUser>> authUserListMap = null;
|
| 24500 |
govind |
531 |
if (loginDetails.getEmailId().equals("amandeep.singh@smartdukaan.com")) {
|
|
|
532 |
tickets = ticketRepository.selectAll(offset, limit, Optional.empty());
|
| 24620 |
govind |
533 |
authUserListMap = csService.getAuthUserList(tickets, authUser);
|
| 24500 |
govind |
534 |
size = ticketRepository.selectAllCount();
|
|
|
535 |
} else {
|
| 24699 |
govind |
536 |
tickets = ticketRepository.selectAllManagerTicket(authUser.getId(), sortOrder, Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), offset, limit);
|
| 24620 |
govind |
537 |
authUserListMap = csService.getAuthUserList(tickets, authUser);
|
| 24699 |
govind |
538 |
size = ticketRepository.selectAllCountByManagerTicket(authUser.getId(), Optional.of(TicketStatus.CLOSED.equals(ticketStatus)));
|
| 24620 |
govind |
539 |
if (tickets.size() > 0) {
|
|
|
540 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
|
|
|
541 |
model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
|
| 24439 |
govind |
542 |
}
|
|
|
543 |
}
|
|
|
544 |
if (size < limit) {
|
|
|
545 |
model.addAttribute("end", offset + size);
|
|
|
546 |
} else {
|
|
|
547 |
model.addAttribute("end", offset + limit);
|
|
|
548 |
}
|
|
|
549 |
model.addAttribute("start", offset + 1);
|
|
|
550 |
model.addAttribute("size", size);
|
|
|
551 |
model.addAttribute("tickets", tickets);
|
| 24500 |
govind |
552 |
|
| 24439 |
govind |
553 |
Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = csService
|
|
|
554 |
.getSubCategoryIdAndSubCategoryMap(tickets);
|
| 24699 |
govind |
555 |
model.addAttribute("ticketStatusValues", TicketStatus.values());
|
|
|
556 |
model.addAttribute("orderByValues", SortOrder.values());
|
|
|
557 |
model.addAttribute("selectedticketStatus", ticketStatus);
|
|
|
558 |
model.addAttribute("selectedorderby", sortOrder);
|
| 24439 |
govind |
559 |
model.addAttribute("tickets", tickets);
|
| 24500 |
govind |
560 |
model.addAttribute("authUserListMap", authUserListMap);
|
| 24439 |
govind |
561 |
model.addAttribute("subCategoryIdAndSubCategoryMap", subCategoryIdAndSubCategoryMap);
|
|
|
562 |
return "managerTicket";
|
|
|
563 |
}
|
| 24500 |
govind |
564 |
|
|
|
565 |
@GetMapping(value = "/cs/managerTicket-paginated")
|
|
|
566 |
public String getL2L3AndL4TicketsPaginated(HttpServletRequest request,
|
| 24699 |
govind |
567 |
@RequestParam(name = "orderby", defaultValue = "DESCENDING") SortOrder sortOrder,
|
|
|
568 |
@RequestParam(name = "ticketStatus", defaultValue = "OPENED") TicketStatus ticketStatus,
|
| 24500 |
govind |
569 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
570 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
571 |
throws ProfitMandiBusinessException {
|
| 24467 |
govind |
572 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24500 |
govind |
573 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
| 24557 |
govind |
574 |
Map<Integer, List<AuthUser>> authUserListMap = null;
|
| 24500 |
govind |
575 |
List<Ticket> tickets = null;
|
|
|
576 |
if (loginDetails.getEmailId().equals("amandeep.singh@smartdukaan.com")) {
|
|
|
577 |
tickets = ticketRepository.selectAll(offset, limit, Optional.empty());
|
| 24620 |
govind |
578 |
authUserListMap = csService.getAuthUserList(tickets, authUser);
|
| 24500 |
govind |
579 |
} else {
|
| 24699 |
govind |
580 |
|
|
|
581 |
tickets = ticketRepository.selectAllManagerTicket(authUser.getId(), sortOrder, Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), offset, limit);
|
| 24620 |
govind |
582 |
authUserListMap = csService.getAuthUserList(tickets, authUser);
|
|
|
583 |
if (tickets.size() > 0) {
|
| 24500 |
govind |
584 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
|
| 24467 |
govind |
585 |
model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
|
| 24620 |
govind |
586 |
}
|
| 24467 |
govind |
587 |
}
|
|
|
588 |
model.addAttribute("tickets", tickets);
|
|
|
589 |
Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = csService
|
|
|
590 |
.getSubCategoryIdAndSubCategoryMap(tickets);
|
|
|
591 |
model.addAttribute("tickets", tickets);
|
| 24500 |
govind |
592 |
model.addAttribute("authUserListMap", authUserListMap);
|
| 24467 |
govind |
593 |
model.addAttribute("subCategoryIdAndSubCategoryMap", subCategoryIdAndSubCategoryMap);
|
|
|
594 |
return "managerTicket-paginated";
|
|
|
595 |
}
|
| 24500 |
govind |
596 |
|
|
|
597 |
@GetMapping(value = "/cs/edit-ticket")
|
|
|
598 |
public String getEditTicket(HttpServletRequest request,
|
|
|
599 |
@RequestParam(name = "ticketId", defaultValue = "0") int ticketId, Model model) {
|
|
|
600 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
|
|
601 |
List<TicketCategory> ticketCategories = csService.getAllTicketCategotyFromSubCategory();
|
|
|
602 |
TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.selectById(ticket.getSubCategoryId());
|
|
|
603 |
List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository
|
|
|
604 |
.selectAll(ticketSubCategory.getcategoryId());
|
| 24569 |
govind |
605 |
List<AuthUser> authUsers = authRepository.selectAll();
|
| 24467 |
govind |
606 |
model.addAttribute("ticket", ticket);
|
|
|
607 |
model.addAttribute("ticketCategories", ticketCategories);
|
|
|
608 |
model.addAttribute("ticketSubCategories", ticketSubCategories);
|
| 24575 |
govind |
609 |
model.addAttribute("ticketSubCategory", ticketSubCategory);
|
| 24500 |
govind |
610 |
model.addAttribute("authUsers", authUsers);
|
| 24467 |
govind |
611 |
return "edit-ticket-modal";
|
|
|
612 |
}
|
| 24500 |
govind |
613 |
|
|
|
614 |
@PostMapping(value = "/cs/edit-ticket")
|
|
|
615 |
public String editTicket(HttpServletRequest request,
|
|
|
616 |
@RequestParam(name = "ticketId", defaultValue = "0") int ticketId,
|
|
|
617 |
@RequestParam(name = "subCategoryId", defaultValue = "0") int subCategoryId,
|
|
|
618 |
@RequestParam(name = "categoryId", defaultValue = "0") int categoryId,
|
|
|
619 |
@RequestParam(name = "authUserId", defaultValue = "0") int authUserId, Model model) throws Exception {
|
| 24467 |
govind |
620 |
LOGGER.info(ticketId);
|
| 24500 |
govind |
621 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
| 24569 |
govind |
622 |
ticketAssignedRepository.deleteByTicketId(ticketId);
|
|
|
623 |
if (ticket.getSubCategoryId() == subCategoryId) {
|
|
|
624 |
LOGGER.info(ticket);
|
|
|
625 |
TicketAssigned ticketAssigned = new TicketAssigned();
|
| 24500 |
govind |
626 |
ticketAssigned.setTicketId(ticketId);
|
|
|
627 |
ticketAssigned.setAssineeId(authUserId);
|
|
|
628 |
ticketAssignedRepository.persist(ticketAssigned);
|
| 24569 |
govind |
629 |
ticket.setL1AuthUser(authUserId);
|
|
|
630 |
ticket.setSubCategoryId(subCategoryId);
|
|
|
631 |
ticket.setUpdateTimestamp(LocalDateTime.now());
|
|
|
632 |
ticket.setL2EscalationTimestamp(ticket.getUpdateTimestamp().plusDays(2));
|
|
|
633 |
ticket.setL3EscalationTimestamp(ticket.getL2EscalationTimestamp().plusDays(2));
|
|
|
634 |
ticket.setLastEscalationTimestamp(ticket.getL3EscalationTimestamp().plusDays(2));
|
|
|
635 |
ticketRepository.persist(ticket);
|
|
|
636 |
csService.sendAssignedTicketMail(authRepository.selectById(authUserId), ticket);
|
| 24500 |
govind |
637 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 24569 |
govind |
638 |
} else {
|
|
|
639 |
csService.updateTicket(categoryId, subCategoryId, ticket);
|
|
|
640 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 24500 |
govind |
641 |
}
|
| 24467 |
govind |
642 |
return "response";
|
|
|
643 |
}
|
| 24500 |
govind |
644 |
|
|
|
645 |
@DeleteMapping(value = "/cs/removePosition")
|
|
|
646 |
public String removePosition(HttpServletRequest request,
|
|
|
647 |
@RequestParam(name = "positionId", defaultValue = "0") int positionId, Model model) throws Exception {
|
| 24471 |
govind |
648 |
positionRepository.delete(positionId);
|
|
|
649 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
650 |
return "response";
|
|
|
651 |
}
|
| 24620 |
govind |
652 |
|
|
|
653 |
@PostMapping(value = "/cs/create-last-activity")
|
|
|
654 |
public String createlastActivity(HttpServletRequest request, @RequestParam(name = "ticketId") int ticketId,
|
|
|
655 |
@RequestParam(name = "lastactivity") ActivityType lastActivity, Model model) throws Exception {
|
|
|
656 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
657 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
|
|
658 |
Activity activity = new Activity();
|
|
|
659 |
String subject = String.format(ACTIVITY_SUBJECT, ticket.getId());
|
|
|
660 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
|
|
661 |
ticket.setLastActivity(lastActivity);
|
|
|
662 |
String to = retailerService.getFofoRetailer(ticket.getFofoId()).getEmail();
|
| 24699 |
govind |
663 |
String message = String.format(PARTNER_RESOLVED_TICKET_MAIL, ticketId, "REOPEN");
|
| 24620 |
govind |
664 |
activity.setMessage(message);
|
|
|
665 |
activity.setCreatedBy(authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getId());
|
|
|
666 |
activity.setTicketId(ticketId);
|
|
|
667 |
activity.setCreateTimestamp(LocalDateTime.now());
|
|
|
668 |
activity.setType(ActivityType.COMMUNICATION_OUT);
|
| 24621 |
govind |
669 |
this.activityRelatedMail(to, null, subject, message);
|
| 24620 |
govind |
670 |
} else {
|
|
|
671 |
if (ActivityType.RESOLVED_ACCEPTED == lastActivity) {
|
|
|
672 |
ticket.setLastActivity(lastActivity);
|
|
|
673 |
ticket.setCloseTimestamp(LocalDateTime.now());
|
|
|
674 |
activity.setMessage(ActivityType.RESOLVED.toString());
|
|
|
675 |
activity.setCreatedBy(0);
|
|
|
676 |
activity.setTicketId(ticketId);
|
|
|
677 |
activity.setType(ActivityType.COMMUNICATION_IN);
|
|
|
678 |
activity.setCreateTimestamp(LocalDateTime.now());
|
|
|
679 |
} else {
|
| 24699 |
govind |
680 |
String message = String.format(INTERNAL_REOPEN_MAIL, ticketId,
|
|
|
681 |
retailerService.getFofoRetailer(loginDetails.getFofoId()).getBusinessName());
|
| 24620 |
govind |
682 |
String to = authRepository.selectById(ticket.getL1AuthUser()).getEmailId();
|
|
|
683 |
String cc[] = { authRepository.selectById(ticket.getL2AuthUser()).getEmailId(),
|
|
|
684 |
authRepository.selectById(ticket.getL3AuthUser()).getEmailId() };
|
|
|
685 |
ticket.setLastActivity(lastActivity);
|
| 24638 |
govind |
686 |
ticket.setUpdateTimestamp(LocalDateTime.now());
|
|
|
687 |
ticket.setL2EscalationTimestamp(ticket.getUpdateTimestamp().plusDays(2));
|
|
|
688 |
ticket.setL3EscalationTimestamp(ticket.getL2EscalationTimestamp().plusDays(2));
|
|
|
689 |
ticket.setLastEscalationTimestamp(ticket.getL3EscalationTimestamp().plusDays(2));
|
|
|
690 |
ticketAssignedRepository.deleteByTicketId(ticketId);
|
| 24699 |
govind |
691 |
TicketAssigned ticketAssigned = new TicketAssigned();
|
| 24638 |
govind |
692 |
ticketAssigned.setAssineeId(ticket.getL1AuthUser());
|
|
|
693 |
ticketAssigned.setTicketId(ticketId);
|
|
|
694 |
ticketAssignedRepository.persist(ticketAssigned);
|
| 24620 |
govind |
695 |
activity.setMessage(INTERNAL_REOPEN_ACTIVITY_MESSAGE);
|
|
|
696 |
activity.setCreatedBy(0);
|
|
|
697 |
activity.setTicketId(ticketId);
|
|
|
698 |
activity.setType(ActivityType.COMMUNICATION_IN);
|
|
|
699 |
activity.setCreateTimestamp(LocalDateTime.now());
|
| 24621 |
govind |
700 |
this.activityRelatedMail(to, cc, subject, message);
|
| 24699 |
govind |
701 |
this.activityRelatedMail(retailerService.getFofoRetailer(loginDetails.getFofoId()).getEmail(), null,
|
|
|
702 |
subject, String.format(PARTNER_REOPEN, ticketId));
|
| 24620 |
govind |
703 |
}
|
|
|
704 |
|
|
|
705 |
}
|
|
|
706 |
ticketRepository.persist(ticket);
|
|
|
707 |
activityRepository.persist(activity);
|
|
|
708 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
709 |
return "response";
|
|
|
710 |
}
|
|
|
711 |
|
| 24417 |
govind |
712 |
}
|