Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2

This commit is contained in:
weizhihong 2022-08-12 13:27:22 +08:00
commit e865770a4b
13 changed files with 212 additions and 34 deletions

View File

@ -1,6 +1,6 @@
package club.joylink.rtss.entity.training2;
import club.joylink.rtss.vo.client.training2.Expression;
import club.joylink.rtss.simulation.cbtc.training2.Expression;
import java.time.LocalDateTime;

View File

@ -478,7 +478,7 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService {
MapRouteNewVO departureRoute = routeVOMap.get(startEndSignalCode); //发车进路
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(departureRoute.getName().startsWith("L"),
String.format("信号机[%s]的通过进路的发车进路[%s]不是列车进路", signal.getCode(), departureRoute.getCode()));
routeAspectVOS.add(new MapRouteAspectVO(departureRoute.getCode(), departureRoute.getSignalAspect()));
routeAspectVOS.add(new MapRouteAspectVO(departureRoute.getCode(), getAspectIndex(SignalAspect.Y)));
routeVO.setEndSectionCode(departureRoute.getEndSectionCode());
List<MapSignalButtonVO> buttons = signalCode_button_map.get(destination.getCode());
MapSignalButtonVO endButton = buttons.stream().filter(vo -> MapSignalButtonVO.Type.PICK.equals(vo.getType()))
@ -494,7 +494,7 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService {
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(receivingRoute,
String.format("[%s]接车进路不存在", startEndSignalCode));
routeVO.setStartSectionCode(receivingRoute.getStartSectionCode());
routeAspectVOS.add(new MapRouteAspectVO(receivingRoute.getCode(), receivingRoute.getSignalAspect()));
routeAspectVOS.add(new MapRouteAspectVO(receivingRoute.getCode(), getAspectIndex(SignalAspect.GY)));
outboundSignal = section.getSignalOf(right);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(outboundSignal,
String.format("股道[%s]无出站信号机", section.getCode()));

View File

@ -0,0 +1,132 @@
package club.joylink.rtss.simulation.cbtc.training2;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.Objects;
/**
* 表达式
*/
@Getter
@Setter
@NoArgsConstructor
public class Expression<T> implements Valuable<Boolean> {
Valuable<T> v1;
Operator operator;
Valuable<T> v2;
@Override
public Boolean getValue() throws IllegalAccessException {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(operator);
switch (operator) {
//逻辑运算符
case AND:
return (Boolean) v1.getValue() && (Boolean) v2.getValue();
case OR:
return (Boolean) v1.getValue() || (Boolean) v2.getValue();
case NOT: //还是觉得不要这个好
return !(Boolean) v1.getValue();
//关系运算符
case EQUALS:
return Objects.equals(v1.getValue(), v2.getValue());
case NOT_EQUALS:
return !Objects.equals(v1.getValue(), v2.getValue());
case GREATER_THAN:
return ((Comparable)v1.getValue()).compareTo(v2.getValue()) > 0;
case GREATER_THAN_OR_EQUALS:
return ((Comparable)v1.getValue()).compareTo(v2.getValue()) >= 0;
case LESS_THAN:
return ((Comparable)v1.getValue()).compareTo(v2.getValue()) < 0;
case LESS_THAN_OR_EQUALS:
return ((Comparable)v1.getValue()).compareTo(v2.getValue()) <= 0;
default:
throw new IllegalStateException("Unexpected value: " + operator);
}
}
public enum Operator {
AND(1),
OR(2),
NOT(3),
EQUALS(4),
NOT_EQUALS(5),
GREATER_THAN(6),
GREATER_THAN_OR_EQUALS(7),
LESS_THAN(8),
LESS_THAN_OR_EQUALS(9),
;
private final int code;
Operator(int code) {
this.code = code;
}
}
/**
* 逻辑表达式
*/
public static class Expression1 extends Expression<Boolean> {
@Override
public Boolean getValue() throws IllegalAccessException {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(operator);
switch (operator) {
//逻辑运算符
case AND:
return v1.getValue() && v2.getValue();
case OR:
return v1.getValue() || v2.getValue();
case NOT: //还是觉得不要这个好
return !v1.getValue();
default:
throw new IllegalStateException("Unexpected value: " + operator);
}
}
}
/**
* 关系表达式1
*/
public static class Expression2 extends Expression<Object> {
@Override
public Boolean getValue() throws IllegalAccessException {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(operator);
switch (operator) {
//关系运算符
case EQUALS:
return Objects.equals(v1.getValue(), v2.getValue());
case NOT_EQUALS:
return !Objects.equals(v1.getValue(), v2.getValue());
default:
throw new IllegalStateException("Unexpected value: " + operator);
}
}
}
/**
* 关系表达式1
*/
public static class Expression3<T extends Comparable<T>> extends Expression<T> {
@Override
public Boolean getValue() throws IllegalAccessException {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(operator);
switch (operator) {
//关系运算符
case GREATER_THAN:
return v1.getValue().compareTo(v2.getValue()) > 0;
case GREATER_THAN_OR_EQUALS:
return v1.getValue().compareTo(v2.getValue()) >= 0;
case LESS_THAN:
return v1.getValue().compareTo(v2.getValue()) < 0;
case LESS_THAN_OR_EQUALS:
return v1.getValue().compareTo(v2.getValue()) <= 0;
default:
throw new IllegalStateException("Unexpected value: " + operator);
}
}
}
}

View File

@ -0,0 +1,39 @@
package club.joylink.rtss.simulation.cbtc.training2;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import java.lang.reflect.Field;
public class StatusValue<T> implements Valuable<T>{
private MapElement element;
private String fieldName;
private Field field;
public StatusValue(MapElement element, String fieldName) throws NoSuchFieldException {
this.element = element;
this.fieldName = fieldName;
Class<?> aClass = element.getClass();
while (true) {
try {
field = aClass.getDeclaredField(fieldName);
} catch (NoSuchFieldException e) {
// e.printStackTrace();
}
if (field != null)
break;
aClass = aClass.getSuperclass();
if (aClass == null) {
throw new NoSuchFieldException();
}
}
field.setAccessible(true);
}
@Override
public T getValue() throws IllegalAccessException {
return (T) field.get(element);
}
}

View File

@ -0,0 +1,8 @@
package club.joylink.rtss.simulation.cbtc.training2;
/**
* 有值的
*/
public interface Valuable<T> {
T getValue() throws IllegalAccessException;
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.vo.client.training2;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.training2.Expression;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.map.graph.Point;
import com.fasterxml.jackson.annotation.JsonIgnore;

View File

@ -12,8 +12,6 @@ import java.util.List;
public class Step2VO {
private String id;
private String name;
private String description;
private List<String> operaIds;

View File

@ -57,9 +57,9 @@ public class MapArrowVO {
*/
private String color;
/**
* 显示条件 01现地&行调 / 02行调 / 03现地
*/
@NotBlank(message="显示条件不能为空")
private String showConditions;
// /**
// * 显示条件 01现地&行调 / 02行调 / 03现地
// */
// @NotBlank(message="显示条件不能为空")
// private String showConditions;
}

View File

@ -50,11 +50,11 @@ public class MapLineVO {
*/
private String lineColor;
/**
* 显示条件 01现地&行调 / 02行调 / 03现地
*/
@NotBlank(message="显示条件不能为空")
private String showConditions;
// /**
// * 显示条件 01现地&行调 / 02行调 / 03现地
// */
// @NotBlank(message="显示条件不能为空")
// private String showConditions;
private Integer offsetX;

View File

@ -43,9 +43,9 @@ public class MapOuterFrameVO {
@NotNull(message="位置不能为空")
private Point position;
/**
* 显示条件 01现地&行调 / 02行调 / 03现地
*/
@NotBlank(message="显示条件不能为空")
private String showConditions;
// /**
// * 显示条件 01现地&行调 / 02行调 / 03现地
// */
// @NotBlank(message="显示条件不能为空")
// private String showConditions;
}

View File

@ -35,10 +35,10 @@ public class MapPowerLineVO {
*/
private boolean rightTerminal;
/**
*显示工作站类型
*/
private String showConditions;
// /**
// *显示工作站类型
// */
// private String showConditions;
/**
*端点坐标

View File

@ -39,9 +39,9 @@ public class MapStationSplitVO {
@NotNull
private Point position;
/**
* 显示条件 01现地&行调 / 02行调 / 03现地
*/
@NotBlank(message="显示条件不能为空")
private String showConditions;
// /**
// * 显示条件 01现地&行调 / 02行调 / 03现地
// */
// @NotBlank(message="显示条件不能为空")
// private String showConditions;
}

View File

@ -50,9 +50,9 @@ public class MapTextVO {
@NotNull(message="坐标不能为空")
private Point position;
/**
* 显示条件 01现地&行调 / 02行调 / 03现地
*/
@NotBlank(message="显示条件不能为空")
private String showConditions;
// /**
// * 显示条件 01现地&行调 / 02行调 / 03现地
// */
// @NotBlank(message="显示条件不能为空")
// private String showConditions;
}