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