Subversion Repositories SmartDukaan

Rev

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

Rev 28641 Rev 28825
Line 41... Line 41...
41
import org.springframework.web.bind.annotation.RequestMapping;
41
import org.springframework.web.bind.annotation.RequestMapping;
42
import org.springframework.web.bind.annotation.RequestMethod;
42
import org.springframework.web.bind.annotation.RequestMethod;
43
import org.springframework.web.bind.annotation.RequestParam;
43
import org.springframework.web.bind.annotation.RequestParam;
44
 
44
 
45
import com.google.gson.Gson;
45
import com.google.gson.Gson;
-
 
46
import com.mongodb.DBObject;
46
import com.spice.profitmandi.common.enumuration.ContentType;
47
import com.spice.profitmandi.common.enumuration.ContentType;
47
import com.spice.profitmandi.common.enumuration.MessageType;
48
import com.spice.profitmandi.common.enumuration.MessageType;
48
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
49
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
49
import com.spice.profitmandi.common.model.ActivateItemModel;
50
import com.spice.profitmandi.common.model.ActivateItemModel;
50
import com.spice.profitmandi.common.model.ChartInvestmentModel;
51
import com.spice.profitmandi.common.model.ChartInvestmentModel;
Line 65... Line 66...
65
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
66
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
66
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
67
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
67
import com.spice.profitmandi.dao.entity.inventory.ReporticoCacheTable;
68
import com.spice.profitmandi.dao.entity.inventory.ReporticoCacheTable;
68
import com.spice.profitmandi.dao.entity.transaction.Order;
69
import com.spice.profitmandi.dao.entity.transaction.Order;
69
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
70
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
-
 
71
import com.spice.profitmandi.dao.model.ActivationImeiUpdationModel;
-
 
72
import com.spice.profitmandi.dao.model.BrandWiseActivatedModel;
70
import com.spice.profitmandi.dao.model.BrandWisePartnerSaleModel;
73
import com.spice.profitmandi.dao.model.BrandWisePartnerSaleModel;
71
import com.spice.profitmandi.dao.model.BrandWiseUnbilledActivateStockModel;
74
import com.spice.profitmandi.dao.model.BrandWiseUnbilledActivateStockModel;
72
import com.spice.profitmandi.dao.model.CreateOfferRequest;
75
import com.spice.profitmandi.dao.model.CreateOfferRequest;
73
import com.spice.profitmandi.dao.model.InStockBrandItemModel;
76
import com.spice.profitmandi.dao.model.InStockBrandItemModel;
74
import com.spice.profitmandi.dao.model.InStockBrandModel;
77
import com.spice.profitmandi.dao.model.InStockBrandModel;
Line 78... Line 81...
78
import com.spice.profitmandi.dao.model.PartnerPendingIndentItemModel;
81
import com.spice.profitmandi.dao.model.PartnerPendingIndentItemModel;
79
import com.spice.profitmandi.dao.model.PriceDropBrandModel;
82
import com.spice.profitmandi.dao.model.PriceDropBrandModel;
80
import com.spice.profitmandi.dao.model.PriceDropWithDetailsByYearMonthModel;
83
import com.spice.profitmandi.dao.model.PriceDropWithDetailsByYearMonthModel;
81
import com.spice.profitmandi.dao.model.PriceDropYearMonthModel;
84
import com.spice.profitmandi.dao.model.PriceDropYearMonthModel;
82
import com.spice.profitmandi.dao.model.WarehouseBrandItemUnbilledActivatedModel;
85
import com.spice.profitmandi.dao.model.WarehouseBrandItemUnbilledActivatedModel;
-
 
86
import com.spice.profitmandi.dao.model.WarehouseBrandWiseItemActivatedModel;
83
import com.spice.profitmandi.dao.model.WarehouseBrandWiseItemSaleModel;
87
import com.spice.profitmandi.dao.model.WarehouseBrandWiseItemSaleModel;
-
 
88
import com.spice.profitmandi.dao.model.WarehouseWiseActivatedModel;
84
import com.spice.profitmandi.dao.model.WarehouseWiseBrandSaleModel;
89
import com.spice.profitmandi.dao.model.WarehouseWiseBrandSaleModel;
85
import com.spice.profitmandi.dao.model.WarehouseWiseBrandStockModel;
90
import com.spice.profitmandi.dao.model.WarehouseWiseBrandStockModel;
86
import com.spice.profitmandi.dao.model.WarehouseWiseBrandUnbilledActivatedModel;
91
import com.spice.profitmandi.dao.model.WarehouseWiseBrandUnbilledActivatedModel;
87
import com.spice.profitmandi.dao.model.WarehouseWiseitemStockModel;
92
import com.spice.profitmandi.dao.model.WarehouseWiseitemStockModel;
88
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
93
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
Line 92... Line 97...
92
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
97
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
93
import com.spice.profitmandi.dao.repository.cs.TicketAssignedRepository;
98
import com.spice.profitmandi.dao.repository.cs.TicketAssignedRepository;
94
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
99
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
95
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
100
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
96
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
101
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
-
 
102
import com.spice.profitmandi.dao.repository.dtr.Mongo;
97
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
103
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
98
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
104
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
-
 
105
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
99
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
106
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
100
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
107
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
101
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
108
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
102
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
109
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
103
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
110
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
Line 245... Line 252...
245
 
252
 
246
	@Autowired
253
	@Autowired
247
	private FofoUser fofoUser;
254
	private FofoUser fofoUser;
248
 
255
 
249
	@Autowired
256
	@Autowired
-
 
257
	private ActivatedImeiRepository activatedImeiRepository;
-
 
258
 
-
 
259
	@Autowired
-
 
260
	private Mongo mongoClient;
-
 
261
 
-
 
262
	@Autowired
250
	private PositionRepository positionRepository;
263
	private PositionRepository positionRepository;
251
	private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
264
	private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
252
 
265
 
253
	@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
266
	@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
254
	public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
267
	public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
Line 562... Line 575...
562
 
575
 
563
		model.addAttribute("priceDropdetailsList", priceDropdetailsList);
576
		model.addAttribute("priceDropdetailsList", priceDropdetailsList);
564
 
577
 
565
		return "price-drop-details";
578
		return "price-drop-details";
566
	}
579
	}
567
	
-
 
568
	
580
 
569
	@RequestMapping(value = "/getPriceDropDetailSixMonths", method = RequestMethod.GET)
581
	@RequestMapping(value = "/getPriceDropDetailSixMonths", method = RequestMethod.GET)
570
	public String getPriceDropDetailSixMonths(HttpServletRequest request,
582
	public String getPriceDropDetailSixMonths(HttpServletRequest request,
571
			@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
583
			@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
572
			@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model)
584
			@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model)
573
			throws Exception {
585
			throws Exception {
Line 576... Line 588...
576
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
588
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
577
		LocalDateTime startfMonthSixMonth = curDate.withDayOfMonth(1).minusMonths(12);
589
		LocalDateTime startfMonthSixMonth = curDate.withDayOfMonth(1).minusMonths(12);
578
		LocalDateTime endMonthTotal = curDate.withDayOfMonth(1).minusMonths(6);
590
		LocalDateTime endMonthTotal = curDate.withDayOfMonth(1).minusMonths(6);
579
 
591
 
580
		List<PriceDropWithDetailsByYearMonthModel> priceDropdetailsList = priceDropRepository
592
		List<PriceDropWithDetailsByYearMonthModel> priceDropdetailsList = priceDropRepository
581
				.selectBrandPendingPriceDropWithDetailsAndSixMonth(fofoId, brand, startfMonthSixMonth,endMonthTotal);
593
				.selectBrandPendingPriceDropWithDetailsAndSixMonth(fofoId, brand, startfMonthSixMonth, endMonthTotal);
582
 
594
 
583
		LOGGER.info("priceDropdetailsList" + priceDropdetailsList);
595
		LOGGER.info("priceDropdetailsList" + priceDropdetailsList);
584
 
596
 
585
		model.addAttribute("priceDropdetailsList", priceDropdetailsList);
597
		model.addAttribute("priceDropdetailsList", priceDropdetailsList);
586
 
598
 
587
		return "price-drop-details";
599
		return "price-drop-details";
588
	}
600
	}
589
 
601
 
590
	
-
 
591
	@RequestMapping(value = "/getMonthlyPriceDrop", method = RequestMethod.GET)
602
	@RequestMapping(value = "/getMonthlyPriceDrop", method = RequestMethod.GET)
592
	public String getMonthlyPriceDropTabular(HttpServletRequest request, Model model) throws Exception {
603
	public String getMonthlyPriceDropTabular(HttpServletRequest request, Model model) throws Exception {
593
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
604
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
594
		int fofoId = loginDetails.getFofoId();
605
		int fofoId = loginDetails.getFofoId();
595
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
606
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
Line 616... Line 627...
616
		DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
627
		DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
617
 
628
 
618
		Map<String, Map<YearMonth, Double>> brandMonthValue = new HashMap<>();
629
		Map<String, Map<YearMonth, Double>> brandMonthValue = new HashMap<>();
619
 
630
 
620
		LOGGER.info("priceDropBrandSixMonthTotals" + priceDropBrandSixMonthTotals);
631
		LOGGER.info("priceDropBrandSixMonthTotals" + priceDropBrandSixMonthTotals);
621
		
-
 
622
	
632
 
623
		Map<String, Double> priceDropBrandSixMonthMap=priceDropBrandSixMonthTotals.stream().collect(Collectors.toMap(x->x.getBrand(), x->(double)x.getAmount()));
633
		Map<String, Double> priceDropBrandSixMonthMap = priceDropBrandSixMonthTotals.stream()
-
 
634
				.collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getAmount()));
624
		
635
 
625
		model.addAttribute("priceDropBrandSixMonthMap", priceDropBrandSixMonthMap);
636
		model.addAttribute("priceDropBrandSixMonthMap", priceDropBrandSixMonthMap);
626
		
637
 
627
		LOGGER.info("priceDropYearMonthModels" + priceDropYearMonthModels);
638
		LOGGER.info("priceDropYearMonthModels" + priceDropYearMonthModels);
628
 
639
 
629
		for (PriceDropYearMonthModel pdm : priceDropYearMonthModels) {
640
		for (PriceDropYearMonthModel pdm : priceDropYearMonthModels) {
630
			Map<YearMonth, Double> brandValue = new HashMap<>();
641
			Map<YearMonth, Double> brandValue = new HashMap<>();
631
 
642
 
Line 649... Line 660...
649
		brands.add("Tecno");
660
		brands.add("Tecno");
650
		brands.add("Itel");
661
		brands.add("Itel");
651
		brands.add("Nokia");
662
		brands.add("Nokia");
652
		Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
663
		Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
653
 
664
 
654
       model.addAttribute("brands", brands);
665
		model.addAttribute("brands", brands);
655
		
666
 
656
		for (String brand : brands) {
667
		for (String brand : brands) {
657
			Map<YearMonth, Double> yearMonthValue = brandMonthValue.get(brand);
668
			Map<YearMonth, Double> yearMonthValue = brandMonthValue.get(brand);
658
			for (int i = 6; i >= 1; i--) {
669
			for (int i = 6; i >= 1; i--) {
659
 
670
 
660
				LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
671
				LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
Line 1501... Line 1512...
1501
		LOGGER.info("chartMap" + gson.toJson(cm));
1512
		LOGGER.info("chartMap" + gson.toJson(cm));
1502
		model.addAttribute("chartMap", gson.toJson(cm));
1513
		model.addAttribute("chartMap", gson.toJson(cm));
1503
		return "brand-wise-mobile-lmp-chart";
1514
		return "brand-wise-mobile-lmp-chart";
1504
	}
1515
	}
1505
 
1516
 
-
 
1517
	@RequestMapping(value = "/getActivatedModelWarehouseWise", method = RequestMethod.GET)
-
 
1518
	public String getActivatedModelWarehouseWise(HttpServletRequest request, Model model, @RequestParam String brand)
-
 
1519
			throws Exception {
-
 
1520
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
1521
		List<Integer> fofoIds = getFofoIds(loginDetails);
-
 
1522
		List<WarehouseWiseActivatedModel> warehouseWiseActivatedModels = activatedImeiRepository
-
 
1523
				.selectActivatedModelGroupByWarehouse(brand, fofoIds);
-
 
1524
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
-
 
1525
 
-
 
1526
		List<DBObject> mobileBrands = mongoClient.getAllBrandsToDisplay(3);
-
 
1527
 
-
 
1528
		List<String> brands = mobileBrands.stream().map(x -> (String) x.get("name")).collect(Collectors.toList());
-
 
1529
		LOGGER.info("brands" + brands.add("Redmi"));
-
 
1530
 
-
 
1531
		model.addAttribute("warehouseWiseActivatedModels", warehouseWiseActivatedModels);
-
 
1532
		model.addAttribute("warehouseMap", warehouseMap);
-
 
1533
		model.addAttribute("brands", brands);
-
 
1534
		model.addAttribute("selectedbrand", brand);
-
 
1535
		return "warehousewise_activated_model";
-
 
1536
	}
-
 
1537
 
-
 
1538
	@RequestMapping(value = "/getActivatedModelByBrand", method = RequestMethod.GET)
-
 
1539
	public String getActivatedModelByBrand(HttpServletRequest request, Model model) throws Exception {
-
 
1540
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
1541
		List<Integer> fofoIds = getFofoIds(loginDetails);
-
 
1542
		List<BrandWiseActivatedModel> activatedModels = activatedImeiRepository
-
 
1543
				.selectActivatedModelGroupByBrand(new ArrayList<>(fofoIds));
-
 
1544
		model.addAttribute("activatedModels", activatedModels);
-
 
1545
		return "activation-brandwise-report";
-
 
1546
	}
-
 
1547
 
-
 
1548
	@RequestMapping(value = "/getWarehouseBrandWiseItemActivatedModel", method = RequestMethod.GET)
-
 
1549
	public String getWarehouseBrandWiseItemActivatedModel(HttpServletRequest request, Model model,
-
 
1550
			@RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
-
 
1551
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
1552
		List<Integer> fofoIds = getFofoIds(loginDetails);
-
 
1553
 
-
 
1554
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
-
 
1555
		List<WarehouseBrandWiseItemActivatedModel> activatedItems = activatedImeiRepository
-
 
1556
				.selectWarehouseBrandActivatedItem(warehouseId, brand, fofoIds);
-
 
1557
		model.addAttribute("warehouseMap", warehouseMap);
-
 
1558
		model.addAttribute("activatedItems", activatedItems);
-
 
1559
		return "warehouse-activated-itemwise-model";
-
 
1560
 
-
 
1561
	}
-
 
1562
 
-
 
1563
	@RequestMapping(value = "/getActivatedImeiUpdationDate", method = RequestMethod.GET)
-
 
1564
	public String getActivatedImeiUpdationDate(HttpServletRequest request, Model model) throws Exception {
-
 
1565
 
-
 
1566
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
-
 
1567
 
-
 
1568
		List<ActivationImeiUpdationModel> activationImeiUpdations = activatedImeiRepository
-
 
1569
				.selectActivatedUpdationDate();
-
 
1570
		model.addAttribute("warehouseMap", warehouseMap);
-
 
1571
		model.addAttribute("activationImeiUpdations", activationImeiUpdations);
-
 
1572
		return "activation-updation-timestamp";
-
 
1573
 
-
 
1574
	}
-
 
1575
 
-
 
1576
	private List<Integer> getFofoIds(LoginDetails loginDetails) throws ProfitMandiBusinessException {
-
 
1577
		String email = loginDetails.getEmailId();
-
 
1578
 
-
 
1579
		AuthUser authUser = authRepository.selectByEmailOrMobile(email);
-
 
1580
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
-
 
1581
 
-
 
1582
		Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
-
 
1583
		if (emails.contains(authUser.getEmailId())) {
-
 
1584
			fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
-
 
1585
			LOGGER.info("fofoIds" + fofoIds);
-
 
1586
		}
-
 
1587
 
-
 
1588
		if (fofoIds == null) {
-
 
1589
			List<Position> positions1 = positionRepository.selectAll(authUser.getId());
-
 
1590
			if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
-
 
1591
					.count() > 0) {
-
 
1592
				fofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream().flatMap(x -> x.stream())
-
 
1593
						.map(x -> x.getPartnerId()).collect(Collectors.toSet());
-
 
1594
			}
-
 
1595
		}
-
 
1596
		return new ArrayList<>(fofoIds);
-
 
1597
	}
-
 
1598
 
1506
}
1599
}