2025-05-09 09:32:01 +00:00
<?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" >
2025-06-11 08:09:09 +00:00
<resultMap type= "EmisTmsSiteBatchMiss" id= "EmisTmsSiteBatchMissResult" extends= "com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult" >
2025-05-09 09:32:01 +00:00
<result property= "id" column= "id" />
<result property= "billCode" column= "bill_code" />
<result property= "manager" column= "manager" />
2025-05-15 06:29:01 +00:00
<result property= "transManager" column= "trans_manager" />
2025-05-09 09:32:01 +00:00
<result property= "missReason" column= "miss_reason" />
2025-06-11 08:09:09 +00:00
<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" />
2025-05-09 09:32:01 +00:00
<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" />
2025-06-11 08:09:09 +00:00
<result property= "blIsQuestion" column= "bl_is_question" />
2025-05-09 09:32:01 +00:00
<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" />
2025-06-20 05:56:56 +00:00
<result property= "missType" column= "miss_type" />
2025-07-10 01:01:59 +00:00
<result property= "virtualRemark" column= "virtual_remark" />
<result property= "problemType" column= "problem_type" />
2025-07-10 02:48:25 +00:00
<result property= "dispatchUnderlingSiteCode" column= "dispatch_underling_site_code" />
<result property= "dispatchUnderlingSiteName" column= "dispatch_underling_site_name" />
2025-05-09 09:32:01 +00:00
</resultMap>
<sql id= "selectEmisTmsSiteBatchMissVo" >
2025-06-11 08:09:09 +00:00
select
2025-07-10 01:01:59 +00:00
m.id, m.bill_code, m.miss_reason, m.create_time, m.update_time, m.remark, m.del_flag,
2025-06-20 05:56:56 +00:00
m.line_code, m.product_type, m.start_site_code, m.next_site_code, m.supplier_code, m.start_date, m.end_date,m.miss_type,
2025-07-10 02:48:25 +00:00
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 dispatch_underling_site_name,w.bl_is_question,
2025-06-12 08:07:21 +00:00
l.line_name as line_name,
2025-06-11 08:09:09 +00:00
w.receive_country, c2.name as receive_country_name, w.send_date, w.bl_sign, w.sign_date,
2025-07-10 02:48:25 +00:00
w.product_type,w.problem_type,w.virtual_remark,w.dispatch_underling_site_code,
2025-06-12 08:07:21 +00:00
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
2025-05-09 09:32:01 +00:00
from emis_tms_site_batch_miss m
2025-07-01 06:33:50 +00:00
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'
2025-07-10 02:48:25 +00:00
left join emis_destination n on w.dispatch_underling_site_code=n.dest_code and n.del_flag='0'
2025-07-01 06:33:50 +00:00
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'
2025-05-09 09:32:01 +00:00
</sql>
2025-06-11 08:09:09 +00:00
<!-- <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> -->
2025-05-09 09:32:01 +00:00
<select id= "selectEmisTmsSiteBatchMissList" parameterType= "EmisTmsSiteBatchMiss" resultMap= "EmisTmsSiteBatchMissResult" >
2025-07-01 06:33:50 +00:00
<choose >
<when test= "missCount == -4" >
<!-- 当missCount= - 4时, 查询emis_waybill_batch_status表 -->
select
2025-07-09 07:58:45 +00:00
distinct w.bill_code, null as id, '已组批次成功' as miss_reason,
2025-07-01 06:33:50 +00:00
null as create_by, null as create_time, null as update_by, null as update_time,
null as remark, '0' as del_flag,
w.trans_line_type as line_code, w.product_type, w.start_site_code, w.next_site_code,
null as supplier_code, null as start_date, null as end_date, '0' as miss_type,
w.send_site_code, s1.site_name as send_site_name,
2025-07-10 02:48:25 +00:00
w.send_country, c1.name as send_country_name, w.destination_code, n.dest_name as dispatch_underling_site_name, w.bl_is_question,
2025-07-01 06:33:50 +00:00
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.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,
null as manager, null as trans_manager,
(SELECT GROUP_CONCAT(s.site_name ORDER BY FIND_IN_SET(s.site_code, w.start_site_code))
FROM emis_site s
WHERE FIND_IN_SET(s.site_code, w.start_site_code) AND s.del_flag = 0) as start_site_name,
(SELECT GROUP_CONCAT(s.site_name ORDER BY FIND_IN_SET(s.site_code, w.next_site_code))
FROM emis_site s
WHERE FIND_IN_SET(s.site_code, w.next_site_code) AND s.del_flag = 0) as next_site_name,
null as supplier_name,
(SELECT GROUP_CONCAT(p.prod_name)
FROM emis_trans_product p
WHERE FIND_IN_SET(p.prod_code, w.product_type)
AND p.del_flag = '0') as product_type_name
from emis_waybill_batch_status b
inner join emis_waybill w on b.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_country c1 on w.send_country=c1.code and c1.del_flag=0
2025-07-10 02:48:25 +00:00
left join emis_destination n on w.dispatch_underling_site_code=n.dest_code and n.del_flag=0
2025-07-01 06:33:50 +00:00
left join emis_trans_line l on w.trans_line_type=l.line_code and l.del_flag=0
left join emis_country c2 on w.receive_country=c2.code and c2.del_flag=0
<where >
b.site_batch_status = '1'
2025-07-03 06:23:50 +00:00
<if test= "billCode != null and billCode != '' and ( params.billCodeSortList == null or (params.billCodeSortList != null and params.billCodeSortList.size() == 1 ) )" >
and ( b.`bill_code`=#{billCode} or b.bill_code like concat('%',#{billCode}) )
</if>
<if test= "params.billCodeSortList != null and params.billCodeSortList.size() > 1 " >
and b.bill_code in
<foreach collection= "params.billCodeSortList" item= "item" open= "(" separator= "," close= ")" >
#{item}
</foreach>
2025-07-01 06:33:50 +00:00
</if>
<if test= "lineCode != null and lineCode != ''" >
AND w.trans_line_type = #{lineCode}
</if>
<if test= "productType != null and productType != ''" >
AND FIND_IN_SET(#{productType}, w.product_type)
</if>
<if test= "startSiteCode != null and startSiteCode != ''" >
AND (
w.start_site_code REGEXP REPLACE(#{startSiteCode}, ',', '|')
)
</if>
<if test= "nextSiteCode != null and nextSiteCode != ''" >
AND (
w.next_site_code REGEXP REPLACE(#{nextSiteCode}, ',', '|')
)
</if>
<if test= "blIsQuestion != null and blIsQuestion != ''" >
AND w.bl_is_question = #{blIsQuestion}
</if>
<if test= "sendSiteCode != null and sendSiteCode != ''" >
AND w.send_site_code = #{sendSiteCode}
</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>
2025-07-08 08:36:52 +00:00
<if test= "params.privSiteCode != null and params.privSiteCode != '88888'" >
and w.send_site_code=#{params.privSiteCode}
</if>
2025-07-01 06:33:50 +00:00
</where>
order by w.bill_code desc
</when>
<otherwise >
<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}
)
AND m.miss_type = 0
</when>
</choose>
</if>
2025-07-03 06:23:50 +00:00
<if test= "billCode != null and billCode != '' and ( params.billCodeSortList == null or (params.billCodeSortList != null and params.billCodeSortList.size() == 1 ) )" >
and ( m.`bill_code`=#{billCode} or m.bill_code like concat('%',#{billCode}) )
</if>
<if test= "params.billCodeSortList != null and params.billCodeSortList.size() > 1 " >
and m.bill_code in
<foreach collection= "params.billCodeSortList" item= "item" open= "(" separator= "," close= ")" >
#{item}
</foreach>
2025-07-01 06:33:50 +00:00
</if>
<if test= "missReason != null and missReason != ''" >
AND m.miss_reason like concat('%', #{missReason}, '%')
</if>
<if test= "manager != null and manager != ''" >
AND (
m.manager REGEXP REPLACE(#{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'" >
2025-07-08 06:22:45 +00:00
and (m.start_site_code=#{params.privSiteCode} or m.next_site_code=#{params.privSiteCode} or
r.manager=#{params.privEmpName} or k.trans_manager=#{params.privEmpName})
2025-07-01 06:33:50 +00:00
</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 REGEXP REPLACE(#{startSiteCode}, ',', '|')
)
</if>
<if test= "nextSiteCode != null and nextSiteCode != ''" >
AND (
m.next_site_code REGEXP REPLACE(#{nextSiteCode}, ',', '|')
2025-06-11 08:09:09 +00:00
)
2025-07-01 06:33:50 +00:00
</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= "sendSiteCode != null and sendSiteCode != ''" >
AND w.send_site_code = #{sendSiteCode}
</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>
order by m.bill_code desc
</otherwise>
</choose>
2025-05-09 09:32:01 +00:00
</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'
2025-06-12 06:19:58 +00:00
<if test= "lineCode != null and lineCode != ''" >
where line_code = #{lineCode}
</if>
2025-05-09 09:32:01 +00:00
</update>
2025-07-09 09:00:46 +00:00
<delete id= "deleteReally" >
delete from emis_tms_site_batch_miss
<if test= "lineCode != null and lineCode != ''" >
where line_code = #{lineCode}
</if>
</delete>
2025-06-13 07:18:03 +00:00
<update id= "deleteByBillCodes" >
update emis_tms_site_batch_miss set del_flag = '1'
where bill_code in
<foreach collection= "billCodes" item= "billCode" open= "(" separator= "," close= ")" >
#{billCode}
</foreach>
</update>
2025-05-09 09:32:01 +00:00
<insert id= "batchInsertEmisTmsSiteBatchMiss" parameterType= "java.util.List" >
insert into emis_tms_site_batch_miss
2025-06-11 08:09:09 +00:00
(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)
2025-05-09 09:32:01 +00:00
values
<foreach collection= "list" item= "item" separator= "," >
2025-06-11 08:09:09 +00:00
(
#{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}
)
2025-05-09 09:32:01 +00:00
</foreach>
</insert>
2025-06-11 08:09:09 +00:00
<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>
2025-07-10 01:01:59 +00:00
<select id= "selectByBillCodes" resultMap= "com.xdadan.erp.emis.mapper.EmisWaybillMapper.EmisWaybillResult" >
select a.id, a.bill_code,a.trans_line_type,
a.product_type,a.start_site_code,a.send_site_code,a.problem_type,a.virtual_remark
from emis_waybill a
where bill_code in
<foreach collection= "billCodes" item= "billCode" open= "(" separator= "," close= ")" >
#{billCode}
</foreach>
</select>
2025-05-09 09:32:01 +00:00
</mapper>