| Line 1716... |
Line 1716... |
| 1716 |
Set<Integer> fofoIds = csService1.getAuthFofoIds(email, true);
|
1716 |
Set<Integer> fofoIds = csService1.getAuthFofoIds(email, true);
|
| 1717 |
|
1717 |
|
| 1718 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
|
1718 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
|
| 1719 |
|
1719 |
|
| 1720 |
Map<Integer, Map<String, Double>> fofoIdBrandAmountMap = new HashMap<>();
|
1720 |
Map<Integer, Map<String, Double>> fofoIdBrandAmountMap = new HashMap<>();
|
| - |
|
1721 |
Map<Integer, Map<String, Double>> fofoIdBrandQtyMap = new HashMap<>();
|
| 1721 |
|
1722 |
|
| 1722 |
Map<Integer, InStockAccessoriesTvFofoIdModel> inStockAccessTv = new HashMap<>();
|
1723 |
Map<Integer, InStockAccessoriesTvFofoIdModel> inStockAccessTv = new HashMap<>();
|
| 1723 |
Map<Integer, InStockAccessoriesTvFofoIdModel> pendingIndentAccessTv = new HashMap<>();
|
1724 |
Map<Integer, InStockAccessoriesTvFofoIdModel> pendingIndentAccessTv = new HashMap<>();
|
| 1724 |
Map<Integer, InStockAccessoriesTvFofoIdModel> grnPendingAccessTvOrders = new HashMap<>();
|
1725 |
Map<Integer, InStockAccessoriesTvFofoIdModel> grnPendingAccessTvOrders = new HashMap<>();
|
| 1725 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
1726 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| Line 1748... |
Line 1749... |
| 1748 |
|
1749 |
|
| 1749 |
model.addAttribute("partnerBrandLimitMap", partnerBrandLimitMap);
|
1750 |
model.addAttribute("partnerBrandLimitMap", partnerBrandLimitMap);
|
| 1750 |
customRetailers = fofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null)
|
1751 |
customRetailers = fofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null)
|
| 1751 |
.collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
1752 |
.collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 1752 |
Map<Integer, Map<String, Double>> inStockBrandModel;
|
1753 |
Map<Integer, Map<String, Double>> inStockBrandModel;
|
| - |
|
1754 |
Map<Integer, Map<String, Double>> inStockBrandModelQty;
|
| 1753 |
Map<Integer, Map<String, Double>> pendingIndent;
|
1755 |
Map<Integer, Map<String, Double>> pendingIndent;
|
| - |
|
1756 |
Map<Integer, Map<String, Double>> pendingIndentQty;
|
| 1754 |
Map<Integer, Map<String, Double>> grnPendingOrders;
|
1757 |
Map<Integer, Map<String, Double>> grnPendingOrders;
|
| - |
|
1758 |
Map<Integer, Map<String, Double>> grnPendingOrdersQty;
|
| 1755 |
|
1759 |
|
| 1756 |
// mobile
|
1760 |
// mobile
|
| 1757 |
inStockBrandModel = currentInventorySnapshotRepository.selectSumInStockMobiletabletGroupByBrand(fofoIdList)
|
1761 |
inStockBrandModel = currentInventorySnapshotRepository.selectSumInStockMobiletabletGroupByBrand(fofoIdList)
|
| 1758 |
.stream()
|
1762 |
.stream()
|
| 1759 |
.collect(Collectors.groupingBy(InStockBrandFofoIdModel::getFofoId,
|
1763 |
.collect(Collectors.groupingBy(InStockBrandFofoIdModel::getFofoId,
|
| 1760 |
Collectors.groupingBy(InStockBrandFofoIdModel::getBrand,
|
1764 |
Collectors.groupingBy(InStockBrandFofoIdModel::getBrand,
|
| 1761 |
Collectors.summingDouble(InStockBrandFofoIdModel::getAmount))));
|
1765 |
Collectors.summingDouble(InStockBrandFofoIdModel::getAmount))));
|
| 1762 |
|
1766 |
|
| - |
|
1767 |
inStockBrandModelQty = currentInventorySnapshotRepository.selectSumInStockMobiletabletGroupByBrand(fofoIdList)
|
| - |
|
1768 |
.stream()
|
| - |
|
1769 |
.collect(Collectors.groupingBy(InStockBrandFofoIdModel::getFofoId,
|
| - |
|
1770 |
Collectors.groupingBy(InStockBrandFofoIdModel::getBrand,
|
| - |
|
1771 |
Collectors.summingDouble(InStockBrandFofoIdModel::getQty))));
|
| - |
|
1772 |
|
| 1763 |
pendingIndent = transactionService.getInTransitOrders(fofoIdList).stream()
|
1773 |
pendingIndent = transactionService.getInTransitOrders(fofoIdList).stream()
|
| 1764 |
.filter(x -> x.getLineItem().getItem().getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID)
|
1774 |
.filter(x -> x.getLineItem().getItem().getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID)
|
| 1765 |
.collect(Collectors.groupingBy(x -> x.getRetailerId(),
|
1775 |
.collect(Collectors.groupingBy(x -> x.getRetailerId(),
|
| 1766 |
Collectors.groupingBy(y -> y.getLineItem().getBrand(),
|
1776 |
Collectors.groupingBy(y -> y.getLineItem().getBrand(),
|
| 1767 |
Collectors.summingDouble(y -> (double) y.getTotalAmount()))));
|
1777 |
Collectors.summingDouble(y -> (double) y.getTotalAmount()))));
|
| 1768 |
|
1778 |
|
| - |
|
1779 |
pendingIndentQty = transactionService.getInTransitOrders(fofoIdList).stream()
|
| - |
|
1780 |
.filter(x -> x.getLineItem().getItem().getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID)
|
| - |
|
1781 |
.collect(Collectors.groupingBy(x -> x.getRetailerId(),
|
| - |
|
1782 |
Collectors.groupingBy(y -> y.getLineItem().getBrand(),
|
| - |
|
1783 |
Collectors.summingDouble(y -> (double) y.getLineItem().getQuantity()))));
|
| - |
|
1784 |
|
| 1769 |
grnPendingOrders = orderRepository.selectPendingGrnOrders(fofoIdList).stream()
|
1785 |
grnPendingOrders = orderRepository.selectPendingGrnOrders(fofoIdList).stream()
|
| 1770 |
.filter(x -> x.getLineItem().getItem().getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID)
|
1786 |
.filter(x -> x.getLineItem().getItem().getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID)
|
| 1771 |
.collect(Collectors.groupingBy(x -> x.getRetailerId(),
|
1787 |
.collect(Collectors.groupingBy(x -> x.getRetailerId(),
|
| 1772 |
Collectors.groupingBy(y -> y.getLineItem().getBrand(),
|
1788 |
Collectors.groupingBy(y -> y.getLineItem().getBrand(),
|
| 1773 |
Collectors.summingDouble(y -> (double) y.getTotalAmount()))));
|
1789 |
Collectors.summingDouble(y -> (double) y.getTotalAmount()))));
|
| - |
|
1790 |
grnPendingOrdersQty = orderRepository.selectPendingGrnOrders(fofoIdList).stream()
|
| - |
|
1791 |
.filter(x -> x.getLineItem().getItem().getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID)
|
| - |
|
1792 |
.collect(Collectors.groupingBy(x -> x.getRetailerId(),
|
| - |
|
1793 |
Collectors.groupingBy(y -> y.getLineItem().getBrand(),
|
| - |
|
1794 |
Collectors.summingDouble(y -> (double) y.getLineItem().getQuantity()))));
|
| 1774 |
|
1795 |
|
| 1775 |
// accessories
|
1796 |
// accessories
|
| 1776 |
inStockAccessTv = currentInventorySnapshotRepository.selectSumInStockAccessoriesAndTv(fofoIdList).stream()
|
1797 |
inStockAccessTv = currentInventorySnapshotRepository.selectSumInStockAccessoriesAndTv(fofoIdList).stream()
|
| 1777 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
1798 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 1778 |
|
1799 |
|
| Line 1785... |
Line 1806... |
| 1785 |
// Bulk fetch partner types to avoid N+1 queries
|
1806 |
// Bulk fetch partner types to avoid N+1 queries
|
| 1786 |
fofoIdPartnerTypeMap = partnerTypeChangeService.getTypesForFofoIds(new ArrayList<>(customRetailers.keySet()), LocalDate.now());
|
1807 |
fofoIdPartnerTypeMap = partnerTypeChangeService.getTypesForFofoIds(new ArrayList<>(customRetailers.keySet()), LocalDate.now());
|
| 1787 |
|
1808 |
|
| 1788 |
for (Entry<Integer, CustomRetailer> customRetailer : customRetailers.entrySet()) {
|
1809 |
for (Entry<Integer, CustomRetailer> customRetailer : customRetailers.entrySet()) {
|
| 1789 |
Map<String, Double> stockBrand = inStockBrandModel.get(customRetailer.getKey());
|
1810 |
Map<String, Double> stockBrand = inStockBrandModel.get(customRetailer.getKey());
|
| - |
|
1811 |
Map<String, Double> stockBrandQty = inStockBrandModelQty.get(customRetailer.getKey());
|
| 1790 |
Map<String, Double> pendingIndentBrand = pendingIndent.get(customRetailer.getKey());
|
1812 |
Map<String, Double> pendingIndentBrand = pendingIndent.get(customRetailer.getKey());
|
| - |
|
1813 |
Map<String, Double> pendingIndentBrandQty = pendingIndentQty.get(customRetailer.getKey());
|
| 1791 |
Map<String, Double> grnBrand = grnPendingOrders.get(customRetailer.getKey());
|
1814 |
Map<String, Double> grnBrand = grnPendingOrders.get(customRetailer.getKey());
|
| - |
|
1815 |
Map<String, Double> grnBrandQty = grnPendingOrdersQty.get(customRetailer.getKey());
|
| 1792 |
double totalAmount = 0;
|
1816 |
double totalAmount = 0;
|
| - |
|
1817 |
double totalQty = 0;
|
| 1793 |
|
1818 |
|
| 1794 |
Map<String, Double> brandAmountMap = new HashMap<>();
|
1819 |
Map<String, Double> brandAmountMap = new HashMap<>();
|
| - |
|
1820 |
Map<String, Double> brandQtyMap = new HashMap<>();
|
| 1795 |
for (String brand : brands) {
|
1821 |
for (String brand : brands) {
|
| 1796 |
|
1822 |
|
| 1797 |
double stockValue = 0;
|
1823 |
double stockValue = 0;
|
| - |
|
1824 |
double stockQty = 0;
|
| 1798 |
double pendingValue = 0;
|
1825 |
double pendingValue = 0;
|
| - |
|
1826 |
double pendingQty = 0;
|
| 1799 |
double grnValue = 0;
|
1827 |
double grnValue = 0;
|
| - |
|
1828 |
double grnQty = 0;
|
| 1800 |
if (stockBrand != null) {
|
1829 |
if (stockBrand != null) {
|
| 1801 |
|
1830 |
|
| 1802 |
if (stockBrand.get(brand) != null) {
|
1831 |
if (stockBrand.get(brand) != null) {
|
| 1803 |
stockValue = stockBrand.get(brand);
|
1832 |
stockValue = stockBrand.get(brand);
|
| 1804 |
}
|
1833 |
}
|
| 1805 |
}
|
1834 |
}
|
| 1806 |
|
1835 |
|
| - |
|
1836 |
if (stockBrandQty != null) {
|
| - |
|
1837 |
|
| - |
|
1838 |
if (stockBrandQty.get(brand) != null) {
|
| - |
|
1839 |
stockQty = stockBrandQty.get(brand);
|
| - |
|
1840 |
}
|
| - |
|
1841 |
}
|
| - |
|
1842 |
|
| 1807 |
if (pendingIndentBrand != null) {
|
1843 |
if (pendingIndentBrand != null) {
|
| 1808 |
if (pendingIndentBrand.get(brand) != null) {
|
1844 |
if (pendingIndentBrand.get(brand) != null) {
|
| 1809 |
pendingValue = pendingIndentBrand.get(brand);
|
1845 |
pendingValue = pendingIndentBrand.get(brand);
|
| 1810 |
}
|
1846 |
}
|
| 1811 |
}
|
1847 |
}
|
| - |
|
1848 |
if (pendingIndentBrandQty != null) {
|
| - |
|
1849 |
if (pendingIndentBrandQty.get(brand) != null) {
|
| - |
|
1850 |
pendingQty = pendingIndentBrandQty.get(brand);
|
| - |
|
1851 |
}
|
| - |
|
1852 |
}
|
| 1812 |
|
1853 |
|
| 1813 |
if (grnBrand != null) {
|
1854 |
if (grnBrand != null) {
|
| 1814 |
if (grnBrand.get(brand) != null) {
|
1855 |
if (grnBrand.get(brand) != null) {
|
| 1815 |
grnValue = grnBrand.get(brand);
|
1856 |
grnValue = grnBrand.get(brand);
|
| 1816 |
}
|
1857 |
}
|
| 1817 |
}
|
1858 |
}
|
| 1818 |
|
1859 |
|
| - |
|
1860 |
if (grnBrandQty != null) {
|
| - |
|
1861 |
if (grnBrandQty.get(brand) != null) {
|
| - |
|
1862 |
grnQty = grnBrandQty.get(brand);
|
| - |
|
1863 |
}
|
| - |
|
1864 |
}
|
| - |
|
1865 |
|
| 1819 |
totalAmount = stockValue + pendingValue + grnValue;
|
1866 |
totalAmount = stockValue + pendingValue + grnValue;
|
| 1820 |
|
1867 |
|
| - |
|
1868 |
totalQty = stockQty + pendingQty + grnQty;
|
| - |
|
1869 |
|
| 1821 |
brandAmountMap.put(brand, totalAmount);
|
1870 |
brandAmountMap.put(brand, totalAmount);
|
| 1822 |
|
1871 |
|
| - |
|
1872 |
brandQtyMap.put(brand, totalQty);
|
| - |
|
1873 |
|
| 1823 |
}
|
1874 |
}
|
| 1824 |
|
1875 |
|
| 1825 |
fofoIdBrandAmountMap.put(customRetailer.getKey(), brandAmountMap);
|
1876 |
fofoIdBrandAmountMap.put(customRetailer.getKey(), brandAmountMap);
|
| - |
|
1877 |
fofoIdBrandQtyMap.put(customRetailer.getKey(), brandQtyMap);
|
| 1826 |
|
1878 |
|
| 1827 |
}
|
1879 |
}
|
| 1828 |
|
1880 |
|
| 1829 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
1881 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
| 1830 |
.selectAll(new ArrayList<>(fofoIdList), LocalDate.now().minusDays(1));
|
1882 |
.selectAll(new ArrayList<>(fofoIdList), LocalDate.now().minusDays(1));
|
| Line 1876... |
Line 1928... |
| 1876 |
|
1928 |
|
| 1877 |
model.addAttribute("brands", brands);
|
1929 |
model.addAttribute("brands", brands);
|
| 1878 |
|
1930 |
|
| 1879 |
model.addAttribute("brandAmountLimit", Brand_Amount_Limit);
|
1931 |
model.addAttribute("brandAmountLimit", Brand_Amount_Limit);
|
| 1880 |
model.addAttribute("fofoIdBrandAmountMap", fofoIdBrandAmountMap);
|
1932 |
model.addAttribute("fofoIdBrandAmountMap", fofoIdBrandAmountMap);
|
| - |
|
1933 |
model.addAttribute("fofoIdBrandQtyMap", fofoIdBrandQtyMap);
|
| 1881 |
|
1934 |
|
| 1882 |
model.addAttribute("inStockAccessTv", inStockAccessTv);
|
1935 |
model.addAttribute("inStockAccessTv", inStockAccessTv);
|
| 1883 |
model.addAttribute("pendingIndentAccessTv", pendingIndentAccessTv);
|
1936 |
model.addAttribute("pendingIndentAccessTv", pendingIndentAccessTv);
|
| 1884 |
model.addAttribute("grnPendingAccessTvOrders", grnPendingAccessTvOrders);
|
1937 |
model.addAttribute("grnPendingAccessTvOrders", grnPendingAccessTvOrders);
|
| 1885 |
model.addAttribute("fofoIdPartnerTypeMap", fofoIdPartnerTypeMap);
|
1938 |
model.addAttribute("fofoIdPartnerTypeMap", fofoIdPartnerTypeMap);
|