| | |
| | | @Data |
| | | public class StockInventoryExportData { |
| | | |
| | | |
| | | |
| | | @Excel(name = "产品名称") |
| | | private String productName; |
| | | |
| | |
| | | @Excel(name = "单位") |
| | | private String unit; |
| | | |
| | | @Excel(name = "厚度(mm)") |
| | | private BigDecimal thickness; |
| | | |
| | | @Excel(name = "合格库存数量") |
| | | private BigDecimal qualifiedQuantity; |
| | | |
| | |
| | | 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(); |
| | | } |
| | | } |
| | |
| | | MAX(warn_num) as warn_num, |
| | | MAX(version) as version, |
| | | model, |
| | | thickness, |
| | | MAX(remark) as remark, |
| | | unit, |
| | | product_name, |
| | |
| | | si.version, |
| | | (si.qualitity - COALESCE(si.locked_quantity, 0)) as un_locked_quantity, |
| | | pm.model, |
| | | pm.thickness, |
| | | si.remark, |
| | | pm.unit, |
| | | p.product_name, |
| | |
| | | su.version, |
| | | (su.qualitity - COALESCE(su.locked_quantity, 0)) as un_locked_quantity, |
| | | pm.model, |
| | | pm.thickness, |
| | | su.remark, |
| | | pm.unit, |
| | | p.product_name, |
| | |
| | | and combined.product_id in (select id from product_tree) |
| | | </if> |
| | | </where> |
| | | group by product_model_id, model, unit, product_name, product_id |
| | | group by product_model_id, model, thickness, unit, product_name, product_id |
| | | </select> |
| | | <select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockInventoryExportData"> |
| | | WITH RECURSIVE product_tree AS ( |