Subversion Repositories SmartDukaan

Rev

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

Rev 28435 Rev 28439
Line 111... Line 111...
111
import com.spice.profitmandi.dao.model.InStockBrandModel;
111
import com.spice.profitmandi.dao.model.InStockBrandModel;
112
import com.spice.profitmandi.dao.model.ItemWiseTertiaryModel;
112
import com.spice.profitmandi.dao.model.ItemWiseTertiaryModel;
113
import com.spice.profitmandi.dao.model.MonthSaleModel;
113
import com.spice.profitmandi.dao.model.MonthSaleModel;
114
import com.spice.profitmandi.dao.model.PartnerDetailModel;
114
import com.spice.profitmandi.dao.model.PartnerDetailModel;
115
import com.spice.profitmandi.dao.model.PartnerPendingIndentItemModel;
115
import com.spice.profitmandi.dao.model.PartnerPendingIndentItemModel;
-
 
116
import com.spice.profitmandi.dao.model.SecondaryOrderBilledLmsModel;
116
import com.spice.profitmandi.dao.model.SimpleCampaign;
117
import com.spice.profitmandi.dao.model.SimpleCampaign;
117
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
118
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
118
import com.spice.profitmandi.dao.model.WarehouseBrandItemUnbilledActivatedModel;
119
import com.spice.profitmandi.dao.model.WarehouseBrandItemUnbilledActivatedModel;
119
import com.spice.profitmandi.dao.model.WarehouseBrandWiseItemSaleModel;
120
import com.spice.profitmandi.dao.model.WarehouseBrandWiseItemSaleModel;
120
import com.spice.profitmandi.dao.model.WarehouseWiseBrandSaleModel;
121
import com.spice.profitmandi.dao.model.WarehouseWiseBrandSaleModel;
Line 755... Line 756...
755
		model.addAttribute("linechartMap", gson.toJson(cm));
756
		model.addAttribute("linechartMap", gson.toJson(cm));
756
 
757
 
757
		return "lmsLineChart";
758
		return "lmsLineChart";
758
	}
759
	}
759
 
760
 
-
 
761
	@RequestMapping(value = "/getMonthlyPurchaseLineChart", method = RequestMethod.GET)
-
 
762
	public String getMonthlyPurchaseLineChart(HttpServletRequest request, Model model) throws Exception {
-
 
763
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
764
		int fofoId = loginDetails.getFofoId();
-
 
765
		ChartModel cm = this.getPurchaseOrderChart(fofoId);
-
 
766
 
-
 
767
		LOGGER.info("chartMap" + gson.toJson(cm));
-
 
768
		model.addAttribute("chartMap", gson.toJson(cm));
-
 
769
 
-
 
770
		return "purchase_chart";
-
 
771
	}
-
 
772
 
760
	@RequestMapping(value = "/getBarChart", method = RequestMethod.GET)
773
	@RequestMapping(value = "/getBarChart", method = RequestMethod.GET)
761
	public String getBarChart(HttpServletRequest request, Model model) throws Exception {
774
	public String getBarChart(HttpServletRequest request, Model model) throws Exception {
762
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
775
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
763
		int fofoId = loginDetails.getFofoId();
776
		int fofoId = loginDetails.getFofoId();
764
		ChartModel cm = this.getBrandChart(fofoId);
777
		ChartModel cm = this.getBrandChart(fofoId);
Line 843... Line 856...
843
		cm.setOptions(om);
856
		cm.setOptions(om);
844
 
857
 
845
		return cm;
858
		return cm;
846
	}
859
	}
847
 
860
 
-
 
861
	private ChartModel getPurchaseOrderChart(int fofoId) throws ProfitMandiBusinessException {
-
 
862
 
-
 
863
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
-
 
864
 
-
 
865
		LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(1);
-
 
866
 
-
 
867
		List<SecondaryOrderBilledLmsModel> soblms = orderRepository.selectAllBilledOrderGroupByBrandFofoId(fofoId,
-
 
868
				curDate.withDayOfMonth(1).minusMonths(6));
-
 
869
 
-
 
870
		LOGGER.info("soblms" + soblms);
-
 
871
		Map<String, Map<YearMonth, Double>> brandMonthValueMap = new HashMap<>();
-
 
872
		for (SecondaryOrderBilledLmsModel orderBilledLmsMode : soblms) {
-
 
873
			Map<YearMonth, Double> yearMonthMap = new HashMap<>();
-
 
874
			yearMonthMap.put(YearMonth.from(startOfMonth), (double) orderBilledLmsMode.getFirstMonthValue());
-
 
875
			yearMonthMap.put(YearMonth.from(startOfMonth.minusNanos(1)),
-
 
876
					(double) orderBilledLmsMode.getSecondMonthValue());
-
 
877
 
-
 
878
			yearMonthMap.put(YearMonth.from(startOfMonth.minusMonths(2)),
-
 
879
					(double) orderBilledLmsMode.getThirdMonthValue());
-
 
880
			yearMonthMap.put(YearMonth.from(startOfMonth.minusMonths(3)),
-
 
881
					(double) orderBilledLmsMode.getFourthMonthValue());
-
 
882
			yearMonthMap.put(YearMonth.from(startOfMonth.minusMonths(4)),
-
 
883
					(double) orderBilledLmsMode.getFifthMonthValue());
-
 
884
			yearMonthMap.put(YearMonth.from(startOfMonth.minusMonths(5)),
-
 
885
					(double) orderBilledLmsMode.getSixthMonthValue());
-
 
886
			Map<YearMonth, Double> sortedYearMonthMap = new TreeMap<YearMonth, Double>(yearMonthMap);
-
 
887
			brandMonthValueMap.put(orderBilledLmsMode.getBrand(), sortedYearMonthMap);
-
 
888
 
-
 
889
		}
-
 
890
		LOGGER.info("brandMonthValueMap" + brandMonthValueMap);
-
 
891
 
-
 
892
		List<String> brands = new ArrayList<>();
-
 
893
		brands.add("Accessories");
-
 
894
		brands.add("Oppo");
-
 
895
		brands.add("Vivo");
-
 
896
		brands.add("Samsung");
-
 
897
		brands.add("Realme");
-
 
898
		brands.add("Mi");
-
 
899
		brands.add("Tecno");
-
 
900
		brands.add("Itel");
-
 
901
		brands.add("Lava");
-
 
902
		brands.add("Nokia");
-
 
903
		Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
-
 
904
 
-
 
905
		for (String brand : brands) {
-
 
906
			Map<YearMonth, Double> coll = brandMonthValueMap.get(brand);
-
 
907
			LOGGER.info("coll" + coll);
-
 
908
			List<Double> valueList = new ArrayList<>();
-
 
909
 
-
 
910
			if (coll != null) {
-
 
911
 
-
 
912
				valueList.addAll(coll.values());
-
 
913
			}
-
 
914
			sortedBrandValue.put(brand, valueList);
-
 
915
 
-
 
916
		}
-
 
917
		LinkedHashSet<String> labels = new LinkedHashSet<String>();
-
 
918
		
-
 
919
		for (int i = 6; i >= 1; i--) {
-
 
920
 
-
 
921
			LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
-
 
922
			labels.add(startMonth.format(DateTimeFormatter.ofPattern("MMM''uu")).toString());
-
 
923
 
-
 
924
			LOGGER.info("labels" + labels);
-
 
925
		}
-
 
926
 
-
 
927
		LOGGER.info("labels" + labels);
-
 
928
	
-
 
929
		LOGGER.info("sortedBrandValue" + sortedBrandValue);
-
 
930
		List<DatasetModel> datasets = new ArrayList<>();
-
 
931
		List<String> colorList = new ArrayList<>();
-
 
932
		colorList.add("slateblue");
-
 
933
		colorList.add("darkgreen");
-
 
934
		colorList.add("darkorange");
-
 
935
		colorList.add("#654321");
-
 
936
		colorList.add("deeppink");
-
 
937
 
-
 
938
		colorList.add("darkred");
-
 
939
 
-
 
940
		colorList.add("burlywood");
-
 
941
		colorList.add("goldenrod");
-
 
942
		colorList.add("slategray");
-
 
943
		colorList.add("darkviolet");
-
 
944
		colorList.add("cornsilk");
-
 
945
 
-
 
946
		List<String> borderList = new ArrayList<>();
-
 
947
		borderList.add("lightskyblue");
-
 
948
		borderList.add("green");
-
 
949
		borderList.add("orange");
-
 
950
		borderList.add("#DB8C44");
-
 
951
		borderList.add("pink");
-
 
952
		borderList.add("red");
-
 
953
 
-
 
954
		borderList.add("slategray");
-
 
955
		borderList.add("burlywood");
-
 
956
		borderList.add("goldenrod");
-
 
957
		borderList.add("darkviolet");
-
 
958
		borderList.add("cornsilk");
-
 
959
 
-
 
960
		int i = 0;
-
 
961
 
-
 
962
		for (Entry<String, List<Double>> brandValue : sortedBrandValue.entrySet()) {
-
 
963
 
-
 
964
			DatasetModel purchaseModel = new DatasetModel();
-
 
965
			purchaseModel.setLabel(brandValue.getKey());
-
 
966
			purchaseModel.setBackgroundColor(borderList.get(i));
-
 
967
			if (brandValue.getValue().isEmpty()) {
-
 
968
 
-
 
969
				purchaseModel.setData(Arrays.asList(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
-
 
970
			} else {
-
 
971
				purchaseModel.setData(brandValue.getValue());
-
 
972
			}
-
 
973
			purchaseModel.setType("line");
-
 
974
			purchaseModel.setOrder(1);
-
 
975
			purchaseModel.setFill("false");
-
 
976
			purchaseModel.setBorderColor(colorList.get(i));
-
 
977
			datasets.add(purchaseModel);
-
 
978
 
-
 
979
			i++;
-
 
980
		}
-
 
981
 
-
 
982
		DataModel dm = new DataModel();
-
 
983
		dm.setDatasets(datasets);
-
 
984
		dm.setLabels(labels);
-
 
985
 
-
 
986
		LegendModel lm = new LegendModel();
-
 
987
		lm.setPosition("top");
-
 
988
 
-
 
989
		Tooltips tooltips = new Tooltips();
-
 
990
		tooltips.setBodyFontSize(15);
-
 
991
		tooltips.setTitleFontSize(15);
-
 
992
		tooltips.setMode("index");
-
 
993
		tooltips.setIntersect(false);
-
 
994
 
-
 
995
		HoverModel hover = new HoverModel();
-
 
996
		hover.setIntersect(false);
-
 
997
		hover.setMode("index");
-
 
998
 
-
 
999
		TitleModel tm = new TitleModel();
-
 
1000
		tm.setText("Brand Wise Monthly Purchase");
-
 
1001
		tm.setDisplay(true);
-
 
1002
		tm.setFontSize(20);
-
 
1003
		tm.setFontColor("#111");
-
 
1004
 
-
 
1005
		OptionsModel om = new OptionsModel();
-
 
1006
		om.setResponsive(true);
-
 
1007
		om.setLegend(lm);
-
 
1008
		om.setTitle(tm);
-
 
1009
		om.setTooltips(tooltips);
-
 
1010
		om.setHover(hover);
-
 
1011
 
-
 
1012
		ChartModel cm = new ChartModel();
-
 
1013
		cm.setType("line");
-
 
1014
		cm.setData(dm);
-
 
1015
		cm.setOptions(om);
-
 
1016
 
-
 
1017
		LOGGER.info("cm" + cm);
-
 
1018
 
-
 
1019
		return cm;
-
 
1020
 
-
 
1021
	}
-
 
1022
 
848
	private ChartModel getLmsLineChart(int fofoId) throws ProfitMandiBusinessException {
1023
	private ChartModel getLmsLineChart(int fofoId) throws ProfitMandiBusinessException {
849
 
1024
 
850
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
1025
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
851
 
1026
 
852
		Map<YearMonth, Map<String, Double>> monthValueMap = new HashMap<>();
1027
		Map<YearMonth, Map<String, Double>> monthValueMap = new HashMap<>();
Line 921... Line 1096...
921
 
1096
 
922
		}
1097
		}
923
 
1098
 
924
		List<String> labelList = new ArrayList<>(labels);
1099
		List<String> labelList = new ArrayList<>(labels);
925
		List<Double> lmsValues = new ArrayList<>();
1100
		List<Double> lmsValues = new ArrayList<>();
-
 
1101
 
926
		List<DatasetModel> datasets = new ArrayList<>();
1102
		List<DatasetModel> datasets = new ArrayList<>();
927
		List<String> colorList = new ArrayList<>();
1103
		List<String> colorList = new ArrayList<>();
928
		colorList.add("slateblue");
1104
		colorList.add("slateblue");
929
		colorList.add("darkgreen");
1105
		colorList.add("darkgreen");
930
		colorList.add("darkorange");
1106
		colorList.add("darkorange");
931
		colorList.add("#654321");
1107
		colorList.add("#654321");
932
		colorList.add("deeppink");
1108
		colorList.add("deeppink");
933
		
1109
 
934
		colorList.add("darkred");
1110
		colorList.add("darkred");
935
		
1111
 
936
		colorList.add("burlywood");
1112
		colorList.add("burlywood");
937
		colorList.add("goldenrod");
1113
		colorList.add("goldenrod");
938
		colorList.add("slategray");
1114
		colorList.add("slategray");
939
		colorList.add("darkviolet");
1115
		colorList.add("darkviolet");
940
		colorList.add("cornsilk");
1116
		colorList.add("cornsilk");
Line 943... Line 1119...
943
		borderList.add("lightskyblue");
1119
		borderList.add("lightskyblue");
944
		borderList.add("green");
1120
		borderList.add("green");
945
		borderList.add("orange");
1121
		borderList.add("orange");
946
		borderList.add("#DB8C44");
1122
		borderList.add("#DB8C44");
947
		borderList.add("pink");
1123
		borderList.add("pink");
948
		
-
 
949
		borderList.add("red");
1124
		borderList.add("red");
950
		
1125
 
951
		borderList.add("slategray");
1126
		borderList.add("slategray");
952
		borderList.add("burlywood");
1127
		borderList.add("burlywood");
953
		borderList.add("goldenrod");
1128
		borderList.add("goldenrod");
954
		borderList.add("darkviolet");
1129
		borderList.add("darkviolet");
955
		borderList.add("cornsilk");
1130
		borderList.add("cornsilk");
Line 961... Line 1136...
961
			DatasetModel lineLmsChart = new DatasetModel();
1136
			DatasetModel lineLmsChart = new DatasetModel();
962
			lineLmsChart.setLabel(brandValue.getKey());
1137
			lineLmsChart.setLabel(brandValue.getKey());
963
			lineLmsChart.setBackgroundColor(borderList.get(i));
1138
			lineLmsChart.setBackgroundColor(borderList.get(i));
964
			if (brandValue.getValue().isEmpty()) {
1139
			if (brandValue.getValue().isEmpty()) {
965
 
1140
 
966
                  lineLmsChart.setData(Arrays.asList(0.0,0.0,0.0,0.0,0.0,0.0));
1141
				lineLmsChart.setData(Arrays.asList(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
967
			} else {
1142
			} else {
968
				lineLmsChart.setData(brandValue.getValue());
1143
				lineLmsChart.setData(brandValue.getValue());
969
			}
1144
			}
970
			lineLmsChart.setType("line");
1145
			lineLmsChart.setType("line");
971
			lineLmsChart.setOrder(1);
1146
			lineLmsChart.setOrder(1);