任务相关
This commit is contained in:
parent
f59eabb06f
commit
e0dc6d32f8
|
|
@ -206,12 +206,16 @@ public abstract class AbtParentTask implements TaskAction {
|
||||||
ScheduledExecutorService schedule = Executors.newScheduledThreadPool(
|
ScheduledExecutorService schedule = Executors.newScheduledThreadPool(
|
||||||
1);
|
1);
|
||||||
schedule.scheduleWithFixedDelay(() -> {
|
schedule.scheduleWithFixedDelay(() -> {
|
||||||
log.info("task is running....");
|
|
||||||
try {
|
try {
|
||||||
if (this.getRoomStatus()) {
|
if (this.getRoomStatus()) {
|
||||||
if (distanceInfoMap.isEmpty()) {
|
if (distanceInfoMap.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(!this.canMoved.get()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.info("{}-移动中",this.scenarioTask.getResourceId());
|
||||||
long duringTime = getDuringTime() - taskRelativeTime;
|
long duringTime = getDuringTime() - taskRelativeTime;
|
||||||
if (duringTime <= 0) {
|
if (duringTime <= 0) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -113,10 +113,12 @@ public class MoveTask extends AbtParentTask implements TaskAction {
|
||||||
try {
|
try {
|
||||||
//获取油品消耗规则
|
//获取油品消耗规则
|
||||||
String fuelConsumptionStr = SpringUtil.getBean(Environment.class)
|
String fuelConsumptionStr = SpringUtil.getBean(Environment.class)
|
||||||
.getProperty("fuel_spreed");
|
.getProperty("fuel.spreed");
|
||||||
|
log.info("油料消耗速度::{}",fuelConsumptionStr);
|
||||||
fuelConsumption = Double.parseDouble(fuelConsumptionStr == null ? "0" : fuelConsumptionStr);
|
fuelConsumption = Double.parseDouble(fuelConsumptionStr == null ? "0" : fuelConsumptionStr);
|
||||||
fuelThreshold = Double.parseDouble(SpringUtil.getBean(Environment.class)
|
fuelThreshold = Double.parseDouble(SpringUtil.getBean(Environment.class)
|
||||||
.getProperty("fuel.warn ", "0"));
|
.getProperty("fuel.warn ", "0"));
|
||||||
|
log.info("油料最低阈值::{}",fuelThreshold);
|
||||||
statisticBean = SpringUtil.getBean(StatisticServiceImpl.class)
|
statisticBean = SpringUtil.getBean(StatisticServiceImpl.class)
|
||||||
.statistic(scenarioTask.getResourceId());
|
.statistic(scenarioTask.getResourceId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -136,10 +138,12 @@ public class MoveTask extends AbtParentTask implements TaskAction {
|
||||||
|
|
||||||
double fuel = getCurrentFuel();
|
double fuel = getCurrentFuel();
|
||||||
if (fuel == 0) {
|
if (fuel == 0) {
|
||||||
log.error("fuel is empty");
|
log.error("{}-油料为空",scenarioTask.getResourceId());
|
||||||
|
this.canMoved.set(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fuel = fuel - currentUseUp;
|
fuel = fuel - currentUseUp;
|
||||||
|
log.info("{}-当前油料{}",scenarioTask.getResourceId(),fuel);
|
||||||
Object statisticObj = redis.hget(
|
Object statisticObj = redis.hget(
|
||||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||||
"scenarioInfo");
|
"scenarioInfo");
|
||||||
|
|
@ -153,7 +157,7 @@ public class MoveTask extends AbtParentTask implements TaskAction {
|
||||||
|
|
||||||
double totalFuel = statisticBean.getFuel().getTotal();
|
double totalFuel = statisticBean.getFuel().getTotal();
|
||||||
if (fuel * 100 / totalFuel < fuelThreshold && !requestFlag.get()) {
|
if (fuel * 100 / totalFuel < fuelThreshold && !requestFlag.get()) {
|
||||||
log.info("fuel is not enough,stop moving");
|
log.info("{}-油料不足",scenarioTask.getResourceId());
|
||||||
this.canMoved.set(false);
|
this.canMoved.set(false);
|
||||||
requestFlag.set(true);
|
requestFlag.set(true);
|
||||||
//需要产生需求
|
//需要产生需求
|
||||||
|
|
|
||||||
|
|
@ -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