更新指定表的引用状态 兼容数据量大于1000的场景
This commit is contained in:
parent
9f3ff2b3a4
commit
5220ac11b2
|
|
@ -117,8 +117,13 @@ public class RefreshIsUsedUtil {
|
|||
private static void RefreshIsUsedStatus(String tableName, List<String> usedIds) {
|
||||
if (CollectionUtils.isNotEmpty(usedIds)) {
|
||||
List<String> collect = Arrays.stream(String.join(",", usedIds).split(",")).collect(Collectors.toList());
|
||||
getRefreshUseMapper().updateIsUsedByIds(tableName, collect, 0);
|
||||
getRefreshUseMapper().updateIsUsedByIds(tableName, collect, 1);
|
||||
final int batchSize = 1000;
|
||||
for (int i = 0; i < collect.size(); i += batchSize) {
|
||||
int endIndex = Math.min(collect.size(), i + batchSize);
|
||||
List<String> batch = collect.subList(i, endIndex);
|
||||
getRefreshUseMapper().updateIsUsedByIds(tableName, batch, 0);
|
||||
getRefreshUseMapper().updateIsUsedByIds(tableName, batch, 1);
|
||||
}
|
||||
} else {
|
||||
getRefreshUseMapper().initIsUseStatus(tableName);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue