【超限等级设置、设置任务】

This commit is contained in:
weizhihong 2022-07-08 17:01:26 +08:00
parent a8a5a4c884
commit f8a8f5cc75
5 changed files with 60 additions and 13 deletions

View File

@ -216,12 +216,12 @@ public class CtcStationRunPlanOperateHandler {
* @param simulation 仿真
* @param stationCode 车站编码
* @param runPlanCode 运行计划编码
* @param task 任务
* @param taskKey 任务Key
* @param status 是否设置 1 0
*/
@OperateHandlerMapping(type = Operation.Type.CTC_LOG_SET_TASK)
public void setTask(Simulation simulation, String stationCode, String runPlanCode, CtcStationRunPlanLog.RunPlanTask task, int status) {
ctcStationRunPlanLogService.setTask(simulation, stationCode, runPlanCode, task, status);
public void setTask(Simulation simulation, String stationCode, String runPlanCode, String taskKey, int status) {
ctcStationRunPlanLogService.setTask(simulation, stationCode, runPlanCode, taskKey, status);
}
/**

View File

@ -131,6 +131,11 @@ public class CtcRunPlanParam implements Cloneable {
*/
private Boolean departElectrical;
/**
* 超限等级
*/
private CtcStationRunPlanLog.TransfiniteType transfinite;
/**
* 到达超限
*/
@ -166,11 +171,6 @@ public class CtcRunPlanParam implements Cloneable {
*/
private Boolean entryOutDiscordant;
/**
* 超限等级
*/
private CtcStationRunPlanLog.TransfiniteType transfinite;
/**
* 记事
*/
@ -656,6 +656,15 @@ public class CtcRunPlanParam implements Cloneable {
return this.arriveElectrical != null || this.departElectrical != null;
}
/**
* 是否指定到达出发超限等级
*
* @return 是否存在
*/
public boolean arriveAndDepartTransfinite() {
return this.arriveTransfinite != null || this.departTransfinite != null;
}
@Override
public CtcRunPlanParam clone() {
try {

View File

@ -459,9 +459,11 @@ public class CtcStationRunPlanLogService {
* @param simulation 仿真
* @param stationCode 车站编码
* @param runPlanCode 运行计划编码
* @param task 任务
* @param taskKey 任务Key
*/
public void setTask(Simulation simulation, String stationCode, String runPlanCode, CtcStationRunPlanLog.RunPlanTask task, int status) {
public void setTask(Simulation simulation, String stationCode, String runPlanCode, String taskKey, int status) {
CtcStationRunPlanLog.RunPlanTask task = CtcStationRunPlanLog.RunPlanTask.getTaskByKey(taskKey);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(task);
CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository().getRunPlanByRunPlanCode(stationCode, runPlanCode);
if (status == 1) { // 设置
runPlanLog.getRunPlanTaskItemMap().put(task.getOptionKey(), new CtcStationRunPlanLog.RunPlanTaskItem(task));
@ -710,9 +712,21 @@ public class CtcStationRunPlanLogService {
Boolean electrical = arrive ? paramInfo.getArriveElectrical() : paramInfo.getDepartElectrical();
runPlanItem.setElectrical(electrical);
} else {
// 设置默认电力
if (paramInfo.getElectrical() != null && !Objects.equals(runPlanItem.isElectrical(), paramInfo.getElectrical())) {
runPlanItem.setElectrical(paramInfo.getElectrical());
}
}
// 超限设置
if (paramInfo.arriveAndDepartTransfinite()) {
CtcStationRunPlanLog.TransfiniteType transfinite = arrive ? paramInfo.getArriveTransfinite() : paramInfo.getDepartTransfinite();
runPlanItem.setTransfinite(transfinite);
} else {
if (!Objects.equals(runPlanItem.getTransfinite(), paramInfo.getTransfinite())) {
runPlanItem.setTransfinite(paramInfo.getTransfinite());
}
}
}
return change;
}

View File

@ -436,6 +436,10 @@ public class CtcStationRunPlanLog {
*/
private boolean finish;
/**
* 超限等级
*/
private TransfiniteType transfinite;
public RunPlanItem(CtcRunPlanParam paramInfo) {
this.paramInfo = paramInfo;
@ -447,6 +451,7 @@ public class CtcStationRunPlanLog {
this.adjacentMessageTime = "";
this.setOutTypeMap = new HashMap<>(SetOutType.values().length);
this.processTypeMap = new HashMap<>(ProcessType.values().length);
this.transfinite = TransfiniteType.NO;
}
public void initAccessName() {
@ -555,6 +560,13 @@ public class CtcStationRunPlanLog {
} else {
runPlanItem.setElectrical(paramInfo.getElectrical());
}
// 超限等级
if (paramInfo.arriveAndDepartTransfinite()) {
TransfiniteType transfinite = arrive ? paramInfo.getArriveTransfinite() : paramInfo.getDepartTransfinite();
runPlanItem.setTransfinite(transfinite);
} else {
runPlanItem.setTransfinite(paramInfo.getTransfinite());
}
}
return runPlanItem;
}
@ -613,7 +625,7 @@ public class CtcStationRunPlanLog {
* @param key 唯一键
* @return 运行任务
*/
public RunPlanTask getTaskByKey(String key) {
public static RunPlanTask getTaskByKey(String key) {
return Arrays.stream(RunPlanTask.values()).filter(r -> r.getOptionKey().equals(key))
.findFirst().orElseGet(null);
}

View File

@ -408,6 +408,12 @@ public class CtcStationRunPlanLogVO {
changeRunItem.setElectrical(runPlanItem.isElectrical());
change = true;
}
// 超限
if (runPlanItem.getTransfinite() != null && !Objects.equals(paramInfo.getTransfinite(), runPlanItem.getTransfinite().getVal())) {
paramInfo.setTransfinite(runPlanItem.getTransfinite().getVal());
changeRunItem.setTransfinite(runPlanItem.getTransfinite().getVal());
change = true;
}
return change ? changeRunItem : null; // 没有变化返回null
}
@ -474,6 +480,11 @@ public class CtcStationRunPlanLogVO {
*/
private Boolean electrical;
/**
* 超限等级
*/
private String transfinite;
public RunPlanItem() {
}
@ -495,6 +506,7 @@ public class CtcStationRunPlanLogVO {
this.adjacentMessageTime = runPlanItem.getAdjacentMessageTime();
this.finish = runPlanItem.isFinish();
this.electrical = runPlanItem.isElectrical();
this.transfinite = runPlanItem.getTransfinite().getVal();
}
}
}