任务相关
This commit is contained in:
parent
5d078e0dac
commit
1af5e030e8
|
|
@ -137,12 +137,13 @@ public abstract class AbtParentTask implements TaskAction {
|
||||||
+ scenarioTask.getToLng()
|
+ scenarioTask.getToLng()
|
||||||
+ "&points_encoded=false"
|
+ "&points_encoded=false"
|
||||||
+ "&algorithm=alternative_route&alternative_route.max_paths=3";
|
+ "&algorithm=alternative_route&alternative_route.max_paths=3";
|
||||||
|
log.info("params:;{}", params);
|
||||||
//获取路线信息
|
//获取路线信息
|
||||||
String result = webClient.get().uri(params)
|
String result = webClient.get().uri(params)
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.bodyToMono(String.class)
|
.bodyToMono(String.class)
|
||||||
.block();
|
.block();
|
||||||
log.info("init path finished ::{}",result);
|
log.info("init path finished ::{}", result);
|
||||||
JSONObject pointJson = JSON.parseObject(result);
|
JSONObject pointJson = JSON.parseObject(result);
|
||||||
//获取路径点
|
//获取路径点
|
||||||
if (pointJson != null) {
|
if (pointJson != null) {
|
||||||
|
|
@ -204,9 +205,11 @@ public abstract class AbtParentTask implements TaskAction {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.getRoomStatus()) {
|
if (this.getRoomStatus()) {
|
||||||
|
if (distanceInfoMap.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
long duringTime = getDuringTime() - taskRelativeTime;
|
long duringTime = getDuringTime() - taskRelativeTime;
|
||||||
if(duringTime <= 0) {
|
if (duringTime <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -215,11 +218,11 @@ public abstract class AbtParentTask implements TaskAction {
|
||||||
|
|
||||||
//获取大与此距离的第一个路线点key
|
//获取大与此距离的第一个路线点key
|
||||||
Entry<Double, Coordinate> endPoint = distanceInfoMap.ceilingEntry(distance);
|
Entry<Double, Coordinate> endPoint = distanceInfoMap.ceilingEntry(distance);
|
||||||
if(endPoint == null) {
|
if (endPoint == null) {
|
||||||
endPoint = distanceInfoMap.lastEntry();
|
endPoint = distanceInfoMap.lastEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("enPoint::{}",endPoint);
|
log.info("enPoint::{}",endPoint);
|
||||||
//ws数据
|
//ws数据
|
||||||
List<double[]> dataList = new ArrayList<>();
|
List<double[]> dataList = new ArrayList<>();
|
||||||
HashMap<Object, Object> dataMap = new HashMap<>();
|
HashMap<Object, Object> dataMap = new HashMap<>();
|
||||||
|
|
@ -229,6 +232,9 @@ public abstract class AbtParentTask implements TaskAction {
|
||||||
if (Double.compare(distance, endPoint.getKey()) < 0) {
|
if (Double.compare(distance, endPoint.getKey()) < 0) {
|
||||||
//获取小于最大值的第一个key
|
//获取小于最大值的第一个key
|
||||||
Double lowerKey = distanceInfoMap.lowerKey(endPoint.getKey());
|
Double lowerKey = distanceInfoMap.lowerKey(endPoint.getKey());
|
||||||
|
if(lowerKey==null){
|
||||||
|
lowerKey = endPoint.getKey();
|
||||||
|
}
|
||||||
|
|
||||||
NavigableMap<Double, Coordinate> subPathMap = distanceInfoMap.subMap(startPoint.get(),
|
NavigableMap<Double, Coordinate> subPathMap = distanceInfoMap.subMap(startPoint.get(),
|
||||||
true, lowerKey, true);
|
true, lowerKey, true);
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doSomeThing() {
|
public void doSomeThing() {
|
||||||
log.info("move task running");
|
log.info("move task running:{}",scenarioTask.getResourceId());
|
||||||
|
|
||||||
initEnv(); //初始化环境
|
initEnv(); //初始化环境
|
||||||
initPath(); //初始化路径
|
initPath(); //初始化路径
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ public class Room implements AutoCloseable {
|
||||||
//线程池
|
//线程池
|
||||||
private final ExecutorService actionExecutor =
|
private final ExecutorService actionExecutor =
|
||||||
new ThreadPoolExecutor(
|
new ThreadPoolExecutor(
|
||||||
5, 5, // corePoolSize, maximumPoolSize
|
5, 100, // corePoolSize, maximumPoolSize
|
||||||
0L, TimeUnit.MILLISECONDS,
|
0L, TimeUnit.MILLISECONDS,
|
||||||
new LinkedBlockingQueue<>(1000), // 有界队列,只允许100个待执行任务
|
new LinkedBlockingQueue<>(1000), // 有界队列,只允许100个待执行任务
|
||||||
new ThreadPoolExecutor.AbortPolicy() // 超出直接抛异常
|
new ThreadPoolExecutor.AbortPolicy() // 超出直接抛异常
|
||||||
|
|
@ -130,7 +130,7 @@ public class Room implements AutoCloseable {
|
||||||
if (magValue != null) {
|
if (magValue != null) {
|
||||||
this.mag = magValue.getMag();
|
this.mag = magValue.getMag();
|
||||||
}
|
}
|
||||||
log.info("mag:{}", mag);
|
|
||||||
long curTime = duringTime.addAndGet(this.mag);
|
long curTime = duringTime.addAndGet(this.mag);
|
||||||
|
|
||||||
sendRemainTime((totalTime.get() - curTime));
|
sendRemainTime((totalTime.get() - curTime));
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,7 @@ public class ScenarioTaskServiceImpl extends
|
||||||
ScenarioTask scenarioTask = new ScenarioTask();
|
ScenarioTask scenarioTask = new ScenarioTask();
|
||||||
scenarioTask.setScenarioId(scenario.getId());
|
scenarioTask.setScenarioId(scenario.getId());
|
||||||
List<ScenarioTask> taskList = this.queryTaskList(scenarioTask);
|
List<ScenarioTask> taskList = this.queryTaskList(scenarioTask);
|
||||||
|
log.info("taskList.size ::{}", taskList.size());
|
||||||
for (ScenarioTask task : taskList) {
|
for (ScenarioTask task : taskList) {
|
||||||
try {
|
try {
|
||||||
long diff = Duration.between(scenario.getStartTime(),task.getStartTime())
|
long diff = Duration.between(scenario.getStartTime(),task.getStartTime())
|
||||||
|
|
@ -152,6 +153,7 @@ public class ScenarioTaskServiceImpl extends
|
||||||
switch (task.getTaskType()) {
|
switch (task.getTaskType()) {
|
||||||
//移动任务
|
//移动任务
|
||||||
case "1":
|
case "1":
|
||||||
|
log.info("move task::{}",diff);
|
||||||
MoveRootTask moveRootTask = new MoveRootTask(task, roomId);
|
MoveRootTask moveRootTask = new MoveRootTask(task, roomId);
|
||||||
RoomManager.addAction(roomId, diff, moveRootTask);
|
RoomManager.addAction(roomId, diff, moveRootTask);
|
||||||
break;
|
break;
|
||||||
|
|
@ -166,6 +168,7 @@ public class ScenarioTaskServiceImpl extends
|
||||||
case "6":
|
case "6":
|
||||||
case "7":
|
case "7":
|
||||||
case "8":
|
case "8":
|
||||||
|
log.info("supplier task::{}",diff);
|
||||||
SupplierTask supplierTask = new SupplierTask(task, roomId);
|
SupplierTask supplierTask = new SupplierTask(task, roomId);
|
||||||
RoomManager.addAction(roomId, diff, supplierTask);
|
RoomManager.addAction(roomId, diff, supplierTask);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user