任务相关
This commit is contained in:
parent
de3028c19a
commit
f775eb9214
|
|
@ -127,7 +127,7 @@ public abstract class AbtParentTask implements TaskAction {
|
||||||
|
|
||||||
protected void initPath() {
|
protected void initPath() {
|
||||||
try {
|
try {
|
||||||
|
log.info("init path");
|
||||||
String url = SpringUtil.getBean(Environment.class).getProperty("path.planning.url");
|
String url = SpringUtil.getBean(Environment.class).getProperty("path.planning.url");
|
||||||
String params = url + "?"
|
String params = url + "?"
|
||||||
+ "profile=car"
|
+ "profile=car"
|
||||||
|
|
@ -142,7 +142,7 @@ public abstract class AbtParentTask implements TaskAction {
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.bodyToMono(String.class)
|
.bodyToMono(String.class)
|
||||||
.block();
|
.block();
|
||||||
|
log.info("init path finished ::{}",result);
|
||||||
JSONObject pointJson = JSON.parseObject(result);
|
JSONObject pointJson = JSON.parseObject(result);
|
||||||
//获取路径点
|
//获取路径点
|
||||||
if (pointJson != null) {
|
if (pointJson != null) {
|
||||||
|
|
@ -206,12 +206,16 @@ public abstract class AbtParentTask implements TaskAction {
|
||||||
if (this.getRoomStatus()) {
|
if (this.getRoomStatus()) {
|
||||||
|
|
||||||
long duringTime = getDuringTime() - taskRelativeTime;
|
long duringTime = getDuringTime() - taskRelativeTime;
|
||||||
|
if(duringTime <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
log.info("duringTime::{}", duringTime);
|
|
||||||
//跑动距离
|
//跑动距离
|
||||||
double distance = duringTime * speed;
|
double distance = duringTime * speed;
|
||||||
|
|
||||||
//获取大与此距离的第一个路线点key
|
//获取大与此距离的第一个路线点key
|
||||||
Entry<Double, Coordinate> endPoint = distanceInfoMap.ceilingEntry(distance);
|
Entry<Double, Coordinate> endPoint = distanceInfoMap.ceilingEntry(distance);
|
||||||
|
|
||||||
//ws数据
|
//ws数据
|
||||||
List<double[]> dataList = new ArrayList<>();
|
List<double[]> dataList = new ArrayList<>();
|
||||||
HashMap<Object, Object> dataMap = new HashMap<>();
|
HashMap<Object, Object> dataMap = new HashMap<>();
|
||||||
|
|
@ -221,8 +225,7 @@ 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());
|
||||||
// log.info("distance::{},lowerKey::{},endPoint{}",distance,lowerKey,endPoint.getKey());
|
|
||||||
//获取从上一个开始节点到lowKey的数据
|
|
||||||
NavigableMap<Double, Coordinate> subPathMap = distanceInfoMap.subMap(startPoint.get(),
|
NavigableMap<Double, Coordinate> subPathMap = distanceInfoMap.subMap(startPoint.get(),
|
||||||
true, lowerKey, true);
|
true, lowerKey, true);
|
||||||
for (Double key : subPathMap.keySet()) {
|
for (Double key : subPathMap.keySet()) {
|
||||||
|
|
@ -272,6 +275,8 @@ public abstract class AbtParentTask implements TaskAction {
|
||||||
Global.sendCmdInfoQueue.add(
|
Global.sendCmdInfoQueue.add(
|
||||||
ResponseCmdInfo.create(WsCmdTypeEnum.PATH_FINISHED.getCode(), roomId,
|
ResponseCmdInfo.create(WsCmdTypeEnum.PATH_FINISHED.getCode(), roomId,
|
||||||
scenarioTask.getScenarioId(), dataMap));
|
scenarioTask.getScenarioId(), dataMap));
|
||||||
|
//任务终止
|
||||||
|
schedule.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
|
||||||
* 初始化环境
|
* 初始化环境
|
||||||
*/
|
*/
|
||||||
private void initEnv() {
|
private void initEnv() {
|
||||||
|
try{
|
||||||
//获取油品消耗规则
|
//获取油品消耗规则
|
||||||
String fuelConsumptionStr = SpringUtil.getBean(Environment.class)
|
String fuelConsumptionStr = SpringUtil.getBean(Environment.class)
|
||||||
.getProperty("fuel_spreed");
|
.getProperty("fuel_spreed");
|
||||||
|
|
@ -86,11 +86,15 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
|
||||||
.getProperty("fuel.warn ", "0"));
|
.getProperty("fuel.warn ", "0"));
|
||||||
statisticBean = SpringUtil.getBean(StatisticServiceImpl.class)
|
statisticBean = SpringUtil.getBean(StatisticServiceImpl.class)
|
||||||
.statistic(scenarioTask.getResourceId());
|
.statistic(scenarioTask.getResourceId());
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("init env exception",e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void fuelConsumption() {
|
private void fuelConsumption() {
|
||||||
|
try{
|
||||||
ScheduledExecutorService schedule = Executors.newScheduledThreadPool(
|
ScheduledExecutorService schedule = Executors.newScheduledThreadPool(
|
||||||
1);
|
1);
|
||||||
schedule.scheduleWithFixedDelay(() -> {
|
schedule.scheduleWithFixedDelay(() -> {
|
||||||
|
|
@ -124,6 +128,10 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
|
||||||
|
|
||||||
|
|
||||||
}, 0, consumptionTaskInterval, TimeUnit.SECONDS);
|
}, 0, consumptionTaskInterval, TimeUnit.SECONDS);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("fuel consumption exception",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ food.warn = 3
|
||||||
water.warn = 3
|
water.warn = 3
|
||||||
fuel.warn = 2
|
fuel.warn = 2
|
||||||
medical.warn = 1
|
medical.warn = 1
|
||||||
death.spreed = 3;
|
death.spreed = 3
|
||||||
injured.spreed = 3;
|
injured.spreed = 3
|
||||||
ammunition_spreed = 2.6;
|
ammunition_spreed = 2.6
|
||||||
food_spreed = 2.3;
|
food_spreed = 2.3
|
||||||
water_spreed = 3.6;
|
water_spreed = 3.6
|
||||||
fuel_spreed = 3.6;
|
fuel_spreed = 3.6
|
||||||
medical_spreed = 1.6;
|
medical_spreed = 1.6
|
||||||
Loading…
Reference in New Issue
Block a user