1.传入方法:
list<StockInfo> stokkInfos =new ArrayList<>();
StockInfo stockInfo = new StockInfo();
stockInfo.setEquipmentNo = 123456;
.
.
.
stockInfos.add(stockInfo); //修改时需要把id传过来
stockInfoMapper.batchInsert(stockInfos);
2.dao层方法://在service层自动创建就好
void batchInsert(List<StockInfo> stockInfos);
3.批量新增的方法
<insert id="batchInsert"
parameterType="com.erp.entity.StockInfo" //自己的实体位置
useGeneratedKeys="true" keyProperty="id">
insert into
stock_info(warehouse_info_id,equipment_info_id,equipment_no,number,state,price,create_time,
create_user_name,create_user_id,in_pk_id,in_stock_type,in_stock_time,memo,create_post_id,
stock_form)
values
<foreach collection="list" item="item" separator=","> //以list的方式传入,item是随便取的叫什么都可以
(#{item.warehouseInfoId},#{item.equipmentInfoId},#{item.equipmentNo},#{item.number},
#{item.state},#{item.price},#{item.createTime},#{item.createUserName},#{item.createUserId},
#{item.inPkId},#{item.inStockType},#{item.inStockTime},#{item.memo},#{item.createPostId},
#{item.stockForm})
</foreach>
</insert>
4.批量修改的方法
<update id="batchUpdate"
parameterType="com.huge.erp.entity.StockInfo"
useGeneratedKeys="true" keyProperty="id">
<foreach collection="list" item="item" separator=";">
update
stock_info set
<trim prefix="" suffix=" " suffixOverrides=",">
<if test="item.warehouseInfoId != null">
warehouse_info_id=#{item.warehouseInfoId},
</if>
<if test="item.equipmentInfoId != null">
equipment_info_id=#{item.equipmentInfoId},
</if>
<if test="item.equipmentNo != null">
equipment_no=#{item.equipmentNo},
</if>
</trim>
where id = #{item.id}
</foreach>
</update>