任务相关
This commit is contained in:
parent
5d078e0dac
commit
1af5e030e8
|
@ -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,11 +218,11 @@ public abstract class AbtParentTask implements TaskAction {
|
|||
|
||||
//获取大与此距离的第一个路线点key
|
||||
Entry<Double, Coordinate> endPoint = distanceInfoMap.ceilingEntry(distance);
|
||||
if(endPoint == null) {
|
||||
if (endPoint == null) {
|
||||
endPoint = distanceInfoMap.lastEntry();
|
||||
}
|
||||
|
||||
log.info("enPoint::{}",endPoint);
|
||||
log.info("enPoint::{}",endPoint);
|
||||
//ws数据
|
||||
List<double[]> dataList = new ArrayList<>();
|
||||
HashMap<Object, Object> dataMap = new HashMap<>();
|
||||
|
@ -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);
|
||||
|
|
|
@ -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(); //初始化路径
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user