| Line 11... |
Line 11... |
| 11 |
import java.util.HashSet;
|
11 |
import java.util.HashSet;
|
| 12 |
import java.util.Iterator;
|
12 |
import java.util.Iterator;
|
| 13 |
import java.util.List;
|
13 |
import java.util.List;
|
| 14 |
import java.util.Map;
|
14 |
import java.util.Map;
|
| 15 |
import java.util.Map.Entry;
|
15 |
import java.util.Map.Entry;
|
| - |
|
16 |
import java.util.Optional;
|
| 16 |
import java.util.Set;
|
17 |
import java.util.Set;
|
| 17 |
import java.util.function.Function;
|
18 |
import java.util.function.Function;
|
| 18 |
import java.util.stream.Collectors;
|
19 |
import java.util.stream.Collectors;
|
| 19 |
|
20 |
|
| 20 |
import javax.servlet.http.HttpServletRequest;
|
21 |
import javax.servlet.http.HttpServletRequest;
|
| Line 42... |
Line 43... |
| 42 |
import com.mongodb.DBObject;
|
43 |
import com.mongodb.DBObject;
|
| 43 |
import com.spice.profitmandi.common.enumuration.CounterSize;
|
44 |
import com.spice.profitmandi.common.enumuration.CounterSize;
|
| 44 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
45 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 45 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
46 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 46 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
47 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
| 47 |
import com.spice.profitmandi.common.model.IntegerIdAggregateValue;
|
- |
|
| 48 |
import com.spice.profitmandi.common.model.CatalogListingModel;
|
48 |
import com.spice.profitmandi.common.model.CatalogListingModel;
|
| 49 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
49 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| - |
|
50 |
import com.spice.profitmandi.common.model.FocusedModelShortageModel;
|
| - |
|
51 |
import com.spice.profitmandi.common.model.IntegerIdAggregateValue;
|
| 50 |
import com.spice.profitmandi.common.model.PlannedModel;
|
52 |
import com.spice.profitmandi.common.model.PlannedModel;
|
| - |
|
53 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 51 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
54 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
| 52 |
import com.spice.profitmandi.common.model.StockAllocationModel;
|
55 |
import com.spice.profitmandi.common.model.StockAllocationModel;
|
| 53 |
import com.spice.profitmandi.common.model.SuggestedPoIdModel;
|
56 |
import com.spice.profitmandi.common.model.SuggestedPoIdModel;
|
| 54 |
import com.spice.profitmandi.common.model.SuggestedPoModel;
|
57 |
import com.spice.profitmandi.common.model.SuggestedPoModel;
|
| 55 |
import com.spice.profitmandi.common.util.FileUtil;
|
58 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 56 |
import com.spice.profitmandi.common.util.Utils;
|
59 |
import com.spice.profitmandi.common.util.Utils;
|
| 57 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
60 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
| 58 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
61 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| - |
|
62 |
import com.spice.profitmandi.dao.entity.catalog.Category;
|
| 59 |
import com.spice.profitmandi.dao.entity.catalog.FocusedModel;
|
63 |
import com.spice.profitmandi.dao.entity.catalog.FocusedModel;
|
| 60 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
64 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 61 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
65 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| - |
|
66 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 62 |
import com.spice.profitmandi.dao.entity.cs.Region;
|
67 |
import com.spice.profitmandi.dao.entity.cs.Region;
|
| 63 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
68 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 64 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
69 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 65 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
70 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 66 |
import com.spice.profitmandi.dao.entity.fofo.MonthlyPlanned;
|
71 |
import com.spice.profitmandi.dao.entity.fofo.MonthlyPlanned;
|
| - |
|
72 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| - |
|
73 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| 67 |
import com.spice.profitmandi.dao.entity.fofo.PlannedDetail;
|
74 |
import com.spice.profitmandi.dao.entity.fofo.PlannedDetail;
|
| 68 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
75 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
| 69 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
76 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
| 70 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
77 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
| - |
|
78 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
| 71 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
79 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 72 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
80 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 73 |
import com.spice.profitmandi.dao.entity.user.User;
|
81 |
import com.spice.profitmandi.dao.entity.user.User;
|
| 74 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
82 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| - |
|
83 |
import com.spice.profitmandi.dao.model.FofoReportingModel;
|
| - |
|
84 |
import com.spice.profitmandi.dao.model.InStockAccessoriesTvFofoIdModel;
|
| - |
|
85 |
import com.spice.profitmandi.dao.model.InStockBrandFofoIdModel;
|
| 75 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
86 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| - |
|
87 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
| 76 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
|
88 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
|
| 77 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
89 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 78 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
90 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 79 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
91 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 80 |
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
|
92 |
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
|
| - |
|
93 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 81 |
import com.spice.profitmandi.dao.repository.cs.RegionRepository;
|
94 |
import com.spice.profitmandi.dao.repository.cs.RegionRepository;
|
| 82 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
95 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 83 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
96 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 84 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
97 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 85 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
98 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 86 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
99 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 87 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
100 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 88 |
import com.spice.profitmandi.dao.repository.fofo.MonthlyPlannedRepository;
|
101 |
import com.spice.profitmandi.dao.repository.fofo.MonthlyPlannedRepository;
|
| - |
|
102 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 89 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
|
103 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
|
| - |
|
104 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 90 |
import com.spice.profitmandi.dao.repository.fofo.PlannedDetailRepository;
|
105 |
import com.spice.profitmandi.dao.repository.fofo.PlannedDetailRepository;
|
| 91 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
106 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| 92 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
107 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
| 93 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
108 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
| 94 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
|
109 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
|
| Line 108... |
Line 123... |
| 108 |
import com.spice.profitmandi.web.model.LoginDetails;
|
123 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 109 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
124 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 110 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
125 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 111 |
|
126 |
|
| 112 |
import in.shop2020.logistics.PickUpType;
|
127 |
import in.shop2020.logistics.PickUpType;
|
| - |
|
128 |
|
| 113 |
import in.shop2020.model.v1.order.LineItem;
|
129 |
import in.shop2020.model.v1.order.LineItem;
|
| 114 |
import in.shop2020.model.v1.order.OrderSource;
|
130 |
import in.shop2020.model.v1.order.OrderSource;
|
| 115 |
import in.shop2020.model.v1.order.OrderStatus;
|
131 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 116 |
import in.shop2020.model.v1.order.OrderType;
|
132 |
import in.shop2020.model.v1.order.OrderType;
|
| 117 |
import in.shop2020.model.v1.order.Transaction;
|
133 |
import in.shop2020.model.v1.order.Transaction;
|
| Line 237... |
Line 253... |
| 237 |
private SaholicInventoryCISRepository saholicInventoryCISRepository;
|
253 |
private SaholicInventoryCISRepository saholicInventoryCISRepository;
|
| 238 |
|
254 |
|
| 239 |
@Autowired
|
255 |
@Autowired
|
| 240 |
private SaholicInventoryService saholicInventoryService;
|
256 |
private SaholicInventoryService saholicInventoryService;
|
| 241 |
|
257 |
|
| - |
|
258 |
@Autowired
|
| - |
|
259 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| - |
|
260 |
|
| 242 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
261 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
| 243 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
|
262 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
|
| 244 |
@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
|
263 |
@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
|
| 245 |
if (fofoId == 0) {
|
264 |
if (fofoId == 0) {
|
| 246 |
|
265 |
|
| Line 1712... |
Line 1731... |
| 1712 |
model.addAttribute("items", items);
|
1731 |
model.addAttribute("items", items);
|
| 1713 |
LOGGER.info("itemIdAndColorMap" + items);
|
1732 |
LOGGER.info("itemIdAndColorMap" + items);
|
| 1714 |
return "select-item-color";
|
1733 |
return "select-item-color";
|
| 1715 |
}
|
1734 |
}
|
| 1716 |
|
1735 |
|
| - |
|
1736 |
List<String> emails = Arrays.asList("kamini.sharma@smartdukaan.com", "neeraj.gupta@smartdukaan.com",
|
| - |
|
1737 |
"niranjan.kala@smartdukaan.com", "amit.gupta@shop2020.in", "tejbeer.kaur@shop2020.in");
|
| - |
|
1738 |
|
| - |
|
1739 |
@Autowired
|
| - |
|
1740 |
private PositionRepository positionRepository;
|
| - |
|
1741 |
|
| - |
|
1742 |
@Autowired
|
| - |
|
1743 |
private PartnerTypeChangeService partnerTypeChangeService;
|
| - |
|
1744 |
|
| - |
|
1745 |
@Autowired
|
| - |
|
1746 |
private com.spice.profitmandi.service.transaction.TransactionService transactionService;
|
| - |
|
1747 |
|
| - |
|
1748 |
@Autowired
|
| - |
|
1749 |
private CategoryRepository categoryRepository;
|
| - |
|
1750 |
|
| - |
|
1751 |
private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING,
|
| - |
|
1752 |
OrderStatus.ACCEPTED);
|
| - |
|
1753 |
|
| - |
|
1754 |
public static final Map<String, Double> Brand_Amount_Limit = new HashMap<>();
|
| - |
|
1755 |
|
| - |
|
1756 |
static {
|
| - |
|
1757 |
Brand_Amount_Limit.put("Vivo", 250000.00);
|
| - |
|
1758 |
Brand_Amount_Limit.put("Samsung", 150000.00);
|
| - |
|
1759 |
Brand_Amount_Limit.put("Realme", 150000.00);
|
| - |
|
1760 |
Brand_Amount_Limit.put("Tecno", 80000.00);
|
| - |
|
1761 |
Brand_Amount_Limit.put("Itel", 30000.00);
|
| - |
|
1762 |
Brand_Amount_Limit.put("Lava", 15000.00);
|
| - |
|
1763 |
Brand_Amount_Limit.put("OnePlus", 200000.00);
|
| - |
|
1764 |
Brand_Amount_Limit.put("Oppo", 250000.00);
|
| - |
|
1765 |
Brand_Amount_Limit.put("Xiaomi", 0.00);
|
| - |
|
1766 |
Brand_Amount_Limit.put("Nokia", 0.00);
|
| - |
|
1767 |
Brand_Amount_Limit.put("accessories", 10000.00);
|
| - |
|
1768 |
Brand_Amount_Limit.put("TV", 27000.00);
|
| - |
|
1769 |
}
|
| - |
|
1770 |
|
| - |
|
1771 |
@RequestMapping(value = "/getPartnersBrandWiseDetail", method = RequestMethod.GET)
|
| - |
|
1772 |
public String getPartnersBrandWiseDetail(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
1773 |
|
| - |
|
1774 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
1775 |
String email = loginDetails.getEmailId();
|
| - |
|
1776 |
|
| - |
|
1777 |
List<String> brands = Arrays.asList("Vivo", "Samsung", "Oppo", "Tecno", "Itel", "OnePlus", "Lava", "Realme",
|
| - |
|
1778 |
"Xiaomi", "Nokia");
|
| - |
|
1779 |
|
| - |
|
1780 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
| - |
|
1781 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| - |
|
1782 |
|
| - |
|
1783 |
Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
|
| - |
|
1784 |
|
| - |
|
1785 |
if (emails.contains(authUser.getEmailId())) {
|
| - |
|
1786 |
fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
|
| - |
|
1787 |
LOGGER.info("fofoIds" + fofoIds);
|
| - |
|
1788 |
}
|
| - |
|
1789 |
if (fofoIds == null) {
|
| - |
|
1790 |
List<Position> positions1 = positionRepository.selectAll(authUser.getId());
|
| - |
|
1791 |
if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
|
| - |
|
1792 |
.count() > 0) {
|
| - |
|
1793 |
fofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream().flatMap(x -> x.stream())
|
| - |
|
1794 |
.map(x -> x.getPartnerId()).collect(Collectors.toSet());
|
| - |
|
1795 |
}
|
| - |
|
1796 |
}
|
| - |
|
1797 |
|
| - |
|
1798 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
|
| - |
|
1799 |
|
| - |
|
1800 |
Map<Integer, Map<String, Double>> inStockBrandModel = new HashMap<>();
|
| - |
|
1801 |
Map<Integer, Map<String, Double>> pendingIndent = new HashMap<>();
|
| - |
|
1802 |
Map<Integer, Map<String, Double>> grnPendingOrders = new HashMap<>();
|
| - |
|
1803 |
|
| - |
|
1804 |
Map<Integer, InStockAccessoriesTvFofoIdModel> inStockAccessTv = new HashMap<>();
|
| - |
|
1805 |
Map<Integer, InStockAccessoriesTvFofoIdModel> pendingIndentAccessTv = new HashMap<>();
|
| - |
|
1806 |
Map<Integer, InStockAccessoriesTvFofoIdModel> grnPendingAccessTvOrders = new HashMap<>();
|
| - |
|
1807 |
|
| - |
|
1808 |
Map<Integer, CustomRetailer> customRetailers = new HashMap<>();
|
| - |
|
1809 |
Map<Integer, PartnerType> fofoIdPartnerTypeMap = new HashMap<>();
|
| - |
|
1810 |
|
| - |
|
1811 |
if (fofoIds.size() > 0 && fofoIds != null) {
|
| - |
|
1812 |
List<Integer> fofoIdList = new ArrayList<>(fofoIds);
|
| - |
|
1813 |
|
| - |
|
1814 |
Map<Integer, FofoReportingModel> partnerSalesHeadersMap = csService.getPartnerIdSalesHeaders();
|
| - |
|
1815 |
|
| - |
|
1816 |
model.addAttribute("partnerSalesHeadersMap", partnerSalesHeadersMap);
|
| - |
|
1817 |
customRetailers = retailerService.getFofoRetailers(fofoIdList);
|
| - |
|
1818 |
|
| - |
|
1819 |
for (Entry<Integer, CustomRetailer> customRetailer : customRetailers.entrySet()) {
|
| - |
|
1820 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(customRetailer.getKey(),
|
| - |
|
1821 |
LocalDate.now());
|
| - |
|
1822 |
fofoIdPartnerTypeMap.put(customRetailer.getKey(), partnerType);
|
| - |
|
1823 |
}
|
| - |
|
1824 |
|
| - |
|
1825 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
| - |
|
1826 |
.selectAll(new ArrayList<>(fofoIdList), LocalDate.now().minusDays(1));
|
| - |
|
1827 |
if (!partnerDailyInvestments.isEmpty()) {
|
| - |
|
1828 |
partnerDailyInvestmentMap = partnerDailyInvestments.stream()
|
| - |
|
1829 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| - |
|
1830 |
}
|
| - |
|
1831 |
|
| - |
|
1832 |
inStockBrandModel = currentInventorySnapshotRepository.selectSumInStockMobiletabletGroupByBrand(fofoIdList)
|
| - |
|
1833 |
.stream()
|
| - |
|
1834 |
.collect(Collectors.groupingBy(InStockBrandFofoIdModel::getFofoId,
|
| - |
|
1835 |
Collectors.groupingBy(InStockBrandFofoIdModel::getBrand,
|
| - |
|
1836 |
Collectors.summingDouble(InStockBrandFofoIdModel::getAmount))));
|
| - |
|
1837 |
|
| - |
|
1838 |
pendingIndent = transactionService.getInTransitOrders(fofoIdList).stream()
|
| - |
|
1839 |
.filter(x -> x.getLineItem().getItem().equals("10006"))
|
| - |
|
1840 |
.collect(Collectors.groupingBy(x -> x.getRetailerId(),
|
| - |
|
1841 |
Collectors.groupingBy(y -> y.getLineItem().getBrand(),
|
| - |
|
1842 |
Collectors.summingDouble(y -> (double) y.getTotalAmount()))));
|
| - |
|
1843 |
|
| - |
|
1844 |
grnPendingOrders = orderRepository.selectPendingGrnOrders(fofoIdList).stream()
|
| - |
|
1845 |
.filter(x -> x.getLineItem().getItem().equals("10006"))
|
| - |
|
1846 |
.collect(Collectors.groupingBy(x -> x.getRetailerId(),
|
| - |
|
1847 |
Collectors.groupingBy(y -> y.getLineItem().getBrand(),
|
| - |
|
1848 |
Collectors.summingDouble(y -> (double) y.getTotalAmount()))));
|
| - |
|
1849 |
|
| - |
|
1850 |
inStockAccessTv = currentInventorySnapshotRepository.selectSumInStockAccessoriesAndTv(fofoIdList).stream()
|
| - |
|
1851 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| - |
|
1852 |
|
| - |
|
1853 |
pendingIndentAccessTv = orderRepository.selectAllPendingIndentAccessoriesTvGroupByFofoId(fofoIdList)
|
| - |
|
1854 |
.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| - |
|
1855 |
|
| - |
|
1856 |
grnPendingAccessTvOrders = orderRepository.selectAllGrnPendingAccessoriesTvGroupByFofoId(fofoIdList)
|
| - |
|
1857 |
.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| - |
|
1858 |
|
| - |
|
1859 |
}
|
| - |
|
1860 |
|
| - |
|
1861 |
model.addAttribute("customRetailers", customRetailers);
|
| - |
|
1862 |
|
| - |
|
1863 |
LOGGER.info("partnerDailyInvestmentMap" + partnerDailyInvestmentMap);
|
| - |
|
1864 |
|
| - |
|
1865 |
model.addAttribute("partnerDailyInvestmentMap", partnerDailyInvestmentMap);
|
| - |
|
1866 |
|
| - |
|
1867 |
LOGGER.info("inStockBrandModel" + inStockBrandModel);
|
| - |
|
1868 |
|
| - |
|
1869 |
model.addAttribute("brands", brands);
|
| - |
|
1870 |
|
| - |
|
1871 |
model.addAttribute("brandAmountLimit", Brand_Amount_Limit);
|
| - |
|
1872 |
model.addAttribute("inStockBrandModel", inStockBrandModel);
|
| - |
|
1873 |
model.addAttribute("pendingIndent", pendingIndent);
|
| - |
|
1874 |
model.addAttribute("grnPendingOrders", grnPendingOrders);
|
| - |
|
1875 |
|
| - |
|
1876 |
model.addAttribute("inStockAccessTv", inStockAccessTv);
|
| - |
|
1877 |
model.addAttribute("pendingIndentAccessTv", pendingIndentAccessTv);
|
| - |
|
1878 |
model.addAttribute("grnPendingAccessTvOrders", grnPendingAccessTvOrders);
|
| - |
|
1879 |
model.addAttribute("fofoIdPartnerTypeMap", fofoIdPartnerTypeMap);
|
| - |
|
1880 |
return "partner-brandwise-detail";
|
| - |
|
1881 |
}
|
| - |
|
1882 |
|
| - |
|
1883 |
@RequestMapping(value = "/getPartnerShortageStock", method = RequestMethod.GET)
|
| - |
|
1884 |
public String getPartnerShortageStock(HttpServletRequest request,
|
| - |
|
1885 |
@RequestParam(required = false, defaultValue = "") String brand, @RequestParam int fofoId, Model model)
|
| - |
|
1886 |
throws Exception {
|
| - |
|
1887 |
|
| - |
|
1888 |
Map<Integer, Map<Integer, List<SaholicCIS>>> warehouseItemAvailabilityMap = saholicInventoryService
|
| - |
|
1889 |
.getSaholicStock();
|
| - |
|
1890 |
|
| - |
|
1891 |
Map<Integer, Map<Integer, List<SaholicPOItem>>> warehousePoItemAvailabilityMap = saholicInventoryService
|
| - |
|
1892 |
.getSaholicPOItems();
|
| - |
|
1893 |
|
| - |
|
1894 |
List<FocusedModelShortageModel> focusedModelShortageList = new ArrayList<>();
|
| - |
|
1895 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
| - |
|
1896 |
Map<Integer, Integer> processingOrderMap = null;
|
| - |
|
1897 |
Map<Integer, Integer> catalogIdAndQtyMap = null;
|
| - |
|
1898 |
Map<Integer, Integer> grnPendingOrdersMap = null;
|
| - |
|
1899 |
|
| - |
|
1900 |
Map<Integer, Integer> currentInventorySnapshot = currentInventorySnapshotRepository.selectByFofoId(fofoId)
|
| - |
|
1901 |
.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
| - |
|
1902 |
|
| - |
|
1903 |
if (!currentInventorySnapshot.isEmpty()) {
|
| - |
|
1904 |
catalogIdAndQtyMap = itemRepository.selectByIds(currentInventorySnapshot.keySet()).stream()
|
| - |
|
1905 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
| - |
|
1906 |
Collectors.summingInt(x -> currentInventorySnapshot.get(x.getId()))));
|
| - |
|
1907 |
|
| - |
|
1908 |
}
|
| - |
|
1909 |
|
| - |
|
1910 |
Map<Integer, Integer> grnPendingOrders = orderRepository.selectPendingGrnOrders(fofoId).stream()
|
| - |
|
1911 |
.collect(Collectors.groupingBy(x -> x.getLineItem().getItemId(),
|
| - |
|
1912 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
| - |
|
1913 |
if (!grnPendingOrders.isEmpty()) {
|
| - |
|
1914 |
grnPendingOrdersMap = itemRepository.selectByIds(grnPendingOrders.keySet()).stream()
|
| - |
|
1915 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
| - |
|
1916 |
Collectors.summingInt(x -> grnPendingOrders.get(x.getId()))));
|
| - |
|
1917 |
|
| - |
|
1918 |
}
|
| - |
|
1919 |
|
| - |
|
1920 |
Map<Integer, Integer> processingOrder = orderRepository.selectOrders(fofoId, orderStatusList).stream()
|
| - |
|
1921 |
.collect(Collectors.groupingBy(x -> x.getLineItem().getItemId(),
|
| - |
|
1922 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
| - |
|
1923 |
if (!processingOrder.isEmpty()) {
|
| - |
|
1924 |
processingOrderMap = itemRepository.selectByIds(processingOrder.keySet()).stream().collect(Collectors
|
| - |
|
1925 |
.groupingBy(x -> x.getCatalogItemId(), Collectors.summingInt(x -> processingOrder.get(x.getId()))));
|
| - |
|
1926 |
|
| - |
|
1927 |
}
|
| - |
|
1928 |
|
| - |
|
1929 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
|
| - |
|
1930 |
.collect(Collectors.toList());
|
| - |
|
1931 |
LOGGER.info("regionIds" + regionIds);
|
| - |
|
1932 |
if (regionIds.size() == 0) {
|
| - |
|
1933 |
LOGGER.info("No region found for partner {}", fofoId);
|
| - |
|
1934 |
|
| - |
|
1935 |
}
|
| - |
|
1936 |
Map<Integer, Optional<Integer>> focusedCatalogIdAndQtyMap = focusedModelRepository
|
| - |
|
1937 |
.selectAllByRegionIds(regionIds).stream().collect(Collectors.groupingBy(FocusedModel::getCatalogId,
|
| - |
|
1938 |
Collectors.mapping(FocusedModel::getObsMinimumQty, Collectors.maxBy(Integer::compareTo))));
|
| - |
|
1939 |
|
| - |
|
1940 |
for (Map.Entry<Integer, Optional<Integer>> entry : focusedCatalogIdAndQtyMap.entrySet()) {
|
| - |
|
1941 |
List<Item> items = itemRepository.selectAllByCatalogItemId(entry.getKey());
|
| - |
|
1942 |
|
| - |
|
1943 |
if (brand.equals("undefined") || items.get(0).getBrand().equals(brand)) {
|
| - |
|
1944 |
|
| - |
|
1945 |
FocusedModelShortageModel fm = this.getFocusedModelShortage(entry.getValue().get(), entry.getKey(),
|
| - |
|
1946 |
processingOrderMap, grnPendingOrdersMap, catalogIdAndQtyMap, fofoId,
|
| - |
|
1947 |
warehouseItemAvailabilityMap, warehousePoItemAvailabilityMap, items, customRetailer);
|
| - |
|
1948 |
|
| - |
|
1949 |
focusedModelShortageList.add(fm);
|
| - |
|
1950 |
} else if (brand.equals("accessories")) {
|
| - |
|
1951 |
|
| - |
|
1952 |
if (items.get(0).getCategoryId() != ProfitMandiConstants.MOBILE_CATEGORY_ID) {
|
| - |
|
1953 |
if (items.get(0).getCategoryId() != 0) {
|
| - |
|
1954 |
Category category = categoryRepository.selectById(items.get(0).getCategoryId());
|
| - |
|
1955 |
|
| - |
|
1956 |
if (category.getParentCategoryId() == 10011) {
|
| - |
|
1957 |
FocusedModelShortageModel fm = this.getFocusedModelShortage(entry.getValue().get(),
|
| - |
|
1958 |
entry.getKey(), processingOrderMap, grnPendingOrdersMap, catalogIdAndQtyMap, fofoId,
|
| - |
|
1959 |
warehouseItemAvailabilityMap, warehousePoItemAvailabilityMap, items,
|
| - |
|
1960 |
customRetailer);
|
| - |
|
1961 |
|
| - |
|
1962 |
focusedModelShortageList.add(fm);
|
| - |
|
1963 |
|
| - |
|
1964 |
}
|
| - |
|
1965 |
}
|
| - |
|
1966 |
|
| - |
|
1967 |
}
|
| - |
|
1968 |
|
| - |
|
1969 |
} else if (brand.equals("TV")) {
|
| - |
|
1970 |
|
| - |
|
1971 |
if (items.get(0).getCategoryId() != ProfitMandiConstants.MOBILE_CATEGORY_ID) {
|
| - |
|
1972 |
LOGGER.info("items.get(0).getCategoryId()" + items.get(0).getCategoryId());
|
| - |
|
1973 |
if (items.get(0).getCategoryId() != 0) {
|
| - |
|
1974 |
|
| - |
|
1975 |
Category category = categoryRepository.selectById(items.get(0).getCategoryId());
|
| - |
|
1976 |
|
| - |
|
1977 |
if (category.getParentCategoryId() == 14200) {
|
| - |
|
1978 |
FocusedModelShortageModel fm = this.getFocusedModelShortage(entry.getValue().get(),
|
| - |
|
1979 |
entry.getKey(), processingOrderMap, grnPendingOrdersMap, catalogIdAndQtyMap, fofoId,
|
| - |
|
1980 |
warehouseItemAvailabilityMap, warehousePoItemAvailabilityMap, items,
|
| - |
|
1981 |
customRetailer);
|
| - |
|
1982 |
|
| - |
|
1983 |
focusedModelShortageList.add(fm);
|
| - |
|
1984 |
|
| - |
|
1985 |
}
|
| - |
|
1986 |
}
|
| - |
|
1987 |
|
| - |
|
1988 |
}
|
| - |
|
1989 |
|
| - |
|
1990 |
}
|
| - |
|
1991 |
|
| - |
|
1992 |
}
|
| - |
|
1993 |
|
| - |
|
1994 |
LOGGER.info("focusedModelShortageList" + focusedModelShortageList);
|
| - |
|
1995 |
|
| - |
|
1996 |
model.addAttribute("focusedModelShortageList", focusedModelShortageList);
|
| - |
|
1997 |
|
| - |
|
1998 |
model.addAttribute("customRetailer", customRetailer);
|
| - |
|
1999 |
return "partner-stock";
|
| - |
|
2000 |
|
| - |
|
2001 |
}
|
| - |
|
2002 |
|
| - |
|
2003 |
private FocusedModelShortageModel getFocusedModelShortage(int qty, int catalogId,
|
| - |
|
2004 |
Map<Integer, Integer> processingOrderMap, Map<Integer, Integer> grnPendingOrdersMap,
|
| - |
|
2005 |
Map<Integer, Integer> catalogIdAndQtyMap, int fofoId,
|
| - |
|
2006 |
Map<Integer, Map<Integer, List<SaholicCIS>>> warehouseItemAvailabilityMap,
|
| - |
|
2007 |
Map<Integer, Map<Integer, List<SaholicPOItem>>> warehousePoItemAvailabilityMap, List<Item> items,
|
| - |
|
2008 |
CustomRetailer customRetailer) throws ProfitMandiBusinessException {
|
| - |
|
2009 |
|
| - |
|
2010 |
int minQty = qty;
|
| - |
|
2011 |
int inStockQty = 0;
|
| - |
|
2012 |
int processingQty = 0;
|
| - |
|
2013 |
int grnPendingQty = 0;
|
| - |
|
2014 |
int allColorNetAvailability = 0;
|
| - |
|
2015 |
int allColorPoAvailability = 0;
|
| - |
|
2016 |
if (processingOrderMap != null) {
|
| - |
|
2017 |
processingQty = (processingOrderMap.get(catalogId) == null) ? 0 : processingOrderMap.get(catalogId);
|
| - |
|
2018 |
|
| - |
|
2019 |
}
|
| - |
|
2020 |
if (grnPendingOrdersMap != null) {
|
| - |
|
2021 |
grnPendingQty = (grnPendingOrdersMap.get(catalogId) == null) ? 0 : grnPendingOrdersMap.get(catalogId);
|
| - |
|
2022 |
|
| - |
|
2023 |
}
|
| - |
|
2024 |
if (catalogIdAndQtyMap != null) {
|
| - |
|
2025 |
inStockQty = (catalogIdAndQtyMap.get(catalogId) == null) ? 0 : catalogIdAndQtyMap.get(catalogId);
|
| - |
|
2026 |
|
| - |
|
2027 |
}
|
| - |
|
2028 |
|
| - |
|
2029 |
int grnStockQty = grnPendingQty + inStockQty;
|
| - |
|
2030 |
int totalQty = processingQty + grnPendingQty + inStockQty;
|
| - |
|
2031 |
|
| - |
|
2032 |
int shortageQty = minQty - totalQty;
|
| - |
|
2033 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| - |
|
2034 |
|
| - |
|
2035 |
Map<Integer, List<SaholicCIS>> itemAvailabilityMap = warehouseItemAvailabilityMap
|
| - |
|
2036 |
.get(fofoStore.getWarehouseId());
|
| - |
|
2037 |
|
| - |
|
2038 |
Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = warehousePoItemAvailabilityMap
|
| - |
|
2039 |
.get(fofoStore.getWarehouseId());
|
| - |
|
2040 |
|
| - |
|
2041 |
for (Item it : items) {
|
| - |
|
2042 |
List<SaholicCIS> currentAvailability = null;
|
| - |
|
2043 |
List<SaholicPOItem> poItemAvailability = null;
|
| - |
|
2044 |
if (itemAvailabilityMap != null) {
|
| - |
|
2045 |
currentAvailability = itemAvailabilityMap.get(it.getId());
|
| - |
|
2046 |
}
|
| - |
|
2047 |
|
| - |
|
2048 |
if (poItemAvailabilityMap != null) {
|
| - |
|
2049 |
poItemAvailability = poItemAvailabilityMap.get(it.getId());
|
| - |
|
2050 |
}
|
| - |
|
2051 |
if (currentAvailability != null) {
|
| - |
|
2052 |
allColorNetAvailability += currentAvailability.stream()
|
| - |
|
2053 |
.collect(Collectors.summingInt(SaholicCIS::getNetavailability));
|
| - |
|
2054 |
}
|
| - |
|
2055 |
|
| - |
|
2056 |
if (poItemAvailability != null) {
|
| - |
|
2057 |
allColorPoAvailability += poItemAvailability.stream()
|
| - |
|
2058 |
.collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty));
|
| - |
|
2059 |
}
|
| - |
|
2060 |
|
| - |
|
2061 |
}
|
| - |
|
2062 |
|
| - |
|
2063 |
FocusedModelShortageModel fm = new FocusedModelShortageModel();
|
| - |
|
2064 |
fm.setFofoId(fofoId);
|
| - |
|
2065 |
fm.setStoreCode(fofoStore.getCode());
|
| - |
|
2066 |
fm.setStoreName(customRetailer.getBusinessName());
|
| - |
|
2067 |
fm.setBrandName(items.get(0).getBrand());
|
| - |
|
2068 |
fm.setModelName(items.get(0).getModelName());
|
| - |
|
2069 |
fm.setModelNumber(items.get(0).getModelNumber());
|
| - |
|
2070 |
fm.setGrnStockQty(grnStockQty);
|
| - |
|
2071 |
fm.setPendingIndentQty(processingQty);
|
| - |
|
2072 |
fm.setShortageQty(shortageQty);
|
| - |
|
2073 |
fm.setPoAvailabitiy(allColorPoAvailability);
|
| - |
|
2074 |
fm.setItemName(items.get(0).getBrand() + items.get(0).getModelNumber() + items.get(0).getModelName());
|
| - |
|
2075 |
fm.setAvailabitiy(allColorNetAvailability);
|
| - |
|
2076 |
return fm;
|
| - |
|
2077 |
|
| - |
|
2078 |
}
|
| - |
|
2079 |
|
| 1717 |
}
|
2080 |
}
|
| 1718 |
|
2081 |
|