查询存在仿真接口增加筛选功能

This commit is contained in:
joylink_zhangsai 2022-05-18 13:38:00 +08:00
parent 83bd55d67f
commit d04d8dd4b4
6 changed files with 56 additions and 17 deletions

View File

@ -1,13 +1,11 @@
package club.joylink.rtss.controller.test;
import club.joylink.rtss.controller.advice.AuthenticateInterceptor;
import club.joylink.rtss.controller.advice.Role;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.ModbusTcpTestService;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.PlcGatewayConnectManager;
import club.joylink.rtss.vo.AccountVO;
import io.netty.channel.Channel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -29,8 +27,22 @@ public class ModbusTestController {
@Role(SuperAdmin)
@PostMapping("/writeCoil")
public void modbusWriteSingleCoil(String code,
int addr, boolean val) {
int addr, boolean val) {
this.modbusTcpTestService.writeSingleCoil(this.plcGatewayConnectManager.getChannel(code), addr, val);
}
@Role(SuperAdmin)
@PostMapping("/writeCoil/test")
public void modbusWriteSignalCoilTest() throws InterruptedException {
int start = 96;
Channel channel = this.plcGatewayConnectManager.getChannel("Test");
this.modbusTcpTestService.writeSingleCoil(channel, start, true);
Thread.sleep(1000);
for (int i = start + 1; i < start + 24; i++) {
this.modbusTcpTestService.writeSingleCoil(channel, i, true);
this.modbusTcpTestService.writeSingleCoil(channel, i - 1, false);
Thread.sleep(1000);
}
this.modbusTcpTestService.writeSingleCoil(channel, start + 23, false);
}
}

View File

@ -5,6 +5,7 @@ import club.joylink.rtss.simulation.vo.SimulationFaultVO;
import club.joylink.rtss.simulation.vo.SimulationInfoVO;
import club.joylink.rtss.simulation.vo.SimulationMemberVO;
import club.joylink.rtss.simulation.vo.SimulationUserVO;
import club.joylink.rtss.vo.client.simulationv1.SimulationInfoQueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
@ -12,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 仿真通用接口
@ -25,12 +27,20 @@ public class SimulationCommonController {
private SimulationOperationDispatcher simulationOperationDispatcher;
@GetMapping("/list")
public List<SimulationInfoVO> queryInfo() {
public List<SimulationInfoVO> queryInfo(SimulationInfoQueryVO queryVO) {
List<Simulation> simulationList = this.simulationManager.getSimulationList();
List<SimulationInfoVO> list = simulationList.stream()
.map(Simulation::convertToVO)
.collect(Collectors.toList());
return list;
Stream<Simulation> stream = simulationList.stream();
if (StringUtils.hasText(queryVO.getGroup())) {
stream = stream.filter(simulation -> simulation.getId().contains(queryVO.getGroup()));
}
if (StringUtils.hasText(queryVO.getUserName())) {
stream = stream.filter(simulation -> simulation.getSimulationUsers().stream().anyMatch(user -> ((SimulationUser) user).getName().contains(queryVO.getUserName())));
}
if (StringUtils.hasText(queryVO.getPrdType())) {
stream = stream.filter(simulation -> simulation instanceof club.joylink.rtss.simulation.cbtc.Simulation
&& queryVO.getPrdType().equals(((club.joylink.rtss.simulation.cbtc.Simulation) simulation).getBuildParams().getProdType().getCode()));
}
return stream.map(Simulation::convertToVO).collect(Collectors.toList());
}
@PutMapping("/{id}/pause")

View File

@ -268,7 +268,7 @@ public class StationOperateHandler {
}
/**
* 引导总锁
* 引导总锁大铁
* @param stationCode 车站
*/
@OperateHandlerMapping(type = Operation.Type.Station_Master_Lock)
@ -277,7 +277,7 @@ public class StationOperateHandler {
}
/**
* 解除引导总锁
* 解除引导总锁大铁
*/
@OperateHandlerMapping(type = Operation.Type.Station_Master_Unlock)
public void masterUnlock(Simulation simulation, String stationCode, Station.Throat throat) {

View File

@ -242,11 +242,6 @@ public class Route extends MapNamedElement {
}
}
}
// if (Objects.nonNull(this.overlap)) {
// if (this.overlap.containRpSwitch()) { // 延续保护存在反位道岔
// return false;
// }
// }
return true;
}

View File

@ -6,15 +6,21 @@ import club.joylink.rtss.simulation.vo.SimulationInfoVO;
import club.joylink.rtss.vo.map.MapVO;
import lombok.Getter;
import java.time.LocalDateTime;
@Getter
public class OldSimulationInfoVO extends SimulationInfoVO {
private String prodType;
private MapVO map;
private LocalDateTime createTime;
public OldSimulationInfoVO(Simulation simulation) {
super(simulation);
SimulationBuildParams buildParams = simulation.getBuildParams();
this.prodType = buildParams.getProdType().getCode();
if (buildParams.getProdType() != null) {
this.prodType = buildParams.getProdType().getCode();
}
this.map = buildParams.getMap().buildBasicInfo();
this.createTime = buildParams.getCreateTime();
}
}

View File

@ -0,0 +1,16 @@
package club.joylink.rtss.vo.client.simulationv1;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class SimulationInfoQueryVO {
private String group;
private String userName;
private String prdType;
}