任务相关

This commit is contained in:
李玉东 2025-09-21 02:21:29 +08:00
parent e636f7d248
commit ddf9e082f2
2 changed files with 30 additions and 8 deletions

View File

@ -18,6 +18,7 @@ import com.hivekion.scenario.entity.ScenarioResource;
import com.hivekion.scenario.entity.ScenarioTask; import com.hivekion.scenario.entity.ScenarioTask;
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.EditScenarioInfo;
import com.hivekion.statistic.bean.ScenarioInfo; import com.hivekion.statistic.bean.ScenarioInfo;
import com.hivekion.statistic.bean.StatisticBean; import com.hivekion.statistic.bean.StatisticBean;
import com.hivekion.statistic.service.impl.StatisticServiceImpl; import com.hivekion.statistic.service.impl.StatisticServiceImpl;
@ -32,10 +33,8 @@ import java.util.Map.Entry;
import java.util.NavigableMap; import java.util.NavigableMap;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -200,7 +199,7 @@ public abstract class AbtParentTask implements TaskAction {
Map<String, Object> dataMap = new HashMap<>(); Map<String, Object> dataMap = new HashMap<>();
dataMap.put("resourceId", scenarioTask.getResourceId()); dataMap.put("resourceId", scenarioTask.getResourceId());
dataMap.put("points", coordinates); dataMap.put("points", coordinates);
dataMap.put("teamType",resourceMap.get(this.scenarioTask.getResourceId()).getType()); dataMap.put("teamType", resourceMap.get(this.scenarioTask.getResourceId()).getType());
if (RoomManager.getRoom(roomId) != null) { if (RoomManager.getRoom(roomId) != null) {
RoomManager.getRoom(roomId) RoomManager.getRoom(roomId)
.addResourcePath(this.scenarioTask.getResourceId(), coordinates); .addResourcePath(this.scenarioTask.getResourceId(), coordinates);
@ -259,11 +258,12 @@ public abstract class AbtParentTask implements TaskAction {
if (this.getRoomStatus()) { if (this.getRoomStatus()) {
double currentFuel = getCurrentFuel(); double currentFuel = getCurrentFuel();
if (currentFuel < 0) { double totalFuel = statisticBean.getFuel().getTotal();
if (currentFuel <= 0 || totalFuel <= 0) {
log.error("{}:油量为零停止移动", this.scenarioTask.getResourceId()); log.error("{}:油量为零停止移动", this.scenarioTask.getResourceId());
return; return;
} }
double totalFuel = statisticBean.getFuel().getTotal();
log.info("{}-当前比值{},阈值{}", scenarioTask.getResourceId(), log.info("{}-当前比值{},阈值{}", scenarioTask.getResourceId(),
currentFuel * 100 / totalFuel, currentFuel * 100 / totalFuel,
fuelThreshold); fuelThreshold);
@ -277,7 +277,7 @@ public abstract class AbtParentTask implements TaskAction {
produceTask(currentFuel); produceTask(currentFuel);
return; return;
} }
if(currentFuel * 100 / totalFuel < fuelThreshold ){ if (currentFuel * 100 / totalFuel < fuelThreshold) {
log.error("{}:油量不足停止移动,等待补给", this.scenarioTask.getResourceId()); log.error("{}:油量不足停止移动,等待补给", this.scenarioTask.getResourceId());
return; return;
} }
@ -340,6 +340,15 @@ public abstract class AbtParentTask implements TaskAction {
ResponseCmdInfo.create(WsCmdTypeEnum.PATH_UPDATE.getCode(), roomId, ResponseCmdInfo.create(WsCmdTypeEnum.PATH_UPDATE.getCode(), roomId,
scenarioTask.getScenarioId(), dataMap)); scenarioTask.getScenarioId(), dataMap));
//修改位置信息
EditScenarioInfo editScenarioInfo = getEditScenarioInfo(
this.scenarioTask.getResourceId());
editScenarioInfo.getJbxx().getTeam().setLat(coordinate.getLat() + "");
editScenarioInfo.getJbxx().getTeam().setLng(coordinate.getLng() + "");
setEditScenarioInfo(editScenarioInfo);
pushStatus(scenarioTask.getResourceId());
} else if (Double.compare(distance, endPoint.getKey()) == 0) { } else if (Double.compare(distance, endPoint.getKey()) == 0) {
NavigableMap<Double, Coordinate> subPathMap = distanceInfoMap.subMap(startPoint.get(), NavigableMap<Double, Coordinate> subPathMap = distanceInfoMap.subMap(startPoint.get(),
true, endPoint.getKey(), true); true, endPoint.getKey(), true);
@ -381,6 +390,19 @@ public abstract class AbtParentTask implements TaskAction {
private RedisUtil redisUtil; private RedisUtil redisUtil;
protected EditScenarioInfo getEditScenarioInfo(String resourceId) {
String updJsonStr = (String) redisUtil.hget(
this.scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
"updScenarioInfo");
return JSON.parseObject(updJsonStr, EditScenarioInfo.class);
}
protected void setEditScenarioInfo(EditScenarioInfo editScenarioInfo) {
redisUtil.hset(
this.scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
"updScenarioInfo", JSON.toJSONString(editScenarioInfo));
}
//统一推送方法 //统一推送方法
protected void pushStatus(String resourceId) { protected void pushStatus(String resourceId) {
if (StringUtils.isBlank(resourceId)) { if (StringUtils.isBlank(resourceId)) {
@ -410,7 +432,7 @@ public abstract class AbtParentTask implements TaskAction {
} }
protected double getCurrentFuel() { protected double getCurrentFuel() {
Object statisticObj = redisUtil.hget( Object statisticObj = SpringUtil.getBean(RedisUtil.class).hget(
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(), scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
"scenarioInfo"); "scenarioInfo");

View File

@ -3,7 +3,7 @@ death.warn = 56
ammunition.warn = 3 ammunition.warn = 3
food.warn = 3 food.warn = 3
water.warn = 3 water.warn = 3
fuel.warn = 99.6 fuel.warn = 80.6
medical.warn = 1 medical.warn = 1
death.spreed = 3 death.spreed = 3
injured.spreed = 3 injured.spreed = 3