Subversion Repositories SmartDukaan

Rev

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

Rev 29677 Rev 29707
Line 68... Line 68...
68
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
68
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
69
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
69
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
70
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
70
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
71
import com.spice.profitmandi.dao.entity.inventory.ReporticoCacheTable;
71
import com.spice.profitmandi.dao.entity.inventory.ReporticoCacheTable;
72
import com.spice.profitmandi.dao.entity.transaction.Order;
72
import com.spice.profitmandi.dao.entity.transaction.Order;
-
 
73
import com.spice.profitmandi.dao.enumuration.catalog.UpgradeOfferStatus;
73
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
74
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
74
import com.spice.profitmandi.dao.model.ActivationBrandModel;
75
import com.spice.profitmandi.dao.model.ActivationBrandModel;
75
import com.spice.profitmandi.dao.model.ActivationImeiUpdationModel;
76
import com.spice.profitmandi.dao.model.ActivationImeiUpdationModel;
76
import com.spice.profitmandi.dao.model.ActivationItemDetailModel;
77
import com.spice.profitmandi.dao.model.ActivationItemDetailModel;
77
import com.spice.profitmandi.dao.model.ActivationYearMonthModel;
78
import com.spice.profitmandi.dao.model.ActivationYearMonthModel;
-
 
79
import com.spice.profitmandi.dao.model.BrandAmountModel;
78
import com.spice.profitmandi.dao.model.BrandWiseActivatedModel;
80
import com.spice.profitmandi.dao.model.BrandWiseActivatedModel;
79
import com.spice.profitmandi.dao.model.BrandWisePartnerSaleModel;
81
import com.spice.profitmandi.dao.model.BrandWisePartnerSaleModel;
80
import com.spice.profitmandi.dao.model.BrandWiseUnbilledActivateStockModel;
82
import com.spice.profitmandi.dao.model.BrandWiseUnbilledActivateStockModel;
81
import com.spice.profitmandi.dao.model.CreateOfferRequest;
83
import com.spice.profitmandi.dao.model.CreateOfferRequest;
82
import com.spice.profitmandi.dao.model.InStockBrandItemModel;
84
import com.spice.profitmandi.dao.model.InStockBrandItemModel;
Line 86... Line 88...
86
import com.spice.profitmandi.dao.model.PartnerDetailModel;
88
import com.spice.profitmandi.dao.model.PartnerDetailModel;
87
import com.spice.profitmandi.dao.model.PartnerPendingIndentItemModel;
89
import com.spice.profitmandi.dao.model.PartnerPendingIndentItemModel;
88
import com.spice.profitmandi.dao.model.PriceDropBrandModel;
90
import com.spice.profitmandi.dao.model.PriceDropBrandModel;
89
import com.spice.profitmandi.dao.model.PriceDropWithDetailsByYearMonthModel;
91
import com.spice.profitmandi.dao.model.PriceDropWithDetailsByYearMonthModel;
90
import com.spice.profitmandi.dao.model.PriceDropYearMonthModel;
92
import com.spice.profitmandi.dao.model.PriceDropYearMonthModel;
-
 
93
import com.spice.profitmandi.dao.model.SamsungUpgradeOfferModel;
-
 
94
import com.spice.profitmandi.dao.model.UpgradeOfferItemDetailModel;
91
import com.spice.profitmandi.dao.model.WarehouseBrandItemUnbilledActivatedModel;
95
import com.spice.profitmandi.dao.model.WarehouseBrandItemUnbilledActivatedModel;
92
import com.spice.profitmandi.dao.model.WarehouseBrandWiseItemActivatedModel;
96
import com.spice.profitmandi.dao.model.WarehouseBrandWiseItemActivatedModel;
93
import com.spice.profitmandi.dao.model.WarehouseBrandWiseItemSaleModel;
97
import com.spice.profitmandi.dao.model.WarehouseBrandWiseItemSaleModel;
94
import com.spice.profitmandi.dao.model.WarehouseWiseActivatedModel;
98
import com.spice.profitmandi.dao.model.WarehouseWiseActivatedModel;
95
import com.spice.profitmandi.dao.model.WarehouseWiseBrandSaleModel;
99
import com.spice.profitmandi.dao.model.WarehouseWiseBrandSaleModel;
96
import com.spice.profitmandi.dao.model.WarehouseWiseBrandStockModel;
100
import com.spice.profitmandi.dao.model.WarehouseWiseBrandStockModel;
97
import com.spice.profitmandi.dao.model.WarehouseWiseBrandUnbilledActivatedModel;
101
import com.spice.profitmandi.dao.model.WarehouseWiseBrandUnbilledActivatedModel;
98
import com.spice.profitmandi.dao.model.WarehouseWiseitemStockModel;
102
import com.spice.profitmandi.dao.model.WarehouseWiseitemStockModel;
99
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
103
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
100
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
104
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
-
 
105
import com.spice.profitmandi.dao.repository.catalog.SamsungUpgradeOfferRepository;
101
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
106
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
102
import com.spice.profitmandi.dao.repository.cs.CsService;
107
import com.spice.profitmandi.dao.repository.cs.CsService;
103
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
108
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
104
import com.spice.profitmandi.dao.repository.cs.TicketAssignedRepository;
109
import com.spice.profitmandi.dao.repository.cs.TicketAssignedRepository;
105
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
110
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
Line 273... Line 278...
273
	@Autowired
278
	@Autowired
274
	private FofoLineItemRepository fofoLineItemRepository;
279
	private FofoLineItemRepository fofoLineItemRepository;
275
 
280
 
276
	@Autowired
281
	@Autowired
277
	private PositionRepository positionRepository;
282
	private PositionRepository positionRepository;
-
 
283
 
-
 
284
	@Autowired
-
 
285
	private SamsungUpgradeOfferRepository samsungUpgradeOfferRepository;
278
	private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
286
	private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
279
 
287
 
280
	@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
288
	@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
281
	public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
289
	public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
282
		boolean isAdmin = false;
290
		boolean isAdmin = false;
Line 869... Line 877...
869
		model.addAttribute("activationItemDetails", activationItemDetails);
877
		model.addAttribute("activationItemDetails", activationItemDetails);
870
 
878
 
871
		return "activation-pending-item-details";
879
		return "activation-pending-item-details";
872
	}
880
	}
873
 
881
 
-
 
882
	@RequestMapping(value = "/getMonthlySamsungUpgradeOffer", method = RequestMethod.GET)
-
 
883
	public String getMonthlySamsungUpgradeOffer(HttpServletRequest request, Model model) throws Exception {
-
 
884
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
885
		int fofoId = loginDetails.getFofoId();
-
 
886
 
-
 
887
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
-
 
888
		LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
-
 
889
 
-
 
890
		List<YearMonth> yms = new ArrayList<YearMonth>();
-
 
891
 
-
 
892
		for (int i = 0; i <= 5; i++) {
-
 
893
			yms.add(YearMonth.from(curDate.withDayOfMonth(1).minusMonths(i)));
-
 
894
		}
-
 
895
		Collections.reverse(yms);
-
 
896
		model.addAttribute("yms", yms);
-
 
897
		LOGGER.info("ym" + yms);
-
 
898
 
-
 
899
		List<SamsungUpgradeOfferModel> suos = samsungUpgradeOfferRepository.selectUpgradeOfferGroupByYearMonth(fofoId,
-
 
900
				UpgradeOfferStatus.approved, startOfMonth);
-
 
901
 
-
 
902
		LOGGER.info("suos" + suos);
-
 
903
 
-
 
904
		List<BrandAmountModel> beforeSixMonthOffers = samsungUpgradeOfferRepository
-
 
905
				.selectUpgradeOfferByYearMonthGroupByBrand(fofoId, UpgradeOfferStatus.approved, startOfMonth);
-
 
906
 
-
 
907
		Map<String, Double> pendingUpgradeOfferBeforeSixMonthMap = beforeSixMonthOffers.stream()
-
 
908
				.collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getAmount()));
-
 
909
 
-
 
910
		model.addAttribute("pendingUpgradeOfferBeforeSixMonthMap", pendingUpgradeOfferBeforeSixMonthMap);
-
 
911
 
-
 
912
		DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
-
 
913
 
-
 
914
		Map<String, Map<YearMonth, Double>> upgradeOfferBrandMonthMap = new HashMap<>();
-
 
915
 
-
 
916
		for (SamsungUpgradeOfferModel suo : suos) {
-
 
917
			Map<YearMonth, Double> brandValue = new HashMap<>();
-
 
918
 
-
 
919
			if (upgradeOfferBrandMonthMap.containsKey(suo.getBrand())) {
-
 
920
				brandValue = upgradeOfferBrandMonthMap.get(suo.getBrand());
-
 
921
				brandValue.put(YearMonth.parse(suo.getYearMonth(), dateTimeFormatter), (double) suo.getAmount());
-
 
922
			} else {
-
 
923
 
-
 
924
				brandValue.put(YearMonth.parse(suo.getYearMonth(), dateTimeFormatter), (double) suo.getAmount());
-
 
925
 
-
 
926
			}
-
 
927
			upgradeOfferBrandMonthMap.put(suo.getBrand(), brandValue);
-
 
928
		}
-
 
929
 
-
 
930
		Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
-
 
931
		String brand = "Samsung";
-
 
932
 
-
 
933
		Map<YearMonth, Double> yearMonthValue = upgradeOfferBrandMonthMap.get(brand);
-
 
934
		for (int i = 5; i >= 0; i--) {
-
 
935
			LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
-
 
936
			if (yearMonthValue != null) {
-
 
937
				if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
-
 
938
					yearMonthValue.put(YearMonth.from(startMonth), 0.0);
-
 
939
				}
-
 
940
 
-
 
941
			} else {
-
 
942
				yearMonthValue = new HashMap<>();
-
 
943
				yearMonthValue.put(YearMonth.from(startMonth), 0.0);
-
 
944
			}
-
 
945
		}
-
 
946
		Map<YearMonth, Double> sortedMonthBrandValue = new TreeMap<>(yearMonthValue);
-
 
947
		upgradeOfferBrandMonthMap.put(brand, sortedMonthBrandValue);
-
 
948
		sortedBrandValue.put(brand, sortedMonthBrandValue.values().stream().collect(Collectors.toList()));
-
 
949
		LOGGER.info("sortedBrandValue" + sortedBrandValue);
-
 
950
 
-
 
951
		model.addAttribute("brand", brand);
-
 
952
		model.addAttribute("sortedBrandValue", sortedBrandValue);
-
 
953
		model.addAttribute("fofoId", fofoId);
-
 
954
		return "upgrade-offer-tabular";
-
 
955
 
-
 
956
	}
-
 
957
 
-
 
958
	@RequestMapping(value = "/getMonthlyUpgradeOfferItemDetail", method = RequestMethod.GET)
-
 
959
	public String getMonthlyUpgradeOfferItemDetail(HttpServletRequest request,
-
 
960
			@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
-
 
961
			@RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
-
 
962
			@RequestParam(name = "yearMonth", required = false, defaultValue = "0") String yearMonth, Model model)
-
 
963
			throws Exception {
-
 
964
 
-
 
965
		LOGGER.info("params" + fofoId + brand + yearMonth);
-
 
966
		List<UpgradeOfferItemDetailModel> offerItems = samsungUpgradeOfferRepository
-
 
967
				.selectUpgradeOfferItemDetails(fofoId, UpgradeOfferStatus.approved, brand, yearMonth);
-
 
968
 
-
 
969
		model.addAttribute("offerItems", offerItems);
-
 
970
 
-
 
971
		return "upgrade-offer-item-detail";
-
 
972
	}
-
 
973
 
-
 
974
	@RequestMapping(value = "/getUpgradeOfferBeforeSixMonthItemDetail", method = RequestMethod.GET)
-
 
975
	public String getUpgradeOfferBeforeSixMonthItemDetail(HttpServletRequest request,
-
 
976
			@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
-
 
977
			@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model)
-
 
978
			throws Exception {
-
 
979
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
-
 
980
 
-
 
981
		LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
-
 
982
 
-
 
983
		List<UpgradeOfferItemDetailModel> offerItems = samsungUpgradeOfferRepository
-
 
984
				.selectUpgradeOfferItemDetailByYearMonth(fofoId, UpgradeOfferStatus.approved, brand, startOfMonth);
-
 
985
 
-
 
986
		model.addAttribute("offerItems", offerItems);
-
 
987
 
-
 
988
		return "upgrade-offer-item-detail";
-
 
989
	}
-
 
990
 
874
	@RequestMapping(value = "/getAuthUserPartners", method = RequestMethod.GET)
991
	@RequestMapping(value = "/getAuthUserPartners", method = RequestMethod.GET)
875
	public String AuthUserPartnersDetail(HttpServletRequest request, Model model, @RequestParam int authId)
992
	public String AuthUserPartnersDetail(HttpServletRequest request, Model model, @RequestParam int authId)
876
			throws Exception {
993
			throws Exception {
877
 
994
 
878
		Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
995
		Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();