1、新增:出入一个list,list里面可以为bean,也可以为map类型,判断的时候区分大小写;此处判断了每个字段是否为空
需注意,date,timestamp类型,不能进行item.dealdate !=''此种判断
<insert id="insertBatch" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" separator="union all" >
insert into POS_CHECK_DATA(
<if test=" item.businessfrom != null and item.businessfrom !=''"> businessfrom, </if>
<if test=" item.dealdate != null and item.dealdate !=''"> dealdate, </if>
<if test=" item.dealtime != null and item.dealtime !=''"> dealtime, </if>
<if test=" item.expno != null and item.expno !=''"> expno, </if>
<if test=" item.exptype != null and item.exptype !=''"> exptype, </if>
<if test=" item.ordercod != null and item.ordercod !=''"> ordercod, </if>
<if test=" item.goodcod != null and item.goodcod !=''"> goodcod, </if>
<if test=" item.expcod != null and item.expcod !=''"> expcod, </if>
<if test=" item.paytype != null and item.paytype !=''"> paytype, </if>
<if test=" item.countdate != null and item.countdate !=''"> countdate, </if>
<if test=" item.countcod != null and item.countcod !=''"> countcod, </if>
<if test=" item.cardfee != null and item.cardfee !=''"> cardfee, </if>
<if test=" item.cardno != null and item.cardno !=''"> cardno, </if>
<if test=" item.cardbank != null and item.cardbank !=''"> cardbank, </if>
<if test=" item.cardtype != null and item.cardtype !=''"> cardtype, </if>
<if test=" item.voucherno != null and item.voucherno !=''"> voucherno, </if>
<if test=" item.searchno != null and item.searchno !=''"> searchno, </if>
<if test=" item.countposno != null and item.countposno !=''"> countposno, </if>
<if test=" item.acceptposno != null and item.acceptposno !=''"> acceptposno, </if>
<if test=" item.dealtype != null and item.dealtype !=''"> dealtype, </if>
<if test=" item.teimid != null and item.teimid !=''"> teimid, </if>
<if test=" item.expname != null and item.expname !=''"> expname, </if>
<if test=" item.expbussno != null and item.expbussno !=''"> expbussno, </if>
<if test=" item.orderno != null and item.orderno !=''"> orderno, </if>
<if test=" item.billno != null and item.billno !=''"> billno, </if>
<if test=" item.iscover != null and item.iscover !=''"> iscover, </if>
<if test=" item.netno != null and item.netno !=''"> netno, </if>
<if test=" item.netname != null and item.netname !=''"> netname, </if>
<if test=" item.owncode != null and item.owncode !=''"> owncode, </if>
<if test=" item.ownname != null and item.ownname !=''"> ownname, </if>
<if test=" item.describe != null and item.describe !=''"> describe, </if>
<if test=" item.opertime != null"> opertime, </if>
<if test=" item.operatorstate != null and item.operatorstate !=''"> operatorstate, </if>
<if test=" item.userdealdate != null and item.userdealdate !=''"> userdealdate, </if>
<if test=" item.dealuser != null and item.dealuser !=''"> dealuser, </if>
id
)
select
<if test=" item.businessfrom != null and item.businessfrom !=''"> #{item.businessfrom}, </if>
<if test=" item.dealdate != null and item.dealdate !=''"> #{item.dealdate}, </if>
<if test=" item.dealtime != null and item.dealtime !=''"> #{item.dealtime}, </if>
<if test=" item.expno != null and item.expno !=''"> #{item.expno}, </if>
<if test=" item.exptype != null and item.exptype !=''"> #{item.exptype}, </if>
<if test=" item.ordercod != null and item.ordercod !=''"> #{item.ordercod}, </if>
<if test=" item.goodcod != null and item.goodcod !=''"> #{item.goodcod}, </if>
<if test=" item.expcod != null and item.expcod !=''"> #{item.expcod}, </if>
<if test=" item.paytype != null and item.paytype !=''"> #{item.paytype}, </if>
<if test=" item.countdate != null and item.countdate !=''"> #{item.countdate}, </if>
<if test=" item.countcod != null and item.countcod !=''"> #{item.countcod}, </if>
<if test=" item.cardfee != null and item.cardfee !=''"> #{item.cardfee}, </if>
<if test=" item.cardno != null and item.cardno !=''"> #{item.cardno}, </if>
<if test=" item.cardbank != null and item.cardbank !=''"> #{item.cardbank}, </if>
<if test=" item.cardtype != null and item.cardtype !=''"> #{item.cardtype}, </if>
<if test=" item.voucherno != null and item.voucherno !=''"> #{item.voucherno}, </if>
<if test=" item.searchno != null and item.searchno !=''"> #{item.searchno}, </if>
<if test=" item.countposno != null and item.countposno !=''"> #{item.countposno}, </if>
<if test=" item.acceptposno != null and item.acceptposno !=''"> #{item.acceptposno}, </if>
<if test=" item.dealtype != null and item.dealtype !=''"> #{item.dealtype}, </if>
<if test=" item.teimid != null and item.teimid !=''"> #{item.teimid}, </if>
<if test=" item.expname != null and item.expname !=''"> #{item.expname}, </if>
<if test=" item.expbussno != null and item.expbussno !=''"> #{item.expbussno}, </if>
<if test=" item.orderno != null and item.orderno !=''"> #{item.orderno}, </if>
<if test=" item.billno != null and item.billno !=''"> #{item.billno}, </if>
<if test=" item.iscover != null and item.iscover !=''"> #{item.iscover}, </if>
<if test=" item.netno != null and item.netno !=''"> #{item.netno}, </if>
<if test=" item.netname != null and item.netname !=''"> #{item.netname}, </if>
<if test=" item.owncode != null and item.owncode !=''"> #{item.owncode}, </if>
<if test=" item.ownname != null and item.ownname !=''"> #{item.ownname}, </if>
<if test=" item.describe != null and item.describe !=''"> #{item.describe}, </if>
<if test=" item.opertime != null"> #{item.opertime}, </if>
<if test=" item.operatorstate != null and item.operatorstate !=''"> #{item.operatorstate}, </if>
<if test=" item.userdealdate != null and item.userdealdate !=''"> #{item.userdealdate}, </if>
<if test=" item.dealuser != null and item.dealuser !=''"> #{item.dealuser}, </if>
#{item.id}
from dual
</foreach>
</insert>
2、修改:此处关键是<foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">此处的配置。以及set里面对每个值进行是否为空判断。
需注意,date,timestamp类型,不能进行item.dealdate !=''此种判断
<!-- 修改 -->
<update id="editBatch" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
update POS_CHECK_DATA
<set>
<if test=" item.businessfrom != null and item.businessfrom !=''">
businessFrom = #{item.businessfrom},
</if>
<if test=" item.dealdate != null and item.dealdate !=''">
dealDate = #{item.dealdate},
</if>
<if test=" item.dealtime != null and item.dealtime !=''">
dealTime = #{item.dealtime},
</if>
<if test=" item.expno != null and item.expno !=''">
expNo = #{item.expno},
</if>
<if test=" item.exptype != null and item.exptype !=''">
expType = #{item.exptype},
</if>
<if test=" item.ordercod != null and item.ordercod !=''">
orderCod = #{item.ordercod},
</if>
<if test=" item.goodcod != null and item.goodcod !=''">
goodCod = #{item.goodcod},
</if>
<if test=" item.expcod != null and item.expcod !=''">
expCod = #{item.expcod},
</if>
<if test=" item.paytype != null and item.paytype !=''">
payType = #{item.paytype},
</if>
<if test=" item.countdate != null and item.countdate !=''">
countDate = #{item.countdate},
</if>
<if test=" item.countcod != null and item.countcod !=''">
countCod = #{item.countcod},
</if>
<if test=" item.cardfee != null and item.cardfee !=''">
cardFee = #{item.cardfee},
</if>
<if test=" item.cardno != null and item.cardno !=''">
cardNo = #{item.cardno},
</if>
<if test=" item.cardbank != null and item.cardbank !=''">
cardBank = #{item.cardbank},
</if>
<if test=" item.cardtype != null and item.cardtype !=''">
cardType = #{item.cardtype},
</if>
<if test=" item.voucherno != null and item.voucherno !=''">
voucherNo = #{item.voucherno},
</if>
<if test=" item.searchno != null and item.searchno !=''">
searchNo = #{item.searchno},
</if>
<if test=" item.countposno != null and item.countposno !=''">
countPosNo = #{item.countposno},
</if>
<if test=" item.acceptposno != null and item.acceptposno !=''">
acceptPosNo = #{item.acceptposno},
</if>
<if test=" item.dealtype != null and item.dealtype !=''">
dealType = #{item.dealtype},
</if>
<if test=" item.teimid != null and item.teimid !=''">
teimId = #{item.teimid},
</if>
<if test=" item.expname != null and item.expname !=''">
expName = #{item.expname},
</if>
<if test=" item.expbussno != null and item.expbussno !=''">
expBussNo = #{item.expbussno},
</if>
<if test=" item.orderno != null and item.orderno !=''">
orderNo = #{item.orderno},
</if>
<if test=" item.billno != null and item.billno !=''">
billNo = #{item.billno},
</if>
<if test=" item.iscover != null and item.iscover !=''">
isCover = #{item.iscover},
</if>
<if test=" item.netno != null and item.netno !=''">
netNo = #{item.netno},
</if>
<if test=" item.netname != null and item.netname !=''">
netName = #{item.netname},
</if>
<if test=" item.owncode != null and item.owncode !=''">
ownCode = #{item.owncode},
</if>
<if test=" item.ownname != null and item.ownname !=''">
ownName = #{item.ownname},
</if>
<if test=" item.describe != null and item.describe !=''">
describe = #{item.describe},
</if>
<if test=" item.operatorstate != null and item.operatorstate !=''">
operatorstate = #{item.operatorstate},
</if>
<if test=" item.opertime != null">
opertime = #{item.opertime},
</if>
<if test=" item.dealuser != null and item.dealuser !=''">
dealuser = #{item.dealuser},
</if>
<if test=" item.userdealdate != null">
userdealdate = #{item.userdealdate},
</if>
</set>
where id = #{item.id}
</foreach>
</update>