| 24417 |
govind |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
|
|
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
4 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 32812 |
shampa |
5 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 24620 |
govind |
6 |
import com.spice.profitmandi.common.util.Utils;
|
| 24417 |
govind |
7 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 27690 |
amit.gupta |
8 |
import com.spice.profitmandi.dao.entity.cs.*;
|
| 27270 |
tejbeer |
9 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
| 24417 |
govind |
10 |
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
|
|
|
11 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 24699 |
govind |
12 |
import com.spice.profitmandi.dao.enumuration.cs.TicketStatus;
|
| 25570 |
tejbeer |
13 |
import com.spice.profitmandi.dao.model.CreatePositionModel;
|
| 24417 |
govind |
14 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 27690 |
amit.gupta |
15 |
import com.spice.profitmandi.dao.repository.cs.*;
|
| 27270 |
tejbeer |
16 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
| 25570 |
tejbeer |
17 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 24417 |
govind |
18 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
|
|
19 |
import com.spice.profitmandi.service.user.RetailerService;
|
|
|
20 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
21 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
|
|
22 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 27690 |
amit.gupta |
23 |
import org.apache.logging.log4j.LogManager;
|
|
|
24 |
import org.apache.logging.log4j.Logger;
|
|
|
25 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
26 |
import org.springframework.mail.javamail.JavaMailSender;
|
|
|
27 |
import org.springframework.stereotype.Controller;
|
|
|
28 |
import org.springframework.transaction.annotation.Transactional;
|
|
|
29 |
import org.springframework.ui.Model;
|
|
|
30 |
import org.springframework.web.bind.annotation.*;
|
| 24417 |
govind |
31 |
|
| 27690 |
amit.gupta |
32 |
import javax.servlet.http.HttpServletRequest;
|
|
|
33 |
import javax.swing.*;
|
|
|
34 |
import java.time.LocalDateTime;
|
|
|
35 |
import java.util.*;
|
|
|
36 |
import java.util.stream.Collectors;
|
|
|
37 |
|
| 24417 |
govind |
38 |
@Controller
|
|
|
39 |
@Transactional(rollbackFor = Throwable.class)
|
|
|
40 |
public class CsController {
|
|
|
41 |
|
| 31762 |
tejbeer |
42 |
private static final Logger LOGGER = LogManager.getLogger(CsController.class);
|
|
|
43 |
private static final String ACTIVITY_SUBJECT = "Message related ticketId#%s";
|
|
|
44 |
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";
|
|
|
45 |
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";
|
|
|
46 |
private static final String INTERNAL_REOPEN_MAIL = "Team, Pls note that the Ticket Id %s has been re-opened by %s , pls respond on priority";
|
|
|
47 |
private static final String INTERNAL_REOPEN_ACTIVITY_MESSAGE = "Hi,My ticket is not resolved yet,so I have reopened it";
|
| 24699 |
govind |
48 |
|
| 31762 |
tejbeer |
49 |
@Autowired
|
|
|
50 |
JavaMailSender mailSender;
|
| 24620 |
govind |
51 |
|
| 31762 |
tejbeer |
52 |
@Autowired
|
|
|
53 |
private CsService csService;
|
| 24417 |
govind |
54 |
|
| 31762 |
tejbeer |
55 |
@Autowired
|
|
|
56 |
private CookiesProcessor cookiesProcessor;
|
| 24417 |
govind |
57 |
|
| 31762 |
tejbeer |
58 |
@Autowired
|
|
|
59 |
private TicketCategoryRepository ticketCategoryRepository;
|
| 24417 |
govind |
60 |
|
| 31762 |
tejbeer |
61 |
@Autowired
|
|
|
62 |
private TicketSubCategoryRepository ticketSubCategoryRepository;
|
| 24417 |
govind |
63 |
|
| 31762 |
tejbeer |
64 |
@Autowired
|
|
|
65 |
private RegionRepository regionRepository;
|
| 24417 |
govind |
66 |
|
| 31762 |
tejbeer |
67 |
@Autowired
|
|
|
68 |
private RetailerService retailerService;
|
| 24417 |
govind |
69 |
|
| 31762 |
tejbeer |
70 |
@Autowired
|
|
|
71 |
private MVCResponseSender mvcResponseSender;
|
| 24417 |
govind |
72 |
|
| 31762 |
tejbeer |
73 |
@Autowired
|
|
|
74 |
private AuthRepository authRepository;
|
| 24417 |
govind |
75 |
|
| 31762 |
tejbeer |
76 |
@Autowired
|
|
|
77 |
private PositionRepository positionRepository;
|
| 24417 |
govind |
78 |
|
| 31762 |
tejbeer |
79 |
@Autowired
|
|
|
80 |
private TicketRepository ticketRepository;
|
| 24417 |
govind |
81 |
|
| 31762 |
tejbeer |
82 |
@Autowired
|
|
|
83 |
private RoleManager roleManager;
|
| 24417 |
govind |
84 |
|
| 31762 |
tejbeer |
85 |
@Autowired
|
|
|
86 |
private ActivityRepository activityRepository;
|
| 24417 |
govind |
87 |
|
| 31762 |
tejbeer |
88 |
@Autowired
|
|
|
89 |
private ActivityAttachmentRepository activityAttachmentRepository;
|
| 27270 |
tejbeer |
90 |
|
| 31762 |
tejbeer |
91 |
@Autowired
|
|
|
92 |
private TicketAssignedRepository ticketAssignedRepository;
|
| 24569 |
govind |
93 |
|
| 31762 |
tejbeer |
94 |
@Autowired
|
|
|
95 |
private PartnerRegionRepository partnerRegionRepository;
|
| 24500 |
govind |
96 |
|
| 31762 |
tejbeer |
97 |
@Autowired
|
| 32493 |
amit.gupta |
98 |
PartnerPositionRepository partnerPositionRepository;
|
| 25570 |
tejbeer |
99 |
|
| 31762 |
tejbeer |
100 |
@Autowired
|
|
|
101 |
FofoStoreRepository fofoStoreRepository;
|
| 25570 |
tejbeer |
102 |
|
| 31762 |
tejbeer |
103 |
@Autowired
|
|
|
104 |
DocumentRepository documentRepository;
|
| 27270 |
tejbeer |
105 |
|
| 31762 |
tejbeer |
106 |
@GetMapping(value = "/cs/createCategory")
|
|
|
107 |
public String getCreateCategory(HttpServletRequest request, Model model) {
|
|
|
108 |
List<TicketCategory> ticketCategories = ticketCategoryRepository.selectAll();
|
|
|
109 |
model.addAttribute("ticketCategories", ticketCategories);
|
|
|
110 |
return "create-ticket-category";
|
|
|
111 |
}
|
| 24417 |
govind |
112 |
|
| 31762 |
tejbeer |
113 |
@PostMapping(value = "/cs/createCategory")
|
| 33081 |
ranu |
114 |
public String createCategory(HttpServletRequest request,
|
|
|
115 |
@RequestParam(name = "name") String name,
|
|
|
116 |
@RequestParam(name = "categoryType") int categoryType,
|
|
|
117 |
@RequestParam(name = "description") String description,
|
|
|
118 |
Model model) throws ProfitMandiBusinessException {
|
| 31762 |
tejbeer |
119 |
TicketCategory ticketCategory = ticketCategoryRepository.selectByName(name);
|
|
|
120 |
if (ticketCategory != null) {
|
|
|
121 |
throw new ProfitMandiBusinessException("name", name, "already exists!");
|
|
|
122 |
}
|
| 33081 |
ranu |
123 |
|
| 31762 |
tejbeer |
124 |
ticketCategory = new TicketCategory();
|
|
|
125 |
ticketCategory.setName(name);
|
|
|
126 |
ticketCategory.setDescription(description);
|
| 33081 |
ranu |
127 |
|
|
|
128 |
ticketCategory.setCategoryType(categoryType == 1);
|
| 31762 |
tejbeer |
129 |
ticketCategoryRepository.persist(ticketCategory);
|
|
|
130 |
return "create-ticket-category";
|
|
|
131 |
}
|
| 24417 |
govind |
132 |
|
| 33081 |
ranu |
133 |
|
| 31762 |
tejbeer |
134 |
@GetMapping(value = "/cs/createSubCategory")
|
|
|
135 |
public String getCreateSubCategory(HttpServletRequest request, Model model) {
|
|
|
136 |
List<TicketCategory> ticketCategories = ticketCategoryRepository.selectAll();
|
|
|
137 |
model.addAttribute("ticketCategories", ticketCategories);
|
|
|
138 |
return "create-ticket-sub-category";
|
|
|
139 |
}
|
| 24417 |
govind |
140 |
|
| 31762 |
tejbeer |
141 |
@GetMapping(value = "/cs/getSubCategoryByCategoryId")
|
|
|
142 |
public String getSubCategoryByCategoryId(HttpServletRequest request, @RequestParam(name = "ticketCategoryId", defaultValue = "") int ticketCategoryId, Model model) {
|
|
|
143 |
List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository.selectAll(ticketCategoryId);
|
|
|
144 |
TicketCategory ticketCategory = ticketCategoryRepository.selectById(ticketCategoryId);
|
| 33081 |
ranu |
145 |
LOGGER.info("ticketSubCategories {}", ticketSubCategories);
|
|
|
146 |
LOGGER.info("ticketCategory {}", ticketCategory);
|
| 31762 |
tejbeer |
147 |
model.addAttribute("ticketSubCategories", ticketSubCategories);
|
|
|
148 |
model.addAttribute("ticketCategory", ticketCategory);
|
|
|
149 |
return "ticket-sub-category";
|
|
|
150 |
}
|
| 24417 |
govind |
151 |
|
| 31762 |
tejbeer |
152 |
@PostMapping(value = "/cs/createSubCategory")
|
|
|
153 |
public String createSubCategory(HttpServletRequest request, @RequestParam(name = "categoryId", defaultValue = "0") int categoryId, @RequestParam(name = "name") String name, @RequestParam(name = "description") String description, Model model) throws ProfitMandiBusinessException {
|
| 24417 |
govind |
154 |
|
| 31762 |
tejbeer |
155 |
TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.selectTicketSubCategory(categoryId, name);
|
|
|
156 |
if (ticketSubCategory != null) {
|
|
|
157 |
throw new ProfitMandiBusinessException("name & categoryId", name + " " + categoryId, "already exists!");
|
|
|
158 |
}
|
| 24417 |
govind |
159 |
|
| 31762 |
tejbeer |
160 |
ticketSubCategory = new TicketSubCategory();
|
|
|
161 |
ticketSubCategory.setCategoryId(categoryId);
|
|
|
162 |
ticketSubCategory.setName(name);
|
|
|
163 |
ticketSubCategory.setDescription(description);
|
|
|
164 |
ticketSubCategoryRepository.persist(ticketSubCategory);
|
|
|
165 |
return "create-ticket-sub-category";
|
|
|
166 |
}
|
| 24417 |
govind |
167 |
|
| 31762 |
tejbeer |
168 |
@GetMapping(value = "/cs/createRegion")
|
|
|
169 |
public String createRegion(HttpServletRequest request, Model model) {
|
|
|
170 |
List<Region> regions = regionRepository.selectAll();
|
|
|
171 |
model.addAttribute("regions", regions);
|
|
|
172 |
return "create-region";
|
|
|
173 |
}
|
| 24417 |
govind |
174 |
|
| 31762 |
tejbeer |
175 |
@PostMapping(value = "/cs/createRegion")
|
|
|
176 |
public String createRegion(HttpServletRequest request, @RequestParam(name = "name") String name, @RequestParam(name = "description") String description, Model model) throws Exception {
|
|
|
177 |
Region region = regionRepository.selectByName(name);
|
|
|
178 |
if (region != null) {
|
|
|
179 |
throw new ProfitMandiBusinessException("name", name, "already exists!");
|
|
|
180 |
}
|
|
|
181 |
region = new Region();
|
|
|
182 |
region.setName(name);
|
|
|
183 |
region.setDescription(description);
|
|
|
184 |
regionRepository.persist(region);
|
|
|
185 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
186 |
return "response";
|
|
|
187 |
}
|
| 24417 |
govind |
188 |
|
| 31762 |
tejbeer |
189 |
@GetMapping(value = "/cs/getPartners")
|
| 33244 |
ranu |
190 |
public String getPartners(HttpServletRequest request, @RequestParam(name = "regionId", defaultValue = "0") int regionId, Model model) throws ProfitMandiBusinessException {
|
| 31762 |
tejbeer |
191 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
192 |
List<Integer> addedfofoIds = partnerRegionRepository.selectByRegionId(regionId).stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
| 30426 |
tejbeer |
193 |
|
| 31762 |
tejbeer |
194 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
|
|
195 |
Map<Integer, CustomRetailer> fofoRetailers = fofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
|
|
196 |
model.addAttribute("fofoRetailers", fofoRetailers);
|
|
|
197 |
model.addAttribute("addedfofoIds", addedfofoIds);
|
|
|
198 |
return "added-region-partners";
|
|
|
199 |
}
|
| 24569 |
govind |
200 |
|
| 31762 |
tejbeer |
201 |
@GetMapping(value = "/cs/getPartnersByRegion")
|
| 33244 |
ranu |
202 |
public String getPartnersByRegion(HttpServletRequest request, @RequestParam(name = "regionId", defaultValue = "0") int regionId, Model model) throws ProfitMandiBusinessException {
|
| 31762 |
tejbeer |
203 |
List<Integer> fofoIds = null;
|
|
|
204 |
fofoIds = partnerRegionRepository.selectByRegionId(regionId).stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
| 25570 |
tejbeer |
205 |
|
| 31762 |
tejbeer |
206 |
if (fofoIds.contains(0)) {
|
|
|
207 |
fofoIds = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive()).collect(Collectors.toList()).stream().map(x -> x.getId()).collect(Collectors.toList());
|
| 25570 |
tejbeer |
208 |
|
| 31762 |
tejbeer |
209 |
}
|
|
|
210 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| 25570 |
tejbeer |
211 |
|
| 31762 |
tejbeer |
212 |
Map<Integer, CustomRetailer> fofoRetailers = fofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
|
|
213 |
model.addAttribute("fofoRetailers", fofoRetailers);
|
|
|
214 |
return "added-subregion-partners";
|
|
|
215 |
}
|
| 25570 |
tejbeer |
216 |
|
| 31762 |
tejbeer |
217 |
@GetMapping(value = "/cs/createPartnerRegion")
|
|
|
218 |
public String createPartnerRegion(HttpServletRequest request, Model model) {
|
|
|
219 |
List<Region> regions = regionRepository.selectAll();
|
|
|
220 |
model.addAttribute("regions", regions);
|
|
|
221 |
return "create-partner-region";
|
|
|
222 |
}
|
| 24417 |
govind |
223 |
|
| 31762 |
tejbeer |
224 |
@PostMapping(value = "/cs/createPartnerRegion")
|
|
|
225 |
public String createPartnerRegion(HttpServletRequest request, @RequestParam(name = "regionId") int regionId, @RequestBody List<Integer> selectedFofoIds, Model model) throws Exception {
|
|
|
226 |
partnerRegionRepository.delete(regionId);
|
|
|
227 |
LOGGER.info("successfully removed");
|
|
|
228 |
LOGGER.info(selectedFofoIds.size());
|
|
|
229 |
csService.addPartnerToRegion(regionId, selectedFofoIds);
|
|
|
230 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
231 |
return "response";
|
|
|
232 |
}
|
| 24417 |
govind |
233 |
|
| 31762 |
tejbeer |
234 |
@GetMapping(value = "/cs/getPosition")
|
| 33244 |
ranu |
235 |
public String getPosition(HttpServletRequest request, @RequestParam int positionId, Model model) throws ProfitMandiBusinessException {
|
| 27410 |
tejbeer |
236 |
|
| 31762 |
tejbeer |
237 |
Position position = positionRepository.selectById(positionId);
|
| 27410 |
tejbeer |
238 |
|
| 31762 |
tejbeer |
239 |
List<CustomRetailer> positionIdCustomRetailer = csService.getPositionCustomRetailerMap(Arrays.asList(position)).get(position.getId());
|
| 27410 |
tejbeer |
240 |
|
| 31762 |
tejbeer |
241 |
Map<Integer, CustomRetailer> regionRetailerMap = csService.getRegionPartners(Arrays.asList(position)).get(position.getRegionId()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 27410 |
tejbeer |
242 |
|
| 31762 |
tejbeer |
243 |
model.addAttribute("position", position);
|
|
|
244 |
model.addAttribute("regionRetailerMap", regionRetailerMap);
|
|
|
245 |
model.addAttribute("positionIdCustomRetailer", positionIdCustomRetailer);
|
| 27410 |
tejbeer |
246 |
|
| 31762 |
tejbeer |
247 |
return "position-partner";
|
|
|
248 |
}
|
| 27410 |
tejbeer |
249 |
|
| 31762 |
tejbeer |
250 |
@GetMapping(value = "/cs/createPosition")
|
|
|
251 |
public String createPosition(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) {
|
|
|
252 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
|
|
253 |
List<TicketCategory> ticketCategories = ticketCategoryRepository.selectAll();
|
|
|
254 |
List<Region> regions = regionRepository.selectAll();
|
|
|
255 |
model.addAttribute("escalationTypes", EscalationType.values());
|
|
|
256 |
model.addAttribute("authUsers", authUsers);
|
|
|
257 |
model.addAttribute("ticketCategories", ticketCategories);
|
|
|
258 |
model.addAttribute("regions", regions);
|
| 24500 |
govind |
259 |
|
| 31762 |
tejbeer |
260 |
List<Position> positions = positionRepository.selectAllPosition();
|
|
|
261 |
LOGGER.info("positions" + positions);
|
| 30426 |
tejbeer |
262 |
|
| 31762 |
tejbeer |
263 |
Map<Integer, AuthUser> authUserIdAndAuthUserMap = csService.getAuthUserIdAndAuthUserMapUsingPositions(positions);
|
|
|
264 |
Map<Integer, TicketCategory> categoryIdAndCategoryMap = csService.getCategoryIdAndCategoryUsingPositions(positions);
|
|
|
265 |
Map<Integer, Region> regionIdAndRegionMap = csService.getRegionIdAndRegionMap(positions);
|
| 25570 |
tejbeer |
266 |
|
| 27410 |
tejbeer |
267 |
// Map<Integer, List<CustomRetailer>> positionIdAndpartnerRegionMap = csService
|
|
|
268 |
// .getpositionIdAndpartnerRegionMap(positions);
|
| 25570 |
tejbeer |
269 |
|
| 27410 |
tejbeer |
270 |
// Map<Integer, List<CustomRetailer>> addedpositionIdAndCustomRetailerMap = csService
|
|
|
271 |
// .getPositionCustomRetailerMap(positions);
|
|
|
272 |
// LOGGER.info("fofoIdAndCustomRetailerMap" + addedpositionIdAndCustomRetailerMap);
|
| 24500 |
govind |
273 |
|
| 31762 |
tejbeer |
274 |
model.addAttribute("start", offset + 1);
|
| 30426 |
tejbeer |
275 |
|
| 31762 |
tejbeer |
276 |
model.addAttribute("positions", positions);
|
|
|
277 |
model.addAttribute("authUserIdAndAuthUserMap", authUserIdAndAuthUserMap);
|
|
|
278 |
model.addAttribute("categoryIdAndCategoryMap", categoryIdAndCategoryMap);
|
|
|
279 |
model.addAttribute("regionIdAndRegionMap", regionIdAndRegionMap);
|
|
|
280 |
// model.addAttribute("positionIdAndCustomRetailerMap",
|
|
|
281 |
// addedpositionIdAndCustomRetailerMap);
|
|
|
282 |
// model.addAttribute("positionIdAndpartnerRegionMap",
|
| 27410 |
tejbeer |
283 |
// positionIdAndpartnerRegionMap);
|
| 25570 |
tejbeer |
284 |
|
| 31762 |
tejbeer |
285 |
return "create-position";
|
|
|
286 |
}
|
| 24500 |
govind |
287 |
|
| 31762 |
tejbeer |
288 |
@GetMapping(value = "/cs/position-paginated")
|
|
|
289 |
public String positionPaginated(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) {
|
| 24500 |
govind |
290 |
|
| 31762 |
tejbeer |
291 |
List<Position> positions = positionRepository.selectAll(offset, limit);
|
|
|
292 |
Map<Integer, AuthUser> authUserIdAndAuthUserMap = csService.getAuthUserIdAndAuthUserMapUsingPositions(positions);
|
|
|
293 |
Map<Integer, TicketCategory> categoryIdAndCategoryMap = csService.getCategoryIdAndCategoryUsingPositions(positions);
|
|
|
294 |
Map<Integer, Region> regionIdAndRegionMap = csService.getRegionIdAndRegionMap(positions);
|
|
|
295 |
/*
|
|
|
296 |
* Map<Integer, List<CustomRetailer>> positionIdAndpartnerRegionMap = csService
|
|
|
297 |
* .getpositionIdAndpartnerRegionMap(positions);
|
|
|
298 |
*
|
|
|
299 |
* Map<Integer, List<CustomRetailer>> addedpositionIdAndCustomRetailerMap =
|
|
|
300 |
* csService .getPositionCustomRetailerMap(positions);
|
|
|
301 |
*/
|
| 25570 |
tejbeer |
302 |
|
| 31762 |
tejbeer |
303 |
model.addAttribute("positions", positions);
|
|
|
304 |
model.addAttribute("authUserIdAndAuthUserMap", authUserIdAndAuthUserMap);
|
|
|
305 |
model.addAttribute("categoryIdAndCategoryMap", categoryIdAndCategoryMap);
|
|
|
306 |
model.addAttribute("regionIdAndRegionMap", regionIdAndRegionMap);
|
|
|
307 |
// model.addAttribute("positionIdAndCustomRetailerMap",
|
|
|
308 |
// addedpositionIdAndCustomRetailerMap);
|
|
|
309 |
// model.addAttribute("positionIdAndpartnerRegionMap",
|
|
|
310 |
// positionIdAndpartnerRegionMap);
|
| 25570 |
tejbeer |
311 |
|
| 31762 |
tejbeer |
312 |
return "position-paginated";
|
|
|
313 |
}
|
| 24417 |
govind |
314 |
|
| 31762 |
tejbeer |
315 |
@PostMapping(value = "/cs/createPosition")
|
|
|
316 |
public String createPosition(HttpServletRequest request, @RequestBody CreatePositionModel createPositionModel, Model model) throws Exception {
|
| 24417 |
govind |
317 |
|
| 25570 |
tejbeer |
318 |
|
| 31762 |
tejbeer |
319 |
LOGGER.info("partnerPosition" + createPositionModel.isTicketAssigned());
|
|
|
320 |
Position position = positionRepository.selectPosition(createPositionModel.getAuthUserId(), createPositionModel.getCategoryId(), createPositionModel.getRegionId(), createPositionModel.getEscalationType());
|
|
|
321 |
if (position == null) {
|
|
|
322 |
position = new Position();
|
|
|
323 |
position.setAuthUserId(createPositionModel.getAuthUserId());
|
|
|
324 |
position.setCategoryId(createPositionModel.getCategoryId());
|
|
|
325 |
position.setEscalationType(createPositionModel.getEscalationType());
|
|
|
326 |
position.setRegionId(createPositionModel.getRegionId());
|
|
|
327 |
position.setCreateTimestamp(LocalDateTime.now());
|
|
|
328 |
position.setTicketAssignee(createPositionModel.isTicketAssigned());
|
|
|
329 |
positionRepository.persist(position);
|
| 25570 |
tejbeer |
330 |
|
| 31762 |
tejbeer |
331 |
for (int fofoId : createPositionModel.getFofoIds()) {
|
| 25570 |
tejbeer |
332 |
|
| 31762 |
tejbeer |
333 |
PartnerPosition partnerPosition = new PartnerPosition();
|
|
|
334 |
partnerPosition.setFofoId(fofoId);
|
|
|
335 |
partnerPosition.setRegionId(createPositionModel.getRegionId());
|
|
|
336 |
partnerPosition.setPositionId(position.getId());
|
| 32493 |
amit.gupta |
337 |
partnerPositionRepository.persist(partnerPosition);
|
| 31762 |
tejbeer |
338 |
LOGGER.info("partnerPosition" + partnerPosition);
|
|
|
339 |
}
|
| 24417 |
govind |
340 |
|
| 31762 |
tejbeer |
341 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
342 |
} else {
|
|
|
343 |
throw new ProfitMandiBusinessException("Position", createPositionModel.getAuthUserId(), "already exists!");
|
|
|
344 |
}
|
|
|
345 |
return "response";
|
|
|
346 |
}
|
| 25570 |
tejbeer |
347 |
|
| 31762 |
tejbeer |
348 |
@PostMapping(value = "/cs/updatePartnerPosition")
|
|
|
349 |
public String updatePartnerPosition(HttpServletRequest request, @RequestParam(name = "regionId") int regionId, @RequestBody List<Integer> selectedFofoIds, @RequestParam(name = "positionId") int positionId, Model model) throws Exception {
|
| 25570 |
tejbeer |
350 |
|
| 32493 |
amit.gupta |
351 |
partnerPositionRepository.delete(positionId);
|
| 31762 |
tejbeer |
352 |
for (int fofoId : selectedFofoIds) {
|
|
|
353 |
PartnerPosition partnerPosition = new PartnerPosition();
|
|
|
354 |
partnerPosition.setFofoId(fofoId);
|
|
|
355 |
partnerPosition.setRegionId(regionId);
|
|
|
356 |
partnerPosition.setPositionId(positionId);
|
| 32493 |
amit.gupta |
357 |
partnerPositionRepository.persist(partnerPosition);
|
| 31762 |
tejbeer |
358 |
}
|
| 25570 |
tejbeer |
359 |
|
| 31762 |
tejbeer |
360 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 25570 |
tejbeer |
361 |
|
| 31762 |
tejbeer |
362 |
return "response";
|
|
|
363 |
}
|
| 24417 |
govind |
364 |
|
| 31762 |
tejbeer |
365 |
@GetMapping(value = "/cs/createTicket")
|
|
|
366 |
public String createTicket(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
367 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
368 |
List<TicketCategory> ticketCategories = csService.getAllTicketCategotyFromSubCategory();
|
|
|
369 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
|
|
370 |
model.addAttribute("ticketCategories", ticketCategories);
|
|
|
371 |
return "create-ticket";
|
|
|
372 |
}
|
| 24417 |
govind |
373 |
|
| 31762 |
tejbeer |
374 |
@GetMapping(value = "/cs/getSubCategoriesByCategoryId")
|
|
|
375 |
public String getSubCategoriesByCategoryId(HttpServletRequest request, @RequestParam(name = "categoryId", defaultValue = "0") int categoryId, Model model) {
|
| 31830 |
amit.gupta |
376 |
List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository.selectAllVisible(categoryId);
|
| 31762 |
tejbeer |
377 |
LOGGER.info(ticketSubCategories);
|
|
|
378 |
model.addAttribute("ticketSubCategories", ticketSubCategories);
|
|
|
379 |
return "ticket-sub-categories";
|
|
|
380 |
}
|
| 24417 |
govind |
381 |
|
| 24791 |
govind |
382 |
|
| 31762 |
tejbeer |
383 |
@GetMapping(value = "/cs/getEscalationTypeByCategoryId")
|
|
|
384 |
public String getEscalationTypeByCategoryId(HttpServletRequest request, @RequestParam(name = "categoryId", defaultValue = "0") int categoryId, @RequestParam(name = "authId", defaultValue = "0") int authId, Model model) {
|
|
|
385 |
List<Position> positions = positionRepository.selectPositionbyCategoryIdAndAuthId(categoryId, authId);
|
|
|
386 |
List<EscalationType> escalationTypes = new ArrayList<>();
|
| 24791 |
govind |
387 |
|
| 31762 |
tejbeer |
388 |
if (!positions.isEmpty()) {
|
|
|
389 |
escalationTypes = positions.stream().map(x -> x.getEscalationType()).distinct().collect(Collectors.toList());
|
|
|
390 |
}
|
| 24620 |
govind |
391 |
|
| 31762 |
tejbeer |
392 |
LOGGER.info("escalationTypes {}", escalationTypes);
|
| 24500 |
govind |
393 |
|
| 31762 |
tejbeer |
394 |
model.addAttribute("escalationTypes", escalationTypes);
|
|
|
395 |
return "ticket-escalationtype";
|
|
|
396 |
}
|
| 24500 |
govind |
397 |
|
| 24824 |
govind |
398 |
|
| 31762 |
tejbeer |
399 |
@GetMapping(value = "/cs/getCategoriesByAuthId")
|
|
|
400 |
public String getCategoriesByAuthId(HttpServletRequest request, @RequestParam(name = "authId", defaultValue = "0") int authId, Model model) {
|
| 24824 |
govind |
401 |
|
| 24787 |
govind |
402 |
|
| 31762 |
tejbeer |
403 |
List<Position> positions = positionRepository.selectPositionByAuthId(authId);
|
| 24791 |
govind |
404 |
|
| 31762 |
tejbeer |
405 |
LOGGER.info("positions {}", positions);
|
| 24417 |
govind |
406 |
|
| 31762 |
tejbeer |
407 |
List<TicketCategory> ticketCategories = new ArrayList<TicketCategory>();
|
| 24417 |
govind |
408 |
|
| 31762 |
tejbeer |
409 |
if (!positions.isEmpty()) {
|
| 24417 |
govind |
410 |
|
| 31762 |
tejbeer |
411 |
List<Integer> categoryIds = positions.stream().map(x -> x.getCategoryId()).collect(Collectors.toList());
|
|
|
412 |
ticketCategories = ticketCategoryRepository.selectAll(categoryIds);
|
|
|
413 |
}
|
|
|
414 |
LOGGER.info("ticketCategories {}", ticketCategories);
|
|
|
415 |
model.addAttribute("ticketCategories", ticketCategories);
|
|
|
416 |
return "ticket-categories";
|
|
|
417 |
}
|
| 27270 |
tejbeer |
418 |
|
| 31762 |
tejbeer |
419 |
@PostMapping(value = "/cs/createTicket")
|
|
|
420 |
public String createTicket(HttpServletRequest request, @RequestParam(name = "categoryId") int categoryId, @RequestParam(name = "subCategoryId") int subCategoryId, @RequestParam(name = "message") String message, Model model) throws Exception {
|
|
|
421 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
422 |
List<Ticket> tickets = ticketRepository.selectAllResolvedMarkedTicketByCreator(loginDetails.getFofoId());
|
|
|
423 |
if (tickets.size() > 3 || tickets.size() == 3) {
|
|
|
424 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
|
|
425 |
} else {
|
|
|
426 |
csService.createTicket(loginDetails.getFofoId(), categoryId, subCategoryId, message);
|
|
|
427 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
428 |
}
|
|
|
429 |
return "response";
|
|
|
430 |
}
|
| 27270 |
tejbeer |
431 |
|
| 31762 |
tejbeer |
432 |
@GetMapping(value = "/cs/myticket")
|
|
|
433 |
public String getTicket(HttpServletRequest request, @RequestParam(name = "orderby", defaultValue = "DESCENDING") SortOrder sortOrder, @RequestParam(name = "ticketStatus", defaultValue = "OPENED") TicketStatus ticketStatus, @RequestParam(name = "ticketSearchType", defaultValue = "") TicketSearchType ticketSearchType, @RequestParam(name = "searchTerm", defaultValue = "0") int searchTerm, Model model) throws ProfitMandiBusinessException {
|
|
|
434 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
435 |
List<Ticket> tickets = null;
|
|
|
436 |
List<TicketAssigned> ticketAssigneds = null;
|
|
|
437 |
long size = 0;
|
|
|
438 |
Map<Integer, AuthUser> authUserIdAndAuthUserMap = null;
|
|
|
439 |
if (roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))) {
|
|
|
440 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
|
|
441 |
if (ticketSearchType == null) {
|
|
|
442 |
if (ticketStatus.equals(TicketStatus.RESOLVED)) {
|
|
|
443 |
tickets = ticketRepository.selectAllByAssignee(authUser.getId(), Optional.empty(), sortOrder, null, searchTerm);
|
|
|
444 |
size = ticketRepository.selectAllCountByAssignee(authUser.getId(), Optional.empty(), null, searchTerm);
|
|
|
445 |
} else {
|
|
|
446 |
tickets = ticketRepository.selectAllByAssignee(authUser.getId(), Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), sortOrder, null, searchTerm);
|
|
|
447 |
size = ticketRepository.selectAllCountByAssignee(authUser.getId(), Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), null, searchTerm);
|
|
|
448 |
}
|
| 27270 |
tejbeer |
449 |
|
| 31762 |
tejbeer |
450 |
} else {
|
| 27270 |
tejbeer |
451 |
|
| 31762 |
tejbeer |
452 |
if (ticketStatus.equals(TicketStatus.RESOLVED)) {
|
|
|
453 |
tickets = ticketRepository.selectAllByAssignee(authUser.getId(), Optional.empty(), sortOrder, ticketSearchType, searchTerm);
|
|
|
454 |
size = ticketRepository.selectAllCountByAssignee(authUser.getId(), Optional.empty(), ticketSearchType, searchTerm);
|
|
|
455 |
} else {
|
|
|
456 |
tickets = ticketRepository.selectAllByAssignee(authUser.getId(), Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), sortOrder, ticketSearchType, searchTerm);
|
|
|
457 |
size = ticketRepository.selectAllCountByAssignee(authUser.getId(), Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), ticketSearchType, searchTerm);
|
|
|
458 |
}
|
|
|
459 |
}
|
|
|
460 |
// LOGGER.info(size + "size");
|
|
|
461 |
if (tickets.size() > 0) {
|
|
|
462 |
ticketAssigneds = ticketAssignedRepository.selectByTicketIds(tickets.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
|
|
463 |
authUserIdAndAuthUserMap = csService.getAuthUserIdAndAuthUserMap(ticketAssigneds);
|
|
|
464 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
|
|
|
465 |
model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
|
|
|
466 |
}
|
| 24500 |
govind |
467 |
|
| 31762 |
tejbeer |
468 |
} else {
|
|
|
469 |
tickets = ticketRepository.selectAllByCreator(loginDetails.getFofoId(), Optional.of(TicketStatus.OPENED.equals(ticketStatus)), sortOrder);
|
|
|
470 |
size = ticketRepository.selectAllCountByCreator(loginDetails.getFofoId(), Optional.of(TicketStatus.OPENED.equals(ticketStatus)));
|
|
|
471 |
}
|
|
|
472 |
authUserIdAndAuthUserMap = csService.getTicketIdAndAuthUserMapUsingTickets(tickets);
|
| 24620 |
govind |
473 |
|
| 31762 |
tejbeer |
474 |
model.addAttribute("size", size);
|
|
|
475 |
model.addAttribute("roleType", roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds())));
|
| 24500 |
govind |
476 |
|
| 31762 |
tejbeer |
477 |
List<Integer> subCategoryIds = tickets.stream().map(x -> x.getSubCategoryId()).collect(Collectors.toList());
|
|
|
478 |
Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = csService.getSubCategoryIdAndSubCategoryMap(subCategoryIds);
|
| 24747 |
govind |
479 |
|
| 31762 |
tejbeer |
480 |
Map<Integer, TicketCategory> subCategoryIdAndCategoryMap = csService.getSubCategoryIdAndCategoryMap(subCategoryIds);
|
| 27318 |
amit.gupta |
481 |
|
| 31762 |
tejbeer |
482 |
List<Integer> ticketIds = tickets.stream().map(x -> x.getId()).collect(Collectors.toList());
|
| 24500 |
govind |
483 |
|
| 31762 |
tejbeer |
484 |
Map<Integer, List<Activity>> activityMap = new HashMap<Integer, List<Activity>>();
|
| 33864 |
ranu |
485 |
Map<Integer, List<Activity>> activityMapWithActivityId = new HashMap<>();
|
| 24500 |
govind |
486 |
|
| 31762 |
tejbeer |
487 |
if (!ticketIds.isEmpty()) {
|
|
|
488 |
activityMap = activityRepository.selectAll(ticketIds).stream().collect(Collectors.groupingBy(x -> x.getTicketId()));
|
| 33864 |
ranu |
489 |
activityMapWithActivityId = activityRepository.selectAll(ticketIds).stream().collect(Collectors.groupingBy(x -> x.getId()));
|
| 24787 |
govind |
490 |
|
| 31762 |
tejbeer |
491 |
}
|
| 24787 |
govind |
492 |
|
| 33864 |
ranu |
493 |
List<AuthUser> authUsersList = authRepository.selectAll();
|
|
|
494 |
Map<Integer, AuthUser> authUserMap = authUsersList.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 24787 |
govind |
495 |
|
| 31762 |
tejbeer |
496 |
model.addAttribute("tickets", tickets);
|
|
|
497 |
model.addAttribute("resolved", ActivityType.RESOLVED);
|
|
|
498 |
model.addAttribute("resolved-accepted", ActivityType.RESOLVED_ACCEPTED);
|
|
|
499 |
model.addAttribute("resolved-rejected", ActivityType.RESOLVED_REJECTED);
|
|
|
500 |
model.addAttribute("authUserIdAndAuthUserMap", authUserIdAndAuthUserMap);
|
|
|
501 |
model.addAttribute("subCategoryIdAndSubCategoryMap", subCategoryIdAndSubCategoryMap);
|
| 27318 |
amit.gupta |
502 |
|
| 31762 |
tejbeer |
503 |
model.addAttribute("subCategoryIdAndCategoryMap", subCategoryIdAndCategoryMap);
|
|
|
504 |
model.addAttribute("activityMap", activityMap);
|
| 33864 |
ranu |
505 |
model.addAttribute("authUserMap", authUserMap);
|
|
|
506 |
model.addAttribute("activityMapWithActivityId", activityMapWithActivityId);
|
| 24500 |
govind |
507 |
|
| 31762 |
tejbeer |
508 |
model.addAttribute("ticketStatusValues", TicketStatus.values());
|
|
|
509 |
model.addAttribute("orderByValues", SortOrder.values());
|
|
|
510 |
model.addAttribute("selectedticketStatus", ticketStatus);
|
|
|
511 |
model.addAttribute("selectedorderby", sortOrder);
|
|
|
512 |
model.addAttribute("ticketSearchTypes", TicketSearchType.values());
|
|
|
513 |
model.addAttribute("ticketSearchType", ticketSearchType);
|
|
|
514 |
model.addAttribute("searchTerm", searchTerm);
|
|
|
515 |
return "ticket";
|
|
|
516 |
}
|
| 24500 |
govind |
517 |
|
| 27124 |
amit.gupta |
518 |
|
| 31762 |
tejbeer |
519 |
@GetMapping(value = "/cs/getActivities")
|
|
|
520 |
public String getActivity(HttpServletRequest request, @RequestParam(name = "ticketId", defaultValue = "0") int ticketId, Model model) throws Exception {
|
|
|
521 |
List<Activity> allactivities = activityRepository.selectAll(ticketId);
|
|
|
522 |
List<List<ActivityAttachment>> activityAttachments = allactivities.stream().map(x -> x.getActivityAttachment()).collect(Collectors.toList());
|
|
|
523 |
for (List<ActivityAttachment> aA : activityAttachments) {
|
|
|
524 |
// List<ActivityAttachment> documentId = aA.stream().map(x ->
|
|
|
525 |
// x).collect(Collectors.toList());
|
|
|
526 |
for (ActivityAttachment attachment : aA) {
|
|
|
527 |
Document document = documentRepository.selectById(attachment.getDocumentId());
|
|
|
528 |
attachment.setDocumentName(document.getDisplayName());
|
|
|
529 |
activityAttachmentRepository.persist(attachment);
|
|
|
530 |
}
|
|
|
531 |
}
|
|
|
532 |
List<Activity> activities = null;
|
|
|
533 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
534 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
|
|
535 |
Set<Integer> authUserIds = allactivities.stream().map(x -> x.getCreatedBy()).collect(Collectors.toSet());
|
| 35395 |
amit |
536 |
List<AuthUser> users = authRepository.selectByIds(new ArrayList<>(authUserIds));
|
| 31762 |
tejbeer |
537 |
Map<Integer, String> authUserNameMap = users.stream().collect(Collectors.toMap(AuthUser::getId, x -> x.getFirstName() + " " + x.getLastName()));
|
|
|
538 |
allactivities.stream().forEach(x -> x.setName(authUserNameMap.get(x.getCreatedBy())));
|
|
|
539 |
activities = allactivities;
|
|
|
540 |
} else {
|
|
|
541 |
activities = allactivities.stream().filter(x -> ActivityType.PARTNER_ACTIVITIES.contains(x.getType())).collect(Collectors.toList());
|
|
|
542 |
}
|
|
|
543 |
if (activities == null) {
|
|
|
544 |
throw new ProfitMandiBusinessException("Activity", ticketId, "No Activity Found");
|
|
|
545 |
}
|
|
|
546 |
model.addAttribute("response1", mvcResponseSender.createResponseString(activities));
|
|
|
547 |
return "response";
|
| 24500 |
govind |
548 |
|
| 31762 |
tejbeer |
549 |
}
|
| 24620 |
govind |
550 |
|
| 31762 |
tejbeer |
551 |
@PostMapping(value = "/cs/createActivity")
|
|
|
552 |
public String createActivity(HttpServletRequest request, @RequestParam(name = "ticketId", defaultValue = "0") int ticketId, @RequestParam(name = "assigneeId", defaultValue = "0") int assigneeId, @RequestParam(name = "internal", defaultValue = "true") boolean internal, @RequestParam(name = "message", defaultValue = "") String message, @RequestBody List<Integer> documentIds,
|
| 24620 |
govind |
553 |
|
| 31762 |
tejbeer |
554 |
Model model) throws Exception {
|
| 24620 |
govind |
555 |
|
| 31762 |
tejbeer |
556 |
LOGGER.info("documentIds" + documentIds);
|
|
|
557 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
558 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
|
|
559 |
List<TicketAssigned> ticketAssignedList = ticketAssignedRepository.selectByTicketIds(Arrays.asList(ticketId));
|
|
|
560 |
List<Integer> authUserIds = ticketAssignedList.stream().map(x -> x.getAssineeId()).collect(Collectors.toList());
|
|
|
561 |
authUserIds.add(ticketAssignedList.get(ticketAssignedList.size() - 1).getManagerId());
|
| 35395 |
amit |
562 |
Map<Integer, AuthUser> authUsersMap = authRepository.selectByIds(authUserIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 31762 |
tejbeer |
563 |
if (ticket.getCloseTimestamp() == null) {
|
|
|
564 |
Activity activity = new Activity();
|
|
|
565 |
activity.setCreatedBy(0);
|
|
|
566 |
activity.setCreateTimestamp(LocalDateTime.now());
|
|
|
567 |
String subject = null;
|
|
|
568 |
String mailMessage = null;
|
|
|
569 |
activity.setMessage(message);
|
|
|
570 |
if (!roleManager.isAdmin(new HashSet<>(loginDetails.getRoleIds()))) {
|
|
|
571 |
CustomRetailer customRetailer = retailerService.getFofoRetailers(true).get(loginDetails.getFofoId());
|
|
|
572 |
activity.setType(ActivityType.COMMUNICATION_IN);
|
|
|
573 |
subject = String.format("Ticket Update #%s by franchisee %s", ticket.getId(), customRetailer.getBusinessName() + "(" + customRetailer.getCode() + ")");
|
|
|
574 |
mailMessage = String.format("Franchisee message - %s", message);
|
|
|
575 |
} else {
|
|
|
576 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
|
|
577 |
activity.setCreatedBy(authUser.getId());
|
|
|
578 |
authUsersMap.remove(authUser.getId());
|
|
|
579 |
subject = String.format("Ticket Update #%s by %s", ticket.getId(), authUser.getName());
|
|
|
580 |
mailMessage = String.format("%s's message - %s", authUser.getFirstName(), message);
|
|
|
581 |
if (internal) {
|
|
|
582 |
activity.setType(ActivityType.COMMUNICATION_INTERNAL);
|
|
|
583 |
// String subject = String.format(ACTIVITY_SUBJECT, ticket.getId());
|
|
|
584 |
} else {
|
|
|
585 |
String updatedBy = "SD Team";
|
| 31854 |
amit.gupta |
586 |
CustomRetailer customRetailer = retailerService.getFofoRetailers(false).get(ticket.getFofoId());
|
| 31762 |
tejbeer |
587 |
subject = String.format("Ticket Update #%s by %s", ticket.getId(), updatedBy);
|
|
|
588 |
String partnerMessage = String.format("%s's message - %s", updatedBy, message);
|
|
|
589 |
this.activityRelatedMail(customRetailer.getEmail(), null, "subject", partnerMessage);
|
|
|
590 |
activity.setType(ActivityType.COMMUNICATION_OUT);
|
|
|
591 |
}
|
|
|
592 |
}
|
|
|
593 |
activityRepository.persist(activity);
|
|
|
594 |
|
|
|
595 |
for (Integer documentId : documentIds) {
|
|
|
596 |
ActivityAttachment activityAttachment = new ActivityAttachment();
|
|
|
597 |
activityAttachment.setActivityId(activity.getId());
|
|
|
598 |
activityAttachment.setDocumentId(documentId);
|
|
|
599 |
activityAttachmentRepository.persist(activityAttachment);
|
|
|
600 |
}
|
|
|
601 |
|
|
|
602 |
csService.addActivity(ticket, activity);
|
|
|
603 |
AuthUser authUser = authUsersMap.remove(authUserIds.get(0));
|
|
|
604 |
if (authUser == null) {
|
|
|
605 |
authUser = authUsersMap.remove(authUserIds.get(1));
|
|
|
606 |
}
|
|
|
607 |
model.addAttribute("response1", mvcResponseSender.createResponseString(authUser));
|
|
|
608 |
String[] cc = authUsersMap.entrySet().stream().map(x -> x.getValue().getEmailId()).toArray(String[]::new);
|
|
|
609 |
this.activityRelatedMail(authUser.getEmailId(), cc, subject, mailMessage);
|
|
|
610 |
} else {
|
|
|
611 |
throw new ProfitMandiBusinessException("Ticket", ticket.getId(), "Already closed ticket");
|
|
|
612 |
}
|
|
|
613 |
return "response";
|
|
|
614 |
}
|
|
|
615 |
|
|
|
616 |
private void activityRelatedMail(String to, String[] cc, String subject, String message) throws ProfitMandiBusinessException {
|
|
|
617 |
try {
|
|
|
618 |
Utils.sendMailWithAttachments(mailSender, to, cc, subject, message, null);
|
|
|
619 |
} catch (Exception e) {
|
|
|
620 |
throw new ProfitMandiBusinessException("Ticket Activity", to, "Could not send ticket activity mail");
|
|
|
621 |
}
|
|
|
622 |
}
|
|
|
623 |
|
|
|
624 |
@PostMapping(value = "/cs/closeTicket")
|
|
|
625 |
public String closeTicket(HttpServletRequest request, @RequestParam(name = "ticketId", defaultValue = "0") int ticketId, @RequestParam(name = "happyCode") String happyCode, Model model) throws Exception {
|
|
|
626 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
|
|
627 |
if (ticket.getHappyCode().equals(happyCode)) {
|
|
|
628 |
ticket.setCloseTimestamp(LocalDateTime.now());
|
|
|
629 |
ticketRepository.persist(ticket);
|
|
|
630 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
631 |
} else {
|
|
|
632 |
throw new ProfitMandiBusinessException("Ticket", ticketId, "Happy Code can't match");
|
|
|
633 |
}
|
|
|
634 |
return "response";
|
|
|
635 |
}
|
|
|
636 |
|
| 34913 |
ranu |
637 |
@GetMapping(value = "/cs/myPartyTicketTicket")
|
|
|
638 |
public String getMyPartyTicketTicket(HttpServletRequest request, @RequestParam(name = "orderby", defaultValue = "DESCENDING") SortOrder sortOrder, @RequestParam(name = "ticketStatus", defaultValue = "OPENED") TicketStatus ticketStatus, @RequestParam(name = "ticketSearchType", defaultValue = "") TicketSearchType ticketSearchType, @RequestParam(name = "searchTerm", defaultValue = "0") int searchTerm, Model model) throws ProfitMandiBusinessException {
|
|
|
639 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
640 |
long size = 0;
|
|
|
641 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
|
|
642 |
List<Ticket> tickets = new ArrayList<>();
|
|
|
643 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
644 |
Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
|
|
|
645 |
|
|
|
646 |
Map<Integer, List<AuthUser>> authUserListMap = null;
|
|
|
647 |
if (fofoIds != null && !fofoIds.isEmpty()) {
|
|
|
648 |
for (Integer fofoId : fofoIds) {
|
|
|
649 |
List<Ticket> partnerWiseTickets = ticketRepository.selectAllOpenTicketByRetailer(fofoId);
|
|
|
650 |
|
|
|
651 |
if (partnerWiseTickets != null && !partnerWiseTickets.isEmpty()) {
|
|
|
652 |
// Filter tickets where last_activity is not "RESOLVED"
|
|
|
653 |
List<Ticket> filteredTickets = partnerWiseTickets.stream()
|
|
|
654 |
.filter(ticket -> ticket.getLastActivity() == null ||
|
|
|
655 |
ticket.getLastActivity() != ActivityType.RESOLVED)
|
|
|
656 |
.collect(Collectors.toList());
|
|
|
657 |
|
|
|
658 |
tickets.addAll(filteredTickets);
|
|
|
659 |
}
|
|
|
660 |
}
|
|
|
661 |
}
|
|
|
662 |
|
|
|
663 |
authUserListMap = csService.getAssignedAuthList(tickets);
|
|
|
664 |
|
|
|
665 |
|
|
|
666 |
if (tickets.size() > 0) {
|
|
|
667 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
|
|
|
668 |
model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
|
|
|
669 |
}
|
|
|
670 |
|
|
|
671 |
model.addAttribute("size", tickets.size());
|
|
|
672 |
model.addAttribute("tickets", tickets);
|
|
|
673 |
|
|
|
674 |
List<Integer> subCategoryIds = tickets.stream().map(x -> x.getSubCategoryId()).collect(Collectors.toList());
|
|
|
675 |
Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = csService.getSubCategoryIdAndSubCategoryMap(subCategoryIds);
|
|
|
676 |
|
|
|
677 |
Map<Integer, TicketCategory> subCategoryIdAndCategoryMap = csService.getSubCategoryIdAndCategoryMap(subCategoryIds);
|
|
|
678 |
|
|
|
679 |
List<Integer> ticketIds = tickets.stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
680 |
Map<Integer, List<Activity>> activityMap = new HashMap<>();
|
|
|
681 |
Map<Integer, List<Activity>> activityMapWithActivityId = new HashMap<>();
|
|
|
682 |
|
|
|
683 |
if (!ticketIds.isEmpty()) {
|
|
|
684 |
activityMap = activityRepository.selectAll(ticketIds).stream().collect(Collectors.groupingBy(x -> x.getTicketId()));
|
|
|
685 |
activityMapWithActivityId = activityRepository.selectAll(ticketIds).stream().collect(Collectors.groupingBy(x -> x.getId()));
|
|
|
686 |
|
|
|
687 |
}
|
|
|
688 |
|
|
|
689 |
List<AuthUser> authUsersList = authRepository.selectAll();
|
|
|
690 |
Map<Integer, AuthUser> authUserMap = authUsersList.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
|
|
691 |
|
|
|
692 |
model.addAttribute("ticketStatusValues", TicketStatus.values());
|
|
|
693 |
model.addAttribute("orderByValues", SortOrder.values());
|
|
|
694 |
model.addAttribute("selectedticketStatus", ticketStatus);
|
|
|
695 |
model.addAttribute("selectedorderby", sortOrder);
|
|
|
696 |
model.addAttribute("tickets", tickets);
|
|
|
697 |
model.addAttribute("ticketSearchTypes", TicketSearchType.values());
|
|
|
698 |
model.addAttribute("ticketSearchType", ticketSearchType);
|
|
|
699 |
model.addAttribute("searchTerm", searchTerm);
|
|
|
700 |
model.addAttribute("authUserListMap", authUserListMap);
|
|
|
701 |
model.addAttribute("subCategoryIdAndSubCategoryMap", subCategoryIdAndSubCategoryMap);
|
|
|
702 |
|
|
|
703 |
model.addAttribute("subCategoryIdAndCategoryMap", subCategoryIdAndCategoryMap);
|
|
|
704 |
|
|
|
705 |
model.addAttribute("activityMap", activityMap);
|
|
|
706 |
model.addAttribute("authUserMap", authUserMap);
|
|
|
707 |
model.addAttribute("activityMapWithActivityId", activityMapWithActivityId);
|
|
|
708 |
|
|
|
709 |
return "my-partner-tickets";
|
|
|
710 |
}
|
|
|
711 |
|
| 31762 |
tejbeer |
712 |
@GetMapping(value = "/cs/managerTicket")
|
|
|
713 |
public String getManagerTickets(HttpServletRequest request, @RequestParam(name = "orderby", defaultValue = "DESCENDING") SortOrder sortOrder, @RequestParam(name = "ticketStatus", defaultValue = "OPENED") TicketStatus ticketStatus, @RequestParam(name = "ticketSearchType", defaultValue = "") TicketSearchType ticketSearchType, @RequestParam(name = "searchTerm", defaultValue = "0") int searchTerm, Model model) throws ProfitMandiBusinessException {
|
|
|
714 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
715 |
long size = 0;
|
|
|
716 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
|
|
717 |
List<Ticket> tickets = null;
|
|
|
718 |
Map<Integer, List<AuthUser>> authUserListMap = null;
|
|
|
719 |
if (ticketSearchType == null) {
|
|
|
720 |
if (ticketStatus.equals(TicketStatus.RESOLVED)) {
|
|
|
721 |
tickets = ticketRepository.selectAllManagerTicket(authUser.getId(), sortOrder, Optional.empty(), null, searchTerm);
|
|
|
722 |
size = ticketRepository.selectAllCountByManagerTicket(authUser.getId(), Optional.empty(), null, 0);
|
|
|
723 |
} else {
|
|
|
724 |
tickets = ticketRepository.selectAllManagerTicket(authUser.getId(), sortOrder, Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), null, searchTerm);
|
|
|
725 |
size = ticketRepository.selectAllCountByManagerTicket(authUser.getId(), Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), null, 0);
|
|
|
726 |
}
|
|
|
727 |
} else {
|
|
|
728 |
if (ticketStatus.equals(TicketStatus.RESOLVED)) {
|
|
|
729 |
tickets = ticketRepository.selectAllManagerTicket(authUser.getId(), sortOrder, Optional.empty(), ticketSearchType, searchTerm);
|
|
|
730 |
size = ticketRepository.selectAllCountByManagerTicket(authUser.getId(), Optional.empty(), ticketSearchType, searchTerm);
|
|
|
731 |
} else {
|
|
|
732 |
tickets = ticketRepository.selectAllManagerTicket(authUser.getId(), sortOrder, Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), ticketSearchType, searchTerm);
|
|
|
733 |
size = ticketRepository.selectAllCountByManagerTicket(authUser.getId(), Optional.of(TicketStatus.CLOSED.equals(ticketStatus)), ticketSearchType, searchTerm);
|
|
|
734 |
}
|
|
|
735 |
|
|
|
736 |
}
|
|
|
737 |
authUserListMap = csService.getAssignedAuthList(tickets);
|
|
|
738 |
|
|
|
739 |
if (tickets.size() > 0) {
|
|
|
740 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = csService.getPartnerByFofoIds(tickets);
|
|
|
741 |
model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
|
|
|
742 |
}
|
|
|
743 |
|
|
|
744 |
model.addAttribute("size", size);
|
|
|
745 |
model.addAttribute("tickets", tickets);
|
|
|
746 |
|
|
|
747 |
List<Integer> subCategoryIds = tickets.stream().map(x -> x.getSubCategoryId()).collect(Collectors.toList());
|
|
|
748 |
Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = csService.getSubCategoryIdAndSubCategoryMap(subCategoryIds);
|
|
|
749 |
|
|
|
750 |
Map<Integer, TicketCategory> subCategoryIdAndCategoryMap = csService.getSubCategoryIdAndCategoryMap(subCategoryIds);
|
|
|
751 |
|
|
|
752 |
List<Integer> ticketIds = tickets.stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
753 |
Map<Integer, List<Activity>> activityMap = new HashMap<>();
|
| 33778 |
ranu |
754 |
Map<Integer, List<Activity>> activityMapWithActivityId = new HashMap<>();
|
| 31762 |
tejbeer |
755 |
|
|
|
756 |
if (!ticketIds.isEmpty()) {
|
|
|
757 |
activityMap = activityRepository.selectAll(ticketIds).stream().collect(Collectors.groupingBy(x -> x.getTicketId()));
|
| 33778 |
ranu |
758 |
activityMapWithActivityId = activityRepository.selectAll(ticketIds).stream().collect(Collectors.groupingBy(x -> x.getId()));
|
| 31762 |
tejbeer |
759 |
|
|
|
760 |
}
|
| 33778 |
ranu |
761 |
|
|
|
762 |
List<AuthUser> authUsersList = authRepository.selectAll();
|
|
|
763 |
Map<Integer, AuthUser> authUserMap = authUsersList.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
|
|
764 |
|
| 31762 |
tejbeer |
765 |
model.addAttribute("ticketStatusValues", TicketStatus.values());
|
|
|
766 |
model.addAttribute("orderByValues", SortOrder.values());
|
|
|
767 |
model.addAttribute("selectedticketStatus", ticketStatus);
|
|
|
768 |
model.addAttribute("selectedorderby", sortOrder);
|
|
|
769 |
model.addAttribute("tickets", tickets);
|
|
|
770 |
model.addAttribute("ticketSearchTypes", TicketSearchType.values());
|
|
|
771 |
model.addAttribute("ticketSearchType", ticketSearchType);
|
|
|
772 |
model.addAttribute("searchTerm", searchTerm);
|
|
|
773 |
model.addAttribute("authUserListMap", authUserListMap);
|
|
|
774 |
model.addAttribute("subCategoryIdAndSubCategoryMap", subCategoryIdAndSubCategoryMap);
|
|
|
775 |
|
|
|
776 |
model.addAttribute("subCategoryIdAndCategoryMap", subCategoryIdAndCategoryMap);
|
|
|
777 |
|
|
|
778 |
model.addAttribute("activityMap", activityMap);
|
| 33778 |
ranu |
779 |
model.addAttribute("authUserMap", authUserMap);
|
|
|
780 |
model.addAttribute("activityMapWithActivityId", activityMapWithActivityId);
|
| 31762 |
tejbeer |
781 |
|
|
|
782 |
return "managerTicket";
|
|
|
783 |
}
|
|
|
784 |
|
|
|
785 |
|
|
|
786 |
@GetMapping(value = "/cs/edit-ticket")
|
|
|
787 |
public String getEditTicket(HttpServletRequest request, @RequestParam(name = "ticketId", defaultValue = "0") int ticketId, Model model) {
|
|
|
788 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
|
|
789 |
List<TicketCategory> ticketCategories = csService.getAllTicketCategotyFromSubCategory();
|
|
|
790 |
TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.selectById(ticket.getSubCategoryId());
|
|
|
791 |
List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository.selectAll(ticketSubCategory.getCategoryId());
|
|
|
792 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
|
|
793 |
model.addAttribute("ticket", ticket);
|
|
|
794 |
model.addAttribute("ticketCategories", ticketCategories);
|
|
|
795 |
model.addAttribute("ticketSubCategories", ticketSubCategories);
|
|
|
796 |
model.addAttribute("ticketSubCategory", ticketSubCategory);
|
|
|
797 |
model.addAttribute("authUsers", authUsers);
|
|
|
798 |
return "edit-ticket-modal";
|
|
|
799 |
}
|
|
|
800 |
|
| 34913 |
ranu |
801 |
@GetMapping(value = "/cs/edit-partner-ticket")
|
|
|
802 |
public String getEditPartnerTicket(HttpServletRequest request, @RequestParam(name = "ticketId", defaultValue = "0") int ticketId, Model model) {
|
|
|
803 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
|
|
804 |
List<TicketCategory> ticketCategories = csService.getAllTicketCategotyFromSubCategory();
|
|
|
805 |
TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.selectById(ticket.getSubCategoryId());
|
|
|
806 |
List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository.selectAll(ticketSubCategory.getCategoryId());
|
|
|
807 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
|
|
808 |
model.addAttribute("ticket", ticket);
|
|
|
809 |
model.addAttribute("ticketCategories", ticketCategories);
|
|
|
810 |
model.addAttribute("ticketSubCategories", ticketSubCategories);
|
|
|
811 |
model.addAttribute("ticketSubCategory", ticketSubCategory);
|
|
|
812 |
model.addAttribute("authUsers", authUsers);
|
|
|
813 |
return "edit-ticket-partner-modal";
|
|
|
814 |
}
|
|
|
815 |
|
| 31762 |
tejbeer |
816 |
@PostMapping(value = "/cs/edit-ticket")
|
|
|
817 |
public String editTicket(HttpServletRequest request, @RequestParam(name = "ticketId", defaultValue = "0") int ticketId, @RequestParam(name = "subCategoryId", defaultValue = "0") int subCategoryId, @RequestParam(name = "categoryId", defaultValue = "0") int categoryId, @RequestParam(name = "authUserId", defaultValue = "0") int authUserId, @RequestParam(name = "escalationType", defaultValue = "L1") EscalationType escalationType, Model model) throws Exception {
|
|
|
818 |
LOGGER.info("Ticket Id {}, CategoryId {}, SubCategory Id {} authUserId {}", ticketId, categoryId, subCategoryId, authUserId);
|
|
|
819 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
|
|
820 |
csService.updateTicket(categoryId, subCategoryId, ticket, authUserId, escalationType);
|
|
|
821 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
822 |
return "response";
|
|
|
823 |
|
|
|
824 |
}
|
|
|
825 |
|
| 34913 |
ranu |
826 |
@PostMapping(value = "/cs/edit-partner-ticket")
|
|
|
827 |
public String editPartnerTicket(HttpServletRequest request, @RequestParam(name = "ticketId", defaultValue = "0") int ticketId, @RequestParam(name = "subCategoryId", defaultValue = "0") int subCategoryId, @RequestParam(name = "categoryId", defaultValue = "0") int categoryId, @RequestParam(name = "authUserId", defaultValue = "0") int authUserId, @RequestParam(name = "escalationType", defaultValue = "L1") EscalationType escalationType, Model model) throws Exception {
|
|
|
828 |
LOGGER.info("Ticket Id {}, CategoryId {}, SubCategory Id {} authUserId {}", ticketId, categoryId, subCategoryId, authUserId);
|
|
|
829 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
|
|
830 |
csService.updateTicket(categoryId, subCategoryId, ticket, authUserId, escalationType);
|
|
|
831 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
832 |
return "response";
|
|
|
833 |
|
|
|
834 |
}
|
|
|
835 |
|
| 31762 |
tejbeer |
836 |
@PostMapping(value = "/cs/changeTicketAssignee")
|
|
|
837 |
public String changeTicketAssignee(HttpServletRequest request, @RequestParam(name = "positionId", defaultValue = "0") int positionId, Model model) throws Exception {
|
|
|
838 |
Position position = positionRepository.selectById(positionId);
|
|
|
839 |
if (position.isTicketAssignee()) {
|
|
|
840 |
position.setTicketAssignee(false);
|
|
|
841 |
} else {
|
|
|
842 |
position.setTicketAssignee(true);
|
|
|
843 |
}
|
|
|
844 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
845 |
return "response";
|
|
|
846 |
}
|
|
|
847 |
|
|
|
848 |
|
|
|
849 |
@DeleteMapping(value = "/cs/removePosition")
|
|
|
850 |
public String removePosition(HttpServletRequest request, @RequestParam(name = "positionId", defaultValue = "0") int positionId, Model model) throws Exception {
|
|
|
851 |
positionRepository.delete(positionId);
|
|
|
852 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
853 |
return "response";
|
|
|
854 |
}
|
|
|
855 |
|
|
|
856 |
@PostMapping(value = "/cs/create-last-activity")
|
|
|
857 |
public String createlastActivity(HttpServletRequest request, @RequestParam(name = "ticketId") int ticketId, @RequestParam(name = "lastactivity") ActivityType lastActivity, Model model) throws Exception {
|
|
|
858 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
859 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
|
|
860 |
Activity activity = new Activity();
|
|
|
861 |
String subject = String.format(ACTIVITY_SUBJECT, ticket.getId());
|
|
|
862 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
|
|
863 |
ticket.setLastActivity(lastActivity);
|
|
|
864 |
String to = retailerService.getFofoRetailer(ticket.getFofoId()).getEmail();
|
|
|
865 |
String message = String.format(PARTNER_RESOLVED_TICKET_MAIL, ticketId, "REOPEN");
|
|
|
866 |
activity.setMessage(message);
|
|
|
867 |
activity.setCreatedBy(authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getId());
|
|
|
868 |
activity.setTicketId(ticketId);
|
|
|
869 |
activity.setCreateTimestamp(LocalDateTime.now());
|
|
|
870 |
activity.setType(ActivityType.COMMUNICATION_OUT);
|
|
|
871 |
this.activityRelatedMail(to, null, subject, message);
|
|
|
872 |
} else {
|
|
|
873 |
if (ActivityType.RESOLVED_ACCEPTED == lastActivity) {
|
|
|
874 |
ticket.setLastActivity(lastActivity);
|
|
|
875 |
ticket.setCloseTimestamp(LocalDateTime.now());
|
|
|
876 |
activity.setMessage(ActivityType.RESOLVED_ACCEPTED.toString());
|
|
|
877 |
activity.setCreatedBy(0);
|
|
|
878 |
activity.setTicketId(ticketId);
|
|
|
879 |
activity.setType(ActivityType.COMMUNICATION_IN);
|
|
|
880 |
activity.setCreateTimestamp(LocalDateTime.now());
|
|
|
881 |
} else {
|
|
|
882 |
String message = String.format(INTERNAL_REOPEN_MAIL, ticketId, retailerService.getFofoRetailer(loginDetails.getFofoId()).getBusinessName());
|
|
|
883 |
String to = authRepository.selectById(ticket.getL1AuthUser()).getEmailId();
|
| 35395 |
amit |
884 |
String[] ccTo = authRepository.selectByIds(Arrays.asList(ticket.getL2AuthUser(), ticket.getL3AuthUser(), ticket.getL4AuthUser(), ticket.getL5AuthUser())).stream().map(x -> x.getEmailId()).toArray(String[]::new);
|
| 31762 |
tejbeer |
885 |
ticket.setLastActivity(lastActivity);
|
|
|
886 |
ticket.setUpdateTimestamp(LocalDateTime.now());
|
|
|
887 |
ticketAssignedRepository.deleteByTicketId(ticketId);
|
|
|
888 |
TicketAssigned ticketAssigned = new TicketAssigned();
|
|
|
889 |
ticketAssigned.setAssineeId(ticket.getL1AuthUser());
|
|
|
890 |
ticketAssigned.setTicketId(ticketId);
|
|
|
891 |
ticketAssignedRepository.persist(ticketAssigned);
|
|
|
892 |
activity.setMessage(INTERNAL_REOPEN_ACTIVITY_MESSAGE);
|
|
|
893 |
activity.setCreatedBy(0);
|
|
|
894 |
activity.setTicketId(ticketId);
|
|
|
895 |
activity.setType(ActivityType.COMMUNICATION_IN);
|
|
|
896 |
activity.setCreateTimestamp(LocalDateTime.now());
|
|
|
897 |
this.activityRelatedMail(to, ccTo, subject, message);
|
|
|
898 |
this.activityRelatedMail(retailerService.getFofoRetailer(loginDetails.getFofoId()).getEmail(), null, subject, String.format(PARTNER_REOPEN, ticketId));
|
|
|
899 |
}
|
|
|
900 |
|
|
|
901 |
}
|
|
|
902 |
activityRepository.persist(activity);
|
|
|
903 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
904 |
return "response";
|
|
|
905 |
}
|
|
|
906 |
|
| 32812 |
shampa |
907 |
|
|
|
908 |
|
|
|
909 |
|
|
|
910 |
|
|
|
911 |
@PostMapping(value = "/partner-position/update")
|
|
|
912 |
public String positionUpdated(Model model, @RequestBody List<PartnerPositonUpdateModel> partnerPositionUpdateModels)
|
|
|
913 |
throws Exception {
|
|
|
914 |
|
| 32821 |
shampa |
915 |
Map<Integer, List<String>> positionIdsToAddMap = partnerPositionUpdateModels.stream().filter(x->x.getPositionIdTo()!=0).collect(Collectors.groupingBy(x->x.getPositionIdTo(),
|
| 32812 |
shampa |
916 |
Collectors.mapping(x->x.getStoreCode(), Collectors.toList())));
|
|
|
917 |
|
| 32821 |
shampa |
918 |
Map<Integer, List<String>> positionIdsToRemoveMap = partnerPositionUpdateModels.stream().filter(x->x.getPositionIdFrom()!=0).collect(Collectors.groupingBy(x->x.getPositionIdFrom(),
|
| 32812 |
shampa |
919 |
Collectors.mapping(x->x.getStoreCode(), Collectors.toList())));
|
|
|
920 |
|
|
|
921 |
List<Integer> positionIdsToUpdate = new ArrayList<>();
|
|
|
922 |
positionIdsToUpdate.addAll(positionIdsToAddMap.keySet());
|
|
|
923 |
positionIdsToUpdate.addAll(positionIdsToRemoveMap.keySet());
|
|
|
924 |
|
| 35395 |
amit |
925 |
Map<Integer, Position> positionsToUpdateMap = positionRepository.selectByIds(positionIdsToUpdate).stream().collect(Collectors.toMap(x->x.getId(), x->x));
|
| 32812 |
shampa |
926 |
List<Integer> invalidPositionIds = positionsToUpdateMap.values().stream().filter(x-> x.getCategoryId()!= ProfitMandiConstants.TICKET_CATEGORY_RBM
|
| 34908 |
ranu |
927 |
&& x.getCategoryId() != ProfitMandiConstants.TICKET_CATEGORY_SALES && x.getCategoryId() != ProfitMandiConstants.TICKET_CATEGORY_ABM).map(x -> x.getId()).collect(Collectors.toList());
|
| 32812 |
shampa |
928 |
if(invalidPositionIds.size() > 0) {
|
| 34908 |
ranu |
929 |
String message = "Non RBM/Sales/ABM are not allowed - " + invalidPositionIds;
|
| 32812 |
shampa |
930 |
throw new ProfitMandiBusinessException(message, message, message);
|
|
|
931 |
}
|
|
|
932 |
|
|
|
933 |
for (Map.Entry<Integer, List<String>> positionIdStoreMapEntry : positionIdsToAddMap.entrySet()) {
|
|
|
934 |
int positionId = positionIdStoreMapEntry.getKey();
|
|
|
935 |
Position position = positionsToUpdateMap.get(positionId);
|
| 32821 |
shampa |
936 |
LOGGER.info("positionId - {}, Position - {}", positionId, position);
|
| 32812 |
shampa |
937 |
List<String> storeCodesToAdd = positionIdStoreMapEntry.getValue();
|
|
|
938 |
List<Integer> retailerIdsToAdd = fofoStoreRepository.selectByStoreCodes(storeCodesToAdd).stream().map(x->x.getId()).collect(Collectors.toList());
|
|
|
939 |
Map<Integer, PartnerPosition> partnerPositionsMapByFofoId = partnerPositionRepository
|
| 32821 |
shampa |
940 |
.selectByRegionIdAndPostionId(Arrays.asList(position.getRegionId())
|
|
|
941 |
,Arrays.asList(positionId)).stream().collect(Collectors.toMap(x->x.getFofoId(),x->x));
|
| 32812 |
shampa |
942 |
for (Integer retailerIdToAdd : retailerIdsToAdd) {
|
|
|
943 |
if (!partnerPositionsMapByFofoId.containsKey(retailerIdToAdd)) {
|
|
|
944 |
PartnerPosition partnerPositionNew = new PartnerPosition();
|
|
|
945 |
partnerPositionNew.setPositionId(positionId);
|
|
|
946 |
partnerPositionNew.setFofoId(retailerIdToAdd);
|
|
|
947 |
partnerPositionNew.setRegionId(position.getRegionId());
|
| 32865 |
amit.gupta |
948 |
partnerPositionRepository.persist(partnerPositionNew);
|
| 32812 |
shampa |
949 |
}
|
|
|
950 |
}
|
|
|
951 |
}
|
|
|
952 |
|
|
|
953 |
for (Map.Entry<Integer, List<String>> positionIdStoreMapEntry : positionIdsToRemoveMap.entrySet()) {
|
|
|
954 |
|
|
|
955 |
int positionId = positionIdStoreMapEntry.getKey();
|
|
|
956 |
Position position = positionsToUpdateMap.get(positionId);
|
|
|
957 |
List<String> storeCodesToRemove = positionIdStoreMapEntry.getValue();
|
|
|
958 |
List<Integer> retailerIdsToRemove = fofoStoreRepository.selectByStoreCodes(storeCodesToRemove).stream().map(x->x.getId()).collect(Collectors.toList());
|
|
|
959 |
Map<Integer, PartnerPosition> partnerPositionsMapByFofoId = partnerPositionRepository
|
|
|
960 |
.selectByRegionIdAndPostionId(Arrays.asList(position.getRegionId()),Arrays.asList(positionId)).stream().collect(Collectors.toMap(x->x.getFofoId(),x->x));
|
|
|
961 |
for (Integer retailerIdToRemove : retailerIdsToRemove) {
|
|
|
962 |
if (partnerPositionsMapByFofoId.containsKey(retailerIdToRemove)) {
|
|
|
963 |
PartnerPosition partnerPositionToRemove = partnerPositionsMapByFofoId.get(retailerIdToRemove);
|
|
|
964 |
partnerPositionRepository.delete(partnerPositionToRemove);
|
|
|
965 |
}
|
|
|
966 |
}
|
|
|
967 |
}
|
|
|
968 |
|
|
|
969 |
|
|
|
970 |
|
|
|
971 |
/*partnerPositionUpdateModels.str
|
|
|
972 |
|
|
|
973 |
Map<Integer, Position> positionIdMap = positionsToUpdate.stream().collect(Collectors.toMap(x->x.getId(), x->x));
|
|
|
974 |
for (PartnerPositonUpdateModel partnerPositionUpdateModel : partnerPositionUpdateModels) {
|
|
|
975 |
FofoStore fofoStore = fofoStoreRepository.selectByStoreCode(partnerPositionUpdateModel.getStoreCode());
|
|
|
976 |
Position positionFrom = positionIdMap.get(partnerPositionUpdateModel.getPositionIdFrom());
|
|
|
977 |
Position positionTo = positionIdMap.get(partnerPositionUpdateModel.getPositionIdTo());
|
|
|
978 |
if(positionFrom != null) {
|
|
|
979 |
partnerPositionRepository.selectByRegionIdAndPostionId(Arrays.)
|
|
|
980 |
int regionId = positionFrom.getRegionId()
|
|
|
981 |
}
|
|
|
982 |
if(positionTo != null) {
|
|
|
983 |
|
|
|
984 |
}
|
|
|
985 |
}*/
|
|
|
986 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
987 |
return "response";
|
|
|
988 |
|
|
|
989 |
}
|
|
|
990 |
|
|
|
991 |
|
| 24417 |
govind |
992 |
}
|