From 7e88695376f7412a312bfc935200a2f2409f9236 Mon Sep 17 00:00:00 2001 From: Cui YongXing <2835316714@qq.com> Date: Thu, 5 Sep 2024 23:10:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BB=E6=89=BE=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/service/impl/TaskInfoServiceImpl.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cloud-task-server/src/main/java/com/muyu/task/server/service/impl/TaskInfoServiceImpl.java b/cloud-task-server/src/main/java/com/muyu/task/server/service/impl/TaskInfoServiceImpl.java index f8de73d..dc21d0f 100644 --- a/cloud-task-server/src/main/java/com/muyu/task/server/service/impl/TaskInfoServiceImpl.java +++ b/cloud-task-server/src/main/java/com/muyu/task/server/service/impl/TaskInfoServiceImpl.java @@ -31,6 +31,7 @@ import javax.annotation.Resource; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.concurrent.TimeUnit; import static com.muyu.task.server.thread.OptimizedPrioritizedThreadPool.*; @@ -253,6 +254,11 @@ public class TaskInfoServiceImpl extends ServiceImpl i submitHighPriorityTask(()->{ getString(pageNum, finalFieName, finalJoint,basicId,newBasicId,tableId,map,num); }); + try { + TimeUnit.MILLISECONDS.sleep(100); // 适当延迟,避免所有任务同时提交 + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } } } if (Weight.centre.getValue().equals(weight)){ @@ -304,9 +310,9 @@ public class TaskInfoServiceImpl extends ServiceImpl i @NotNull private void getString(Long pageNum,String fieName,String joint,Long basicId,Long newBasicId,Long tableId,HashMap map ,Integer num) { String sqlSelect = " SELECT " + fieName + " FROM " + joint +" limit "+pageNum +","+PAGE_SIZE; - //log.info(sqlSelect); + log.info(sqlSelect); - //log.info("执行{}查询的方法",sqlSelect); + log.info("执行{}查询的方法",sqlSelect); Result tableValueResult = datasourceFeign.findTableValueToArray(basicId, sqlSelect); DataValue[][] data = tableValueResult.getData(); // if (pageNum==160000){ @@ -323,10 +329,10 @@ public class TaskInfoServiceImpl extends ServiceImpl i dataValue.setKey(newKey); } } - //log.info("{}查询结束",sqlSelect); - //log.info("执行{}添加的方法",sqlSelect); + log.info("{}查询结束",sqlSelect); + log.info("执行{}添加的方法",sqlSelect); Result result = datasourceFeign.addProduct(newBasicId, tableId, data); - //log.info("{}添加结束",sqlSelect); + log.info("{}添加结束",sqlSelect); // for (List dataValues : tableValue) { // for (DataValue dataValue : dataValues) { // String key = dataValue.getKey();