| Line 5... |
Line 5... |
| 5 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
5 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 6 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
6 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 7 |
import com.spice.profitmandi.common.model.*;
|
7 |
import com.spice.profitmandi.common.model.*;
|
| 8 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
8 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 9 |
import com.spice.profitmandi.common.util.PdfUtils;
|
9 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| 10 |
import com.spice.profitmandi.common.util.Utils;
|
- |
|
| 11 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
10 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
| 12 |
import com.spice.profitmandi.common.web.client.RestClient;
|
11 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 13 |
import com.spice.profitmandi.service.mail.MailOutboxService;
|
- |
|
| 14 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
12 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 15 |
import com.spice.profitmandi.dao.entity.catalog.*;
|
13 |
import com.spice.profitmandi.dao.entity.catalog.*;
|
| 16 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
14 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 17 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
15 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
| 18 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
16 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| Line 45... |
Line 43... |
| 45 |
import com.spice.profitmandi.service.catalog.ComboService;
|
43 |
import com.spice.profitmandi.service.catalog.ComboService;
|
| 46 |
import com.spice.profitmandi.service.inventory.Combo;
|
44 |
import com.spice.profitmandi.service.inventory.Combo;
|
| 47 |
import com.spice.profitmandi.service.inventory.ComboOptionModel;
|
45 |
import com.spice.profitmandi.service.inventory.ComboOptionModel;
|
| 48 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
46 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 49 |
import com.spice.profitmandi.service.inventory.MappedComboModel;
|
47 |
import com.spice.profitmandi.service.inventory.MappedComboModel;
|
| - |
|
48 |
import com.spice.profitmandi.service.mail.MailOutboxService;
|
| 50 |
import com.spice.profitmandi.service.order.OrderService;
|
49 |
import com.spice.profitmandi.service.order.OrderService;
|
| 51 |
import com.spice.profitmandi.service.transaction.SDCreditService;
|
50 |
import com.spice.profitmandi.service.transaction.SDCreditService;
|
| 52 |
import com.spice.profitmandi.service.user.RetailerService;
|
51 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 53 |
import com.spice.profitmandi.web.model.LoginDetails;
|
52 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 54 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
53 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| Line 109... |
Line 108... |
| 109 |
|
108 |
|
| 110 |
@Autowired
|
109 |
@Autowired
|
| 111 |
private CookiesProcessor cookiesProcessor;
|
110 |
private CookiesProcessor cookiesProcessor;
|
| 112 |
|
111 |
|
| 113 |
@Autowired
|
112 |
@Autowired
|
| - |
|
113 |
private BrandsRepository brandsRepository;
|
| - |
|
114 |
|
| - |
|
115 |
@Autowired
|
| 114 |
@Qualifier("fofoInventoryService")
|
116 |
@Qualifier("fofoInventoryService")
|
| 115 |
private InventoryService inventoryService;
|
117 |
private InventoryService inventoryService;
|
| 116 |
|
118 |
|
| 117 |
@Autowired
|
119 |
@Autowired
|
| 118 |
TagListingRepository tagListingRepository;
|
120 |
TagListingRepository tagListingRepository;
|
| Line 1482... |
Line 1484... |
| 1482 |
|
1484 |
|
| 1483 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
1485 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 1484 |
if (warehouseIds.contains(0)) {
|
1486 |
if (warehouseIds.contains(0)) {
|
| 1485 |
warehouseIds.addAll(warehouseMap.keySet());
|
1487 |
warehouseIds.addAll(warehouseMap.keySet());
|
| 1486 |
}
|
1488 |
}
|
| - |
|
1489 |
// Band-aid for URL '+' decode issue on brand names (e.g. "Ai+"):
|
| - |
|
1490 |
// if a brand doesn't exist in catalog.brand as-is but "<brand>+" does,
|
| - |
|
1491 |
// switch to the plus variant. Zero regression for the other brands.
|
| - |
|
1492 |
brand = brand.stream().map(b -> {
|
| - |
|
1493 |
if (b == null || b.trim().isEmpty()) return b;
|
| - |
|
1494 |
String probe = b.replaceAll("\\s+$", "");
|
| - |
|
1495 |
try {
|
| - |
|
1496 |
if (brandsRepository.selectByBrand(b) == null
|
| - |
|
1497 |
&& (probe.equals(b) || brandsRepository.selectByBrand(probe) == null)) {
|
| - |
|
1498 |
String withPlus = probe + "+";
|
| - |
|
1499 |
if (brandsRepository.selectByBrand(withPlus) != null) {
|
| - |
|
1500 |
LOGGER.info("getOpenPoItemByBrand brand fallback: '{}' -> '{}'", b, withPlus);
|
| - |
|
1501 |
return withPlus;
|
| - |
|
1502 |
}
|
| - |
|
1503 |
}
|
| - |
|
1504 |
} catch (Exception e) {
|
| - |
|
1505 |
LOGGER.warn("getOpenPoItemByBrand brand fallback failed for '{}': {}", b, e.getMessage());
|
| - |
|
1506 |
}
|
| - |
|
1507 |
return b;
|
| - |
|
1508 |
}).collect(Collectors.toList());
|
| 1487 |
LOGGER.info("brand" + brand);
|
1509 |
LOGGER.info("brand" + brand);
|
| 1488 |
|
1510 |
|
| 1489 |
if (brand.contains("Total Values")) {
|
1511 |
if (brand.contains("Total Values")) {
|
| 1490 |
List<String> poBrands = warehousePurchaseOrderRepository.selectOpenPo(warehouseIds).stream().map(x -> x.getBrand()).collect(Collectors.toList());
|
1512 |
List<String> poBrands = warehousePurchaseOrderRepository.selectOpenPo(warehouseIds).stream().map(x -> x.getBrand()).collect(Collectors.toList());
|
| 1491 |
|
1513 |
|
| Line 1515... |
Line 1537... |
| 1515 |
|
1537 |
|
| 1516 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
1538 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 1517 |
if (warehouseIds.contains(0)) {
|
1539 |
if (warehouseIds.contains(0)) {
|
| 1518 |
warehouseIds.addAll(warehouseMap.keySet());
|
1540 |
warehouseIds.addAll(warehouseMap.keySet());
|
| 1519 |
}
|
1541 |
}
|
| - |
|
1542 |
// Band-aid for URL '+' decode issue on brand names (e.g. "Ai+"):
|
| - |
|
1543 |
// if a brand doesn't exist in catalog.brand as-is but "<brand>+" does,
|
| - |
|
1544 |
// switch to the plus variant. Zero regression for the other brands.
|
| - |
|
1545 |
brand = brand.stream().map(b -> {
|
| - |
|
1546 |
if (b == null || b.trim().isEmpty()) return b;
|
| - |
|
1547 |
String probe = b.replaceAll("\\s+$", "");
|
| - |
|
1548 |
try {
|
| - |
|
1549 |
if (brandsRepository.selectByBrand(b) == null
|
| - |
|
1550 |
&& (probe.equals(b) || brandsRepository.selectByBrand(probe) == null)) {
|
| - |
|
1551 |
String withPlus = probe + "+";
|
| - |
|
1552 |
if (brandsRepository.selectByBrand(withPlus) != null) {
|
| - |
|
1553 |
LOGGER.info("getOurPurchaseItemByBrand brand fallback: '{}' -> '{}'", b, withPlus);
|
| - |
|
1554 |
return withPlus;
|
| - |
|
1555 |
}
|
| - |
|
1556 |
}
|
| - |
|
1557 |
} catch (Exception e) {
|
| - |
|
1558 |
LOGGER.warn("getOurPurchaseItemByBrand brand fallback failed for '{}': {}", b, e.getMessage());
|
| - |
|
1559 |
}
|
| - |
|
1560 |
return b;
|
| - |
|
1561 |
}).collect(Collectors.toList());
|
| 1520 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
1562 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 1521 |
|
1563 |
|
| 1522 |
if (brand.contains("Total Values")) {
|
1564 |
if (brand.contains("Total Values")) {
|
| 1523 |
List<String> purchasebrands = warehouseScanRepository.selectOurPurchase(warehouseIds).stream().map(x -> x.getBrand()).collect(Collectors.toList());
|
1565 |
List<String> purchasebrands = warehouseScanRepository.selectOurPurchase(warehouseIds).stream().map(x -> x.getBrand()).collect(Collectors.toList());
|
| 1524 |
|
1566 |
|
| Line 1550... |
Line 1592... |
| 1550 |
}
|
1592 |
}
|
| 1551 |
|
1593 |
|
| 1552 |
@RequestMapping(value = "/getWarehouseWiseSecondaryBillingByBrand", method = RequestMethod.GET)
|
1594 |
@RequestMapping(value = "/getWarehouseWiseSecondaryBillingByBrand", method = RequestMethod.GET)
|
| 1553 |
public String getWarehouseWiseSecondaryBillingByBrand(HttpServletRequest request, @RequestParam(name = "brand", required = true, defaultValue = "") String brand, int timeValue, Model model) throws Exception {
|
1595 |
public String getWarehouseWiseSecondaryBillingByBrand(HttpServletRequest request, @RequestParam(name = "brand", required = true, defaultValue = "") String brand, int timeValue, Model model) throws Exception {
|
| 1554 |
|
1596 |
|
| - |
|
1597 |
// Band-aid for URL '+' decode issue on brand names (e.g. "Ai+"):
|
| - |
|
1598 |
// if the incoming brand isn't found in catalog.brand but "<brand>+" is,
|
| - |
|
1599 |
// switch to the plus variant. Zero regression for the other brands.
|
| - |
|
1600 |
if (brand != null && !brand.trim().isEmpty()) {
|
| - |
|
1601 |
String probe = brand.replaceAll("\\s+$", "");
|
| - |
|
1602 |
try {
|
| - |
|
1603 |
if (brandsRepository.selectByBrand(brand) == null
|
| - |
|
1604 |
&& (probe.equals(brand) || brandsRepository.selectByBrand(probe) == null)) {
|
| - |
|
1605 |
String withPlus = probe + "+";
|
| - |
|
1606 |
if (brandsRepository.selectByBrand(withPlus) != null) {
|
| - |
|
1607 |
LOGGER.info("getWarehouseWiseSecondaryBillingByBrand brand fallback: '{}' -> '{}'", brand, withPlus);
|
| - |
|
1608 |
brand = withPlus;
|
| - |
|
1609 |
}
|
| - |
|
1610 |
}
|
| - |
|
1611 |
} catch (Exception e) {
|
| - |
|
1612 |
LOGGER.warn("getWarehouseWiseSecondaryBillingByBrand brand fallback failed for '{}': {}", brand, e.getMessage());
|
| - |
|
1613 |
}
|
| - |
|
1614 |
}
|
| - |
|
1615 |
|
| 1555 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
1616 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 1556 |
int dayOfMonth = curDate.getDayOfMonth();
|
1617 |
int dayOfMonth = curDate.getDayOfMonth();
|
| 1557 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1);
|
1618 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1);
|
| 1558 |
int lengthOfMonth = YearMonth.from(startOfMonth.minusMonths(1)).lengthOfMonth();
|
1619 |
int lengthOfMonth = YearMonth.from(startOfMonth.minusMonths(1)).lengthOfMonth();
|
| 1559 |
|
1620 |
|
| Line 1651... |
Line 1712... |
| 1651 |
|
1712 |
|
| 1652 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
1713 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 1653 |
if (warehouseIds.contains(0)) {
|
1714 |
if (warehouseIds.contains(0)) {
|
| 1654 |
warehouseIds.addAll(warehouseMap.keySet());
|
1715 |
warehouseIds.addAll(warehouseMap.keySet());
|
| 1655 |
}
|
1716 |
}
|
| - |
|
1717 |
// Band-aid for URL '+' decode issue on brand names (e.g. "Ai+"):
|
| - |
|
1718 |
// if a brand doesn't exist in catalog.brand as-is but "<brand>+" does,
|
| - |
|
1719 |
// switch to the plus variant. Zero regression for the other brands.
|
| - |
|
1720 |
brand = brand.stream().map(b -> {
|
| - |
|
1721 |
if (b == null || b.trim().isEmpty()) return b;
|
| - |
|
1722 |
String probe = b.replaceAll("\\s+$", "");
|
| - |
|
1723 |
try {
|
| - |
|
1724 |
if (brandsRepository.selectByBrand(b) == null
|
| - |
|
1725 |
&& (probe.equals(b) || brandsRepository.selectByBrand(probe) == null)) {
|
| - |
|
1726 |
String withPlus = probe + "+";
|
| - |
|
1727 |
if (brandsRepository.selectByBrand(withPlus) != null) {
|
| - |
|
1728 |
LOGGER.info("getPartnerTertiaryItemByBrand brand fallback: '{}' -> '{}'", b, withPlus);
|
| - |
|
1729 |
return withPlus;
|
| - |
|
1730 |
}
|
| - |
|
1731 |
}
|
| - |
|
1732 |
} catch (Exception e) {
|
| - |
|
1733 |
LOGGER.warn("getPartnerTertiaryItemByBrand brand fallback failed for '{}': {}", b, e.getMessage());
|
| - |
|
1734 |
}
|
| - |
|
1735 |
return b;
|
| - |
|
1736 |
}).collect(Collectors.toList());
|
| 1656 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
1737 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 1657 |
int dayOfMonth = curDate.getDayOfMonth();
|
1738 |
int dayOfMonth = curDate.getDayOfMonth();
|
| 1658 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1);
|
1739 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1);
|
| 1659 |
int lengthOfMonth = YearMonth.from(startOfMonth.minusMonths(1)).lengthOfMonth();
|
1740 |
int lengthOfMonth = YearMonth.from(startOfMonth.minusMonths(1)).lengthOfMonth();
|
| 1660 |
if (brand.contains("Total Values")) {
|
1741 |
if (brand.contains("Total Values")) {
|