| Line 20... |
Line 20... |
| 20 |
import com.spice.profitmandi.dao.entity.transaction.SDCreditRequirement;
|
20 |
import com.spice.profitmandi.dao.entity.transaction.SDCreditRequirement;
|
| 21 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
21 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 22 |
import com.spice.profitmandi.dao.entity.user.User;
|
22 |
import com.spice.profitmandi.dao.entity.user.User;
|
| 23 |
import com.spice.profitmandi.dao.entity.warehouse.BrandRegionMapping;
|
23 |
import com.spice.profitmandi.dao.entity.warehouse.BrandRegionMapping;
|
| 24 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
24 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| - |
|
25 |
import com.spice.profitmandi.dao.enumuration.inventory.CatalogMovingEnum;
|
| - |
|
26 |
import com.spice.profitmandi.dao.event.TagListingEventPublisher;
|
| 25 |
import com.spice.profitmandi.dao.model.*;
|
27 |
import com.spice.profitmandi.dao.model.*;
|
| 26 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
28 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 27 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
- |
|
| 28 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
|
- |
|
| 29 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
29 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
| 30 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
- |
|
| 31 |
import com.spice.profitmandi.dao.event.TagListingEventPublisher;
|
- |
|
| 32 |
import com.spice.profitmandi.dao.repository.cs.*;
|
30 |
import com.spice.profitmandi.dao.repository.cs.*;
|
| 33 |
import com.spice.profitmandi.dao.repository.dtr.BrandLimitRepository;
|
31 |
import com.spice.profitmandi.dao.repository.dtr.BrandLimitRepository;
|
| 34 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
32 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 35 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
33 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 36 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
34 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| Line 42... |
Line 40... |
| 42 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
40 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 43 |
import com.spice.profitmandi.dao.repository.transaction.SDCreditRequirementRepository;
|
41 |
import com.spice.profitmandi.dao.repository.transaction.SDCreditRequirementRepository;
|
| 44 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
42 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 45 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
43 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 46 |
import com.spice.profitmandi.dao.repository.warehouse.BrandRegionMappingRepository;
|
44 |
import com.spice.profitmandi.dao.repository.warehouse.BrandRegionMappingRepository;
|
| - |
|
45 |
import com.spice.profitmandi.model.WarehouseItemQtyModel;
|
| 47 |
import com.spice.profitmandi.service.FofoUser;
|
46 |
import com.spice.profitmandi.service.FofoUser;
|
| 48 |
import com.spice.profitmandi.service.NotificationService;
|
47 |
import com.spice.profitmandi.service.NotificationService;
|
| 49 |
import com.spice.profitmandi.service.RbmTargetService;
|
48 |
import com.spice.profitmandi.service.RbmTargetService;
|
| 50 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
49 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 51 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
50 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
| Line 251... |
Line 250... |
| 251 |
BrandsService brandsService;
|
250 |
BrandsService brandsService;
|
| 252 |
|
251 |
|
| 253 |
@Autowired
|
252 |
@Autowired
|
| 254 |
SDCreditRequirementRepository sdCreditRequirementRepository;
|
253 |
SDCreditRequirementRepository sdCreditRequirementRepository;
|
| 255 |
|
254 |
|
| - |
|
255 |
@Autowired
|
| - |
|
256 |
CategorisedCatalogRepository categorisedCatalogRepository;
|
| - |
|
257 |
|
| 256 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
258 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
| 257 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
|
259 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
|
| 258 |
@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
|
260 |
@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
|
| 259 |
if (fofoId == 0) {
|
261 |
if (fofoId == 0) {
|
| 260 |
|
262 |
|
| Line 2356... |
Line 2358... |
| 2356 |
}
|
2358 |
}
|
| 2357 |
|
2359 |
|
| 2358 |
return responseSender.ok(inStockItemDetailModels);
|
2360 |
return responseSender.ok(inStockItemDetailModels);
|
| 2359 |
}
|
2361 |
}
|
| 2360 |
|
2362 |
|
| - |
|
2363 |
@RequestMapping(value = "/indent/getOurStockDetails", method = RequestMethod.GET)
|
| - |
|
2364 |
public ResponseEntity<?> getOurStockDetails(HttpServletRequest request, @RequestParam int catalogId, @RequestParam int warehouseId, Model model)
|
| - |
|
2365 |
throws Exception {
|
| - |
|
2366 |
try {
|
| - |
|
2367 |
// Get all items by catalogId
|
| - |
|
2368 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
|
| - |
|
2369 |
List<Integer> itemIds = items.stream().map(Item::getId).collect(Collectors.toList());
|
| - |
|
2370 |
|
| - |
|
2371 |
if (itemIds.isEmpty()) {
|
| - |
|
2372 |
return responseSender.ok(Collections.emptyList());
|
| - |
|
2373 |
}
|
| - |
|
2374 |
|
| - |
|
2375 |
// Get saholic stock for these items
|
| - |
|
2376 |
Map<Integer, List<WarehouseItemQtyModel>> stockMap = saholicInventoryService.getSaholicStock(warehouseId, itemIds);
|
| - |
|
2377 |
|
| - |
|
2378 |
// Build result with item description and qty where netAvailability > 0
|
| - |
|
2379 |
List<Map<String, Object>> result = new ArrayList<>();
|
| - |
|
2380 |
for (Item item : items) {
|
| - |
|
2381 |
List<WarehouseItemQtyModel> stockList = stockMap.get(item.getId());
|
| - |
|
2382 |
if (stockList != null && !stockList.isEmpty()) {
|
| - |
|
2383 |
int totalNetAvailability = stockList.stream()
|
| - |
|
2384 |
.mapToInt(WarehouseItemQtyModel::getNetAvailability)
|
| - |
|
2385 |
.sum();
|
| - |
|
2386 |
if (totalNetAvailability > 0) {
|
| - |
|
2387 |
Map<String, Object> itemDetail = new HashMap<>();
|
| - |
|
2388 |
itemDetail.put("itemId", item.getId());
|
| - |
|
2389 |
itemDetail.put("color", item.getColor());
|
| - |
|
2390 |
itemDetail.put("itemDescription", item.getItemDescription());
|
| - |
|
2391 |
itemDetail.put("qty", totalNetAvailability);
|
| - |
|
2392 |
result.add(itemDetail);
|
| - |
|
2393 |
}
|
| - |
|
2394 |
}
|
| - |
|
2395 |
}
|
| - |
|
2396 |
|
| - |
|
2397 |
return responseSender.ok(result);
|
| - |
|
2398 |
} catch (Exception e) {
|
| - |
|
2399 |
LOGGER.error("Error getting our stock details for catalogId: {} warehouseId: {}", catalogId, warehouseId, e);
|
| - |
|
2400 |
return responseSender.ok(Collections.emptyList());
|
| - |
|
2401 |
}
|
| - |
|
2402 |
}
|
| - |
|
2403 |
|
| - |
|
2404 |
@RequestMapping(value = "/indent/getOutOfStockDetails", method = RequestMethod.GET)
|
| - |
|
2405 |
public ResponseEntity<?> getOutOfStockDetails(HttpServletRequest request, @RequestParam String brand, @RequestParam int warehouseId, Model model) throws Exception {
|
| - |
|
2406 |
try {
|
| - |
|
2407 |
// Get all catalogs for the brand with their movement status
|
| - |
|
2408 |
List<CategorisedCatalogListModel> catalogMovements = categorisedCatalogRepository.getBrandWiseCatalogMovement(brand);
|
| - |
|
2409 |
|
| - |
|
2410 |
// Filter only HID, FASTMOVING, RUNNING status
|
| - |
|
2411 |
Set<CatalogMovingEnum> validStatuses = new HashSet<>(Arrays.asList(
|
| - |
|
2412 |
CatalogMovingEnum.HID, CatalogMovingEnum.FASTMOVING, CatalogMovingEnum.RUNNING));
|
| - |
|
2413 |
|
| - |
|
2414 |
List<CategorisedCatalogListModel> filteredCatalogs = catalogMovements.stream()
|
| - |
|
2415 |
.filter(c -> validStatuses.contains(c.getCurrentStatus()))
|
| - |
|
2416 |
.collect(Collectors.toList());
|
| - |
|
2417 |
|
| - |
|
2418 |
if (filteredCatalogs.isEmpty()) {
|
| - |
|
2419 |
return responseSender.ok(Collections.emptyList());
|
| - |
|
2420 |
}
|
| - |
|
2421 |
|
| - |
|
2422 |
List<Map<String, Object>> result = new ArrayList<>();
|
| - |
|
2423 |
|
| - |
|
2424 |
for (CategorisedCatalogListModel catalogModel : filteredCatalogs) {
|
| - |
|
2425 |
int catalogId = catalogModel.getModelId();
|
| - |
|
2426 |
|
| - |
|
2427 |
// Get all items for this catalog
|
| - |
|
2428 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
|
| - |
|
2429 |
List<Integer> itemIds = items.stream().map(Item::getId).collect(Collectors.toList());
|
| - |
|
2430 |
|
| - |
|
2431 |
if (itemIds.isEmpty()) {
|
| - |
|
2432 |
// No items means out of stock for this model
|
| - |
|
2433 |
Map<String, Object> itemDetail = new HashMap<>();
|
| - |
|
2434 |
itemDetail.put("catalogId", catalogId);
|
| - |
|
2435 |
itemDetail.put("modelNumber", catalogModel.getModelNumber());
|
| - |
|
2436 |
itemDetail.put("status", catalogModel.getCurrentStatus().getValue());
|
| - |
|
2437 |
itemDetail.put("qty", 0);
|
| - |
|
2438 |
result.add(itemDetail);
|
| - |
|
2439 |
continue;
|
| - |
|
2440 |
}
|
| - |
|
2441 |
|
| - |
|
2442 |
// Get saholic stock for these items
|
| - |
|
2443 |
Map<Integer, List<WarehouseItemQtyModel>> stockMap = saholicInventoryService.getSaholicStock(warehouseId, itemIds);
|
| - |
|
2444 |
|
| - |
|
2445 |
// Calculate total net availability for this catalog
|
| - |
|
2446 |
int totalNetAvailability = 0;
|
| - |
|
2447 |
for (Item item : items) {
|
| - |
|
2448 |
List<WarehouseItemQtyModel> stockList = stockMap.get(item.getId());
|
| - |
|
2449 |
if (stockList != null && !stockList.isEmpty()) {
|
| - |
|
2450 |
totalNetAvailability += stockList.stream()
|
| - |
|
2451 |
.mapToInt(WarehouseItemQtyModel::getNetAvailability)
|
| - |
|
2452 |
.sum();
|
| - |
|
2453 |
}
|
| - |
|
2454 |
}
|
| - |
|
2455 |
|
| - |
|
2456 |
// Only include if out of stock (netAvailability <= 0)
|
| - |
|
2457 |
if (totalNetAvailability <= 0) {
|
| - |
|
2458 |
Map<String, Object> itemDetail = new HashMap<>();
|
| - |
|
2459 |
itemDetail.put("catalogId", catalogId);
|
| - |
|
2460 |
itemDetail.put("modelNumber", catalogModel.getModelNumber());
|
| - |
|
2461 |
itemDetail.put("status", catalogModel.getCurrentStatus().getValue());
|
| - |
|
2462 |
itemDetail.put("qty", totalNetAvailability);
|
| - |
|
2463 |
result.add(itemDetail);
|
| - |
|
2464 |
}
|
| - |
|
2465 |
}
|
| - |
|
2466 |
|
| - |
|
2467 |
return responseSender.ok(result);
|
| - |
|
2468 |
} catch (Exception e) {
|
| - |
|
2469 |
LOGGER.error("Error getting out of stock details for brand: {} warehouseId: {}", brand, warehouseId, e);
|
| - |
|
2470 |
return responseSender.ok(Collections.emptyList());
|
| - |
|
2471 |
}
|
| - |
|
2472 |
}
|
| - |
|
2473 |
|
| 2361 |
@Autowired
|
2474 |
@Autowired
|
| 2362 |
FofoOpeningStockRepository fofoOpeningStockRepository;
|
2475 |
FofoOpeningStockRepository fofoOpeningStockRepository;
|
| 2363 |
|
2476 |
|
| 2364 |
@RequestMapping(value = "/getPartnerShortageStock", method = RequestMethod.GET)
|
2477 |
@RequestMapping(value = "/getPartnerShortageStock", method = RequestMethod.GET)
|
| 2365 |
public String getPartnerShortageStock(HttpServletRequest request,
|
2478 |
public String getPartnerShortageStock(HttpServletRequest request,
|