fix: improve shadow diagnostic matching

This commit is contained in:
zgw
2026-08-28 11:55:43 +08:00
parent da5a0a1561
commit 3f7ed3718d
9 changed files with 218 additions and 20 deletions

View File

@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectInboundInput" resultType="com.ruoyi.algorithm.shadow.ShadowInboundReference">
select top (1)
job.job_id as requestId,
job.warehouse_id as warehouseId,
job.tray_code as trayNo,
coalesce(nullif(ltrim(rtrim(detail.spare4)), ''),
nullif(ltrim(rtrim(stock.spare4)), '')) as projectNo,
@@ -25,7 +26,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select detail.stockout_detail_id as requestId,
detail.warehouse_id as warehouseId,
nullif(ltrim(rtrim(detail.spare4)), '') as projectNo,
detail.product_id as productId
detail.product_id as productId,
convert(varchar(40), (select max(snapshot.synchronized_at)
from alg.inventory_item_snapshot snapshot
where snapshot.warehouse_id = detail.warehouse_id), 126)
as snapshotSynchronizedAt,
(select count(*)
from bas_stock live
where live.warehouse_id = detail.warehouse_id
and live.stock_status = '1'
and live.product_status = '1'
and live.quantity &gt; live.out_quantity
and (NULLIF(LTRIM(RTRIM(detail.product_id)), '') IS NULL
OR live.product_id = NULLIF(LTRIM(RTRIM(detail.product_id)), ''))) as liveMatchCount,
(select count(*)
from alg.inventory_item_snapshot snapshot
where snapshot.warehouse_id = detail.warehouse_id
and snapshot.project_no = nullif(ltrim(rtrim(detail.spare4)), '')
and (NULLIF(LTRIM(RTRIM(detail.product_id)), '') IS NULL
OR snapshot.product_no = NULLIF(LTRIM(RTRIM(detail.product_id)), '')))
as shadowMatchCount
from out_stockout_detail detail
where detail.stockout_detail_id = #{stockoutDetailId}
</select>
@@ -37,7 +57,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
stock.cargo_space_id as spaceId,
stock.warehouse_id as warehouseId,
nullif(ltrim(rtrim(stock.spare4)), '') as projectNo,
stock.product_id as productId
stock.product_id as productId,
convert(varchar(40), (select max(snapshot.synchronized_at)
from alg.inventory_item_snapshot snapshot
where snapshot.warehouse_id = stock.warehouse_id), 126)
as snapshotSynchronizedAt,
(select count(*)
from bas_stock live
where live.stock_id = stock.stock_id
and live.stock_status = '1'
and live.product_status = '1'
and live.quantity &gt; live.out_quantity) as liveMatchCount,
(select count(*)
from alg.inventory_item_snapshot snapshot
where snapshot.stock_id = stock.stock_id
and snapshot.warehouse_id = stock.warehouse_id) as shadowMatchCount
from bas_stock stock
where stock.stock_id = #{stockId}
and stock.stock_status = '1'