emis-service/emis-biz/src/main/resources/mapper/EmisTmsPackDtlMapper.xml
2025-03-18 11:03:03 +08:00

232 lines
13 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.xdadan.erp.emis.mapper.EmisTmsPackDtlMapper">
<resultMap type="EmisTmsPackDtl" id="BaseEmisTmsPackDtlResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
<result property="id" column="id" />
<result property="packNo" column="pack_no" />
<result property="billCode" column="bill_code" />
<result property="mainBillCode" column="main_bill_code" />
<result property="blSubBill" column="bl_sub_bill" />
<result property="scanDate" column="scan_date" />
<result property="scanStatus" column="scan_status" />
<result property="packStatus" column="pack_status" />
<result property="scanMan" column="scan_man" />
<result property="scanSite" column="scan_site" />
</resultMap>
<resultMap id="EmisTmsPackDtlResult" type="EmisTmsPackDtl" extends="BaseEmisTmsPackDtlResult" >
<association property="waybillDetail"
column="main_bill_code"
select="com.xdadan.erp.emis.mapper.EmisWaybillMapper.selectWaybillBaseInfoByBillCode"
fetchType="lazy"
/>
</resultMap>
<sql id="selectEmisTmsPackDtlVo">
select id, pack_no, bill_code, main_bill_code, bl_sub_bill, scan_date, scan_status, pack_status, scan_man, scan_site, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_tms_pack_dtl
</sql>
<select id="selectEmisTmsPackDtlList" parameterType="EmisTmsPackDtl" resultMap="EmisTmsPackDtlResult">
<include refid="selectEmisTmsPackDtlVo"/>
<where>
del_flag='0'
<if test="id != null "> and id = #{id}</if>
<if test="packNo != null and packNo != ''"> and ( FIND_IN_SET(`pack_no`,#{packNo}) or pack_no like concat('%', #{packNo}, '%') )</if>
<if test="billCode != null and billCode != ''"> and ( FIND_IN_SET(`bill_code`,#{billCode}) or FIND_IN_SET(`main_bill_code`,#{billCode}) or bill_code like concat('%', #{billCode}, '%') or main_bill_code like concat('%', #{billCode}, '%') )</if>
<if test="mainBillCode != null and mainBillCode != ''"> and main_bill_code = #{mainBillCode}</if>
<if test="blSubBill != null and blSubBill != ''"> and bl_sub_bill = #{blSubBill}</if>
<if test="scanDate != null "> and scan_date = #{scanDate}</if>
<if test="scanStatus != null and scanStatus != ''"> and scan_status = #{scanStatus}</if>
<if test="packStatus != null and packStatus != ''"> and pack_status = #{packStatus}</if>
<if test="scanMan != null and scanMan != ''"> and scan_man = #{scanMan}</if>
<if test="scanSite != null and scanSite != ''"> and scan_site = #{scanSite}</if>
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
<if test="tenantId != null and tenantId != ''"> and tenant_id = #{tenantId}</if>
<if test="delFlag != null and delFlag != ''"> and del_flag = #{delFlag}</if>
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by = #{updateBy}</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="createSite != null and createSite != ''"> and create_site = #{createSite}</if>
<if test="updateSite != null and updateSite != ''"> and update_site = #{updateSite}</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != ''">
and create_time <![CDATA[ >= ]]> #{params.beginCreateTime}
</if>
<if test="params.endCreateTime != null and params.endCreateTime != ''">
and create_time <![CDATA[ <= ]]> #{params.endCreateTime}
</if>
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
and (
create_site= #{params.privSiteCode}
)
</if>
</where>
order by create_time desc
</select>
<select id="selectPackDtlListByPackNo" parameterType="String" resultMap="EmisTmsPackDtlResult">
select id, pack_no, bill_code, main_bill_code, bl_sub_bill, scan_date, scan_status, pack_status, scan_man, scan_site, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_tms_pack_dtl a
where del_flag='0' and pack_no=#{packNo}
</select>
<select id="checkUnique" parameterType="EmisTmsPackDtl" resultType="int">
select count(1) from emis_tms_pack_dtl
where del_flag='0'
and pack_no = #{packNo}
and bill_code = #{billCode}
limit 1
</select>
<select id="checkIsExists" parameterType="EmisTmsPackDtl" resultType="int">
select count(1) from emis_tms_pack_dtl
where del_flag='0' and pack_status='1'
and bill_code = #{billCode}
limit 1
</select>
<select id="checkHasPack" parameterType="EmisTmsPackDtl" resultType="int">
select count(1) from emis_tms_pack_dtl
where del_flag='0' and pack_status='1'
and bill_code = #{billCode}
limit 1
</select>
<select id="checkHasPackSubBillCode" parameterType="EmisTmsPackDtl" resultType="int">
select count(1) from emis_tms_pack_dtl
where del_flag='0' and pack_status='1'
and main_bill_code=#{mainBillCode} and main_bill_code!=bill_code
limit 1
</select>
<select id="checkIsExistsSubBillCode" parameterType="EmisTmsPackDtl" resultType="int">
select count(1) from emis_tms_pack_dtl
where del_flag='0' and pack_status='1'
and main_bill_code=#{mainBillCode} and main_bill_code!=bill_code
limit 1
</select>
<select id="selectEmisTmsPackDtlById" parameterType="Long" resultMap="EmisTmsPackDtlResult">
select id, pack_no, bill_code, main_bill_code, bl_sub_bill, scan_date, scan_status, pack_status, scan_man, scan_site, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_tms_pack_dtl a
where del_flag='0' and a.id = #{id}
</select>
<select id="selectEmisTmsPackDtlByBillCode" parameterType="String" resultMap="EmisTmsPackDtlResult">
select id, pack_no, bill_code, main_bill_code, bl_sub_bill, scan_date, scan_status, pack_status, scan_man, scan_site, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_tms_pack_dtl a
where del_flag='0' and a.bill_code = #{billCode}
</select>
<insert id="insertEmisTmsPackDtl" parameterType="EmisTmsPackDtl" useGeneratedKeys="true" keyProperty="id">
insert into emis_tms_pack_dtl
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="packNo != null and packNo != ''">pack_no,</if>
<if test="billCode != null and billCode != ''">bill_code,</if>
<if test="mainBillCode != null and mainBillCode != ''">main_bill_code,</if>
<if test="blSubBill != null and blSubBill != ''">bl_sub_bill,</if>
<if test="scanDate != null">scan_date,</if>
<if test="scanStatus != null and scanStatus != ''">scan_status,</if>
<if test="packStatus != null and packStatus != ''">pack_status,</if>
<if test="scanMan != null and scanMan != ''">scan_man,</if>
<if test="scanSite != null and scanSite != ''">scan_site,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="tenantId != null and tenantId != ''">tenant_id,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="createSite != null and createSite != ''">create_site,</if>
<if test="updateSite != null and updateSite != ''">update_site,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="packNo != null and packNo != ''">#{packNo},</if>
<if test="billCode != null and billCode != ''">#{billCode},</if>
<if test="mainBillCode != null and mainBillCode != ''">#{mainBillCode},</if>
<if test="blSubBill != null and blSubBill != ''">#{blSubBill},</if>
<if test="scanDate != null">#{scanDate},</if>
<if test="scanStatus != null and scanStatus != ''">#{scanStatus},</if>
<if test="packStatus != null and packStatus != ''">#{packStatus},</if>
<if test="scanMan != null and scanMan != ''">#{scanMan},</if>
<if test="scanSite != null and scanSite != ''">#{scanSite},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createSite != null and createSite != ''">#{createSite},</if>
<if test="updateSite != null and updateSite != ''">#{updateSite},</if>
</trim>
</insert>
<update id="updateEmisTmsPackDtl" parameterType="EmisTmsPackDtl">
update emis_tms_pack_dtl
<trim prefix="SET" suffixOverrides=",">
<if test="packNo != null and packNo != ''">pack_no = #{packNo},</if>
<if test="billCode != null and billCode != ''">bill_code = #{billCode},</if>
<if test="mainBillCode != null and mainBillCode != ''">main_bill_code = #{mainBillCode},</if>
<if test="blSubBill != null and blSubBill != ''">bl_sub_bill = #{blSubBill},</if>
<if test="scanDate != null">scan_date = #{scanDate},</if>
<if test="scanStatus != null and scanStatus != ''">scan_status = #{scanStatus},</if>
<if test="packStatus != null and packStatus != ''">pack_status = #{packStatus},</if>
<if test="scanMan != null and scanMan != ''">scan_man = #{scanMan},</if>
<if test="scanSite != null and scanSite != ''">scan_site = #{scanSite},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="tenantId != null and tenantId != ''">tenant_id = #{tenantId},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createSite != null and createSite != ''">create_site = #{createSite},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id}
</update>
<update id="updateScanStatus" parameterType="EmisTmsPackDtl">
update emis_tms_pack_dtl
<trim prefix="SET" suffixOverrides=",">
<if test="scanDate != null">scan_date = #{scanDate},</if>
<if test="scanStatus != null and scanStatus != ''">scan_status = #{scanStatus},</if>
<if test="packStatus != null and packStatus != ''">pack_status = #{packStatus},</if>
<if test="scanMan != null and scanMan != ''">scan_man = #{scanMan},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
</trim>
where bill_code = #{billCode} and pack_no = #{packNo}
</update>
<delete id="deleteEmisTmsPackDtlById" parameterType="Long">
update from emis_tms_pack_dtl where id = #{id}
</delete>
<delete id="deleteEmisTmsPackDtlByIds" parameterType="String">
update from emis_tms_pack_dtl where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteEmisTmsPackDtlByBillCode" parameterType="String">
update from emis_tms_pack_dtl where id = #{id}
</delete>
</mapper>