增加仿真工作参数变更后发送ws消息逻辑;

This commit is contained in:
joylink_zhangsai 2022-11-03 15:37:17 +08:00
parent 19775a11ce
commit c0c2e81ebf
9 changed files with 32 additions and 19 deletions

View File

@ -18,7 +18,7 @@ public interface IscsSystemResourcesDAO extends MyBatisBaseDao<IscsSystemResourc
" values " +
" <foreach collection=\"list\" item=\"entity\" separator=\",\"> " +
" (#{entity.mapId,jdbcType=BIGINT}, #{entity.system,jdbcType=VARCHAR}, " +
" #{entity.type,jdbcType=VARCHAR}, #{entity.resource_ids,jdbcType=VARCHAR})" +
" #{entity.type,jdbcType=VARCHAR}, #{entity.resourceIds,jdbcType=VARCHAR})" +
" </foreach>" +
"</script>")
void batchInsert(@Param("list") List<IscsSystemResources> iscsSystemResources);

View File

@ -104,18 +104,6 @@ public class FuZhouLineOne1PassengerFlowDataServiceImpl implements MapPassengerF
this.iCacheService.remove(BusinessConsts.CachePrefix.Map_Passenger_Flow + mapId);
}
@Override
public MapPassengerFlowWithBLOBs queryMapPassengerFlowData(Long mapId) {
MapPassengerFlowExample example = new MapPassengerFlowExample();
example.createCriteria()
.andMapIdEqualTo(mapId);
List<MapPassengerFlowWithBLOBs> mpfs = this.mapPassengerFlowDAO.selectByExampleWithBLOBs(example);
if (!CollectionUtils.isEmpty(mpfs)) {
return mpfs.get(0);
}
return null;
}
@Override
public MapPassengerFlowWithBLOBs queryInitialMapPassengerFlowData(Long mapId) {
MapPassengerFlowExample example = new MapPassengerFlowExample();

View File

@ -1,7 +1,7 @@
package club.joylink.rtss.services.publishData;
import club.joylink.rtss.simulation.cbtc.passenger.data.PassengerFlowData;
import club.joylink.rtss.entity.MapPassengerFlowWithBLOBs;
import club.joylink.rtss.simulation.cbtc.passenger.data.PassengerFlowData;
import club.joylink.rtss.vo.client.passenger.MapPassengerFlowVO;
import java.util.List;
@ -12,8 +12,6 @@ public interface MapPassengerFlowDataService {
void importTripData(Long mapId, String data);
MapPassengerFlowWithBLOBs queryMapPassengerFlowData(Long mapId);
PassengerFlowData queryPassengerFlowDataOfMap(Long mapId, Long passengerFlowId);
MapPassengerFlowWithBLOBs queryInitialMapPassengerFlowData(Long mapId);

View File

@ -9,8 +9,11 @@ import club.joylink.rtss.simulation.cbtc.work.SimulationWorkService;
import club.joylink.rtss.simulation.cbtc.work.SimulationWorkServiceManager;
import club.joylink.rtss.simulation.messaging.websocket.DefaultMessageSender;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.SocketMessageVO;
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
import club.joylink.rtss.vo.client.mapFunction.RtsMapFunctionVO;
import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam;
import club.joylink.rtss.websocket.StompMessageService;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@ -21,6 +24,7 @@ import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@Service
public class SimulationServiceImpl implements SimulationService {
@ -36,6 +40,8 @@ public class SimulationServiceImpl implements SimulationService {
private DefaultMessageSender defaultMessageSender;
@Autowired
private RtsMapFunctionService rtsMapFunctionService;
@Autowired
private StompMessageService stompMessageService;
@Override
public String createSimulation(long mapId, SimulationWorkParamVO workParamVO, @NonNull LoginUserInfoVO loginUserInfoVO) {
@ -91,6 +97,10 @@ public class SimulationServiceImpl implements SimulationService {
"非仿真创建者不能使用该功能");
}
initService.addItems(simulation, functionInfoMap, loginInfo);
SocketMessageVO<SimulationWorkParamVO> workParamMessage = SocketMessageFactory
.buildSimulationWorkParamMessage(simulationId, simulation.getBuildParams().getWorkParamVO());
Set<String> users = simulation.getSimulationUserIds();
stompMessageService.sendToUser(users, workParamMessage);
}
}

View File

@ -7,6 +7,7 @@ import club.joylink.rtss.simulation.cbtc.data.plan.RealRun;
import club.joylink.rtss.simulation.cbtc.data.status.DeviceStatus;
import club.joylink.rtss.simulation.cbtc.event.*;
import club.joylink.rtss.simulation.cbtc.member.SimulationUser;
import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO;
import club.joylink.rtss.simulation.event.SimulationUserDisconnectEvent;
import club.joylink.rtss.simulation.event.SimulationUserSubscribeEvent;
import club.joylink.rtss.simulation.event.SimulationUserUnsubscribeEvent;
@ -151,6 +152,11 @@ public class SimulationUserWsListener {
.build(WebSocketMessageType.Simulation_Alarm, simulation.getId(), alarmList);
this.stompMessageService.sendToUser(userId, alarmMessageVO);
}
// 仿真工作参数同步
SimulationWorkParamVO workParamVO = simulation.getBuildParams().getWorkParamVO();
SocketMessageVO<SimulationWorkParamVO> message = SocketMessageFactory
.buildSimulationWorkParamMessage(simulation.getId(), workParamVO);
this.stompMessageService.sendToUser(userId, message);
}
@Async("nsExecutor")

View File

@ -1,7 +1,6 @@
package club.joylink.rtss.simulation.cbtc.vo;
import club.joylink.rtss.simulation.cbtc.Simulation;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.*;
import org.springframework.util.CollectionUtils;
@ -23,7 +22,6 @@ public class SimulationWorkParamVO {
/**
* 仿真加载项
*/
@JsonInclude(value = JsonInclude.Include.NON_NULL)
private Map<Item, String> itemMap;
/**

View File

@ -55,6 +55,10 @@ public enum WebSocketMessageType {
* 仿真-时间同步消息
*/
Simulation_Time_Sync,
/**
* 仿真-工作参数
*/
SIMULATION_WORK_PARAM,
/**
* 仿真-设备状态消息

View File

@ -17,6 +17,7 @@ import club.joylink.rtss.simulation.cbtc.data.vo.*;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.member.SimulationUser;
import club.joylink.rtss.simulation.cbtc.message.SimulationSubscribeTopic;
import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.SocketMessageVO;
@ -77,6 +78,7 @@ public class SocketMessageFactory {
break;
}
case Simulation_Time_Sync:
case SIMULATION_WORK_PARAM:
case Simulation_User:
case Simulation_Member:
case Simulation_DeviceStatus:
@ -447,4 +449,11 @@ public class SocketMessageFactory {
public static SocketMessageVO<Ticket> buildRailTicketMessage(String sId, Ticket body) {
return build(WebSocketMessageType.SIMULATION_RAIL_TICKET, sId, body);
}
/**
* 构建仿真工作参数
*/
public static SocketMessageVO<SimulationWorkParamVO> buildSimulationWorkParamMessage(String sId, SimulationWorkParamVO body) {
return build(WebSocketMessageType.SIMULATION_WORK_PARAM, sId, body);
}
}

View File

@ -19,7 +19,7 @@ public class PictureVO {
private String type;
private String stationCode;
private List<String> stationCodes;
private Map<String, Device> deviceMap;