任务相关
This commit is contained in:
parent
f539feef7f
commit
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,13 @@ 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 +169,20 @@ 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);
|
||||
SpringUtil.getBean(BattleConsumeServiceImpl.class).save(battleConsume);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user