Compare commits
5 Commits
41e82f91c1
...
07aeee82d0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
07aeee82d0 | ||
![]() |
a0f8a1ec96 | ||
![]() |
f724eac193 | ||
![]() |
31be71a1d2 | ||
![]() |
3924e206f6 |
|
@ -5,8 +5,10 @@ import com.hivekion.common.redis.RedisUtil;
|
|||
import com.hivekion.common.uuid.IdUtils;
|
||||
import com.hivekion.room.RoomManager;
|
||||
import com.hivekion.room.func.TaskAction;
|
||||
import com.hivekion.scenario.entity.BattleConsume;
|
||||
import com.hivekion.scenario.entity.ScenarioResource;
|
||||
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.ScenarioTaskServiceImpl;
|
||||
import com.hivekion.statistic.bean.StatisticBean;
|
||||
|
@ -50,7 +52,7 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
|
|||
/**
|
||||
* 消耗任务间隔
|
||||
*/
|
||||
private final int consumptionTaskInterval = 5;
|
||||
private final int consumptionTaskInterval = 10;
|
||||
/**
|
||||
* redis 服务类
|
||||
*/
|
||||
|
@ -65,7 +67,7 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
|
|||
|
||||
@Override
|
||||
public void doSomeThing() {
|
||||
log.info("move task running:{}",scenarioTask.getResourceId());
|
||||
log.info("move task running:{}", scenarioTask.getResourceId());
|
||||
|
||||
initEnv(); //初始化环境
|
||||
initPath(); //初始化路径
|
||||
|
@ -77,7 +79,7 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
|
|||
* 初始化环境
|
||||
*/
|
||||
private void initEnv() {
|
||||
try{
|
||||
try {
|
||||
//获取油品消耗规则
|
||||
String fuelConsumptionStr = SpringUtil.getBean(Environment.class)
|
||||
.getProperty("fuel_spreed");
|
||||
|
@ -86,15 +88,15 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
|
|||
.getProperty("fuel.warn ", "0"));
|
||||
statisticBean = SpringUtil.getBean(StatisticServiceImpl.class)
|
||||
.statistic(scenarioTask.getResourceId());
|
||||
}catch (Exception e){
|
||||
log.error("init env exception",e);
|
||||
} catch (Exception e) {
|
||||
log.error("init env exception", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void fuelConsumption() {
|
||||
try{
|
||||
try {
|
||||
ScheduledExecutorService schedule = Executors.newScheduledThreadPool(
|
||||
1);
|
||||
schedule.scheduleWithFixedDelay(() -> {
|
||||
|
@ -124,12 +126,14 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
|
|||
}
|
||||
}
|
||||
//插入消耗表
|
||||
insertConsumption(currentUseUp);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}, 0, consumptionTaskInterval, TimeUnit.SECONDS);
|
||||
}catch (Exception e){
|
||||
log.error("fuel consumption exception",e);
|
||||
} catch (Exception e) {
|
||||
log.error("fuel consumption exception", e);
|
||||
}
|
||||
|
||||
|
||||
|
@ -166,12 +170,24 @@ public class MoveRootTask extends AbtParentTask implements TaskAction {
|
|||
task.setFromLng(resourceList.get(0).getLng());
|
||||
task.setFromSource("general");
|
||||
SpringUtil.getBean(ScenarioTaskServiceImpl.class).save(task);
|
||||
//增加到房间任务
|
||||
//增加到房间任务
|
||||
SupplierTask supplierTask = new SupplierTask(task, roomId);
|
||||
//立即执行
|
||||
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,6 +92,8 @@ public class Room implements AutoCloseable {
|
|||
status.set(true);
|
||||
totalTime.set(time);
|
||||
startTask();
|
||||
//初始化系统资源 物资人员等信息
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,4 +197,8 @@ public class Room implements AutoCloseable {
|
|||
public boolean isRunning() {
|
||||
return status.get();
|
||||
}
|
||||
//统一推送方法
|
||||
protected void pushStatus(String resourceId){
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user