Subversion Repositories SmartDukaan

Rev

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

Rev 27895 Rev 27900
Line 59... Line 59...
59
import com.spice.profitmandi.common.model.DataInvestmentModel;
59
import com.spice.profitmandi.common.model.DataInvestmentModel;
60
import com.spice.profitmandi.common.model.DataModel;
60
import com.spice.profitmandi.common.model.DataModel;
61
import com.spice.profitmandi.common.model.DatasetModel;
61
import com.spice.profitmandi.common.model.DatasetModel;
62
import com.spice.profitmandi.common.model.Legend;
62
import com.spice.profitmandi.common.model.Legend;
63
import com.spice.profitmandi.common.model.LegendModel;
63
import com.spice.profitmandi.common.model.LegendModel;
-
 
64
import com.spice.profitmandi.common.model.LineChartModel;
64
import com.spice.profitmandi.common.model.Notification;
65
import com.spice.profitmandi.common.model.Notification;
65
import com.spice.profitmandi.common.model.OptionModel;
66
import com.spice.profitmandi.common.model.OptionModel;
66
import com.spice.profitmandi.common.model.OptionsModel;
67
import com.spice.profitmandi.common.model.OptionsModel;
67
import com.spice.profitmandi.common.model.PieLables;
68
import com.spice.profitmandi.common.model.PieLables;
68
import com.spice.profitmandi.common.model.ProfitMandiConstants;
69
import com.spice.profitmandi.common.model.ProfitMandiConstants;
Line 641... Line 642...
641
		return "investmentdetails";
642
		return "investmentdetails";
642
	}
643
	}
643
 
644
 
644
	private ChartInvestmentModel getInvestmentChart(int fofoId) throws ProfitMandiBusinessException {
645
	private ChartInvestmentModel getInvestmentChart(int fofoId) throws ProfitMandiBusinessException {
645
		PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 0);
646
		PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 0);
-
 
647
 
646
		Map<String, Float> investmentWalletAmount = new HashMap<>();
648
		Map<String, Float> investmentWalletAmount = new HashMap<>();
647
		investmentWalletAmount.put("Wallet", investment.getWalletAmount());
649
		investmentWalletAmount.put("Wallet", investment.getWalletAmount());
648
 
-
 
649
		investmentWalletAmount.put("InStock", investment.getInStockAmount());
650
		investmentWalletAmount.put("InStock", investment.getInStockAmount());
650
		investmentWalletAmount.put("Unbilled", investment.getUnbilledAmount());
651
		investmentWalletAmount.put("Unbilled Order", investment.getUnbilledAmount());
651
		investmentWalletAmount.put("GrnPending", investment.getGrnPendingAmount());
652
		investmentWalletAmount.put("GrnPending", investment.getGrnPendingAmount());
652
		investmentWalletAmount.put("ReturnInTransit", investment.getReturnInTransitAmount());
653
		investmentWalletAmount.put("ReturnInTransit", investment.getReturnInTransitAmount());
653
 
654
 
-
 
655
		if (investment.getShortInvestment() > 0) {
-
 
656
			investmentWalletAmount.put("Short Investment", investment.getShortInvestment());
-
 
657
		}
-
 
658
 
654
		ChartInvestmentModel cm = new ChartInvestmentModel();
659
		ChartInvestmentModel cm = new ChartInvestmentModel();
655
 
660
 
656
		HashSet<String> labels = new HashSet<String>();
661
		HashSet<String> labels = new HashSet<String>();
657
		labels.addAll(investmentWalletAmount.keySet());
662
		labels.addAll(investmentWalletAmount.keySet());
658
 
663
 
659
		List<String> labelList = new ArrayList<>(labels);
664
		List<String> labelList = new ArrayList<>(labels);
660
		List<String> backgroundColor = new ArrayList<>();
665
		List<String> backgroundColor = new ArrayList<>();
661
 
-
 
-
 
666
		List<Float> labelsValue = new ArrayList<>();
662
		List<Float> values = new ArrayList<>();
667
		List<Float> values = new ArrayList<>();
663
		for (String label : labelList) {
668
		for (String label : labelList) {
664
			values.add(investmentWalletAmount.get(label));
669
			values.add(investmentWalletAmount.get(label));
665
			if (label.equals("Wallet")) {
670
			if (label.equals("Wallet")) {
666
				backgroundColor.add("pink");
671
				backgroundColor.add("pink");
667
			}
672
			}
-
 
673
			if (label.equals("Short Investment")) {
-
 
674
				backgroundColor.add("red");
668
 
675
			}
669
			if (label.equals("InStock")) {
676
			if (label.equals("InStock")) {
670
				backgroundColor.add("limegreen");
677
				backgroundColor.add("#9ACD32");
671
			}
678
			}
672
			if (label.equals("Unbilled")) {
679
			if (label.equals("Unbilled Order")) {
673
				backgroundColor.add("red");
680
				backgroundColor.add("blue");
674
			}
681
			}
675
 
682
 
676
			if (label.equals("ReturnInTransit")) {
683
			if (label.equals("ReturnInTransit")) {
677
				backgroundColor.add("orange");
684
				backgroundColor.add("orange");
678
			}
685
			}
Line 717... Line 724...
717
 
724
 
718
		LOGGER.info("cur Date" + curDate.withDayOfMonth(1));
725
		LOGGER.info("cur Date" + curDate.withDayOfMonth(1));
719
 
726
 
720
		LOGGER.info("curDateYear" + curDate.with(LocalTime.MAX));
727
		LOGGER.info("curDateYear" + curDate.with(LocalTime.MAX));
721
 
728
 
722
		Map<String, Double> brandwiseSale = fofoOrderItemRepository
729
		Map<String, Double> brandwisesale = fofoOrderItemRepository
723
				.selectSumAmountGroupByBrand(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId);
730
				.selectSumAmountGroupByBrand(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId);
724
 
731
 
725
		LOGGER.info("brandwisesale" + brandwiseSale);
732
		LOGGER.info("brandwisesale" + brandwisesale);
726
 
733
 
727
		Map<Integer, Double> accesoriesmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(
734
		Map<Integer, Double> accesoriesmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(
728
				fofoId, curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false));
735
				fofoId, curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false));
729
		brandwiseSale.put("Accessories", accesoriesmtdsale.get(fofoId));
736
		brandwisesale.put("Accessories", accesoriesmtdsale.get(fofoId));
730
		
-
 
731
		Map<String, Double> activatedImeisWithSellingPriceMTD = fofoOrderRepository
737
		Map<String, Double> activatedImeisWithSellingPriceMTD = fofoOrderRepository
732
				.selectValueOfActivatedImeis(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId).stream()
738
				.selectValueOfActivatedImeis(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId).stream()
733
				.collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getSellingPrice()));
739
				.collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getSellingPrice()));
-
 
740
 
734
		Map<String, Double> activatedImeisWithSellingPriceLMTD = fofoOrderRepository
741
		Map<String, Double> activatedImeisWithSellingPriceLMTD = fofoOrderRepository
735
				.selectValueOfActivatedImeis(curDate.withDayOfMonth(1).minusMonths(1),
742
				.selectValueOfActivatedImeis(curDate.withDayOfMonth(1).minusMonths(1),
736
						curDate.with(LocalTime.MAX).minusMonths(1), fofoId)
743
						curDate.with(LocalTime.MAX).minusMonths(1), fofoId)
737
				.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getSellingPrice()));
744
				.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getSellingPrice()));
738
 
745
 
Line 746... Line 753...
746
		lmtdBrandWiseSale.put("Accessories", accesorieslmtdsale.get(fofoId));
753
		lmtdBrandWiseSale.put("Accessories", accesorieslmtdsale.get(fofoId));
747
 
754
 
748
		ChartModel cm = new ChartModel();
755
		ChartModel cm = new ChartModel();
749
 
756
 
750
		HashSet<String> labels = new HashSet<String>();
757
		HashSet<String> labels = new HashSet<String>();
751
		labels.addAll(brandwiseSale.keySet());
758
		labels.addAll(brandwisesale.keySet());
752
		labels.addAll(lmtdBrandWiseSale.keySet());
759
		labels.addAll(lmtdBrandWiseSale.keySet());
753
 
760
 
754
		List<String> labelList = new ArrayList<>(labels);
761
		List<String> labelList = new ArrayList<>(labels);
755
 
762
 
756
		List<Double> mtdActivatedImeisValues = new ArrayList<>();
763
		List<Double> mtdActivatedImeisValues = new ArrayList<>();
Line 764... Line 771...
764
			mtdActivatedImeisValues.add(activatedImeisWithSellingPriceMTD.get(label) == null ? 0
771
			mtdActivatedImeisValues.add(activatedImeisWithSellingPriceMTD.get(label) == null ? 0
765
					: activatedImeisWithSellingPriceMTD.get(label));
772
					: activatedImeisWithSellingPriceMTD.get(label));
766
			lmtdActivatedImeisValues.add(activatedImeisWithSellingPriceLMTD.get(label) == null ? 0
773
			lmtdActivatedImeisValues.add(activatedImeisWithSellingPriceLMTD.get(label) == null ? 0
767
					: activatedImeisWithSellingPriceLMTD.get(label));
774
					: activatedImeisWithSellingPriceLMTD.get(label));
768
 
775
 
769
			mtdValues.add(brandwiseSale.get(label) == null ? 0 : brandwiseSale.get(label));
776
			mtdValues.add(brandwisesale.get(label) == null ? 0 : brandwisesale.get(label));
770
			if (brandwiseSale.get(label) != null) {
777
			if (brandwisesale.get(label) != null) {
771
				mtdUnActivatedImeisValues
778
				mtdUnActivatedImeisValues
772
						.add(brandwiseSale.get(label) - (activatedImeisWithSellingPriceMTD.get(label) == null ? 0
779
						.add(brandwisesale.get(label) - (activatedImeisWithSellingPriceMTD.get(label) == null ? 0
773
								: activatedImeisWithSellingPriceMTD.get(label)));
780
								: activatedImeisWithSellingPriceMTD.get(label)));
774
			} else {
781
			} else {
775
				mtdUnActivatedImeisValues.add(0.0);
782
				mtdUnActivatedImeisValues.add(0.0);
776
			}
783
			}
777
			if (lmtdBrandWiseSale.get(label) != null) {
784
			if (lmtdBrandWiseSale.get(label) != null) {
Line 787... Line 794...
787
		DatasetModel dsmtotal = new DatasetModel();
794
		DatasetModel dsmtotal = new DatasetModel();
788
		dsmtotal.setLabel("MTD");
795
		dsmtotal.setLabel("MTD");
789
		dsmtotal.setBackgroundColor("blue");
796
		dsmtotal.setBackgroundColor("blue");
790
		dsmtotal.setData(mtdValues);
797
		dsmtotal.setData(mtdValues);
791
		dsmtotal.setStack("stack0");
798
		dsmtotal.setStack("stack0");
-
 
799
		dsmtotal.setOrder(1);
792
 
800
 
793
		DatasetModel dsmUnactivated = new DatasetModel();
801
		DatasetModel dsmUnactivated = new DatasetModel();
794
		dsmUnactivated.setLabel("MTD Unactivated");
802
		dsmUnactivated.setLabel("MTD Unactivated");
795
		dsmUnactivated.setBackgroundColor("red");
803
		dsmUnactivated.setBackgroundColor("red");
796
		dsmUnactivated.setData(mtdUnActivatedImeisValues);
804
		dsmUnactivated.setData(mtdUnActivatedImeisValues);
797
		dsmUnactivated.setStack("stack0");
805
		dsmUnactivated.setStack("stack0");
-
 
806
		dsmUnactivated.setOrder(1);
798
 
807
 
799
		LOGGER.info("mtdValuesMoney" + mtdValues);
808
		LOGGER.info("mtdValuesMoney" + mtdValues);
800
 
809
 
801
		DatasetModel mtdActivatedImeis = new DatasetModel();
810
		DatasetModel mtdActivatedImeis = new DatasetModel();
802
		mtdActivatedImeis.setLabel("MTD Activation");
811
		mtdActivatedImeis.setLabel("MTD Activation");
803
		mtdActivatedImeis.setData(mtdActivatedImeisValues);
812
		mtdActivatedImeis.setData(mtdActivatedImeisValues);
804
		mtdActivatedImeis.setBackgroundColor("blue");
813
		mtdActivatedImeis.setBackgroundColor("#4169E1");
805
		mtdActivatedImeis.setStack("stack0");
814
		mtdActivatedImeis.setStack("stack0");
-
 
815
		mtdActivatedImeis.setOrder(1);
806
 
816
 
807
		DatasetModel lmtddsmtotal = new DatasetModel();
817
		DatasetModel lmtddsmtotal = new DatasetModel();
808
		lmtddsmtotal.setLabel("LMTD");
818
		lmtddsmtotal.setLabel("LMTD");
809
		lmtddsmtotal.setBackgroundColor("blue");
819
		lmtddsmtotal.setBackgroundColor("blue");
810
		lmtddsmtotal.setData(lmtdValues);
820
		lmtddsmtotal.setData(lmtdValues);
811
		lmtddsmtotal.setStack("stack1");
821
		lmtddsmtotal.setStack("stack1");
-
 
822
		lmtddsmtotal.setOrder(1);
812
 
823
 
813
		DatasetModel lmtdUnActivated = new DatasetModel();
824
		DatasetModel lmtdUnActivated = new DatasetModel();
814
		lmtdUnActivated.setLabel("LMTD Unactivation");
825
		lmtdUnActivated.setLabel("LMTD Unactivation");
815
		lmtdUnActivated.setBackgroundColor("red");
826
		lmtdUnActivated.setBackgroundColor("red");
816
		lmtdUnActivated.setData(lmtdUnActivatedImeisValues);
827
		lmtdUnActivated.setData(lmtdUnActivatedImeisValues);
817
		lmtdUnActivated.setStack("stack1");
828
		lmtdUnActivated.setStack("stack1");
-
 
829
		lmtdUnActivated.setOrder(1);
818
 
830
 
819
		DatasetModel LmtdActivatedImeis = new DatasetModel();
831
		DatasetModel LmtdActivatedImeis = new DatasetModel();
820
		LmtdActivatedImeis.setLabel("LMTD Activation");
832
		LmtdActivatedImeis.setLabel("LMTD Activation");
821
		LmtdActivatedImeis.setBackgroundColor("blue");
833
		LmtdActivatedImeis.setBackgroundColor("#6e7ecb");
822
		LmtdActivatedImeis.setData(lmtdActivatedImeisValues);
834
		LmtdActivatedImeis.setData(lmtdActivatedImeisValues);
823
		LmtdActivatedImeis.setStack("stack1");
835
		LmtdActivatedImeis.setStack("stack1");
-
 
836
		LmtdActivatedImeis.setOrder(1);
-
 
837
		
-
 
838
		
-
 
839
		DatasetModel linemtdChart = new DatasetModel();
-
 
840
		linemtdChart.setLabel("MTD");
-
 
841
		linemtdChart.setBackgroundColor("#DCDCDC");
-
 
842
		linemtdChart.setData(mtdValues);
-
 
843
		linemtdChart.setType("line");
-
 
844
		linemtdChart.setOrder(2);
-
 
845
	
-
 
846
		DatasetModel lineLmtdChart = new DatasetModel();
-
 
847
		lineLmtdChart.setLabel("LMTD");
-
 
848
		lineLmtdChart.setBackgroundColor("#DCDCDC");
-
 
849
		lineLmtdChart.setData(lmtdValues);
-
 
850
		lineLmtdChart.setType("line");
-
 
851
		lineLmtdChart.setOrder(2);
-
 
852
	
824
 
853
 
825
		List<DatasetModel> datasets = new ArrayList<>();
854
		List<DatasetModel> datasets = new ArrayList<>();
826
 
855
 
827
		datasets.add(dsmUnactivated);
856
		datasets.add(dsmUnactivated);
828
		datasets.add(mtdActivatedImeis);
857
		datasets.add(mtdActivatedImeis);
829
 
858
 
830
		datasets.add(lmtdUnActivated);
859
		datasets.add(lmtdUnActivated);
831
		datasets.add(LmtdActivatedImeis);
860
		datasets.add(LmtdActivatedImeis);
-
 
861
		datasets.add(linemtdChart);
-
 
862
		datasets.add(lineLmtdChart);
832
 
863
 
833
		DataModel dm = new DataModel();
864
		DataModel dm = new DataModel();
834
		dm.setDatasets(datasets);
865
		dm.setDatasets(datasets);
835
		dm.setLabels(labels);
866
		dm.setLabels(labels);
836
 
867