Subversion Repositories SmartDukaan

Rev

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

Rev 30017 Rev 30024
Line 1718... Line 1718...
1718
			}
1718
			}
1719
		}
1719
		}
1720
 
1720
 
1721
		Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
1721
		Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
1722
 
1722
 
1723
		Map<Integer, Map<String, Double>> inStockBrandModel = new HashMap<>();
1723
		Map<Integer, Map<String, Double>> fofoIdBrandAmountMap = new HashMap<>();
1724
		Map<Integer, Map<String, Double>> pendingIndent = new HashMap<>();
-
 
1725
		Map<Integer, Map<String, Double>> grnPendingOrders = new HashMap<>();
-
 
1726
 
1724
 
1727
		Map<Integer, InStockAccessoriesTvFofoIdModel> inStockAccessTv = new HashMap<>();
1725
		Map<Integer, InStockAccessoriesTvFofoIdModel> inStockAccessTv = new HashMap<>();
1728
		Map<Integer, InStockAccessoriesTvFofoIdModel> pendingIndentAccessTv = new HashMap<>();
1726
		Map<Integer, InStockAccessoriesTvFofoIdModel> pendingIndentAccessTv = new HashMap<>();
1729
		Map<Integer, InStockAccessoriesTvFofoIdModel> grnPendingAccessTvOrders = new HashMap<>();
1727
		Map<Integer, InStockAccessoriesTvFofoIdModel> grnPendingAccessTvOrders = new HashMap<>();
1730
 
1728
 
Line 1737... Line 1735...
1737
			Map<Integer, FofoReportingModel> partnerSalesHeadersMap = csService.getPartnerIdSalesHeaders();
1735
			Map<Integer, FofoReportingModel> partnerSalesHeadersMap = csService.getPartnerIdSalesHeaders();
1738
 
1736
 
1739
			model.addAttribute("partnerSalesHeadersMap", partnerSalesHeadersMap);
1737
			model.addAttribute("partnerSalesHeadersMap", partnerSalesHeadersMap);
1740
			customRetailers = retailerService.getFofoRetailers(fofoIdList);
1738
			customRetailers = retailerService.getFofoRetailers(fofoIdList);
1741
 
1739
 
1742
			for (Entry<Integer, CustomRetailer> customRetailer : customRetailers.entrySet()) {
1740
			Map<Integer, Map<String, Double>> inStockBrandModel = new HashMap<>();
1743
				PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(customRetailer.getKey(),
-
 
1744
						LocalDate.now());
-
 
1745
				fofoIdPartnerTypeMap.put(customRetailer.getKey(), partnerType);
1741
			Map<Integer, Map<String, Double>> pendingIndent = new HashMap<>();
1746
			}
-
 
1747
 
-
 
1748
			List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
-
 
1749
					.selectAll(new ArrayList<>(fofoIdList), LocalDate.now().minusDays(1));
-
 
1750
			if (!partnerDailyInvestments.isEmpty()) {
-
 
1751
				partnerDailyInvestmentMap = partnerDailyInvestments.stream()
1742
			Map<Integer, Map<String, Double>> grnPendingOrders = new HashMap<>();
1752
						.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
-
 
1753
			}
-
 
1754
 
1743
 
-
 
1744
			// mobile
1755
			inStockBrandModel = currentInventorySnapshotRepository.selectSumInStockMobiletabletGroupByBrand(fofoIdList)
1745
			inStockBrandModel = currentInventorySnapshotRepository.selectSumInStockMobiletabletGroupByBrand(fofoIdList)
1756
					.stream()
1746
					.stream()
1757
					.collect(Collectors.groupingBy(InStockBrandFofoIdModel::getFofoId,
1747
					.collect(Collectors.groupingBy(InStockBrandFofoIdModel::getFofoId,
1758
							Collectors.groupingBy(InStockBrandFofoIdModel::getBrand,
1748
							Collectors.groupingBy(InStockBrandFofoIdModel::getBrand,
1759
									Collectors.summingDouble(InStockBrandFofoIdModel::getAmount))));
1749
									Collectors.summingDouble(InStockBrandFofoIdModel::getAmount))));
1760
 
1750
 
1761
			pendingIndent = transactionService.getInTransitOrders(fofoIdList).stream()
1751
			pendingIndent = transactionService.getInTransitOrders(fofoIdList).stream()
1762
					.filter(x -> x.getLineItem().getItem().getCategoryId() == 10006)
1752
					.filter(x -> x.getLineItem().getItem().getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID)
1763
					.collect(Collectors.groupingBy(x -> x.getRetailerId(),
1753
					.collect(Collectors.groupingBy(x -> x.getRetailerId(),
1764
							Collectors.groupingBy(y -> y.getLineItem().getBrand(),
1754
							Collectors.groupingBy(y -> y.getLineItem().getBrand(),
1765
									Collectors.summingDouble(y -> (double) y.getTotalAmount()))));
1755
									Collectors.summingDouble(y -> (double) y.getTotalAmount()))));
1766
 
1756
 
1767
			grnPendingOrders = orderRepository.selectPendingGrnOrders(fofoIdList).stream()
1757
			grnPendingOrders = orderRepository.selectPendingGrnOrders(fofoIdList).stream()
1768
					.filter(x -> x.getLineItem().getItem().getCategoryId() == 10006)
1758
					.filter(x -> x.getLineItem().getItem().getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID)
1769
					.collect(Collectors.groupingBy(x -> x.getRetailerId(),
1759
					.collect(Collectors.groupingBy(x -> x.getRetailerId(),
1770
							Collectors.groupingBy(y -> y.getLineItem().getBrand(),
1760
							Collectors.groupingBy(y -> y.getLineItem().getBrand(),
1771
									Collectors.summingDouble(y -> (double) y.getTotalAmount()))));
1761
									Collectors.summingDouble(y -> (double) y.getTotalAmount()))));
1772
 
1762
 
-
 
1763
			// accessories
1773
			inStockAccessTv = currentInventorySnapshotRepository.selectSumInStockAccessoriesAndTv(fofoIdList).stream()
1764
			inStockAccessTv = currentInventorySnapshotRepository.selectSumInStockAccessoriesAndTv(fofoIdList).stream()
1774
					.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
1765
					.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
1775
 
1766
 
1776
			pendingIndentAccessTv = orderRepository.selectAllPendingIndentAccessoriesTvGroupByFofoId(fofoIdList)
1767
			pendingIndentAccessTv = orderRepository.selectAllPendingIndentAccessoriesTvGroupByFofoId(fofoIdList)
1777
					.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
1768
					.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
1778
 
1769
 
1779
			grnPendingAccessTvOrders = orderRepository.selectAllGrnPendingAccessoriesTvGroupByFofoId(fofoIdList)
1770
			grnPendingAccessTvOrders = orderRepository.selectAllGrnPendingAccessoriesTvGroupByFofoId(fofoIdList)
1780
					.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
1771
					.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
1781
 
1772
 
-
 
1773
			for (Entry<Integer, CustomRetailer> customRetailer : customRetailers.entrySet()) {
-
 
1774
				PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(customRetailer.getKey(),
-
 
1775
						LocalDate.now());
-
 
1776
				fofoIdPartnerTypeMap.put(customRetailer.getKey(), partnerType);
-
 
1777
 
-
 
1778
				Map<String, Double> stockBrand = inStockBrandModel.get(customRetailer.getKey());
-
 
1779
				Map<String, Double> pendingIndentBrand = pendingIndent.get(customRetailer.getKey());
-
 
1780
				Map<String, Double> grnBrand = grnPendingOrders.get(customRetailer.getKey());
-
 
1781
				double totalAmount = 0;
-
 
1782
 
-
 
1783
				Map<String, Double> brandAmountMap = new HashMap<>();
-
 
1784
				for (String brand : brands) {
-
 
1785
 
-
 
1786
					double stockValue = 0;
-
 
1787
					double pendingValue = 0;
-
 
1788
					double grnValue = 0;
-
 
1789
					if (stockBrand != null) {
-
 
1790
 
-
 
1791
						if (stockBrand.get(brand) != null) {
-
 
1792
							stockValue = stockBrand.get(brand);
-
 
1793
						}
-
 
1794
					}
-
 
1795
 
-
 
1796
					if (pendingIndentBrand != null) {
-
 
1797
						if (pendingIndentBrand.get(brand) != null) {
-
 
1798
							pendingValue = pendingIndentBrand.get(brand);
-
 
1799
						}
-
 
1800
					}
-
 
1801
 
-
 
1802
					if (grnBrand != null) {
-
 
1803
						if (grnBrand.get(brand) != null) {
-
 
1804
							grnValue = grnBrand.get(brand);
-
 
1805
						}
-
 
1806
					}
-
 
1807
 
-
 
1808
					totalAmount = stockValue + pendingValue + grnValue;
-
 
1809
 
-
 
1810
					brandAmountMap.put(brand, totalAmount);
-
 
1811
 
-
 
1812
				}
-
 
1813
 
-
 
1814
				fofoIdBrandAmountMap.put(customRetailer.getKey(), brandAmountMap);
-
 
1815
 
-
 
1816
			}
-
 
1817
 
-
 
1818
			List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
-
 
1819
					.selectAll(new ArrayList<>(fofoIdList), LocalDate.now().minusDays(1));
-
 
1820
			if (!partnerDailyInvestments.isEmpty()) {
-
 
1821
				partnerDailyInvestmentMap = partnerDailyInvestments.stream()
-
 
1822
						.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
-
 
1823
			}
-
 
1824
 
1782
		}
1825
		}
1783
 
1826
 
1784
		model.addAttribute("customRetailers", customRetailers);
1827
		model.addAttribute("customRetailers", customRetailers);
1785
 
1828
 
1786
		LOGGER.info("pendingIndent" + pendingIndent);
1829
		LOGGER.info("fofoIdBrandAmountMap" + fofoIdBrandAmountMap);
1787
 
1830
 
1788
		model.addAttribute("partnerDailyInvestmentMap", partnerDailyInvestmentMap);
1831
		model.addAttribute("partnerDailyInvestmentMap", partnerDailyInvestmentMap);
1789
 
1832
 
1790
		LOGGER.info("grnPendingOrders" + grnPendingOrders);
-
 
1791
 
-
 
1792
		model.addAttribute("brands", brands);
1833
		model.addAttribute("brands", brands);
1793
 
1834
 
1794
		model.addAttribute("brandAmountLimit", Brand_Amount_Limit);
1835
		model.addAttribute("brandAmountLimit", Brand_Amount_Limit);
1795
		model.addAttribute("inStockBrandModel", inStockBrandModel);
1836
		model.addAttribute("fofoIdBrandAmountMap", fofoIdBrandAmountMap);
1796
		model.addAttribute("pendingIndent", pendingIndent);
-
 
1797
		model.addAttribute("grnPendingOrders", grnPendingOrders);
-
 
1798
 
1837
 
1799
		model.addAttribute("inStockAccessTv", inStockAccessTv);
1838
		model.addAttribute("inStockAccessTv", inStockAccessTv);
1800
		model.addAttribute("pendingIndentAccessTv", pendingIndentAccessTv);
1839
		model.addAttribute("pendingIndentAccessTv", pendingIndentAccessTv);
1801
		model.addAttribute("grnPendingAccessTvOrders", grnPendingAccessTvOrders);
1840
		model.addAttribute("grnPendingAccessTvOrders", grnPendingAccessTvOrders);
1802
		model.addAttribute("fofoIdPartnerTypeMap", fofoIdPartnerTypeMap);
1841
		model.addAttribute("fofoIdPartnerTypeMap", fofoIdPartnerTypeMap);