and batch = #{batch}
and (batch IS NULL OR batch = '')
INSERT INTO
asr_loc_detl(loc_no,zpallet,barcode,batch,anfme,matnr,maktx,unit,specs,model,color,manu,sku,brand
,origin,item_num,manu_date,weight,volume,length,modi_time,modi_user,appe_time,appe_user)
VALUES
(
#{item.locNo},
#{item.zpallet},
#{item.barcode},
#{item.batch},
#{item.anfme},
#{item.matnr},
#{item.maktx},
#{item.unit},
#{item.specs},
#{item.model},
#{item.color},
#{item.manu},
#{item.sku},
#{item.brand},
#{item.origin},
#{item.itemNum},
#{item.manuDate},
#{item.weight},
#{item.volume},
#{item.length},
#{item.modiTime},
#{item.modiUser},
#{item.appeTime},
#{item.appeUser}
)
delete from asr_loc_detl
where 1=1
and loc_no = #{locNo}
and matnr = #{matnr}
update asr_loc_detl
set anfme = #{anfme}
, modi_time = getdate()
where 1=1
and loc_no = #{locNo}
and matnr = #{matnr}
delete from asr_loc_detl
where 1=1
and loc_no = #{locNo}
and model = #{model}
update asr_loc_detl
set anfme = #{anfme}
, modi_time = getdate()
where 1=1
and loc_no = #{locNo}
and model = #{model}
and a.loc_no like concat('%' , #{loc_no} , '%')
and a.matnr like concat('%' , #{matnr} , '%')
and a.maktx like concat('%' , #{maktx} , '%')
and a.anfme like concat('%' , #{anfme} , '%')
and a.modi_time between #{startTime} and #{endTime}
and b.crn_no=#{crnNo}
and a.batch like concat('%' , #{batch} , '%')
and a.specs like concat('%' , #{specs} , '%')
and a.brand like concat('%' , #{brand} , '%')
and a.model like concat('%' , #{model} , '%')
and a.unit like concat('%' , #{unit} , '%')
UPDATE a
SET a.matnr=b.matnr,
a.specs=b.specs,
a.maktx=b.maktx,
a.unit=b.unit
FROM asr_loc_detl a
INNER JOIN man_mat b ON a.matnr=#{matnrOld} AND b.matnr=#{matnr};
update asr_loc_detl set dead_warn = #{status},modi_time = getdate() where loc_no = #{locNo}
update asr_loc_detl set three_code = #{qualified} where model = #{rollNo}