一个用户同时只能存在一个仿真

This commit is contained in:
tiger_zhou 2023-05-08 11:03:31 +08:00
parent 877372b2cd
commit fdf503261e

View File

@ -32,6 +32,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import lombok.NonNull; import lombok.NonNull;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -193,24 +194,29 @@ public class SimulationServiceImpl implements SimulationService {
return true; return true;
} }
private String checkSameSimulation(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 @Override
public String createSimulation(Long mapFunctionId, LoginUserInfoVO loginInfo) { public String createSimulation(Long mapFunctionId, LoginUserInfoVO loginInfo) {
MapFunctionVO mapFunctionVO = rtsMapFunctionService.get(mapFunctionId); MapFunctionVO mapFunctionVO = rtsMapFunctionService.get(mapFunctionId);
// List<String> userExistGroup = this.groupSimulationService.getUserRunningSimulationGroups(loginInfo.getAccountVO()); String group = this.checkSameSimulation(mapFunctionVO,loginInfo.getAccountVO());
// if(!CollectionUtils.isEmpty(userExistGroup)){ if(StringUtils.isNotEmpty(group)){
// String group = userExistGroup.get(0); return group;
// Simulation simulation = this.groupSimulationService.getSimulationByGroup(group); }
// if(Objects.equals(simulation.getMapFunctionId(), mapFunctionId)){
// BusinessExceptionAssertEnum.OPERATION_REPEAT.assertNotTrue(mapFunctionVO.getParamVO().getDomConfig().isHasExam(),"考试只能单独用户操作");
// return group;
// }else{
// BusinessExceptionAssertEnum.OPERATION_REPEAT.assertNotTrue(!CollectionUtils.isEmpty(userExistGroup),"用户重复创建仿真");
// }
// }
Long mapId = mapFunctionVO.getMapId(); Long mapId = mapFunctionVO.getMapId();
Map<String,Boolean> createUserType = this.checkUserPermission(mapFunctionVO,loginInfo); Map<String,Boolean> createUserType = this.checkUserPermission(mapFunctionVO,loginInfo);
SimulationWorkParamVO workParamVO = mapFunctionVO.getParamVO(); SimulationWorkParamVO workParamVO = mapFunctionVO.getParamVO();