增加用功能参数创建仿真的接口;
This commit is contained in:
parent
8446891ba5
commit
761c7e02eb
@ -0,0 +1,66 @@
|
||||
package club.joylink.rtss.controller.racetr;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 赛题训练接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/race")
|
||||
public class RaceApplicationController {
|
||||
/**
|
||||
* 开始训练
|
||||
*
|
||||
* @param paperId 赛题ID
|
||||
* @return 训练的信息
|
||||
*/
|
||||
@PostMapping("/{paperId}")
|
||||
public Object start(@PathVariable long paperId) {
|
||||
//暂时就用用户id作为竞赛上下文的id,也就是说一个用户同时只能开一个竞赛
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载场景
|
||||
*
|
||||
* @param simulationId 场景依托的仿真
|
||||
* @param sceneId 场景的ID
|
||||
*/
|
||||
@PutMapping("/{simulationId}/{sceneId}/load")
|
||||
public void loadScene(@PathVariable String simulationId, @PathVariable String sceneId) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成任务
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @param record 任务记录(需要前端进行判定的操作的记录)
|
||||
*/
|
||||
@PutMapping("/{taskId}/finish")
|
||||
public void finishTask(@PathVariable long taskId, @RequestBody Object record) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成训练
|
||||
*
|
||||
* @return 评分结果
|
||||
*/
|
||||
public Object finish() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户正在进行的竞赛信息
|
||||
* <p>
|
||||
* 目前想到的使用场景就是页面刷新后
|
||||
*
|
||||
* @return 竞赛信息
|
||||
*/
|
||||
@GetMapping("")
|
||||
public Object getRaceInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -18,6 +18,7 @@ import club.joylink.rtss.simulation.cbtc.data.vo.SimulationVO;
|
||||
import club.joylink.rtss.simulation.cbtc.member.MemberManager;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import club.joylink.rtss.simulation.cbtc.script.ScriptBO;
|
||||
import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO;
|
||||
import club.joylink.rtss.simulation.vo.SimulationInfoVO;
|
||||
import club.joylink.rtss.vo.AccountVO;
|
||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
@ -31,37 +32,22 @@ import club.joylink.rtss.vo.client.operation.DriveParamVO;
|
||||
import club.joylink.rtss.vo.client.psl.PslStatus;
|
||||
import club.joylink.rtss.vo.client.runplan.PlanTripNumberVO;
|
||||
import club.joylink.rtss.vo.client.runplan.RunPlanEChartsDataVO;
|
||||
import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam;
|
||||
import club.joylink.rtss.vo.client.simulationv1.SimulationInfoQueryVO;
|
||||
import club.joylink.rtss.vo.client.simulationv1.SimulationLogPagedQueryVO;
|
||||
import club.joylink.rtss.vo.client.simulationv1.SimulationMemberVO;
|
||||
import club.joylink.rtss.vo.client.simulationv1.SimulationUserVO;
|
||||
import club.joylink.rtss.vo.client.simulationv1.*;
|
||||
import club.joylink.rtss.vo.map.MapVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapStationNewVO;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 新仿真接口
|
||||
@ -515,15 +501,15 @@ public class SimulationV1Controller {
|
||||
/* ----------------------- 仿真新接口 ----------------------- */
|
||||
|
||||
/**
|
||||
* 仿真创建接口(新)
|
||||
* 根据功能配置创建仿真
|
||||
*/
|
||||
/*@Deprecated
|
||||
@Deprecated
|
||||
@PostMapping("/new/{mapId}")
|
||||
public String createSimulation(@PathVariable long mapId, @RequestBody @Validated SimulationWorkParamVO paramVO,
|
||||
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY)
|
||||
LoginUserInfoVO loginUserInfoVO) {
|
||||
return simulationService.createSimulation(mapId, null, paramVO, loginUserInfoVO);
|
||||
}*/
|
||||
return simulationService.createSimulation(mapId, paramVO, loginUserInfoVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据地图功能id创建仿真
|
||||
@ -531,7 +517,7 @@ public class SimulationV1Controller {
|
||||
@PostMapping("/new/mapFunction/{mapFunctionId}")
|
||||
public String createSimulationByMapFunction(@PathVariable long mapFunctionId,
|
||||
@RequestAttribute LoginUserInfoVO loginInfo) {
|
||||
return simulationService.createSimulation(mapFunctionId, loginInfo);
|
||||
return simulationService.createSimulation(mapFunctionId, loginInfo, true).getId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,6 @@
|
||||
package club.joylink.rtss.services.training2;
|
||||
|
||||
import club.joylink.rtss.constants.MapStatus;
|
||||
import club.joylink.rtss.constants.Project;
|
||||
import club.joylink.rtss.controller.advice.AuthenticateInterceptor;
|
||||
import club.joylink.rtss.dao.MapInfoDAO;
|
||||
import club.joylink.rtss.dao.PublishedTraining2DAO;
|
||||
import club.joylink.rtss.dao.RtsMapFunctionDAO;
|
||||
@ -11,36 +9,29 @@ import club.joylink.rtss.entity.MapInfo;
|
||||
import club.joylink.rtss.entity.MapInfoExample;
|
||||
import club.joylink.rtss.entity.RtsMapFunction;
|
||||
import club.joylink.rtss.entity.RtsMapFunctionExample;
|
||||
import club.joylink.rtss.entity.training2.*;
|
||||
import club.joylink.rtss.entity.training2.PublishedTraining2Example;
|
||||
import club.joylink.rtss.entity.training2.PublishedTraining2WithBLOBs;
|
||||
import club.joylink.rtss.entity.training2.RtsTraining2RuleExample;
|
||||
import club.joylink.rtss.entity.training2.RtsTraining2RuleWithBLOBs;
|
||||
import club.joylink.rtss.services.mapFunction.RtsMapFunctionService;
|
||||
import club.joylink.rtss.services.project.ProjectService;
|
||||
import club.joylink.rtss.simulation.SimulationManager;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.SimulationService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Switch;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.vo.client.training2.ScoringRuleVO;
|
||||
import club.joylink.rtss.vo.project.ProjectVO;
|
||||
import club.joylink.rtss.vo.training2.rule.BgSceneStatusRule;
|
||||
import club.joylink.rtss.vo.training2.rule.MapLocationRule;
|
||||
import club.joylink.rtss.vo.training2.rule.StepRule;
|
||||
import club.joylink.rtss.vo.training2.rule.Training2Rule;
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.logging.log4j.util.BiConsumer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -85,7 +76,7 @@ public class Training2RuleService {
|
||||
* @return 生成结果
|
||||
*/
|
||||
public List<String> generateTrainingByRule(String groupId) {
|
||||
Simulation simulation = simulationManager.getById(groupId , Simulation.class);
|
||||
Simulation simulation = simulationManager.getById(groupId, Simulation.class);
|
||||
Long mapId = simulation.getBuildParams().getMap().getId();
|
||||
if (runningMapIdSet.contains(mapId)) {
|
||||
return Arrays.asList("该地图正在生成实训!");
|
||||
@ -131,7 +122,6 @@ public class Training2RuleService {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mapId
|
||||
* @param functionId
|
||||
* @return
|
||||
@ -144,7 +134,7 @@ public class Training2RuleService {
|
||||
/**
|
||||
* 根据地图ID生成实训
|
||||
*/
|
||||
public List<String> generateTrainingByMapId(List<Long> mapIdList, LoginUserInfoVO loginUserInfoVO){
|
||||
public List<String> generateTrainingByMapId(List<Long> mapIdList, LoginUserInfoVO loginUserInfoVO) {
|
||||
// 地图列表
|
||||
MapInfoExample example = new MapInfoExample();
|
||||
MapInfoExample.Criteria criteria = example.createCriteria().andStatusEqualTo(MapStatus.Online.getCode());
|
||||
@ -223,7 +213,7 @@ public class Training2RuleService {
|
||||
List<Map<String, Long>> publishTrainingIdList = publishedTraining2DAO.selectTrainingByRuleId(
|
||||
ruleIdList, mapList.stream().map(MapInfo::getId).collect(Collectors.toList()));
|
||||
Map<Long, List<Long>> publishTrainingIdMap = publishTrainingIdList.stream().collect(
|
||||
Collectors.groupingBy(m -> m.get("mapId"), Collectors.mapping(m -> m.get("id") , Collectors.toList())));
|
||||
Collectors.groupingBy(m -> m.get("mapId"), Collectors.mapping(m -> m.get("id"), Collectors.toList())));
|
||||
|
||||
List<String> errorMsgList = new ArrayList<>();
|
||||
loopMapListGenerateTraining(loginUserInfoVO, mapList, lineCodeRuleMap, errorMsgList, publishTrainingIdMap);
|
||||
@ -246,8 +236,8 @@ public class Training2RuleService {
|
||||
// 获取客户端参数
|
||||
List<RtsMapFunction> entities = getRtsMapFunctions(k);
|
||||
if (!CollectionUtils.isEmpty(entities)) {
|
||||
List<Map<String,String>> ruleNameMapList = ruleList.stream().map(r -> {
|
||||
Map<String,String> map = new HashMap<>();
|
||||
List<Map<String, String>> ruleNameMapList = ruleList.stream().map(r -> {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("ruleName", r.getName());
|
||||
map.put("client", r.getClient());
|
||||
return map;
|
||||
@ -255,7 +245,7 @@ public class Training2RuleService {
|
||||
// 需要删除的列表
|
||||
List<Long> delTrainingIdList = publishedTraining2DAO.selectTrainingIdByRuleNameAndMapId(ruleNameMapList, k);
|
||||
try {
|
||||
Simulation simulation = simulationService.createSimulationPojo(entities.get(0).getId(), loginUserInfoVO, false);
|
||||
Simulation simulation = simulationService.createSimulation(entities.get(0).getId(), loginUserInfoVO, false);
|
||||
errorMsgList.addAll(generateTraining(simulation, ruleList, delTrainingIdList, delPublishTrainingByIds));
|
||||
} catch (Exception e) {
|
||||
log.error("创建仿真失败", e);
|
||||
@ -302,7 +292,7 @@ public class Training2RuleService {
|
||||
List<RtsMapFunction> entities = getRtsMapFunctions(mapInfo.getId());
|
||||
if (!CollectionUtils.isEmpty(entities) && !CollectionUtils.isEmpty(lineCodeRuleMap.get(mapInfo.getLineCode()))) {
|
||||
try {
|
||||
Simulation simulation = simulationService.createSimulationPojo(entities.get(0).getId(), loginUserInfoVO, false);
|
||||
Simulation simulation = simulationService.createSimulation(entities.get(0).getId(), loginUserInfoVO, false);
|
||||
if (CollectionUtils.isEmpty(deleteTrainingIdMap)) {
|
||||
errorMsgList.addAll(generateTraining(simulation, lineCodeRuleMap.get(mapInfo.getLineCode()), null, delPublishTrainingByMapId));
|
||||
} else {
|
||||
@ -318,6 +308,7 @@ public class Training2RuleService {
|
||||
|
||||
/**
|
||||
* 生成实训方法
|
||||
*
|
||||
* @param simulation 对应地图仿真
|
||||
* @param ruleList 生成规则
|
||||
* @param delTrainingIds 要删除已发布的实训ID
|
||||
@ -358,11 +349,11 @@ public class Training2RuleService {
|
||||
publishedTraining2DAO.insertList(training2WithBLOBs);
|
||||
} catch (RuntimeException e) {
|
||||
log.error("实训反序列化失败", e);
|
||||
errorMsgList.add(String.format("地图%d实训[%s]反序列化,实训ID【%d】", mapId, rule.getName(), rule.getId(),Locale.ENGLISH));
|
||||
errorMsgList.add(String.format("地图%d实训[%s]反序列化,实训ID【%d】", mapId, rule.getName(), rule.getId(), Locale.ENGLISH));
|
||||
} catch (Exception e) {
|
||||
log.error("实训生成失败", e);
|
||||
errorMsgList.add(String.format("地图%d实训[%s]生成失败,设备信息【%s】,原因:%s", mapId,
|
||||
rule.getName(), rule.getDeviceRule(),e.getMessage(),Locale.ENGLISH));
|
||||
rule.getName(), rule.getDeviceRule(), e.getMessage(), Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import club.joylink.rtss.simulation.vo.SimulationInfoVO;
|
||||
import club.joylink.rtss.vo.AccountVO;
|
||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.mapFunction.MapFunctionVO;
|
||||
import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam;
|
||||
import club.joylink.rtss.vo.client.simulationv1.SimulationInfoQueryVO;
|
||||
import lombok.NonNull;
|
||||
@ -18,9 +17,7 @@ public interface SimulationService {
|
||||
/**
|
||||
* 创建仿真
|
||||
*/
|
||||
String createSimulation(long mapId, MapFunctionVO mapFunctionVO, @NonNull LoginUserInfoVO loginUserInfoVO, Map<String, Boolean> createUserType);
|
||||
|
||||
String createSimulation(Long mapFunctionId, LoginUserInfoVO loginInfo);
|
||||
String createSimulation(long mapId, SimulationWorkParamVO workParamVO, @NonNull LoginUserInfoVO loginUserInfoVO);
|
||||
|
||||
/**
|
||||
* 给仿真添加功能
|
||||
@ -44,6 +41,7 @@ public interface SimulationService {
|
||||
|
||||
/**
|
||||
* 根据地图和功能ID获取仿真GroupId
|
||||
*
|
||||
* @param mapId 地图ID
|
||||
* @param mapFunctionId 功能ID
|
||||
* @return 仿真GroupId
|
||||
@ -53,6 +51,7 @@ public interface SimulationService {
|
||||
|
||||
/**
|
||||
* 根据地图和功能ID获取仿真GroupId返回仿真对象
|
||||
*
|
||||
* @param mapId 地图ID
|
||||
* @param mapFunctionId 功能ID
|
||||
* @return 仿真GroupId
|
||||
@ -64,8 +63,6 @@ public interface SimulationService {
|
||||
*/
|
||||
void monitor(String simulationId, AccountVO user);
|
||||
|
||||
Simulation createSimulationPojo(long mapId, MapFunctionVO mapFunctionVO, @NonNull LoginUserInfoVO loginUserInfoVO, Map<String, Boolean> createUserType);
|
||||
|
||||
/**
|
||||
* 后台创建仿真
|
||||
*
|
||||
@ -74,7 +71,7 @@ public interface SimulationService {
|
||||
* @param checkAuth 是否检查权限
|
||||
* @return 仿真对象
|
||||
*/
|
||||
Simulation createSimulationPojo(Long mapFunctionId, LoginUserInfoVO loginInfo, boolean checkAuth);
|
||||
Simulation createSimulation(Long mapFunctionId, LoginUserInfoVO loginInfo, boolean checkAuth);
|
||||
|
||||
void loadDraftRunPlan(String simulationId, long draftRunPlanId);
|
||||
|
||||
|
@ -80,19 +80,20 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
|
||||
|
||||
@Override
|
||||
public String createSimulation(long mapId, MapFunctionVO mapFunctionVO, @NonNull LoginUserInfoVO loginUserInfoVO, Map<String, Boolean> createUserType) {
|
||||
return createSimulationPojo(mapId,mapFunctionVO, loginUserInfoVO, createUserType).getId();
|
||||
public String createSimulation(long mapId, SimulationWorkParamVO workParamVO, @NonNull LoginUserInfoVO loginUserInfoVO) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(workParamVO.containsRealDeviceItem(), "此途径创建的仿真不能连接真实设备");
|
||||
return createSimulation(mapId, null, workParamVO, loginUserInfoVO, null).getId();
|
||||
}
|
||||
|
||||
//只获取所有与该功能相关的权限信息
|
||||
private List<PermissionSubjectVO> filterUserPermission(List<PermissionSubjectVO> subjectVOList, MapFunctionVO functionVO, LoginUserInfoVO loginUserInfoVO){
|
||||
private List<PermissionSubjectVO> filterUserPermission(List<PermissionSubjectVO> subjectVOList, MapFunctionVO functionVO, LoginUserInfoVO loginUserInfoVO) {
|
||||
List<PermissionSubjectVO> newVoList = Lists.newArrayList();
|
||||
for (PermissionSubjectVO subjectVO : subjectVOList) {
|
||||
if(subjectVO.getStartTime().isAfter(LocalDateTime.now())){
|
||||
log.info("权限主体id:[{}] 用户id:[{}] 开始时间:[{}]未到时间",subjectVO.getId(),subjectVO.getSubjectId(),subjectVO.getStartTime());
|
||||
if (subjectVO.getStartTime().isAfter(LocalDateTime.now())) {
|
||||
log.info("权限主体id:[{}] 用户id:[{}] 开始时间:[{}]未到时间", subjectVO.getId(), subjectVO.getSubjectId(), subjectVO.getStartTime());
|
||||
continue;
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(subjectVO.getSystemAbilityList())){
|
||||
if (!CollectionUtils.isEmpty(subjectVO.getSystemAbilityList())) {
|
||||
/* if(Objects.equals(PermissionTypeEnum.PROJECT.getValue(),subjectVO.getPermissionType())){
|
||||
if(Objects.equals(subjectVO.getPermissionProjectCode(),loginUserInfoVO.getProject().toLowerCase())){
|
||||
newVoList.add(subjectVO);
|
||||
@ -104,14 +105,14 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
}
|
||||
}else{*/
|
||||
for (PermissionSystemAbilityVO permissionSystemAbilityVO : subjectVO.getSystemAbilityList()) {
|
||||
if(Objects.equals(permissionSystemAbilityVO.getAbilityId(), functionVO.getId())) {
|
||||
if (Objects.equals(permissionSystemAbilityVO.getAbilityId(), functionVO.getId())) {
|
||||
newVoList.add(subjectVO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// }
|
||||
}else {
|
||||
log.error("权限主体对应的功能是空 主体id:[{}],subjectId:[{}],subjectType:[{}]",subjectVO.getId(),subjectVO.getSubjectId(),subjectVO.getSubjectType());
|
||||
} else {
|
||||
log.error("权限主体对应的功能是空 主体id:[{}],subjectId:[{}],subjectType:[{}]", subjectVO.getId(), subjectVO.getSubjectId(), subjectVO.getSubjectType());
|
||||
}
|
||||
}
|
||||
return newVoList;
|
||||
@ -119,122 +120,71 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
|
||||
/**
|
||||
* 检测用户对应的权限是否满足
|
||||
*
|
||||
* @param functionVO
|
||||
* @param loginInfo
|
||||
|
||||
*/
|
||||
private Map<String,Boolean> checkUserPermission(MapFunctionVO functionVO, LoginUserInfoVO loginInfo){
|
||||
if(loginInfo.getAccountVO().isAdmin()){
|
||||
private Map<String, Boolean> checkUserPermission(MapFunctionVO functionVO, LoginUserInfoVO loginInfo) {
|
||||
if (loginInfo.getAccountVO().isAdmin()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
LoginUserInfoVO newLoginUser = loginInfo;
|
||||
if(loginInfo.getAccountVO().isThirdChildAccount()){
|
||||
if (loginInfo.getAccountVO().isThirdChildAccount()) {
|
||||
AccountVO user = this.iSysUserService.queryUserByAccountForMaster(loginInfo.getAccountVO().getParentAccount());
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(user),"未找到主账号相关权限");
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(user), "未找到主账号相关权限");
|
||||
newLoginUser = new LoginUserInfoVO();
|
||||
user.setCompanyId(loginInfo.getAccountVO().getCompanyId());
|
||||
newLoginUser.setAccountVO(user);
|
||||
newLoginUser.setProjectInfo(loginInfo.getProjectInfo());
|
||||
}
|
||||
|
||||
List<PermissionSubjectVO> subjectVOList = this.subjectService.findPermissionWithMapIdAndUserInfo(functionVO.getMapId(),newLoginUser);
|
||||
List<PermissionSubjectVO> subjectVOList = this.subjectService.findPermissionWithMapIdAndUserInfo(functionVO.getMapId(), newLoginUser);
|
||||
|
||||
List<PermissionSubjectVO> newVOLIst = this.filterUserPermission(subjectVOList,functionVO,newLoginUser);
|
||||
if(CollectionUtils.isEmpty(newVOLIst)){
|
||||
log.error("未找到对应的权限数据mapId[{}],functionId[{}],userId[{}]",functionVO.getMapId(),functionVO.getId(),newLoginUser.getAccountVO().getId());
|
||||
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertNotTrue(true,"未找到该权限");
|
||||
List<PermissionSubjectVO> newVOLIst = this.filterUserPermission(subjectVOList, functionVO, newLoginUser);
|
||||
if (CollectionUtils.isEmpty(newVOLIst)) {
|
||||
log.error("未找到对应的权限数据mapId[{}],functionId[{}],userId[{}]", functionVO.getMapId(), functionVO.getId(), newLoginUser.getAccountVO().getId());
|
||||
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertNotTrue(true, "未找到该权限");
|
||||
}
|
||||
Map<String,Boolean> resultMap2 = Maps.newHashMap();
|
||||
Map<String,List<PermissionSubjectVO>> subjectMapList = newVOLIst.stream().collect(Collectors.groupingBy(PermissionSubjectVO::getSubjectType));
|
||||
Map<String, Boolean> resultMap2 = Maps.newHashMap();
|
||||
Map<String, List<PermissionSubjectVO>> subjectMapList = newVOLIst.stream().collect(Collectors.groupingBy(PermissionSubjectVO::getSubjectType));
|
||||
for (PermissionSubjectTypeEnum st : PermissionSubjectTypeEnum.SORT_ENUM) {
|
||||
List<PermissionSubjectVO> tmpSubjectVOList = subjectMapList.get(st.name());
|
||||
if(CollectionUtils.isEmpty(tmpSubjectVOList)){
|
||||
if (CollectionUtils.isEmpty(tmpSubjectVOList)) {
|
||||
continue;
|
||||
}
|
||||
List<PermissionSubjectVO> canUseSubjectList = this.findCanUsedPermission(tmpSubjectVOList,functionVO,loginInfo);
|
||||
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertNotTrue(CollectionUtils.isEmpty(canUseSubjectList),"该权限过期");
|
||||
List<PermissionSubjectVO> canUseSubjectList = this.findCanUsedPermission(tmpSubjectVOList, functionVO, loginInfo);
|
||||
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertNotTrue(CollectionUtils.isEmpty(canUseSubjectList), "该权限过期");
|
||||
for (PermissionSubjectVO subjectVO : canUseSubjectList) {
|
||||
String key = String.format("%s-%s",st.name(),subjectVO.getId());
|
||||
String key = String.format("%s-%s", st.name(), subjectVO.getId());
|
||||
List<Simulation> findSimList = this.simulationManager.finder(key);
|
||||
resultMap2.put(key,false);
|
||||
if(findSimList.size() +1 <= subjectVO.getAmount()){
|
||||
resultMap2.put(key,true);
|
||||
resultMap2.put(key, false);
|
||||
if (findSimList.size() + 1 <= subjectVO.getAmount()) {
|
||||
resultMap2.put(key, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(resultMap2.values().stream().anyMatch(d->Objects.equals(true,d))){
|
||||
if (resultMap2.values().stream().anyMatch(d -> Objects.equals(true, d))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertNotTrue(resultMap2.values().stream().allMatch(d->Objects.equals(false,d)),"仿真生成数量过载");
|
||||
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertNotTrue(resultMap2.values().stream().allMatch(d -> Objects.equals(false, d)), "仿真生成数量过载");
|
||||
return resultMap2;
|
||||
}
|
||||
|
||||
private List<PermissionSubjectVO> findCanUsedPermission(List<PermissionSubjectVO> newVOLIst, MapFunctionVO functionVO, LoginUserInfoVO loginInfo){
|
||||
List<PermissionSubjectVO> canUseSubjectList = newVOLIst.stream().filter(d->Objects.equals(true,d.getForever())).collect(Collectors.toList());
|
||||
if(CollectionUtils.isEmpty(canUseSubjectList)){
|
||||
List<Long> timeOverIdList = newVOLIst.stream().filter(d->Objects.nonNull(d.getEndTime()) && d.getEndTime().isAfter(LocalDateTime.now()))
|
||||
.map(d->d.getId())
|
||||
private List<PermissionSubjectVO> findCanUsedPermission(List<PermissionSubjectVO> newVOLIst, MapFunctionVO functionVO, LoginUserInfoVO loginInfo) {
|
||||
List<PermissionSubjectVO> canUseSubjectList = newVOLIst.stream().filter(d -> Objects.equals(true, d.getForever())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(canUseSubjectList)) {
|
||||
List<Long> timeOverIdList = newVOLIst.stream().filter(d -> Objects.nonNull(d.getEndTime()) && d.getEndTime().isAfter(LocalDateTime.now()))
|
||||
.map(d -> d.getId())
|
||||
.collect(Collectors.toList());
|
||||
if(CollectionUtils.isEmpty(timeOverIdList)){
|
||||
log.error("mapId[{}],functionId[{}] userId[{}] 权限过期",functionVO.getMapId(),functionVO.getId(),loginInfo.getAccountVO().getId());
|
||||
if (CollectionUtils.isEmpty(timeOverIdList)) {
|
||||
log.error("mapId[{}],functionId[{}] userId[{}] 权限过期", functionVO.getMapId(), functionVO.getId(), loginInfo.getAccountVO().getId());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
canUseSubjectList = newVOLIst.stream().filter(d->timeOverIdList.contains(d.getId())).collect(Collectors.toList());
|
||||
canUseSubjectList = newVOLIst.stream().filter(d -> timeOverIdList.contains(d.getId())).collect(Collectors.toList());
|
||||
}
|
||||
return canUseSubjectList;
|
||||
}
|
||||
private boolean checkUserPermissionDetail(List<PermissionSubjectVO> newVOLIst, MapFunctionVO functionVO, LoginUserInfoVO loginInfo){
|
||||
boolean isForever = newVOLIst.stream().anyMatch(d->Objects.equals(true,d.getForever()));
|
||||
if(Objects.equals(false,isForever)){
|
||||
boolean timeOver = newVOLIst.stream().allMatch(d->Objects.nonNull(d.getEndTime()) && d.getEndTime().isBefore(LocalDateTime.now()));
|
||||
if(timeOver){
|
||||
log.error("mapId[{}],functionId[{}] userId[{}] 权限过期",functionVO.getMapId(),functionVO.getId(),loginInfo.getAccountVO().getId());
|
||||
// BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertNotTrue(timeOver,"该权限过期");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String checkUserExistSimulation(MapFunctionVO mapFunctionVO, AccountVO user){
|
||||
List<String> userExistGroup = this.groupSimulationService.getUserRunningSimulationGroups(user);
|
||||
if(!CollectionUtils.isEmpty(userExistGroup)){
|
||||
Optional<Simulation> optional = userExistGroup.stream()
|
||||
.map(d->this.groupSimulationService.getSimulationByGroup(d))
|
||||
.filter(d->Objects.equals(d.getMapFunctionId(), mapFunctionVO.getId())).findAny();
|
||||
if(optional.isPresent()){
|
||||
BusinessExceptionAssertEnum.OPERATION_REPEAT.assertNotTrue(mapFunctionVO.getParamVO().getDomConfig().isHasExam(),"考试只能单独用户操作");
|
||||
Simulation simulation = optional.get();
|
||||
return simulation.getId();
|
||||
}
|
||||
BusinessExceptionAssertEnum.OPERATION_REPEAT.assertNotTrue(userExistGroup.size() >= 1,"用户重复创建仿真");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public String createSimulation(Long mapFunctionId, LoginUserInfoVO loginInfo) {
|
||||
MapFunctionVO mapFunctionVO = rtsMapFunctionService.get(mapFunctionId);
|
||||
/* String group = this.checkUserExistSimulation(mapFunctionVO,loginInfo.getAccountVO());
|
||||
if(StringUtils.isNotEmpty(group)){
|
||||
return group;
|
||||
}*/
|
||||
Long mapId = mapFunctionVO.getMapId();
|
||||
Map<String,Boolean> createUserType = this.checkUserPermission(mapFunctionVO,loginInfo);
|
||||
SimulationWorkParamVO workParamVO = mapFunctionVO.getParamVO();
|
||||
|
||||
if (workParamVO.containsRealDeviceItem()) {
|
||||
//有实体设备加载项的地图功能(实训室)同时只能存在一个
|
||||
Stream<Simulation> stream = simulationManager.getSimulationStream(Simulation.class);
|
||||
Optional<Simulation> oldSimulationOptional = stream
|
||||
.filter(sim -> Objects.equals(sim.getMapFunctionId(), mapFunctionId))
|
||||
.findFirst();
|
||||
oldSimulationOptional.ifPresent(simulation -> simulationManager.destroy(simulation.getId()));
|
||||
}
|
||||
|
||||
return createSimulation(mapId, mapFunctionVO, loginInfo,createUserType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItems(@NonNull String simulationId, Map<SimulationWorkParamVO.Item, String> itemMap) {
|
||||
@ -316,9 +266,8 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
simulationWorkServiceManager.addSimulationUser(simulation, simulationUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Simulation createSimulationPojo(long mapId, MapFunctionVO mapFunctionVO, @NonNull LoginUserInfoVO loginUserInfoVO, Map<String, Boolean> createUserType) {
|
||||
SimulationWorkParamVO workParamVO = mapFunctionVO.getParamVO();
|
||||
private Simulation createSimulation(long mapId, MapFunctionVO mapFunctionVO, @NonNull SimulationWorkParamVO workParamVO,
|
||||
@NonNull LoginUserInfoVO loginUserInfoVO, Map<String, Boolean> createUserType) {
|
||||
//获取仿真工作服务
|
||||
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(workParamVO.getType());
|
||||
|
||||
@ -359,12 +308,12 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Simulation createSimulationPojo(Long mapFunctionId, LoginUserInfoVO loginInfo, boolean checkAuth) {
|
||||
public Simulation createSimulation(Long mapFunctionId, LoginUserInfoVO loginInfo, boolean checkAuth) {
|
||||
MapFunctionVO mapFunctionVO = rtsMapFunctionService.get(mapFunctionId);
|
||||
Long mapId = mapFunctionVO.getMapId();
|
||||
Map<String,Boolean> createUserType = Maps.newHashMap();
|
||||
Map<String, Boolean> createUserType = Maps.newHashMap();
|
||||
if (checkAuth) {
|
||||
createUserType = this.checkUserPermission(mapFunctionVO,loginInfo);
|
||||
createUserType = this.checkUserPermission(mapFunctionVO, loginInfo);
|
||||
}
|
||||
SimulationWorkParamVO workParamVO = mapFunctionVO.getParamVO();
|
||||
|
||||
@ -377,7 +326,7 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
oldSimulationOptional.ifPresent(simulation -> simulationManager.destroy(simulation.getId()));
|
||||
}
|
||||
|
||||
return createSimulationPojo(mapId, mapFunctionVO, loginInfo, createUserType);
|
||||
return createSimulation(mapId, mapFunctionVO, mapFunctionVO.getParamVO(), loginInfo, createUserType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user