Subversion Repositories SmartDukaan

Rev

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

Rev 30017 Rev 30028
Line 837... Line 837...
837
 
837
 
838
	}
838
	}
839
 
839
 
840
	@RequestMapping(value = "/setUpdateLimit", method = RequestMethod.POST)
840
	@RequestMapping(value = "/setUpdateLimit", method = RequestMethod.POST)
841
	public String getUpdateLimit(HttpServletRequest request,
841
	public String getUpdateLimit(HttpServletRequest request,
842
								 @RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
842
			@RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
843
								 @RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
843
			@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
844
								 @RequestParam(name = "limit", required = true, defaultValue = "0") float limit, Model model)
844
			@RequestParam(name = "limit", required = true, defaultValue = "0") float limit,
-
 
845
			@RequestParam(name = "minStockLimit", required = true, defaultValue = "0") float minStockLimit,
-
 
846
			@RequestParam(name = "preLimit", required = true, defaultValue = "0") float preLimit,
-
 
847
			@RequestParam(name = "preStockLimit", required = true, defaultValue = "0") float preStockLimit, Model model)
845
			throws Exception {
848
			throws Exception {
846
 
849
 
847
		CustomRetailer cr = retailerService.getFofoRetailer(fofoId);
850
		CustomRetailer cr = retailerService.getFofoRetailer(fofoId);
848
 
851
 
849
		Map.Entry<Integer, CustomRetailer> customRetailers = new AbstractMap.SimpleEntry(cr.getPartnerId(), cr);
852
		Map.Entry<Integer, CustomRetailer> customRetailers = new AbstractMap.SimpleEntry(cr.getPartnerId(), cr);
850
 
853
 
851
		// Map<Integer, CustomRetailer> customRetailers =
854
		// Map<Integer, CustomRetailer> customRetailers =
852
		// retailerService.getFofoRetailers(true);
855
		// retailerService.getFofoRetailers(true);
853
		LOGGER.info("customRetailers" + customRetailers);
-
 
-
 
856
 
854
		RetailerBrandsLimit retailerBrands = retailerBrandsLimitRepository.selectLimitByBrandAndFofoId(fofoId, brand);
857
		RetailerBrandsLimit retailerBrands = retailerBrandsLimitRepository.selectLimitByBrandAndFofoId(fofoId, brand);
855
 
858
 
856
		if (retailerBrands == null) {
859
		if (retailerBrands == null) {
857
			retailerBrands = new RetailerBrandsLimit();
860
			retailerBrands = new RetailerBrandsLimit();
-
 
861
 
-
 
862
			if (minStockLimit != 0) {
-
 
863
 
-
 
864
				retailerBrands.setMinStockLimit(minStockLimit);
-
 
865
			} else {
-
 
866
				retailerBrands.setMinStockLimit(preStockLimit);
-
 
867
			}
-
 
868
			if (limit != 0) {
858
			retailerBrands.setBrandLimit(limit);
869
				retailerBrands.setBrandLimit(limit);
-
 
870
			} else {
-
 
871
				retailerBrands.setBrandLimit(preLimit);
-
 
872
			}
-
 
873
 
859
			retailerBrands.setIsUpdate(1);
874
			retailerBrands.setIsUpdate(1);
860
			retailerBrands.setCreatedTimestamp(LocalDateTime.now());
875
			retailerBrands.setCreatedTimestamp(LocalDateTime.now());
861
			retailerBrands.setPartnerId(fofoId);
876
			retailerBrands.setPartnerId(fofoId);
862
			retailerBrands.setBrandName(brand);
877
			retailerBrands.setBrandName(brand);
863
			retailerBrands.setUpdatedTimestamp(LocalDateTime.now());
878
			retailerBrands.setUpdatedTimestamp(LocalDateTime.now());
864
			retailerBrandsLimitRepository.persist(retailerBrands);
879
			retailerBrandsLimitRepository.persist(retailerBrands);
865
 
-
 
866
		} else {
880
		} else {
-
 
881
			if (minStockLimit != 0) {
-
 
882
				retailerBrands.setMinStockLimit(minStockLimit);
-
 
883
			} else {
-
 
884
				retailerBrands.setMinStockLimit(preStockLimit);
-
 
885
			}
-
 
886
 
-
 
887
			if (limit != 0) {
867
			retailerBrands.setBrandLimit(limit);
888
				retailerBrands.setBrandLimit(limit);
-
 
889
			} else {
-
 
890
				retailerBrands.setBrandLimit(preLimit);
-
 
891
			}
868
			retailerBrands.setIsUpdate(1);
892
			retailerBrands.setIsUpdate(1);
869
			retailerBrands.setUpdatedTimestamp(LocalDateTime.now());
893
			retailerBrands.setUpdatedTimestamp(LocalDateTime.now());
870
			retailerBrandsLimitRepository.persist(retailerBrands);
894
			retailerBrandsLimitRepository.persist(retailerBrands);
871
 
895
 
872
		}
896
		}
Line 906... Line 930...
906
		model.addAttribute("brandLimit", brandLimit);
930
		model.addAttribute("brandLimit", brandLimit);
907
 
931
 
908
		return "brands-limit-mapping";
932
		return "brands-limit-mapping";
909
 
933
 
910
	}
934
	}
911
 
-
 
912
	@RequestMapping(value = "/setBrandWiseLimit", method = RequestMethod.POST)
935
	@RequestMapping(value = "/setBrandWiseLimit", method = RequestMethod.POST)
913
	public String brandwiseLimit(HttpServletRequest request,
936
	public String brandwiseLimit(HttpServletRequest request,
914
								 @RequestParam(name = "brands", required = true, defaultValue = "") String brands,
937
			@RequestParam(name = "brands", required = true, defaultValue = "") String brands,
915
								 @RequestParam(name = "limit", required = true, defaultValue = "") float limit, Model model)
938
			@RequestParam(name = "limit", required = true, defaultValue = "") float limit, Model model)
916
			throws Exception {
939
			throws Exception {
917
 
940
 
918
		LOGGER.info("limit" + limit);
941
		LOGGER.info("limit" + limit);
919
 
942
 
920
		BrandLimit brandLimit = brandLimitRepository.setLimitByBrands(brands);
943
		BrandLimit brandLimit = brandLimitRepository.setLimitByBrands(brands);
Line 933... Line 956...
933
			brandLimit.setBrandName(brands);
956
			brandLimit.setBrandName(brands);
934
			brandLimit.setCreatedTimestamp(LocalDateTime.now());
957
			brandLimit.setCreatedTimestamp(LocalDateTime.now());
935
			brandLimit.setUpdatedTimestamp(LocalDateTime.now());
958
			brandLimit.setUpdatedTimestamp(LocalDateTime.now());
936
			brandLimitRepository.persist(brandLimit);
959
			brandLimitRepository.persist(brandLimit);
937
 
960
 
-
 
961
		}
-
 
962
 
938
		} else {
963
		else {
939
			brandLimit.setBrandLimit(limit);
964
			brandLimit.setBrandLimit(limit);
940
 
965
 
941
			brandLimit.setUpdatedTimestamp(LocalDateTime.now());
966
			brandLimit.setUpdatedTimestamp(LocalDateTime.now());
942
			brandLimitRepository.persist(brandLimit);
967
			brandLimitRepository.persist(brandLimit);
943
 
968
 
Line 948... Line 973...
948
		model.addAttribute("brand", brands);
973
		model.addAttribute("brand", brands);
949
		model.addAttribute("brandLimit", brandLimit);
974
		model.addAttribute("brandLimit", brandLimit);
950
		model.addAttribute("customRetailers", customRetailers);
975
		model.addAttribute("customRetailers", customRetailers);
951
		model.addAttribute("retailerBrandsLimitMap", retailerBrandsLimitMap);
976
		model.addAttribute("retailerBrandsLimitMap", retailerBrandsLimitMap);
952
		return "brands-limit-mapping";
977
		return "brands-limit-mapping";
-
 
978
 
-
 
979
	}
-
 
980
 
-
 
981
	@RequestMapping(value = "/setBrandWiseStockLimit", method = RequestMethod.POST)
-
 
982
	public String setBrandWiseStockLimit(HttpServletRequest request,
-
 
983
			@RequestParam(name = "brands", required = true, defaultValue = "") String brands,
-
 
984
			@RequestParam(name = "stockLimit", required = true, defaultValue = "") float stockLimit, Model model)
-
 
985
			throws Exception {
-
 
986
 
-
 
987
		LOGGER.info("limit" + stockLimit);
-
 
988
 
-
 
989
		BrandLimit brandLimit = brandLimitRepository.setLimitByBrands(brands);
-
 
990
 
-
 
991
		List<RetailerBrandsLimit> retailerBrandsLimit = retailerBrandsLimitRepository.setAllLimitByBrands(brands);
-
 
992
 
-
 
993
		Map<Integer, RetailerBrandsLimit> retailerBrandsLimitMap = retailerBrandsLimit.stream()
-
 
994
				.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
995
 
-
 
996
		Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(true);
-
 
997
 
-
 
998
		if (brandLimit == null) {
-
 
999
 
-
 
1000
			brandLimit = new BrandLimit();
-
 
1001
			brandLimit.setBrandLimit(0);
-
 
1002
			brandLimit.setBrandName(brands);
-
 
1003
			brandLimit.setStockLimit(stockLimit);
-
 
1004
			brandLimit.setCreatedTimestamp(LocalDateTime.now());
-
 
1005
			brandLimit.setUpdatedTimestamp(LocalDateTime.now());
-
 
1006
			brandLimitRepository.persist(brandLimit);
-
 
1007
 
-
 
1008
		}
-
 
1009
 
-
 
1010
		else {
-
 
1011
			brandLimit.setStockLimit(stockLimit);
-
 
1012
 
-
 
1013
			brandLimit.setUpdatedTimestamp(LocalDateTime.now());
-
 
1014
			brandLimitRepository.persist(brandLimit);
-
 
1015
 
-
 
1016
		}
-
 
1017
		brandLimit = brandLimitRepository.setLimitByBrands(brands);
-
 
1018
 
-
 
1019
		model.addAttribute("brand", brands);
-
 
1020
		model.addAttribute("brandLimit", brandLimit);
-
 
1021
		model.addAttribute("customRetailers", customRetailers);
-
 
1022
		model.addAttribute("retailerBrandsLimitMap", retailerBrandsLimitMap);
-
 
1023
		return "brands-limit-mapping";
953
 
1024
 
954
	}
1025
	}
955
 
1026
 
956
	@RequestMapping(value = "/setPartnerPincode", method = RequestMethod.POST)
1027
	@RequestMapping(value = "/setPartnerPincode", method = RequestMethod.POST)
957
	public String setPartnerPincode(HttpServletRequest request,
1028
	public String setPartnerPincode(HttpServletRequest request,