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

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 lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
@ -193,24 +194,29 @@ public class SimulationServiceImpl implements SimulationService {
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
public String createSimulation(Long mapFunctionId, LoginUserInfoVO loginInfo) {
MapFunctionVO mapFunctionVO = rtsMapFunctionService.get(mapFunctionId);
// List<String> userExistGroup = this.groupSimulationService.getUserRunningSimulationGroups(loginInfo.getAccountVO());
// if(!CollectionUtils.isEmpty(userExistGroup)){
// String group = userExistGroup.get(0);
// 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),"用户重复创建仿真");
// }
// }
String group = this.checkSameSimulation(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();