监管仿真接口

This commit is contained in:
tiger_zhou 2022-10-11 09:18:14 +08:00
parent 3bf5996bee
commit 1e379c7e93

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.SimulationInfoVO;
import club.joylink.rtss.simulation.vo.SimulationMemberVO; import club.joylink.rtss.simulation.vo.SimulationMemberVO;
import club.joylink.rtss.simulation.vo.SimulationUserVO; import club.joylink.rtss.simulation.vo.SimulationUserVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.simulationv1.SimulationInfoQueryVO; import club.joylink.rtss.vo.client.simulationv1.SimulationInfoQueryVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -13,9 +14,12 @@ import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static club.joylink.rtss.controller.advice.AuthenticateInterceptor.LOGIN_INFO_KEY;
/** /**
* 仿真通用接口 * 仿真通用接口
*/ */
@ -28,6 +32,33 @@ public class SimulationCommonController {
@Autowired @Autowired
private SimulationOperationDispatcher simulationOperationDispatcher; private SimulationOperationDispatcher simulationOperationDispatcher;
/**
* 监管仿真
* @param loginUserInfoVO
* @param queryVO
* @return
*/
@GetMapping("/supervise")
public List<SimulationInfoVO> superviseSimulation(@RequestAttribute(name=LOGIN_INFO_KEY) LoginUserInfoVO loginUserInfoVO, SimulationInfoQueryVO queryVO) {
List<Simulation> simulationList = this.simulationManager.getSimulationList();
Stream<Simulation> stream = simulationList.stream();
stream = stream.filter(simulation -> simulation instanceof club.joylink.rtss.simulation.cbtc.Simulation
&& Objects.equals(loginUserInfoVO.getTopOrgId(),((club.joylink.rtss.simulation.cbtc.Simulation)simulation).getBuildParams().getLoginUserInfo().getTopOrgId()));
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());
}
@GetMapping("/list") @GetMapping("/list")
public List<SimulationInfoVO> queryInfo(SimulationInfoQueryVO queryVO) { public List<SimulationInfoVO> queryInfo(SimulationInfoQueryVO queryVO) {
List<Simulation> simulationList = this.simulationManager.getSimulationList(); List<Simulation> simulationList = this.simulationManager.getSimulationList();