Subversion Repositories SmartDukaan

Rev

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

Rev 24570 Rev 24699
Line 4... Line 4...
4
import java.util.ArrayList;
4
import java.util.ArrayList;
5
import java.util.HashMap;
5
import java.util.HashMap;
6
import java.util.HashSet;
6
import java.util.HashSet;
7
import java.util.List;
7
import java.util.List;
8
import java.util.Map;
8
import java.util.Map;
-
 
9
import java.util.Optional;
-
 
10
 
-
 
11
import javax.swing.SortOrder;
9
 
12
 
10
import org.apache.commons.lang.RandomStringUtils;
13
import org.apache.commons.lang.RandomStringUtils;
11
import org.apache.logging.log4j.LogManager;
14
import org.apache.logging.log4j.LogManager;
12
import org.apache.logging.log4j.Logger;
15
import org.apache.logging.log4j.Logger;
13
import org.springframework.beans.factory.annotation.Autowired;
16
import org.springframework.beans.factory.annotation.Autowired;
Line 23... Line 26...
23
import com.spice.profitmandi.dao.entity.cs.Position;
26
import com.spice.profitmandi.dao.entity.cs.Position;
24
import com.spice.profitmandi.dao.entity.cs.Region;
27
import com.spice.profitmandi.dao.entity.cs.Region;
25
import com.spice.profitmandi.dao.entity.cs.Ticket;
28
import com.spice.profitmandi.dao.entity.cs.Ticket;
26
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
29
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
27
import com.spice.profitmandi.dao.entity.cs.TicketCategory;
30
import com.spice.profitmandi.dao.entity.cs.TicketCategory;
-
 
31
import com.spice.profitmandi.dao.entity.cs.TicketSearchType;
28
import com.spice.profitmandi.dao.entity.cs.TicketSubCategory;
32
import com.spice.profitmandi.dao.entity.cs.TicketSubCategory;
29
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
33
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
30
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
34
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
31
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
35
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
32
import com.spice.profitmandi.service.user.RetailerService;
36
import com.spice.profitmandi.service.user.RetailerService;
Line 89... Line 93...
89
		ticket.setL2EscalationTimestamp(ticket.getUpdateTimestamp().plusDays(2));
93
		ticket.setL2EscalationTimestamp(ticket.getUpdateTimestamp().plusDays(2));
90
		ticket.setL3EscalationTimestamp(ticket.getL2EscalationTimestamp().plusDays(2));
94
		ticket.setL3EscalationTimestamp(ticket.getL2EscalationTimestamp().plusDays(2));
91
		ticket.setLastEscalationTimestamp(ticket.getL3EscalationTimestamp().plusDays(2));
95
		ticket.setLastEscalationTimestamp(ticket.getL3EscalationTimestamp().plusDays(2));
92
		ticket.setHappyCode(getRandomString());
96
		ticket.setHappyCode(getRandomString());
93
		int l1Auth = this.getAuthUserId(categoryId, escalationTypeL1, fofoId);
97
		int l1Auth = this.getAuthUserId(categoryId, escalationTypeL1, fofoId);
94
		LOGGER.info("l1Auth"+l1Auth);
98
		LOGGER.info("l1Auth" + l1Auth);
95
		int l2Auth = this.getAuthUserId(categoryId, escalationTypeL2, fofoId);
99
		int l2Auth = this.getAuthUserId(categoryId, escalationTypeL2, fofoId);
96
		LOGGER.info("l2Auth"+l2Auth);
100
		LOGGER.info("l2Auth" + l2Auth);
97
		int l3Auth = this.getAuthUserId(categoryId, escalationTypeL3, fofoId);
101
		int l3Auth = this.getAuthUserId(categoryId, escalationTypeL3, fofoId);
98
		LOGGER.info("l3Auth"+l3Auth);
102
		LOGGER.info("l3Auth" + l3Auth);
99
		if (l1Auth == 0) {
103
		if (l1Auth == 0) {
100
			if (l2Auth == 0) {
104
			if (l2Auth == 0) {
101
				this.setAssignment(ticket, ticketAssigned);
105
				this.setAssignment(ticket, ticketAssigned);
102
			} else {
106
			} else {
103
				ticketAssigned.setAssineeId(l2Auth);
107
				ticketAssigned.setAssineeId(l2Auth);
Line 107... Line 111...
107
		} else {
111
		} else {
108
			ticketAssigned.setAssineeId(l1Auth);
112
			ticketAssigned.setAssineeId(l1Auth);
109
			ticket.setL1AuthUser(l1Auth);
113
			ticket.setL1AuthUser(l1Auth);
110
			ticket.setL2AuthUser(l2Auth);
114
			ticket.setL2AuthUser(l2Auth);
111
		}
115
		}
112
		if(ticket.getL2AuthUser()==0)
116
		if (ticket.getL2AuthUser() == 0) {
113
		{
-
 
114
			ticket.setL2AuthUser(l3Auth);
117
			ticket.setL2AuthUser(l3Auth);
115
		}
118
		}
116
		ticket.setL3AuthUser(l3Auth);
119
		ticket.setL3AuthUser(l3Auth);
117
		ticketRepository.persist(ticket);
120
		ticketRepository.persist(ticket);
118
		ticketAssigned.setTicketId(ticket.getId());
121
		ticketAssigned.setTicketId(ticket.getId());
Line 143... Line 146...
143
			if (regions.size() == 0) {
146
			if (regions.size() == 0) {
144
				regions = partnerRegionRepository.selectByfofoId(0);
147
				regions = partnerRegionRepository.selectByfofoId(0);
145
				LOGGER.info("regions=" + regions);
148
				LOGGER.info("regions=" + regions);
146
			}
149
			}
147
			for (PartnerRegion region : regions) {
150
			for (PartnerRegion region : regions) {
148
				LOGGER.info(categoryId+":"+escalationType+":"+region.getRegionId());
151
				LOGGER.info(categoryId + ":" + escalationType + ":" + region.getRegionId());
149
				positions = positionRepository.selectPositionbyCategoryIdAndEscalationType(categoryId, escalationType,
152
				positions = positionRepository.selectPositionbyCategoryIdAndEscalationType(categoryId, escalationType,
150
						region.getRegionId());
153
						region.getRegionId());
151
				LOGGER.info("positions:-" + positions);
154
				LOGGER.info("positions:-" + positions);
152
				if (positions.size() > 0) {
155
				if (positions.size() > 0) {
153
					break;
156
					break;
Line 177... Line 180...
177
							break;
180
							break;
178
						}
181
						}
179
					}
182
					}
180
				}
183
				}
181
			}
184
			}
182
			
185
 
183
		}
186
		}
184
		if(positions.size()==0)
187
		if (positions.size() == 0) {
185
		{
-
 
186
			return 0;
188
			return 0;
187
		}
189
		}
188
		LOGGER.info(positions.get(0).getAuthUserId());
190
		LOGGER.info(positions.get(0).getAuthUserId());
189
		return positions.get(0).getAuthUserId();
191
		return positions.get(0).getAuthUserId();
190
		/*
192
		/*
Line 244... Line 246...
244
	}
246
	}
245
 
247
 
246
	@Override
248
	@Override
247
	public Map<Integer, TicketSubCategory> getSubCategoryIdAndSubCategoryMap(List<Ticket> tickets) {
249
	public Map<Integer, TicketSubCategory> getSubCategoryIdAndSubCategoryMap(List<Ticket> tickets) {
248
		Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = new HashMap<>();
250
		Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = new HashMap<>();
249
		if(tickets !=null) {
251
		if (tickets != null) {
250
		for (Ticket ticket : tickets) {
252
			for (Ticket ticket : tickets) {
251
			TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.selectById(ticket.getSubCategoryId());
253
				TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.selectById(ticket.getSubCategoryId());
252
			subCategoryIdAndSubCategoryMap.put(ticket.getSubCategoryId(), ticketSubCategory);
254
				subCategoryIdAndSubCategoryMap.put(ticket.getSubCategoryId(), ticketSubCategory);
-
 
255
			}
253
		}
256
		}
254
	}
-
 
255
		return subCategoryIdAndSubCategoryMap;
257
		return subCategoryIdAndSubCategoryMap;
256
	}
258
	}
257
 
259
 
258
	@Override
260
	@Override
259
	public Map<Integer, CustomRetailer> getPartnerByFofoIds(List<Ticket> tickets) {
261
	public Map<Integer, CustomRetailer> getPartnerByFofoIds(List<Ticket> tickets) {
260
		List<Integer> fofoIds = new ArrayList<>();
262
		List<Integer> fofoIds = new ArrayList<>();
261
		LOGGER.info(tickets);
263
		LOGGER.info(tickets);
262
		if(tickets==null)
264
		if (tickets == null) {
263
		{
-
 
264
			return null;
265
			return null;
265
		}
266
		}
266
		for (Ticket ticket : tickets) {
267
		for (Ticket ticket : tickets) {
267
			fofoIds.add(ticket.getFofoId());
268
			fofoIds.add(ticket.getFofoId());
268
		}
269
		}
269
		Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer= retailerService.getFofoRetailers(fofoIds);
270
		Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = retailerService.getFofoRetailers(fofoIds);
270
		return fofoIdsAndCustomRetailer;
271
		return fofoIdsAndCustomRetailer;
271
	}
272
	}
272
 
273
 
273
	@Override
274
	@Override
274
	public List<TicketCategory> getAllTicketCategotyFromSubCategory() {
275
	public List<TicketCategory> getAllTicketCategotyFromSubCategory() {
Line 325... Line 326...
325
		}
326
		}
326
		return regionIdAndRegionMap;
327
		return regionIdAndRegionMap;
327
	}
328
	}
328
 
329
 
329
	@Override
330
	@Override
330
	public Map<Integer, List<AuthUser>> getAuthUserList(List<Ticket> tickets,AuthUser authUser) {
331
	public Map<Integer, List<AuthUser>> getAuthUserList(List<Ticket> tickets, AuthUser authUser) {
331
		Map<Integer, List<AuthUser>> authUserListMap = new HashMap<>();
332
		Map<Integer, List<AuthUser>> authUserListMap = new HashMap<>();
332
		for (Ticket ticket : tickets) {
333
		for (Ticket ticket : tickets) {
333
			if (ticket.getL2AuthUser() == authUser.getId()) {
334
			if (ticket.getL2AuthUser() == authUser.getId()) {
334
				List<AuthUser> authUsers = new ArrayList<>();
335
				List<AuthUser> authUsers = new ArrayList<>();
335
				authUsers.add(authRepository.selectById(ticket.getL1AuthUser()));
336
				authUsers.add(authRepository.selectById(ticket.getL1AuthUser()));
Line 409... Line 410...
409
		AuthUser authUser = authRepository.selectById(ticketAssigned.getAssineeId());
410
		AuthUser authUser = authRepository.selectById(ticketAssigned.getAssineeId());
410
		this.sendAssignedTicketMail(authUser, ticket);
411
		this.sendAssignedTicketMail(authUser, ticket);
411
	}
412
	}
412
 
413
 
413
	@Override
414
	@Override
414
	public void sendAssignedTicketMail(AuthUser authUser,Ticket ticket) throws ProfitMandiBusinessException
415
	public void sendAssignedTicketMail(AuthUser authUser, Ticket ticket) throws ProfitMandiBusinessException {
415
	{
-
 
416
		try {
416
		try {
417
			Utils.sendMailWithAttachments(mailSender, authUser.getEmailId(), null, ASSINMENT_SUBJECT,
417
			Utils.sendMailWithAttachments(mailSender, authUser.getEmailId(), null, ASSINMENT_SUBJECT,
418
					String.format(ASSIGNED_TICKET, authUser.getFirstName(),
418
					String.format(ASSIGNED_TICKET, authUser.getFirstName(),
419
							retailerService.getFofoRetailer(ticket.getFofoId()).getBusinessName(),ticket.getId()),
419
							retailerService.getFofoRetailer(ticket.getFofoId()).getBusinessName(), ticket.getId()),
420
					null);
420
					null);
421
		} catch (Exception e) {
421
		} catch (Exception e) {
422
			throw new ProfitMandiBusinessException("Ticket Assingment", authUser.getEmailId(),
422
			throw new ProfitMandiBusinessException("Ticket Assingment", authUser.getEmailId(),
423
					"Could not send ticket assignment mail");
423
					"Could not send ticket assignment mail");
424
		}
424
		}