select
m.id, m.bill_code, m.miss_reason, m.create_time, m.update_time, m.remark, m.del_flag,
m.line_code, m.product_type,
COALESCE(m.start_site_code, w.start_site_code, w.send_site_code) as start_site_code,
COALESCE(m.next_site_code, w.destination_code) as next_site_code,
m.supplier_code, m.start_date, m.end_date,m.miss_type,
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, s4.site_name as dispatch_underling_site_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.problem_type,w.virtual_remark,w.dispatch_underling_site_code,
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,
w.payee, w.salesmen, u.emp_name as registerManName,
(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 COALESCE(m.start_site_code, w.start_site_code, w.send_site_code)=s2.site_code and s2.del_flag=0
left join emis_site s3 on COALESCE(m.next_site_code, w.destination_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_site s4 on w.dispatch_underling_site_code=s4.site_code and s4.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'
left join sys_user u on w.register_man_code=u.emp_code and u.del_flag='0'
insert into emis_tms_site_batch_miss
bill_code,miss_reason,create_by,create_time,update_by,update_time,remark,#{billCode},#{missReason},#{createBy},#{createTime},#{updateBy},#{updateTime},#{remark},
update emis_tms_site_batch_miss
bill_code = #{billCode},miss_reason = #{missReason},update_by = #{updateBy},update_time = #{updateTime},remark = #{remark},
where id = #{id}
update emis_tms_site_batch_miss set del_flag = '1' where id = #{id}
update emis_tms_site_batch_miss set del_flag = '1' where id in
#{id}
update emis_tms_site_batch_miss set del_flag = '1'
where line_code = #{lineCode}
delete from emis_tms_site_batch_miss
where line_code = #{lineCode}
update emis_tms_site_batch_miss set del_flag = '1'
where bill_code in
#{billCode}
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
(
#{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}
)