cmvr-wms/ruoyi-system/src/main/resources/mapper/warehouse/WmsBatchItemMapper.xml

125 lines
6.0 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.warehouse.mapper.WmsBatchItemMapper">
<resultMap type="WmsBatchItem" id="WmsBatchItemResult">
<id property="id" column="id"/>
<result property="jobId" column="job_id"/>
<result property="rowNo" column="row_no"/>
<result property="actionType" column="action_type"/>
<result property="rawText" column="raw_text"/>
<result property="parsedJson" column="parsed_json"/>
<result property="status" column="status"/>
<result property="errorMsg" column="error_msg"/>
<result property="warningMsg" column="warning_msg"/>
<result property="refId" column="ref_id"/>
<result property="areaName" column="area_name"/>
<result property="productName" column="product_name"/>
<result property="brand" column="brand"/>
<result property="category" column="category"/>
<result property="spec" column="spec"/>
<result property="unit" column="unit"/>
<result property="quantity" column="quantity"/>
<result property="operatorName" column="operator_name"/>
<result property="typeCode" column="type_code"/>
<result property="sourceNo" column="source_no"/>
<result property="remark" column="remark"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<resultMap type="WmsBatchJob" id="WmsBatchItemStatsResult">
<result property="totalCount" column="total_count"/>
<result property="successCount" column="success_count"/>
<result property="failCount" column="fail_count"/>
</resultMap>
<sql id="selectWmsBatchItemVo">
select id, job_id, row_no, action_type, raw_text, parsed_json, status, error_msg, warning_msg, ref_id,
area_name, product_name, brand, category, spec, unit, quantity, operator_name, type_code,
source_no, remark, create_time, update_time
from wms_batch_item
</sql>
<select id="selectWmsBatchItemList" parameterType="WmsBatchItem" resultMap="WmsBatchItemResult">
<include refid="selectWmsBatchItemVo"/>
<where>
<if test="jobId != null">and job_id = #{jobId}</if>
<if test="status != null">and status = #{status}</if>
<if test="actionType != null and actionType != ''">and action_type = #{actionType}</if>
</where>
order by row_no asc, id asc
</select>
<select id="selectWmsBatchItemById" parameterType="Long" resultMap="WmsBatchItemResult">
<include refid="selectWmsBatchItemVo"/> where id = #{id}
</select>
<select id="countByJobIdAndStatus" parameterType="WmsBatchItem" resultType="int">
select count(1) from wms_batch_item where job_id = #{jobId} and status = #{status}
</select>
<select id="selectWmsBatchItemStats" parameterType="Long" resultMap="WmsBatchItemStatsResult">
select count(1) as total_count,
coalesce(sum(case when status = 1 then 1 else 0 end), 0) as success_count,
coalesce(sum(case when status = 2 then 1 else 0 end), 0) as fail_count
from wms_batch_item where job_id = #{jobId}
</select>
<insert id="insertWmsBatchItem" parameterType="WmsBatchItem" useGeneratedKeys="true" keyProperty="id">
insert into wms_batch_item(job_id, row_no, action_type, raw_text, parsed_json, status, error_msg, warning_msg,
ref_id, area_name, product_name, brand, category, spec, unit, quantity,
operator_name, type_code, source_no, remark, create_time)
values(#{jobId}, #{rowNo}, #{actionType}, #{rawText}, #{parsedJson}, #{status}, #{errorMsg}, #{warningMsg},
#{refId}, #{areaName}, #{productName}, #{brand}, #{category}, #{spec}, #{unit}, #{quantity},
#{operatorName}, #{typeCode}, #{sourceNo}, #{remark}, sysdate())
</insert>
<insert id="insertWmsBatchItemBatch">
insert into wms_batch_item(job_id, row_no, action_type, raw_text, parsed_json, status, error_msg, warning_msg,
ref_id, area_name, product_name, brand, category, spec, unit, quantity,
operator_name, type_code, source_no, remark, create_time)
values
<foreach collection="items" item="item" separator=",">
(#{item.jobId}, #{item.rowNo}, #{item.actionType}, #{item.rawText}, #{item.parsedJson}, #{item.status},
#{item.errorMsg}, #{item.warningMsg}, #{item.refId}, #{item.areaName}, #{item.productName}, #{item.brand},
#{item.category}, #{item.spec}, #{item.unit}, #{item.quantity}, #{item.operatorName}, #{item.typeCode},
#{item.sourceNo}, #{item.remark}, sysdate())
</foreach>
</insert>
<update id="updateWmsBatchItem" parameterType="WmsBatchItem">
update wms_batch_item
<set>
row_no = #{rowNo},
action_type = #{actionType},
raw_text = #{rawText},
parsed_json = #{parsedJson},
status = #{status},
error_msg = #{errorMsg},
warning_msg = #{warningMsg},
ref_id = #{refId},
area_name = #{areaName},
product_name = #{productName},
brand = #{brand},
category = #{category},
spec = #{spec},
unit = #{unit},
quantity = #{quantity},
operator_name = #{operatorName},
type_code = #{typeCode},
source_no = #{sourceNo},
remark = #{remark},
update_time = sysdate()
</set>
where id = #{id}
</update>
<delete id="deleteWmsBatchItemById" parameterType="Long">
delete from wms_batch_item where id = #{id}
</delete>
<delete id="deleteWmsBatchItemByJobId" parameterType="Long">
delete from wms_batch_item where job_id = #{value}
</delete>
</mapper>