实训修改,教学成绩导出学号修改

This commit is contained in:
DU 2021-03-01 19:09:24 +08:00
parent e3a44e76f4
commit 09298761bf
10 changed files with 125 additions and 20 deletions

View File

@ -185,7 +185,7 @@ public interface GeneratorNew {
* @param string
* @return
*/
private boolean containPlaceholder(String string) {
default boolean containPlaceholder(String string) {
if (StringUtils.hasText(string)) {
return Pattern.matches(".*\\{\\d+}.*", string);
}
@ -200,7 +200,7 @@ public interface GeneratorNew {
* @param mapDevice
* @return
*/
private String replacePlaceholder(String str, Map<String, OperatePlaceholderVO> placeholderVOMap, MapElement mapDevice, Object mapButton, MapVO map) {
default String replacePlaceholder(String str, Map<String, OperatePlaceholderVO> placeholderVOMap, MapElement mapDevice, Object mapButton, MapVO map) {
Pattern pattern = Pattern.compile(".*?(\\{(\\d+)}).*?");
Matcher matcher = pattern.matcher(str);
while (matcher.find()) {

View File

@ -1,35 +1,89 @@
package club.joylink.rtss.services.training.generatornew.base;
import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.services.training.constant.TrainingConsts;
import club.joylink.rtss.services.training.data.GenerateConfig;
import club.joylink.rtss.services.training.generatornew.GeneratorNew;
import club.joylink.rtss.services.training.generatornew.annotation.GeneratorSelectorNew;
import club.joylink.rtss.simulation.cbtc.ATP.ground.TempSpeedLimitService;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.simulation.cbtc.data.storage.StorageSimulation;
import club.joylink.rtss.vo.client.map.MapTempSpeedLimitVO;
import club.joylink.rtss.vo.client.map.newmap.MapAutomaticRouteButtonVO;
import club.joylink.rtss.vo.client.map.newmap.MapCycleButtonVO;
import club.joylink.rtss.vo.client.map.newmap.MapTotalGuideLockButtonVO;
import club.joylink.rtss.vo.client.map.newmap.MapTurnBackStrategyVO;
import club.joylink.rtss.vo.client.training.TrainingStepVO;
import club.joylink.rtss.vo.client.training.definition.OperateDefinitionVO;
import club.joylink.rtss.vo.client.training.TrainingNewVO;
import club.joylink.rtss.vo.client.training.definition.OperatePlaceholderVO;
import club.joylink.rtss.vo.client.training.definition.OperateStepVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@GeneratorSelectorNew(operateObject = Operation.Object.WholeLineTempSpeedLimit)
@GeneratorSelectorNew(operateObject = Operation.Object.LimitControl)
public class SpeedLimitGeneratorNew implements GeneratorNew {
private final static int LIMIT_SPEED = 30;
@Autowired
private TempSpeedLimitService tempSpeedLimitService;
@Override
public List<TrainingNewVO> generate(GenerateConfig config, Simulation simulation, OperateDefinitionVO operateDefinitionVO) {
List<TrainingNewVO> trainingVOList = new ArrayList<>();
//TODO
// simulation.getRepository().getSectionList()
// tempLimitSpeedList.forEach(tempLimitSpeed -> {
// switch (Operation.Type.valueOf (operateDefinitionVO.getOperateType())) {
// case Cancel_Whole_Line_Temp_Speed_Limit: // 取消全线临时限速
// trainingVOList.add(cancelWholeLineTempSpeedLimit(tempLimitSpeed, config, simulation, operateDefinitionVO));
// break;
// }
// });
simulation.getRepository().getSectionList().forEach(section -> tempSpeedLimitService.setSectionLimitSpeed(simulation, section, LIMIT_SPEED));
switch (Operation.Type.valueOf(operateDefinitionVO.getOperateType())) {
case Cancel_All_Limit_Speed: // 取消全线临时限速
List<MapTempSpeedLimitVO> tempSpeedLimitList = simulation.getBuildParams().getMap().getGraphDataNew().getTempSpeedLimitList();
tempSpeedLimitList.forEach(mapTempSpeedLimitVO -> {
trainingVOList.add(this.build(config, simulation,null,mapTempSpeedLimitVO, operateDefinitionVO));
simulation.reset();
});
break;
}
return trainingVOList;
}
@Override
public TrainingNewVO build(GenerateConfig config, Simulation simulation, MapElement nullableDevice, Object mapButton, OperateDefinitionVO operateDefinitionVO) {
// 实训基本信息
TrainingNewVO trainingVO = new TrainingNewVO(config, operateDefinitionVO);
// 设置每一步操作的设备
List<OperateStepVO> stepList = operateDefinitionVO.getStepVOList();
stepList.get(0).setDeviceCode(((MapTempSpeedLimitVO) mapButton).getCode());
Map<String, OperatePlaceholderVO> placeholderVOMap = operateDefinitionVO.getPlaceholderVOMap();
// 设置定位
trainingVO.setLocateDeviceCode(((MapTempSpeedLimitVO) mapButton).getCode());
// 替换占位符
if (containPlaceholder(trainingVO.getName())) {
trainingVO.setName(replacePlaceholder(trainingVO.getName(), placeholderVOMap, nullableDevice, mapButton, simulation.getBuildParams().getMap()));
}
if (containPlaceholder(trainingVO.getRemarks())) {
trainingVO.setRemarks(replacePlaceholder(trainingVO.getRemarks(), placeholderVOMap, nullableDevice, mapButton, simulation.getBuildParams().getMap()));
}
// 添加步骤
List<TrainingStepVO> steps = new ArrayList<>(stepList.size());
stepList.forEach(operateStepVO -> {
TrainingStepVO stepVO = new TrainingStepVO(operateStepVO);
if (containPlaceholder(stepVO.getTip())) {
stepVO.setTip(replacePlaceholder(stepVO.getTip(), placeholderVOMap, nullableDevice, mapButton, simulation.getBuildParams().getMap()));
}
if (containPlaceholder(stepVO.getVal())) {
stepVO.setVal(replacePlaceholder(stepVO.getVal(), placeholderVOMap, nullableDevice, mapButton, simulation.getBuildParams().getMap()));
}
steps.add(stepVO);
});
trainingVO.setSteps(steps);
trainingVO.setScenes(new StorageSimulation(simulation, false));
return trainingVO;
}
}

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.services.training.generatornew.base;
import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.services.training.data.GenerateConfig;
import club.joylink.rtss.services.training.generatornew.GeneratorNew;
import club.joylink.rtss.services.training.generatornew.annotation.GeneratorSelectorNew;
@ -76,7 +77,8 @@ public class StationGeneratorNew implements GeneratorNew {
}
break;
case Station_CIArea_Close_AllSignal:
station.setControlMode(Station.ControlMode.Center);
if(!station.isInterlock())continue;
station.getDeviceStation().setControlMode(Station.ControlMode.Center);
// simulation.getRepository().getSignalList().stream()
// .filter(s -> Objects.equals(station.getCode(), s.getInterlockStation().getCode()))
// .forEach(signal -> {
@ -86,7 +88,13 @@ public class StationGeneratorNew implements GeneratorNew {
// });
break;
case Station_Close_AllSignal:
station.setControlMode(Station.ControlMode.Local);
if (BusinessConsts.MapPrd.PrdType.Type01.equals(config.getPrdType())) {
if(station.isCentralized()) {
station.setControlMode(Station.ControlMode.Local);
}else{
station.getDeviceStation().setControlMode(Station.ControlMode.Local);
}
}
// simulation.getRepository().getSignalList().stream()
// .filter(s -> Objects.equals(station.getCode(), s.getDeviceStation().getCode()))
// .forEach(signal -> {
@ -99,7 +107,7 @@ public class StationGeneratorNew implements GeneratorNew {
if(!station.isTurnBack()) {
continue;
}
station.setControlMode(Station.ControlMode.Center);
station.getDeviceStation().setControlMode(Station.ControlMode.Center);
if(operateDefinitionVO.turnBackStrategyButton()){
simulation.getBuildParams().getMap().getGraphDataNew().getTbStrategyList()
.stream().filter(turnBackStrategyO -> turnBackStrategyO.getStationCode().equals(station.getCode()))
@ -115,7 +123,7 @@ public class StationGeneratorNew implements GeneratorNew {
continue;
}
station.setControlMode(Station.ControlMode.Local);
station.setRestartTime(LocalTime.now());
station.setRestartTime(LocalTime.of(2,0));
List<Section> sections = simulation.getRepository().getSectionList();
sections.stream().filter(section -> Objects.equals(section.getDeviceStation(), station)).forEach(section -> section.setFaultLock(true));
break;
@ -203,6 +211,16 @@ public class StationGeneratorNew implements GeneratorNew {
});
}
continue;
case Station_Set_Or_Cancel_Force_Physical_Signal:
if(!station.isInterlock())continue;
if (BusinessConsts.MapPrd.PrdType.Type01.equals(config.getPrdType())) {
if(station.isCentralized()) {
station.setControlMode(Station.ControlMode.Local);
}else{
station.getDeviceStation().setControlMode(Station.ControlMode.Local);
}
}
break;
default:
// 其他操作不生成
continue;

View File

@ -395,7 +395,7 @@ public class Operation {
/** 集中站 */
Station,
/**全线临时限速*/
WholeLineTempSpeedLimit
LimitControl
}

View File

@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Objects;
@Slf4j
@OperateHandler
@ -170,7 +171,10 @@ public class StandOperateHandler {
* 区间列车数量限制
*/
@OperateHandlerMapping(type = Operation.Type.Stand_Set_Hold_Train_Auto)
public void setHoldTrainAuto(Simulation simulation, String standCode, int limit) {
public void setHoldTrainAuto(Simulation simulation, String standCode, Integer limit) {
if (Objects.isNull(limit)) {
limit = 0;
}
atsStandService.setAutoHoldTrainLimit(simulation, standCode, limit);
}

View File

@ -179,7 +179,7 @@ public class StationOperateHandler {
@OperateHandlerMapping(type = Operation.Type.Station_Close_AllSignal)
public void closeAllSignal(Simulation simulation, String stationCode){
SimulationDataRepository repository = simulation.getRepository();
repository.getSignalList().stream().filter(s -> Objects.equals(stationCode,s.getDeviceStation().getCode())).forEach(signal -> ciApiService.blockadeSignal(simulation, signal.getCode()));
repository.getSignalList().stream().filter(s -> Objects.equals(stationCode,s.getStation().getCode())).forEach(signal -> ciApiService.blockadeSignal(simulation, signal.getCode()));
}
/**关区信号*/

View File

@ -517,9 +517,14 @@ public class CiApiServiceImpl implements CiApiService {
station = station.getDeviceStation();
}
Station deviceStation = station;
if (Objects.nonNull(deviceStation.getRestartTime()) && deviceStation.getRestartTime().plusMinutes(8).isBefore(LocalTime.now())) {
if (Objects.nonNull(deviceStation.getRestartTime())
&& deviceStation.getRestartTime().isBefore(LocalTime.now())
&& ((Simulation.FunctionalType.LESSON.equals(simulation.getBuildParams().getFunctionalType())
||Simulation.FunctionalType.EXAM.equals(simulation.getBuildParams().getFunctionalType()))
?true: deviceStation.getRestartTime().plusMinutes(8).isAfter(LocalTime.now()))) {
List<Section> sections = simulation.getRepository().getSectionList();
sections.stream().filter(section -> Objects.equals(section.getDeviceStation(), deviceStation)).forEach(Section::faultUnlock);
return;
}
throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("无效操作或连锁机重启过8分钟需手动解锁");
}

View File

@ -866,6 +866,14 @@ public class MapDeviceBuilder {
} else {
signal.setDeviceStation(deviceStation);
}
// 所属车站
// Station station = (Station) elementMap.get(signalVO.getBelongStationCode());
// if (Objects.isNull(station)) {
// errMsgList.add(String.format("信号机[%s(%s)]未设置所属车站或所属车站不存在", signal.getName(), signal.getCode()));
// } else {
// signal.setStation(station);
// }
// 所属联锁站
Station interlockStation = ((Station) elementMap.get(signalVO.getInterlockStationCode()));
if (Objects.isNull(interlockStation)) {

View File

@ -35,6 +35,11 @@ public class Signal extends MayOutOfOrderDevice {
*/
private Station deviceStation;
/**
* 所属车站
*/
private Station station;
/**
* 联锁站
*/

View File

@ -1,11 +1,14 @@
package club.joylink.rtss.vo.client.student;
import club.joylink.rtss.services.OrgUserService;
import io.swagger.annotations.ApiModel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ApiModel(value = "导出学生信息")
@Getter
@ -27,4 +30,12 @@ public class ExportStudentInfo {
public ExportStudentInfo() {
this.scores = new ArrayList<>();
}
public String getStudentID() {
if(Objects.nonNull(studentID)){
return studentID.substring(0,studentID.indexOf(OrgUserService.companyCodePrefix));
}
return null;
}
}