将所有的shu数据放在list里进行分批插入
int temp = monomerProductInfoList.size()/500; for(int i=0;i<temp;i++){ monomerProductInfoDao.insertBatch(monomerProductInfoList.subList(i*500,i*500+500)); }
if(temp*500 != monomerProductInfoList.size()){
monomerProductInfoDao.insertBatch(monomerProductInfoList.subList(temp*500,monomerProductInfoList.size()));
}
<insert id="insertBatch" parameterType="java.util.ArrayList"> insert into monomer_product_info(pk_id,excel_id,monomer_num,monomer_barcode,module_included,monomer_model,monomer_standard,
real_content,real_voltage,real_quality,production_date,create_user,create_date,del_flag,department_id) <foreach collection="list" item="item" index="index" separator="union all"> select #{item.pkId},#{item.excelId},#{item.monomerNum},#{item.monomerBarcode},#{item.moduleIncluded},#{item.monomerModel},
#{item.monomerStandard},#{item.realContent},#{item.realVoltage},#{item.realQuality},#{item.productionDate,jdbcType=DATE},
#{item.createUser},#{item.createDate,jdbcType=DATE},#{item.delFlag},#{item.departmentId} from dual </foreach> </insert>
批量查询
<select id="selectMonomerCountForCheck" parameterType="java.util.ArrayList" resultType="java.lang.Integer"> select count(pk_id) from module_product_info where module_barcode in <foreach collection="list" item="barCode" index="index" open="(" close=")" separator=","> #{barCode} </foreach> </select>