Compare commits
No commits in common. "07aeee82d020ae4d6d03da8fd94cb543a84a908e" and "41e82f91c1f636f8ef4c355c94672c6bf27e72c5" have entirely different histories.
07aeee82d0
...
41e82f91c1
|
|
@ -5,10 +5,8 @@ import com.hivekion.common.redis.RedisUtil;
|
||||||
import com.hivekion.common.uuid.IdUtils;
|
import com.hivekion.common.uuid.IdUtils;
|
||||||
import com.hivekion.room.RoomManager;
|
import com.hivekion.room.RoomManager;
|
||||||
import com.hivekion.room.func.TaskAction;
|
import com.hivekion.room.func.TaskAction;
|
||||||
import com.hivekion.scenario.entity.BattleConsume;
|
|
||||||
import com.hivekion.scenario.entity.ScenarioResource;
|
import com.hivekion.scenario.entity.ScenarioResource;
|
||||||
import com.hivekion.scenario.entity.ScenarioTask;
|
import com.hivekion.scenario.entity.ScenarioTask;
|
||||||
import com.hivekion.scenario.service.impl.BattleConsumeServiceImpl;
|
|
||||||
import com.hivekion.scenario.service.impl.BattleSupplierServiceImpl;
|
import com.hivekion.scenario.service.impl.BattleSupplierServiceImpl;
|
||||||
import com.hivekion.scenario.service.impl.ScenarioTaskServiceImpl;
|
import com.hivekion.scenario.service.impl.ScenarioTaskServiceImpl;
|
||||||
import com.hivekion.statistic.bean.StatisticBean;
|
import com.hivekion.statistic.bean.StatisticBean;
|
||||||
|
|
@ -52,7 +50,7 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
|
||||||
/**
|
/**
|
||||||
* 消耗任务间隔
|
* 消耗任务间隔
|
||||||
*/
|
*/
|
||||||
private final int consumptionTaskInterval = 10;
|
private final int consumptionTaskInterval = 5;
|
||||||
/**
|
/**
|
||||||
* redis 服务类
|
* redis 服务类
|
||||||
*/
|
*/
|
||||||
|
|
@ -67,7 +65,7 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doSomeThing() {
|
public void doSomeThing() {
|
||||||
log.info("move task running:{}", scenarioTask.getResourceId());
|
log.info("move task running:{}",scenarioTask.getResourceId());
|
||||||
|
|
||||||
initEnv(); //初始化环境
|
initEnv(); //初始化环境
|
||||||
initPath(); //初始化路径
|
initPath(); //初始化路径
|
||||||
|
|
@ -79,7 +77,7 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
|
||||||
* 初始化环境
|
* 初始化环境
|
||||||
*/
|
*/
|
||||||
private void initEnv() {
|
private void initEnv() {
|
||||||
try {
|
try{
|
||||||
//获取油品消耗规则
|
//获取油品消耗规则
|
||||||
String fuelConsumptionStr = SpringUtil.getBean(Environment.class)
|
String fuelConsumptionStr = SpringUtil.getBean(Environment.class)
|
||||||
.getProperty("fuel_spreed");
|
.getProperty("fuel_spreed");
|
||||||
|
|
@ -88,15 +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) {
|
}catch (Exception e){
|
||||||
log.error("init env exception", e);
|
log.error("init env exception",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void fuelConsumption() {
|
private void fuelConsumption() {
|
||||||
try {
|
try{
|
||||||
ScheduledExecutorService schedule = Executors.newScheduledThreadPool(
|
ScheduledExecutorService schedule = Executors.newScheduledThreadPool(
|
||||||
1);
|
1);
|
||||||
schedule.scheduleWithFixedDelay(() -> {
|
schedule.scheduleWithFixedDelay(() -> {
|
||||||
|
|
@ -126,14 +124,12 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//插入消耗表
|
//插入消耗表
|
||||||
insertConsumption(currentUseUp);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}, 0, consumptionTaskInterval, TimeUnit.SECONDS);
|
}, 0, consumptionTaskInterval, TimeUnit.SECONDS);
|
||||||
} catch (Exception e) {
|
}catch (Exception e){
|
||||||
log.error("fuel consumption exception", e);
|
log.error("fuel consumption exception",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -176,18 +172,6 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
|
||||||
RoomManager.addAction(roomId, 0, supplierTask);
|
RoomManager.addAction(roomId, 0, supplierTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertConsumption(double num) {
|
|
||||||
BattleConsume battleConsume = new BattleConsume();
|
|
||||||
battleConsume.setId(IdUtils.simpleUUID());
|
|
||||||
battleConsume.setResourceId(scenarioTask.getResourceId());
|
|
||||||
battleConsume.setFuel(num);
|
|
||||||
battleConsume.setConsumeDate(LocalDateTime.now());
|
|
||||||
SpringUtil.getBean(BattleConsumeServiceImpl.class).save(battleConsume);
|
|
||||||
}
|
|
||||||
private void pushStatus(double num){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,6 @@ public class Room implements AutoCloseable {
|
||||||
status.set(true);
|
status.set(true);
|
||||||
totalTime.set(time);
|
totalTime.set(time);
|
||||||
startTask();
|
startTask();
|
||||||
//初始化系统资源 物资人员等信息
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -197,8 +195,4 @@ public class Room implements AutoCloseable {
|
||||||
public boolean isRunning() {
|
public boolean isRunning() {
|
||||||
return status.get();
|
return status.get();
|
||||||
}
|
}
|
||||||
//统一推送方法
|
|
||||||
protected void pushStatus(String resourceId){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user