Files
FT546MWS/ruoyi-admin/src/main/resources/mapper/algorithm/ShadowInputMapper.xml

90 lines
4.5 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.algorithm.shadow.mapper.ShadowInputMapper">
<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,
jobDetail.product_id as productId,
jobDetail.lot_no as lotNo
from mydo_job job
left join mydo_job_detail jobDetail on jobDetail.job_id = job.job_id
left join in_stockin_detail detail on detail.stockin_detail_id = jobDetail.stockin_detail_id
left join bas_stock stock on stock.stock_id = jobDetail.stock_id
where job.task_no = #{taskNo}
and job.tray_code = #{trayNo}
order by jobDetail.job_detail_id
</select>
<select id="selectProjectOutboundReference" resultType="com.ruoyi.algorithm.shadow.ShadowStockReference">
select detail.stockout_detail_id as requestId,
detail.warehouse_id as warehouseId,
nullif(ltrim(rtrim(detail.spare4)), '') as projectNo,
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>
<select id="selectStockReference" resultType="com.ruoyi.algorithm.shadow.ShadowStockReference">
select top (1)
stock.stock_id as stockId,
stock.tray_code as trayNo,
stock.cargo_space_id as spaceId,
stock.warehouse_id as warehouseId,
nullif(ltrim(rtrim(stock.spare4)), '') as projectNo,
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'
and stock.product_status = '1'
and stock.quantity &gt; stock.out_quantity
</select>
<insert id="insertComparison">
insert into alg.decision_log (
decision_id, warehouse_id, decision_type, input_version, result_code, reason)
values (
try_convert(uniqueidentifier, #{decisionId}), #{warehouseId}, #{decisionType},
null, #{resultCode}, #{reason})
</insert>
</mapper>