赞
踩
原理就是分批查询。每次查询一定数量数据之后记录id,进行数据处理之后再继续查询继续处理,
allFrameObject = mapper.findAllFrameObjectByMaxId(minTime, beginRow, 1000);
while (CollectionUtils.isNotEmpty(allFrameObject)) {
beginRow = allFrameObject.get(allFrameObject.size() - 1).getId() + 1;
addTicketAndStateReport(allFrameObject, reports);
allFrameObject = mapper.findAllFrameObjectByMaxId(minTime, beginRow, 1000);
}
<select id="findAllFrameObjectByMaxId" resultMap="frameObjectData">
select * FROM gsms_frame_object_data
where id >= #{beginRow} <if test="beforeDay!=null">and CREATE_TIME > #{beforeDay} </if>
order by
id
limit #{batchSize}
</select>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。