diff --git a/src/main/java/com/hivekion/room/bean/AbtParentTask.java b/src/main/java/com/hivekion/room/bean/AbtParentTask.java index 4f1d157..a1ff001 100644 --- a/src/main/java/com/hivekion/room/bean/AbtParentTask.java +++ b/src/main/java/com/hivekion/room/bean/AbtParentTask.java @@ -206,12 +206,16 @@ public abstract class AbtParentTask implements TaskAction { ScheduledExecutorService schedule = Executors.newScheduledThreadPool( 1); schedule.scheduleWithFixedDelay(() -> { - log.info("task is running...."); + try { if (this.getRoomStatus()) { if (distanceInfoMap.isEmpty()) { return; } + if(!this.canMoved.get()){ + return; + } + log.info("{}-移动中",this.scenarioTask.getResourceId()); long duringTime = getDuringTime() - taskRelativeTime; if (duringTime <= 0) { return; diff --git a/src/main/java/com/hivekion/room/bean/MoveTask.java b/src/main/java/com/hivekion/room/bean/MoveTask.java index a94ae62..d48c134 100644 --- a/src/main/java/com/hivekion/room/bean/MoveTask.java +++ b/src/main/java/com/hivekion/room/bean/MoveTask.java @@ -113,10 +113,12 @@ public class MoveTask extends AbtParentTask implements TaskAction { try { //获取油品消耗规则 String fuelConsumptionStr = SpringUtil.getBean(Environment.class) - .getProperty("fuel_spreed"); + .getProperty("fuel.spreed"); + log.info("油料消耗速度::{}",fuelConsumptionStr); fuelConsumption = Double.parseDouble(fuelConsumptionStr == null ? "0" : fuelConsumptionStr); fuelThreshold = Double.parseDouble(SpringUtil.getBean(Environment.class) .getProperty("fuel.warn ", "0")); + log.info("油料最低阈值::{}",fuelThreshold); statisticBean = SpringUtil.getBean(StatisticServiceImpl.class) .statistic(scenarioTask.getResourceId()); } catch (Exception e) { @@ -136,10 +138,12 @@ public class MoveTask extends AbtParentTask implements TaskAction { double fuel = getCurrentFuel(); if (fuel == 0) { - log.error("fuel is empty"); + log.error("{}-油料为空",scenarioTask.getResourceId()); + this.canMoved.set(false); return; } fuel = fuel - currentUseUp; + log.info("{}-当前油料{}",scenarioTask.getResourceId(),fuel); Object statisticObj = redis.hget( scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(), "scenarioInfo"); @@ -153,7 +157,7 @@ public class MoveTask extends AbtParentTask implements TaskAction { double totalFuel = statisticBean.getFuel().getTotal(); if (fuel * 100 / totalFuel < fuelThreshold && !requestFlag.get()) { - log.info("fuel is not enough,stop moving"); + log.info("{}-油料不足",scenarioTask.getResourceId()); this.canMoved.set(false); requestFlag.set(true); //需要产生需求 diff --git a/src/main/resources/application-rule.properties b/src/main/resources/application-rule.properties index b73df47..641f978 100644 --- a/src/main/resources/application-rule.properties +++ b/src/main/resources/application-rule.properties @@ -5,10 +5,10 @@ food.warn = 3 water.warn = 3 fuel.warn = 2 medical.warn = 1 -death.spreed = 3; -injured.spreed = 3; -ammunition.spreed = 2.6; -food.spreed = 2.3; -water.spreed = 3.6; -fuel.spreed = 3.6; -medical.spreed = 1.6; \ No newline at end of file +death.spreed = 3 +injured.spreed = 3 +ammunition.spreed = 2.6 +food.spreed = 2.3 +water.spreed = 3.6 +fuel.spreed = 3.6 +medical.spreed = 1.6 \ No newline at end of file