Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
4dafe34ec4
|
@ -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,7 +106,7 @@ public class Scenario extends SearchInputVo {
|
|||
private String leftBottomLat;
|
||||
@TableField(value = "right_bottom_lat")
|
||||
private String rightBottomLat;
|
||||
private String desc;
|
||||
private String mark;
|
||||
/**
|
||||
* 想定关联的资源列表
|
||||
*/
|
||||
|
|
|
@ -83,4 +83,7 @@ public class RoomManager {
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
public static Room getRoom(String id){
|
||||
return roomsMap.get(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,6 +161,10 @@ public abstract class AbtParentTask implements TaskAction {
|
|||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("resourceId", scenarioTask.getResourceId());
|
||||
dataMap.put("points", coordinates);
|
||||
|
||||
if(RoomManager.getRoom(roomId)!=null){
|
||||
RoomManager.getRoom(roomId).addResourcePath(this.scenarioTask.getResourceId(),coordinates);
|
||||
}
|
||||
//推送路径任务
|
||||
Global.sendCmdInfoQueue.add(
|
||||
ResponseCmdInfo.create(WsCmdTypeEnum.PATH_INIT.getCode(), roomId,
|
||||
|
@ -233,7 +237,7 @@ 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<>();
|
||||
|
@ -293,6 +297,8 @@ public abstract class AbtParentTask implements TaskAction {
|
|||
if (finishedAction != null) {
|
||||
finishedAction.doSomeThing();
|
||||
}
|
||||
|
||||
|
||||
//完成路径
|
||||
Global.sendCmdInfoQueue.add(
|
||||
ResponseCmdInfo.create(WsCmdTypeEnum.PATH_FINISHED.getCode(), roomId,
|
||||
|
|
|
@ -10,7 +10,10 @@ 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;
|
||||
|
@ -26,10 +29,6 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import com.hivekion.scenario.entity.ScenarioResource;
|
||||
import com.hivekion.statistic.bean.EditScenarioInfo;
|
||||
import com.hivekion.statistic.bean.ScenarioInfo;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
@ -47,6 +46,10 @@ 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<>();
|
||||
/**
|
||||
* 任务管理相关
|
||||
*/
|
||||
|
@ -218,24 +221,49 @@ public class Room implements AutoCloseable {
|
|||
return status.get();
|
||||
}
|
||||
|
||||
public void initRoomParam(){
|
||||
if( scenarioService == null) {
|
||||
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){
|
||||
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));
|
||||
redisUtil.hset(
|
||||
scenarioResource.getScenarioId() + "-" + roomId + "-" + scenarioResource.getId(),
|
||||
"scenarioInfo", JSON.toJSONString(scenarioInfo));
|
||||
redisUtil.hset(
|
||||
scenarioResource.getScenarioId() + "-" + roomId + "-" + scenarioResource.getId(),
|
||||
"updScenarioInfo", JSON.toJSONString(updScenarioInfo));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -19,4 +19,5 @@ public interface ScenarioTaskService extends IService<ScenarioTask> {
|
|||
void wakeup(Integer id,String roomId);
|
||||
|
||||
List<ScenarioTask> queryTaskList(ScenarioTask task);
|
||||
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ public class ScenarioTaskServiceImpl extends
|
|||
if (StringUtils.isNotBlank(task.getResourceId())) {
|
||||
queryWrapper.eq("resource_id", task.getResourceId());
|
||||
}
|
||||
queryWrapper.orderByAsc("start_time");
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,7 @@ public class Teaminfo extends SearchInputVo {
|
|||
@ApiModelProperty("图标ID")
|
||||
@TableField(value="icon_id")
|
||||
private String iconId;
|
||||
@TableField(value="team_type")
|
||||
private Integer teamType;
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,10 @@ import cn.hutool.extra.spring.SpringUtil;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.hivekion.Global;
|
||||
import com.hivekion.common.entity.RequestCmdInfo;
|
||||
import com.hivekion.common.entity.ResponseCmdInfo;
|
||||
import com.hivekion.room.RoomManager;
|
||||
import com.hivekion.room.bean.Room;
|
||||
import com.hivekion.ws.WsServer;
|
||||
import java.util.Map;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
|
@ -23,14 +25,21 @@ 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{
|
||||
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==========================");
|
||||
}
|
||||
|
||||
|
@ -40,4 +49,39 @@ public class HandleReceiveRunnable implements Runnable {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleMessage(RequestCmdInfo requestCmdInfo) {
|
||||
try {
|
||||
switch (requestCmdInfo.getCmdType()) {
|
||||
case "get_init_path":
|
||||
handleGetInitPath(requestCmdInfo);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("error::", e);
|
||||
}
|
||||
}
|
||||
|
||||
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{
|
||||
WsServer.sendMessage(requestCmdInfo.getScenarioId(),requestCmdInfo.getRoom(),
|
||||
JSON.toJSONString(v));
|
||||
|
||||
}catch (Exception e){
|
||||
log.error("error::",e);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<result property="type" column="type"/>
|
||||
<result property="mappingguid" column="mappingguid"/>
|
||||
<result property="iconId" column="icon_id"/>
|
||||
<result property="teamType" column="team_type"/>
|
||||
<!-- 其他字段 -->
|
||||
</resultMap>
|
||||
<select id="list" resultMap="DMTeamInfo" parameterType="com.hivekion.team.entity.Teaminfo" databaseId="dm">
|
||||
|
|
Loading…
Reference in New Issue
Block a user