| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| - |
|
3 |
import com.spice.profitmandi.service.warehouse.BillingWarehouseService;
|
| - |
|
4 |
|
| 3 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
5 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
| 4 |
import com.google.gson.Gson;
|
6 |
import com.google.gson.Gson;
|
| 5 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
7 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 6 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
8 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 7 |
import com.spice.profitmandi.common.model.*;
|
9 |
import com.spice.profitmandi.common.model.*;
|
| Line 94... |
Line 96... |
| 94 |
|
96 |
|
| 95 |
@Controller
|
97 |
@Controller
|
| 96 |
@Transactional(rollbackFor = Throwable.class)
|
98 |
@Transactional(rollbackFor = Throwable.class)
|
| 97 |
public class InventoryController {
|
99 |
public class InventoryController {
|
| 98 |
|
100 |
|
| - |
|
101 |
@Autowired
|
| - |
|
102 |
private BillingWarehouseService billingWarehouseService;
|
| - |
|
103 |
|
| - |
|
104 |
|
| 99 |
private static final Logger LOGGER = LogManager.getLogger(InventoryController.class);
|
105 |
private static final Logger LOGGER = LogManager.getLogger(InventoryController.class);
|
| 100 |
|
106 |
|
| 101 |
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d/yyyy H:m:s");
|
107 |
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d/yyyy H:m:s");
|
| 102 |
|
108 |
|
| 103 |
private static final List<String> imeis = Arrays.asList("351030944216680", "351030944217183", "351030944217886", "351030944507286", "351081710231270", "351081710238713", "351081710238796", "351081710241279", "351081710244737", "355777112655976");
|
109 |
private static final List<String> imeis = Arrays.asList("351030944216680", "351030944217183", "351030944217886", "351030944507286", "351081710231270", "351081710238713", "351081710238796", "351081710241279", "351081710244737", "355777112655976");
|
| Line 1341... |
Line 1347... |
| 1341 |
@RequestMapping(value = "/inventory", method = RequestMethod.GET)
|
1347 |
@RequestMapping(value = "/inventory", method = RequestMethod.GET)
|
| 1342 |
public String Inventory(HttpServletRequest request, @RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds, Model model) throws Exception {
|
1348 |
public String Inventory(HttpServletRequest request, @RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds, Model model) throws Exception {
|
| 1343 |
model.addAttribute("warehouseId", warehouseIds);
|
1349 |
model.addAttribute("warehouseId", warehouseIds);
|
| 1344 |
LOGGER.info("warehouseIds" + warehouseIds);
|
1350 |
LOGGER.info("warehouseIds" + warehouseIds);
|
| 1345 |
|
1351 |
|
| 1346 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
1352 |
Map<Integer, String> warehouseMap = billingWarehouseService.getActiveWarehouses();
|
| 1347 |
if (warehouseIds.contains(0)) {
|
1353 |
if (warehouseIds.contains(0)) {
|
| 1348 |
warehouseIds.addAll(warehouseMap.keySet());
|
1354 |
warehouseIds.addAll(warehouseMap.keySet());
|
| 1349 |
}
|
1355 |
}
|
| 1350 |
|
1356 |
|
| 1351 |
long poTodayValue = 0;
|
1357 |
long poTodayValue = 0;
|
| Line 1500... |
Line 1506... |
| 1500 |
@RequestMapping(value = "/getOpenPoItemByBrand", method = RequestMethod.GET)
|
1506 |
@RequestMapping(value = "/getOpenPoItemByBrand", method = RequestMethod.GET)
|
| 1501 |
public String Inventory(HttpServletRequest request, @RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds, @RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue, Model model) throws Exception {
|
1507 |
public String Inventory(HttpServletRequest request, @RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds, @RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue, Model model) throws Exception {
|
| 1502 |
model.addAttribute("warehouseId", warehouseIds);
|
1508 |
model.addAttribute("warehouseId", warehouseIds);
|
| 1503 |
LOGGER.info("warehouseIds" + warehouseIds);
|
1509 |
LOGGER.info("warehouseIds" + warehouseIds);
|
| 1504 |
|
1510 |
|
| 1505 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
1511 |
Map<Integer, String> warehouseMap = billingWarehouseService.getActiveWarehouses();
|
| 1506 |
if (warehouseIds.contains(0)) {
|
1512 |
if (warehouseIds.contains(0)) {
|
| 1507 |
warehouseIds.addAll(warehouseMap.keySet());
|
1513 |
warehouseIds.addAll(warehouseMap.keySet());
|
| 1508 |
}
|
1514 |
}
|
| 1509 |
// Band-aid for URL '+' decode issue on brand names (e.g. "Ai+"):
|
1515 |
// Band-aid for URL '+' decode issue on brand names (e.g. "Ai+"):
|
| 1510 |
// if a brand doesn't exist in catalog.brand as-is but "<brand>+" does,
|
1516 |
// if a brand doesn't exist in catalog.brand as-is but "<brand>+" does,
|
| Line 1553... |
Line 1559... |
| 1553 |
@RequestMapping(value = "/getOurPurchaseItemByBrand", method = RequestMethod.GET)
|
1559 |
@RequestMapping(value = "/getOurPurchaseItemByBrand", method = RequestMethod.GET)
|
| 1554 |
public String getOurPurchaseItemByBrand(HttpServletRequest request, @RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds, @RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue, Model model) throws Exception {
|
1560 |
public String getOurPurchaseItemByBrand(HttpServletRequest request, @RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds, @RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue, Model model) throws Exception {
|
| 1555 |
model.addAttribute("warehouseId", warehouseIds);
|
1561 |
model.addAttribute("warehouseId", warehouseIds);
|
| 1556 |
LOGGER.info("warehouseIds" + warehouseIds);
|
1562 |
LOGGER.info("warehouseIds" + warehouseIds);
|
| 1557 |
|
1563 |
|
| 1558 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
1564 |
Map<Integer, String> warehouseMap = billingWarehouseService.getActiveWarehouses();
|
| 1559 |
if (warehouseIds.contains(0)) {
|
1565 |
if (warehouseIds.contains(0)) {
|
| 1560 |
warehouseIds.addAll(warehouseMap.keySet());
|
1566 |
warehouseIds.addAll(warehouseMap.keySet());
|
| 1561 |
}
|
1567 |
}
|
| 1562 |
// Band-aid for URL '+' decode issue on brand names (e.g. "Ai+"):
|
1568 |
// Band-aid for URL '+' decode issue on brand names (e.g. "Ai+"):
|
| 1563 |
// if a brand doesn't exist in catalog.brand as-is but "<brand>+" does,
|
1569 |
// if a brand doesn't exist in catalog.brand as-is but "<brand>+" does,
|
| Line 1636... |
Line 1642... |
| 1636 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
1642 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 1637 |
int dayOfMonth = curDate.getDayOfMonth();
|
1643 |
int dayOfMonth = curDate.getDayOfMonth();
|
| 1638 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1);
|
1644 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1);
|
| 1639 |
int lengthOfMonth = YearMonth.from(startOfMonth.minusMonths(1)).lengthOfMonth();
|
1645 |
int lengthOfMonth = YearMonth.from(startOfMonth.minusMonths(1)).lengthOfMonth();
|
| 1640 |
|
1646 |
|
| 1641 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
1647 |
Map<Integer, String> warehouseMap = billingWarehouseService.getActiveWarehouses();
|
| 1642 |
SecondaeryOrderDateRange sr = null;
|
1648 |
SecondaeryOrderDateRange sr = null;
|
| 1643 |
if (brand.equals("Total Values")) {
|
1649 |
if (brand.equals("Total Values")) {
|
| 1644 |
brand = null;
|
1650 |
brand = null;
|
| 1645 |
}
|
1651 |
}
|
| 1646 |
if (timeValue != 0) {
|
1652 |
if (timeValue != 0) {
|
| Line 1747... |
Line 1753... |
| 1747 |
@RequestMapping(value = "/getPartnerTertiaryItemByBrand", method = RequestMethod.GET)
|
1753 |
@RequestMapping(value = "/getPartnerTertiaryItemByBrand", method = RequestMethod.GET)
|
| 1748 |
public String getPartnerTertiaryItemByBrand(HttpServletRequest request, @RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds, @RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue, Model model) throws Exception {
|
1754 |
public String getPartnerTertiaryItemByBrand(HttpServletRequest request, @RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds, @RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue, Model model) throws Exception {
|
| 1749 |
model.addAttribute("warehouseId", warehouseIds);
|
1755 |
model.addAttribute("warehouseId", warehouseIds);
|
| 1750 |
LOGGER.info("warehouseIds" + warehouseIds);
|
1756 |
LOGGER.info("warehouseIds" + warehouseIds);
|
| 1751 |
|
1757 |
|
| 1752 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
1758 |
Map<Integer, String> warehouseMap = billingWarehouseService.getActiveWarehouses();
|
| 1753 |
if (warehouseIds.contains(0)) {
|
1759 |
if (warehouseIds.contains(0)) {
|
| 1754 |
warehouseIds.addAll(warehouseMap.keySet());
|
1760 |
warehouseIds.addAll(warehouseMap.keySet());
|
| 1755 |
}
|
1761 |
}
|
| 1756 |
// Band-aid for URL '+' decode issue on brand names (e.g. "Ai+"):
|
1762 |
// Band-aid for URL '+' decode issue on brand names (e.g. "Ai+"):
|
| 1757 |
// if a brand doesn't exist in catalog.brand as-is but "<brand>+" does,
|
1763 |
// if a brand doesn't exist in catalog.brand as-is but "<brand>+" does,
|
| Line 2081... |
Line 2087... |
| 2081 |
}
|
2087 |
}
|
| 2082 |
|
2088 |
|
| 2083 |
@RequestMapping(value = "/createCombo", method = RequestMethod.GET)
|
2089 |
@RequestMapping(value = "/createCombo", method = RequestMethod.GET)
|
| 2084 |
public String createCombo(HttpServletRequest request, Model model) throws Exception {
|
2090 |
public String createCombo(HttpServletRequest request, Model model) throws Exception {
|
| 2085 |
|
2091 |
|
| 2086 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
2092 |
Map<Integer, String> warehouseMap = billingWarehouseService.getOperationalWarehouses();
|
| 2087 |
|
2093 |
|
| 2088 |
|
2094 |
|
| 2089 |
List<ComboModel> comboModels = comboModelRepository.selectAll();
|
2095 |
List<ComboModel> comboModels = comboModelRepository.selectAll();
|
| 2090 |
|
2096 |
|
| 2091 |
model.addAttribute("warehouseMap", warehouseMap);
|
2097 |
model.addAttribute("warehouseMap", warehouseMap);
|
| Line 2097... |
Line 2103... |
| 2097 |
public String addCombo(HttpServletRequest request, @RequestBody Combo combo, Model model) throws Exception {
|
2103 |
public String addCombo(HttpServletRequest request, @RequestBody Combo combo, Model model) throws Exception {
|
| 2098 |
List<Integer> warehouseIds = new ArrayList<Integer>();
|
2104 |
List<Integer> warehouseIds = new ArrayList<Integer>();
|
| 2099 |
|
2105 |
|
| 2100 |
|
2106 |
|
| 2101 |
if (combo.getWarehouseId().isEmpty()) {
|
2107 |
if (combo.getWarehouseId().isEmpty()) {
|
| 2102 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
2108 |
Map<Integer, String> warehouseMap = billingWarehouseService.getOperationalWarehouses();
|
| 2103 |
|
2109 |
|
| 2104 |
warehouseIds.addAll(warehouseMap.entrySet().stream().map(x -> x.getKey()).collect(Collectors.toList()));
|
2110 |
warehouseIds.addAll(warehouseMap.entrySet().stream().map(x -> x.getKey()).collect(Collectors.toList()));
|
| 2105 |
|
2111 |
|
| 2106 |
} else {
|
2112 |
} else {
|
| 2107 |
warehouseIds.addAll(combo.getWarehouseId());
|
2113 |
warehouseIds.addAll(combo.getWarehouseId());
|