mybatis + oracle 批量修改

service层:
   int batchSize = 1000;
   int totalData = waferOrderList.size();
   int startIndex = 0;
        while (startIndex < totalData) {
            int endIndex = Math.min(startIndex + batchSize, totalData);
            List<WaferOrder> subIds = waferOrderList.subList(startIndex, endIndex);
            waferOrderMapper.updateWaferOrderByIds(subIds);
            startIndex += batchSize;
        }

mapper.xml

  <update id="updateWaferOrderByIds" parameterType="java.util.List">
        begin
        <foreach collection="waferList" item="wafer" separator=";">
            UPDATE wafer_order
            <set>
                <if test="wafer.woId != null">
                    wo_id = #{wafer.woId},
                </if>
                <if test="wafer.eventTime != null">
                    event_time = #{wafer.eventTime},
                </if>
                status = '已投单'
            </set>
            WHERE id = #{wafer.id}
        </foreach>
        ;end;
    </update>

 

posted @ 2024-01-24 10:04  jessi呀  阅读(79)  评论(0编辑  收藏  举报