【运行日志参数修改】

This commit is contained in:
weizhihong 2022-06-17 10:40:32 +08:00
parent 3e16b48761
commit 1ca1b5372b
3 changed files with 28 additions and 21 deletions

View File

@ -4,12 +4,12 @@ import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@Getter
@ -134,7 +134,7 @@ public class CtcRunPlanParam implements Cloneable {
/**
* 列车运行计划作业
*/
private List<CtcStationRunPlanLog.RunPlanTask> runPlanTaskList = new ArrayList<>();
private Map<CtcStationRunPlanLog.RunPlanTask, Integer> runPlanTaskMap = new HashMap();
/**
* 删除时构造实体
@ -146,7 +146,7 @@ public class CtcRunPlanParam implements Cloneable {
p.setRunPlanCode(this.runPlanCode);
p.setStationCode(this.stationCode);
p.setTripNumber(this.tripNumber);
p.setRunPlanTaskList(null);
p.setRunPlanTaskMap(null);
return p;
}
@ -232,10 +232,15 @@ public class CtcRunPlanParam implements Cloneable {
change = true;
}
// 存在不一样的选项
long modifyNum = modify.getRunPlanTaskList().stream().filter(task -> !this.runPlanTaskList.contains(task)).count();
if (modifyNum > 0 || (this.runPlanTaskList.size() != modify.getRunPlanTaskList().size())) { // 长度不一致直接赋值
this.runPlanTaskList = modify.getRunPlanTaskList();
runPlanParam.setRunPlanTaskList(modify.getRunPlanTaskList());
Map<CtcStationRunPlanLog.RunPlanTask, Integer> modifyMap = new HashMap<>();
modify.getRunPlanTaskMap().forEach((k, v) -> {
if (!this.runPlanTaskMap.containsKey(k) || !Objects.equals(this.runPlanTaskMap.get(k), v)) {
modifyMap.put(k, v);
}
});
if (this.runPlanTaskMap.size() != modify.getRunPlanTaskMap().size() || !CollectionUtils.isEmpty(modifyMap)) {
this.runPlanTaskMap.putAll(modify.getRunPlanTaskMap());
runPlanParam.setRunPlanTaskMap(modifyMap);
change = true;
}
return change ? runPlanParam : null;
@ -266,9 +271,9 @@ public class CtcRunPlanParam implements Cloneable {
public CtcRunPlanParam clone() {
try {
CtcRunPlanParam clone = (CtcRunPlanParam) super.clone();
List<CtcStationRunPlanLog.RunPlanTask> list = new ArrayList<>(this.runPlanTaskList.size());
Collections.copy(list, this.runPlanTaskList);
clone.setRunPlanTaskList(list);
Map<CtcStationRunPlanLog.RunPlanTask, Integer> map = new HashMap(this.runPlanTaskMap.size());
map.putAll(this.runPlanTaskMap);
clone.setRunPlanTaskMap(map);
return clone;
} catch (CloneNotSupportedException e) {
throw new AssertionError();

View File

@ -19,10 +19,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@ -484,9 +481,14 @@ public class CtcStationRunPlanLogService {
original.setDepartDirectionCode(modify.getDepartDirectionCode());
}
// 存在不一样的选项
long modifyNum = modify.getRunPlanTaskList().stream().filter(task -> !original.getRunPlanTaskList().contains(task)).count();
if (modifyNum > 0 || (original.getRunPlanTaskList().size() != modify.getRunPlanTaskList().size())) { // 长度不一致直接赋值
original.setRunPlanTaskList(modify.getRunPlanTaskList());
Map<CtcStationRunPlanLog.RunPlanTask, Integer> modifyMap = new HashMap<>();
modify.getRunPlanTaskMap().forEach((k, v) -> {
if (!original.getRunPlanTaskMap().containsKey(k) && !Objects.equals(original.getRunPlanTaskMap().get(k), v)) {
modifyMap.put(k, v);
}
});
if (original.getRunPlanTaskMap().size() != modify.getRunPlanTaskMap().size() || !CollectionUtils.isEmpty(modifyMap)) {
original.getRunPlanTaskMap().putAll(modify.getRunPlanTaskMap());
}
if (!Objects.equals(original.getStatus(), modify.getStatus())) {
original.setStatus(modify.getStatus());

View File

@ -131,8 +131,8 @@ public class CtcStationRunPlanLog {
this.trackDiscordant = paramInfo.getTrackDiscordant(); // 运行股道与基本径路不一致
this.entryOutDiscordant = paramInfo.getEntryOutDiscordant(); // 出入口与基本径路不一致
this.transfinite = paramInfo.getTransfinite(); // 超限等级
if (CollectionUtils.isEmpty(paramInfo.getRunPlanTaskList())) { // 运行计划任务
this.runPlanTaskItemMap = paramInfo.getRunPlanTaskList().stream()
if (CollectionUtils.isEmpty(paramInfo.getRunPlanTaskMap())) { // 运行计划任务
this.runPlanTaskItemMap = paramInfo.getRunPlanTaskMap().keySet().stream()
.collect(Collectors.toMap(t -> t, t -> new RunPlanTaskItem(t)));
} else {
this.runPlanTaskItemMap = new HashMap<>(0);