高效地批量更新主机节点名称,通过分批次处理大量数据,减少单次更新的压力和提高效率。
int nationalTotalCount = updateNationalList.size();
if (CollectionUtils.isNotEmpty(updateNationalList)) {
for (int startIndex = 0; startIndex < nationalTotalCount; startIndex += DEFAULT_PAGE_NUMBER) {
int endIndex = Math.min(startIndex + DEFAULT_PAGE_NUMBER, nationalTotalCount);
List<NationalVideoDevice> updateBatchList = updateNationalList.subList(startIndex, endIndex);
log.info("批量更新主机节点名称 当前索引:{} 更新数量:{}", startIndex, updateBatchList.size());
log.info("批量更新主机节点名称 开始时间:{}", System.currentTimeMillis());
nationalVideoDeviceMapper.batchUpdate(updateBatchList);
log.info("批量更新主机节点名称 结束时间:{}", System.currentTimeMillis());
}
}