chore: 保存盘点开发前改动
This commit is contained in:
@@ -168,6 +168,8 @@ external:
|
||||
WCS:
|
||||
base-url: http://172.16.4.63:8084
|
||||
token: wcs-token
|
||||
# 本地测试默认启用模拟返回;联调或生产设为 false 即可恢复真实 WCS 调用
|
||||
mock-enabled: false
|
||||
apis:
|
||||
sendPutawayTask: /wcs/api/receiveWmsJob
|
||||
sendRetrieveTask: /wcs/api/receiveWmsJob
|
||||
|
||||
@@ -177,6 +177,100 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where cargo_space_id = #{cargoSpaceId}
|
||||
</update>
|
||||
|
||||
<update id="markOutboundAssignedByStockId" parameterType="String">
|
||||
update bcs
|
||||
set bcs.status = '4',
|
||||
bcs.tray_code = bs.tray_code
|
||||
from bas_cargo_space bcs
|
||||
inner join bas_stock bs on bcs.cargo_space_id = bs.cargo_space_id
|
||||
where bs.stock_id = #{stockId}
|
||||
</update>
|
||||
|
||||
<update id="markOutboundAssignedByStockRef" parameterType="String">
|
||||
update bcs
|
||||
set bcs.status = '4',
|
||||
bcs.tray_code = bs.tray_code
|
||||
from bas_cargo_space bcs
|
||||
inner join bas_stock bs on bcs.cargo_space_id = bs.cargo_space_id
|
||||
where bs.stock_id = #{stockRef}
|
||||
or exists (
|
||||
select 1
|
||||
from bas_stock_detail bsd
|
||||
where bsd.stock_id = bs.stock_id
|
||||
and bsd.detail_id = #{stockRef}
|
||||
)
|
||||
</update>
|
||||
|
||||
<update id="markOutboundAssignedByStockoutDetailId" parameterType="String">
|
||||
update bcs
|
||||
set bcs.status = '4',
|
||||
bcs.tray_code = bs.tray_code
|
||||
from bas_cargo_space bcs
|
||||
inner join bas_stock bs on bcs.cargo_space_id = bs.cargo_space_id
|
||||
where exists (
|
||||
select 1
|
||||
from mydo_job_detail jd
|
||||
inner join mydo_job j on j.job_id = jd.job_id
|
||||
where jd.stock_id = bs.stock_id
|
||||
and jd.in_or_out_d_id = #{stockoutDetailId}
|
||||
and j.in_or_out >= 20
|
||||
and j.status in ('1', '2', '3')
|
||||
)
|
||||
</update>
|
||||
|
||||
<update id="markOutboundAssignedByCargoSpaceId" parameterType="String">
|
||||
update bas_cargo_space
|
||||
set status = '4'
|
||||
where cargo_space_id = #{cargoSpaceId}
|
||||
and status in ('1', '6')
|
||||
</update>
|
||||
|
||||
<update id="releaseOutboundCargoSpace" parameterType="String">
|
||||
update bas_cargo_space
|
||||
set status = '1',
|
||||
tray_code = null
|
||||
where cargo_space_id = #{cargoSpaceId}
|
||||
</update>
|
||||
|
||||
<update id="markOutboundNeedCheck" parameterType="String">
|
||||
update bas_cargo_space
|
||||
set status = '6'
|
||||
where cargo_space_id = #{cargoSpaceId}
|
||||
</update>
|
||||
|
||||
<update id="markInboundNeedCheck" parameterType="String">
|
||||
update bas_cargo_space
|
||||
set status = '5'
|
||||
where cargo_space_id = #{cargoSpaceId}
|
||||
</update>
|
||||
|
||||
<select id="selectAvailableInboundCargoSpaceInRoadway" parameterType="com.ruoyi.in.job.domain.MydoJob" resultMap="BasCargoSpaceResult">
|
||||
select top 1 cargo_space_id, warehouse_id, roadway_id, cargo_area_id, the_type, the_type_name, cargo_space_name, the_platoon, the_column, the_floor, status, locked, tray_code, iss_double, group_coding_no, group_coding, cargo_space_logo, this_cargo_area, dept_id, dept_name, the_weight, the_height
|
||||
from (
|
||||
select bcs.cargo_space_id, bcs.warehouse_id, bcs.roadway_id, bcs.cargo_area_id, bcs.the_type, bcs.the_type_name,
|
||||
bcs.cargo_space_name, bcs.the_platoon, bcs.the_column, bcs.the_floor, bcs.status, bcs.locked,
|
||||
bcs.tray_code, bcs.iss_double, bcs.group_coding_no, bcs.group_coding, bcs.cargo_space_logo,
|
||||
bcs.this_cargo_area, bcs.dept_id, bcs.dept_name, bcs.the_weight, bcs.the_height,
|
||||
count(1) over (partition by bcs.the_platoon) as platoon_empty_count
|
||||
from bas_cargo_space bcs
|
||||
where bcs.warehouse_id = #{warehouseId}
|
||||
and bcs.roadway_id = #{roadwayId}
|
||||
and bcs.status = '1'
|
||||
and ISNULL(bcs.locked, 'N') = 'N'
|
||||
and (#{cargoSpaceId} is null or bcs.cargo_space_id != #{cargoSpaceId})
|
||||
and bcs.the_type = (select top 1 btr.allowed_cargo_type
|
||||
from bas_tray_rule btr
|
||||
where btr.tray_type is not null
|
||||
and btr.tray_type != ''
|
||||
and #{trayCode} is not null
|
||||
and #{trayCode} != ''
|
||||
and left(#{trayCode}, len(btr.tray_type)) = btr.tray_type
|
||||
and charindex(',' + #{warehouseId} + ',', ',' + btr.allowed_warehouses + ',') > 0
|
||||
order by len(btr.tray_type) desc, btr.id)
|
||||
) candidate
|
||||
order by platoon_empty_count desc, the_platoon asc, the_floor asc, the_column asc, cargo_space_id asc
|
||||
</select>
|
||||
|
||||
<delete id="deleteBasCargoSpaceByCargoSpaceId" parameterType="String">
|
||||
delete from bas_cargo_space where cargo_space_id = #{cargoSpaceId}
|
||||
</delete>
|
||||
@@ -187,4 +281,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{cargoSpaceId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
@@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="trayCode" column="tray_code" />
|
||||
<result property="warehouseId" column="warehouse_id" />
|
||||
<result property="warehouseName" column="warehouse_name" />
|
||||
<result property="trayType" column="tray_type" />
|
||||
<result property="availableQuantity" column="available_quantity" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
@@ -33,17 +34,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
select bsd.detail_id, bsd.stock_id, bsd.product_status, bsd.lot_no, bsd.product_id, bsd.product_name,
|
||||
bsd.quantity, bsd.out_quantity, bsd.job_detail_id, bsd.stockin_detail_id,
|
||||
bs.cargo_space_id, bcs.cargo_space_name, bs.stock_status, bs.in_date, bs.back_date,
|
||||
bs.tray_code, bs.warehouse_id, bs.warehouse_name,
|
||||
bs.tray_code, bs.warehouse_id, ISNULL(NULLIF(bs.warehouse_name, ''), bw.warehouse_name) as warehouse_name,
|
||||
bbf.tray_type,
|
||||
ISNULL(bsd.quantity, 0) - ISNULL(bsd.out_quantity, 0) as available_quantity,
|
||||
bsd.create_time, bsd.update_time, bsd.remark
|
||||
from bas_stock_detail bsd
|
||||
left join bas_stock bs on bsd.stock_id = bs.stock_id
|
||||
left join bas_cargo_space bcs on bs.cargo_space_id = bcs.cargo_space_id
|
||||
left join bas_warehouse bw on bs.warehouse_id = bw.warehouse_id
|
||||
OUTER APPLY (
|
||||
select top 1 prefix as tray_type
|
||||
from bas_barcode_format bbf
|
||||
where bbf.prefix is not null
|
||||
and bbf.prefix != ''
|
||||
and bs.tray_code is not null
|
||||
and left(bs.tray_code, len(bbf.prefix)) = bbf.prefix
|
||||
order by len(bbf.prefix) desc
|
||||
) bbf
|
||||
</sql>
|
||||
|
||||
<select id="selectBasStockDetailList" parameterType="BasStockDetail" resultMap="BasStockDetailResult">
|
||||
<include refid="selectBasStockDetailVo" />
|
||||
<where>
|
||||
bcs.status = '2'
|
||||
<if test="detailId != null and detailId != ''"> and bsd.detail_id = #{detailId}</if>
|
||||
<if test="stockId != null and stockId != ''"> and bsd.stock_id = #{stockId}</if>
|
||||
<if test="productStatus != null and productStatus != ''"> and bsd.product_status = #{productStatus}</if>
|
||||
@@ -56,7 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="stockStatus != null and stockStatus != ''"> and bs.stock_status = #{stockStatus}</if>
|
||||
<if test="trayCode != null and trayCode != ''"> and bs.tray_code = #{trayCode}</if>
|
||||
<if test="warehouseId != null and warehouseId != ''"> and bs.warehouse_id = #{warehouseId}</if>
|
||||
<if test="warehouseName != null and warehouseName != ''"> and bs.warehouse_name like concat('%', #{warehouseName}, '%')</if>
|
||||
<if test="warehouseName != null and warehouseName != ''"> and ISNULL(NULLIF(bs.warehouse_name, ''), bw.warehouse_name) like concat('%', #{warehouseName}, '%')</if>
|
||||
<if test="params.beginInDate != null and params.beginInDate != '' and params.endInDate != null and params.endInDate != ''"> and bs.in_date between #{params.beginInDate} and #{params.endInDate}</if>
|
||||
<if test="params.beginBackDate != null and params.beginBackDate != '' and params.endBackDate != null and params.endBackDate != ''"> and bs.back_date between #{params.beginBackDate} and #{params.endBackDate}</if>
|
||||
${params.warehouseScope}
|
||||
@@ -69,6 +82,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where bsd.detail_id = #{detailId}
|
||||
</select>
|
||||
|
||||
<select id="countBasStockDetailByStockId" parameterType="String" resultType="int">
|
||||
select count(1)
|
||||
from bas_stock_detail with (UPDLOCK, HOLDLOCK)
|
||||
where stock_id = #{stockId}
|
||||
</select>
|
||||
|
||||
<select id="selectStockIdsByDetailIds" parameterType="String" resultType="String">
|
||||
select distinct stock_id from bas_stock_detail where detail_id in
|
||||
<foreach item="detailId" collection="array" open="(" separator="," close=")">
|
||||
@@ -128,6 +147,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where detail_id = #{detailId}
|
||||
</update>
|
||||
|
||||
<update id="rollbackOutboundQuantityByJobId" parameterType="String">
|
||||
update bsd
|
||||
set bsd.out_quantity = case
|
||||
when ISNULL(bsd.out_quantity, 0) - ISNULL(jd.rollback_quantity, 0) < 0 then 0
|
||||
else ISNULL(bsd.out_quantity, 0) - ISNULL(jd.rollback_quantity, 0)
|
||||
end,
|
||||
bsd.job_detail_id = case
|
||||
when exists (
|
||||
select 1
|
||||
from mydo_job_detail x
|
||||
where x.job_id = #{jobId}
|
||||
and x.job_detail_id = bsd.job_detail_id
|
||||
) then null
|
||||
else bsd.job_detail_id
|
||||
end,
|
||||
bsd.update_time = SYSDATETIME()
|
||||
from bas_stock_detail bsd
|
||||
inner join (
|
||||
select stockin_detail_id as detail_id,
|
||||
sum(ISNULL(out_quantity, 0)) as rollback_quantity
|
||||
from mydo_job_detail
|
||||
where job_id = #{jobId}
|
||||
and stockin_detail_id is not null
|
||||
and stockin_detail_id != ''
|
||||
group by stockin_detail_id
|
||||
) jd on jd.detail_id = bsd.detail_id
|
||||
</update>
|
||||
|
||||
<delete id="deleteBasStockDetailByDetailId" parameterType="String">
|
||||
delete from bas_stock_detail where detail_id = #{detailId}
|
||||
</delete>
|
||||
|
||||
@@ -35,7 +35,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectBasStockVo">
|
||||
select stock_id, cargo_space_id, stock_status, product_status, lot_no, in_date, back_date, product_id, product_name, quantity, job_id, job_detail_id, tray_code, out_quantity, stockin_detail_id, stockin_id, in_type, warehouse_id, warehouse_name, user_id, user_name, dept_id, dept_name, supplier_id as suplier_id, supplier_name as suplier_name from bas_stock
|
||||
select stock_id, cargo_space_id, stock_status, product_status, lot_no, in_date, back_date, product_id, product_name, quantity, job_id, job_detail_id, tray_code, out_quantity, stockin_detail_id, stockin_id, in_type, warehouse_id,
|
||||
ISNULL(NULLIF(warehouse_name, ''), (select top 1 bw.warehouse_name from bas_warehouse bw where bw.warehouse_id = bas_stock.warehouse_id)) as warehouse_name,
|
||||
user_id, user_name, dept_id, dept_name, supplier_id as suplier_id, supplier_name as suplier_name from bas_stock
|
||||
</sql>
|
||||
|
||||
<select id="selectBasStockList" parameterType="BasStock" resultMap="BasStockResult">
|
||||
@@ -46,12 +48,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
bs.job_id, null as job_detail_id,
|
||||
bs.tray_code, ISNULL(bsa.out_quantity, 0) as out_quantity,
|
||||
null as stockin_detail_id,
|
||||
bs.stockin_id, bs.in_type, bs.warehouse_id, bs.warehouse_name,
|
||||
bs.stockin_id, bs.in_type, bs.warehouse_id, ISNULL(NULLIF(bs.warehouse_name, ''), bw.warehouse_name) as warehouse_name,
|
||||
bs.user_id, bs.user_name, bs.dept_id, bs.dept_name, bs.supplier_id as suplier_id, bs.supplier_name as suplier_name,
|
||||
ISNULL(bsa.detail_count, 0) as detail_count,
|
||||
ISNULL(bsa.quantity, 0) - ISNULL(bsa.out_quantity, 0) as available_quantity
|
||||
from bas_stock bs
|
||||
left join bas_cargo_space bcs on bs.cargo_space_id = bcs.cargo_space_id
|
||||
left join bas_warehouse bw on bs.warehouse_id = bw.warehouse_id
|
||||
left join (
|
||||
select stock_id,
|
||||
count(1) as detail_count,
|
||||
@@ -80,7 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="stockinId != null and stockinId != ''"> and bs.stockin_id = #{stockinId}</if>
|
||||
<if test="inType != null and inType != ''"> and bs.in_type = #{inType}</if>
|
||||
<if test="warehouseId != null and warehouseId != ''"> and bs.warehouse_id = #{warehouseId}</if>
|
||||
<if test="warehouseName != null and warehouseName != ''"> and bs.warehouse_name like concat('%', #{warehouseName}, '%')</if>
|
||||
<if test="warehouseName != null and warehouseName != ''"> and ISNULL(NULLIF(bs.warehouse_name, ''), bw.warehouse_name) like concat('%', #{warehouseName}, '%')</if>
|
||||
<if test="userName != null and userName != ''"> and bs.user_name like concat('%', #{userName}, '%')</if>
|
||||
<if test="deptName != null and deptName != ''"> and bs.dept_name like concat('%', #{deptName}, '%')</if>
|
||||
<if test="suplierName != null and suplierName != ''"> and bs.supplier_name like concat('%', #{suplierName}, '%')</if>
|
||||
@@ -204,6 +207,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where bs.stock_id = #{stockId}
|
||||
</update>
|
||||
|
||||
<update id="markExceptionByJobId" parameterType="String">
|
||||
update bs
|
||||
set bs.stock_status = '3'
|
||||
from bas_stock bs
|
||||
where exists (
|
||||
select 1
|
||||
from mydo_job_detail jd
|
||||
where jd.job_id = #{jobId}
|
||||
and jd.stock_id = bs.stock_id
|
||||
)
|
||||
</update>
|
||||
|
||||
<delete id="deleteBasStockByStockId" parameterType="String">
|
||||
delete from bas_stock where stock_id = #{stockId}
|
||||
</delete>
|
||||
|
||||
@@ -153,4 +153,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{jobDetailId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteMydoJobDetailByJobId" parameterType="String">
|
||||
delete from mydo_job_detail where job_id = #{jobId}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
||||
@@ -39,10 +39,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectMydoJobVo">
|
||||
select job_id, status, task_no, in_or_out, execution_phase, tray_code, warehouse_id, warehouse_name, roadway_id, cargo_space_id, cargo_space_name, target_roadway_id, target_cargo_space_id, target_cargo_space_name, line_type, priority, height, weight, create_time, start_time, finish_time, entrance_id, exit_id, dept_id, dept_name, user_id, user_name, supplier_id, supplier_name, customer_id, customer_name from mydo_job
|
||||
select job_id, status, task_no, in_or_out, execution_phase, tray_code, warehouse_id,
|
||||
isnull(nullif(warehouse_name, ''), (select top 1 bw.warehouse_name from bas_warehouse bw where bw.warehouse_id = mydo_job.warehouse_id)) as warehouse_name,
|
||||
roadway_id, cargo_space_id, cargo_space_name, target_roadway_id, target_cargo_space_id, target_cargo_space_name, line_type, priority, height, weight, create_time, start_time, finish_time, entrance_id, exit_id, dept_id, dept_name, user_id, user_name, supplier_id, supplier_name, customer_id, customer_name from mydo_job
|
||||
</sql>
|
||||
<sql id="selectMydoJobFinishVo">
|
||||
select job_id, status, task_no, in_or_out, execution_phase, tray_code, warehouse_id, warehouse_name, roadway_id, cargo_space_id, cargo_space_name, target_roadway_id, target_cargo_space_id, target_cargo_space_name, line_type, priority, height, weight, create_time, start_time, finish_time, entrance_id, exit_id, dept_id, dept_name, user_id, user_name, supplier_id, supplier_name, customer_id, customer_name from mydo_job_finish
|
||||
select job_id, status, task_no, in_or_out, execution_phase, tray_code, warehouse_id,
|
||||
isnull(nullif(warehouse_name, ''), (select top 1 bw.warehouse_name from bas_warehouse bw where bw.warehouse_id = mydo_job_finish.warehouse_id)) as warehouse_name,
|
||||
roadway_id, cargo_space_id, cargo_space_name, target_roadway_id, target_cargo_space_id, target_cargo_space_name, line_type, priority, height, weight, create_time, start_time, finish_time, entrance_id, exit_id, dept_id, dept_name, user_id, user_name, supplier_id, supplier_name, customer_id, customer_name from mydo_job_finish
|
||||
</sql>
|
||||
|
||||
<select id="selectMydoJobList" parameterType="MydoJob" resultMap="MydoJobResult">
|
||||
@@ -53,6 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="inOrOut != null "> and in_or_out = #{inOrOut}</if>
|
||||
<if test="executionPhase != null and executionPhase != ''"> and execution_phase = #{executionPhase}</if>
|
||||
<if test="trayCode != null and trayCode != ''"> and tray_code = #{trayCode}</if>
|
||||
<if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId}</if>
|
||||
<if test="warehouseName != null and warehouseName != ''"> and warehouse_name like concat('%', #{warehouseName}, '%')</if>
|
||||
<if test="roadwayId != null and roadwayId != ''"> and roadway_id = #{roadwayId}</if>
|
||||
<if test="cargoSpaceId != null and cargoSpaceId != ''"> and cargo_space_id = #{cargoSpaceId}</if>
|
||||
@@ -84,7 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
finish_time, entrance_id, exit_id, dept_id, dept_name, user_id, user_name, supplier_id,
|
||||
supplier_name, customer_id, customer_name
|
||||
from mydo_job
|
||||
where tray_code = #{trayCode} and in_or_out = 1
|
||||
where tray_code = #{trayCode} and in_or_out < 20
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
@@ -95,7 +100,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
finish_time, entrance_id, exit_id, dept_id, dept_name, user_id, user_name, supplier_id,
|
||||
supplier_name, customer_id, customer_name
|
||||
from mydo_job
|
||||
where task_no = #{taskNo} and in_or_out = 1
|
||||
where task_no = #{taskNo} and in_or_out < 20
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
@@ -117,7 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
finish_time, entrance_id, exit_id, dept_id, dept_name, user_id, user_name, supplier_id,
|
||||
supplier_name, customer_id, customer_name
|
||||
from mydo_job
|
||||
where tray_code = #{trayCode} and warehouse_id = #{warehouseId} and in_or_out = 1
|
||||
where tray_code = #{trayCode} and warehouse_id = #{warehouseId} and in_or_out < 20
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
@@ -154,6 +159,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and stockin_id is not null
|
||||
and stockin_id != ''
|
||||
</select>
|
||||
|
||||
<select id="selectStockIdsByJobId" parameterType="String" resultType="String">
|
||||
select distinct stock_id
|
||||
from mydo_job_detail
|
||||
where job_id = #{jobId}
|
||||
and stock_id is not null
|
||||
and stock_id != ''
|
||||
</select>
|
||||
|
||||
<select id="selectStockoutDetailIdsByJobId" parameterType="String" resultType="String">
|
||||
select distinct in_or_out_d_id
|
||||
from mydo_job_detail
|
||||
where job_id = #{jobId}
|
||||
and in_or_out_d_id is not null
|
||||
and in_or_out_d_id != ''
|
||||
</select>
|
||||
<select id="completeJob" parameterType="java.util.Map" statementType="CALLABLE">
|
||||
{call proc_complete_in_job(
|
||||
#{job_id,mode=IN,jdbcType=VARCHAR},
|
||||
@@ -313,6 +334,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="inOrOut != null "> and in_or_out = #{inOrOut}</if>
|
||||
<if test="executionPhase != null and executionPhase != ''"> and execution_phase = #{executionPhase}</if>
|
||||
<if test="trayCode != null and trayCode != ''"> and tray_code = #{trayCode}</if>
|
||||
<if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId}</if>
|
||||
<if test="warehouseName != null and warehouseName != ''"> and warehouse_name like concat('%', #{warehouseName}, '%')</if>
|
||||
<if test="roadwayId != null and roadwayId != ''"> and roadway_id = #{roadwayId}</if>
|
||||
<if test="cargoSpaceId != null and cargoSpaceId != ''"> and cargo_space_id = #{cargoSpaceId}</if>
|
||||
@@ -339,6 +361,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="inOrOut != null "> and in_or_out = #{inOrOut}</if>
|
||||
<if test="executionPhase != null and executionPhase != ''"> and execution_phase = #{executionPhase}</if>
|
||||
<if test="trayCode != null and trayCode != ''"> and tray_code = #{trayCode}</if>
|
||||
<if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId}</if>
|
||||
<if test="warehouseName != null and warehouseName != ''"> and warehouse_name like concat('%', #{warehouseName}, '%')</if>
|
||||
<if test="roadwayId != null and roadwayId != ''"> and roadway_id = #{roadwayId}</if>
|
||||
<if test="cargoSpaceId != null and cargoSpaceId != ''"> and cargo_space_id = #{cargoSpaceId}</if>
|
||||
@@ -365,6 +388,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="inOrOut != null "> and in_or_out = #{inOrOut}</if>
|
||||
<if test="executionPhase != null and executionPhase != ''"> and execution_phase = #{executionPhase}</if>
|
||||
<if test="trayCode != null and trayCode != ''"> and tray_code = #{trayCode}</if>
|
||||
<if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId}</if>
|
||||
<if test="warehouseName != null and warehouseName != ''"> and warehouse_name like concat('%', #{warehouseName}, '%')</if>
|
||||
<if test="roadwayId != null and roadwayId != ''"> and roadway_id = #{roadwayId}</if>
|
||||
<if test="cargoSpaceId != null and cargoSpaceId != ''"> and cargo_space_id = #{cargoSpaceId}</if>
|
||||
@@ -392,6 +416,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="inOrOut != null "> and in_or_out = #{inOrOut}</if>
|
||||
<if test="executionPhase != null and executionPhase != ''"> and execution_phase = #{executionPhase}</if>
|
||||
<if test="trayCode != null and trayCode != ''"> and tray_code = #{trayCode}</if>
|
||||
<if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId}</if>
|
||||
<if test="warehouseName != null and warehouseName != ''"> and warehouse_name like concat('%', #{warehouseName}, '%')</if>
|
||||
<if test="roadwayId != null and roadwayId != ''"> and roadway_id = #{roadwayId}</if>
|
||||
<if test="cargoSpaceId != null and cargoSpaceId != ''"> and cargo_space_id = #{cargoSpaceId}</if>
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
<?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.out.location.mapper.LocationOutboundMapper">
|
||||
|
||||
<resultMap type="LocationOutboundStock" id="LocationOutboundStockResult">
|
||||
<result property="cargoSpaceId" column="cargo_space_id" />
|
||||
<result property="cargoSpaceName" column="cargo_space_name" />
|
||||
<result property="cargoSpaceStatus" column="cargo_space_status" />
|
||||
<result property="locked" column="locked" />
|
||||
<result property="warehouseId" column="warehouse_id" />
|
||||
<result property="warehouseName" column="warehouse_name" />
|
||||
<result property="roadwayId" column="roadway_id" />
|
||||
<result property="thePlatoon" column="the_platoon" />
|
||||
<result property="theColumn" column="the_column" />
|
||||
<result property="theFloor" column="the_floor" />
|
||||
<result property="theType" column="the_type" />
|
||||
<result property="theTypeName" column="the_type_name" />
|
||||
<result property="stockId" column="stock_id" />
|
||||
<result property="stockStatus" column="stock_status" />
|
||||
<result property="trayCode" column="tray_code" />
|
||||
<result property="trayType" column="tray_type" />
|
||||
<result property="inDate" column="in_date" />
|
||||
<result property="stockinId" column="stockin_id" />
|
||||
<result property="inType" column="in_type" />
|
||||
<result property="supplierId" column="supplier_id" />
|
||||
<result property="supplierName" column="supplier_name" />
|
||||
<result property="detailCount" column="detail_count" />
|
||||
<result property="quantity" column="quantity" />
|
||||
<result property="outQuantity" column="out_quantity" />
|
||||
<result property="availableQuantity" column="available_quantity" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="BasStockDetail" id="LocationOutboundDetailResult">
|
||||
<result property="detailId" column="detail_id" />
|
||||
<result property="stockId" column="stock_id" />
|
||||
<result property="productStatus" column="product_status" />
|
||||
<result property="lotNo" column="lot_no" />
|
||||
<result property="productId" column="product_id" />
|
||||
<result property="productName" column="product_name" />
|
||||
<result property="quantity" column="quantity" />
|
||||
<result property="outQuantity" column="out_quantity" />
|
||||
<result property="jobDetailId" column="job_detail_id" />
|
||||
<result property="stockinDetailId" column="stockin_detail_id" />
|
||||
<result property="cargoSpaceId" column="cargo_space_id" />
|
||||
<result property="cargoSpaceName" column="cargo_space_name" />
|
||||
<result property="stockStatus" column="stock_status" />
|
||||
<result property="inDate" column="in_date" />
|
||||
<result property="backDate" column="back_date" />
|
||||
<result property="trayCode" column="tray_code" />
|
||||
<result property="warehouseId" column="warehouse_id" />
|
||||
<result property="warehouseName" column="warehouse_name" />
|
||||
<result property="trayType" column="tray_type" />
|
||||
<result property="availableQuantity" column="available_quantity" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="stockAggregate">
|
||||
select stock_id,
|
||||
count(1) as detail_count,
|
||||
sum(isnull(quantity, 0)) as quantity,
|
||||
sum(isnull(out_quantity, 0)) as out_quantity,
|
||||
sum(isnull(quantity, 0) - isnull(out_quantity, 0)) as available_quantity
|
||||
from bas_stock_detail
|
||||
group by stock_id
|
||||
</sql>
|
||||
|
||||
<sql id="detailSelect">
|
||||
select bsd.detail_id, bsd.stock_id, bsd.product_status, bsd.lot_no, bsd.product_id, bsd.product_name,
|
||||
bsd.quantity, bsd.out_quantity, bsd.job_detail_id, bsd.stockin_detail_id,
|
||||
bs.cargo_space_id, bcs.cargo_space_name, bs.stock_status, bs.in_date, bs.back_date,
|
||||
bs.tray_code, bs.warehouse_id, isnull(nullif(bs.warehouse_name, ''), bw.warehouse_name) as warehouse_name,
|
||||
bbf.tray_type,
|
||||
isnull(bsd.quantity, 0) - isnull(bsd.out_quantity, 0) as available_quantity,
|
||||
bsd.create_time, bsd.update_time, bsd.remark
|
||||
from bas_stock_detail bsd
|
||||
inner join bas_stock bs on bsd.stock_id = bs.stock_id
|
||||
left join bas_cargo_space bcs on bs.cargo_space_id = bcs.cargo_space_id
|
||||
left join bas_warehouse bw on bs.warehouse_id = bw.warehouse_id
|
||||
outer apply (
|
||||
select top 1 prefix as tray_type
|
||||
from bas_barcode_format bbf
|
||||
where bbf.prefix is not null
|
||||
and bbf.prefix != ''
|
||||
and bs.tray_code is not null
|
||||
and left(bs.tray_code, len(bbf.prefix)) = bbf.prefix
|
||||
order by len(bbf.prefix) desc
|
||||
) bbf
|
||||
</sql>
|
||||
|
||||
<select id="selectLocationOutboundStockList" parameterType="LocationOutboundStock" resultMap="LocationOutboundStockResult">
|
||||
select bcs.cargo_space_id, bcs.cargo_space_name, bcs.status as cargo_space_status, bcs.locked,
|
||||
bcs.warehouse_id, isnull(nullif(bs.warehouse_name, ''), bw.warehouse_name) as warehouse_name,
|
||||
bcs.roadway_id, bcs.the_platoon, bcs.the_column, bcs.the_floor, bcs.the_type, bcs.the_type_name,
|
||||
bs.stock_id, bs.stock_status, bs.tray_code, bbf.tray_type, bs.in_date, bs.stockin_id, bs.in_type,
|
||||
bs.supplier_id, bs.supplier_name,
|
||||
isnull(bsa.detail_count, 0) as detail_count,
|
||||
isnull(bsa.quantity, 0) as quantity,
|
||||
isnull(bsa.out_quantity, 0) as out_quantity,
|
||||
isnull(bsa.available_quantity, 0) as available_quantity
|
||||
from bas_cargo_space bcs
|
||||
left join bas_stock bs on bs.cargo_space_id = bcs.cargo_space_id
|
||||
and bcs.status in ('2', '4')
|
||||
left join bas_warehouse bw on bcs.warehouse_id = bw.warehouse_id
|
||||
left join (
|
||||
<include refid="stockAggregate" />
|
||||
) bsa on bsa.stock_id = bs.stock_id
|
||||
outer apply (
|
||||
select top 1 prefix as tray_type
|
||||
from bas_barcode_format bbf
|
||||
where bbf.prefix is not null
|
||||
and bbf.prefix != ''
|
||||
and bs.tray_code is not null
|
||||
and left(bs.tray_code, len(bbf.prefix)) = bbf.prefix
|
||||
order by len(bbf.prefix) desc
|
||||
) bbf
|
||||
<where>
|
||||
<if test="showEmpty == null or showEmpty == false">
|
||||
and bcs.status = '2'
|
||||
and bs.stock_id is not null
|
||||
and isnull(bsa.available_quantity, 0) > 0
|
||||
</if>
|
||||
<if test="warehouseId != null and warehouseId != ''"> and bcs.warehouse_id = #{warehouseId}</if>
|
||||
<if test="warehouseName != null and warehouseName != ''"> and isnull(nullif(bs.warehouse_name, ''), bw.warehouse_name) like concat('%', #{warehouseName}, '%')</if>
|
||||
<if test="roadwayId != null and roadwayId != ''"> and bcs.roadway_id = #{roadwayId}</if>
|
||||
<if test="cargoSpaceId != null and cargoSpaceId != ''"> and bcs.cargo_space_id like concat('%', #{cargoSpaceId}, '%')</if>
|
||||
<if test="cargoSpaceName != null and cargoSpaceName != ''"> and bcs.cargo_space_name like concat('%', #{cargoSpaceName}, '%')</if>
|
||||
<if test="cargoSpaceStatus != null and cargoSpaceStatus != ''"> and bcs.status = #{cargoSpaceStatus}</if>
|
||||
<if test="stockStatus != null and stockStatus != ''"> and bs.stock_status = #{stockStatus}</if>
|
||||
<if test="trayCode != null and trayCode != ''"> and bs.tray_code like concat('%', #{trayCode}, '%')</if>
|
||||
<if test="productId != null and productId != ''"> and exists (select 1 from bas_stock_detail x where x.stock_id = bs.stock_id and x.product_id like concat('%', #{productId}, '%'))</if>
|
||||
<if test="productName != null and productName != ''"> and exists (select 1 from bas_stock_detail x where x.stock_id = bs.stock_id and x.product_name like concat('%', #{productName}, '%'))</if>
|
||||
<if test="lotNo != null and lotNo != ''"> and exists (select 1 from bas_stock_detail x where x.stock_id = bs.stock_id and x.lot_no like concat('%', #{lotNo}, '%'))</if>
|
||||
${params.warehouseScope}
|
||||
</where>
|
||||
order by bcs.warehouse_id, bcs.roadway_id, bcs.the_floor, bcs.the_platoon, bcs.the_column, bcs.cargo_space_id, bs.stock_id
|
||||
</select>
|
||||
|
||||
<select id="selectLocationOutboundDetailsByStockIds" parameterType="String" resultMap="LocationOutboundDetailResult">
|
||||
<include refid="detailSelect" />
|
||||
where bsd.stock_id in
|
||||
<foreach item="stockId" collection="array" open="(" separator="," close=")">
|
||||
#{stockId}
|
||||
</foreach>
|
||||
and isnull(bsd.quantity, 0) > 0
|
||||
order by bsd.stock_id, bsd.product_id, bsd.detail_id
|
||||
</select>
|
||||
|
||||
<select id="selectLocationOutboundStockForUpdate" parameterType="String" resultMap="LocationOutboundStockResult">
|
||||
select top 1 bcs.cargo_space_id, bcs.cargo_space_name, bcs.status as cargo_space_status, bcs.locked,
|
||||
bcs.warehouse_id, isnull(nullif(bs.warehouse_name, ''), bw.warehouse_name) as warehouse_name,
|
||||
bcs.roadway_id, bcs.the_platoon, bcs.the_column, bcs.the_floor, bcs.the_type, bcs.the_type_name,
|
||||
bs.stock_id, bs.stock_status, bs.tray_code, bbf.tray_type, bs.in_date, bs.stockin_id, bs.in_type,
|
||||
bs.supplier_id, bs.supplier_name,
|
||||
isnull(bsa.detail_count, 0) as detail_count,
|
||||
isnull(bsa.quantity, 0) as quantity,
|
||||
isnull(bsa.out_quantity, 0) as out_quantity,
|
||||
isnull(bsa.available_quantity, 0) as available_quantity
|
||||
from bas_stock bs with (UPDLOCK, HOLDLOCK)
|
||||
inner join bas_cargo_space bcs with (UPDLOCK, HOLDLOCK) on bs.cargo_space_id = bcs.cargo_space_id
|
||||
left join bas_warehouse bw on bs.warehouse_id = bw.warehouse_id
|
||||
left join (
|
||||
<include refid="stockAggregate" />
|
||||
) bsa on bsa.stock_id = bs.stock_id
|
||||
outer apply (
|
||||
select top 1 prefix as tray_type
|
||||
from bas_barcode_format bbf
|
||||
where bbf.prefix is not null
|
||||
and bbf.prefix != ''
|
||||
and bs.tray_code is not null
|
||||
and left(bs.tray_code, len(bbf.prefix)) = bbf.prefix
|
||||
order by len(bbf.prefix) desc
|
||||
) bbf
|
||||
where bs.stock_id = #{stockId}
|
||||
</select>
|
||||
|
||||
<select id="selectLocationOutboundLocationForUpdate" parameterType="String" resultMap="LocationOutboundStockResult">
|
||||
select top 1 bcs.cargo_space_id, bcs.cargo_space_name, bcs.status as cargo_space_status, bcs.locked,
|
||||
bcs.warehouse_id, isnull(nullif(bs.warehouse_name, ''), bw.warehouse_name) as warehouse_name,
|
||||
bcs.roadway_id, bcs.the_platoon, bcs.the_column, bcs.the_floor, bcs.the_type, bcs.the_type_name,
|
||||
bs.stock_id, bs.stock_status, bs.tray_code, bbf.tray_type, bs.in_date, bs.stockin_id, bs.in_type,
|
||||
bs.supplier_id, bs.supplier_name,
|
||||
isnull(bsa.detail_count, 0) as detail_count,
|
||||
isnull(bsa.quantity, 0) as quantity,
|
||||
isnull(bsa.out_quantity, 0) as out_quantity,
|
||||
isnull(bsa.available_quantity, 0) as available_quantity
|
||||
from bas_cargo_space bcs with (UPDLOCK, HOLDLOCK)
|
||||
left join bas_stock bs with (UPDLOCK, HOLDLOCK) on bs.cargo_space_id = bcs.cargo_space_id
|
||||
and bcs.status in ('2', '4')
|
||||
left join bas_warehouse bw on bcs.warehouse_id = bw.warehouse_id
|
||||
left join (
|
||||
<include refid="stockAggregate" />
|
||||
) bsa on bsa.stock_id = bs.stock_id
|
||||
outer apply (
|
||||
select top 1 prefix as tray_type
|
||||
from bas_barcode_format bbf
|
||||
where bbf.prefix is not null
|
||||
and bbf.prefix != ''
|
||||
and bs.tray_code is not null
|
||||
and left(bs.tray_code, len(bbf.prefix)) = bbf.prefix
|
||||
order by len(bbf.prefix) desc
|
||||
) bbf
|
||||
where bcs.cargo_space_id = #{cargoSpaceId}
|
||||
order by bs.in_date desc, bs.stock_id
|
||||
</select>
|
||||
|
||||
<select id="selectAvailableDetailsForUpdate" parameterType="String" resultMap="LocationOutboundDetailResult">
|
||||
select bsd.detail_id, bsd.stock_id, bsd.product_status, bsd.lot_no, bsd.product_id, bsd.product_name,
|
||||
bsd.quantity, bsd.out_quantity, bsd.job_detail_id, bsd.stockin_detail_id,
|
||||
bs.cargo_space_id, bcs.cargo_space_name, bs.stock_status, bs.in_date, bs.back_date,
|
||||
bs.tray_code, bs.warehouse_id, isnull(nullif(bs.warehouse_name, ''), bw.warehouse_name) as warehouse_name,
|
||||
bbf.tray_type,
|
||||
isnull(bsd.quantity, 0) - isnull(bsd.out_quantity, 0) as available_quantity,
|
||||
bsd.create_time, bsd.update_time, bsd.remark
|
||||
from bas_stock_detail bsd with (UPDLOCK, HOLDLOCK)
|
||||
inner join bas_stock bs with (UPDLOCK, HOLDLOCK) on bsd.stock_id = bs.stock_id
|
||||
left join bas_cargo_space bcs with (UPDLOCK, HOLDLOCK) on bs.cargo_space_id = bcs.cargo_space_id
|
||||
left join bas_warehouse bw on bs.warehouse_id = bw.warehouse_id
|
||||
outer apply (
|
||||
select top 1 prefix as tray_type
|
||||
from bas_barcode_format bbf
|
||||
where bbf.prefix is not null
|
||||
and bbf.prefix != ''
|
||||
and bs.tray_code is not null
|
||||
and left(bs.tray_code, len(bbf.prefix)) = bbf.prefix
|
||||
order by len(bbf.prefix) desc
|
||||
) bbf
|
||||
where bsd.stock_id = #{stockId}
|
||||
and isnull(bsd.quantity, 0) - isnull(bsd.out_quantity, 0) > 0
|
||||
order by bsd.product_id, bsd.detail_id
|
||||
</select>
|
||||
|
||||
<update id="reserveStockDetailForOutbound" parameterType="java.util.Map">
|
||||
update bas_stock_detail
|
||||
set out_quantity = isnull(out_quantity, 0) + #{quantity},
|
||||
job_detail_id = #{jobDetailId},
|
||||
update_time = sysdatetime()
|
||||
where detail_id = #{stockDetailId}
|
||||
and stock_id = #{stockId}
|
||||
and isnull(quantity, 0) - isnull(out_quantity, 0) >= #{quantity}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -28,56 +28,68 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="remar" column="remar" />
|
||||
<result property="stockId" column="stock_id" />
|
||||
<result property="stockDetailId" column="stock_detail_id" />
|
||||
<result property="trayType" column="tray_type" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectOutStockoutDetailVo">
|
||||
select stockout_detail_id, stockout_id, lot_no, product_id, product_name, quantity, allot_num, assign_num, remark, status,
|
||||
line_n, item_cod, item_nam, spec_mode, uni, actual_qt, warehous, locatio, inventory_, source_doc_n, remar,
|
||||
stock_id, stock_detail_id
|
||||
from out_stockout_detail
|
||||
select d.stockout_detail_id, d.stockout_id, d.lot_no, d.product_id, d.product_name, d.quantity, d.allot_num, d.assign_num, d.remark, d.status,
|
||||
d.line_n, d.item_cod, d.item_nam, d.spec_mode, d.uni, d.actual_qt, d.warehous, d.locatio, d.inventory_, d.source_doc_n, d.remar,
|
||||
d.stock_id, d.stock_detail_id, bbf.tray_type
|
||||
from out_stockout_detail d
|
||||
left join bas_stock_detail bsd on d.stock_detail_id = bsd.detail_id
|
||||
left join bas_stock bs on bs.stock_id = COALESCE(NULLIF(d.stock_id, ''), bsd.stock_id)
|
||||
OUTER APPLY (
|
||||
select top 1 prefix as tray_type
|
||||
from bas_barcode_format bbf
|
||||
where bbf.prefix is not null
|
||||
and bbf.prefix != ''
|
||||
and bs.tray_code is not null
|
||||
and left(bs.tray_code, len(bbf.prefix)) = bbf.prefix
|
||||
order by len(bbf.prefix) desc
|
||||
) bbf
|
||||
</sql>
|
||||
<sql id="selectOutStockoutDetailFinishVo">
|
||||
select stockout_detail_id, stockout_id, lot_no, product_id, product_name, quantity, allot_num, assign_num, remark, status,
|
||||
line_n, item_cod, item_nam, spec_mode, uni, actual_qt, warehous, locatio, inventory_, source_doc_n, remar,
|
||||
stock_id, stock_detail_id
|
||||
from out_stockout_detail_finish
|
||||
select d.stockout_detail_id, d.stockout_id, d.lot_no, d.product_id, d.product_name, d.quantity, d.allot_num, d.assign_num, d.remark, d.status,
|
||||
d.line_n, d.item_cod, d.item_nam, d.spec_mode, d.uni, d.actual_qt, d.warehous, d.locatio, d.inventory_, d.source_doc_n, d.remar,
|
||||
d.stock_id, d.stock_detail_id, null as tray_type
|
||||
from out_stockout_detail_finish d
|
||||
</sql>
|
||||
|
||||
<select id="selectOutStockoutDetailList" parameterType="OutStockoutDetail" resultMap="OutStockoutDetailResult">
|
||||
<include refid="selectOutStockoutDetailVo"/>
|
||||
<where>
|
||||
<if test="stockoutId != null and stockoutId != ''"> and stockout_id = #{stockoutId}</if>
|
||||
<if test="lotNo != null and lotNo != ''"> and lot_no = #{lotNo}</if>
|
||||
<if test="productId != null and productId != ''"> and product_id = #{productId}</if>
|
||||
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
|
||||
<if test="quantity != null "> and quantity = #{quantity}</if>
|
||||
<if test="allotNum != null "> and allot_num = #{allotNum}</if>
|
||||
<if test="assignNum != null "> and assign_num = #{assignNum}</if>
|
||||
<if test="itemCod != null and itemCod != ''"> and item_cod like concat('%', #{itemCod}, '%')</if>
|
||||
<if test="itemNam != null and itemNam != ''"> and item_nam like concat('%', #{itemNam}, '%')</if>
|
||||
<if test="stockoutId != null and stockoutId != ''"> and d.stockout_id = #{stockoutId}</if>
|
||||
<if test="lotNo != null and lotNo != ''"> and d.lot_no = #{lotNo}</if>
|
||||
<if test="productId != null and productId != ''"> and d.product_id = #{productId}</if>
|
||||
<if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>
|
||||
<if test="quantity != null "> and d.quantity = #{quantity}</if>
|
||||
<if test="allotNum != null "> and d.allot_num = #{allotNum}</if>
|
||||
<if test="assignNum != null "> and d.assign_num = #{assignNum}</if>
|
||||
<if test="itemCod != null and itemCod != ''"> and d.item_cod like concat('%', #{itemCod}, '%')</if>
|
||||
<if test="itemNam != null and itemNam != ''"> and d.item_nam like concat('%', #{itemNam}, '%')</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectOutStockoutDetailByStockoutDetailId" parameterType="String" resultMap="OutStockoutDetailResult">
|
||||
<include refid="selectOutStockoutDetailVo"/>
|
||||
where stockout_detail_id = #{stockoutDetailId}
|
||||
where d.stockout_detail_id = #{stockoutDetailId}
|
||||
</select>
|
||||
<select id="selectOutStockoutDetailListByStockoutId" parameterType="String" resultMap="OutStockoutDetailResult">
|
||||
<include refid="selectOutStockoutDetailVo"/>
|
||||
where stockout_id = #{stockoutDetailId}
|
||||
where d.stockout_id = #{stockoutDetailId}
|
||||
</select>
|
||||
<select id="selectOutStockoutDetailFinishList" parameterType="OutStockoutDetail" resultMap="OutStockoutDetailResult">
|
||||
<include refid="selectOutStockoutDetailFinishVo"/>
|
||||
<where>
|
||||
<if test="stockoutId != null and stockoutId != ''"> and stockout_id = #{stockoutId}</if>
|
||||
<if test="lotNo != null and lotNo != ''"> and lot_no = #{lotNo}</if>
|
||||
<if test="productId != null and productId != ''"> and product_id = #{productId}</if>
|
||||
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
|
||||
<if test="quantity != null "> and quantity = #{quantity}</if>
|
||||
<if test="allotNum != null "> and allot_num = #{allotNum}</if>
|
||||
<if test="assignNum != null "> and assign_num = #{assignNum}</if>
|
||||
<if test="itemCod != null and itemCod != ''"> and item_cod like concat('%', #{itemCod}, '%')</if>
|
||||
<if test="itemNam != null and itemNam != ''"> and item_nam like concat('%', #{itemNam}, '%')</if>
|
||||
<if test="stockoutId != null and stockoutId != ''"> and d.stockout_id = #{stockoutId}</if>
|
||||
<if test="lotNo != null and lotNo != ''"> and d.lot_no = #{lotNo}</if>
|
||||
<if test="productId != null and productId != ''"> and d.product_id = #{productId}</if>
|
||||
<if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>
|
||||
<if test="quantity != null "> and d.quantity = #{quantity}</if>
|
||||
<if test="allotNum != null "> and d.allot_num = #{allotNum}</if>
|
||||
<if test="assignNum != null "> and d.assign_num = #{assignNum}</if>
|
||||
<if test="itemCod != null and itemCod != ''"> and d.item_cod like concat('%', #{itemCod}, '%')</if>
|
||||
<if test="itemNam != null and itemNam != ''"> and d.item_nam like concat('%', #{itemNam}, '%')</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@@ -164,6 +176,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where stockout_detail_id = #{stockoutDetailId}
|
||||
</update>
|
||||
|
||||
<update id="rollbackAllotByJobId" parameterType="String">
|
||||
update d
|
||||
set d.allot_num = case
|
||||
when ISNULL(d.allot_num, 0) - ISNULL(jd.rollback_quantity, 0) < 0 then 0
|
||||
else ISNULL(d.allot_num, 0) - ISNULL(jd.rollback_quantity, 0)
|
||||
end,
|
||||
d.status = case
|
||||
when ISNULL(d.allot_num, 0) - ISNULL(jd.rollback_quantity, 0) <= 0 then '0'
|
||||
else d.status
|
||||
end
|
||||
from out_stockout_detail d
|
||||
inner join (
|
||||
select in_or_out_d_id as stockout_detail_id,
|
||||
sum(ISNULL(out_quantity, 0)) as rollback_quantity
|
||||
from mydo_job_detail
|
||||
where job_id = #{jobId}
|
||||
and in_or_out_d_id is not null
|
||||
and in_or_out_d_id != ''
|
||||
group by in_or_out_d_id
|
||||
) jd on jd.stockout_detail_id = d.stockout_detail_id
|
||||
</update>
|
||||
|
||||
<delete id="deleteOutStockoutDetailByStockoutDetailId" parameterType="String">
|
||||
delete from out_stockout_detail where stockout_detail_id = #{stockoutDetailId}
|
||||
</delete>
|
||||
|
||||
@@ -108,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="autoAssignOutStockoutByProc" parameterType="java.util.Map" statementType="CALLABLE">
|
||||
{call proc_out_auto_allocation(
|
||||
#{v_stockout_detail_id,mode=IN,jdbcType=VARCHAR},
|
||||
#{v_exit_id,mode=IN,jdbcType=VARCHAR},
|
||||
#{v_result,mode=OUT,jdbcType=INTEGER},
|
||||
#{v_resultString,mode=OUT,jdbcType=VARCHAR}
|
||||
)}
|
||||
@@ -252,11 +253,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
{call proc_out_hand_allocation(
|
||||
#{v_stockout_detail_id,mode=IN,jdbcType=VARCHAR},
|
||||
#{v_stock_id,mode=IN,jdbcType=VARCHAR},
|
||||
#{v_exit_id,mode=IN,jdbcType=VARCHAR},
|
||||
#{v_result,mode=OUT,jdbcType=INTEGER},
|
||||
#{v_resultString,mode=OUT,jdbcType=VARCHAR}
|
||||
)}
|
||||
</select>
|
||||
|
||||
<update id="reopenOutStockoutByExceptionJobId" parameterType="String">
|
||||
update o
|
||||
set o.status = '2',
|
||||
o.start_date = null
|
||||
from out_stockout o
|
||||
where o.status = '3'
|
||||
and exists (
|
||||
select 1
|
||||
from mydo_job_detail jd
|
||||
where jd.job_id = #{jobId}
|
||||
and jd.in_or_out_id = o.stockout_id
|
||||
)
|
||||
and not exists (
|
||||
select 1
|
||||
from mydo_job_detail active_jd
|
||||
where active_jd.in_or_out_id = o.stockout_id
|
||||
and active_jd.job_id != #{jobId}
|
||||
)
|
||||
</update>
|
||||
|
||||
<delete id="deleteOutStockoutByStockoutId" parameterType="String">
|
||||
delete from out_stockout where stockout_id = #{stockoutId}
|
||||
</delete>
|
||||
|
||||
@@ -50,18 +50,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="lockInboundCargoSpace" parameterType="java.util.Map">
|
||||
update bas_cargo_space
|
||||
set status = '3',
|
||||
locked = 'Y',
|
||||
tray_code = #{v_tray_code}
|
||||
where cargo_space_id = (
|
||||
select top 1 cargo_space_id
|
||||
from bas_cargo_space with (UPDLOCK, READPAST, ROWLOCK)
|
||||
where warehouse_id = #{v_warehouse_id}
|
||||
and the_type = #{v_cargo_type}
|
||||
and (#{v_roadway_id} is null or #{v_roadway_id} = '' or roadway_id = #{v_roadway_id})
|
||||
and status = '1'
|
||||
and locked = 'N'
|
||||
and (tray_code is null or tray_code = '')
|
||||
order by the_floor asc, the_platoon asc, the_column asc
|
||||
from (
|
||||
select bcs.cargo_space_id,
|
||||
bcs.the_platoon,
|
||||
bcs.the_column,
|
||||
bcs.the_floor,
|
||||
count(1) over (partition by bcs.the_platoon) as platoon_empty_count
|
||||
from bas_cargo_space bcs with (UPDLOCK, READPAST, ROWLOCK)
|
||||
where bcs.warehouse_id = #{v_warehouse_id}
|
||||
and bcs.the_type = #{v_cargo_type}
|
||||
and (#{v_roadway_id} is null or #{v_roadway_id} = '' or bcs.roadway_id = #{v_roadway_id})
|
||||
and bcs.status = '1'
|
||||
and bcs.locked = 'N'
|
||||
and (bcs.tray_code is null or bcs.tray_code = '')
|
||||
) candidate
|
||||
order by platoon_empty_count desc, the_platoon asc, the_floor asc, the_column asc, cargo_space_id asc
|
||||
)
|
||||
</update>
|
||||
|
||||
@@ -72,19 +78,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and tray_code = #{v_tray_code}
|
||||
and (#{v_roadway_id} is null or #{v_roadway_id} = '' or roadway_id = #{v_roadway_id})
|
||||
and status = '3'
|
||||
and locked = 'Y'
|
||||
order by the_floor asc, the_platoon asc, the_column asc
|
||||
</select>
|
||||
|
||||
<update id="releaseInboundCargoSpace" parameterType="java.util.Map">
|
||||
update bas_cargo_space
|
||||
set status = '1',
|
||||
locked = 'N',
|
||||
tray_code = null
|
||||
where warehouse_id = #{v_warehouse_id}
|
||||
and tray_code = #{v_tray_code}
|
||||
and status = '3'
|
||||
and locked = 'Y'
|
||||
</update>
|
||||
|
||||
<select id="outboundTaskList" parameterType="java.util.Map" resultType="java.util.HashMap">
|
||||
@@ -99,16 +102,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
isnull(j.exit_id, '') as portName,
|
||||
convert(varchar(19), j.create_time, 120) as createTime,
|
||||
j.status as status,
|
||||
case j.status
|
||||
when '1' then '未执行'
|
||||
when '2' then '待执行'
|
||||
when '3' then '执行中'
|
||||
j.execution_phase as executionPhase,
|
||||
case
|
||||
when j.execution_phase = '5' then '待扫码确认'
|
||||
when j.status = '1' then '未执行'
|
||||
when j.status = '2' then '待执行'
|
||||
when j.status = '3' then '执行中'
|
||||
else '待确认'
|
||||
end as statusName,
|
||||
case j.status
|
||||
when '1' then 'pending'
|
||||
when '2' then 'pending'
|
||||
when '3' then 'processing'
|
||||
case
|
||||
when j.execution_phase = '5' then 'pending'
|
||||
when j.status = '1' then 'pending'
|
||||
when j.status = '2' then 'pending'
|
||||
when j.status = '3' then 'processing'
|
||||
else 'pending'
|
||||
end as statusClass
|
||||
from mydo_job j
|
||||
@@ -116,38 +122,192 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where j.in_or_out >= 20
|
||||
and j.status in ('1', '2', '3')
|
||||
and (#{taskNo} is null or #{taskNo} = '' or j.task_no = #{taskNo})
|
||||
group by j.job_id, j.task_no, j.exit_id, j.create_time, j.status
|
||||
group by j.job_id, j.task_no, j.exit_id, j.create_time, j.status, j.execution_phase
|
||||
order by j.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectOutboundDetail" parameterType="java.util.Map" resultType="java.util.HashMap">
|
||||
select top 1 j.job_id as jobId,
|
||||
j.task_no as taskNo,
|
||||
jd.job_detail_id as jobDetailId,
|
||||
jd.stock_id as stockId,
|
||||
jd.stockin_detail_id as stockDetailId,
|
||||
jd.product_id as materialCode,
|
||||
jd.product_name as materialName,
|
||||
jd.lot_no as lotNo,
|
||||
jd.out_quantity as quantity,
|
||||
j.tray_code as trayCode,
|
||||
j.cargo_space_id as locationCode,
|
||||
j.cargo_space_name as locationName,
|
||||
j.warehouse_id as warehouseId,
|
||||
j.warehouse_name as warehouseName,
|
||||
j.execution_phase as executionPhase,
|
||||
isnull(j.exit_id, '') as portName,
|
||||
sum(isnull(jd.out_quantity, 0)) as quantity,
|
||||
count(1) as materialCount,
|
||||
'' as spec
|
||||
from mydo_job j
|
||||
inner join mydo_job_detail jd on j.job_id = jd.job_id
|
||||
where j.in_or_out >= 20
|
||||
and j.status in ('1', '2', '3')
|
||||
and (#{taskNo} is null or #{taskNo} = '' or j.task_no = #{taskNo})
|
||||
and (
|
||||
#{barcode} is null or #{barcode} = ''
|
||||
or j.task_no = #{barcode}
|
||||
or j.tray_code = #{barcode}
|
||||
or jd.stock_id = #{barcode}
|
||||
or jd.stockin_detail_id = #{barcode}
|
||||
or jd.product_id = #{barcode}
|
||||
)
|
||||
order by j.create_time desc, jd.job_detail_id
|
||||
and (#{barcode} is null or #{barcode} = '' or j.tray_code = #{barcode})
|
||||
group by j.job_id, j.task_no, j.tray_code, j.cargo_space_id, j.cargo_space_name,
|
||||
j.warehouse_id, j.warehouse_name, j.execution_phase, j.exit_id, j.create_time
|
||||
order by j.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectOutboundTrayMaterials" parameterType="java.util.Map" resultType="java.util.HashMap">
|
||||
select jd.job_detail_id as jobDetailId,
|
||||
jd.stock_id as stockId,
|
||||
jd.stockin_detail_id as stockDetailId,
|
||||
jd.product_id as materialCode,
|
||||
jd.product_name as materialName,
|
||||
jd.lot_no as lotNo,
|
||||
jd.stock_quantity as stockQuantity,
|
||||
jd.out_quantity as quantity,
|
||||
isnull(jd.stock_quantity, 0) - isnull(jd.out_quantity, 0) as residualQuantity
|
||||
from mydo_job_detail jd
|
||||
where jd.job_id = #{jobId}
|
||||
order by jd.job_detail_id
|
||||
</select>
|
||||
|
||||
<select id="selectResidualTrayMaterials" parameterType="java.util.Map" resultType="java.util.HashMap">
|
||||
select bsd.detail_id as stockDetailId,
|
||||
bsd.stock_id as stockId,
|
||||
bsd.product_id as productId,
|
||||
bsd.product_id as materialCode,
|
||||
bsd.product_name as productName,
|
||||
bsd.product_name as materialName,
|
||||
bsd.lot_no as lotNo,
|
||||
isnull(bsd.quantity, 0) as quantity,
|
||||
bs.tray_code as trayCode,
|
||||
bs.warehouse_id as warehouseId,
|
||||
bs.warehouse_name as warehouseName,
|
||||
bs.cargo_space_id as cargoSpaceId,
|
||||
bcs.cargo_space_name as cargoSpaceName,
|
||||
bcs.roadway_id as roadwayId,
|
||||
bs.supplier_id as supplierId,
|
||||
bs.supplier_name as supplierName
|
||||
from bas_stock_detail bsd
|
||||
inner join bas_stock bs on bsd.stock_id = bs.stock_id
|
||||
left join bas_cargo_space bcs on bs.cargo_space_id = bcs.cargo_space_id
|
||||
where bs.tray_code = #{trayCode}
|
||||
and bs.warehouse_id = #{warehouseId}
|
||||
and isnull(bsd.quantity, 0) > 0
|
||||
order by bsd.detail_id
|
||||
</select>
|
||||
|
||||
<select id="selectTrayStockMaterials" parameterType="String" resultType="java.util.HashMap">
|
||||
select bsd.detail_id as stockDetailId,
|
||||
bsd.stock_id as stockId,
|
||||
bsd.product_id as productId,
|
||||
bsd.product_id as materialCode,
|
||||
bsd.product_name as productName,
|
||||
bsd.product_name as materialName,
|
||||
bsd.lot_no as lotNo,
|
||||
isnull(bsd.quantity, 0) as quantity,
|
||||
isnull(bsd.out_quantity, 0) as outQuantity,
|
||||
isnull(bsd.quantity, 0) - isnull(bsd.out_quantity, 0) as availableQuantity,
|
||||
bs.tray_code as trayCode,
|
||||
bs.stock_status as stockStatus,
|
||||
bs.product_status as productStatus,
|
||||
bs.warehouse_id as warehouseId,
|
||||
isnull(nullif(bs.warehouse_name, ''), bw.warehouse_name) as warehouseName,
|
||||
bs.cargo_space_id as cargoSpaceId,
|
||||
bcs.cargo_space_name as cargoSpaceName,
|
||||
bcs.roadway_id as roadwayId,
|
||||
bs.supplier_id as supplierId,
|
||||
bs.supplier_name as supplierName,
|
||||
convert(varchar(19), bs.in_date, 120) as inDate
|
||||
from bas_stock bs
|
||||
inner join bas_stock_detail bsd on bs.stock_id = bsd.stock_id
|
||||
left join bas_cargo_space bcs on bs.cargo_space_id = bcs.cargo_space_id
|
||||
left join bas_warehouse bw on bs.warehouse_id = bw.warehouse_id
|
||||
where bs.tray_code = #{trayCode}
|
||||
and isnull(bsd.quantity, 0) > 0
|
||||
order by bsd.detail_id
|
||||
</select>
|
||||
|
||||
<select id="selectAvailableEmptyTrayTypeCounts" parameterType="String" resultType="java.util.HashMap">
|
||||
select bbf.id as formatId,
|
||||
bbf.format_name as formatName,
|
||||
bbf.prefix as barcodePrefix,
|
||||
count(1) as quantity
|
||||
from bas_stock_detail bsd
|
||||
inner join bas_stock bs on bsd.stock_id = bs.stock_id
|
||||
inner join bas_barcode_format bbf
|
||||
on bbf.prefix is not null
|
||||
and bbf.prefix != ''
|
||||
and left(bs.tray_code, len(bbf.prefix)) = bbf.prefix
|
||||
where bs.warehouse_id = #{warehouseId}
|
||||
and bsd.product_id = 'KTP0001'
|
||||
and isnull(bsd.quantity, 0) - isnull(bsd.out_quantity, 0) > 0
|
||||
and bs.tray_code is not null
|
||||
and bs.tray_code != ''
|
||||
and not exists (
|
||||
select 1
|
||||
from bas_barcode_format bbf2
|
||||
where bbf2.prefix is not null
|
||||
and bbf2.prefix != ''
|
||||
and left(bs.tray_code, len(bbf2.prefix)) = bbf2.prefix
|
||||
and len(bbf2.prefix) > len(bbf.prefix)
|
||||
)
|
||||
group by bbf.id, bbf.format_name, bbf.prefix
|
||||
order by bbf.prefix
|
||||
</select>
|
||||
|
||||
<select id="countAvailableEmptyTrays" parameterType="java.util.Map" resultType="int">
|
||||
select count(1)
|
||||
from bas_stock_detail bsd
|
||||
inner join bas_stock bs on bsd.stock_id = bs.stock_id
|
||||
where bs.warehouse_id = #{warehouseId}
|
||||
and left(bs.tray_code, len(#{barcodePrefix})) = #{barcodePrefix}
|
||||
and bsd.product_id = 'KTP0001'
|
||||
and isnull(bsd.quantity, 0) - isnull(bsd.out_quantity, 0) > 0
|
||||
and bs.tray_code is not null
|
||||
and bs.tray_code != ''
|
||||
</select>
|
||||
|
||||
<select id="selectAvailableEmptyTrayStocks" parameterType="java.util.Map" resultType="java.util.HashMap">
|
||||
select top (#{limit})
|
||||
bsd.detail_id as stockDetailId,
|
||||
bsd.stock_id as stockId,
|
||||
bsd.lot_no as lotNo,
|
||||
bsd.product_id as productId,
|
||||
bsd.product_name as productName,
|
||||
isnull(bsd.quantity, 0) - isnull(bsd.out_quantity, 0) as availableQuantity,
|
||||
bs.tray_code as trayCode,
|
||||
bs.warehouse_id as warehouseId,
|
||||
isnull(nullif(bs.warehouse_name, ''), (select top 1 bw.warehouse_name from bas_warehouse bw where bw.warehouse_id = bs.warehouse_id)) as warehouseName,
|
||||
bs.cargo_space_id as cargoSpaceId,
|
||||
bcs.cargo_space_name as cargoSpaceName,
|
||||
bcs.roadway_id as roadwayId,
|
||||
bs.supplier_id as supplierId,
|
||||
bs.supplier_name as supplierName
|
||||
from bas_stock_detail bsd with (UPDLOCK, HOLDLOCK)
|
||||
inner join bas_stock bs with (UPDLOCK, HOLDLOCK) on bsd.stock_id = bs.stock_id
|
||||
left join bas_cargo_space bcs with (UPDLOCK, HOLDLOCK) on bs.cargo_space_id = bcs.cargo_space_id
|
||||
where bs.warehouse_id = #{warehouseId}
|
||||
and left(bs.tray_code, len(#{barcodePrefix})) = #{barcodePrefix}
|
||||
and bsd.product_id = 'KTP0001'
|
||||
and isnull(bsd.quantity, 0) - isnull(bsd.out_quantity, 0) > 0
|
||||
and bs.tray_code is not null
|
||||
and bs.tray_code != ''
|
||||
order by bs.in_date asc, bs.cargo_space_id asc, bsd.detail_id asc
|
||||
</select>
|
||||
|
||||
<update id="reserveEmptyTrayStockDetail" parameterType="java.util.Map">
|
||||
update bas_stock_detail
|
||||
set out_quantity = isnull(out_quantity, 0) + #{quantity},
|
||||
job_detail_id = #{jobDetailId},
|
||||
update_time = sysdatetime()
|
||||
where detail_id = #{stockDetailId}
|
||||
and stock_id = #{stockId}
|
||||
and product_id = 'KTP0001'
|
||||
and isnull(quantity, 0) - isnull(out_quantity, 0) >= #{quantity}
|
||||
</update>
|
||||
|
||||
<update id="lockEmptyTrayCargoSpace" parameterType="java.util.Map">
|
||||
update bcs
|
||||
set status = '4',
|
||||
tray_code = bs.tray_code
|
||||
from bas_cargo_space bcs
|
||||
inner join bas_stock bs on bcs.cargo_space_id = bs.cargo_space_id
|
||||
where bs.stock_id = #{stockId}
|
||||
and bs.cargo_space_id = #{cargoSpaceId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user