From ddf9e082f22c6dd9909b6c37d0d6188d0fd74659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=8E=89=E4=B8=9C?= <129883742+liyudong2018@users.noreply.github.com> Date: Sun, 21 Sep 2025 02:21:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hivekion/room/bean/AbtParentTask.java | 36 +++++++++++++++---- .../resources/application-rule.properties | 2 +- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/hivekion/room/bean/AbtParentTask.java b/src/main/java/com/hivekion/room/bean/AbtParentTask.java index bf31cea..b07ecf9 100644 --- a/src/main/java/com/hivekion/room/bean/AbtParentTask.java +++ b/src/main/java/com/hivekion/room/bean/AbtParentTask.java @@ -18,6 +18,7 @@ import com.hivekion.scenario.entity.ScenarioResource; import com.hivekion.scenario.entity.ScenarioTask; import com.hivekion.scenario.service.impl.BattleSupplierServiceImpl; import com.hivekion.scenario.service.impl.ScenarioTaskServiceImpl; +import com.hivekion.statistic.bean.EditScenarioInfo; import com.hivekion.statistic.bean.ScenarioInfo; import com.hivekion.statistic.bean.StatisticBean; import com.hivekion.statistic.service.impl.StatisticServiceImpl; @@ -32,10 +33,8 @@ import java.util.Map.Entry; import java.util.NavigableMap; import java.util.TreeMap; import java.util.concurrent.Executors; -import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; @@ -200,7 +199,7 @@ public abstract class AbtParentTask implements TaskAction { Map dataMap = new HashMap<>(); dataMap.put("resourceId", scenarioTask.getResourceId()); 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) { RoomManager.getRoom(roomId) .addResourcePath(this.scenarioTask.getResourceId(), coordinates); @@ -259,11 +258,12 @@ public abstract class AbtParentTask implements TaskAction { if (this.getRoomStatus()) { double currentFuel = getCurrentFuel(); - if (currentFuel < 0) { + double totalFuel = statisticBean.getFuel().getTotal(); + if (currentFuel <= 0 || totalFuel <= 0) { log.error("{}:油量为零停止移动", this.scenarioTask.getResourceId()); return; } - double totalFuel = statisticBean.getFuel().getTotal(); + log.info("{}-当前比值{},阈值{}", scenarioTask.getResourceId(), currentFuel * 100 / totalFuel, fuelThreshold); @@ -277,7 +277,7 @@ public abstract class AbtParentTask implements TaskAction { produceTask(currentFuel); return; } - if(currentFuel * 100 / totalFuel < fuelThreshold ){ + if (currentFuel * 100 / totalFuel < fuelThreshold) { log.error("{}:油量不足停止移动,等待补给", this.scenarioTask.getResourceId()); return; } @@ -340,6 +340,15 @@ public abstract class AbtParentTask implements TaskAction { ResponseCmdInfo.create(WsCmdTypeEnum.PATH_UPDATE.getCode(), roomId, 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) { NavigableMap subPathMap = distanceInfoMap.subMap(startPoint.get(), true, endPoint.getKey(), true); @@ -381,6 +390,19 @@ public abstract class AbtParentTask implements TaskAction { 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) { if (StringUtils.isBlank(resourceId)) { @@ -410,7 +432,7 @@ public abstract class AbtParentTask implements TaskAction { } protected double getCurrentFuel() { - Object statisticObj = redisUtil.hget( + Object statisticObj = SpringUtil.getBean(RedisUtil.class).hget( scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(), "scenarioInfo"); diff --git a/src/main/resources/application-rule.properties b/src/main/resources/application-rule.properties index de7cb24..f39607c 100644 --- a/src/main/resources/application-rule.properties +++ b/src/main/resources/application-rule.properties @@ -3,7 +3,7 @@ death.warn = 56 ammunition.warn = 3 food.warn = 3 water.warn = 3 -fuel.warn = 99.6 +fuel.warn = 80.6 medical.warn = 1 death.spreed = 3 injured.spreed = 3