任务相关

This commit is contained in:
李玉东 2025-09-19 16:13:10 +08:00
parent 5d078e0dac
commit 1af5e030e8
4 changed files with 17 additions and 8 deletions

View File

@ -137,12 +137,13 @@ public abstract class AbtParentTask implements TaskAction {
+ scenarioTask.getToLng()
+ "&points_encoded=false"
+ "&algorithm=alternative_route&alternative_route.max_paths=3";
log.info("params:;{}", params);
//获取路线信息
String result = webClient.get().uri(params)
.retrieve()
.bodyToMono(String.class)
.block();
log.info("init path finished ::{}",result);
log.info("init path finished ::{}", result);
JSONObject pointJson = JSON.parseObject(result);
//获取路径点
if (pointJson != null) {
@ -204,9 +205,11 @@ public abstract class AbtParentTask implements TaskAction {
try {
if (this.getRoomStatus()) {
if (distanceInfoMap.isEmpty()) {
return;
}
long duringTime = getDuringTime() - taskRelativeTime;
if(duringTime <= 0) {
if (duringTime <= 0) {
return;
}
@ -215,7 +218,7 @@ public abstract class AbtParentTask implements TaskAction {
//获取大与此距离的第一个路线点key
Entry<Double, Coordinate> endPoint = distanceInfoMap.ceilingEntry(distance);
if(endPoint == null) {
if (endPoint == null) {
endPoint = distanceInfoMap.lastEntry();
}
@ -229,6 +232,9 @@ public abstract class AbtParentTask implements TaskAction {
if (Double.compare(distance, endPoint.getKey()) < 0) {
//获取小于最大值的第一个key
Double lowerKey = distanceInfoMap.lowerKey(endPoint.getKey());
if(lowerKey==null){
lowerKey = endPoint.getKey();
}
NavigableMap<Double, Coordinate> subPathMap = distanceInfoMap.subMap(startPoint.get(),
true, lowerKey, true);

View File

@ -65,7 +65,7 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
@Override
public void doSomeThing() {
log.info("move task running");
log.info("move task running:{}",scenarioTask.getResourceId());
initEnv(); //初始化环境
initPath(); //初始化路径

View File

@ -63,7 +63,7 @@ public class Room implements AutoCloseable {
//线程池
private final ExecutorService actionExecutor =
new ThreadPoolExecutor(
5, 5, // corePoolSize, maximumPoolSize
5, 100, // corePoolSize, maximumPoolSize
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(1000), // 有界队列只允许100个待执行任务
new ThreadPoolExecutor.AbortPolicy() // 超出直接抛异常
@ -130,7 +130,7 @@ public class Room implements AutoCloseable {
if (magValue != null) {
this.mag = magValue.getMag();
}
log.info("mag:{}", mag);
long curTime = duringTime.addAndGet(this.mag);
sendRemainTime((totalTime.get() - curTime));

View File

@ -144,6 +144,7 @@ public class ScenarioTaskServiceImpl extends
ScenarioTask scenarioTask = new ScenarioTask();
scenarioTask.setScenarioId(scenario.getId());
List<ScenarioTask> taskList = this.queryTaskList(scenarioTask);
log.info("taskList.size ::{}", taskList.size());
for (ScenarioTask task : taskList) {
try {
long diff = Duration.between(scenario.getStartTime(),task.getStartTime())
@ -152,6 +153,7 @@ public class ScenarioTaskServiceImpl extends
switch (task.getTaskType()) {
//移动任务
case "1":
log.info("move task::{}",diff);
MoveRootTask moveRootTask = new MoveRootTask(task, roomId);
RoomManager.addAction(roomId, diff, moveRootTask);
break;
@ -166,6 +168,7 @@ public class ScenarioTaskServiceImpl extends
case "6":
case "7":
case "8":
log.info("supplier task::{}",diff);
SupplierTask supplierTask = new SupplierTask(task, roomId);
RoomManager.addAction(roomId, diff, supplierTask);
break;