| 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.Set;
|
15 |
import java.util.Set;
|
| - |
|
16 |
import java.util.Map.Entry;
|
| 16 |
import java.util.function.Function;
|
17 |
import java.util.function.Function;
|
| 17 |
import java.util.stream.Collectors;
|
18 |
import java.util.stream.Collectors;
|
| 18 |
|
19 |
|
| 19 |
import javax.servlet.http.HttpServletRequest;
|
20 |
import javax.servlet.http.HttpServletRequest;
|
| 20 |
|
21 |
|
| Line 67... |
Line 68... |
| 67 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
68 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| 68 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTypeChange;
|
69 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTypeChange;
|
| 69 |
import com.spice.profitmandi.dao.entity.fofo.PlannedDetail;
|
70 |
import com.spice.profitmandi.dao.entity.fofo.PlannedDetail;
|
| 70 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
71 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
| 71 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
72 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
| - |
|
73 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
| 72 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
74 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 73 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
75 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 74 |
import com.spice.profitmandi.dao.entity.user.User;
|
76 |
import com.spice.profitmandi.dao.entity.user.User;
|
| 75 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
77 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| - |
|
78 |
import com.spice.profitmandi.dao.model.WarehosueWiseItemStockAvailability;
|
| - |
|
79 |
import com.spice.profitmandi.dao.model.WarehouseWiseStockModel;
|
| 76 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
80 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 77 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
|
81 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
|
| 78 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
82 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 79 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
83 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 80 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
84 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| Line 90... |
Line 94... |
| 90 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
|
94 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
|
| 91 |
import com.spice.profitmandi.dao.repository.fofo.PlannedDetailRepository;
|
95 |
import com.spice.profitmandi.dao.repository.fofo.PlannedDetailRepository;
|
| 92 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
96 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| 93 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
97 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
| 94 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
98 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
| - |
|
99 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
|
| 95 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
100 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 96 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
101 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 97 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
102 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 98 |
import com.spice.profitmandi.service.NotificationService;
|
103 |
import com.spice.profitmandi.service.NotificationService;
|
| 99 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
104 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 100 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
105 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| - |
|
106 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
| 101 |
import com.spice.profitmandi.service.inventory.StockAllocationService;
|
107 |
import com.spice.profitmandi.service.inventory.StockAllocationService;
|
| 102 |
import com.spice.profitmandi.service.user.RetailerService;
|
108 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 103 |
import com.spice.profitmandi.service.wallet.WalletService;
|
109 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 104 |
import com.spice.profitmandi.thrift.clients.PaymentClient;
|
110 |
import com.spice.profitmandi.thrift.clients.PaymentClient;
|
| 105 |
import com.spice.profitmandi.thrift.clients.TransactionClient;
|
111 |
import com.spice.profitmandi.thrift.clients.TransactionClient;
|
| Line 235... |
Line 241... |
| 235 |
private RegionRepository regionRepository;
|
241 |
private RegionRepository regionRepository;
|
| 236 |
|
242 |
|
| 237 |
@Autowired
|
243 |
@Autowired
|
| 238 |
private PartnerRegionRepository partnerRegionRepository;
|
244 |
private PartnerRegionRepository partnerRegionRepository;
|
| 239 |
|
245 |
|
| - |
|
246 |
@Autowired
|
| - |
|
247 |
private SaholicInventoryCISRepository saholicInventoryCISRepository;
|
| - |
|
248 |
|
| - |
|
249 |
@Autowired
|
| - |
|
250 |
private SaholicInventoryService saholicInventoryService;
|
| - |
|
251 |
|
| 240 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
252 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
| 241 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
|
253 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
|
| 242 |
@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
|
254 |
@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
|
| 243 |
if (fofoId == 0) {
|
255 |
if (fofoId == 0) {
|
| 244 |
|
256 |
|
| Line 1363... |
Line 1375... |
| 1363 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
1375 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> (int) x.getAggregateValue()));
|
| 1364 |
|
1376 |
|
| 1365 |
}
|
1377 |
}
|
| 1366 |
}
|
1378 |
}
|
| 1367 |
|
1379 |
|
| - |
|
1380 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| 1368 |
LOGGER.info("currentStock" + currentStockMap);
|
1381 |
LOGGER.info("currentStock" + currentStockMap);
|
| 1369 |
|
1382 |
|
| 1370 |
Map<Integer, Integer> itemsInTransit = null;
|
1383 |
Map<Integer, Integer> itemsInTransit = null;
|
| 1371 |
List<TagListing> tagListings = tagListingRepository.selectAll(true);
|
1384 |
List<TagListing> tagListings = tagListingRepository.selectAll(true);
|
| 1372 |
if (!isAdmin) {
|
1385 |
if (!isAdmin) {
|
| Line 1447... |
Line 1460... |
| 1447 |
|
1460 |
|
| 1448 |
Map<String, Object> equalsItemJoinMap = new HashMap<>();
|
1461 |
Map<String, Object> equalsItemJoinMap = new HashMap<>();
|
| 1449 |
equalsItemJoinMap.put("active", 1);
|
1462 |
equalsItemJoinMap.put("active", 1);
|
| 1450 |
List<CatalogIdAggregateValue> tagListingCatalogIds = itemRepository.selectItems(TagListing.class, "id",
|
1463 |
List<CatalogIdAggregateValue> tagListingCatalogIds = itemRepository.selectItems(TagListing.class, "id",
|
| 1451 |
"itemId", equalsMap, notEqualsMap, equalsItemJoinMap, notEqualsJoinMap, "tagId");
|
1464 |
"itemId", equalsMap, notEqualsMap, equalsItemJoinMap, notEqualsJoinMap, "tagId");
|
| - |
|
1465 |
Map<Integer, Integer> ourStockAvailability = new HashMap<>();
|
| - |
|
1466 |
Map<Integer, List<SaholicCIS>> itemAvailabilityMap = saholicInventoryService.getSaholicStock()
|
| - |
|
1467 |
.get(fofoStore.getWarehouseId());
|
| - |
|
1468 |
|
| - |
|
1469 |
Map<Integer, List<Integer>> catalogItemIdMap = itemRepository
|
| - |
|
1470 |
.selectAllByCatalogIds(new HashSet<>(
|
| - |
|
1471 |
tagListingCatalogIds.stream().map(x -> x.getCatalogId()).collect(Collectors.toList())))
|
| - |
|
1472 |
.stream().collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
| - |
|
1473 |
Collectors.mapping(y -> y.getId(), Collectors.toList())));
|
| - |
|
1474 |
for (Entry<Integer, List<Integer>> catalogItem : catalogItemIdMap.entrySet()) {
|
| - |
|
1475 |
List<Integer> itemIds = catalogItem.getValue();
|
| - |
|
1476 |
int availability = 0;
|
| - |
|
1477 |
for (Integer itemId : itemIds) {
|
| - |
|
1478 |
List<SaholicCIS> scis = itemAvailabilityMap.get(itemId);
|
| - |
|
1479 |
if (scis != null) {
|
| - |
|
1480 |
availability += scis.stream().collect(Collectors.summingInt(x -> x.getAvailability()));
|
| - |
|
1481 |
}
|
| - |
|
1482 |
}
|
| - |
|
1483 |
Integer catalogItemId = catalogItem.getKey();
|
| - |
|
1484 |
ourStockAvailability.put(catalogItemId, availability);
|
| - |
|
1485 |
}
|
| 1452 |
LOGGER.info("tagListingCatalogIds");
|
1486 |
LOGGER.info("ourStockAvailability" + ourStockAvailability);
|
| - |
|
1487 |
|
| 1453 |
for (CatalogIdAggregateValue catalogIdAggregateValue : tagListingCatalogIds) {
|
1488 |
for (CatalogIdAggregateValue catalogIdAggregateValue : tagListingCatalogIds) {
|
| 1454 |
int catalogId = catalogIdAggregateValue.getCatalogId();
|
1489 |
int catalogId = catalogIdAggregateValue.getCatalogId();
|
| 1455 |
Item item = catalogIdItemMap.get(catalogId).get(0);
|
1490 |
Item item = catalogIdItemMap.get(catalogId).get(0);
|
| 1456 |
TagListing tagListing = taglistingMap.get(item.getId());
|
1491 |
TagListing tagListing = taglistingMap.get(item.getId());
|
| 1457 |
CatalogListingModel catalogListingModel = catalogListingMap.get(catalogId);
|
1492 |
CatalogListingModel catalogListingModel = catalogListingMap.get(catalogId);
|
| Line 1484... |
Line 1519... |
| 1484 |
catalogListingModel.setBrand(item.getBrand());
|
1519 |
catalogListingModel.setBrand(item.getBrand());
|
| 1485 |
if (item.getCategoryId() == 10006) {
|
1520 |
if (item.getCategoryId() == 10006) {
|
| 1486 |
catalogListingModel.setCategoryId(item.getCategoryId());
|
1521 |
catalogListingModel.setCategoryId(item.getCategoryId());
|
| 1487 |
}
|
1522 |
}
|
| 1488 |
|
1523 |
|
| - |
|
1524 |
Integer ourStock = ourStockAvailability.get(catalogId);
|
| - |
|
1525 |
LOGGER.info("catalogId" + catalogId);
|
| - |
|
1526 |
|
| - |
|
1527 |
LOGGER.info("ourStock" + ourStock);
|
| - |
|
1528 |
if (ourStock != null) {
|
| - |
|
1529 |
catalogListingModel.setOurStockQty(ourStock);
|
| - |
|
1530 |
}
|
| - |
|
1531 |
|
| 1489 |
FocusedModel fm = focusedModelMap.get(catalogId);
|
1532 |
FocusedModel fm = focusedModelMap.get(catalogId);
|
| 1490 |
if (fm != null) {
|
1533 |
if (fm != null) {
|
| 1491 |
catalogListingModel.setRecommendedQty(fm.getRecommendedQty());
|
1534 |
catalogListingModel.setRecommendedQty(fm.getRecommendedQty());
|
| 1492 |
catalogListingModel.setMinimumQty(fm.getMinimumQty());
|
1535 |
catalogListingModel.setMinimumQty(fm.getMinimumQty());
|
| 1493 |
|
1536 |
|
| Line 1545... |
Line 1588... |
| 1545 |
Comparator.reverseOrder());
|
1588 |
Comparator.reverseOrder());
|
| 1546 |
LOGGER.info("monthlyPlanned" + monthlyPlanned);
|
1589 |
LOGGER.info("monthlyPlanned" + monthlyPlanned);
|
| 1547 |
model.addAttribute("catalogTagListings",
|
1590 |
model.addAttribute("catalogTagListings",
|
| 1548 |
catalogModelList.stream().sorted(firstCmp).collect(Collectors.toList()));
|
1591 |
catalogModelList.stream().sorted(firstCmp).collect(Collectors.toList()));
|
| 1549 |
model.addAttribute("isAdmin", roleManager.isAdmin(roleIds));
|
1592 |
model.addAttribute("isAdmin", roleManager.isAdmin(roleIds));
|
| 1550 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(loginDetails.getFofoId()));
|
1593 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(fofoId));
|
| 1551 |
model.addAttribute("previousPlanningMonth", LocalDate.now().minusMonths(1).getMonth());
|
1594 |
model.addAttribute("previousPlanningMonth", LocalDate.now().minusMonths(1).getMonth());
|
| 1552 |
model.addAttribute("currentPlanningMonth", LocalDate.now().getMonth());
|
1595 |
model.addAttribute("currentPlanningMonth", LocalDate.now().getMonth());
|
| 1553 |
|
1596 |
|
| 1554 |
model.addAttribute("customRetailers", customRetailers);
|
1597 |
model.addAttribute("customRetailers", customRetailers);
|
| 1555 |
model.addAttribute("totalAmount", totalAmount);
|
1598 |
model.addAttribute("totalAmount", totalAmount);
|