From 890051c9ca5f49130b2dcbd0bf82dc68b7962aac Mon Sep 17 00:00:00 2001 From: zhouz <> Date: Tue, 13 Oct 2026 09:11:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E6=95=B0=E6=8D=AE=E5=8F=A3=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../groupplate/GroupPlateServiceImpl.java | 12 +++++- .../CurrentInventoryReportMapper.xml | 14 +++++-- sql/mysql/wms_current_inventory_report.sql | 41 +++++++++++++++---- 3 files changed, 56 insertions(+), 11 deletions(-) diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/groupplate/GroupPlateServiceImpl.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/groupplate/GroupPlateServiceImpl.java index 88fa1077..1f6e08d4 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/groupplate/GroupPlateServiceImpl.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/groupplate/GroupPlateServiceImpl.java @@ -13,6 +13,7 @@ import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; +import java.time.LocalDateTime; import java.util.List; import static cn.code.nl.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -35,6 +36,9 @@ public class GroupPlateServiceImpl implements GroupPlateService { public Long createGroupPlate(GroupPlateSaveReqVO createReqVO) { // 插入 GroupPlateDO groupPlate = BeanUtils.toBean(createReqVO, GroupPlateDO.class); + if ("02".equals(groupPlate.getStatus())) { + groupPlate.setInboundTime(LocalDateTime.now()); + } groupPlateMapper.insert(groupPlate); // 返回 @@ -46,9 +50,15 @@ public class GroupPlateServiceImpl implements GroupPlateService { success = WMS_GROUP_PLATE_SUCCESS) public void updateGroupPlate(GroupPlateSaveReqVO updateReqVO) { // 校验存在 - validateGroupPlateExists(updateReqVO.getGroupId()); + GroupPlateDO existing = groupPlateMapper.selectById(updateReqVO.getGroupId()); + if (existing == null) { + throw exception(GROUP_PLATE_NOT_EXISTS); + } // 更新 GroupPlateDO updateObj = BeanUtils.toBean(updateReqVO, GroupPlateDO.class); + if (!"02".equals(existing.getStatus()) && "02".equals(updateObj.getStatus())) { + updateObj.setInboundTime(LocalDateTime.now()); + } groupPlateMapper.updateById(updateObj); LogRecordContext.putVariable("loginUserNickname", SecurityFrameworkUtils.getLoginUserNickname()); LogRecordContext.putVariable("group", updateObj); diff --git a/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/inventoryreport/CurrentInventoryReportMapper.xml b/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/inventoryreport/CurrentInventoryReportMapper.xml index 02a6c324..a2850cd6 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/inventoryreport/CurrentInventoryReportMapper.xml +++ b/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/inventoryreport/CurrentInventoryReportMapper.xml @@ -16,9 +16,17 @@ gp.inbound_time, gp.frozen_qty FROM wms_group_plate gp - INNER JOIN wms_structattr sa - ON sa.storagevehicle_code = gp.vehicle_code - AND sa.deleted = b'0' + INNER JOIN ( + SELECT storagevehicle_code, MIN(struct_id) AS struct_id + FROM wms_structattr + WHERE deleted = b'0' + AND is_used = b'1' + AND inventory_type = '1' + AND storagevehicle_code IS NOT NULL + AND storagevehicle_code != '' + GROUP BY storagevehicle_code + ) current_location ON current_location.storagevehicle_code = gp.vehicle_code + INNER JOIN wms_structattr sa ON sa.struct_id = current_location.struct_id WHERE gp.status = '02' AND gp.deleted = b'0' diff --git a/sql/mysql/wms_current_inventory_report.sql b/sql/mysql/wms_current_inventory_report.sql index c5750f38..e959999c 100644 --- a/sql/mysql/wms_current_inventory_report.sql +++ b/sql/mysql/wms_current_inventory_report.sql @@ -14,21 +14,26 @@ PREPARE add_inbound_time_stmt FROM @add_inbound_time_sql; EXECUTE add_inbound_time_stmt; DEALLOCATE PREPARE add_inbound_time_stmt; --- 2. 仅使用已完成入库单的最近确认时间回填当前库存;无法可靠匹配的数据保持为空。 +-- 2. 仅按组盘标识匹配唯一一张已完成入库单;多轮或无法匹配的数据保持为空。 UPDATE wms_group_plate gp INNER JOIN ( - SELECT dis.storagevehicle_code, MAX(inv.confirm_time) AS inbound_time - FROM wms_iostorinvdis dis + SELECT CAST(dtl.source_billdtl_id AS UNSIGNED) AS group_id, + MAX(inv.confirm_time) AS inbound_time + FROM wms_iostorinvdtl dtl + INNER JOIN wms_iostorinvdis dis + ON dis.iostorinvdtl_id = CAST(dtl.iostorinvdtl_id AS CHAR) + AND dis.work_status = '99' INNER JOIN wms_iostorinv inv ON inv.iostorinv_id = CAST(dis.iostorinv_id AS UNSIGNED) AND inv.io_type = '0' AND inv.bill_status = '99' AND inv.deleted = b'0' - WHERE dis.storagevehicle_code IS NOT NULL - AND dis.storagevehicle_code != '' + WHERE dtl.deleted = b'0' + AND dtl.source_billdtl_id REGEXP '^[0-9]+$' AND inv.confirm_time IS NOT NULL - GROUP BY dis.storagevehicle_code -) latest_inbound ON latest_inbound.storagevehicle_code = gp.vehicle_code + GROUP BY CAST(dtl.source_billdtl_id AS UNSIGNED) + HAVING COUNT(DISTINCT inv.iostorinv_id) = 1 +) latest_inbound ON latest_inbound.group_id = gp.group_id SET gp.inbound_time = latest_inbound.inbound_time WHERE gp.status = '02' AND gp.deleted = b'0' @@ -40,6 +45,28 @@ SELECT COUNT(*) AS current_inventory_without_inbound_time AND deleted = b'0' AND inbound_time IS NULL; +SELECT COUNT(*) AS current_inventory_with_multiple_completed_inbounds + FROM ( + SELECT dtl.source_billdtl_id + FROM wms_iostorinvdtl dtl + INNER JOIN wms_iostorinvdis dis + ON dis.iostorinvdtl_id = CAST(dtl.iostorinvdtl_id AS CHAR) + AND dis.work_status = '99' + INNER JOIN wms_iostorinv inv + ON inv.iostorinv_id = CAST(dis.iostorinv_id AS UNSIGNED) + AND inv.io_type = '0' + AND inv.bill_status = '99' + AND inv.deleted = b'0' + INNER JOIN wms_group_plate gp + ON gp.group_id = CAST(dtl.source_billdtl_id AS UNSIGNED) + AND gp.status = '02' + AND gp.deleted = b'0' + WHERE dtl.deleted = b'0' + AND dtl.source_billdtl_id REGEXP '^[0-9]+$' + GROUP BY dtl.source_billdtl_id + HAVING COUNT(DISTINCT inv.iostorinv_id) > 1 + ) conflicts; + -- 3. 在报表管理下新增库存查询菜单。 SET @report_menu_id = ( SELECT id