fix(shadow): align outbound predicates with site data for v3.3
Use the business project and captured site predicates, validate single-stock proposals, and skip unsupported scopes without changing Legacy. Add the guarded V3.3 SQL upgrade, CMD operations, regression tests and deployment runbook.
This commit is contained in:
@@ -25,6 +25,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and input.tray_no = #{trayNo}
|
||||
</select>
|
||||
|
||||
<sql id="outboundCandidatePredicate">
|
||||
item.warehouse_id = #{warehouseId}
|
||||
and item.snapshot_generation = #{generation}
|
||||
and cargo.warehouse_id = item.warehouse_id
|
||||
and cargo.snapshot_generation = item.snapshot_generation
|
||||
and cargo.space_id = item.space_id and cargo.tray_code = item.tray_code
|
||||
and cargo.locked = 'N'
|
||||
and ((cargo.space_status = '2' and item.out_quantity = 0)
|
||||
or (cargo.space_status = '4' and item.quantity > item.out_quantity))
|
||||
and (nullif(input.project_no, '') is null or item.project_no = input.project_no)
|
||||
and (nullif(input.product_id, '') is null or item.product_no = input.product_id)
|
||||
and (nullif(input.spare1, '') is null or item.spare1 = input.spare1)
|
||||
and (nullif(input.spare2, '') is null or item.spare2 = input.spare2)
|
||||
and (nullif(input.spare3, '') is null or item.spare3 = input.spare3)
|
||||
and (nullif(input.voltage, '') is null or item.voltage = input.voltage)
|
||||
and (nullif(input.phase, '') is null or item.phase = input.phase)
|
||||
and not exists (
|
||||
select 1 from alg.active_job_snapshot job
|
||||
where job.warehouse_id = item.warehouse_id
|
||||
and job.snapshot_generation = item.snapshot_generation
|
||||
and job.tray_code = item.tray_code and job.in_or_out = '26')
|
||||
</sql>
|
||||
|
||||
<select id="selectProjectOutboundReference"
|
||||
resultType="com.ruoyi.algorithm.shadow.ShadowStockReference">
|
||||
select top (1)
|
||||
@@ -32,21 +55,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
input.raw_warehouse_id as warehouseId,
|
||||
input.project_no as projectNo,
|
||||
input.product_id as productId,
|
||||
input.requested_quantity as requestedQuantity,
|
||||
input.requested_quantity - input.allocated_quantity as requestedQuantity,
|
||||
input.predicate_version as predicateVersion,
|
||||
input.spare1, input.spare2, input.spare3, input.voltage, input.phase,
|
||||
convert(varchar(40), input.synchronized_at, 126) as snapshotSynchronizedAt,
|
||||
(select count(*)
|
||||
from alg.inventory_item_snapshot item
|
||||
where item.warehouse_id = #{warehouseId}
|
||||
and item.snapshot_generation = #{generation}
|
||||
and item.project_no = nullif(ltrim(rtrim(input.project_no)), '')
|
||||
and (nullif(ltrim(rtrim(input.product_id)), '') is null
|
||||
or item.product_no = nullif(ltrim(rtrim(input.product_id)), ''))
|
||||
and isnull(item.quantity, 0) > isnull(item.out_quantity, 0))
|
||||
join alg.cargo_space_snapshot cargo on cargo.space_id = item.space_id
|
||||
where <include refid="outboundCandidatePredicate"/>)
|
||||
as shadowMatchCount
|
||||
from alg.shadow_outbound_request_snapshot input
|
||||
where input.warehouse_id = #{warehouseId}
|
||||
and input.snapshot_generation = #{generation}
|
||||
and input.stockout_detail_id = #{stockoutDetailId}
|
||||
and input.predicate_version = 1
|
||||
</select>
|
||||
|
||||
<select id="selectProjectOutboundCandidates" resultType="com.ruoyi.algorithm.shadow.ShadowStockReference">
|
||||
select top (201)
|
||||
item.stock_id as stockId, item.tray_code as trayNo, item.space_id as spaceId,
|
||||
item.project_no as projectNo, item.product_no as productId,
|
||||
item.tray_job_count as trayJobCount,
|
||||
item.quantity - item.out_quantity as availableQuantity,
|
||||
(select count(*) from alg.inventory_item_snapshot trayItem
|
||||
where trayItem.warehouse_id = item.warehouse_id
|
||||
and trayItem.snapshot_generation = item.snapshot_generation
|
||||
and trayItem.space_id = item.space_id and trayItem.tray_code = item.tray_code)
|
||||
as trayItemCount
|
||||
from alg.shadow_outbound_request_snapshot input
|
||||
join alg.inventory_item_snapshot item on item.warehouse_id = input.warehouse_id
|
||||
join alg.cargo_space_snapshot cargo on cargo.space_id = item.space_id
|
||||
where input.warehouse_id = #{warehouseId}
|
||||
and input.snapshot_generation = #{generation}
|
||||
and input.stockout_detail_id = #{stockoutDetailId}
|
||||
and input.predicate_version = 1
|
||||
and <include refid="outboundCandidatePredicate"/>
|
||||
order by item.stock_id
|
||||
</select>
|
||||
|
||||
<select id="selectStockReference" resultType="com.ruoyi.algorithm.shadow.ShadowStockReference">
|
||||
|
||||
Reference in New Issue
Block a user