Subversion Repositories SmartDukaan

Rev

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

Rev 27882 Rev 27884
Line 48... Line 48...
48
import com.spice.profitmandi.common.enumuration.ContentType;
48
import com.spice.profitmandi.common.enumuration.ContentType;
49
import com.spice.profitmandi.common.enumuration.MessageType;
49
import com.spice.profitmandi.common.enumuration.MessageType;
50
import com.spice.profitmandi.common.enumuration.ReporticoProject;
50
import com.spice.profitmandi.common.enumuration.ReporticoProject;
51
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
51
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
52
import com.spice.profitmandi.common.model.ActivateItemModel;
52
import com.spice.profitmandi.common.model.ActivateItemModel;
-
 
53
import com.spice.profitmandi.common.model.Axis;
53
import com.spice.profitmandi.common.model.BrandStockPrice;
54
import com.spice.profitmandi.common.model.BrandStockPrice;
-
 
55
import com.spice.profitmandi.common.model.ChartInvestmentModel;
54
import com.spice.profitmandi.common.model.ChartModel;
56
import com.spice.profitmandi.common.model.ChartModel;
55
import com.spice.profitmandi.common.model.CustomRetailer;
57
import com.spice.profitmandi.common.model.CustomRetailer;
-
 
58
import com.spice.profitmandi.common.model.Data;
-
 
59
import com.spice.profitmandi.common.model.DataInvestmentModel;
56
import com.spice.profitmandi.common.model.DataModel;
60
import com.spice.profitmandi.common.model.DataModel;
57
import com.spice.profitmandi.common.model.DatasetModel;
61
import com.spice.profitmandi.common.model.DatasetModel;
-
 
62
import com.spice.profitmandi.common.model.Legend;
58
import com.spice.profitmandi.common.model.LegendModel;
63
import com.spice.profitmandi.common.model.LegendModel;
59
import com.spice.profitmandi.common.model.Notification;
64
import com.spice.profitmandi.common.model.Notification;
-
 
65
import com.spice.profitmandi.common.model.OptionModel;
60
import com.spice.profitmandi.common.model.OptionsModel;
66
import com.spice.profitmandi.common.model.OptionsModel;
-
 
67
import com.spice.profitmandi.common.model.PieLables;
61
import com.spice.profitmandi.common.model.ProfitMandiConstants;
68
import com.spice.profitmandi.common.model.ProfitMandiConstants;
-
 
69
import com.spice.profitmandi.common.model.ScalesModel;
62
import com.spice.profitmandi.common.model.TitleModel;
70
import com.spice.profitmandi.common.model.TitleModel;
63
import com.spice.profitmandi.common.web.util.ResponseSender;
71
import com.spice.profitmandi.common.web.util.ResponseSender;
64
import com.spice.profitmandi.dao.Interface.Campaign;
72
import com.spice.profitmandi.dao.Interface.Campaign;
65
import com.spice.profitmandi.dao.entity.auth.AuthUser;
73
import com.spice.profitmandi.dao.entity.auth.AuthUser;
66
import com.spice.profitmandi.dao.entity.auth.Menu;
74
import com.spice.profitmandi.dao.entity.auth.Menu;
Line 326... Line 334...
326
			model.addAttribute("fofoStore", customRetailer);
334
			model.addAttribute("fofoStore", customRetailer);
327
			model.addAttribute("partnerType", partnerType);
335
			model.addAttribute("partnerType", partnerType);
328
			model.addAttribute("hasGift", hasGift(fofoId));
336
			model.addAttribute("hasGift", hasGift(fofoId));
329
			model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
337
			model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
330
 
338
 
331
			// model.addAttribute("brandStockPrices", this.getBrandStockPrices(fofoId));
339
			model.addAttribute("brandStockPrices", this.getBrandStockPrices(fofoId));
332
			model.addAttribute("salesMap", this.getSales(fofoId));
340
			model.addAttribute("salesMap", this.getSales(fofoId));
333
			model.addAttribute("activatedImeis", inventoryItemRepository.selectCountByActivatedNotSold(fofoId));
341
			model.addAttribute("activatedImeis", inventoryItemRepository.selectCountByActivatedNotSold(fofoId));
334
			// this.setInvestments
342
			// this.setInvestments
335
			//
343
			//
336
			model.addAttribute("investments", this.getInvestments(fofoId));
344
			model.addAttribute("investments", this.getInvestments(fofoId));
Line 610... Line 618...
610
		}
618
		}
611
		model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
619
		model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
612
 
620
 
613
		model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
621
		model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
614
		model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
622
		model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
615
		/*if (loginDetails.isReadOnly()) {
623
		/*
616
			return "dashboard-readonly";
624
		 * if (loginDetails.isReadOnly()) { return "dashboard-readonly"; } else { }
617
		} else {
-
 
618
		}*/
625
		 */
619
		return "dashboard1";
626
		return "dashboard1";
620
	}
627
	}
621
 
628
 
-
 
629
	@RequestMapping(value = "/investmentDetails", method = RequestMethod.GET)
-
 
630
	public String getInvestmentDetails(HttpServletRequest request, Model model) throws Exception {
-
 
631
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
632
		int fofoId = loginDetails.getFofoId();
-
 
633
		ChartInvestmentModel cm = this.getInvestmentChart(fofoId);
-
 
634
		model.addAttribute("chartPieMap", gson.toJson(cm));
-
 
635
 
-
 
636
		LOGGER.info("InvestmentChart" + gson.toJson(cm));
-
 
637
		LOGGER.info("InvestmentChart" + cm);
-
 
638
		return "investmentdetails";
-
 
639
	}
-
 
640
 
-
 
641
	private ChartInvestmentModel getInvestmentChart(int fofoId) throws ProfitMandiBusinessException {
-
 
642
		PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 0);
-
 
643
		Map<String, Float> investmentWalletAmount = new HashMap<>();
-
 
644
		investmentWalletAmount.put("Wallet", investment.getWalletAmount());
-
 
645
 
-
 
646
		investmentWalletAmount.put("InStock", investment.getInStockAmount());
-
 
647
		investmentWalletAmount.put("Unbilled", investment.getUnbilledAmount());
-
 
648
		investmentWalletAmount.put("GrnPending", investment.getGrnPendingAmount());
-
 
649
		investmentWalletAmount.put("ReturnInTransit", investment.getReturnInTransitAmount());
-
 
650
 
-
 
651
		ChartInvestmentModel cm = new ChartInvestmentModel();
-
 
652
 
-
 
653
		HashSet<String> labels = new HashSet<String>();
-
 
654
		labels.addAll(investmentWalletAmount.keySet());
-
 
655
 
-
 
656
		List<String> labelList = new ArrayList<>(labels);
-
 
657
		List<String> backgroundColor = new ArrayList<>();
-
 
658
 
-
 
659
		List<Float> values = new ArrayList<>();
-
 
660
		for (String label : labelList) {
-
 
661
			values.add(investmentWalletAmount.get(label));
-
 
662
			if (label.equals("Wallet")) {
-
 
663
				backgroundColor.add("pink");
-
 
664
			}
-
 
665
 
-
 
666
			if (label.equals("InStock")) {
-
 
667
				backgroundColor.add("limegreen");
-
 
668
			}
-
 
669
			if (label.equals("Unbilled")) {
-
 
670
				backgroundColor.add("red");
-
 
671
			}
-
 
672
 
-
 
673
			if (label.equals("ReturnInTransit")) {
-
 
674
				backgroundColor.add("orange");
-
 
675
			}
-
 
676
			if (label.equals("GrnPending")) {
-
 
677
				backgroundColor.add("yellow");
-
 
678
			}
-
 
679
 
-
 
680
		}
-
 
681
 
-
 
682
		Data data = new Data();
-
 
683
		data.setData(values);
-
 
684
		data.setBackgroundColor(backgroundColor);
-
 
685
		data.setLabel("DataSet 1");
-
 
686
 
-
 
687
		PieLables label = new PieLables();
-
 
688
		label.setFontColor("White");
-
 
689
		label.setFontSize(15);
-
 
690
 
-
 
691
		Legend legend = new Legend();
-
 
692
		legend.setLabels(label);
-
 
693
		legend.setPosition("left");
-
 
694
 
-
 
695
		List<Data> dataList = new ArrayList<>();
-
 
696
		dataList.add(data);
-
 
697
 
-
 
698
		DataInvestmentModel datasets = new DataInvestmentModel();
-
 
699
		datasets.setDatasets(dataList);
-
 
700
		datasets.setLabels(labels);
-
 
701
 
-
 
702
		OptionModel om = new OptionModel();
-
 
703
		om.setLegend(legend);
-
 
704
		cm.setType("pie");
-
 
705
		cm.setData(datasets);
-
 
706
		cm.setOptions(om);
-
 
707
 
-
 
708
		return cm;
-
 
709
	}
-
 
710
 
622
	private ChartModel getBrandChart(int fofoId) {
711
	private ChartModel getBrandChart(int fofoId) {
623
 
712
 
624
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
713
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
625
 
714
 
626
		LOGGER.info("cur Date" + curDate.withDayOfMonth(1));
715
		LOGGER.info("cur Date" + curDate.withDayOfMonth(1));
Line 628... Line 717...
628
		LOGGER.info("curDateYear" + curDate.with(LocalTime.MAX));
717
		LOGGER.info("curDateYear" + curDate.with(LocalTime.MAX));
629
 
718
 
630
		Map<String, Double> brandwisesale = fofoOrderItemRepository
719
		Map<String, Double> brandwisesale = fofoOrderItemRepository
631
				.selectSumAmountGroupByBrand(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId);
720
				.selectSumAmountGroupByBrand(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId);
632
 
721
 
-
 
722
		LOGGER.info("brandwisesale" + brandwisesale);
-
 
723
 
633
		Map<Integer, Double> accesoriesmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(
724
		Map<Integer, Double> accesoriesmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(
634
				fofoId, curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false));
725
				fofoId, curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), Optional.of(false));
635
 
-
 
636
		LOGGER.info("accesoriesmtdsale" + accesoriesmtdsale);
726
		brandwisesale.put("Accessories", accesoriesmtdsale.get(fofoId));
-
 
727
		Map<String, Double> activatedImeisWithSellingPriceMTD = fofoOrderRepository
-
 
728
				.selectValueOfActivatedImeis(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId).stream()
-
 
729
				.collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getSellingPrice()));
637
 
730
 
-
 
731
		Map<String, Double> activatedImeisWithSellingPriceLMTD = fofoOrderRepository
-
 
732
				.selectValueOfActivatedImeis(curDate.withDayOfMonth(1).minusMonths(1),
638
		LOGGER.info("brandwisesale" + brandwisesale);
733
						curDate.with(LocalTime.MAX).minusMonths(1), fofoId)
-
 
734
				.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getSellingPrice()));
639
 
735
 
640
		Map<String, Double> lmtdBrandWiseSale = fofoOrderItemRepository.selectSumAmountGroupByBrand(
736
		Map<String, Double> lmtdBrandWiseSale = fofoOrderItemRepository.selectSumAmountGroupByBrand(
641
				curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), fofoId);
737
				curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), fofoId);
642
 
738
 
643
		Map<Integer, Double> accesorieslmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(
739
		Map<Integer, Double> accesorieslmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(
644
				fofoId, curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1),
740
				fofoId, curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1),
645
				Optional.of(false));
741
				Optional.of(false));
-
 
742
 
646
		LOGGER.info("accesorieslmtdsale" + accesorieslmtdsale);
743
		lmtdBrandWiseSale.put("Accessories", accesorieslmtdsale.get(fofoId));
-
 
744
 
647
		ChartModel cm = new ChartModel();
745
		ChartModel cm = new ChartModel();
648
 
746
 
649
		List<String> labels = new ArrayList<>();
747
		HashSet<String> labels = new HashSet<String>();
650
		labels.addAll(brandwisesale.keySet());
748
		labels.addAll(brandwisesale.keySet());
651
		labels.addAll(lmtdBrandWiseSale.keySet());
749
		labels.addAll(lmtdBrandWiseSale.keySet());
652
		labels.add("Accessories");
-
 
653
		List<Double> values = new ArrayList<>();
-
 
654
		values.addAll(brandwisesale.values());
-
 
655
		values.addAll(accesoriesmtdsale.values().size() > 0 ? accesoriesmtdsale.values() : Arrays.asList(0d));
-
 
656
 
750
 
-
 
751
		List<String> labelList = new ArrayList<>(labels);
-
 
752
 
-
 
753
		List<Double> mtdActivatedImeisValues = new ArrayList<>();
-
 
754
 
-
 
755
		List<Double> mtdValues = new ArrayList<>();
-
 
756
		List<Double> lmtdUnActivatedImeisValues = new ArrayList<>();
-
 
757
		List<Double> lmtdActivatedImeisValues = new ArrayList<>();
-
 
758
		List<Double> mtdUnActivatedImeisValues = new ArrayList<>();
657
		List<Double> lmtdValues = new ArrayList<>();
759
		List<Double> lmtdValues = new ArrayList<>();
-
 
760
		for (String label : labelList) {
-
 
761
			mtdActivatedImeisValues.add(activatedImeisWithSellingPriceMTD.get(label) == null ? 0
-
 
762
					: activatedImeisWithSellingPriceMTD.get(label));
-
 
763
			lmtdActivatedImeisValues.add(activatedImeisWithSellingPriceLMTD.get(label) == null ? 0
658
		lmtdValues.addAll(lmtdBrandWiseSale.values());
764
					: activatedImeisWithSellingPriceLMTD.get(label));
-
 
765
 
659
		lmtdValues.addAll(accesorieslmtdsale.values().size() > 0 ? accesorieslmtdsale.values() : Arrays.asList(0d));
766
			mtdValues.add(brandwisesale.get(label) == null ? 0 : brandwisesale.get(label));
-
 
767
			if (brandwisesale.get(label) != null) {
-
 
768
				mtdUnActivatedImeisValues
-
 
769
						.add(brandwisesale.get(label) - (activatedImeisWithSellingPriceMTD.get(label) == null ? 0
-
 
770
								: activatedImeisWithSellingPriceMTD.get(label)));
-
 
771
			} else {
-
 
772
				mtdUnActivatedImeisValues.add(0.0);
-
 
773
			}
-
 
774
			if (lmtdBrandWiseSale.get(label) != null) {
-
 
775
				lmtdUnActivatedImeisValues
-
 
776
						.add(lmtdBrandWiseSale.get(label) - (activatedImeisWithSellingPriceLMTD.get(label) == null ? 0
-
 
777
								: activatedImeisWithSellingPriceLMTD.get(label)));
-
 
778
			} else {
-
 
779
				lmtdUnActivatedImeisValues.add(0.0);
-
 
780
			}
660
 
781
 
-
 
782
			lmtdValues.add(lmtdBrandWiseSale.get(label) == null ? 0 : lmtdBrandWiseSale.get(label));
-
 
783
		}
661
		DatasetModel dsm = new DatasetModel();
784
		DatasetModel dsmtotal = new DatasetModel();
662
		dsm.setLabel("MTD");
785
		dsmtotal.setLabel("MTD");
663
		dsm.setBackgroundColor("#3e95cd");
786
		dsmtotal.setBackgroundColor("blue");
664
		dsm.setData(values);
787
		dsmtotal.setData(mtdValues);
-
 
788
		dsmtotal.setStack("stack0");
-
 
789
 
-
 
790
		DatasetModel dsmUnactivated = new DatasetModel();
-
 
791
		dsmUnactivated.setLabel("MTD Unactivated");
-
 
792
		dsmUnactivated.setBackgroundColor("red");
-
 
793
		dsmUnactivated.setData(mtdUnActivatedImeisValues);
-
 
794
		dsmUnactivated.setStack("stack0");
-
 
795
 
-
 
796
		LOGGER.info("mtdValuesMoney" + mtdValues);
-
 
797
 
-
 
798
		DatasetModel mtdActivatedImeis = new DatasetModel();
-
 
799
		mtdActivatedImeis.setLabel("MTD Activation");
-
 
800
		mtdActivatedImeis.setData(mtdActivatedImeisValues);
-
 
801
		mtdActivatedImeis.setBackgroundColor("blue");
-
 
802
		mtdActivatedImeis.setStack("stack0");
665
 
803
 
666
		DatasetModel lmtddsm = new DatasetModel();
804
		DatasetModel lmtddsmtotal = new DatasetModel();
667
		lmtddsm.setLabel("LMTD");
805
		lmtddsmtotal.setLabel("LMTD");
668
		lmtddsm.setBackgroundColor("#8e5ea2");
806
		lmtddsmtotal.setBackgroundColor("blue");
669
		lmtddsm.setData(lmtdValues);
807
		lmtddsmtotal.setData(lmtdValues);
-
 
808
		lmtddsmtotal.setStack("stack1");
-
 
809
 
-
 
810
		DatasetModel lmtdUnActivated = new DatasetModel();
-
 
811
		lmtdUnActivated.setLabel("LMTD Unactivation");
-
 
812
		lmtdUnActivated.setBackgroundColor("red");
-
 
813
		lmtdUnActivated.setData(lmtdUnActivatedImeisValues);
-
 
814
		lmtdUnActivated.setStack("stack1");
-
 
815
 
-
 
816
		DatasetModel LmtdActivatedImeis = new DatasetModel();
-
 
817
		LmtdActivatedImeis.setLabel("LMTD Activation");
-
 
818
		LmtdActivatedImeis.setBackgroundColor("blue");
-
 
819
		LmtdActivatedImeis.setData(lmtdActivatedImeisValues);
-
 
820
		LmtdActivatedImeis.setStack("stack1");
670
 
821
 
671
		List<DatasetModel> datasets = new ArrayList<>();
822
		List<DatasetModel> datasets = new ArrayList<>();
-
 
823
 
672
		datasets.add(dsm);
824
		datasets.add(dsmUnactivated);
-
 
825
		datasets.add(mtdActivatedImeis);
-
 
826
 
673
		datasets.add(lmtddsm);
827
		datasets.add(lmtdUnActivated);
-
 
828
		datasets.add(LmtdActivatedImeis);
674
 
829
 
675
		DataModel dm = new DataModel();
830
		DataModel dm = new DataModel();
676
		dm.setDatasets(datasets);
831
		dm.setDatasets(datasets);
677
		dm.setLabels(labels);
832
		dm.setLabels(labels);
678
 
833
 
Line 681... Line 836...
681
 
836
 
682
		TitleModel tm = new TitleModel();
837
		TitleModel tm = new TitleModel();
683
		tm.setText("Brand Wise Sales");
838
		tm.setText("Brand Wise Sales");
684
		tm.setDisplay(true);
839
		tm.setDisplay(true);
685
 
840
 
-
 
841
		List<Axis> xAxes = new ArrayList<>();
-
 
842
		Axis xAxis = new Axis();
-
 
843
		xAxis.setStacked(true);
-
 
844
		xAxes.add(xAxis);
-
 
845
 
-
 
846
		List<Axis> yAxes = new ArrayList<>();
-
 
847
		Axis yAxis = new Axis();
-
 
848
		yAxis.setStacked(true);
-
 
849
		yAxes.add(yAxis);
-
 
850
 
-
 
851
		ScalesModel sm = new ScalesModel();
-
 
852
		sm.setxAxes(xAxes);
-
 
853
		sm.setyAxes(yAxes);
-
 
854
 
686
		OptionsModel om = new OptionsModel();
855
		OptionsModel om = new OptionsModel();
687
		om.setLegend(lm);
856
		om.setLegend(lm);
688
		om.setTitle(tm);
857
		om.setTitle(tm);
-
 
858
		om.setScales(sm);
689
 
859
 
690
		cm.setType("bar");
860
		cm.setType("bar");
691
		cm.setData(dm);
861
		cm.setData(dm);
692
		cm.setOptions(om);
862
		cm.setOptions(om);
693
 
863
 
-
 
864
		LOGGER.info("cm" + cm);
-
 
865
 
694
		return cm;
866
		return cm;
695
 
867
 
696
	}
868
	}
697
 
869
 
698
	private String adminPanel(int fofoId, String email, Model model) throws Exception {
870
	private String adminPanel(int fofoId, String email, Model model) throws Exception {