emis-service/emis-biz/src/main/resources/mapper/EmisTmsSiteBatchMissMapper.xml

301 lines
15 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.EmisTmsSiteBatchMissMapper">
<resultMap type="EmisTmsSiteBatchMiss" id="EmisTmsSiteBatchMissResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
<result property="id" column="id"/>
<result property="billCode" column="bill_code"/>
<result property="manager" column="manager"/>
<result property="transManager" column="trans_manager"/>
<result property="missReason" column="miss_reason"/>
<result property="lineCode" column="line_code"/>
<result property="productType" column="product_type"/>
<result property="startSiteCode" column="start_site_code"/>
<result property="nextSiteCode" column="next_site_code"/>
<result property="supplierCode" column="supplier_code"/>
<result property="startDate" column="start_date"/>
<result property="endDate" column="end_date"/>
<result property="lineName" column="line_name"/>
<result property="productTypeName" column="product_type_name"/>
<result property="startSiteName" column="start_site_name"/>
<result property="nextSiteName" column="next_site_name"/>
<result property="supplierName" column="supplier_name"/>
<result property="sendSiteCode" column="send_site_code"/>
<result property="sendSiteName" column="send_site_name"/>
<result property="sendCountry" column="send_country"/>
<result property="sendCountryName" column="send_country_name"/>
<result property="destinationCode" column="destination_code"/>
<result property="destinationName" column="destination_name"/>
<result property="receiveCountry" column="receive_country"/>
<result property="receiveCountryName" column="receive_country_name"/>
<result property="blIsQuestion" column="bl_is_question"/>
<result property="sendDate" column="send_date"/>
<result property="blSign" column="bl_sign"/>
<result property="signDate" column="sign_date"/>
<result property="paymentType" column="payment_type"/>
<result property="parcelQty" column="parcel_qty"/>
<result property="billWeight" column="bill_weight"/>
<result property="totalVolume" column="total_volume"/>
<result property="volumeWeight" column="volume_weight"/>
<result property="settlementWeight" column="settlement_weight"/>
<result property="freight" column="freight"/>
<result property="waybillRemark" column="waybill_remark"/>
<result property="feeRemark" column="fee_remark"/>
</resultMap>
<sql id="selectEmisTmsSiteBatchMissVo">
select
m.id, m.bill_code, m.miss_reason, m.create_by, m.create_time, m.update_by, m.update_time, m.remark, m.del_flag,
m.line_code, m.product_type, m.start_site_code, m.next_site_code, m.supplier_code, m.start_date, m.end_date,
w.send_site_code, s1.site_name as send_site_name,s2.site_name as start_site_name,s3.site_name as next_site_name, w.send_country, c1.name as send_country_name, w.destination_code, n.dest_name as destination_name,w.bl_is_question,
l.line_name as line_name,
w.receive_country, c2.name as receive_country_name, w.send_date, w.bl_sign, w.sign_date,
w.product_type,
w.payment_type, w.parcel_qty, w.bill_weight, w.total_volume, w.volume_weight,
w.settlement_weight, w.freight, w.remark as waybill_remark, w.fee_remark, m.manager, k.trans_manager,
(SELECT GROUP_CONCAT(s.name)
FROM emis_supplier s
WHERE FIND_IN_SET(s.code, m.supplier_code)
AND s.del_flag = '0') as supplier_name,
(SELECT GROUP_CONCAT(p.prod_name)
FROM emis_trans_product p
WHERE FIND_IN_SET(p.prod_code, m.product_type)
AND p.del_flag = '0') as product_type_name
from emis_tms_site_batch_miss m
left join emis_waybill w on m.bill_code = w.bill_code and w.del_flag='0'
left join emis_site s1 on w.send_site_code=s1.site_code and s1.del_flag=0
left join emis_site s2 on m.start_site_code=s2.site_code and s2.del_flag=0
left join emis_site s3 on m.next_site_code=s3.site_code and s3.del_flag=0
left join emis_country c1 on w.send_country=c1.code and c1.del_flag='0'
left join emis_country c2 on w.receive_country=c2.code and c2.del_flag='0'
left join emis_destination n on w.destination_code=n.dest_code and n.del_flag='0'
left join emis_trans_line k on w.trans_line_type=k.line_code and k.del_flag='0'
left join emis_trans_plan_rule r on m.trans_plan_rule_id=r.id and r.del_flag='0'
left join emis_trans_line l on m.line_code=l.line_code and l.del_flag='0'
</sql>
<!-- <select id="selectEmisTmsSiteBatchMissList" parameterType="EmisTmsSiteBatchMiss" resultMap="EmisTmsSiteBatchMissResult">-->
<!-- <include refid="selectEmisTmsSiteBatchMissVo"/>-->
<!-- <where>-->
<!-- m.del_flag = '0'-->
<!-- <if test="billCode != null and billCode != ''">-->
<!-- AND m.bill_code = #{billCode}-->
<!-- </if>-->
<!-- <if test="missReason != null and missReason != ''">-->
<!-- AND m.miss_reason like concat('%', #{missReason}, '%')-->
<!-- </if>-->
<!-- <if test="missType != null and missType != ''">-->
<!-- AND m.miss_type=#{missType}-->
<!-- </if>-->
<!-- <if test="manager != null and manager != ''">-->
<!-- AND m.manager like concat('%', #{manager}, '%')-->
<!-- </if>-->
<!-- <if test="transManager != null and transManager != ''">-->
<!-- AND k.trans_manager like concat('%', #{transManager}, '%')-->
<!-- </if>-->
<!-- <if test="lineCode != null and lineCode != ''">-->
<!-- AND m.line_code = #{lineCode}-->
<!-- </if>-->
<!-- <if test="productType != null and productType != ''">-->
<!-- AND m.product_type = #{productType}-->
<!-- </if>-->
<!-- <if test="startSiteCode != null and startSiteCode != ''">-->
<!-- AND m.start_site_code = #{startSiteCode}-->
<!-- </if>-->
<!-- <if test="nextSiteCode != null and nextSiteCode != ''">-->
<!-- AND m.next_site_code = #{nextSiteCode}-->
<!-- </if>-->
<!-- <if test="supplierCode != null and supplierCode != ''">-->
<!-- AND m.supplier_code = #{supplierCode}-->
<!-- </if>-->
<!-- <if test="startDate != null">-->
<!-- AND m.start_date = #{startDate}-->
<!-- </if>-->
<!-- <if test="endDate != null">-->
<!-- AND m.end_date = #{endDate}-->
<!-- </if>-->
<!-- <if test="blIsQuestion != null and blIsQuestion != ''">-->
<!-- AND w.bl_is_question = #{blIsQuestion}-->
<!-- </if>-->
<!-- <if test="params.privSiteCode != null and params.privSiteCode != '88888'">-->
<!-- and (r.manager=#{params.privEmpName} or k.trans_manager=#{params.privEmpName})-->
<!-- </if>-->
<!-- </where>-->
<!-- </select>-->
<select id="selectEmisTmsSiteBatchMissList" parameterType="EmisTmsSiteBatchMiss" resultMap="EmisTmsSiteBatchMissResult">
<include refid="selectEmisTmsSiteBatchMissVo"/>
<where>
m.del_flag = '0'
<if test="missCount != null">
<choose>
<when test="missCount == -1">
AND m.miss_type = 2
</when>
<when test="missCount == -2">
AND m.miss_type = 3
</when>
<when test="missCount == -3">
AND m.miss_type = 1
</when>
<when test="missCount > 0">
AND m.bill_code IN (
SELECT bill_code
FROM emis_tms_site_batch_miss
WHERE del_flag = '0'
GROUP BY bill_code
HAVING COUNT(*) = #{missCount}
)
</when>
</choose>
</if>
<if test="billCode != null and billCode != ''">
AND m.bill_code = #{billCode}
</if>
<if test="missReason != null and missReason != ''">
AND m.miss_reason like concat('%', #{missReason}, '%')
</if>
<if test="manager != null and manager != ''">
AND r.manager like concat('%', #{manager}, '%')
</if>
<if test="transManager != null and transManager != ''">
AND k.trans_manager like concat('%', #{transManager}, '%')
</if>
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
and (r.manager=#{params.privEmpName} or k.trans_manager=#{params.privEmpName})
</if>
<if test="lineCode != null and lineCode != ''">
AND m.line_code = #{lineCode}
</if>
<if test="productType != null and productType != ''">
AND FIND_IN_SET(#{productType}, m.product_type)
</if>
<if test="startSiteCode != null and startSiteCode != ''">
AND m.start_site_code = #{startSiteCode}
</if>
<if test="nextSiteCode != null and nextSiteCode != ''">
AND m.next_site_code = #{nextSiteCode}
</if>
<if test="supplierCode != null and supplierCode != ''">
AND FIND_IN_SET(#{supplierCode}, m.supplier_code)
</if>
<if test="startDate != null">
AND m.start_date = #{startDate}
</if>
<if test="endDate != null">
AND m.end_date = #{endDate}
</if>
<if test="blIsQuestion != null and blIsQuestion != ''">
AND w.bl_is_question = #{blIsQuestion}
</if>
<if test="params.beginSendDate != null and params.beginSendDate != ''">
and w.send_date <![CDATA[ >= ]]> #{params.beginSendDate}
</if>
<if test="params.endSendDate != null and params.endSendDate != ''">
and w.send_date <![CDATA[ <= ]]> #{params.endSendDate}
</if>
</where>
</select>
<select id="selectEmisTmsSiteBatchMissById" parameterType="Long" resultMap="EmisTmsSiteBatchMissResult">
<include refid="selectEmisTmsSiteBatchMissVo"/>
where m.id = #{id} and m.del_flag = '0'
</select>
<insert id="insertEmisTmsSiteBatchMiss" parameterType="EmisTmsSiteBatchMiss" useGeneratedKeys="true" keyProperty="id">
insert into emis_tms_site_batch_miss
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="billCode != null">bill_code,</if>
<if test="missReason != null">miss_reason,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="billCode != null">#{billCode},</if>
<if test="missReason != null">#{missReason},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateEmisTmsSiteBatchMiss" parameterType="EmisTmsSiteBatchMiss">
update emis_tms_site_batch_miss
<trim prefix="SET" suffixOverrides=",">
<if test="billCode != null">bill_code = #{billCode},</if>
<if test="missReason != null">miss_reason = #{missReason},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<update id="deleteEmisTmsSiteBatchMissById" parameterType="Long">
update emis_tms_site_batch_miss set del_flag = '1' where id = #{id}
</update>
<update id="deleteEmisTmsSiteBatchMissByIds" parameterType="String">
update emis_tms_site_batch_miss set del_flag = '1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<update id="deleteAll">
update emis_tms_site_batch_miss set del_flag = '1'
<if test="lineCode != null and lineCode != ''">
where line_code = #{lineCode}
</if>
</update>
<insert id="batchInsertEmisTmsSiteBatchMiss" parameterType="java.util.List">
insert into emis_tms_site_batch_miss
(trans_plan_rule_id, bill_code, miss_reason, line_code,manager, product_type,
start_site_code, next_site_code, supplier_code, start_date, end_date,
create_by, create_time, update_by, update_time, remark,
create_site, update_site, miss_type)
values
<foreach collection="list" item="item" separator=",">
(
#{item.transPlanRuleId,jdbcType=BIGINT},
#{item.billCode,jdbcType=VARCHAR},
#{item.missReason,jdbcType=VARCHAR},
#{item.lineCode,jdbcType=VARCHAR},
#{item.manager,jdbcType=VARCHAR},
#{item.productType,jdbcType=VARCHAR},
#{item.startSiteCode,jdbcType=VARCHAR},
#{item.nextSiteCode,jdbcType=VARCHAR},
#{item.supplierCode,jdbcType=VARCHAR},
#{item.startDate,jdbcType=TIMESTAMP},
#{item.endDate,jdbcType=TIMESTAMP},
#{item.createBy,jdbcType=VARCHAR},
#{item.createTime,jdbcType=TIMESTAMP},
#{item.updateBy,jdbcType=VARCHAR},
#{item.updateTime,jdbcType=TIMESTAMP},
#{item.remark,jdbcType=VARCHAR},
#{item.createSite,jdbcType=VARCHAR},
#{item.updateSite,jdbcType=VARCHAR},
#{item.missType,jdbcType=VARCHAR}
)
</foreach>
</insert>
<select id="selectByBillCodeCount" parameterType="Integer" resultMap="EmisTmsSiteBatchMissResult">
SELECT t.*
FROM emis_tms_site_batch_miss t
WHERE t.bill_code IN (
SELECT bill_code
FROM emis_tms_site_batch_miss
GROUP BY bill_code
HAVING COUNT(*) = #{count}
)
</select>
</mapper>