Merge branch 'main' of http://git.hivekion.com:3000/liyudong/simulation-backend
This commit is contained in:
commit
61c5d6ba56
|
|
@ -190,10 +190,10 @@ public class ScenarioController extends BaseController {
|
|||
* @param type 类型
|
||||
* @return 资源信息
|
||||
*/
|
||||
@GetMapping("/resources/{type}")
|
||||
@GetMapping("/resources/{type}/{teamType}")
|
||||
public ResponseData<List<ScenarioResource>> getResources(
|
||||
|
||||
@PathVariable("type") Integer type) {
|
||||
@PathVariable("type") Integer type,@PathVariable("teamType") Integer teamType) {
|
||||
Map<String, String> iconMap = iconService.iconMap();
|
||||
switch (type) {
|
||||
case 1:
|
||||
|
|
@ -210,10 +210,10 @@ public class ScenarioController extends BaseController {
|
|||
convertEntityToResource(type, tblEntityService.selectAllChild(3), iconMap));
|
||||
case 5:
|
||||
return ResponseData.success(
|
||||
covertTeamInfoToResource(type, iTeaminfoService.queryByType(0), iconMap));
|
||||
covertTeamInfoToResource(type, iTeaminfoService.queryByType(0,teamType), iconMap));
|
||||
case 6:
|
||||
return ResponseData.success(
|
||||
covertTeamInfoToResource(type, iTeaminfoService.queryByType(1), iconMap));
|
||||
covertTeamInfoToResource(type, iTeaminfoService.queryByType(1,teamType), iconMap));
|
||||
case 7:
|
||||
return ResponseData.success(
|
||||
covertBuildInfoToResource(type,iResourceService.listAllBuildResourceByType(7),iconMap));
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ public class Scenario extends SearchInputVo {
|
|||
private String leftBottomLat;
|
||||
@TableField(value = "right_bottom_lat")
|
||||
private String rightBottomLat;
|
||||
private String mark;
|
||||
/**
|
||||
* 想定关联的资源列表
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package com.hivekion.room;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.hivekion.baseData.entity.Scenario;
|
||||
import com.hivekion.room.bean.Room;
|
||||
import com.hivekion.room.func.TaskAction;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* [类的简要说明]
|
||||
|
|
@ -16,6 +18,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||
* @author LiDongYU
|
||||
* @since 2025/7/22
|
||||
*/
|
||||
@Slf4j
|
||||
public class RoomManager {
|
||||
|
||||
private static final Map<String, Room> roomsMap = new ConcurrentHashMap<>();
|
||||
|
|
@ -48,6 +51,7 @@ public class RoomManager {
|
|||
}
|
||||
|
||||
public static void addAction(String id, long time, TaskAction action) {
|
||||
log.info("增加任务::time::{},action::{}",time, JSON.toJSONString(action));
|
||||
Room room = roomsMap.get(id);
|
||||
if (room != null) {
|
||||
room.addAction(time, action);
|
||||
|
|
@ -76,4 +80,14 @@ public class RoomManager {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
public static int getMag(String id){
|
||||
Room room = roomsMap.get(id);
|
||||
if (room != null) {
|
||||
return room.getMag();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
public static Room getRoom(String id){
|
||||
return roomsMap.get(id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,24 @@ import com.hivekion.baseData.service.ScenarioService;
|
|||
import com.hivekion.common.MultiPointGeoPosition;
|
||||
import com.hivekion.common.entity.ResponseCmdInfo;
|
||||
import com.hivekion.common.redis.RedisUtil;
|
||||
import com.hivekion.common.uuid.IdUtils;
|
||||
import com.hivekion.enums.WsCmdTypeEnum;
|
||||
import com.hivekion.room.RoomManager;
|
||||
import com.hivekion.room.func.TaskAction;
|
||||
import com.hivekion.scenario.entity.ScenarioResource;
|
||||
import com.hivekion.scenario.entity.ScenarioTask;
|
||||
import java.time.Duration;
|
||||
import com.hivekion.scenario.service.impl.BattleSupplierServiceImpl;
|
||||
import com.hivekion.scenario.service.impl.ScenarioResourceServiceImpl;
|
||||
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;
|
||||
import com.hivekion.supplier.entity.SupplierRequest;
|
||||
import com.hivekion.supplier.service.impl.SupplierRequestServiceImpl;
|
||||
import com.hivekion.team.entity.Teaminfo;
|
||||
import com.hivekion.team.service.impl.TeaminfoServiceImpl;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
|
@ -23,14 +36,15 @@ 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;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
|
|
@ -46,6 +60,13 @@ import org.springframework.web.reactive.function.client.WebClient;
|
|||
@Slf4j
|
||||
public abstract class AbtParentTask implements TaskAction {
|
||||
|
||||
|
||||
protected final AtomicBoolean taskFinishedStatus = new AtomicBoolean(false);
|
||||
/**
|
||||
* 油料消耗速率
|
||||
*/
|
||||
protected double fuelConsumption = 0;
|
||||
protected double fuelThreshold = 0;
|
||||
/**
|
||||
* 开始点坐标
|
||||
*/
|
||||
|
|
@ -60,28 +81,24 @@ public abstract class AbtParentTask implements TaskAction {
|
|||
protected final String roomId;
|
||||
//http请求
|
||||
protected WebClient webClient = WebClient.create();
|
||||
|
||||
protected final AtomicReference<Coordinate> coordinateReference = new AtomicReference<>();
|
||||
/**
|
||||
* 任务相对与想定的开始时间
|
||||
* 需求产生标志
|
||||
*/
|
||||
private long taskRelativeTime = 0;
|
||||
//线程池
|
||||
protected ThreadPoolExecutor executor = new ThreadPoolExecutor(
|
||||
5, // 核心线程数
|
||||
10, // 最大线程数
|
||||
60L, // 空闲线程存活时间
|
||||
TimeUnit.SECONDS, // 时间单位
|
||||
new LinkedBlockingQueue<>(100), // 任务队列
|
||||
new CustomThreadFactory("MyPool"), // 线程工厂
|
||||
new ThreadPoolExecutor.CallerRunsPolicy() // 拒绝策略
|
||||
);
|
||||
private final AtomicBoolean requestFlag = new AtomicBoolean(false);
|
||||
private StatisticBean statisticBean;
|
||||
|
||||
|
||||
|
||||
public AbtParentTask(ScenarioTask scenarioTask, String roomId) {
|
||||
this.scenarioTask = scenarioTask;
|
||||
this.roomId = roomId;
|
||||
Scenario scenario = SpringUtil.getBean(ScenarioService.class)
|
||||
.getScenarioById(scenarioTask.getScenarioId());
|
||||
taskRelativeTime = Math.abs(
|
||||
Duration.between(scenario.getStartTime(), scenarioTask.getStartTime()).getSeconds());
|
||||
statisticBean = SpringUtil.getBean(StatisticServiceImpl.class)
|
||||
.statistic(scenarioTask.getResourceId());
|
||||
initEnv();
|
||||
}
|
||||
|
||||
public void addScheduledExecutorServiceRefenceToRoom(
|
||||
|
|
@ -119,11 +136,33 @@ public abstract class AbtParentTask implements TaskAction {
|
|||
1);
|
||||
schedule.scheduleWithFixedDelay(() -> {
|
||||
bizTaskOnTiming.execTask();
|
||||
}, 0, 10, TimeUnit.SECONDS);
|
||||
}, 0, 5, TimeUnit.SECONDS);
|
||||
//房间统一管理定时器;房间关闭后,定时器销毁
|
||||
addScheduledExecutorServiceRefenceToRoom(schedule);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化环境
|
||||
*/
|
||||
private void initEnv() {
|
||||
try {
|
||||
//获取油品消耗规则
|
||||
String fuelConsumptionStr = SpringUtil.getBean(Environment.class)
|
||||
.getProperty("fuel.spreed");
|
||||
|
||||
fuelConsumption = Double.parseDouble(fuelConsumptionStr == null ? "0" : fuelConsumptionStr);
|
||||
fuelThreshold = Double.parseDouble(SpringUtil.getBean(Environment.class)
|
||||
.getProperty("fuel.warn", "0"));
|
||||
|
||||
log.info("初始化::{}-油料消耗速度::{},油料最低阈值::{},当前油料::{}",
|
||||
this.scenarioTask.getResourceId(),
|
||||
fuelConsumptionStr, fuelThreshold, getCurrentFuel());
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("init env exception", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void initPath() {
|
||||
try {
|
||||
|
|
@ -138,6 +177,8 @@ public abstract class AbtParentTask implements TaskAction {
|
|||
+ "&points_encoded=false"
|
||||
+ "&algorithm=alternative_route&alternative_route.max_paths=3";
|
||||
log.info("params:;{}", params);
|
||||
Room room = RoomManager.getRoom(this.roomId);
|
||||
Map<String, ScenarioResource> resourceMap = room.getScenarioResourceMap();
|
||||
//获取路线信息
|
||||
String result = webClient.get().uri(params)
|
||||
.retrieve()
|
||||
|
|
@ -154,6 +195,11 @@ public abstract class AbtParentTask implements TaskAction {
|
|||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("resourceId", scenarioTask.getResourceId());
|
||||
dataMap.put("points", coordinates);
|
||||
dataMap.put("teamType", resourceMap.get(this.scenarioTask.getResourceId()).getType());
|
||||
if (RoomManager.getRoom(roomId) != null) {
|
||||
RoomManager.getRoom(roomId)
|
||||
.addResourcePath(this.scenarioTask.getResourceId(), coordinates);
|
||||
}
|
||||
//推送路径任务
|
||||
Global.sendCmdInfoQueue.add(
|
||||
ResponseCmdInfo.create(WsCmdTypeEnum.PATH_INIT.getCode(), roomId,
|
||||
|
|
@ -197,26 +243,56 @@ public abstract class AbtParentTask implements TaskAction {
|
|||
}
|
||||
}
|
||||
|
||||
protected void updatePath(double speed,TaskAction duringAction, TaskAction finishedAction) {
|
||||
|
||||
protected void updatePath(double speed, TaskAction duringAction, TaskAction finishedAction) {
|
||||
AtomicLong duringTime = new AtomicLong(0);
|
||||
ScheduledExecutorService schedule = Executors.newScheduledThreadPool(
|
||||
1);
|
||||
schedule.scheduleWithFixedDelay(() -> {
|
||||
log.info("task is running....");
|
||||
|
||||
try {
|
||||
|
||||
if (this.getRoomStatus()) {
|
||||
//自动生成的任务不需要判断油量;不要在生成新的任务
|
||||
log.info("{}-fromSource::{}",scenarioTask.getResourceId(),scenarioTask.getFromSource());
|
||||
if(!"general".equals(scenarioTask.getFromSource())) {
|
||||
double currentFuel = getCurrentFuel();
|
||||
double totalFuel = statisticBean.getFuel().getTotal();
|
||||
log.info("totalFuel::{}", totalFuel);
|
||||
if (currentFuel <= 0 || totalFuel <= 0) {
|
||||
log.error("{}:油量为零停止移动", this.scenarioTask.getResourceId());
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("{}-当前比值{},阈值{}", scenarioTask.getResourceId(),
|
||||
currentFuel * 100 / totalFuel,
|
||||
fuelThreshold);
|
||||
if (currentFuel * 100 / totalFuel < fuelThreshold && !requestFlag.get()) {
|
||||
log.info("{}-油料不足,需要补充,新建需求和任务", scenarioTask.getResourceId());
|
||||
|
||||
requestFlag.set(true);
|
||||
//需要产生需求
|
||||
produceFuelRequest();
|
||||
//产生任务
|
||||
produceTask(currentFuel);
|
||||
return;
|
||||
}
|
||||
if (currentFuel * 100 / totalFuel < fuelThreshold) {
|
||||
log.error("{}:油量不足停止移动,等待补给", this.scenarioTask.getResourceId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (distanceInfoMap.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
long duringTime = getDuringTime() - taskRelativeTime;
|
||||
if (duringTime <= 0) {
|
||||
return;
|
||||
}
|
||||
if(duringAction!=null){
|
||||
|
||||
if (duringAction != null) {
|
||||
duringAction.doSomeThing();
|
||||
}
|
||||
log.info("移动中..... 放大系数{}",RoomManager.getMag(roomId));
|
||||
//跑动距离
|
||||
double distance = duringTime * speed;
|
||||
double distance = duringTime.getAndAdd(RoomManager.getMag(roomId)) * speed;
|
||||
|
||||
//获取大与此距离的第一个路线点key
|
||||
Entry<Double, Coordinate> endPoint = distanceInfoMap.ceilingEntry(distance);
|
||||
|
|
@ -224,7 +300,6 @@ public abstract class AbtParentTask implements TaskAction {
|
|||
endPoint = distanceInfoMap.lastEntry();
|
||||
}
|
||||
|
||||
// log.info("enPoint::{}",endPoint);
|
||||
//ws数据
|
||||
List<double[]> dataList = new ArrayList<>();
|
||||
HashMap<Object, Object> dataMap = new HashMap<>();
|
||||
|
|
@ -234,7 +309,7 @@ public abstract class AbtParentTask implements TaskAction {
|
|||
if (Double.compare(distance, endPoint.getKey()) < 0) {
|
||||
//获取小于最大值的第一个key
|
||||
Double lowerKey = distanceInfoMap.lowerKey(endPoint.getKey());
|
||||
if(lowerKey==null){
|
||||
if (lowerKey == null) {
|
||||
lowerKey = endPoint.getKey();
|
||||
}
|
||||
|
||||
|
|
@ -258,6 +333,7 @@ public abstract class AbtParentTask implements TaskAction {
|
|||
coordinate.setLng(insertPoints[1]);
|
||||
distanceInfoMap.put(distance, coordinate);
|
||||
startPoint.set(distance);
|
||||
coordinateReference.set(coordinate);
|
||||
SpringUtil.getBean(RedisUtil.class).hset(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"position", JSON.toJSONString(coordinate));
|
||||
|
|
@ -266,6 +342,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,scenarioTask.getResourceId());
|
||||
pushStatus(scenarioTask.getResourceId());
|
||||
|
||||
} else if (Double.compare(distance, endPoint.getKey()) == 0) {
|
||||
NavigableMap<Double, Coordinate> subPathMap = distanceInfoMap.subMap(startPoint.get(),
|
||||
true, endPoint.getKey(), true);
|
||||
|
|
@ -273,7 +358,7 @@ public abstract class AbtParentTask implements TaskAction {
|
|||
Coordinate coordinate = subPathMap.get(key);
|
||||
dataList.add(new double[]{coordinate.getLng(), coordinate.getLat()});
|
||||
}
|
||||
|
||||
coordinateReference.set(endPoint.getValue());
|
||||
startPoint.set(endPoint.getKey());
|
||||
Global.sendCmdInfoQueue.add(
|
||||
ResponseCmdInfo.create(WsCmdTypeEnum.PATH_UPDATE.getCode(), roomId,
|
||||
|
|
@ -283,6 +368,7 @@ public abstract class AbtParentTask implements TaskAction {
|
|||
if (finishedAction != null) {
|
||||
finishedAction.doSomeThing();
|
||||
}
|
||||
taskFinishedStatus.set(true);
|
||||
//完成路径
|
||||
Global.sendCmdInfoQueue.add(
|
||||
ResponseCmdInfo.create(WsCmdTypeEnum.PATH_FINISHED.getCode(), roomId,
|
||||
|
|
@ -303,10 +389,176 @@ public abstract class AbtParentTask implements TaskAction {
|
|||
//房间统一管理定时器;房间关闭后,定时器销毁
|
||||
addScheduledExecutorServiceRefenceToRoom(schedule);
|
||||
}
|
||||
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
protected EditScenarioInfo getEditScenarioInfo(String resourceId) {
|
||||
String updJsonStr = (String) SpringUtil.getBean(RedisUtil.class).hget(
|
||||
this.scenarioTask.getScenarioId() + "-" + roomId + "-" + resourceId,
|
||||
"updScenarioInfo");
|
||||
return JSON.parseObject(updJsonStr, EditScenarioInfo.class);
|
||||
}
|
||||
|
||||
protected void setEditScenarioInfo(EditScenarioInfo editScenarioInfo,String resourceId) {
|
||||
SpringUtil.getBean(RedisUtil.class).hset(
|
||||
this.scenarioTask.getScenarioId() + "-" + roomId + "-" + resourceId,
|
||||
"updScenarioInfo", JSON.toJSONString(editScenarioInfo));
|
||||
}
|
||||
|
||||
//统一推送方法
|
||||
protected void pushStatus(String resourceId) {
|
||||
if (StringUtils.isBlank(resourceId)) {
|
||||
return;
|
||||
}
|
||||
if (redisUtil == null) {
|
||||
redisUtil = SpringUtil.getBean(RedisUtil.class);
|
||||
}
|
||||
String jsonStr = (String) redisUtil.hget(
|
||||
this.scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"scenarioInfo");
|
||||
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
||||
respObj.setData(jsonStr);
|
||||
respObj.setRoom(roomId);
|
||||
respObj.setScenarioId(scenarioTask.getScenarioId());
|
||||
respObj.setCmdType("scenarioInfo");
|
||||
Global.sendCmdInfoQueue.add(respObj);
|
||||
String updJsonStr = (String) redisUtil.hget(
|
||||
this.scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"updScenarioInfo");
|
||||
ResponseCmdInfo<String> respUpdObj = new ResponseCmdInfo<>();
|
||||
respUpdObj.setData(updJsonStr);
|
||||
respUpdObj.setRoom(roomId);
|
||||
respUpdObj.setScenarioId(scenarioTask.getScenarioId());
|
||||
respUpdObj.setCmdType("updScenarioInfo");
|
||||
Global.sendCmdInfoQueue.add(respUpdObj);
|
||||
}
|
||||
|
||||
protected double getCurrentFuel() {
|
||||
Object statisticObj = SpringUtil.getBean(RedisUtil.class).hget(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"scenarioInfo");
|
||||
|
||||
if (statisticObj != null) {
|
||||
ScenarioInfo scenarioInfo = JSON.parseObject(statisticObj.toString(), ScenarioInfo.class);
|
||||
return scenarioInfo.getFuel().getCurrent();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void produceFuelRequest() {
|
||||
log.info("{}-产生油料保障需求", this.scenarioTask.getResourceId());
|
||||
SupplierRequest supplierRequest = new SupplierRequest();
|
||||
supplierRequest.setId(IdUtils.simpleUUID());
|
||||
supplierRequest.setFromResourceId(scenarioTask.getResourceId());
|
||||
supplierRequest.setSupplierNum(String.valueOf(statisticBean.getFuel().getTotal()));
|
||||
supplierRequest.setSupplierType("fuel");
|
||||
supplierRequest.setGeneralTime(LocalDateTime.now());
|
||||
supplierRequest.setLat(scenarioTask.getToLat());
|
||||
supplierRequest.setLng(scenarioTask.getToLng());
|
||||
supplierRequest.setHandleFlag(1);
|
||||
SpringUtil.getBean(SupplierRequestServiceImpl.class).save(supplierRequest);
|
||||
}
|
||||
|
||||
private void produceTask(double fuel) {
|
||||
try {
|
||||
Map<Integer, Teaminfo> teamInfoMap = SpringUtil.getBean(TeaminfoServiceImpl.class)
|
||||
.teamInfoMap();
|
||||
|
||||
log.info("{}-产生自动保障任务", this.scenarioTask.getResourceId());
|
||||
List<ScenarioResource> resourceList = SpringUtil.getBean(BattleSupplierServiceImpl.class)
|
||||
.selectSupplierResource(scenarioTask.getResourceId());
|
||||
log.info("{}-可选保障分队长度{}", scenarioTask.getResourceId(), resourceList.size());
|
||||
if (!resourceList.isEmpty()) {
|
||||
ScenarioResource supplierResource = null;
|
||||
// 找出油料保障分队
|
||||
for (ScenarioResource resource : resourceList) {
|
||||
|
||||
|
||||
Teaminfo teaminfo = teamInfoMap.get(resource.getResourceId());
|
||||
|
||||
if ("SUPPLIER_FUEL".equals(teaminfo.getRoleCode())) {
|
||||
supplierResource = resource;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (supplierResource == null) {
|
||||
log.error("找不到对应的油料保障分队");
|
||||
return;
|
||||
}
|
||||
//找出油料仓库
|
||||
List<ScenarioResource> resources = SpringUtil.getBean(ScenarioResourceServiceImpl.class)
|
||||
.selectResourceByRoleCode(scenarioTask.getScenarioId(), "WARE_FUEL_HOUSE");
|
||||
if (resources.isEmpty()) {
|
||||
log.error("找不到油料仓库");
|
||||
return;
|
||||
}
|
||||
|
||||
produceMoveTask(supplierResource, resources.get(0), this.coordinateReference.get(), fuel);
|
||||
|
||||
|
||||
} else {
|
||||
log.error("{}-没有保障分队可以选择", scenarioTask.getResourceId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("produceTask exception", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void produceMoveTask(ScenarioResource supplierResource, ScenarioResource fuelResource,
|
||||
Coordinate coordinate, double minusFuel) {
|
||||
ScenarioTask task = new ScenarioTask();
|
||||
task.setId(IdUtils.simpleUUID());
|
||||
task.setScenarioId(scenarioTask.getScenarioId());
|
||||
task.setResourceId(supplierResource.getId());
|
||||
task.setTaskType("1");
|
||||
|
||||
task.setFromLat(supplierResource.getLat());
|
||||
task.setFromLng(supplierResource.getLng());
|
||||
task.setToLat(fuelResource.getLat());
|
||||
task.setToLng(fuelResource.getLng());
|
||||
task.setStartTime(LocalDateTime.now());
|
||||
task.setFromSource("general");
|
||||
log.info("承担保障任务的resourceId::{}", supplierResource.getId());
|
||||
SpringUtil.getBean(ScenarioTaskServiceImpl.class).save(task);
|
||||
MoveTask moveTask = new MoveTask(task, this.roomId, new TaskAction() {
|
||||
@Override
|
||||
public void doSomeThing() {
|
||||
//创建一个保障任务
|
||||
|
||||
ScenarioTask task = new ScenarioTask();
|
||||
task.setId(IdUtils.simpleUUID());
|
||||
task.setScenarioId(scenarioTask.getScenarioId());
|
||||
task.setResourceId(supplierResource.getId());
|
||||
task.setTaskType("6");
|
||||
task.setInsureResourceId(scenarioTask.getResourceId());
|
||||
task.setSupplierNum(statisticBean.getFuel().getTotal() - minusFuel);
|
||||
task.setToLat(coordinate.getLat() + "");
|
||||
task.setToLng(coordinate.getLng() + "");
|
||||
task.setStartTime(LocalDateTime.now());
|
||||
task.setFromLat(fuelResource.getLat());
|
||||
task.setFromLng(fuelResource.getLng());
|
||||
task.setFromSource("general");
|
||||
SpringUtil.getBean(ScenarioTaskServiceImpl.class).save(task);
|
||||
SupplierTask supplierTask = new SupplierTask(task, roomId);
|
||||
RoomManager.addAction(roomId, 0, supplierTask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "";
|
||||
}
|
||||
});
|
||||
//立即执行
|
||||
RoomManager.addAction(roomId, 0, moveTask);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface BizTaskOnTiming {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hivekion.room.bean;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
|
|
@ -8,6 +9,7 @@ import com.hivekion.Global;
|
|||
import com.hivekion.common.entity.ResponseCmdInfo;
|
||||
import com.hivekion.common.redis.RedisUtil;
|
||||
import com.hivekion.common.uuid.IdUtils;
|
||||
import com.hivekion.room.RoomManager;
|
||||
import com.hivekion.scenario.entity.BattleConsume;
|
||||
import com.hivekion.scenario.entity.ScenarioTask;
|
||||
import com.hivekion.scenario.service.IBattleConsumeService;
|
||||
|
|
@ -16,6 +18,7 @@ import com.hivekion.statistic.service.StatisticService;
|
|||
import com.hivekion.statistic.service.impl.StatisticServiceImpl;
|
||||
import com.hivekion.supplier.entity.SupplierRequest;
|
||||
import com.hivekion.supplier.service.ISupplierRequestService;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
|
@ -40,31 +43,26 @@ import java.util.concurrent.TimeUnit;
|
|||
@Slf4j
|
||||
public class BattleRootTask extends AbtParentTask {
|
||||
|
||||
private StatisticService statisticService = null;
|
||||
private RedisUtil redisUtil = null;
|
||||
|
||||
private ISupplierRequestService supplierRequestService;
|
||||
|
||||
private IBattleConsumeService battleConsumeService;
|
||||
|
||||
private static final Integer DEATH_SPREED = 3;
|
||||
private static final Integer INJURED_SPREED = 3;
|
||||
private static final Double AMMUNITION_SPREED = 2.6D;
|
||||
private static final Double FOOD_SPREED = 2.3D;
|
||||
private static final Double WATER_SPREED = 3.6D;
|
||||
private static final Double FUEL_SPREED = 3.6D;
|
||||
private static final Double MEDICAL_SPREED = 1.6D;
|
||||
|
||||
private static final Double FOOD_SPREED = 0.3D;
|
||||
private static final Double WATER_SPREED = 0.1D;
|
||||
// private static final Double FUEL_SPREED = 3.6D;
|
||||
private static final Double MEDICAL_SPREED = 0.2D;
|
||||
|
||||
private final AtomicBoolean isAlreadyProduceTask = new AtomicBoolean(false);
|
||||
|
||||
public BattleRootTask(ScenarioTask scenarioTask,String roomId) {
|
||||
super(scenarioTask,roomId);
|
||||
}
|
||||
|
||||
private void initBean(){
|
||||
if(statisticService == null) {
|
||||
statisticService = SpringUtil.getBean(StatisticService.class);
|
||||
}
|
||||
|
||||
if(redisUtil == null) {
|
||||
redisUtil = SpringUtil.getBean(RedisUtil.class);
|
||||
}
|
||||
|
|
@ -82,33 +80,14 @@ public class BattleRootTask extends AbtParentTask {
|
|||
this.initBean();
|
||||
if(this.getRoomStatus()) {
|
||||
long initDuringTime = this.getDuringTime();
|
||||
StatisticBean statisticBean = null;
|
||||
try {
|
||||
statisticBean = statisticService.statistic(scenarioTask.getResourceId());
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
redisUtil.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),"duringTime",String.valueOf(initDuringTime));
|
||||
String jsonStr = (String)redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),"scenarioInfo");
|
||||
ScenarioInfo scenarioInfo =JSONObject.parseObject(jsonStr,ScenarioInfo.class);
|
||||
|
||||
HashMap<String,Object> battleParams = new HashMap<>();
|
||||
|
||||
// statisticBean.getAmmunition().getCurrent()
|
||||
//初始化本次战斗任务各种资源数
|
||||
battleParams.put("ammunition",Double.valueOf(statisticBean.getAmmunition().getTotal()).toString());
|
||||
battleParams.put("food",Double.valueOf(statisticBean.getFood().getTotal()).toString());
|
||||
battleParams.put("fuel",Double.valueOf(statisticBean.getFuel().getTotal()).toString());
|
||||
battleParams.put("medical",Double.valueOf(statisticBean.getMedical().getTotal()).toString());
|
||||
battleParams.put("water",Double.valueOf(statisticBean.getWater().getTotal()).toString());
|
||||
battleParams.put("person",Integer.valueOf(statisticBean.getPerson().getTotal()).toString());
|
||||
battleParams.put("death",Integer.valueOf(statisticBean.getPerson().getDeath()).toString());
|
||||
battleParams.put("injured",Integer.valueOf(statisticBean.getPerson().getInjured()).toString());
|
||||
battleParams.put("teamLat",statisticBean.getTeam().getLat().toString());
|
||||
battleParams.put("teamLng",statisticBean.getTeam().getLng().toString());
|
||||
battleParams.put("duringTime",Long.valueOf(initDuringTime).toString());
|
||||
redisUtil.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),battleParams);
|
||||
log.info("===============================初始化本次战斗任务各种资源数====================================");
|
||||
double suppleAmount =statisticBean.getAmmunition().getTotal();
|
||||
int suppleDeath =statisticBean.getPerson().getDeath();
|
||||
int suppleInjured =statisticBean.getPerson().getInjured();
|
||||
double suppleAmount =scenarioInfo.getAmmunition().getTotal();
|
||||
int suppleDeath =scenarioInfo.getPerson().getDeath();
|
||||
int suppleInjured =scenarioInfo.getPerson().getInjured();
|
||||
final Map<String,Boolean> suppleFlagMap = new HashMap<>();
|
||||
suppleFlagMap.put("ammunition",false);
|
||||
suppleFlagMap.put("death",false);
|
||||
|
|
@ -118,159 +97,213 @@ public class BattleRootTask extends AbtParentTask {
|
|||
@Override
|
||||
public void execTask() {
|
||||
log.info("===============================定时检查统计各种资源消耗量 begin====================================");
|
||||
|
||||
Long deathConsume = null;
|
||||
Long injuredConsume = null;
|
||||
Double ammunitionConsume = null;
|
||||
Double foodConsume = null;
|
||||
Double waterConsume = null;
|
||||
Double fuelConsume = null;
|
||||
// Double fuelConsume = null;
|
||||
Double medicalConsume = null;
|
||||
String teamLat = null;
|
||||
String teamLng = null;
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
try {
|
||||
HashMap<String,Object> battleParams = (HashMap<String, Object>) redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId());
|
||||
long duringTime = getDuringTime();
|
||||
long lastDuringTime = Long.valueOf(battleParams.get("duringTime").toString());
|
||||
long intervalDuringTime = duringTime - lastDuringTime;
|
||||
double ammunition = Double.valueOf(battleParams.get("ammunition").toString());
|
||||
double food = Double.valueOf(battleParams.get("food").toString());
|
||||
double fuel = Double.valueOf(battleParams.get("fuel").toString());
|
||||
double medical = Double.valueOf(battleParams.get("medical").toString());
|
||||
double water = Double.valueOf(battleParams.get("water").toString());
|
||||
long death = Long.valueOf(battleParams.get("death").toString());
|
||||
long injured = Long.valueOf(battleParams.get("injured").toString());
|
||||
teamLat = battleParams.get( "teamLat").toString();
|
||||
teamLng = battleParams.get( "teamLng").toString();
|
||||
//
|
||||
deathConsume = DEATH_SPREED * intervalDuringTime;
|
||||
injuredConsume = INJURED_SPREED * intervalDuringTime;
|
||||
ammunitionConsume = intervalDuringTime * AMMUNITION_SPREED;
|
||||
foodConsume = intervalDuringTime * FOOD_SPREED;
|
||||
waterConsume = intervalDuringTime * WATER_SPREED;
|
||||
fuelConsume = intervalDuringTime * FUEL_SPREED;
|
||||
medicalConsume = intervalDuringTime * MEDICAL_SPREED;
|
||||
String jsonStr = (String)redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),"scenarioInfo");
|
||||
ScenarioInfo scenarioInfoOnTime =JSONObject.parseObject(jsonStr,ScenarioInfo.class);
|
||||
|
||||
battleParams.put("ammunition",Double.valueOf(ammunition - ammunitionConsume).toString());
|
||||
battleParams.put("food",Double.valueOf(food - foodConsume).toString());
|
||||
battleParams.put("fuel",Double.valueOf(fuel - fuelConsume).toString());
|
||||
battleParams.put("medical",Double.valueOf(medical - medicalConsume).toString());
|
||||
battleParams.put("water",Double.valueOf(water - waterConsume).toString());
|
||||
battleParams.put("death",Long.valueOf(death+deathConsume).toString());
|
||||
battleParams.put("injured",Long.valueOf(injured +injuredConsume).toString());
|
||||
battleParams.put("duringTime",Long.valueOf(duringTime).toString());
|
||||
redisUtil.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(), battleParams);
|
||||
try {
|
||||
|
||||
long duringTime = getDuringTime();
|
||||
long lastDuringTime = Long.valueOf(redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),"duringTime").toString());
|
||||
long intervalDuringTime = duringTime - lastDuringTime;
|
||||
double ammunition = Double.valueOf(scenarioInfoOnTime.getAmmunition().getCurrent());
|
||||
double food = Double.valueOf(scenarioInfoOnTime.getFood().getCurrent());
|
||||
double medical = Double.valueOf(scenarioInfoOnTime.getMedical().getCurrent());
|
||||
double water = Double.valueOf(scenarioInfoOnTime.getWater().getCurrent());
|
||||
long death = Long.valueOf(scenarioInfoOnTime.getPerson().getDeath());
|
||||
long injured = Long.valueOf(scenarioInfoOnTime.getPerson().getInjured());
|
||||
teamLat = scenarioInfoOnTime.getTeam().getLat().toString();
|
||||
teamLng = scenarioInfoOnTime.getTeam().getLng().toString();
|
||||
if(scenarioInfoOnTime.getPerson().getCurrent() >0) {
|
||||
//
|
||||
deathConsume = RandomUtil.getSecureRandom().nextInt(2) * intervalDuringTime* RoomManager.getMag(roomId);
|
||||
injuredConsume = RandomUtil.getSecureRandom().nextInt(3) * intervalDuringTime* RoomManager.getMag(roomId);
|
||||
ammunitionConsume = intervalDuringTime * (0.1D + RandomUtil.getSecureRandom().nextDouble())* RoomManager.getMag(roomId);
|
||||
foodConsume = intervalDuringTime * FOOD_SPREED* RoomManager.getMag(roomId);
|
||||
waterConsume = intervalDuringTime * WATER_SPREED* RoomManager.getMag(roomId);
|
||||
|
||||
medicalConsume = intervalDuringTime * MEDICAL_SPREED* RoomManager.getMag(roomId);
|
||||
|
||||
|
||||
if(scenarioInfoOnTime.getAmmunition().getCurrent() >0) {
|
||||
scenarioInfoOnTime.getAmmunition().setCurrent(Double.valueOf(ammunition - ammunitionConsume));
|
||||
}
|
||||
if(scenarioInfoOnTime.getFood().getCurrent() > 0) {
|
||||
scenarioInfoOnTime.getFood().setCurrent(Double.valueOf(food - foodConsume));
|
||||
}
|
||||
if(scenarioInfoOnTime.getMedical().getCurrent() > 0) {
|
||||
scenarioInfoOnTime.getMedical().setCurrent(Double.valueOf(medical - medicalConsume));
|
||||
}
|
||||
if(scenarioInfoOnTime.getWater().getCurrent() > 0) {
|
||||
scenarioInfoOnTime.getWater().setCurrent(Double.valueOf(water - waterConsume));
|
||||
}
|
||||
scenarioInfoOnTime.getPerson().setDeath(Long.valueOf(death + deathConsume).intValue());
|
||||
scenarioInfoOnTime.getPerson().setInjured(Long.valueOf(injured + injuredConsume).intValue());
|
||||
scenarioInfoOnTime.getPerson().setCurrent(scenarioInfo.getPerson().getCurrent() - Long.valueOf(deathConsume).intValue()-Long.valueOf(injuredConsume).intValue());
|
||||
|
||||
String updJsonStr = (String) redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(), "updScenarioInfo");
|
||||
EditScenarioInfo updScenarioInfo = JSON.parseObject(updJsonStr, EditScenarioInfo.class);
|
||||
if(updScenarioInfo.getJbxx().getAmmunition().getCurrent() >0) {
|
||||
updScenarioInfo.getJbxx().getAmmunition().setCurrent(Double.valueOf(ammunition - ammunitionConsume));
|
||||
}
|
||||
if(updScenarioInfo.getJbxx().getFood().getCurrent() > 0) {
|
||||
updScenarioInfo.getJbxx().getFood().setCurrent(Double.valueOf(food - foodConsume));
|
||||
}
|
||||
// updScenarioInfo.getJbxx().getFuel().setCurrent(Double.valueOf(fuel - fuelConsume));
|
||||
if(updScenarioInfo.getJbxx().getMedical().getCurrent() > 0) {
|
||||
updScenarioInfo.getJbxx().getMedical().setCurrent(Double.valueOf(medical - medicalConsume));
|
||||
}
|
||||
if(updScenarioInfo.getJbxx().getWater().getCurrent() > 0) {
|
||||
updScenarioInfo.getJbxx().getWater().setCurrent(Double.valueOf(water - waterConsume));
|
||||
}
|
||||
updScenarioInfo.getJbxx().getPerson().setDeath(Long.valueOf(death + deathConsume).intValue());
|
||||
updScenarioInfo.getJbxx().getPerson().setInjured(Long.valueOf(injured + injuredConsume).intValue());
|
||||
updScenarioInfo.getJbxx().getPerson().setCurrent(updScenarioInfo.getJbxx().getPerson().getCurrent() - Long.valueOf(deathConsume).intValue()-Long.valueOf(injuredConsume).intValue());
|
||||
redisUtil.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"updScenarioInfo", JSON.toJSONString(updScenarioInfo));
|
||||
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
||||
respObj.setData(JSON.toJSONString(updScenarioInfo));
|
||||
respObj.setRoom(roomId);
|
||||
respObj.setScenarioId(scenarioTask.getScenarioId());
|
||||
respObj.setCmdType("updScenarioInfo");
|
||||
Global.sendCmdInfoQueue.add(respObj);
|
||||
redisUtil.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(), "duringTime", String.valueOf(duringTime));
|
||||
redisUtil.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(), "scenarioInfo", JSONObject.toJSONString(scenarioInfoOnTime));
|
||||
}
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
log.error("==============================设置消耗信息失败=============================================",ex.getMessage());
|
||||
}
|
||||
try {
|
||||
//推送消耗數據
|
||||
ResponseCmdInfo<String> sendConsumeMsg = new ResponseCmdInfo<>();
|
||||
jsonObject.put("deathConsume", deathConsume);
|
||||
jsonObject.put("injuredConsume", injuredConsume);
|
||||
jsonObject.put("ammunitionConsume", ammunitionConsume);
|
||||
jsonObject.put("foodConsume", foodConsume);
|
||||
jsonObject.put("waterConsume", waterConsume);
|
||||
jsonObject.put("fuelConsume", fuelConsume);
|
||||
jsonObject.put("medicalConsume", medicalConsume);
|
||||
jsonObject.put("teamLat",teamLat);
|
||||
jsonObject.put("teamLng",teamLng);
|
||||
jsonObject.put("resourceId",scenarioTask.getResourceId());
|
||||
LocalDateTime currentDateTime = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
jsonObject.put("consumeDate",currentDateTime);
|
||||
sendConsumeMsg.setData(jsonObject.toString());
|
||||
sendConsumeMsg.setRoom(roomId);
|
||||
sendConsumeMsg.setScenarioId(scenarioTask.getScenarioId());
|
||||
sendConsumeMsg.setCmdType("battleConsume");
|
||||
Global.sendCmdInfoQueue.add(sendConsumeMsg);
|
||||
BattleConsume battleConsume = new BattleConsume();
|
||||
battleConsume.setLat(teamLat);
|
||||
battleConsume.setLng(teamLng);
|
||||
battleConsume.setId(IdUtils.simpleUUID());
|
||||
battleConsume.setAmmunition(ammunitionConsume);
|
||||
battleConsume.setDeath(Integer.valueOf(Double.valueOf(deathConsume).intValue()));
|
||||
battleConsume.setInjured(Integer.valueOf(Double.valueOf(injuredConsume).intValue()));
|
||||
battleConsume.setFood(foodConsume);
|
||||
battleConsume.setFuel(fuelConsume);
|
||||
battleConsume.setMedical(medicalConsume);
|
||||
battleConsume.setWater(waterConsume);
|
||||
battleConsume.setResourceId(scenarioTask.getResourceId());
|
||||
battleConsume.setConsumeDate(currentDateTime);
|
||||
battleConsumeService.save(battleConsume);
|
||||
if(scenarioInfoOnTime.getPerson().getCurrent() >0) {
|
||||
//推送消耗數據
|
||||
String battleConsumeStr = "";
|
||||
ResponseCmdInfo<String> sendConsumeMsg = new ResponseCmdInfo<>();
|
||||
LocalDateTime currentDateTime = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
battleConsumeStr += currentDateTime.toString() + " 战斗消耗 [";
|
||||
battleConsumeStr += "死亡人数:" + deathConsume;
|
||||
battleConsumeStr += "受伤人数:" + injuredConsume;
|
||||
battleConsumeStr += "弹药消耗:" + ammunitionConsume;
|
||||
battleConsumeStr += "食品消耗:" + foodConsume;
|
||||
battleConsumeStr += "用水消耗:" + waterConsume;
|
||||
battleConsumeStr += "药材消耗:" + medicalConsume + "]";
|
||||
jsonObject.put("teamLat",teamLat);
|
||||
jsonObject.put("teamLng",teamLng);
|
||||
jsonObject.put("resourceId", scenarioTask.getResourceId());
|
||||
|
||||
jsonObject.put("消耗时间", currentDateTime);
|
||||
jsonObject.put("日志类型", "战斗消耗");
|
||||
|
||||
sendConsumeMsg.setData(battleConsumeStr);
|
||||
sendConsumeMsg.setRoom(roomId);
|
||||
sendConsumeMsg.setScenarioId(scenarioTask.getScenarioId());
|
||||
sendConsumeMsg.setCmdType("battleConsume");
|
||||
Global.sendCmdInfoQueue.add(sendConsumeMsg);
|
||||
BattleConsume battleConsume = new BattleConsume();
|
||||
battleConsume.setLat(teamLat);
|
||||
battleConsume.setLng(teamLng);
|
||||
battleConsume.setId(IdUtils.simpleUUID());
|
||||
battleConsume.setAmmunition(ammunitionConsume);
|
||||
battleConsume.setDeath(Integer.valueOf(Double.valueOf(deathConsume).intValue()));
|
||||
battleConsume.setInjured(Integer.valueOf(Double.valueOf(injuredConsume).intValue()));
|
||||
battleConsume.setFood(foodConsume);
|
||||
// battleConsume.setFuel(fuelConsume);
|
||||
battleConsume.setMedical(medicalConsume);
|
||||
battleConsume.setWater(waterConsume);
|
||||
battleConsume.setResourceId(scenarioTask.getResourceId());
|
||||
battleConsume.setConsumeDate(currentDateTime);
|
||||
battleConsumeService.save(battleConsume);
|
||||
if (injuredConsume > 2 && !isAlreadyProduceTask.get()) {
|
||||
//产生一个
|
||||
|
||||
}
|
||||
}
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
log.error("==================推送消耗數據 失败============================================",ex.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
LocalDateTime currentDateTime = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
String death = SpringUtil.getBean(Environment.class).getProperty("death.warn");
|
||||
String injured = SpringUtil.getBean(Environment.class).getProperty("injured.warn");
|
||||
String ammunition = SpringUtil.getBean(Environment.class).getProperty("ammunition.warn");
|
||||
log.info("===========person ammunition==={}===={}====={}========",death,injured,ammunition);
|
||||
HashMap<String,Object> battleConsumeMap = (HashMap<String, Object>) redisUtil.hget(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId());
|
||||
Double restAmmunition = Double.valueOf(battleConsumeMap.get("ammunition").toString());
|
||||
StatisticBean battleResourceStat = statisticService.statistic(scenarioTask.getResourceId());
|
||||
Double ammunitionConsumeRate = restAmmunition/battleResourceStat.getAmmunition().getTotal()*100;
|
||||
if(Double.valueOf(ammunitionConsumeRate) <= Double.valueOf(ammunition) && suppleFlagMap.get("ammunition") == false){
|
||||
SupplierRequest supplierRequest = new SupplierRequest();
|
||||
supplierRequest.setId(IdUtils.simpleUUID());
|
||||
supplierRequest.setFromResourceId(scenarioTask.getResourceId());
|
||||
supplierRequest.setSupplierNum(String.valueOf(suppleAmount));
|
||||
supplierRequest.setSupplierType("ammunition");
|
||||
supplierRequest.setGeneralTime(currentDateTime);
|
||||
supplierRequest.setLat(jsonObject.get("teamLat").toString());
|
||||
supplierRequest.setLng(jsonObject.get("teamLng").toString());
|
||||
supplierRequestService.save(supplierRequest);
|
||||
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
||||
respObj.setData(JSON.toJSONString(supplierRequest));
|
||||
respObj.setRoom(roomId);
|
||||
respObj.setScenarioId(scenarioTask.getScenarioId());
|
||||
respObj.setCmdType("");
|
||||
Global.sendCmdInfoQueue.add(respObj);
|
||||
suppleFlagMap.put("ammunition",true) ;
|
||||
}
|
||||
Long restDeath = Long.valueOf(battleConsumeMap.get("death").toString());
|
||||
Long deathConsumeRate = 0L;
|
||||
if(battleResourceStat.getPerson().getTotal() !=0) {
|
||||
deathConsumeRate = restDeath * 100 / battleResourceStat.getPerson().getTotal();
|
||||
}
|
||||
if(deathConsumeRate >= Long.valueOf(death) && suppleFlagMap.get("death") == false){
|
||||
SupplierRequest supplierRequest = new SupplierRequest();
|
||||
supplierRequest.setId(IdUtils.simpleUUID());
|
||||
supplierRequest.setFromResourceId(scenarioTask.getResourceId());
|
||||
supplierRequest.setSupplierNum(String.valueOf(suppleDeath));
|
||||
supplierRequest.setSupplierType("death");
|
||||
supplierRequest.setGeneralTime(currentDateTime);
|
||||
supplierRequest.setLat(jsonObject.get("teamLat").toString());
|
||||
supplierRequest.setLng(jsonObject.get("teamLng").toString());
|
||||
supplierRequestService.save(supplierRequest);
|
||||
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
||||
respObj.setData(JSON.toJSONString(supplierRequest));
|
||||
respObj.setRoom(roomId);
|
||||
respObj.setScenarioId(scenarioTask.getScenarioId());
|
||||
Global.sendCmdInfoQueue.add(respObj);
|
||||
suppleFlagMap.put("death",true) ;
|
||||
}
|
||||
Long restInjured = Long.valueOf(battleConsumeMap.get("injured").toString());
|
||||
Long injuredConsumeRate = restInjured*100/battleResourceStat.getPerson().getTotal();
|
||||
if(Long.valueOf(injuredConsumeRate) <= Long.valueOf(injured) && suppleFlagMap.get("injured") == false){
|
||||
SupplierRequest supplierRequest = new SupplierRequest();
|
||||
supplierRequest.setId(IdUtils.simpleUUID());
|
||||
supplierRequest.setFromResourceId(scenarioTask.getResourceId());
|
||||
supplierRequest.setSupplierNum(String.valueOf(suppleInjured));
|
||||
supplierRequest.setSupplierType("injured");
|
||||
supplierRequest.setGeneralTime(currentDateTime);
|
||||
supplierRequest.setLat(jsonObject.get("teamLat").toString());
|
||||
supplierRequest.setLng(jsonObject.get("teamLng").toString());
|
||||
supplierRequestService.save(supplierRequest);
|
||||
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
||||
respObj.setData(JSON.toJSONString(supplierRequest));
|
||||
respObj.setRoom(roomId);
|
||||
respObj.setScenarioId(scenarioTask.getScenarioId());
|
||||
Global.sendCmdInfoQueue.add(respObj);
|
||||
suppleFlagMap.put("injured",true) ;
|
||||
if(scenarioInfoOnTime.getPerson().getCurrent() >0) {
|
||||
LocalDateTime currentDateTime = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
String death = SpringUtil.getBean(Environment.class).getProperty("death.warn");
|
||||
String injured = SpringUtil.getBean(Environment.class).getProperty("injured.warn");
|
||||
String ammunition = SpringUtil.getBean(Environment.class).getProperty("ammunition.warn");
|
||||
log.info("===========person ammunition==={}===={}====={}========", death, injured, ammunition);
|
||||
|
||||
Double restAmmunition = Double.valueOf(scenarioInfoOnTime.getAmmunition().getCurrent());
|
||||
// StatisticBean battleResourceStat = statisticService.statistic(scenarioTask.getResourceId());
|
||||
Double ammunitionConsumeRate = restAmmunition / scenarioInfoOnTime.getAmmunition().getTotal() * 100;
|
||||
if (Double.valueOf(ammunitionConsumeRate) <= Double.valueOf(ammunition) && suppleFlagMap.get("ammunition") == false) {
|
||||
SupplierRequest supplierRequest = new SupplierRequest();
|
||||
supplierRequest.setId(IdUtils.simpleUUID());
|
||||
supplierRequest.setFromResourceId(scenarioTask.getResourceId());
|
||||
supplierRequest.setSupplierNum(String.valueOf(suppleAmount));
|
||||
supplierRequest.setSupplierType("ammunition");
|
||||
supplierRequest.setGeneralTime(currentDateTime);
|
||||
supplierRequest.setLat(jsonObject.get("teamLat").toString());
|
||||
supplierRequest.setLng(jsonObject.get("teamLng").toString());
|
||||
supplierRequestService.save(supplierRequest);
|
||||
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
||||
respObj.setData(JSON.toJSONString(supplierRequest));
|
||||
respObj.setRoom(roomId);
|
||||
respObj.setScenarioId(scenarioTask.getScenarioId());
|
||||
respObj.setCmdType("ammunitionRequest");
|
||||
Global.sendCmdInfoQueue.add(respObj);
|
||||
suppleFlagMap.put("ammunition", true);
|
||||
}
|
||||
Long restDeath = Long.valueOf(scenarioInfo.getPerson().getDeath());
|
||||
Long deathConsumeRate = 0L;
|
||||
if (scenarioInfo.getPerson().getTotal() != 0) {
|
||||
deathConsumeRate = restDeath * 100 / scenarioInfoOnTime.getPerson().getTotal();
|
||||
}
|
||||
if (deathConsumeRate >= Long.valueOf(death) && suppleFlagMap.get("death") == false) {
|
||||
SupplierRequest supplierRequest = new SupplierRequest();
|
||||
supplierRequest.setId(IdUtils.simpleUUID());
|
||||
supplierRequest.setFromResourceId(scenarioTask.getResourceId());
|
||||
supplierRequest.setSupplierNum(String.valueOf(suppleDeath));
|
||||
supplierRequest.setSupplierType("death");
|
||||
supplierRequest.setGeneralTime(currentDateTime);
|
||||
supplierRequest.setLat(jsonObject.get("teamLat").toString());
|
||||
supplierRequest.setLng(jsonObject.get("teamLng").toString());
|
||||
supplierRequestService.save(supplierRequest);
|
||||
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
||||
respObj.setData(JSON.toJSONString(supplierRequest));
|
||||
respObj.setRoom(roomId);
|
||||
respObj.setScenarioId(scenarioTask.getScenarioId());
|
||||
respObj.setCmdType("deathRequest");
|
||||
Global.sendCmdInfoQueue.add(respObj);
|
||||
suppleFlagMap.put("death", true);
|
||||
}
|
||||
Long restInjured = Long.valueOf(scenarioInfoOnTime.getPerson().getInjured());
|
||||
Long injuredConsumeRate = restInjured * 100 / scenarioInfoOnTime.getPerson().getTotal();
|
||||
if (Long.valueOf(injuredConsumeRate) <= Long.valueOf(injured) && suppleFlagMap.get("injured") == false) {
|
||||
SupplierRequest supplierRequest = new SupplierRequest();
|
||||
supplierRequest.setId(IdUtils.simpleUUID());
|
||||
supplierRequest.setFromResourceId(scenarioTask.getResourceId());
|
||||
supplierRequest.setSupplierNum(String.valueOf(suppleInjured));
|
||||
supplierRequest.setSupplierType("injured");
|
||||
supplierRequest.setGeneralTime(currentDateTime);
|
||||
supplierRequest.setLat(jsonObject.get("teamLat").toString());
|
||||
supplierRequest.setLng(jsonObject.get("teamLng").toString());
|
||||
supplierRequestService.save(supplierRequest);
|
||||
ResponseCmdInfo<String> respObj = new ResponseCmdInfo<>();
|
||||
respObj.setData(JSON.toJSONString(supplierRequest));
|
||||
respObj.setRoom(roomId);
|
||||
respObj.setScenarioId(scenarioTask.getScenarioId());
|
||||
respObj.setCmdType("injuredRequest");
|
||||
Global.sendCmdInfoQueue.add(respObj);
|
||||
suppleFlagMap.put("injured", true);
|
||||
}
|
||||
}
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hivekion.room.bean;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.hivekion.Global;
|
||||
import com.hivekion.common.entity.ResponseCmdInfo;
|
||||
import com.hivekion.common.redis.RedisUtil;
|
||||
|
|
@ -8,25 +9,17 @@ 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;
|
||||
import com.hivekion.statistic.service.impl.StatisticServiceImpl;
|
||||
import com.hivekion.supplier.entity.SupplierRequest;
|
||||
import com.hivekion.supplier.service.impl.SupplierRequestServiceImpl;
|
||||
import com.hivekion.statistic.bean.EditScenarioInfo;
|
||||
import com.hivekion.statistic.bean.ScenarioInfo;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* [类的简要说明]
|
||||
|
|
@ -44,46 +37,38 @@ public class MoveTask extends AbtParentTask implements TaskAction {
|
|||
* 速度 换算为100Km/小时
|
||||
*/
|
||||
private final double SPEED = 27;
|
||||
/**
|
||||
* 需求产生标志
|
||||
*/
|
||||
private final AtomicBoolean requestFlag = new AtomicBoolean(false);
|
||||
/**
|
||||
* 油料消耗速率
|
||||
*/
|
||||
private double fuelConsumption = 0;
|
||||
private double fuelThreshold = 0;
|
||||
|
||||
|
||||
/**
|
||||
* 消耗任务间隔
|
||||
*/
|
||||
private final int consumptionTaskInterval = 10;
|
||||
/**
|
||||
* redis 服务类
|
||||
*/
|
||||
private final RedisUtil redis = SpringUtil.getBean(RedisUtil.class);
|
||||
private StatisticBean statisticBean;
|
||||
private final int consumptionTaskInterval = 5;
|
||||
|
||||
private final TaskAction finishedAction;
|
||||
|
||||
|
||||
public MoveTask(ScenarioTask scenarioTask, String roomId) {
|
||||
public MoveTask(ScenarioTask scenarioTask, String roomId,TaskAction finishedAction) {
|
||||
super(scenarioTask, roomId);
|
||||
this.finishedAction = finishedAction;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void doSomeThing() {
|
||||
log.info("move task running:{}", scenarioTask.getResourceId());
|
||||
log.info("move task running:{},fuel::{}", scenarioTask.getResourceId(), getCurrentFuel());
|
||||
|
||||
|
||||
initEnv(); //初始化环境
|
||||
initPath(); //初始化路径
|
||||
updatePath(SPEED, new TaskAction() {
|
||||
@Override
|
||||
public void doSomeThing() {
|
||||
|
||||
//推送移动任务
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("duringTime",getDuringTime());
|
||||
map.put("id",scenarioTask.getResourceId());
|
||||
map.put("roomStatus",true);
|
||||
map.put("type",scenarioTask.getType());
|
||||
map.put("duringTime", getDuringTime());
|
||||
map.put("id", scenarioTask.getResourceId());
|
||||
map.put("roomStatus", true);
|
||||
map.put("type", scenarioTask.getType());
|
||||
|
||||
Global.sendCmdInfoQueue.add(
|
||||
ResponseCmdInfo.create("moveTask", roomId,
|
||||
|
|
@ -99,28 +84,11 @@ public class MoveTask extends AbtParentTask implements TaskAction {
|
|||
public String getType() {
|
||||
return "";
|
||||
}
|
||||
},null); //更新路径
|
||||
}, this.finishedAction); //更新路径
|
||||
fuelConsumption();//油品消耗
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化环境
|
||||
*/
|
||||
private void initEnv() {
|
||||
try {
|
||||
//获取油品消耗规则
|
||||
String fuelConsumptionStr = SpringUtil.getBean(Environment.class)
|
||||
.getProperty("fuel_spreed");
|
||||
fuelConsumption = Double.parseDouble(fuelConsumptionStr == null ? "0" : fuelConsumptionStr);
|
||||
fuelThreshold = Double.parseDouble(SpringUtil.getBean(Environment.class)
|
||||
.getProperty("fuel.warn ", "0"));
|
||||
statisticBean = SpringUtil.getBean(StatisticServiceImpl.class)
|
||||
.statistic(scenarioTask.getResourceId());
|
||||
} catch (Exception e) {
|
||||
log.error("init env exception", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void fuelConsumption() {
|
||||
|
|
@ -129,36 +97,32 @@ public class MoveTask extends AbtParentTask implements TaskAction {
|
|||
1);
|
||||
schedule.scheduleWithFixedDelay(() -> {
|
||||
if (getRoomStatus()) {
|
||||
double currentUseUp = consumptionTaskInterval * SPEED / 1000 * fuelConsumption;
|
||||
double currentFuel = getCurrentFuel();
|
||||
if(currentFuel > 0&&!"general".equals(scenarioTask.getFromSource())&&!taskFinishedStatus.get()) {
|
||||
double currentUseUp = consumptionTaskInterval*RoomManager.getMag(roomId) * SPEED / 1000 * fuelConsumption;
|
||||
|
||||
//更新redis中油品的消耗
|
||||
Object currentFuelObj = redis.hget(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"fuel");
|
||||
if (currentFuelObj != null) {
|
||||
double fuel = Double.parseDouble(currentFuelObj.toString());
|
||||
fuel = fuel - currentUseUp;
|
||||
log.info("{}-当前消耗油料::{},当前剩余油料::{}", scenarioTask.getResourceId(),
|
||||
currentUseUp, currentFuel);
|
||||
|
||||
redis.hset(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"fuelConsume", fuel);
|
||||
//修改油料
|
||||
EditScenarioInfo editScenarioInfo = getEditScenarioInfo(
|
||||
this.scenarioTask.getResourceId());
|
||||
editScenarioInfo.getJbxx().getFuel().setCurrent(editScenarioInfo.getJbxx().getFuel().getCurrent()-currentUseUp);
|
||||
setEditScenarioInfo(editScenarioInfo,scenarioTask.getResourceId());
|
||||
|
||||
double totalFuel = statisticBean.getFuel().getTotal();
|
||||
if (fuel * 100 / totalFuel < fuelThreshold && !requestFlag.get()) {
|
||||
requestFlag.set(true);
|
||||
//需要产生需求
|
||||
produceFuelRequest();
|
||||
//产生任务
|
||||
produceTask();
|
||||
//插入消耗表
|
||||
insertConsumption(currentUseUp);
|
||||
|
||||
}
|
||||
setCurrentFuel(currentUseUp);
|
||||
pushStatus(scenarioTask.getResourceId());
|
||||
}
|
||||
//插入消耗表
|
||||
insertConsumption(currentUseUp);
|
||||
pushStatus(scenarioTask.getResourceId());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}, 0, consumptionTaskInterval, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
log.error("fuel consumption exception", e);
|
||||
|
|
@ -167,53 +131,36 @@ public class MoveTask extends AbtParentTask implements TaskAction {
|
|||
|
||||
}
|
||||
|
||||
private void produceFuelRequest() {
|
||||
SupplierRequest supplierRequest = new SupplierRequest();
|
||||
supplierRequest.setId(IdUtils.simpleUUID());
|
||||
supplierRequest.setFromResourceId(scenarioTask.getResourceId());
|
||||
supplierRequest.setSupplierNum(String.valueOf(statisticBean.getFuel().getTotal()));
|
||||
supplierRequest.setSupplierType("fuel");
|
||||
supplierRequest.setGeneralTime(LocalDateTime.now());
|
||||
supplierRequest.setLat(scenarioTask.getToLat());
|
||||
supplierRequest.setLng(scenarioTask.getToLng());
|
||||
supplierRequest.setHandleFlag(1);
|
||||
SpringUtil.getBean(SupplierRequestServiceImpl.class).save(supplierRequest);
|
||||
}
|
||||
|
||||
private void produceTask() {
|
||||
|
||||
List<ScenarioResource> resourceList = SpringUtil.getBean(BattleSupplierServiceImpl.class)
|
||||
.selectSupplierResource(scenarioTask.getResourceId());
|
||||
if (!resourceList.isEmpty()) {
|
||||
ScenarioTask task = new ScenarioTask();
|
||||
task.setId(IdUtils.simpleUUID());
|
||||
task.setScenarioId(scenarioTask.getScenarioId());
|
||||
task.setResourceId(scenarioTask.getResourceId());
|
||||
task.setTaskType("6");
|
||||
task.setSupplierNum(statisticBean.getFuel().getTotal());
|
||||
task.setToLat(scenarioTask.getToLat());
|
||||
task.setToLng(scenarioTask.getToLng());
|
||||
task.setStartTime(LocalDateTime.now());
|
||||
task.setFromLat(resourceList.get(0).getLat());
|
||||
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);
|
||||
try{
|
||||
log.info("{}-插入油料消耗::{}", this.scenarioTask.getResourceId(), 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);
|
||||
}catch (Exception e){
|
||||
log.error("insertConsumption exception", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setCurrentFuel(double num) {
|
||||
Object statisticObj = SpringUtil.getBean(RedisUtil.class).hget(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"scenarioInfo");
|
||||
if (statisticObj != null) {
|
||||
ScenarioInfo scenarioInfo = JSON.parseObject(statisticObj.toString(), ScenarioInfo.class);
|
||||
scenarioInfo.getFuel().setCurrent(scenarioInfo.getFuel().getCurrent() - num);
|
||||
SpringUtil.getBean(RedisUtil.class).hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"scenarioInfo", JSON.toJSONString(scenarioInfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,19 @@
|
|||
package com.hivekion.room.bean;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.hivekion.Global;
|
||||
import com.hivekion.baseData.entity.Scenario;
|
||||
import com.hivekion.common.entity.ResponseCmdInfo;
|
||||
import com.hivekion.common.redis.RedisUtil;
|
||||
import com.hivekion.common.utils;
|
||||
import com.hivekion.common.uuid.IdUtils;
|
||||
import com.hivekion.room.func.TaskAction;
|
||||
import com.hivekion.scenario.bean.ScenarioWsParam;
|
||||
import com.hivekion.scenario.entity.ScenarioResource;
|
||||
import com.hivekion.scenario.service.impl.ScenarioResourceServiceImpl;
|
||||
import com.hivekion.statistic.bean.EditScenarioInfo;
|
||||
import com.hivekion.statistic.bean.ScenarioInfo;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -21,6 +28,7 @@ import java.util.concurrent.ScheduledFuture;
|
|||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -39,6 +47,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||
public class Room implements AutoCloseable {
|
||||
|
||||
private AtomicBoolean status = new AtomicBoolean(false);
|
||||
//资源最终坐标
|
||||
private Map<String, Coordinate> resourceCoordinateMap = new ConcurrentHashMap<>();
|
||||
//资源路线path
|
||||
private Map<String, Object> resourcePathMap = new ConcurrentHashMap<>();
|
||||
private Map<String,ScenarioResource> scenarioResourceMap = new ConcurrentHashMap<>();
|
||||
/**
|
||||
* 任务管理相关
|
||||
*/
|
||||
|
|
@ -52,6 +65,12 @@ public class Room implements AutoCloseable {
|
|||
* 想定信息
|
||||
*/
|
||||
private Scenario scenario;
|
||||
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
private com.hivekion.statistic.service.ScenarioService scenarioService;
|
||||
|
||||
private AtomicInteger numStatus = new AtomicInteger(0);
|
||||
/**
|
||||
* 任务容器
|
||||
*/
|
||||
|
|
@ -93,14 +112,18 @@ public class Room implements AutoCloseable {
|
|||
totalTime.set(time);
|
||||
startTask();
|
||||
//初始化系统资源 物资人员等信息
|
||||
|
||||
initRoomParam();
|
||||
pushRoomInfo();
|
||||
numStatus.set(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止
|
||||
*/
|
||||
public void stop() {
|
||||
numStatus.set(3);
|
||||
status.set(false);
|
||||
pushRoomInfo();
|
||||
cancelTask();
|
||||
futures.forEach((key, value) -> {
|
||||
try {
|
||||
|
|
@ -117,12 +140,15 @@ public class Room implements AutoCloseable {
|
|||
* 暂停
|
||||
*/
|
||||
public void pause() {
|
||||
numStatus.set(2);
|
||||
status.set(false);
|
||||
pushRoomInfo();
|
||||
cancelTask();
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
status.set(true);
|
||||
pushRoomInfo();
|
||||
startTask();
|
||||
}
|
||||
|
||||
|
|
@ -206,5 +232,65 @@ public class Room implements AutoCloseable {
|
|||
return status.get();
|
||||
}
|
||||
|
||||
public void initRoomParam() {
|
||||
if (scenarioService == null) {
|
||||
scenarioService = SpringUtil.getBean(com.hivekion.statistic.service.ScenarioService.class);
|
||||
}
|
||||
//设置资源列表
|
||||
scenario.setResourceList(SpringUtil.getBean(ScenarioResourceServiceImpl.class)
|
||||
.getResourceListByScenarioId(scenario.getId()));
|
||||
for (ScenarioResource scenarioResource : this.scenario.getResourceList()) {
|
||||
ScenarioInfo scenarioInfo = scenarioService.listScenarioInfo(scenarioResource.getScenarioId(),
|
||||
roomId, scenarioResource.getId());
|
||||
EditScenarioInfo updScenarioInfo = scenarioService.listEditScenarioInfo(
|
||||
scenarioResource.getScenarioId(), roomId, scenarioResource.getId());
|
||||
if (redisUtil == null) {
|
||||
redisUtil = SpringUtil.getBean(RedisUtil.class);
|
||||
}
|
||||
redisUtil.hset(
|
||||
scenarioResource.getScenarioId() + "-" + roomId + "-" + scenarioResource.getId(),
|
||||
"scenarioInfo", JSON.toJSONString(scenarioInfo));
|
||||
redisUtil.hset(
|
||||
scenarioResource.getScenarioId() + "-" + roomId + "-" + scenarioResource.getId(),
|
||||
"updScenarioInfo", JSON.toJSONString(updScenarioInfo));
|
||||
}
|
||||
scenario.getResourceList().forEach(resource -> {
|
||||
scenarioResourceMap.put(resource.getId(), resource);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void addResourcePath(String resourceId, Object obj) {
|
||||
resourcePathMap.put(resourceId, obj);
|
||||
}
|
||||
|
||||
public Object getResourcePath(String resourceId) {
|
||||
return resourcePathMap.get(resourceId);
|
||||
}
|
||||
|
||||
public void addResourceLastPosition(String resourceId, Coordinate obj) {
|
||||
resourceCoordinateMap.put(resourceId, obj);
|
||||
}
|
||||
|
||||
public Coordinate getResourceLastPosition(String resourceId) {
|
||||
return resourceCoordinateMap.get(resourceId);
|
||||
}
|
||||
|
||||
public Map<String, Object> getPathMap() {
|
||||
return resourcePathMap;
|
||||
}
|
||||
public Map<String, ScenarioResource> getScenarioResourceMap() {
|
||||
return scenarioResourceMap;
|
||||
}
|
||||
private void pushRoomInfo(){
|
||||
ResponseCmdInfo<Object> respObj = new ResponseCmdInfo<>();
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("mag", this.getMag());
|
||||
dataMap.put("status", this.numStatus.get());
|
||||
respObj.setData(dataMap);
|
||||
respObj.setRoom(this.getRoomId());
|
||||
respObj.setScenarioId(this.getScenario().getId());
|
||||
respObj.setCmdType("room_info");
|
||||
Global.sendCmdInfoQueue.add(respObj);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
package com.hivekion.room.bean;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.hivekion.common.entity.ResponseCmdInfo;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.hivekion.common.redis.RedisUtil;
|
||||
import com.hivekion.room.func.TaskAction;
|
||||
import com.hivekion.scenario.entity.ScenarioTask;
|
||||
import com.hivekion.statistic.bean.EditScenarioInfo;
|
||||
import com.hivekion.statistic.bean.ScenarioInfo;
|
||||
import com.hivekion.statistic.bean.StatisticBean;
|
||||
import com.hivekion.statistic.service.StatisticService;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
|
|
@ -33,7 +33,7 @@ public class SupplierTask extends AbtParentTask implements TaskAction {
|
|||
StatisticBean statistic = SpringUtil.getBean(StatisticService.class)
|
||||
.statistic(scenarioTask.getResourceId());
|
||||
initPath(); //初始化路径
|
||||
updatePath(30, null, new TaskAction() {
|
||||
updatePath(50, null, new TaskAction() {
|
||||
|
||||
@Override
|
||||
public void doSomeThing() {
|
||||
|
|
@ -58,7 +58,7 @@ public class SupplierTask extends AbtParentTask implements TaskAction {
|
|||
}
|
||||
//推送最新状态信息
|
||||
pushStatus(scenarioTask.getResourceId());
|
||||
pushStatus(scenarioTask.getResourceId());
|
||||
pushStatus(scenarioTask.getInsureResourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -74,112 +74,163 @@ public class SupplierTask extends AbtParentTask implements TaskAction {
|
|||
}
|
||||
|
||||
private void supplierMedical(StatisticBean statistic) {
|
||||
//保障分队
|
||||
Object supplierObj = SpringUtil.getBean(RedisUtil.class).hget(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"scenarioInfo");
|
||||
//被保障分队
|
||||
Object insureObj = SpringUtil.getBean(RedisUtil.class).hget(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getInsureResourceId(),
|
||||
"scenarioInfo");
|
||||
if(supplierObj!=null&&insureObj!=null){
|
||||
|
||||
//增加被保障分队的量
|
||||
SpringUtil.getBean(RedisUtil.class)
|
||||
.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"medical", statistic.getMedical().getTotal() + "");
|
||||
ScenarioInfo scenarioSupplierInfo = JSON.parseObject(supplierObj.toString(), ScenarioInfo.class);
|
||||
ScenarioInfo scenarioInsureInfo = JSON.parseObject(insureObj.toString(), ScenarioInfo.class);
|
||||
|
||||
//获取保障任务的药品信息
|
||||
Object supplierObj = SpringUtil.getBean(RedisUtil.class)
|
||||
.hget(scenarioTask.getScenarioId() + "-" + roomId + "-"
|
||||
+ scenarioTask.getSupplierResourceId(),
|
||||
"medical");
|
||||
//减少保障分队的量
|
||||
if (supplierObj != null) {
|
||||
double supplierMedical = Double.parseDouble(supplierObj.toString());
|
||||
scenarioSupplierInfo.getMedical().setCurrent(scenarioInsureInfo.getMedical().getCurrent() - statistic.getMedical().getTotal());
|
||||
scenarioInsureInfo.getMedical().setCurrent(statistic.getMedical().getTotal());
|
||||
|
||||
double remain = supplierMedical - statistic.getMedical().getTotal();
|
||||
SpringUtil.getBean(RedisUtil.class)
|
||||
.hset(scenarioTask.getScenarioId() + "-" + roomId + "-"
|
||||
+ scenarioTask.getSupplierResourceId(),
|
||||
"medical", remain + "");
|
||||
}
|
||||
|
||||
SpringUtil.getBean(RedisUtil.class).hset(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getInsureResourceId(),
|
||||
"scenarioInfo",JSON.toJSONString(scenarioInsureInfo));
|
||||
|
||||
SpringUtil.getBean(RedisUtil.class).hset(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"scenarioInfo",JSON.toJSONString(scenarioSupplierInfo));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void supplierFuel(StatisticBean statistic) {
|
||||
|
||||
SpringUtil.getBean(RedisUtil.class)
|
||||
.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"fuel", statistic.getFuel().getTotal() + "");
|
||||
//保障分队
|
||||
Object supplierObj = SpringUtil.getBean(RedisUtil.class).hget(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"scenarioInfo");
|
||||
//被保障分队
|
||||
Object insureObj = SpringUtil.getBean(RedisUtil.class).hget(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getInsureResourceId(),
|
||||
"scenarioInfo");
|
||||
if(supplierObj!=null&&insureObj!=null){
|
||||
|
||||
Object supplierObj = SpringUtil.getBean(RedisUtil.class)
|
||||
.hget(scenarioTask.getScenarioId() + "-" + roomId + "-"
|
||||
+ scenarioTask.getSupplierResourceId(),
|
||||
"fuel");
|
||||
//减少保障分队的量
|
||||
if (supplierObj != null) {
|
||||
double supplierMedical = Double.parseDouble(supplierObj.toString());
|
||||
|
||||
double remain = supplierMedical - statistic.getFuel().getTotal();
|
||||
SpringUtil.getBean(RedisUtil.class)
|
||||
.hset(scenarioTask.getScenarioId() + "-" + roomId + "-"
|
||||
+ scenarioTask.getSupplierResourceId(),
|
||||
"fuel", remain + "");
|
||||
ScenarioInfo scenarioSupplierInfo = JSON.parseObject(supplierObj.toString(), ScenarioInfo.class);
|
||||
ScenarioInfo scenarioInsureInfo = JSON.parseObject(insureObj.toString(), ScenarioInfo.class);
|
||||
|
||||
scenarioSupplierInfo.getFuel().setCurrent(scenarioInsureInfo.getFuel().getCurrent() - statistic.getFuel().getTotal());
|
||||
|
||||
scenarioInsureInfo.getFuel().setCurrent(statistic.getFuel().getTotal());
|
||||
|
||||
EditScenarioInfo insureEdit = getEditScenarioInfo(scenarioTask.getInsureResourceId());
|
||||
double supplierNum = statistic.getFuel().getTotal() - statistic.getFuel().getCurrent();
|
||||
insureEdit.getJbxx().getFuel().setCurrent(statistic.getFuel().getTotal());
|
||||
setEditScenarioInfo(insureEdit,scenarioTask.getInsureResourceId());
|
||||
|
||||
EditScenarioInfo supplerEdit = getEditScenarioInfo(scenarioTask.getResourceId());
|
||||
supplerEdit.getJbxx().getFuel().setCurrent(statistic.getFuel().getTotal()-supplierNum);
|
||||
setEditScenarioInfo(supplerEdit,scenarioTask.getResourceId());
|
||||
|
||||
SpringUtil.getBean(RedisUtil.class).hset(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getInsureResourceId(),
|
||||
"scenarioInfo",JSON.toJSONString(scenarioInsureInfo));
|
||||
|
||||
SpringUtil.getBean(RedisUtil.class).hset(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"scenarioInfo",JSON.toJSONString(scenarioSupplierInfo));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void supplierAmmunition(StatisticBean statistic) {
|
||||
|
||||
SpringUtil.getBean(RedisUtil.class)
|
||||
.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"ammunition", statistic.getAmmunition().getTotal() + "");
|
||||
Object supplierObj = SpringUtil.getBean(RedisUtil.class)
|
||||
.hget(scenarioTask.getScenarioId() + "-" + roomId + "-"
|
||||
+ scenarioTask.getSupplierResourceId(),
|
||||
"ammunition");
|
||||
//减少保障分队的量
|
||||
if (supplierObj != null) {
|
||||
double supplierMedical = Double.parseDouble(supplierObj.toString());
|
||||
//保障分队
|
||||
Object supplierObj = SpringUtil.getBean(RedisUtil.class).hget(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"scenarioInfo");
|
||||
//被保障分队
|
||||
Object insureObj = SpringUtil.getBean(RedisUtil.class).hget(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getInsureResourceId(),
|
||||
"scenarioInfo");
|
||||
if(supplierObj!=null&&insureObj!=null){
|
||||
|
||||
ScenarioInfo scenarioSupplierInfo = JSON.parseObject(supplierObj.toString(), ScenarioInfo.class);
|
||||
ScenarioInfo scenarioInsureInfo = JSON.parseObject(insureObj.toString(), ScenarioInfo.class);
|
||||
|
||||
scenarioSupplierInfo.getAmmunition().setCurrent(scenarioInsureInfo.getAmmunition().getCurrent() - statistic.getAmmunition().getTotal());
|
||||
scenarioInsureInfo.getAmmunition().setCurrent(statistic.getAmmunition().getTotal());
|
||||
|
||||
|
||||
SpringUtil.getBean(RedisUtil.class).hset(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getInsureResourceId(),
|
||||
"scenarioInfo",JSON.toJSONString(scenarioInsureInfo));
|
||||
|
||||
SpringUtil.getBean(RedisUtil.class).hset(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"scenarioInfo",JSON.toJSONString(scenarioSupplierInfo));
|
||||
|
||||
double remain = supplierMedical - statistic.getAmmunition().getTotal();
|
||||
SpringUtil.getBean(RedisUtil.class)
|
||||
.hset(scenarioTask.getScenarioId() + "-" + roomId + "-"
|
||||
+ scenarioTask.getSupplierResourceId(),
|
||||
"ammunition", remain + "");
|
||||
}
|
||||
}
|
||||
|
||||
private void supplierWater(StatisticBean statistic) {
|
||||
|
||||
SpringUtil.getBean(RedisUtil.class)
|
||||
.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"water", statistic.getWater().getTotal() + "");
|
||||
Object supplierObj = SpringUtil.getBean(RedisUtil.class)
|
||||
.hget(scenarioTask.getScenarioId() + "-" + roomId + "-"
|
||||
+ scenarioTask.getSupplierResourceId(),
|
||||
"water");
|
||||
//减少保障分队的量
|
||||
if (supplierObj != null) {
|
||||
double supplierMedical = Double.parseDouble(supplierObj.toString());
|
||||
//保障分队
|
||||
Object supplierObj = SpringUtil.getBean(RedisUtil.class).hget(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"scenarioInfo");
|
||||
//被保障分队
|
||||
Object insureObj = SpringUtil.getBean(RedisUtil.class).hget(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getInsureResourceId(),
|
||||
"scenarioInfo");
|
||||
if(supplierObj!=null&&insureObj!=null){
|
||||
|
||||
ScenarioInfo scenarioSupplierInfo = JSON.parseObject(supplierObj.toString(), ScenarioInfo.class);
|
||||
ScenarioInfo scenarioInsureInfo = JSON.parseObject(insureObj.toString(), ScenarioInfo.class);
|
||||
|
||||
scenarioSupplierInfo.getWater().setCurrent(scenarioInsureInfo.getWater().getCurrent() - statistic.getWater().getTotal());
|
||||
scenarioInsureInfo.getWater().setCurrent(statistic.getWater().getTotal());
|
||||
|
||||
|
||||
SpringUtil.getBean(RedisUtil.class).hset(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getInsureResourceId(),
|
||||
"scenarioInfo",JSON.toJSONString(scenarioInsureInfo));
|
||||
|
||||
SpringUtil.getBean(RedisUtil.class).hset(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"scenarioInfo",JSON.toJSONString(scenarioSupplierInfo));
|
||||
|
||||
double remain = supplierMedical - statistic.getWater().getTotal();
|
||||
SpringUtil.getBean(RedisUtil.class)
|
||||
.hset(scenarioTask.getScenarioId() + "-" + roomId + "-"
|
||||
+ scenarioTask.getSupplierResourceId(),
|
||||
"water", remain + "");
|
||||
}
|
||||
}
|
||||
|
||||
private void supplierFood(StatisticBean statistic) {
|
||||
//保障分队
|
||||
Object supplierObj = SpringUtil.getBean(RedisUtil.class).hget(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"scenarioInfo");
|
||||
//被保障分队
|
||||
Object insureObj = SpringUtil.getBean(RedisUtil.class).hget(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getInsureResourceId(),
|
||||
"scenarioInfo");
|
||||
if(supplierObj!=null&&insureObj!=null){
|
||||
|
||||
SpringUtil.getBean(RedisUtil.class)
|
||||
.hset(scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"food", statistic.getFood().getTotal() + "");
|
||||
Object supplierObj = SpringUtil.getBean(RedisUtil.class)
|
||||
.hget(scenarioTask.getScenarioId() + "-" + roomId + "-"
|
||||
+ scenarioTask.getSupplierResourceId(),
|
||||
"food");
|
||||
//减少保障分队的量
|
||||
if (supplierObj != null) {
|
||||
double supplierMedical = Double.parseDouble(supplierObj.toString());
|
||||
ScenarioInfo scenarioSupplierInfo = JSON.parseObject(supplierObj.toString(), ScenarioInfo.class);
|
||||
ScenarioInfo scenarioInsureInfo = JSON.parseObject(insureObj.toString(), ScenarioInfo.class);
|
||||
|
||||
scenarioSupplierInfo.getFood().setCurrent(scenarioInsureInfo.getFood().getCurrent() - statistic.getFood().getTotal());
|
||||
scenarioInsureInfo.getFood().setCurrent(statistic.getFood().getTotal());
|
||||
|
||||
|
||||
SpringUtil.getBean(RedisUtil.class).hset(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getInsureResourceId(),
|
||||
"scenarioInfo",JSON.toJSONString(scenarioInsureInfo));
|
||||
|
||||
SpringUtil.getBean(RedisUtil.class).hset(
|
||||
scenarioTask.getScenarioId() + "-" + roomId + "-" + scenarioTask.getResourceId(),
|
||||
"scenarioInfo",JSON.toJSONString(scenarioSupplierInfo));
|
||||
|
||||
double remain = supplierMedical - statistic.getFood().getTotal();
|
||||
SpringUtil.getBean(RedisUtil.class)
|
||||
.hset(scenarioTask.getScenarioId() + "-" + roomId + "-"
|
||||
+ scenarioTask.getSupplierResourceId(),
|
||||
"food", remain + "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.hivekion.scenario.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* [类的简要说明]
|
||||
* <p>
|
||||
* [详细描述,可选]
|
||||
* <p>
|
||||
*
|
||||
* @author LiDongYU
|
||||
* @since 2025/7/22
|
||||
*/
|
||||
@Data
|
||||
public class StatisticConsumeBean {
|
||||
private String minute;
|
||||
private double food;
|
||||
private double fuel;
|
||||
private double water;
|
||||
private double medical;
|
||||
private double ammunition;
|
||||
private String resourceId;
|
||||
private String resourceName;
|
||||
}
|
||||
|
|
@ -1,7 +1,17 @@
|
|||
package com.hivekion.scenario.controller;
|
||||
|
||||
import com.hivekion.common.entity.ResponseData;
|
||||
import com.hivekion.scenario.bean.StatisticConsumeBean;
|
||||
import com.hivekion.scenario.entity.ScenarioResource;
|
||||
import com.hivekion.scenario.service.IBattleConsumeService;
|
||||
import com.hivekion.scenario.service.ScenarioResourceService;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
|
@ -11,8 +21,33 @@ import org.springframework.stereotype.Controller;
|
|||
* @author liDongYu
|
||||
* @since 2025-09-19
|
||||
*/
|
||||
@Controller
|
||||
@RestController
|
||||
@RequestMapping("/scenario/battleConsume")
|
||||
public class BattleConsumeController {
|
||||
|
||||
@Resource
|
||||
private IBattleConsumeService battleConsumeService;
|
||||
@Resource
|
||||
private ScenarioResourceService scenarioResourceService;
|
||||
|
||||
@GetMapping("/statistic/minute")
|
||||
public ResponseData<List<StatisticConsumeBean>> statisticByMinute() {
|
||||
return ResponseData.success(battleConsumeService.statistic());
|
||||
}
|
||||
|
||||
@GetMapping("/statistic/resource")
|
||||
public ResponseData<List<StatisticConsumeBean>> statisticByResource() {
|
||||
|
||||
List<StatisticConsumeBean> list = battleConsumeService.statisticByResource();
|
||||
Map<String, ScenarioResource> resourceMap = scenarioResourceService.resourceMap();
|
||||
|
||||
list.forEach(item -> {
|
||||
|
||||
if (resourceMap.get(item.getResourceId()) != null) {
|
||||
item.setResourceName(resourceMap.get(item.getResourceId()).getResourceName());
|
||||
}
|
||||
});
|
||||
return ResponseData.success(list.stream().filter(a->a.getResourceName()!=null).collect(
|
||||
Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,7 @@ import java.util.Map;
|
|||
import java.util.Objects;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
|
@ -32,7 +28,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
* @author liDongYu
|
||||
* @since 2025-09-15
|
||||
*/
|
||||
@Controller
|
||||
@RestController
|
||||
@RequestMapping("/battleSupplier")
|
||||
public class BattleSupplierController {
|
||||
|
||||
|
|
@ -47,7 +43,7 @@ public class BattleSupplierController {
|
|||
public ResponseData<Void> save(@RequestBody BattleSupplier battleSupplier) {
|
||||
if (battleSupplier.getId() == null) {
|
||||
battleSupplier.setId(IdUtils.simpleUUID());
|
||||
BattleSupplier tmp = battleSupplierService.getOne(new QueryWrapper<BattleSupplier>().eq("BATTLE_RESOURCE_ID",battleSupplier.getBattleResourceId()).or().eq("SUPPLIER_RESOURCE_ID",battleSupplier.getSupplierResourceId()));
|
||||
BattleSupplier tmp = battleSupplierService.getOne(new QueryWrapper<BattleSupplier>().eq("BATTLE_RESOURCE_ID",battleSupplier.getBattleResourceId()).eq("SUPPLIER_RESOURCE_ID",battleSupplier.getSupplierResourceId()));
|
||||
if(Objects.isNull(tmp)) {
|
||||
battleSupplierService.save(battleSupplier);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,13 @@ import com.hivekion.baseData.controller.BaseController;
|
|||
import com.hivekion.baseData.entity.Scenario;
|
||||
import com.hivekion.baseData.service.ScenarioService;
|
||||
import com.hivekion.common.entity.PagedResultVo;
|
||||
import com.hivekion.common.entity.ResponseCmdInfo;
|
||||
import com.hivekion.common.entity.ResponseData;
|
||||
import com.hivekion.common.enums.ResultCodeEnum;
|
||||
import com.hivekion.common.security.SecurityUtils;
|
||||
import com.hivekion.common.uuid.IdUtils;
|
||||
import com.hivekion.enums.ScenarioRoomStatusEnum;
|
||||
import com.hivekion.room.RoomManager;
|
||||
import com.hivekion.scenario.bean.ScenarioWsParam;
|
||||
import com.hivekion.scenario.entity.RoomLog;
|
||||
import com.hivekion.scenario.entity.ScenarioRoom;
|
||||
|
|
@ -18,6 +20,7 @@ import com.hivekion.scenario.service.ScenarioRoomService;
|
|||
import com.hivekion.scenario.service.ScenarioTaskService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -114,6 +117,7 @@ public class ScenarioRoomController extends BaseController {
|
|||
SecurityUtils.getCurrentLoginUser().getUsername()));
|
||||
|
||||
scenarioRoomService.updateStatus(room.getId(), ScenarioRoomStatusEnum.STARTED.getCode());
|
||||
|
||||
scenarioTaskService.start(room.getScenarioId(), room.getId());
|
||||
return ResponseData.success(null);
|
||||
}
|
||||
|
|
@ -143,17 +147,30 @@ public class ScenarioRoomController extends BaseController {
|
|||
SecurityUtils.getCurrentLoginUser().getUsername()));
|
||||
if (Global.roomParamMap.get(room.getScenarioId() + "_" + room.getId()) == null) {
|
||||
|
||||
Global.roomParamMap.put(room.getScenarioId() + "_" + room.getId(), new ScenarioWsParam(room.getMag()));
|
||||
}else{
|
||||
ScenarioWsParam magValue = Global.roomParamMap.get(room.getScenarioId() + "_" + room.getId());
|
||||
Global.roomParamMap.put(room.getScenarioId() + "_" + room.getId(),
|
||||
new ScenarioWsParam(room.getMag()));
|
||||
} else {
|
||||
ScenarioWsParam magValue = Global.roomParamMap.get(
|
||||
room.getScenarioId() + "_" + room.getId());
|
||||
magValue.setMag(room.getMag());
|
||||
}
|
||||
|
||||
log.info("magValue:{}",Global.roomParamMap.get(room.getScenarioId() + "_" + room.getId()));
|
||||
pushRoomInfo(room.getMag(), room);
|
||||
log.info("magValue:{}", Global.roomParamMap.get(room.getScenarioId() + "_" + room.getId()));
|
||||
}
|
||||
return ResponseData.success(null);
|
||||
}
|
||||
|
||||
private void pushRoomInfo(Integer mag, ScenarioRoom room) {
|
||||
ResponseCmdInfo<Object> respObj = new ResponseCmdInfo<>();
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("mag", mag);
|
||||
dataMap.put("status", RoomManager.getRoom(room.getId()).getStatus());
|
||||
respObj.setData(dataMap);
|
||||
respObj.setRoom(room.getId());
|
||||
respObj.setScenarioId(room.getScenarioId());
|
||||
respObj.setCmdType("room_info");
|
||||
Global.sendCmdInfoQueue.add(respObj);
|
||||
}
|
||||
|
||||
@PostMapping("/stop")
|
||||
public ResponseData<Void> stop(@RequestBody ScenarioRoom room) {
|
||||
|
|
@ -173,13 +190,13 @@ public class ScenarioRoomController extends BaseController {
|
|||
room.setScenario(scenario);
|
||||
room.setScenarioName(scenario.getName());
|
||||
room.setRoomLogs(roomLogService.roomLogListLimit10(id));
|
||||
if (Global.roomParamMap.get(scenario.getId()+"_"+id) == null) {
|
||||
if (Global.roomParamMap.get(scenario.getId() + "_" + id) == null) {
|
||||
ScenarioWsParam scenarioWsParam = new ScenarioWsParam(1);
|
||||
scenarioWsParam.setMag(1);
|
||||
Global.roomParamMap.put(scenario.getId()+"_"+id, scenarioWsParam);
|
||||
Global.roomParamMap.put(scenario.getId() + "_" + id, scenarioWsParam);
|
||||
room.setMag(1);
|
||||
} else {
|
||||
room.setMag(Global.roomParamMap.get(scenario.getId()+"_"+id).getMag());
|
||||
room.setMag(Global.roomParamMap.get(scenario.getId() + "_" + id).getMag());
|
||||
}
|
||||
}
|
||||
return ResponseData.success(room);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
package com.hivekion.scenario.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.hivekion.common.entity.ResponseData;
|
||||
import com.hivekion.common.uuid.IdUtils;
|
||||
import com.hivekion.scenario.entity.ScenarioResource;
|
||||
import com.hivekion.scenario.entity.ScenarioTask;
|
||||
import com.hivekion.scenario.service.ScenarioResourceService;
|
||||
import com.hivekion.scenario.service.ScenarioTaskService;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -28,13 +29,33 @@ public class ScenarioTaskController {
|
|||
|
||||
@Resource
|
||||
private ScenarioTaskService scenarioTaskService;
|
||||
@Resource
|
||||
private ScenarioResourceService scenarioResourceService;
|
||||
|
||||
@PostMapping("/save")
|
||||
public ResponseData<Void> save(@RequestBody ScenarioTask scenarioTask) {
|
||||
if (scenarioTask.getId() == null) {
|
||||
|
||||
ScenarioTask queryTask = new ScenarioTask();
|
||||
queryTask.setScenarioId(scenarioTask.getScenarioId());
|
||||
queryTask.setResourceId(scenarioTask.getResourceId());
|
||||
|
||||
List<ScenarioTask> exitTaskList = scenarioTaskService.queryTaskList(queryTask);
|
||||
if (!exitTaskList.isEmpty()) {
|
||||
ScenarioTask lastTask = exitTaskList.get(exitTaskList.size() - 1);
|
||||
scenarioTask.setFromLat(lastTask.getFromLat());
|
||||
scenarioTask.setFromLng(lastTask.getFromLng());
|
||||
} else {
|
||||
ScenarioResource scenarioResource = scenarioResourceService.getById(
|
||||
scenarioTask.getResourceId());
|
||||
scenarioTask.setFromLat(scenarioResource.getLat());
|
||||
scenarioTask.setFromLng(scenarioResource.getLng());
|
||||
}
|
||||
scenarioTask.setId(IdUtils.simpleUUID());
|
||||
|
||||
scenarioTaskService.save(scenarioTask);
|
||||
} else {
|
||||
|
||||
scenarioTaskService.updateById(scenarioTask);
|
||||
}
|
||||
return ResponseData.success(null);
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ public class ScenarioTask implements Serializable {
|
|||
private String status = "init";
|
||||
@TableField(value = "during_time")
|
||||
private Integer duringTime;
|
||||
@TableField(value = "supplier_resource_id")
|
||||
private String supplierResourceId;
|
||||
@TableField(value = "INSURE_RESOURCE_ID")
|
||||
private String insureResourceId;
|
||||
@TableField(value = "supplier_num")
|
||||
private double supplierNum;
|
||||
@TableField(value="from_source")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.hivekion.scenario.mapper;
|
||||
|
||||
import com.hivekion.scenario.bean.StatisticConsumeBean;
|
||||
import com.hivekion.scenario.entity.BattleConsume;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
|
@ -12,5 +14,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
* @since 2025-09-19
|
||||
*/
|
||||
public interface BattleConsumeMapper extends BaseMapper<BattleConsume> {
|
||||
|
||||
List<StatisticConsumeBean> statistic();
|
||||
List<StatisticConsumeBean> statisticByResource();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.hivekion.scenario.mapper;
|
|||
|
||||
import com.hivekion.scenario.entity.ScenarioResource;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
|
@ -12,5 +14,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
* @since 2025-09-09
|
||||
*/
|
||||
public interface ScenarioResourceMapper extends BaseMapper<ScenarioResource> {
|
||||
|
||||
List<ScenarioResource> selectResourceByRoleCode(@Param("scenarioId") Integer scenarioId,@Param("roleCode") String roleCode );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.hivekion.scenario.service;
|
||||
|
||||
import com.hivekion.scenario.bean.StatisticConsumeBean;
|
||||
import com.hivekion.scenario.entity.BattleConsume;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
|
@ -12,5 +14,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
* @since 2025-09-19
|
||||
*/
|
||||
public interface IBattleConsumeService extends IService<BattleConsume> {
|
||||
|
||||
List<StatisticConsumeBean> statistic();
|
||||
List<StatisticConsumeBean> statisticByResource();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.hivekion.scenario.entity.ScenarioResource;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
|
@ -16,4 +17,6 @@ import java.util.Map;
|
|||
public interface ScenarioResourceService extends IService<ScenarioResource> {
|
||||
List<ScenarioResource> getResourceList(ScenarioResource resource);
|
||||
Map<String,ScenarioResource> resourceMap();
|
||||
List<ScenarioResource> getResourceListByScenarioId(Integer scenarioId);
|
||||
List<ScenarioResource> selectResourceByRoleCode( Integer scenarioId, String roleCode );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,4 +19,5 @@ public interface ScenarioTaskService extends IService<ScenarioTask> {
|
|||
void wakeup(Integer id,String roomId);
|
||||
|
||||
List<ScenarioTask> queryTaskList(ScenarioTask task);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package com.hivekion.scenario.service.impl;
|
||||
|
||||
import com.hivekion.scenario.bean.StatisticConsumeBean;
|
||||
import com.hivekion.scenario.entity.BattleConsume;
|
||||
import com.hivekion.scenario.mapper.BattleConsumeMapper;
|
||||
import com.hivekion.scenario.service.IBattleConsumeService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
|
@ -17,4 +20,13 @@ import org.springframework.stereotype.Service;
|
|||
@Service
|
||||
public class BattleConsumeServiceImpl extends ServiceImpl<BattleConsumeMapper, BattleConsume> implements IBattleConsumeService {
|
||||
|
||||
@Override
|
||||
public List<StatisticConsumeBean> statistic() {
|
||||
return this.baseMapper.statistic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StatisticConsumeBean> statisticByResource() {
|
||||
return this.baseMapper.statisticByResource();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class BattleSupplierServiceImpl extends
|
|||
|
||||
@Override
|
||||
public List<ScenarioResource> selectSupplierResource(String battleResourceId) {
|
||||
|
||||
return this.baseMapper.selectSupplierResource(battleResourceId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,4 +106,16 @@ public class ScenarioResourceServiceImpl extends
|
|||
|
||||
return this.list().stream().collect(Collectors.toMap(ScenarioResource::getId, r -> r));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ScenarioResource> getResourceListByScenarioId(Integer scenarioId) {
|
||||
QueryWrapper<ScenarioResource> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("scenario_id", scenarioId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ScenarioResource> selectResourceByRoleCode(Integer scenarioId, String roleCode) {
|
||||
return this.baseMapper.selectResourceByRoleCode(scenarioId, roleCode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,13 +49,17 @@ public class ScenarioTaskServiceImpl extends
|
|||
@Override
|
||||
public void start(Integer scenarioId, String roomId) {
|
||||
//查询想定的持续时间
|
||||
|
||||
Scenario scenario = scenarioService.getScenarioById(scenarioId);
|
||||
if (scenario != null) {
|
||||
//查看想定的持续时间
|
||||
long duringTime = Duration.between(scenario.getStartTime(),scenario.getEndTime() )
|
||||
.getSeconds();
|
||||
|
||||
RoomManager.startRoom(roomId, scenario, duringTime);
|
||||
|
||||
addWeatherEvent(scenario, roomId);
|
||||
|
||||
addTaskEvent(scenario, roomId);
|
||||
}
|
||||
}
|
||||
|
|
@ -80,9 +84,12 @@ public class ScenarioTaskServiceImpl extends
|
|||
public List<ScenarioTask> queryTaskList(ScenarioTask task) {
|
||||
QueryWrapper<ScenarioTask> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("scenario_id", task.getScenarioId());
|
||||
//限定人工添加,默认是空
|
||||
queryWrapper.isNull("from_source");
|
||||
if (StringUtils.isNotBlank(task.getResourceId())) {
|
||||
queryWrapper.eq("resource_id", task.getResourceId());
|
||||
}
|
||||
queryWrapper.orderByAsc("start_time");
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
|
|
@ -142,6 +149,7 @@ public class ScenarioTaskServiceImpl extends
|
|||
|
||||
//增加任务
|
||||
private void addTaskEvent(Scenario scenario, String roomId) {
|
||||
log.info("--------------------hello");
|
||||
ScenarioTask scenarioTask = new ScenarioTask();
|
||||
scenarioTask.setScenarioId(scenario.getId());
|
||||
List<ScenarioTask> taskList = this.queryTaskList(scenarioTask);
|
||||
|
|
@ -154,8 +162,8 @@ public class ScenarioTaskServiceImpl extends
|
|||
switch (task.getTaskType()) {
|
||||
//移动任务
|
||||
case "1":
|
||||
log.info("move task::{}",diff);
|
||||
MoveTask moveRootTask = new MoveTask(task, roomId);
|
||||
|
||||
MoveTask moveRootTask = new MoveTask(task, roomId,null);
|
||||
RoomManager.addAction(roomId, diff, moveRootTask);
|
||||
respObj.setCmdType("moveTask");
|
||||
respObj.setData(JSON.toJSONString(moveRootTask));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.hivekion.statistic.bean;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class BattleConsumeStatistic {
|
||||
|
||||
private String resourceId;
|
||||
|
||||
private Double ammunition;
|
||||
|
||||
private Integer death;
|
||||
|
||||
private Integer injured;
|
||||
|
||||
private Double fuel;
|
||||
|
||||
private Double food;
|
||||
|
||||
private Double water;
|
||||
|
||||
private Double medical;
|
||||
|
||||
private String lat;
|
||||
|
||||
private String lng;
|
||||
|
||||
|
||||
private String consumeDateStr;
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.hivekion.statistic.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class EditBaseScenarioInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private TeamInfo team = new TeamInfo();
|
||||
private PersonInfo person = new PersonInfo();
|
||||
//弹药
|
||||
private AmmunitionInfo ammunition = new AmmunitionInfo();
|
||||
//食品
|
||||
private FoodInfo food = new FoodInfo();
|
||||
//水
|
||||
private WaterInfo water = new WaterInfo();
|
||||
//油
|
||||
private FuelInfo fuel = new FuelInfo();
|
||||
//药材
|
||||
private MedicalInfo medical = new MedicalInfo();
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.hivekion.statistic.bean;
|
||||
|
||||
import com.hivekion.baseData.entity.Fightpowerstaff;
|
||||
import com.hivekion.baseData.entity.OrgSupplier;
|
||||
import com.hivekion.scenario.entity.ScenarioOrgPost;
|
||||
import com.hivekion.scenario.entity.ScenarioResource;
|
||||
import com.hivekion.scenario.entity.ScenarioTask;
|
||||
import com.hivekion.supplier.entity.SupplierRequest;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class EditScenarioInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<ScenarioOrgPost> orgPostList;
|
||||
|
||||
private List<Fightpowerstaff> staffList;
|
||||
|
||||
private List<OrgSupplier> suppliers;
|
||||
|
||||
private List<ScenarioTask> scenarioTasks;
|
||||
|
||||
private List<SupplierRequest> supplierRequests;
|
||||
|
||||
private EditBaseScenarioInfo jbxx = new EditBaseScenarioInfo();
|
||||
|
||||
private ScenarioResource sdzy;
|
||||
|
||||
}
|
||||
|
|
@ -25,4 +25,17 @@ public class ScenarioInfo implements Serializable {
|
|||
|
||||
private List<SupplierRequest> supplierRequests;
|
||||
|
||||
private TeamInfo team = new TeamInfo();
|
||||
private PersonInfo person = new PersonInfo();
|
||||
//弹药
|
||||
private AmmunitionInfo ammunition = new AmmunitionInfo();
|
||||
//食品
|
||||
private FoodInfo food = new FoodInfo();
|
||||
//水
|
||||
private WaterInfo water = new WaterInfo();
|
||||
//油
|
||||
private FuelInfo fuel = new FuelInfo();
|
||||
//药材
|
||||
private MedicalInfo medical = new MedicalInfo();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hivekion.statistic.controller;
|
||||
|
||||
import com.hivekion.common.entity.ResponseData;
|
||||
import com.hivekion.statistic.bean.BattleConsumeStatistic;
|
||||
import com.hivekion.statistic.bean.StatisticBean;
|
||||
import com.hivekion.statistic.service.StatisticService;
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -8,6 +9,8 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* [类的简要说明]
|
||||
* <p>
|
||||
|
|
@ -25,9 +28,14 @@ public class StatisticController {
|
|||
private StatisticService statisticService;
|
||||
|
||||
@GetMapping("/info")
|
||||
|
||||
public ResponseData<StatisticBean> statistic(String resourceId) {
|
||||
|
||||
return ResponseData.success(statisticService.statistic(resourceId));
|
||||
}
|
||||
|
||||
@GetMapping("/battleConsume")
|
||||
public ResponseData<List<BattleConsumeStatistic>> listBattleConsumeStatistic(){
|
||||
List<BattleConsumeStatistic> qryList = this.statisticService.listBattleConsumeStatistic();
|
||||
return ResponseData.success(qryList);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package com.hivekion.statistic.service;
|
||||
|
||||
import com.hivekion.statistic.bean.EditScenarioInfo;
|
||||
import com.hivekion.statistic.bean.ScenarioInfo;
|
||||
|
||||
public interface ScenarioService {
|
||||
|
||||
public ScenarioInfo listScenarioInfo(Integer scenarioId, String roomId, String resourceId);
|
||||
public EditScenarioInfo listEditScenarioInfo(Integer scenarioId, String roomId, String resourceId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package com.hivekion.statistic.service;
|
||||
|
||||
import com.hivekion.statistic.bean.BattleConsumeStatistic;
|
||||
import com.hivekion.statistic.bean.StatisticBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* [类的简要说明]
|
||||
* <p>
|
||||
|
|
@ -13,4 +16,6 @@ import com.hivekion.statistic.bean.StatisticBean;
|
|||
*/
|
||||
public interface StatisticService {
|
||||
StatisticBean statistic(String resourceId);
|
||||
|
||||
List<BattleConsumeStatistic> listBattleConsumeStatistic();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,41 @@
|
|||
package com.hivekion.statistic.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.hivekion.baseData.domain.TblEntity;
|
||||
import com.hivekion.baseData.entity.Fightpowerstaff;
|
||||
import com.hivekion.baseData.entity.OrgSupplier;
|
||||
import com.hivekion.baseData.service.FightpowerstaffService;
|
||||
import com.hivekion.baseData.service.ITblEntityService;
|
||||
import com.hivekion.baseData.service.OrgSupplierService;
|
||||
import com.hivekion.icon.service.IconService;
|
||||
import com.hivekion.scenario.entity.ScenarioOrgPost;
|
||||
import com.hivekion.scenario.entity.ScenarioResource;
|
||||
import com.hivekion.scenario.entity.ScenarioTask;
|
||||
import com.hivekion.scenario.service.IResourceService;
|
||||
import com.hivekion.scenario.service.IScenarioOrgPostService;
|
||||
import com.hivekion.scenario.service.ScenarioResourceService;
|
||||
import com.hivekion.scenario.service.ScenarioTaskService;
|
||||
import com.hivekion.statistic.bean.EditScenarioInfo;
|
||||
import com.hivekion.statistic.bean.ScenarioInfo;
|
||||
import com.hivekion.statistic.service.ScenarioService;
|
||||
import com.hivekion.supplier.entity.SupplierRequest;
|
||||
import com.hivekion.supplier.entity.SuppliesDict;
|
||||
import com.hivekion.supplier.service.ISupplierRequestService;
|
||||
import com.hivekion.supplier.service.SuppliesDictService;
|
||||
import com.hivekion.team.entity.Teaminfo;
|
||||
import com.hivekion.team.service.ITeaminfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component("WebsocketScenarioService")
|
||||
@Slf4j
|
||||
public class ScenarioServiceImpl implements ScenarioService {
|
||||
|
||||
@Resource
|
||||
|
|
@ -41,10 +53,43 @@ public class ScenarioServiceImpl implements ScenarioService {
|
|||
private ScenarioTaskService scenarioTaskService;
|
||||
@Resource
|
||||
private ISupplierRequestService supplierRequestService;
|
||||
|
||||
@Resource
|
||||
private ITeaminfoService teamInfoService;
|
||||
|
||||
@Resource
|
||||
private ScenarioResourceService resourceService;
|
||||
|
||||
@Resource
|
||||
private ITblEntityService iTblEntityService;
|
||||
|
||||
@Resource
|
||||
private IResourceService resourcesService;
|
||||
@Resource
|
||||
private IconService iconService;
|
||||
|
||||
@Override
|
||||
public ScenarioInfo listScenarioInfo(Integer scenarioId, String roomId, String resourceId) {
|
||||
ScenarioInfo scenarioInfo = new ScenarioInfo();
|
||||
//获取分队信息
|
||||
Map<Integer, Teaminfo> map = teamInfoService.teamInfoMap();
|
||||
Map<String, ScenarioResource> resourceMap = resourceService.resourceMap();
|
||||
ScenarioResource resourceInstance = scenarioResourceService.getById(resourceId);
|
||||
if (resourceMap.get(resourceId) != null) {
|
||||
ScenarioResource resource = resourceMap.get(resourceId);
|
||||
if (map.get(resource.getResourceId()) != null) {
|
||||
scenarioInfo.getTeam().setTeamName(map.get(resource.getResourceId()).getName());
|
||||
resourceInstance.setResourceName(map.get(resource.getResourceId()).getName());
|
||||
}
|
||||
}
|
||||
try {
|
||||
scenarioInfo.getTeam().setType(resourceInstance.getType());
|
||||
scenarioInfo.getTeam().setLat(resourceInstance.getLat());
|
||||
scenarioInfo.getTeam().setLng(resourceInstance.getLng());
|
||||
}catch (Exception ex){
|
||||
log.error("============={}==========================",resourceId);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
//获取关联的组织机构信息
|
||||
ScenarioOrgPost post = new ScenarioOrgPost();
|
||||
post.setResourceId(resourceId);
|
||||
|
|
@ -52,21 +97,77 @@ public class ScenarioServiceImpl implements ScenarioService {
|
|||
List<Integer> orgList = orgPostList.stream().map(ScenarioOrgPost::getOrgId)
|
||||
.collect(Collectors.toList());
|
||||
List<Fightpowerstaff> staffList = null;
|
||||
List<OrgSupplier> suppliers = null;
|
||||
if(!orgList.isEmpty()){
|
||||
staffList = fightpowerstaffService.queryByOrgIds(orgList);
|
||||
if(CollectionUtil.isEmpty(staffList)){
|
||||
staffList = new ArrayList<>();
|
||||
}else{
|
||||
int sum = staffList.stream()
|
||||
.mapToInt(Fightpowerstaff::getNumber)
|
||||
.sum();
|
||||
scenarioInfo.getPerson().setCurrent(sum);
|
||||
scenarioInfo.getPerson().setTotal(sum);
|
||||
}
|
||||
//获取物资信息
|
||||
suppliers = orgSupplierService.selectByOrgIds(orgList);
|
||||
if(suppliers==null||suppliers.isEmpty()){
|
||||
suppliers = new ArrayList<>();
|
||||
}
|
||||
Map<String, SuppliesDict> supplierMap = suppliesDictService.supplierDictMap();
|
||||
|
||||
suppliers.forEach(supplier -> {
|
||||
|
||||
SuppliesDict dict = supplierMap.get(supplier.getSupplierId());
|
||||
|
||||
if (dict != null) {
|
||||
switch (dict.getCode()) {
|
||||
case "FOOD":
|
||||
scenarioInfo.getFood().setTotal(scenarioInfo.getFood().getTotal()+supplier.getAccount());
|
||||
scenarioInfo.getFood().setCurrent(scenarioInfo.getFood().getCurrent()+supplier.getAccount());
|
||||
break;
|
||||
case "WATER":
|
||||
scenarioInfo.getWater().setTotal(scenarioInfo.getWater().getTotal()+supplier.getAccount());
|
||||
scenarioInfo.getWater().setCurrent(scenarioInfo.getWater().getCurrent()+supplier.getAccount());
|
||||
break;
|
||||
case "FUEL":
|
||||
scenarioInfo.getFuel().setTotal(scenarioInfo.getFuel().getTotal()+supplier.getAccount());
|
||||
scenarioInfo.getFuel().setCurrent(scenarioInfo.getFuel().getCurrent()+supplier.getAccount());
|
||||
break;
|
||||
case "MEDICAL":
|
||||
scenarioInfo.getMedical().setTotal( scenarioInfo.getMedical().getTotal()+supplier.getAccount());
|
||||
scenarioInfo.getMedical().setCurrent( scenarioInfo.getMedical().getCurrent()+supplier.getAccount());
|
||||
break;
|
||||
|
||||
case "AMMUNITION":
|
||||
scenarioInfo.getAmmunition().setTotal( scenarioInfo.getAmmunition().getTotal()+supplier.getAccount());
|
||||
scenarioInfo.getAmmunition().setCurrent(scenarioInfo.getAmmunition().getCurrent()+supplier.getAccount());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
staffList = new ArrayList<>();
|
||||
orgPostList = new ArrayList<>();
|
||||
suppliers = new ArrayList<>();
|
||||
}
|
||||
//获取物资信息
|
||||
List<OrgSupplier> suppliers = orgSupplierService.selectByOrgIds(orgList);
|
||||
|
||||
ScenarioTask scenarioTask = new ScenarioTask();
|
||||
scenarioTask.setScenarioId(scenarioId);
|
||||
scenarioTask.setRoomId(roomId);
|
||||
scenarioTask.setResourceId(resourceId);
|
||||
List<ScenarioTask> scenarioTasks = scenarioTaskService.queryTaskList(scenarioTask);
|
||||
|
||||
|
||||
List<ScenarioTask> scenarioTasks = scenarioTaskService.queryTaskList(scenarioTask);
|
||||
if(CollectionUtil.isEmpty(scenarioTasks)){
|
||||
scenarioTasks =new ArrayList<>();
|
||||
}
|
||||
List<SupplierRequest> supplierRequests = supplierRequestService.list(new QueryWrapper<SupplierRequest>().eq("FROM_RESOURCE_ID",resourceId));
|
||||
ScenarioInfo scenarioInfo = new ScenarioInfo();
|
||||
if(CollectionUtil.isEmpty(supplierRequests)){
|
||||
supplierRequests =new ArrayList<>();
|
||||
}
|
||||
scenarioInfo.setScenarioTasks(scenarioTasks);
|
||||
scenarioInfo.setStaffList(staffList);
|
||||
scenarioInfo.setOrgPostList(orgPostList);
|
||||
|
|
@ -74,4 +175,157 @@ public class ScenarioServiceImpl implements ScenarioService {
|
|||
scenarioInfo.setSupplierRequests(supplierRequests);
|
||||
return scenarioInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditScenarioInfo listEditScenarioInfo(Integer scenarioId, String roomId, String resourceId) {
|
||||
EditScenarioInfo scenarioInfo = new EditScenarioInfo();
|
||||
//图标Map
|
||||
Map<String, String> iconMap = iconService.iconMap();
|
||||
//装备Map
|
||||
Map<Integer, TblEntity> entityMap = iTblEntityService.entityMap();
|
||||
Map<Integer,com.hivekion.scenario.entity.Resource> hResourceMap = resourcesService.listBuildResourceByType(7);
|
||||
Map<Integer,com.hivekion.scenario.entity.Resource> wResourceMap = resourcesService.listBuildResourceByType(8);
|
||||
//获取分队信息
|
||||
Map<Integer, Teaminfo> map = teamInfoService.teamInfoMap();
|
||||
Map<String, ScenarioResource> resourceMap = resourceService.resourceMap();
|
||||
ScenarioResource resourceInstance = scenarioResourceService.getById(resourceId);
|
||||
switch (resourceInstance.getResourceType()) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
if (entityMap.get(resourceInstance.getResourceId()) != null) {
|
||||
TblEntity entity = entityMap.get(resourceInstance.getResourceId());
|
||||
resourceInstance.setTitle(entity.getEntityName());
|
||||
resourceInstance.setImgBase64(
|
||||
iconMap.get(entity.getIconId()) == null ? "" : iconMap.get(entity.getIconId()));
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
if (map.get(resourceInstance.getResourceId()) != null) {
|
||||
Teaminfo teaminfo = map.get(resourceInstance.getResourceId());
|
||||
resourceInstance.setTitle(teaminfo.getName());
|
||||
resourceInstance.setImgBase64(
|
||||
iconMap.get(teaminfo.getIconId()) == null ? "" : iconMap.get(teaminfo.getIconId()));
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if(hResourceMap.get(resourceInstance.getResourceId()) != null){
|
||||
com.hivekion.scenario.entity.Resource resource1 = hResourceMap.get(resourceInstance.getResourceId());
|
||||
resourceInstance.setTitle(resource1.getResourceName());
|
||||
resourceInstance.setImgBase64(
|
||||
iconMap.get(resource1.getIcon()) == null ? "" : iconMap.get(resource1.getIcon()));
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if(wResourceMap.get(resourceInstance.getResourceId()) != null){
|
||||
com.hivekion.scenario.entity.Resource resource1 = wResourceMap.get(resourceInstance.getResourceId());
|
||||
resourceInstance.setTitle(resource1.getResourceName());
|
||||
resourceInstance.setImgBase64(
|
||||
iconMap.get(resource1.getIcon()) == null ? "" : iconMap.get(resource1.getIcon()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (resourceMap.get(resourceId) != null) {
|
||||
ScenarioResource resource = resourceMap.get(resourceId);
|
||||
if (map.get(resource.getResourceId()) != null) {
|
||||
scenarioInfo.getJbxx().getTeam().setTeamName(map.get(resource.getResourceId()).getName());
|
||||
resourceInstance.setResourceName(map.get(resource.getResourceId()).getName());
|
||||
}
|
||||
}
|
||||
try {
|
||||
scenarioInfo.getJbxx().getTeam().setType(resourceInstance.getType());
|
||||
scenarioInfo.getJbxx().getTeam().setLat(resourceInstance.getLat());
|
||||
scenarioInfo.getJbxx().getTeam().setLng(resourceInstance.getLng());
|
||||
}catch (Exception ex){
|
||||
log.error("============={}==========================",resourceId);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
//获取关联的组织机构信息
|
||||
ScenarioOrgPost post = new ScenarioOrgPost();
|
||||
post.setResourceId(resourceId);
|
||||
List<ScenarioOrgPost> orgPostList = scenarioOrgPostService.selectByCondition(post);
|
||||
List<Integer> orgList = orgPostList.stream().map(ScenarioOrgPost::getOrgId)
|
||||
.collect(Collectors.toList());
|
||||
List<Fightpowerstaff> staffList = null;
|
||||
List<OrgSupplier> suppliers = null;
|
||||
if(!orgList.isEmpty()){
|
||||
staffList = fightpowerstaffService.queryByOrgIds(orgList);
|
||||
if(CollectionUtil.isEmpty(staffList)){
|
||||
staffList = new ArrayList<>();
|
||||
}else{
|
||||
int sum = staffList.stream()
|
||||
.mapToInt(Fightpowerstaff::getNumber)
|
||||
.sum();
|
||||
scenarioInfo.getJbxx().getPerson().setCurrent(sum);
|
||||
scenarioInfo.getJbxx().getPerson().setTotal(sum);
|
||||
}
|
||||
//获取物资信息
|
||||
suppliers = orgSupplierService.selectByOrgIds(orgList);
|
||||
if(suppliers==null||suppliers.isEmpty()){
|
||||
suppliers = new ArrayList<>();
|
||||
}
|
||||
Map<String, SuppliesDict> supplierMap = suppliesDictService.supplierDictMap();
|
||||
|
||||
suppliers.forEach(supplier -> {
|
||||
|
||||
SuppliesDict dict = supplierMap.get(supplier.getSupplierId());
|
||||
|
||||
if (dict != null) {
|
||||
switch (dict.getCode()) {
|
||||
case "FOOD":
|
||||
scenarioInfo.getJbxx().getFood().setTotal(scenarioInfo.getJbxx().getFood().getTotal()+supplier.getAccount());
|
||||
scenarioInfo.getJbxx().getFood().setCurrent(scenarioInfo.getJbxx().getFood().getCurrent()+supplier.getAccount());
|
||||
break;
|
||||
case "WATER":
|
||||
scenarioInfo.getJbxx().getWater().setTotal(scenarioInfo.getJbxx().getWater().getTotal()+supplier.getAccount());
|
||||
scenarioInfo.getJbxx().getWater().setCurrent(scenarioInfo.getJbxx().getWater().getCurrent()+supplier.getAccount());
|
||||
break;
|
||||
case "FUEL":
|
||||
scenarioInfo.getJbxx().getFuel().setTotal(scenarioInfo.getJbxx().getFuel().getTotal()+supplier.getAccount());
|
||||
scenarioInfo.getJbxx().getFuel().setCurrent(scenarioInfo.getJbxx().getFuel().getCurrent()+supplier.getAccount());
|
||||
break;
|
||||
case "MEDICAL":
|
||||
scenarioInfo.getJbxx().getMedical().setTotal( scenarioInfo.getJbxx().getMedical().getTotal()+supplier.getAccount());
|
||||
scenarioInfo.getJbxx().getMedical().setCurrent( scenarioInfo.getJbxx().getMedical().getCurrent()+supplier.getAccount());
|
||||
break;
|
||||
|
||||
case "AMMUNITION":
|
||||
scenarioInfo.getJbxx().getAmmunition().setTotal( scenarioInfo.getJbxx().getAmmunition().getTotal()+supplier.getAccount());
|
||||
scenarioInfo.getJbxx().getAmmunition().setCurrent(scenarioInfo.getJbxx().getAmmunition().getCurrent()+supplier.getAccount());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
staffList = new ArrayList<>();
|
||||
orgPostList = new ArrayList<>();
|
||||
suppliers = new ArrayList<>();
|
||||
}
|
||||
|
||||
ScenarioTask scenarioTask = new ScenarioTask();
|
||||
scenarioTask.setScenarioId(scenarioId);
|
||||
scenarioTask.setRoomId(roomId);
|
||||
scenarioTask.setResourceId(resourceId);
|
||||
|
||||
|
||||
List<ScenarioTask> scenarioTasks = scenarioTaskService.queryTaskList(scenarioTask);
|
||||
if(CollectionUtil.isEmpty(scenarioTasks)){
|
||||
scenarioTasks =new ArrayList<>();
|
||||
}
|
||||
List<SupplierRequest> supplierRequests = supplierRequestService.list(new QueryWrapper<SupplierRequest>().eq("FROM_RESOURCE_ID",resourceId));
|
||||
if(CollectionUtil.isEmpty(supplierRequests)){
|
||||
supplierRequests =new ArrayList<>();
|
||||
}
|
||||
scenarioInfo.setScenarioTasks(scenarioTasks);
|
||||
scenarioInfo.setStaffList(staffList);
|
||||
scenarioInfo.setOrgPostList(orgPostList);
|
||||
scenarioInfo.setSuppliers(suppliers);
|
||||
scenarioInfo.setSupplierRequests(supplierRequests);
|
||||
scenarioInfo.setSdzy(resourceInstance);
|
||||
return scenarioInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,17 +8,21 @@ import com.hivekion.baseData.entity.OrgSupplier;
|
|||
import com.hivekion.baseData.service.FightpowerstaffService;
|
||||
import com.hivekion.baseData.service.OrgSupplierService;
|
||||
import com.hivekion.scenario.bean.BattleSuppleVo;
|
||||
import com.hivekion.scenario.entity.BattleConsume;
|
||||
import com.hivekion.scenario.entity.BattleSupplier;
|
||||
import com.hivekion.scenario.entity.ScenarioOrgPost;
|
||||
import com.hivekion.scenario.entity.ScenarioResource;
|
||||
import com.hivekion.scenario.service.IBattleConsumeService;
|
||||
import com.hivekion.scenario.service.IBattleSupplierService;
|
||||
import com.hivekion.scenario.service.IScenarioOrgPostService;
|
||||
import com.hivekion.scenario.service.ScenarioResourceService;
|
||||
import com.hivekion.statistic.bean.BattleConsumeStatistic;
|
||||
import com.hivekion.statistic.bean.StatisticBean;
|
||||
import com.hivekion.statistic.service.StatisticService;
|
||||
import com.hivekion.supplier.entity.SuppliesDict;
|
||||
import com.hivekion.supplier.service.SuppliesDictService;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -63,6 +67,9 @@ public class StatisticServiceImpl implements StatisticService {
|
|||
@Resource
|
||||
private ScenarioResourceService resourceService;
|
||||
|
||||
@Resource
|
||||
private IBattleConsumeService battleConsumeService;
|
||||
|
||||
|
||||
@Override
|
||||
public StatisticBean statistic(String resourceId) {
|
||||
|
|
@ -70,6 +77,7 @@ public class StatisticServiceImpl implements StatisticService {
|
|||
//获取分队信息
|
||||
ScenarioResource resourceInstance = scenarioResourceService.getById(resourceId);
|
||||
if(resourceInstance == null){
|
||||
log.info("==========================");
|
||||
return statisticBean;
|
||||
}
|
||||
Map<Integer, Teaminfo> map = teamInfoService.teamInfoMap();
|
||||
|
|
@ -110,7 +118,7 @@ public class StatisticServiceImpl implements StatisticService {
|
|||
List<Integer> orgList = orgPostList.stream().map(ScenarioOrgPost::getOrgId)
|
||||
.collect(Collectors.toList());
|
||||
if(CollectionUtil.isEmpty(orgList)){
|
||||
return new StatisticBean();
|
||||
return statisticBean;
|
||||
}
|
||||
//获取人员信息
|
||||
if(!orgList.isEmpty()){
|
||||
|
|
@ -165,4 +173,19 @@ public class StatisticServiceImpl implements StatisticService {
|
|||
return statisticBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BattleConsumeStatistic> listBattleConsumeStatistic() {
|
||||
List<BattleConsume> qryList = this.battleConsumeService.list();
|
||||
List<BattleConsumeStatistic> qryResult = new ArrayList<>();
|
||||
qryList.stream().forEach(battleConsume -> {
|
||||
BattleConsumeStatistic battleConsumeStatistic = new BattleConsumeStatistic();
|
||||
BeanUtil.copyProperties(battleConsume,battleConsumeStatistic);
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
String consumeDateStr = dateTimeFormatter.format(battleConsume.getConsumeDate());
|
||||
battleConsumeStatistic.setConsumeDateStr(consumeDateStr);
|
||||
qryResult.add(battleConsumeStatistic);
|
||||
});
|
||||
return qryResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.hivekion.common.entity.SearchInputVo;
|
|||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
|
@ -19,6 +20,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||
*/
|
||||
@TableName("TBL_TEAMINFO")
|
||||
@ApiModel(value = "Teaminfo对象", description = "")
|
||||
@Data
|
||||
public class Teaminfo extends SearchInputVo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -40,64 +42,9 @@ public class Teaminfo extends SearchInputVo {
|
|||
@ApiModelProperty("图标ID")
|
||||
@TableField(value="icon_id")
|
||||
private String iconId;
|
||||
@TableField(value="team_type")
|
||||
private Integer teamType;
|
||||
@TableField(value="role_code")
|
||||
private String roleCode;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getGuid() {
|
||||
return guid;
|
||||
}
|
||||
|
||||
public void setGuid(String guid) {
|
||||
this.guid = guid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMappingguid() {
|
||||
return mappingguid;
|
||||
}
|
||||
|
||||
public void setMappingguid(String mappingguid) {
|
||||
this.mappingguid = mappingguid;
|
||||
}
|
||||
|
||||
public String getIconId() {
|
||||
return iconId;
|
||||
}
|
||||
|
||||
public void setIconId(String iconId) {
|
||||
this.iconId = iconId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Teaminfo{" +
|
||||
"id = " + id +
|
||||
", guid = " + guid +
|
||||
", name = " + name +
|
||||
", type = " + type +
|
||||
", mappingguid = " + mappingguid +
|
||||
", iconId = " + iconId +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,6 @@ public interface ITeaminfoService extends IService<Teaminfo> {
|
|||
List<Teaminfo> list(Teaminfo teaminfo);
|
||||
|
||||
Long count(Teaminfo teaminfo);
|
||||
List<Teaminfo> queryByType(Integer type);
|
||||
List<Teaminfo> queryByType(Integer type,Integer teamType);
|
||||
Map<Integer,Teaminfo> teamInfoMap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,9 +33,10 @@ public class TeaminfoServiceImpl extends ServiceImpl<TeaminfoMapper, Teaminfo> i
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Teaminfo> queryByType(Integer type) {
|
||||
public List<Teaminfo> queryByType(Integer type, Integer teamType) {
|
||||
QueryWrapper<Teaminfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("type", type);
|
||||
queryWrapper.eq("team_type", teamType == null ? 0 : teamType);
|
||||
queryWrapper.orderByAsc("id");
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,11 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.hivekion.Global;
|
||||
import com.hivekion.common.entity.RequestCmdInfo;
|
||||
import com.hivekion.common.entity.ResponseCmdInfo;
|
||||
import com.hivekion.ws.WsServer;
|
||||
import com.hivekion.room.RoomManager;
|
||||
import com.hivekion.room.bean.Room;
|
||||
import com.hivekion.scenario.entity.ScenarioResource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
|
|
@ -23,21 +27,107 @@ public class HandleReceiveRunnable implements Runnable {
|
|||
@Override
|
||||
public void run() {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
try {
|
||||
|
||||
try {
|
||||
RequestCmdInfo requestCmdInfo = Global.receiveCmdInfoQueue.take();
|
||||
//消息分发业务bean处理
|
||||
if(SpringUtil.getBean(WebsocketMsgWrapper.class) != null){
|
||||
WebsocketMsgWrapper websocketMsgWrapper = SpringUtil.getBean(WebsocketMsgWrapper.class);
|
||||
websocketMsgWrapper.msgHandle(requestCmdInfo.getScenarioId(),requestCmdInfo.getRoom(),requestCmdInfo.getResourceId(),requestCmdInfo.getMessage());
|
||||
}else{
|
||||
log.warn("==================WebsocketMsgWrapper is null==========================");
|
||||
switch (requestCmdInfo.getCmdType()) {
|
||||
case "get_init_path":
|
||||
case "get_room_info":
|
||||
handleMessage(requestCmdInfo);
|
||||
break;
|
||||
default:
|
||||
//消息分发业务bean处理
|
||||
if (SpringUtil.getBean(WebsocketMsgWrapper.class) != null) {
|
||||
try {
|
||||
WebsocketMsgWrapper websocketMsgWrapper = SpringUtil.getBean(WebsocketMsgWrapper.class);
|
||||
websocketMsgWrapper.msgHandle(requestCmdInfo.getScenarioId(), requestCmdInfo.getRoom(),
|
||||
requestCmdInfo.getResourceId(), requestCmdInfo.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("error::", e);
|
||||
}
|
||||
|
||||
} else {
|
||||
log.warn("==================WebsocketMsgWrapper is null==========================");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("error::", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleMessage(RequestCmdInfo requestCmdInfo) {
|
||||
|
||||
try {
|
||||
switch (requestCmdInfo.getCmdType()) {
|
||||
case "get_init_path":
|
||||
handleGetInitPath(requestCmdInfo);
|
||||
break;
|
||||
case "get_room_info":
|
||||
handleGetRootInfo(requestCmdInfo);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("error::", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleGetRootInfo(RequestCmdInfo requestCmdInfo) {
|
||||
log.info("接收到获取到房间信息::{}", JSON.toJSONString(requestCmdInfo));
|
||||
Room room = RoomManager.getRoom(requestCmdInfo.getRoom());
|
||||
log.info("room::{}", room);
|
||||
ResponseCmdInfo<Object> respObj = new ResponseCmdInfo<>();
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
respObj.setData(dataMap);
|
||||
respObj.setRoom(requestCmdInfo.getRoom());
|
||||
respObj.setScenarioId(requestCmdInfo.getScenarioId());
|
||||
respObj.setCmdType("room_info");
|
||||
|
||||
if (room != null) {
|
||||
|
||||
dataMap.put("status", room.getNumStatus().get());
|
||||
dataMap.put("mag", room.getMag());
|
||||
} else {
|
||||
dataMap.put("status", 0);
|
||||
dataMap.put("mag", 1);
|
||||
}
|
||||
Global.sendCmdInfoQueue.add(respObj);
|
||||
}
|
||||
|
||||
private void handleGetInitPath(RequestCmdInfo requestCmdInfo) {
|
||||
log.info("接收到请求路线信息::{}", JSON.toJSONString(requestCmdInfo));
|
||||
Room room = RoomManager.getRoom(requestCmdInfo.getRoom());
|
||||
if (room != null) {
|
||||
Map<String, Object> pathMap = room.getPathMap();
|
||||
pathMap.forEach((k, v) -> {
|
||||
try {
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
Map<String, ScenarioResource> resourceMap = room.getScenarioResourceMap();
|
||||
dataMap.put("teamType", resourceMap.get(k).getType());
|
||||
ResponseCmdInfo<Object> respObj = new ResponseCmdInfo<>();
|
||||
|
||||
dataMap.put("resourceId", k);
|
||||
dataMap.put("points", v);
|
||||
respObj.setData(dataMap);
|
||||
respObj.setRoom(requestCmdInfo.getRoom());
|
||||
respObj.setScenarioId(requestCmdInfo.getScenarioId());
|
||||
respObj.setCmdType("path_init");
|
||||
Global.sendCmdInfoQueue.add(respObj);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("error::", e);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,33 +3,101 @@ package com.hivekion.thread;
|
|||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.hivekion.Global;
|
||||
import com.hivekion.baseData.entity.Scenario;
|
||||
import com.hivekion.common.entity.ResponseCmdInfo;
|
||||
import com.hivekion.common.redis.RedisUtil;
|
||||
import com.hivekion.scenario.entity.ScenarioResource;
|
||||
import com.hivekion.scenario.service.ScenarioResourceService;
|
||||
import com.hivekion.statistic.bean.EditScenarioInfo;
|
||||
import com.hivekion.statistic.bean.ScenarioInfo;
|
||||
import com.hivekion.statistic.service.ScenarioService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class WebsocketMsgWrapper {
|
||||
|
||||
|
||||
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Resource
|
||||
private ScenarioResourceService scenarioResourceService;
|
||||
|
||||
|
||||
|
||||
public void msgHandle(Integer scenarioId,String roomId,String resourceId,String msg){
|
||||
ResponseCmdInfo responseCmdInfo = new ResponseCmdInfo();
|
||||
responseCmdInfo.setScenarioId(scenarioId);
|
||||
responseCmdInfo.setRoom(roomId);
|
||||
try {
|
||||
JSONObject msgObj = (JSONObject) JSON.parse(msg);
|
||||
|
||||
if(msgObj.getString("cmdType").equals("scenarioRunningInfo")){
|
||||
if( redisUtil == null) {
|
||||
redisUtil = SpringUtil.getBean(RedisUtil.class);
|
||||
}
|
||||
JSONArray allScenario = new JSONArray();
|
||||
List<ScenarioResource> scenarioResourceList = this.scenarioResourceService.list(new QueryWrapper<ScenarioResource>().eq("scenario_id",scenarioId));
|
||||
for(ScenarioResource scenarioResource : scenarioResourceList) {
|
||||
if(redisUtil.hasKey(scenarioResource.getScenarioId() + "-" + roomId + "-" + scenarioResource.getId(), "scenarioInfo")) {
|
||||
String jsonStr = (String) redisUtil.hget(scenarioResource.getScenarioId() + "-" + roomId + "-" + scenarioResource.getId(), "scenarioInfo");
|
||||
allScenario.add(jsonStr);
|
||||
}
|
||||
}
|
||||
responseCmdInfo.setData(JSONArray.toJSONString(allScenario));
|
||||
responseCmdInfo.setCmdType("scenarioInfo");
|
||||
}
|
||||
if(msgObj.getString("cmdType").equals("scenarioInfo")){
|
||||
ScenarioService scenarioService = SpringUtil.getBean(ScenarioService.class);
|
||||
if(scenarioService != null){
|
||||
ScenarioInfo scenarioInfo= scenarioService.listScenarioInfo(scenarioId,roomId,resourceId);
|
||||
String scenarioInfoStr = com.alibaba.fastjson2.JSON.toJSONString(scenarioInfo);
|
||||
responseCmdInfo.setData(scenarioInfoStr);
|
||||
}else {
|
||||
log.warn("=============scenarioService is null================================");
|
||||
}
|
||||
List<ScenarioResource> scenarioResourceList = this.scenarioResourceService.list(new QueryWrapper<ScenarioResource>().eq("scenario_id",scenarioId));
|
||||
ScenarioService scenarioService = SpringUtil.getBean(ScenarioService.class);
|
||||
if(scenarioService != null){
|
||||
JSONArray allScenario = new JSONArray();
|
||||
for(ScenarioResource scenarioResource : scenarioResourceList) {
|
||||
ScenarioInfo scenarioInfo = scenarioService.listScenarioInfo(scenarioResource.getScenarioId(), roomId, scenarioResource.getId());
|
||||
String scenarioInfoStr = com.alibaba.fastjson2.JSON.toJSONString(scenarioInfo);
|
||||
allScenario.add(scenarioInfoStr);
|
||||
}
|
||||
responseCmdInfo.setData(JSONArray.toJSONString(allScenario));
|
||||
}else {
|
||||
log.warn("=============scenarioService is null================================");
|
||||
}
|
||||
responseCmdInfo.setCmdType("scenarioInfo");
|
||||
}
|
||||
if(msgObj.getString("cmdType").equals("editScenarioInfo")){
|
||||
List<ScenarioResource> scenarioResourceList = this.scenarioResourceService.list(new QueryWrapper<ScenarioResource>().eq("scenario_id",scenarioId));
|
||||
ScenarioService scenarioService = SpringUtil.getBean(ScenarioService.class);
|
||||
if(scenarioService != null){
|
||||
JSONArray allScenario = new JSONArray();
|
||||
for(ScenarioResource scenarioResource : scenarioResourceList) {
|
||||
EditScenarioInfo editScenarioInfo = scenarioService.listEditScenarioInfo(scenarioResource.getScenarioId(), roomId, scenarioResource.getId());
|
||||
// String scenarioInfoStr = com.alibaba.fastjson2.JSON.toJSONString(scenarioInfo);
|
||||
com.alibaba.fastjson2.JSONObject jsonObject = com.alibaba.fastjson2.JSONObject.from(editScenarioInfo);
|
||||
allScenario.add(jsonObject);
|
||||
}
|
||||
responseCmdInfo.setData(JSONArray.toJSONString(allScenario));
|
||||
}else {
|
||||
log.warn("=============scenarioService is null================================");
|
||||
}
|
||||
|
||||
responseCmdInfo.setCmdType("editScenarioInfo");
|
||||
}
|
||||
if(msgObj.getString("cmdType").equals("updScenarioInfo")){
|
||||
ScenarioService scenarioService = SpringUtil.getBean(ScenarioService.class);
|
||||
if(scenarioService != null){
|
||||
EditScenarioInfo scenarioInfo = scenarioService.listEditScenarioInfo(scenarioId, roomId, msgObj.getString("resourceId"));
|
||||
responseCmdInfo.setData(JSONArray.toJSONString(scenarioInfo));
|
||||
}else {
|
||||
log.warn("=============scenarioService is null================================");
|
||||
}
|
||||
responseCmdInfo.setCmdType("updScenarioInfo");
|
||||
}
|
||||
Global.sendCmdInfoQueue.add(responseCmdInfo);
|
||||
}catch (Exception ex){
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.hivekion.ws;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.hivekion.Global;
|
||||
import com.hivekion.common.entity.RequestCmdInfo;
|
||||
import java.util.Map;
|
||||
|
|
@ -12,7 +13,9 @@ import javax.websocket.Session;
|
|||
import javax.websocket.server.PathParam;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* [类的简要说明]
|
||||
|
|
@ -32,8 +35,8 @@ public class WsServer {
|
|||
// key -> 当前key下所有会话
|
||||
private static final Map<String, Map<String, Map<String, Session>>> SESSION_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Object lock = new Object();
|
||||
|
||||
private static final Object lock = new Object();
|
||||
private static final Object receiveLock = new Object();
|
||||
|
||||
@OnOpen
|
||||
public void onOpen(Session session,
|
||||
|
|
@ -85,15 +88,19 @@ public class WsServer {
|
|||
@OnMessage
|
||||
public void onMessage(String message, Session session, @PathParam("room") String room,
|
||||
@PathParam("scenarioId") Integer scenarioId) {
|
||||
try {
|
||||
log.info("onMessage::room: {}, message: {}", room, message);
|
||||
RequestCmdInfo requestCmdInfo = new RequestCmdInfo();
|
||||
requestCmdInfo.setScenarioId((scenarioId));
|
||||
requestCmdInfo.setRoom(room);
|
||||
requestCmdInfo.setMessage(message);
|
||||
Global.receiveCmdInfoQueue.add(requestCmdInfo);
|
||||
} catch (Exception e) {
|
||||
log.error("onMessage::room: {}, message: {},error::", room, message, e);
|
||||
synchronized (receiveLock) {
|
||||
try {
|
||||
log.info("onMessage::room: {}, message: {}", room, message);
|
||||
RequestCmdInfo requestCmdInfo = new RequestCmdInfo();
|
||||
requestCmdInfo.setScenarioId((scenarioId));
|
||||
requestCmdInfo.setRoom(room);
|
||||
requestCmdInfo.setCmdType(JSON.parseObject(message, RequestCmdInfo.class).getCmdType());
|
||||
|
||||
requestCmdInfo.setMessage(message);
|
||||
Global.receiveCmdInfoQueue.add(requestCmdInfo);
|
||||
} catch (Exception e) {
|
||||
log.error("onMessage::room: {}, message: {},error::", room, message, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -111,11 +118,11 @@ public class WsServer {
|
|||
}
|
||||
|
||||
public static void sendMessage(Integer scenarioId, String room, String message) {
|
||||
// log.info("send {},{},{}", message, scenarioId, room);
|
||||
log.info("send {},{},{}", message, scenarioId, room);
|
||||
|
||||
synchronized (lock) {
|
||||
Map<String, Map<String, Session>> roomMap = SESSION_MAP.get(String.valueOf(scenarioId));
|
||||
// log.info("roomMap:{}", roomMap);
|
||||
// log.info("roomMap:{}", roomMap);
|
||||
if (roomMap != null) {
|
||||
if (roomMap.containsKey(room)) {
|
||||
Map<String, Session> singleRoomMap = roomMap.get(room);
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ death.warn = 56
|
|||
ammunition.warn = 3
|
||||
food.warn = 3
|
||||
water.warn = 3
|
||||
fuel.warn = 2
|
||||
fuel.warn = 95.99
|
||||
medical.warn = 1
|
||||
death.spreed = 3;
|
||||
injured.spreed = 3;
|
||||
ammunition.spreed = 2.6;
|
||||
food.spreed = 2.3;
|
||||
water.spreed = 3.6;
|
||||
fuel.spreed = 3.6;
|
||||
medical.spreed = 1.6;
|
||||
death.spreed = 3
|
||||
injured.spreed = 3
|
||||
ammunition.spreed = 2.6
|
||||
food.spreed = 2.3
|
||||
water.spreed = 3.6
|
||||
fuel.spreed = 0.4
|
||||
medical.spreed = 1.6
|
||||
|
|
@ -1,5 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.hivekion.scenario.mapper.BattleConsumeMapper">
|
||||
<select id="statistic" resultType="com.hivekion.scenario.bean.StatisticConsumeBean">
|
||||
SELECT
|
||||
TO_CHAR(t.CONSUME_DATE, 'YYYY-MM-DD HH24:MI') AS minute,
|
||||
NVL(SUM(t.FOOD), 0) AS food,
|
||||
NVL(SUM(t.FUEL), 0) AS fuel,
|
||||
NVL(SUM(t.WATER), 0) AS water,
|
||||
NVL(SUM(t.MEDICAL), 0) AS medical,
|
||||
NVL(SUM(t.AMMUNITION), 0) AS ammunition
|
||||
FROM
|
||||
TBL_BATTLE_CONSUME t
|
||||
WHERE
|
||||
t.CONSUME_DATE IS NOT NULL
|
||||
GROUP BY
|
||||
TO_CHAR(t.CONSUME_DATE, 'YYYY-MM-DD HH24:MI')
|
||||
ORDER BY
|
||||
minute
|
||||
</select>
|
||||
<select id="statisticByResource" resultType="com.hivekion.scenario.bean.StatisticConsumeBean">
|
||||
SELECT
|
||||
resource_id as resourceId,
|
||||
NVL(SUM(t.FOOD), 0) AS food,
|
||||
NVL(SUM(t.FUEL), 0) AS fuel,
|
||||
NVL(SUM(t.WATER), 0) AS water,
|
||||
NVL(SUM(t.MEDICAL), 0) AS medical,
|
||||
NVL(SUM(t.AMMUNITION), 0) AS ammunition
|
||||
FROM
|
||||
TBL_BATTLE_CONSUME t
|
||||
WHERE
|
||||
t.CONSUME_DATE IS NOT NULL
|
||||
GROUP BY
|
||||
resource_id
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.hivekion.scenario.mapper.BattleSupplierMapper">
|
||||
<select id="selectSupplierResource" resultType="com.hivekion.scenario.entity.ScenarioResource">
|
||||
select id ,lng,lat,scenario_Id as scenarioId, resource_name as resourceName
|
||||
select id ,lng,lat,scenario_Id as scenarioId, resource_name as resourceName,resource_id as resourceId
|
||||
from tbl_scenario_resource
|
||||
where resource_id in
|
||||
(select supplier_resource_id from tbl_battle_supplier where battle_resoure_id = #{battleResourceId})
|
||||
where id in
|
||||
(select supplier_resource_id from tbl_battle_supplier where battle_resource_id = #{battleResourceId})
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<select id="List" resultType="com.hivekion.baseData.entity.Scenario" parameterType="com.hivekion.baseData.entity.Scenario" >
|
||||
SELECT
|
||||
@rownum := @rownum + 1 AS seq,
|
||||
t.Guid,t.Name,t.TestMode,t.Author,t.CreateUserId,t.CreateTime,t.Content,t.id
|
||||
t.Guid,t.Name,t.TestMode,t.Author,t.CreateUserId,t.CreateTime,t.Content,t.id,t.mark
|
||||
FROM (
|
||||
SELECT * FROM tbl_scenario
|
||||
<where>
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
<select id="List" resultType="com.hivekion.baseData.entity.Scenario" parameterType="com.hivekion.baseData.entity.Scenario" databaseId="dm">
|
||||
select
|
||||
t.seq,
|
||||
t.Guid,t.Name,t.TestMode,t.Author,t.CreateUserId,t.CreateTime,t.id
|
||||
t.Guid,t.Name,t.TestMode,t.Author,t.CreateUserId,t.CreateTime,t.id,t.mark
|
||||
FROM (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (ORDER BY id ASC) AS seq,
|
||||
|
|
@ -73,7 +73,8 @@
|
|||
left_bottom_lng AS leftBottomLng,
|
||||
right_bottom_lng AS rightBottomLng,
|
||||
left_bottom_lat AS leftBottomLat,
|
||||
right_bottom_lat AS rightBottomLat
|
||||
right_bottom_lat AS rightBottomLat,
|
||||
mark
|
||||
FROM
|
||||
tbl_scenario
|
||||
WHERE
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.hivekion.scenario.mapper.ScenarioResourceMapper">
|
||||
|
||||
<select id="selectResourceByRoleCode" resultType="com.hivekion.scenario.entity.ScenarioResource">
|
||||
SELECT
|
||||
id,SCENARIO_ID as scenarioId,RESOURCE_TYPE as resourceType,RESOURCE_ID as resourceId,lng,lat
|
||||
FROM
|
||||
TBL_SCENARIO_RESOURCE t where t.SCENARIO_ID = #{scenarioId}
|
||||
and t.RESOURCE_ID in (select id from TBL_TEAMINFO t2 where t2.role_code=#{roleCode})
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
<result property="type" column="type"/>
|
||||
<result property="mappingguid" column="mappingguid"/>
|
||||
<result property="iconId" column="icon_id"/>
|
||||
<result property="teamType" column="team_type"/>
|
||||
<result property="roleCode" column="role_code"/>
|
||||
<!-- 其他字段 -->
|
||||
</resultMap>
|
||||
<select id="list" resultMap="DMTeamInfo" parameterType="com.hivekion.team.entity.Teaminfo" databaseId="dm">
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user