diff --git a/cloud-task-server/src/main/java/com/muyu/service/impl/TaskServiceImpl.java b/cloud-task-server/src/main/java/com/muyu/service/impl/TaskServiceImpl.java index 17f6b24..5c66bda 100644 --- a/cloud-task-server/src/main/java/com/muyu/service/impl/TaskServiceImpl.java +++ b/cloud-task-server/src/main/java/com/muyu/service/impl/TaskServiceImpl.java @@ -4,20 +4,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.muyu.common.core.domain.Result; import com.muyu.common.core.utils.StringUtils; -import com.muyu.domain.TaskInfo; -import com.muyu.domain.TaskInputInfo; -import com.muyu.domain.TaskJoinInfo; -import com.muyu.domain.TaskOutputInfo; +import com.muyu.domain.*; import com.muyu.domain.req.TaskInfoReq; import com.muyu.domain.taskenum.Weight; import com.muyu.mapper.TaskMapper; import com.muyu.service.TaskInputService; import com.muyu.service.TaskJoinService; import com.muyu.service.TaskOutputService; -import com.muyu.task.SegmentTask; import com.muyu.service.TaskService; import com.muyu.task.feign.DataValueClient; +import jakarta.annotation.Resource; import lombok.extern.log4j.Log4j2; +import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -259,8 +257,60 @@ public class TaskServiceImpl extends ServiceImpl implement } - public void selectAndAdd(){ + static class SegmentTask implements Runnable, Comparable { + + @Resource + private DataValueClient dataValueClient; + + private final String sql; + private final Long basicId; + private final Long tableId; + private final Weight weight; + HashMap map = new HashMap<>(); + + public SegmentTask(String sql, Long basicId, Long tableId, HashMap map, Weight weight) { + this.sql = sql; + this.basicId = basicId; + this.tableId = tableId; + this.map = map; + this.weight = weight; + } + + @Override + public void run() { + + log.info("开始执行任务:" + basicId + " " + sql + " " + weight + " " + tableId, tableId); + // 查询数据 + Result tableValue = dataValueClient.findTableValue(basicId, sql); + log.info("远程调用完毕,调用的值为{}", tableValue.getData()); + List> data = (List>) tableValue.getData(); + log.info("查询结果:{}", data); + for (List datum : data) { + for (DataValue dataValue : datum) { + String key = dataValue.getKey(); + String newKey = map.get(key); + dataValue.setKey(newKey); + } + } + log.info("开始添加:{}", data); + + Result result = dataValueClient.addTableDataValue(basicId, tableId, data); + log.info("添加完毕字段:{}", result); + // 处理结果 +// dataValueList.accept(tableValue.getData()); + + + } + + public Weight geWeight() { + return weight; + } + + + @Override + public int compareTo(@NotNull SegmentTask o) { + return Integer.compare(o.geWeight().getWeight(), this.weight.getWeight()); + } } - } diff --git a/cloud-task-server/src/main/java/com/muyu/task/PriorityQueryExecutor.java b/cloud-task-server/src/main/java/com/muyu/task/PriorityQueryExecutor.java deleted file mode 100644 index 661edd1..0000000 --- a/cloud-task-server/src/main/java/com/muyu/task/PriorityQueryExecutor.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.muyu.task; - - -import java.util.concurrent.PriorityBlockingQueue; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -/** - * @PackageName:com.muyu.task - * @ClassName:PriorityQueryExecutor - * @Description: - * @author: ¥陈思豪¥ - * @date: 2024/9/6 10:31 - */ -public class PriorityQueryExecutor { - - private static final ExecutorService executor = Executors.newFixedThreadPool(50); - - public void execute(SegmentTask task) { - - } - -} diff --git a/cloud-task-server/src/main/java/com/muyu/task/PriorityThreadPool.java b/cloud-task-server/src/main/java/com/muyu/task/PriorityThreadPool.java new file mode 100644 index 0000000..0493d3e --- /dev/null +++ b/cloud-task-server/src/main/java/com/muyu/task/PriorityThreadPool.java @@ -0,0 +1,18 @@ +//package com.muyu.task; +// +//import java.util.concurrent.*; +// +///** +// * @PackageName:com.muyu.task +// * @ClassName:PriorityQueryExecutor +// * @Description: +// * @author: ¥陈思豪¥ +// * @date: 2024/9/6 10:31 +// */ +//public class PriorityThreadPool { +// +// private static final ExecutorService executor; +// private static final Semaphore s +// +// +//} diff --git a/cloud-task-server/src/main/java/com/muyu/task/SegmentTask.java b/cloud-task-server/src/main/java/com/muyu/task/SegmentTask.java index d44204e..ea5cbc6 100644 --- a/cloud-task-server/src/main/java/com/muyu/task/SegmentTask.java +++ b/cloud-task-server/src/main/java/com/muyu/task/SegmentTask.java @@ -1,80 +1,80 @@ -package com.muyu.task; - -/** - * @PackageName:com.muyu.task - * @ClassName:SementTask - * @Description: - * @author: ¥陈思豪¥ - * @date: 2024/9/5 19:57 - */ - -import com.muyu.common.core.domain.Result; -import com.muyu.domain.DataValue; -import com.muyu.domain.taskenum.Weight; -import com.muyu.task.feign.DataValueClient; -import jakarta.annotation.Resource; -import lombok.extern.log4j.Log4j2; -import org.jetbrains.annotations.NotNull; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.HashMap; -import java.util.List; - -@Log4j2 -public class SegmentTask implements Runnable, Comparable { - - - @Resource - private DataValueClient dataValueClient; - - private final String sql; - private final Long basicId; - private final Long tableId; - private final Weight weight; - HashMap map = new HashMap<>(); - - public SegmentTask(String sql, Long basicId, Long tableId, HashMap map, Weight weight) { - this.sql = sql; - this.basicId = basicId; - this.tableId = tableId; - this.map=map; - this.weight = weight; - } - - @Override - public void run() { - - log.info("开始执行任务:" + basicId + " " + sql + " " + weight + " " + tableId, tableId); - // 查询数据 - Result tableValue = dataValueClient.findTableValue(basicId, sql); - log.info("远程调用完毕,调用的值为{}",tableValue.getData()); - List> data = (List>) tableValue.getData(); - log.info("查询结果:{}", data); - for (List datum : data) { - for (DataValue dataValue : datum) { - String key = dataValue.getKey(); - String newKey = map.get(key); - dataValue.setKey(newKey); - } - } - log.info("开始添加:{}",data); - - Result result = dataValueClient.addTableDataValue(basicId, tableId, data); - log.info("添加完毕字段:{}",result); - // 处理结果 -// dataValueList.accept(tableValue.getData()); - - - } - - public Weight geWeight() { - return weight; - } - - - @Override - public int compareTo(@NotNull SegmentTask o) { - return Integer.compare(o.weight.getWeight(), this.weight.getWeight()); - } -} - +//package com.muyu.task; +// +///** +// * @PackageName:com.muyu.task +// * @ClassName:SementTask +// * @Description: +// * @author: ¥陈思豪¥ +// * @date: 2024/9/5 19:57 +// */ +// +//import com.muyu.common.core.domain.Result; +//import com.muyu.domain.DataValue; +//import com.muyu.domain.taskenum.Weight; +//import com.muyu.task.feign.DataValueClient; +//import jakarta.annotation.Resource; +//import lombok.extern.log4j.Log4j2; +//import org.jetbrains.annotations.NotNull; +//import org.springframework.beans.factory.annotation.Autowired; +// +//import java.util.HashMap; +//import java.util.List; +// +//@Log4j2 +//public class SegmentTask implements Runnable, Comparable { +// +// +// @Resource +// private DataValueClient dataValueClient; +// +// private final String sql; +// private final Long basicId; +// private final Long tableId; +// private final Weight weight; +// HashMap map = new HashMap<>(); +// +// public SegmentTask(String sql, Long basicId, Long tableId, HashMap map, Weight weight) { +// this.sql = sql; +// this.basicId = basicId; +// this.tableId = tableId; +// this.map=map; +// this.weight = weight; +// } +// +// @Override +// public void run() { +// +// log.info("开始执行任务:" + basicId + " " + sql + " " + weight + " " + tableId, tableId); +// // 查询数据 +// Result tableValue = dataValueClient.findTableValue(basicId, sql); +// log.info("远程调用完毕,调用的值为{}",tableValue.getData()); +// List> data = (List>) tableValue.getData(); +// log.info("查询结果:{}", data); +// for (List datum : data) { +// for (DataValue dataValue : datum) { +// String key = dataValue.getKey(); +// String newKey = map.get(key); +// dataValue.setKey(newKey); +// } +// } +// log.info("开始添加:{}",data); +// +// Result result = dataValueClient.addTableDataValue(basicId, tableId, data); +// log.info("添加完毕字段:{}",result); +// // 处理结果 +//// dataValueList.accept(tableValue.getData()); +// +// +// } +// +// public Weight geWeight() { +// return weight; +// } +// +// +// @Override +// public int compareTo(@NotNull SegmentTask o) { +// return Integer.compare(o.weight.getWeight(), this.weight.getWeight()); +// } +//} +//