| | |
| | | List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectProduct(); |
| | | Map<String, SalesLedgerProduct> productMap = new HashMap<>(); |
| | | for (SalesLedgerProduct product : salesLedgerProducts) { |
| | | // 使用产品类别和规格型号作为键 |
| | | String key = product.getProductCategory() + "|" + product.getSpecificationModel(); |
| | | // 使用产品名称 + 规格型号 + 厚度作为键 |
| | | String key = buildProductKey(product.getProductCategory(), product.getSpecificationModel(), product.getThickness()); |
| | | productMap.put(key, product); |
| | | } |
| | | |
| | |
| | | |
| | | for (StockInventoryExportData dto : list) { |
| | | // 构建查找键 |
| | | String key = dto.getProductName() + "|" + dto.getModel(); |
| | | String key = buildProductKey(dto.getProductName(), dto.getModel(), dto.getThickness()); |
| | | SalesLedgerProduct matchedProduct = productMap.get(key); |
| | | |
| | | if (matchedProduct != null) { |
| | |
| | | } |
| | | } else { |
| | | // 记录未匹配的产品 |
| | | String unmatchedRecord = "产品名称:" + dto.getProductName() + ",型号:" + dto.getModel(); |
| | | String unmatchedRecord = "产品名称:" + dto.getProductName() + ",型号:" + dto.getModel() + ",厚度:" + normalizeThickness(dto.getThickness()); |
| | | unmatchedRecords.add(unmatchedRecord); |
| | | } |
| | | } |
| | |
| | | stockInventory.setLockedQuantity(stockInventory.getLockedQuantity().subtract(stockInventoryDto.getLockedQuantity())); |
| | | return this.updateById(stockInventory); |
| | | } |
| | | |
| | | private String buildProductKey(String productName, String model, BigDecimal thickness) { |
| | | String safeProductName = productName == null ? "" : productName.trim(); |
| | | String safeModel = model == null ? "" : model.trim(); |
| | | return safeProductName + "|" + safeModel + "|" + normalizeThickness(thickness); |
| | | } |
| | | |
| | | private String normalizeThickness(BigDecimal thickness) { |
| | | if (thickness == null) { |
| | | return ""; |
| | | } |
| | | return thickness.stripTrailingZeros().toPlainString(); |
| | | } |
| | | } |