fix(shadow): capture and validate inbound task evidence for v3.4
This commit is contained in:
@@ -12,6 +12,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
input.project_no as projectNo,
|
||||
input.product_id as productId,
|
||||
input.lot_no as lotNo,
|
||||
input.spare1, input.spare2, input.spare3, input.fault_flag as faultFlag,
|
||||
input.detail_count as detailCount, input.field_group_count as fieldGroupCount,
|
||||
input.product_scope_count as productScopeCount, input.tray_job_count as trayJobCount,
|
||||
input.legacy_scope_complete as legacyScopeComplete, input.predicate_version as predicateVersion,
|
||||
convert(int, coalesce((
|
||||
select sum(convert(bigint, lane.available_count))
|
||||
from alg.lane_state lane
|
||||
@@ -25,6 +29,57 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and input.tray_no = #{trayNo}
|
||||
</select>
|
||||
|
||||
<!-- Conservative subset valid in either Legacy project-count branch. Ranking remains in the planner. -->
|
||||
<select id="countInboundEligibleSpace" resultType="int">
|
||||
select count(*)
|
||||
from alg.shadow_inbound_request_snapshot input
|
||||
join alg.cargo_space_snapshot cargo
|
||||
on cargo.warehouse_id = input.warehouse_id
|
||||
and cargo.snapshot_generation = input.snapshot_generation
|
||||
where input.warehouse_id = #{warehouseId} and input.snapshot_generation = #{generation}
|
||||
and input.task_no = #{taskNo} and input.tray_no = #{trayNo}
|
||||
and input.predicate_version = 1 and input.detail_count > 0
|
||||
and input.field_group_count = 1 and input.product_scope_count = 1
|
||||
and input.tray_job_count = 1 and input.legacy_scope_complete = 1
|
||||
and nullif(ltrim(rtrim(input.project_no)), '') is not null
|
||||
and input.project_no not in ('999', 'COMMON')
|
||||
and cargo.space_id = #{spaceId} and cargo.space_status = '1' and cargo.locked = 'N'
|
||||
and nullif(ltrim(rtrim(cargo.tray_code)), '') is null
|
||||
and cargo.this_cargo_area in ('A', 'C')
|
||||
and nullif(ltrim(rtrim(cargo.lane_code)), '') is not null
|
||||
and nullif(ltrim(rtrim(cargo.floor_no)), '') is not null
|
||||
and not exists (
|
||||
select 1 from alg.inventory_item_snapshot occupied
|
||||
where occupied.warehouse_id = cargo.warehouse_id
|
||||
and occupied.snapshot_generation = cargo.snapshot_generation and occupied.space_id = cargo.space_id)
|
||||
and not exists (
|
||||
select 1 from alg.cargo_space_snapshot busy
|
||||
where busy.warehouse_id = cargo.warehouse_id and busy.snapshot_generation = cargo.snapshot_generation
|
||||
and ((busy.floor_no = cargo.floor_no and busy.space_status = '3')
|
||||
or (busy.lane_code = cargo.lane_code and (busy.space_status in ('3', '4') or busy.locked = 'Y'))))
|
||||
and (
|
||||
not exists (
|
||||
select 1 from alg.cargo_space_snapshot lane
|
||||
where lane.warehouse_id = cargo.warehouse_id and lane.snapshot_generation = cargo.snapshot_generation
|
||||
and lane.lane_code = cargo.lane_code
|
||||
and (lane.space_status is null or lane.space_status <> '1'
|
||||
or lane.locked is null or lane.locked <> 'N'
|
||||
or nullif(ltrim(rtrim(lane.tray_code)), '') is not null
|
||||
or exists (select 1 from alg.inventory_item_snapshot stock
|
||||
where stock.warehouse_id = lane.warehouse_id
|
||||
and stock.snapshot_generation = lane.snapshot_generation and stock.space_id = lane.space_id)))
|
||||
or exists (
|
||||
select 1 from alg.cargo_space_snapshot resident
|
||||
join alg.inventory_item_snapshot stock
|
||||
on stock.warehouse_id = resident.warehouse_id and stock.snapshot_generation = resident.snapshot_generation
|
||||
and stock.space_id = resident.space_id and stock.tray_code = resident.tray_code
|
||||
where resident.warehouse_id = cargo.warehouse_id and resident.snapshot_generation = cargo.snapshot_generation
|
||||
and resident.lane_code = cargo.lane_code and resident.space_status = '2'
|
||||
and resident.this_cargo_area in ('A', 'C')
|
||||
and stock.project_no = input.project_no
|
||||
and stock.spare1 = input.spare1 and stock.spare2 = input.spare2 and stock.spare3 = input.spare3))
|
||||
</select>
|
||||
|
||||
<sql id="outboundCandidatePredicate">
|
||||
item.warehouse_id = #{warehouseId}
|
||||
and item.snapshot_generation = #{generation}
|
||||
|
||||
Reference in New Issue
Block a user