liding
2 天以前 9bad4cfca9b9f51f433bf0caf5b5d166d1fc55a7
src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
@@ -34,6 +34,8 @@
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
@@ -59,6 +61,7 @@
    private ProductMapper productMapper;
    @Autowired
    private ProductModelMapper productModelMapper;
    private static final DateTimeFormatter YYYYMMDD_FORMAT = DateTimeFormatter.ofPattern("yyyyMMdd");
    @Override
@@ -99,6 +102,7 @@
            newStockInventory.setWarnNum(stockInventoryDto.getWarnNum());
            newStockInventory.setBatchNo(stockInventoryDto.getBatchNo());
            newStockInventory.setCustomer(stockInventoryDto.getCustomer());
            newStockInventory.setProductionDate(stockInventoryDto.getProductionDate());
            stockInventoryMapper.insert(newStockInventory);
        }else {
             stockInventoryMapper.updateAddStockInventory(stockInventoryDto);
@@ -148,7 +152,7 @@
            // 查询所有的产品
            List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectProduct();
            ExcelUtil<StockInventoryExportData> util = new ExcelUtil<StockInventoryExportData>(StockInventoryExportData.class);
            ExcelUtil<StockInventoryExportData> util = new ExcelUtil<>(StockInventoryExportData.class);
            List<StockInventoryExportData> list = util.importExcel(file.getInputStream());
            // 记录未找到匹配项的数据
@@ -158,7 +162,8 @@
                boolean matched = false;
                for (SalesLedgerProduct item : salesLedgerProducts) {
                    if (item.getProductCategory().equals(dto.getProductName()) &&
                            item.getSpecificationModel().equals(dto.getModel())) {
                            item.getSpecificationModel().equals(dto.getModel()) &&
                            item.getUidNo().equals(dto.getUidNo())) {
                        StockInventoryDto stockInventoryDto = new StockInventoryDto();
                        stockInventoryDto.setRecordId(0L);
                        stockInventoryDto.setRecordType(StockInQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_IN.getCode());
@@ -170,6 +175,14 @@
                        }
                        stockInventoryDto.setLockedQuantity(dto.getLockedQuantity());
                        stockInventoryDto.setProductModelId(item.getProductModelId());
                        stockInventoryDto.setBatchNo(dto.getBatchNo());
                        stockInventoryDto.setCustomer(dto.getCustomer());
                        String productionDate = dto.getProductionDate();
                        if (productionDate != null && productionDate.length() == 8) {
                            stockInventoryDto.setProductionDate(LocalDate.parse(productionDate, YYYYMMDD_FORMAT));
                        } else {
                            stockInventoryDto.setProductionDate(null);
                        }
                        this.addstockInventory(stockInventoryDto);
                        matched = true;
                        break; // 找到匹配项后跳出循环
@@ -177,8 +190,8 @@
                }
                if (!matched) {
                    // 记录未匹配的数据
                    String unmatchedInfo = String.format("产品名称:%s,规格型号:%s",
                            dto.getProductName(), dto.getModel());
                    String unmatchedInfo = String.format("产品名称:%s,规格型号:%s,UID码:%s",
                            dto.getProductName(), dto.getModel(),dto.getUidNo());
                    unmatchedRecords.add(unmatchedInfo);
                }
            });
@@ -386,6 +399,8 @@
        String customer = StringUtils.isBlank(stock.getCustomer()) ? "无客户" : stock.getCustomer();
        customerNode.setCustomer(customer);
        customerNode.setLabel(customer);
        customerNode.setProductionDate(stock.getProductionDate());
        customerNode.setValidityPeriod(stock.getValidityPeriod());
        customerNode.setNodeType("customer");
        customerNode.setChildren(new ArrayList<>());