增加查询“我”加入的仿真接口

This commit is contained in:
joylink_zhangsai 2023-05-06 18:11:54 +08:00
parent c77ef0b669
commit 65eef78e42
3 changed files with 23 additions and 4 deletions

View File

@ -614,4 +614,12 @@ public class SimulationV1Controller {
public void monitor(@PathVariable String simulationId, @RequestAttribute AccountVO user) {
simulationService.monitor(simulationId, user);
}
/**
* 查询""已加入的仿真
*/
@GetMapping("/joined/by/me")
public SimulationVO querySimulationJoinedByMe(@RequestAttribute LoginUserInfoVO loginInfo) {
return simulationService.querySimulationJoinedByUser(loginInfo.getAccountVO().getId());
}
}

View File

@ -1,10 +1,10 @@
package club.joylink.rtss.simulation.cbtc;
import club.joylink.rtss.simulation.cbtc.data.vo.SimulationVO;
import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam;
import club.joylink.rtss.vo.permission.PermissionSubjectTypeEnum;
import lombok.NonNull;
import java.util.List;
@ -73,4 +73,6 @@ public interface SimulationService {
Simulation createSimulationPojo(Long mapFunctionId, LoginUserInfoVO loginInfo, boolean checkAuth);
void loadDraftRunPlan(String simulationId, long draftRunPlanId);
SimulationVO querySimulationJoinedByUser(long userId);
}

View File

@ -6,6 +6,7 @@ import club.joylink.rtss.services.RunPlanDraftService;
import club.joylink.rtss.services.mapFunction.RtsMapFunctionService;
import club.joylink.rtss.services.permission.PermissionSubjectService;
import club.joylink.rtss.simulation.SimulationManager;
import club.joylink.rtss.simulation.cbtc.data.vo.SimulationVO;
import club.joylink.rtss.simulation.cbtc.discriminate.IVoiceDiscriminateRule;
import club.joylink.rtss.simulation.cbtc.discriminate.VoiceDiscriminateRule;
import club.joylink.rtss.simulation.cbtc.event.SimulationCreateSuccessEvent;
@ -212,8 +213,8 @@ public class SimulationServiceImpl implements SimulationService {
}
@Override
public void addItems(@NonNull String simulationId, Map<SimulationWorkParamVO.Item, String> functionInfoMap) {
if (!CollectionUtils.isEmpty(functionInfoMap)) {
public void addItems(@NonNull String simulationId, Map<SimulationWorkParamVO.Item, String> itemMap) {
if (!CollectionUtils.isEmpty(itemMap)) {
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
Simulation.Type simulationType = simulation.getType();
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(simulationType);
@ -221,7 +222,7 @@ public class SimulationServiceImpl implements SimulationService {
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertEquals(loginInfo.getAccountVO().getIdStr(), simulation.getCreatorId(),
// "非仿真创建者不能使用该功能");
// }
initService.addItems(simulation, functionInfoMap);
initService.addItems(simulation, itemMap);
SocketMessageVO<SimulationWorkParamVO> workParamMessage = SocketMessageFactory
.buildSimulationWorkParamMessage(simulationId, simulation.getBuildParams().getWorkParamVO());
Set<String> users = simulation.getSimulationUserIds();
@ -366,4 +367,12 @@ public class SimulationServiceImpl implements SimulationService {
this.simulationLifeCycleService.reloadRunPlan(simulation, runPlanVO, null);
simulation.getRepository().clearChangeTrips(); //清除掉之前的车次计划变化信息
}
@Override
public SimulationVO querySimulationJoinedByUser(long userId) {
Optional<club.joylink.rtss.simulation.Simulation> optional = simulationManager.getSimulationStream()
.filter(simulation -> simulation.querySimulationUserById(String.valueOf(userId)) != null)
.findFirst();
return optional.map(simulation -> groupSimulationService.getSimulationBasicInfo(simulation.getId())).orElse(null);
}
}