Subversion Repositories SmartDukaan

Rev

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

Rev 25505 Rev 25570
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.Set;
-
 
10
import java.util.stream.Collectors;
9
 
11
 
-
 
12
import org.apache.commons.collections4.map.HashedMap;
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;
14
import org.springframework.mail.javamail.JavaMailSender;
17
import org.springframework.mail.javamail.JavaMailSender;
Line 26... Line 29...
26
import com.spice.profitmandi.dao.entity.cs.Ticket;
29
import com.spice.profitmandi.dao.entity.cs.Ticket;
27
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
30
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
28
import com.spice.profitmandi.dao.entity.cs.TicketCategory;
31
import com.spice.profitmandi.dao.entity.cs.TicketCategory;
29
import com.spice.profitmandi.dao.entity.cs.TicketSubCategory;
32
import com.spice.profitmandi.dao.entity.cs.TicketSubCategory;
30
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
33
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
-
 
34
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
31
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
35
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
32
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
36
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
-
 
37
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
-
 
38
import com.spice.profitmandi.service.slab.TargetSlabService;
33
import com.spice.profitmandi.service.user.RetailerService;
39
import com.spice.profitmandi.service.user.RetailerService;
34
 
40
 
35
@Component
41
@Component
36
public class CsServiceImpl implements CsService {
42
public class CsServiceImpl implements CsService {
37
 
43
 
Line 71... Line 77...
71
	private RegionRepository regionRepository;
77
	private RegionRepository regionRepository;
72
 
78
 
73
	@Autowired
79
	@Autowired
74
	private TicketAssignedRepository ticketAssignedRepository;
80
	private TicketAssignedRepository ticketAssignedRepository;
75
 
81
 
-
 
82
	@Autowired
-
 
83
	private PartnersPositionRepository partnersPositionRepository;
-
 
84
 
-
 
85
	@Autowired
-
 
86
	private TargetSlabService targetSlabService;
-
 
87
 
-
 
88
	@Autowired
-
 
89
	private FofoStoreRepository fofoStoreRepository;
-
 
90
 
76
	@Override
91
	@Override
77
	public void createTicket(int fofoId, int categoryId, int subcategoryId, String message)
92
	public void createTicket(int fofoId, int categoryId, int subcategoryId, String message)
78
			throws ProfitMandiBusinessException {
93
			throws ProfitMandiBusinessException {
79
 
94
 
80
		ActivityType type = ActivityType.OPENED;
95
		ActivityType type = ActivityType.OPENED;
Line 418... Line 433...
418
		} catch (Exception e) {
433
		} catch (Exception e) {
419
			throw new ProfitMandiBusinessException("Ticket Assingment", authUser.getEmailId(),
434
			throw new ProfitMandiBusinessException("Ticket Assingment", authUser.getEmailId(),
420
					"Could not send ticket assignment mail");
435
					"Could not send ticket assignment mail");
421
		}
436
		}
422
	}
437
	}
-
 
438
 
-
 
439
	@Override
-
 
440
	public Map<Integer, List<CustomRetailer>> getPositionCustomRetailerMap(List<Position> positions) {
-
 
441
		Map<Integer, List<CustomRetailer>> positionRetailerMap = new HashMap<>();
-
 
442
		for (Position position : positions) {
-
 
443
			List<Integer> fofoIds = partnersPositionRepository.selectByPositionId(position.getId()).stream()
-
 
444
					.map(x -> x.getFofoId()).collect(Collectors.toList());
-
 
445
 
-
 
446
			if (!fofoIds.isEmpty()) {
-
 
447
				if (fofoIds.contains(0)) {
-
 
448
					fofoIds = partnerRegionRepository.selectByRegionId(position.getRegionId()).stream()
-
 
449
							.map(x -> x.getFofoId()).collect(Collectors.toList());
-
 
450
					if (fofoIds.contains(0)) {
-
 
451
						fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
-
 
452
								.collect(Collectors.toList());
-
 
453
					}
-
 
454
 
-
 
455
				}
-
 
456
				positionRetailerMap.put(position.getId(),
-
 
457
						new ArrayList<CustomRetailer>(retailerService.getFofoRetailers(fofoIds).values()));
-
 
458
 
-
 
459
			}
-
 
460
		}
-
 
461
		return positionRetailerMap;
-
 
462
	}
-
 
463
 
-
 
464
	@Override
-
 
465
	public Map<Integer, List<CustomRetailer>> getpositionIdAndpartnerRegionMap(List<Position> positions) {
-
 
466
		Map<Integer, List<CustomRetailer>> positionIdAndpartnerRegionMap = new HashedMap<>();
-
 
467
		for (Position position : positions) {
-
 
468
			List<Integer> fofoIds = partnerRegionRepository.selectByRegionId(position.getRegionId()).stream()
-
 
469
					.map(x -> x.getFofoId()).collect(Collectors.toList());
-
 
470
 
-
 
471
			if (!fofoIds.isEmpty()) {
-
 
472
				if (fofoIds.contains(0)) {
-
 
473
					fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId()).collect(Collectors.toList());
-
 
474
 
-
 
475
				}
-
 
476
 
-
 
477
				Map<Integer, CustomRetailer> fofoRetailers = retailerService.getFofoRetailers(fofoIds);
-
 
478
				positionIdAndpartnerRegionMap.put(position.getRegionId(),
-
 
479
						new ArrayList<CustomRetailer>(fofoRetailers.values()));
-
 
480
			}
-
 
481
 
-
 
482
		}
-
 
483
 
-
 
484
		return positionIdAndpartnerRegionMap;
-
 
485
	}
423
}
486
}