Subversion Repositories SmartDukaan

Rev

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

Rev 24557 Rev 24569
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.stream.Collectors;
-
 
10
 
9
 
11
import org.apache.commons.lang.RandomStringUtils;
10
import org.apache.commons.lang.RandomStringUtils;
12
import org.apache.logging.log4j.LogManager;
11
import org.apache.logging.log4j.LogManager;
13
import org.apache.logging.log4j.Logger;
12
import org.apache.logging.log4j.Logger;
14
import org.springframework.beans.factory.annotation.Autowired;
13
import org.springframework.beans.factory.annotation.Autowired;
Line 35... Line 34...
35
@Component
34
@Component
36
public class CsServiceImpl implements CsService {
35
public class CsServiceImpl implements CsService {
37
 
36
 
38
	private static final Logger LOGGER = LogManager.getLogger(CsServiceImpl.class);
37
	private static final Logger LOGGER = LogManager.getLogger(CsServiceImpl.class);
39
 
38
 
40
	private static final String ASSIGNED_TICKET = "Dear %s,You have assigned a ticket by %s. Regards\nSmartdukaan";
39
	private static final String ASSIGNED_TICKET = "Dear %s,You have assigned a ticket by %s with ticketId=%s.Regards\nSmartdukaan";
41
	private static final String ASSINMENT_SUBJECT = "Assignment Ticket";
40
	private static final String ASSINMENT_SUBJECT = "Assignment Ticket";
42
 
41
 
43
	@Autowired
42
	@Autowired
44
	TicketRepository ticketRepository;
43
	TicketRepository ticketRepository;
45
 
44
 
Line 108... Line 107...
108
		} else {
107
		} else {
109
			ticketAssigned.setAssineeId(l1Auth);
108
			ticketAssigned.setAssineeId(l1Auth);
110
			ticket.setL1AuthUser(l1Auth);
109
			ticket.setL1AuthUser(l1Auth);
111
			ticket.setL2AuthUser(l2Auth);
110
			ticket.setL2AuthUser(l2Auth);
112
		}
111
		}
-
 
112
		if(ticket.getL2AuthUser()==0)
-
 
113
		{
-
 
114
			ticket.setL2AuthUser(l3Auth);
-
 
115
		}
113
		ticket.setL3AuthUser(l3Auth);
116
		ticket.setL3AuthUser(l3Auth);
114
		ticketRepository.persist(ticket);
117
		ticketRepository.persist(ticket);
115
		ticketAssigned.setTicketId(ticket.getId());
118
		ticketAssigned.setTicketId(ticket.getId());
116
		ticketAssignedRepository.persist(ticketAssigned);
119
		ticketAssignedRepository.persist(ticketAssigned);
117
		AuthUser authUser = authRepository.selectById(ticketAssigned.getAssineeId());
120
		AuthUser authUser = authRepository.selectById(ticketAssigned.getAssineeId());
118
		try {
-
 
119
			Utils.sendMailWithAttachments(mailSender, authUser.getEmailId(), null, ASSINMENT_SUBJECT,
-
 
120
					String.format(ASSIGNED_TICKET, authUser.getFirstName(),
-
 
121
							retailerService.getFofoRetailer(fofoId).getBusinessName()),
-
 
122
					null);
-
 
123
		} catch (Exception e) {
-
 
124
			throw new ProfitMandiBusinessException("Ticket Assingment", authUser.getEmailId(),
-
 
125
					"Could not send ticket assignment mail");
121
		this.sendAssignedTicketMail(authUser, ticket);
126
		}
-
 
127
		Activity activity = this.createActivity(type, message, 0);
122
		Activity activity = this.createActivity(type, message, 0);
128
		this.addActivity(ticket.getId(), activity);
123
		this.addActivity(ticket.getId(), activity);
129
	}
124
	}
130
 
125
 
131
	private Activity createActivity(ActivityType activityType, String message, int createdBy) {
126
	private Activity createActivity(ActivityType activityType, String message, int createdBy) {
Line 249... Line 244...
249
	}
244
	}
250
 
245
 
251
	@Override
246
	@Override
252
	public Map<Integer, TicketSubCategory> getSubCategoryIdAndSubCategoryMap(List<Ticket> tickets) {
247
	public Map<Integer, TicketSubCategory> getSubCategoryIdAndSubCategoryMap(List<Ticket> tickets) {
253
		Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = new HashMap<>();
248
		Map<Integer, TicketSubCategory> subCategoryIdAndSubCategoryMap = new HashMap<>();
-
 
249
		if(tickets !=null) {
254
		for (Ticket ticket : tickets) {
250
		for (Ticket ticket : tickets) {
255
			TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.selectById(ticket.getSubCategoryId());
251
			TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.selectById(ticket.getSubCategoryId());
256
			subCategoryIdAndSubCategoryMap.put(ticket.getSubCategoryId(), ticketSubCategory);
252
			subCategoryIdAndSubCategoryMap.put(ticket.getSubCategoryId(), ticketSubCategory);
257
		}
253
		}
-
 
254
	}
258
		return subCategoryIdAndSubCategoryMap;
255
		return subCategoryIdAndSubCategoryMap;
259
	}
256
	}
260
 
257
 
261
	@Override
258
	@Override
262
	public Map<Integer, CustomRetailer> getPartnerByFofoIds(List<Ticket> tickets) {
259
	public Map<Integer, CustomRetailer> getPartnerByFofoIds(List<Ticket> tickets) {
263
		List<Integer> fofoIds = new ArrayList<>();
260
		List<Integer> fofoIds = new ArrayList<>();
-
 
261
		LOGGER.info(tickets);
-
 
262
		if(tickets==null)
-
 
263
		{
-
 
264
			return null;
-
 
265
		}
264
		for (Ticket ticket : tickets) {
266
		for (Ticket ticket : tickets) {
265
			fofoIds.add(ticket.getFofoId());
267
			fofoIds.add(ticket.getFofoId());
266
		}
268
		}
267
		Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = retailerService.getFofoRetailers(fofoIds);
269
		Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer= retailerService.getFofoRetailers(fofoIds);
268
		return fofoIdsAndCustomRetailer;
270
		return fofoIdsAndCustomRetailer;
269
	}
271
	}
270
 
272
 
271
	@Override
273
	@Override
272
	public List<TicketCategory> getAllTicketCategotyFromSubCategory() {
274
	public List<TicketCategory> getAllTicketCategotyFromSubCategory() {
Line 390... Line 392...
390
		if (l1Auth == 0) {
392
		if (l1Auth == 0) {
391
			if (l2Auth == 0) {
393
			if (l2Auth == 0) {
392
				this.setAssignment(ticket, ticketAssigned);
394
				this.setAssignment(ticket, ticketAssigned);
393
			} else {
395
			} else {
394
				ticketAssigned.setAssineeId(l2Auth);
396
				ticketAssigned.setAssineeId(l2Auth);
395
				ticket.setL1AuthUser(l2Auth);
397
				ticket.setL1AuthUser(0);
396
				ticket.setL2AuthUser(l2Auth);
398
				ticket.setL2AuthUser(l2Auth);
397
			}
399
			}
398
		} else {
400
		} else {
399
			ticketAssigned.setAssineeId(l1Auth);
401
			ticketAssigned.setAssineeId(l1Auth);
400
			ticket.setL1AuthUser(l1Auth);
402
			ticket.setL1AuthUser(l1Auth);
Line 403... Line 405...
403
		ticket.setL3AuthUser(l3Auth);
405
		ticket.setL3AuthUser(l3Auth);
404
		ticketRepository.persist(ticket);
406
		ticketRepository.persist(ticket);
405
		ticketAssigned.setTicketId(ticket.getId());
407
		ticketAssigned.setTicketId(ticket.getId());
406
		ticketAssignedRepository.persist(ticketAssigned);
408
		ticketAssignedRepository.persist(ticketAssigned);
407
		AuthUser authUser = authRepository.selectById(ticketAssigned.getAssineeId());
409
		AuthUser authUser = authRepository.selectById(ticketAssigned.getAssineeId());
-
 
410
		this.sendAssignedTicketMail(authUser, ticket);
-
 
411
	}
-
 
412
 
-
 
413
	@Override
-
 
414
	public void sendAssignedTicketMail(AuthUser authUser,Ticket ticket) throws ProfitMandiBusinessException
-
 
415
	{
408
		try {
416
		try {
409
			Utils.sendMailWithAttachments(mailSender, authUser.getEmailId(), null, ASSINMENT_SUBJECT,
417
			Utils.sendMailWithAttachments(mailSender, authUser.getEmailId(), null, ASSINMENT_SUBJECT,
410
					String.format(ASSIGNED_TICKET, authUser.getFirstName(),
418
					String.format(ASSIGNED_TICKET, authUser.getFirstName(),
411
							retailerService.getFofoRetailer(ticket.getFofoId()).getBusinessName()),
419
							retailerService.getFofoRetailer(ticket.getFofoId()).getBusinessName(),ticket.getId()),
412
					null);
420
					null);
413
		} catch (Exception e) {
421
		} catch (Exception e) {
414
			throw new ProfitMandiBusinessException("Ticket Assingment", authUser.getEmailId(),
422
			throw new ProfitMandiBusinessException("Ticket Assingment", authUser.getEmailId(),
415
					"Could not send ticket assignment mail");
423
					"Could not send ticket assignment mail");
416
		}
424
		}
417
	}
425
	}
418
 
-
 
419
}
426
}