fix: 完善库存报表数据口径
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user