From d087e1b8c5e3807739fde36b9e4a42daf0defe73 Mon Sep 17 00:00:00 2001 From: Kris <2893855659@qq.com> Date: Mon, 9 Jun 2025 10:36:59 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90feat=E3=80=91=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=B0=83=E6=95=B4bulk=E6=89=B9=E6=AC=A1=E4=B8=BA=E6=AF=8F?= =?UTF-8?q?=E6=89=B9=E6=AC=A110000=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DataImportBatchServiceImpl.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/celnet/datadump/service/impl/DataImportBatchServiceImpl.java b/src/main/java/com/celnet/datadump/service/impl/DataImportBatchServiceImpl.java index 9bbb00a..19ea615 100644 --- a/src/main/java/com/celnet/datadump/service/impl/DataImportBatchServiceImpl.java +++ b/src/main/java/com/celnet/datadump/service/impl/DataImportBatchServiceImpl.java @@ -200,13 +200,13 @@ public class DataImportBatchServiceImpl implements DataImportBatchService { if (count == 0) { return; } - //批量插入2000一次 - int page = count%2000 == 0 ? count/2000 : (count/2000) + 1; + //批量插入10000一次 + int page = count%10000 == 0 ? count/10000 : (count/10000) + 1; //总插入数 int sfNum = 0; for (int i = 0; i < page; i++) { - List data = customMapper.listJsonObject("*", api, "new_id is null and CreatedDate >= '" + beginDateStr + "' and CreatedDate < '" + endDateStr + "' limit 2000"); + List data = customMapper.listJsonObject("*", api, "new_id is null and CreatedDate >= '" + beginDateStr + "' and CreatedDate < '" + endDateStr + "' limit 10000"); int size = data.size(); log.info("执行api:{}, 执行page:{}, 执行size:{}", api, i+1, size); @@ -262,7 +262,7 @@ public class DataImportBatchServiceImpl implements DataImportBatchService { // 转换为UTC时间并格式化 LocalDateTime localDateTime = LocalDateTime.parse(String.valueOf(data.get(j - 1).get("CreatedDate")), inputFormatter); - ZonedDateTime utcDateTime = localDateTime.atZone(ZoneId.of("UTC")); + ZonedDateTime utcDateTime = localDateTime.atZone(ZoneId.of("UTC")).minusHours(8) ; String convertedTime = utcDateTime.format(outputFormatter); @@ -276,7 +276,7 @@ public class DataImportBatchServiceImpl implements DataImportBatchService { ids[j-1] = data.get(j-1).get("Id").toString(); insertList.add(account); - if (i*2000+j == count){ + if (i*10000+j == count){ break; } } @@ -497,10 +497,10 @@ public class DataImportBatchServiceImpl implements DataImportBatchService { } // 总更新数 int sfNum = 0; - // 批量更新2000一次 - int page = count%2000 == 0 ? count/2000 : (count/2000) + 1; + // 批量更新10000一次 + int page = count%10000 == 0 ? count/10000 : (count/10000) + 1; for (int i = 0; i < page; i++) { - List> mapList = customMapper.list("*", api, "new_id is not null and CreatedDate >= '" + beginDateStr + "' and CreatedDate < '" + endDateStr + "' order by Id asc limit " + i * 2000 + ",2000"); + List> mapList = customMapper.list("*", api, "new_id is not null and CreatedDate >= '" + beginDateStr + "' and CreatedDate < '" + endDateStr + "' order by Id asc limit " + i * 10000 + ",10000"); List updateList = new ArrayList<>();