From ad19c5633122728e902ada4072898e5b7eeffdca Mon Sep 17 00:00:00 2001 From: weizhihong Date: Wed, 27 Apr 2022 17:08:19 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E3=80=90=E5=88=97=E8=BD=A6=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=96=B9=E5=90=91=E9=80=BB=E8=BE=91=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/constants/ButtonTypeEnum.java | 37 --- .../rtss/constants/DirectionLabelEnum.java | 22 +- .../rtss/constants/IndicatorTypeEnum.java | 32 -- .../rtss/controller/AssistController.java | 69 ---- .../DraftMapStationDirectionController.java | 67 ++++ .../rtss/dao/AssistIndicatorButtonDAO.java | 13 - .../rtss/dao/DraftMapStationDirectionDAO.java | 23 ++ ...ton.java => DraftMapStationDirection.java} | 30 +- ...a => DraftMapStationDirectionExample.java} | 72 ++--- .../AssistButtonIndicatorService.java | 80 ----- .../rtss/services/DraftMapService.java | 13 +- .../IAssistButtonIndicatorService.java | 56 ---- .../DraftMapStationDirectionServiceImpl.java | 78 +++++ .../IDraftMapStationDirectionService.java | 54 ++++ .../ATS/ATSMessageCollectAndDispatcher.java | 15 +- ...va => StationDirectionOperateHandler.java} | 15 +- .../ATS/service/assist/AssistService.java | 297 ------------------ .../service/assist/ButtonThenInterface.java | 8 +- .../service/assist/ButtonValidInterface.java | 8 +- .../assist/StationDirectionService.java | 133 ++++++++ .../rtss/simulation/cbtc/CI/CiLogic.java | 37 +-- .../cbtc/SimulationLifeCycleServiceImpl.java | 4 +- .../cbtc/build/InterlockBuilder2.java | 137 ++++---- .../cbtc/build/MapDeviceBuilder.java | 34 +- .../rtss/simulation/cbtc/data/map/Button.java | 44 ++- .../simulation/cbtc/data/map/Indicator.java | 88 ++++-- .../simulation/cbtc/data/map/MapElement.java | 6 +- .../simulation/cbtc/data/map/Station.java | 13 +- .../cbtc/data/map/StationDirection.java | 240 ++++++++++++++ .../cbtc/data/status/ButtonStatus.java | 45 --- .../cbtc/data/status/IndicatorStatus.java | 47 --- .../data/status/StationDirectionStatus.java | 153 +++++++++ .../cbtc/data/vo/ButtonStatusVO.java | 19 -- .../cbtc/data/vo/IndicatorStatusVO.java | 28 -- .../data/vo/StationDirectionStatusVO.java | 63 ++++ .../rtss/vo/map/MapLogicDataNewVO.java | 6 +- ...AO.xml => DraftMapStationDirectionDAO.xml} | 132 ++++---- 37 files changed, 1202 insertions(+), 1016 deletions(-) delete mode 100644 src/main/java/club/joylink/rtss/constants/ButtonTypeEnum.java delete mode 100644 src/main/java/club/joylink/rtss/constants/IndicatorTypeEnum.java delete mode 100644 src/main/java/club/joylink/rtss/controller/AssistController.java create mode 100644 src/main/java/club/joylink/rtss/controller/draft/DraftMapStationDirectionController.java delete mode 100644 src/main/java/club/joylink/rtss/dao/AssistIndicatorButtonDAO.java create mode 100644 src/main/java/club/joylink/rtss/dao/DraftMapStationDirectionDAO.java rename src/main/java/club/joylink/rtss/entity/{IndicatorButton.java => DraftMapStationDirection.java} (76%) rename src/main/java/club/joylink/rtss/entity/{IndicatorButtonExample.java => DraftMapStationDirectionExample.java} (83%) delete mode 100644 src/main/java/club/joylink/rtss/services/AssistButtonIndicatorService.java delete mode 100644 src/main/java/club/joylink/rtss/services/IAssistButtonIndicatorService.java create mode 100644 src/main/java/club/joylink/rtss/services/draftData/DraftMapStationDirectionServiceImpl.java create mode 100644 src/main/java/club/joylink/rtss/services/draftData/IDraftMapStationDirectionService.java rename src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/{AssistOperateHandler.java => StationDirectionOperateHandler.java} (65%) delete mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/AssistService.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/StationDirectionService.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationDirection.java delete mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/status/ButtonStatus.java delete mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/status/IndicatorStatus.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/status/StationDirectionStatus.java delete mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ButtonStatusVO.java delete mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/IndicatorStatusVO.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/StationDirectionStatusVO.java rename src/main/resources/mybatis/mapper/{AssistIndicatorButtonDAO.xml => DraftMapStationDirectionDAO.xml} (67%) diff --git a/src/main/java/club/joylink/rtss/constants/ButtonTypeEnum.java b/src/main/java/club/joylink/rtss/constants/ButtonTypeEnum.java deleted file mode 100644 index 293b449aa..000000000 --- a/src/main/java/club/joylink/rtss/constants/ButtonTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package club.joylink.rtss.constants; - -/** - * 按钮类型枚举 - */ -public enum ButtonTypeEnum { - // 总辅助 - MAIN_ASSIST, - // 接辅助 - RECEIVE_ASSIST, - // 发辅助 - DELIVER_ASSIST, - // 改方 - CHANGE_DIRECTION, - NO; - - /** - * 获取枚举信息 - * - * @param type 类型 - * @return 枚举 - */ - public static ButtonTypeEnum getType(String type) { - switch (type) { - case "main_assist": - return ButtonTypeEnum.MAIN_ASSIST; - case "deliver_assist": - return ButtonTypeEnum.DELIVER_ASSIST; - case "receive_assist": - return ButtonTypeEnum.RECEIVE_ASSIST; - case "change_direction": - return ButtonTypeEnum.CHANGE_DIRECTION; - default: - return ButtonTypeEnum.NO; - } - } -} diff --git a/src/main/java/club/joylink/rtss/constants/DirectionLabelEnum.java b/src/main/java/club/joylink/rtss/constants/DirectionLabelEnum.java index 8168ed13c..3774642ce 100644 --- a/src/main/java/club/joylink/rtss/constants/DirectionLabelEnum.java +++ b/src/main/java/club/joylink/rtss/constants/DirectionLabelEnum.java @@ -9,5 +9,25 @@ public enum DirectionLabelEnum { XD, S, SF, - SD + SD, + NO; + + public static DirectionLabelEnum getLabel(String label) { + switch (label) { + case "X": + return DirectionLabelEnum.X; + case "XF": + return DirectionLabelEnum.XF; + case "XD": + return DirectionLabelEnum.XD; + case "S": + return DirectionLabelEnum.S; + case "SF": + return DirectionLabelEnum.SF; + case "SD": + return DirectionLabelEnum.SD; + default: + return DirectionLabelEnum.NO; + } + } } diff --git a/src/main/java/club/joylink/rtss/constants/IndicatorTypeEnum.java b/src/main/java/club/joylink/rtss/constants/IndicatorTypeEnum.java deleted file mode 100644 index 61359f686..000000000 --- a/src/main/java/club/joylink/rtss/constants/IndicatorTypeEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -package club.joylink.rtss.constants; - -/** - * 信号灯类型 - */ -public enum IndicatorTypeEnum { - // 接 - RECEIVE, - // 发 - DELIVER, - // 区间 - SECTION, - // 辅助 - ASSIST, - // 无类型 - NO; - - public static IndicatorTypeEnum getType(String type) { - switch (type) { - case "receive": - return IndicatorTypeEnum.RECEIVE; - case "deliver": - return IndicatorTypeEnum.DELIVER; - case "section": - return IndicatorTypeEnum.SECTION; - case "assist": - return IndicatorTypeEnum.ASSIST; - default: - return IndicatorTypeEnum.NO; - } - } -} diff --git a/src/main/java/club/joylink/rtss/controller/AssistController.java b/src/main/java/club/joylink/rtss/controller/AssistController.java deleted file mode 100644 index df2210d52..000000000 --- a/src/main/java/club/joylink/rtss/controller/AssistController.java +++ /dev/null @@ -1,69 +0,0 @@ -package club.joylink.rtss.controller; - -import club.joylink.rtss.entity.IndicatorButton; -import club.joylink.rtss.services.IAssistButtonIndicatorService; -import club.joylink.rtss.vo.client.PageQueryVO; -import club.joylink.rtss.vo.client.PageVO; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -/** - * 地图草稿数据管理接口 - */ -@RestController -@RequestMapping("/api/assist") -@Slf4j -public class AssistController { - @Autowired - private IAssistButtonIndicatorService assistButtonIndicatorService; - - /** - * 查询地图下所有的指示灯、区间、进路等关系列表 - * - * @param mapId 地图ID - * @param standCode 站台 - * @param indicatorCode 指示灯ID - * @param routeCode 进路编码 - * @return 关系列表 - */ - @GetMapping(path = "/indicator/section/list/{mapId}") - public PageVO indicatorSectionList(@PathVariable Long mapId, String standCode, String indicatorCode - , String routeCode, PageQueryVO queryVO) { - return assistButtonIndicatorService.indicatorSectionList(mapId, standCode, indicatorCode, routeCode, queryVO); - } - - /** - * 根据ID查询单个指示灯、区间、进路等关系 - * - * @param id 关系Id - * @return 关系实体 - */ - @GetMapping(path = "/indicator/section/{id}") - public IndicatorButton queryIndicatorSection(@PathVariable Long id) { - return assistButtonIndicatorService.queryIndicatorSection(id); - } - - /** - * 保存关联关系信息 - * - * @param mapId 地图信息 - * @param vo 关联关系 - * @return 处理结果 - */ - @PostMapping(path = "/indicator/section/save/{mapId}") - public String saveIndicatorSection(@PathVariable Long mapId, @RequestBody IndicatorButton vo) { - return assistButtonIndicatorService.saveIndicatorSection(mapId, vo); - } - - /** - * 删除指示灯与区段关联关系 - * - * @param id 主键 - * @param user 用户 - */ - @DeleteMapping(path = "/indicator/section/delete/{id}") - public void deleteIndicatorSection(@PathVariable Long id) { - assistButtonIndicatorService.deleteIndicatorSection(id); - } -} diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapStationDirectionController.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapStationDirectionController.java new file mode 100644 index 000000000..bf3146264 --- /dev/null +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapStationDirectionController.java @@ -0,0 +1,67 @@ +package club.joylink.rtss.controller.draft; + +import club.joylink.rtss.entity.DraftMapStationDirection; +import club.joylink.rtss.services.draftData.IDraftMapStationDirectionService; +import club.joylink.rtss.vo.client.PageQueryVO; +import club.joylink.rtss.vo.client.PageVO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 车站 + */ +@RestController +@RequestMapping("/api/station/direction") +@Slf4j +public class DraftMapStationDirectionController { + @Autowired + private IDraftMapStationDirectionService draftMapStationDirectionLabelService; + + /** + * 查询地图下车站 方向的逻辑数据列表 + * + * @param mapId 地图ID + * @param code Code + * @param labelEnum 方向类型 + * @return 数据列表 + */ + @GetMapping(path = "/list/{mapId}") + public PageVO stationLabelList(@PathVariable Long mapId, String code + , String labelEnum, PageQueryVO queryVO) { + return draftMapStationDirectionLabelService.stationLabelList(mapId, code, labelEnum, queryVO); + } + + /** + * 根据ID查询地图下车站 方向的逻辑数据 + * + * @param id 关系Id + * @return 关系实体 + */ + @GetMapping(path = "/{id}") + public DraftMapStationDirection queryStationLabel(@PathVariable Long id) { + return draftMapStationDirectionLabelService.queryStationLabel(id); + } + + /** + * 保存关联关系信息 + * + * @param mapId 地图信息 + * @param vo 关联关系 + * @return 处理结果 + */ + @PostMapping(path = "/save/{mapId}") + public String saveStationLabel(@PathVariable Long mapId, @RequestBody DraftMapStationDirection vo) { + return draftMapStationDirectionLabelService.saveStationLabel(mapId, vo); + } + + /** + * 删除车站 方向的逻辑数据 + * + * @param id 主键 + */ + @DeleteMapping(path = "/delete/{id}") + public void deleteStationLabel(@PathVariable Long id) { + draftMapStationDirectionLabelService.deleteStationLabel(id); + } +} diff --git a/src/main/java/club/joylink/rtss/dao/AssistIndicatorButtonDAO.java b/src/main/java/club/joylink/rtss/dao/AssistIndicatorButtonDAO.java deleted file mode 100644 index c9ba3e14f..000000000 --- a/src/main/java/club/joylink/rtss/dao/AssistIndicatorButtonDAO.java +++ /dev/null @@ -1,13 +0,0 @@ -package club.joylink.rtss.dao; - -import club.joylink.rtss.entity.IndicatorButton; -import club.joylink.rtss.entity.IndicatorButtonExample; -import org.springframework.stereotype.Repository; - -/** - * AssistButtonDAO继承基类 - */ -@Repository -public interface AssistIndicatorButtonDAO extends MyBatisBaseDao { - -} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/dao/DraftMapStationDirectionDAO.java b/src/main/java/club/joylink/rtss/dao/DraftMapStationDirectionDAO.java new file mode 100644 index 000000000..8a2ed3db4 --- /dev/null +++ b/src/main/java/club/joylink/rtss/dao/DraftMapStationDirectionDAO.java @@ -0,0 +1,23 @@ +package club.joylink.rtss.dao; + +import club.joylink.rtss.entity.DraftMapStationDirection; +import club.joylink.rtss.entity.DraftMapStationDirectionExample; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * AssistButtonDAO继承基类 + */ +@Repository +public interface DraftMapStationDirectionDAO extends MyBatisBaseDao { + + /** + * 多数据保存 + * + * @param record + * @return + */ + int insertList(@Param("list") List records); +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/IndicatorButton.java b/src/main/java/club/joylink/rtss/entity/DraftMapStationDirection.java similarity index 76% rename from src/main/java/club/joylink/rtss/entity/IndicatorButton.java rename to src/main/java/club/joylink/rtss/entity/DraftMapStationDirection.java index 291a79e55..2b4b74be2 100644 --- a/src/main/java/club/joylink/rtss/entity/IndicatorButton.java +++ b/src/main/java/club/joylink/rtss/entity/DraftMapStationDirection.java @@ -1,5 +1,6 @@ package club.joylink.rtss.entity; +import club.joylink.rtss.constants.DirectionLabelEnum; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Getter; @@ -16,7 +17,7 @@ import java.util.List; */ @Setter @Getter -public class IndicatorButton { +public class DraftMapStationDirection { @JsonSerialize(using = ToStringSerializer.class) private Long id; @@ -27,11 +28,16 @@ public class IndicatorButton { private Long mapId; /** - * 指示灯 + * 生成的编码 */ - @NotBlank(message = "编号不能为空") private String code; + /** + * 车站 + */ + @NotBlank(message = "车站编号不能为空") + private String stationCode; + /** * 区间列表 */ @@ -43,24 +49,14 @@ public class IndicatorButton { private String sectionsCode; /** - * 所处站台 + * 方向枚举 */ - private String standCode; + private DirectionLabelEnum labelEnum; /** - * 进路Code + * 信号机Code */ - private String routeCode; - - /** - * 关联实体类型 - */ - private String modelType; - - /** - * 灯类型 - */ - private String type; + private String signalCode; public void generateSectionList() { if (StringUtils.isEmpty(sectionsCode)) { diff --git a/src/main/java/club/joylink/rtss/entity/IndicatorButtonExample.java b/src/main/java/club/joylink/rtss/entity/DraftMapStationDirectionExample.java similarity index 83% rename from src/main/java/club/joylink/rtss/entity/IndicatorButtonExample.java rename to src/main/java/club/joylink/rtss/entity/DraftMapStationDirectionExample.java index 08babae82..f5db89b10 100644 --- a/src/main/java/club/joylink/rtss/entity/IndicatorButtonExample.java +++ b/src/main/java/club/joylink/rtss/entity/DraftMapStationDirectionExample.java @@ -3,7 +3,7 @@ package club.joylink.rtss.entity; import java.util.ArrayList; import java.util.List; -public class IndicatorButtonExample { +public class DraftMapStationDirectionExample { protected String orderByClause; protected boolean distinct; @@ -14,7 +14,7 @@ public class IndicatorButtonExample { private Long offset; - public IndicatorButtonExample() { + public DraftMapStationDirectionExample() { oredCriteria = new ArrayList(); } @@ -254,7 +254,7 @@ public class IndicatorButtonExample { return (Criteria) this; } - public Criteria andIndicatorCodeEqualTo(String value) { + public Criteria andCodeEqualTo(String value) { addCriterion("code =", value, "code"); return (Criteria) this; } @@ -279,84 +279,78 @@ public class IndicatorButtonExample { return (Criteria) this; } - public Criteria andStandCodeIsNull() { - addCriterion("stand_code is null"); + public Criteria andStationCodeIsNull() { + addCriterion("station_code is null"); return (Criteria) this; } - public Criteria andStandCodeIsNotNull() { - addCriterion("stand_code is not null"); + public Criteria andStationCodeIsNotNull() { + addCriterion("station_code is not null"); return (Criteria) this; } - public Criteria andStandCodeEqualTo(String value) { - addCriterion("stand_code =", value, "standCode"); + public Criteria andStationCodeEqualTo(String value) { + addCriterion("station_code =", value, "stationCode"); return (Criteria) this; } - public Criteria andStandCodeNotEqualTo(String value) { - addCriterion("stand_code <>", value, "standCode"); + public Criteria andStationCodeLike(String value) { + addCriterion("station_code like", value, "stationCode"); return (Criteria) this; } - public Criteria andStandCodeLike(String value) { - addCriterion("stand_code like", value, "standCode"); + public Criteria andStationCodeNotLike(String value) { + addCriterion("station_code not like", value, "stationCode"); return (Criteria) this; } - public Criteria andStandCodeNotLike(String value) { - addCriterion("stand_code not like", value, "standCode"); + public Criteria andStationCodeIn(List values) { + addCriterion("station_code in", values, "stationCode"); return (Criteria) this; } - public Criteria andStandCodeIn(List values) { - addCriterion("stand_code in", values, "standCode"); + public Criteria andStationCodeNotIn(List values) { + addCriterion("station_code not in", values, "stationCode"); return (Criteria) this; } - public Criteria andStandCodeNotIn(List values) { - addCriterion("stand_code not in", values, "standCode"); + public Criteria andLabelEnumIsNull() { + addCriterion("label_enum is null"); return (Criteria) this; } - - public Criteria andRouteCodeIsNull() { - addCriterion("route_code is null"); + public Criteria andLabelEnumIsNotNull() { + addCriterion("label_enum is not null"); return (Criteria) this; } - public Criteria andRouteCodeIsNotNull() { - addCriterion("route_code is not null"); + public Criteria andLabelEnumEqualTo(String value) { + addCriterion("label_enum =", value, "labelEnum"); return (Criteria) this; } - public Criteria andRouteCodeEqualTo(String value) { - addCriterion("route_code =", value, "routeCode"); + public Criteria andLabelEnumNotEqualTo(String value) { + addCriterion("label_enum <>", value, "labelEnum"); return (Criteria) this; } - public Criteria andRouteCodeNotEqualTo(String value) { - addCriterion("route_code <>", value, "routeCode"); + public Criteria andLabelEnumLike(String value) { + addCriterion("label_enum like", value, "labelEnum"); return (Criteria) this; } - public Criteria andRouteCodeLike(String value) { - addCriterion("route_code like", value, "routeCode"); + public Criteria andLabelEnumNotLike(String value) { + addCriterion("label_enum not like", value, "labelEnum"); return (Criteria) this; } - public Criteria andRouteCodeNotLike(String value) { - addCriterion("route_code not like", value, "routeCode"); + public Criteria andLabelEnumIn(List values) { + addCriterion("label_enum in", values, "labelEnum"); return (Criteria) this; } - public Criteria andRouteCodeIn(List values) { - addCriterion("route_code in", values, "routeCode"); - return (Criteria) this; - } - - public Criteria andRouteCodeNotIn(List values) { - addCriterion("route_code not in", values, "routeCode"); + public Criteria andLabelEnumNotIn(List values) { + addCriterion("label_enum not in", values, "labelEnum"); return (Criteria) this; } } diff --git a/src/main/java/club/joylink/rtss/services/AssistButtonIndicatorService.java b/src/main/java/club/joylink/rtss/services/AssistButtonIndicatorService.java deleted file mode 100644 index 86c8bbf88..000000000 --- a/src/main/java/club/joylink/rtss/services/AssistButtonIndicatorService.java +++ /dev/null @@ -1,80 +0,0 @@ -package club.joylink.rtss.services; - -import club.joylink.rtss.dao.AssistIndicatorButtonDAO; -import club.joylink.rtss.entity.IndicatorButton; -import club.joylink.rtss.entity.IndicatorButtonExample; -import club.joylink.rtss.vo.client.PageQueryVO; -import club.joylink.rtss.vo.client.PageVO; -import com.github.pagehelper.Page; -import com.github.pagehelper.PageHelper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; - -import java.util.List; - -@Service -public class AssistButtonIndicatorService implements IAssistButtonIndicatorService { - @Autowired - private AssistIndicatorButtonDAO assistIndicatorButtonDAO; - - @Override - public PageVO indicatorSectionList(Long mapId, String standCode, String indicatorCode - , String routeCode, PageQueryVO queryVO) { - PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); - IndicatorButtonExample indicatorButtonExample = new IndicatorButtonExample(); - IndicatorButtonExample.Criteria criteria = indicatorButtonExample.createCriteria(); - criteria.andMapIdEqualTo(mapId); - // 站台 - if (!StringUtils.isEmpty(standCode)) { - criteria.andStandCodeEqualTo(standCode); - } - // 指示灯 - if (!StringUtils.isEmpty(indicatorCode)) { - criteria.andIndicatorCodeEqualTo(indicatorCode); - } - // 进路 - if (!StringUtils.isEmpty(routeCode)) { - criteria.andRouteCodeEqualTo(routeCode); - } - Page page = (Page) assistIndicatorButtonDAO.selectByExample(indicatorButtonExample); - page.getResult().forEach(IndicatorButton::generateSectionList); - return PageVO.convert(page, page.getResult()); - } - - @Override - public IndicatorButton queryIndicatorSection(Long id) { - return assistIndicatorButtonDAO.selectByPrimaryKey(id); - } - - @Override - public String saveIndicatorSection(Long mapId, IndicatorButton vo) { - vo.setMapId(mapId); - if (!CollectionUtils.isEmpty(vo.getSectionList())) { - vo.setSectionsCode(String.join(",", vo.getSectionList())); - } - int line; - if (vo.getId() != null) { - line = assistIndicatorButtonDAO.updateByPrimaryKey(vo); - } else { - line = assistIndicatorButtonDAO.insert(vo); - } - return line != 0 ? "保存成功" : "保存失败"; - } - - @Override - public void deleteIndicatorSection(Long id) { - assistIndicatorButtonDAO.deleteByPrimaryKey(id); - } - - @Override - public List queryAllIndicatorSectionByMapId(Long mapId) { - IndicatorButtonExample indicatorButtonExample = new IndicatorButtonExample(); - IndicatorButtonExample.Criteria criteria = indicatorButtonExample.createCriteria(); - criteria.andMapIdEqualTo(mapId); - List list = assistIndicatorButtonDAO.selectByExample(indicatorButtonExample); - list.forEach(IndicatorButton::generateSectionList); - return list; - } -} diff --git a/src/main/java/club/joylink/rtss/services/DraftMapService.java b/src/main/java/club/joylink/rtss/services/DraftMapService.java index 69eb5b714..fd5b46050 100644 --- a/src/main/java/club/joylink/rtss/services/DraftMapService.java +++ b/src/main/java/club/joylink/rtss/services/DraftMapService.java @@ -6,6 +6,7 @@ import club.joylink.rtss.entity.*; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.draftData.DraftMapOverrunService; import club.joylink.rtss.services.draftData.DraftMapRouteService; +import club.joylink.rtss.services.draftData.IDraftMapStationDirectionService; import club.joylink.rtss.services.draftData.RailwayRouteGenerator; import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder; import club.joylink.rtss.simulation.cbtc.data.CalculateService; @@ -98,7 +99,10 @@ public class DraftMapService implements IDraftMapService { private DraftMapRouteService draftMapRouteService; @Autowired - private IAssistButtonIndicatorService assistButtonIndicatorService; + private IDraftMapStationDirectionService draftMapStationDirectionLabelService; + + @Autowired + private DraftMapStationDirectionDAO draftMapStationDirectionDAO; @Override public List list(AccountVO accountVO) { @@ -510,7 +514,7 @@ public class DraftMapService implements IDraftMapService { logicDataVO.setFlankProtectionList(MapRouteFlankProtectionNewVO.convert2VOList(draftMapRouteFlankProtections)); // 获取指示灯、按钮等关联关系 - logicDataVO.setIndicatorButtonVOList(assistButtonIndicatorService.queryAllIndicatorSectionByMapId(id)); + logicDataVO.setDraftMapStationDirectionList(draftMapStationDirectionLabelService.queryAllStationLabelByMapId(id)); return logicDataVO; } @@ -593,6 +597,11 @@ public class DraftMapService implements IDraftMapService { this.draftMapRouteFlankProtectionDAO.insert(entity); }); } + + // 车站 方向的逻辑数据数据 + if (!CollectionUtils.isEmpty(logicDataVO.getDraftMapStationDirectionList())) { + draftMapStationDirectionDAO.insertList(logicDataVO.getDraftMapStationDirectionList()); + } } private void deleteMapLogicData(Long id) { diff --git a/src/main/java/club/joylink/rtss/services/IAssistButtonIndicatorService.java b/src/main/java/club/joylink/rtss/services/IAssistButtonIndicatorService.java deleted file mode 100644 index 745d50fad..000000000 --- a/src/main/java/club/joylink/rtss/services/IAssistButtonIndicatorService.java +++ /dev/null @@ -1,56 +0,0 @@ -package club.joylink.rtss.services; - -import club.joylink.rtss.entity.IndicatorButton; -import club.joylink.rtss.vo.client.PageQueryVO; -import club.joylink.rtss.vo.client.PageVO; - -import java.util.List; - -public interface IAssistButtonIndicatorService { - - /** - * 查找该地图下的指示灯、区间、站台、进路关系信息列表 - * - * @param mapId 地图ID - * @param standCode 站台 - * @param indicatorCode 指示灯ID - * @param routeCode 进路编码 - * @return 关系列表 - */ - PageVO indicatorSectionList(Long mapId, String standCode, String indicatorCode, String routeCode, PageQueryVO queryVO); - - - /** - * 查找该地图下的指示灯、区间、站台、进路关系信息 - * - * @param id 关系ID - * @return 关系信息 - */ - IndicatorButton queryIndicatorSection(Long id); - - - /** - * 保存指示灯关系数据 - * - * @param mapId 地图ID - * @param vo 实体类 - * @return 保存结果 - */ - String saveIndicatorSection(Long mapId, IndicatorButton vo); - - - /** - * 删除指示灯关系数据 - * - * @param id 关系ID - */ - void deleteIndicatorSection(Long id); - - /** - * 查找该地图下的指示灯、区间、站台、进路关系信息列表 - * - * @param mapId 地图Id - * @return 关系列表 - */ - List queryAllIndicatorSectionByMapId(Long mapId); -} diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapStationDirectionServiceImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapStationDirectionServiceImpl.java new file mode 100644 index 000000000..36d771710 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapStationDirectionServiceImpl.java @@ -0,0 +1,78 @@ +package club.joylink.rtss.services.draftData; + +import club.joylink.rtss.dao.DraftMapStationDirectionDAO; +import club.joylink.rtss.entity.DraftMapStationDirection; +import club.joylink.rtss.entity.DraftMapStationDirectionExample; +import club.joylink.rtss.vo.client.PageQueryVO; +import club.joylink.rtss.vo.client.PageVO; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.util.List; + +@Service +public class DraftMapStationDirectionServiceImpl implements IDraftMapStationDirectionService { + @Autowired + private DraftMapStationDirectionDAO draftMapStationDirectionDAO; + + @Override + public PageVO stationLabelList(Long mapId, String code + , String labelEnum, PageQueryVO queryVO) { + PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); + DraftMapStationDirectionExample draftMapStationDirectionExample = new DraftMapStationDirectionExample(); + DraftMapStationDirectionExample.Criteria criteria = draftMapStationDirectionExample.createCriteria(); + criteria.andMapIdEqualTo(mapId); + // code + if (!StringUtils.isEmpty(code)) { + criteria.andCodeEqualTo(code); + } + // 指示灯 + if (!StringUtils.isEmpty(labelEnum)) { + criteria.andLabelEnumEqualTo(labelEnum); + } + Page page = (Page) draftMapStationDirectionDAO.selectByExample(draftMapStationDirectionExample); + page.getResult().forEach(DraftMapStationDirection::generateSectionList); + return PageVO.convert(page, page.getResult()); + } + + @Override + public DraftMapStationDirection queryStationLabel(Long id) { + return draftMapStationDirectionDAO.selectByPrimaryKey(id); + } + + @Override + public String saveStationLabel(Long mapId, DraftMapStationDirection vo) { + vo.setMapId(mapId); + if (!CollectionUtils.isEmpty(vo.getSectionList())) { + vo.setSectionsCode(String.join(",", vo.getSectionList())); + } + int line; + if (vo.getId() != null) { + line = draftMapStationDirectionDAO.updateByPrimaryKey(vo); + } else { + // 手动拼接Code + vo.setCode(vo.getStationCode() + "_" + vo.getLabelEnum()); + line = draftMapStationDirectionDAO.insert(vo); + } + return line != 0 ? "保存成功" : "保存失败"; + } + + @Override + public void deleteStationLabel(Long id) { + draftMapStationDirectionDAO.deleteByPrimaryKey(id); + } + + @Override + public List queryAllStationLabelByMapId(Long mapId) { + DraftMapStationDirectionExample draftMapStationDirectionExample = new DraftMapStationDirectionExample(); + DraftMapStationDirectionExample.Criteria criteria = draftMapStationDirectionExample.createCriteria(); + criteria.andMapIdEqualTo(mapId); + List list = draftMapStationDirectionDAO.selectByExample(draftMapStationDirectionExample); + list.forEach(DraftMapStationDirection::generateSectionList); + return list; + } +} diff --git a/src/main/java/club/joylink/rtss/services/draftData/IDraftMapStationDirectionService.java b/src/main/java/club/joylink/rtss/services/draftData/IDraftMapStationDirectionService.java new file mode 100644 index 000000000..043e19089 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/draftData/IDraftMapStationDirectionService.java @@ -0,0 +1,54 @@ +package club.joylink.rtss.services.draftData; + +import club.joylink.rtss.entity.DraftMapStationDirection; +import club.joylink.rtss.vo.client.PageQueryVO; +import club.joylink.rtss.vo.client.PageVO; + +import java.util.List; + +public interface IDraftMapStationDirectionService { + + /** + * 查询地图下车站 方向下的逻辑数据列表 + * + * @param mapId 地图ID + * @param code Code + * @param labelEnum 方向类型 + * @return 数据列表 + */ + PageVO stationLabelList(Long mapId, String code, String labelEnum, PageQueryVO queryVO); + + /** + * 查找该地图下的指示灯、区间、站台、进路关系信息 + * + * @param id 关系ID + * @return 关系信息 + */ + DraftMapStationDirection queryStationLabel(Long id); + + + /** + * 保存指示灯关系数据 + * + * @param mapId 地图ID + * @param vo 实体类 + * @return 保存结果 + */ + String saveStationLabel(Long mapId, DraftMapStationDirection vo); + + + /** + * 删除指示灯关系数据 + * + * @param id 关系ID + */ + void deleteStationLabel(Long id); + + /** + * 查找该地图下的指示灯、区间、站台、进路关系信息列表 + * + * @param mapId 地图Id + * @return 关系列表 + */ + List queryAllStationLabelByMapId(Long mapId); +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/ATSMessageCollectAndDispatcher.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/ATSMessageCollectAndDispatcher.java index ccae0b4d9..30d11550a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/ATSMessageCollectAndDispatcher.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/ATSMessageCollectAndDispatcher.java @@ -195,11 +195,9 @@ public class ATSMessageCollectAndDispatcher { case CATENARY: status = new CatenaryStatus((Catenary) device); break; - case INDICATOR: - status = new IndicatorStatus((Indicator) device); - break; - case BUTTON: - status = new ButtonStatus((Button) device); + + case STATION_DIRECTION: + status = new StationDirectionStatus((StationDirection) device); break; } return status; @@ -246,11 +244,8 @@ public class ATSMessageCollectAndDispatcher { status = new CatenaryStatusVO((Catenary) device); break; - case INDICATOR: - status = new IndicatorStatusVO((Indicator) device); - break; - case BUTTON: - status = new ButtonStatusVO((Button) device); + case STATION_DIRECTION: + status = new StationDirectionStatusVO((StationDirection) device); break; } return status; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/AssistOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationDirectionOperateHandler.java similarity index 65% rename from src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/AssistOperateHandler.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationDirectionOperateHandler.java index 31d2e1086..49657658f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/AssistOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationDirectionOperateHandler.java @@ -1,21 +1,21 @@ package club.joylink.rtss.simulation.cbtc.ATS.operation.handler; -import club.joylink.rtss.constants.ButtonTypeEnum; import club.joylink.rtss.constants.DirectionLabelEnum; import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler; import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping; -import club.joylink.rtss.simulation.cbtc.ATS.service.assist.AssistService; +import club.joylink.rtss.simulation.cbtc.ATS.service.assist.StationDirectionService; import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.map.Button; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @Slf4j @OperateHandler -public class AssistOperateHandler { +public class StationDirectionOperateHandler { @Autowired - private AssistService assistService; + private StationDirectionService stationDirectionService; /** * 改方按钮按下操作 @@ -26,9 +26,8 @@ public class AssistOperateHandler { */ @OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_DOWN_TURN_DIRECTION) public void pressDownTurnDirection(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum) { - assistService.changeButtonAspect(simulation, - stationCode, labelEnum, ButtonTypeEnum.CHANGE_DIRECTION, Boolean.TRUE - , assistService.turnDirectionPressDownValid - , assistService.turnDirectionPressDownDo); + stationDirectionService.changeButtonAspect(simulation, + stationCode, labelEnum, Button.ButtonTypeEnum.CHANGE_DIRECTION, Boolean.TRUE + , stationDirectionService.turnDirectionPressDownValid, null); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/AssistService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/AssistService.java deleted file mode 100644 index 5f4dc5d1c..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/AssistService.java +++ /dev/null @@ -1,297 +0,0 @@ -package club.joylink.rtss.simulation.cbtc.ATS.service.assist; - -import club.joylink.rtss.constants.ButtonTypeEnum; -import club.joylink.rtss.constants.DirectionLabelEnum; -import club.joylink.rtss.constants.IndicatorStatusEnum; -import club.joylink.rtss.constants.IndicatorTypeEnum; -import club.joylink.rtss.entity.IndicatorButton; -import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService; -import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.data.map.Button; -import club.joylink.rtss.simulation.cbtc.data.map.Indicator; -import club.joylink.rtss.simulation.cbtc.data.map.Station; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; -import club.joylink.rtss.simulation.cbtc.exception.SimulationException; -import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; -import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.util.Optional; - - -/** - * 工具箱操作service - */ -@Component -@Slf4j -public class AssistService { - @Autowired - private ATPService atpService; - - @Autowired - private CiRouteService routeService; - - /** - * 修改按钮状态信息 - * - * @param simulation 仿真数据 - * @param stationCode 车站编码 - * @param label 按钮类型 - * @param type 类型 - * @param pressDown true:按下,false:抬起 - * @param validMethod 操作检验 - * @param buttonDoMethod 操作后触发动作 - */ - public void changeButtonAspect(Simulation simulation, String stationCode, - DirectionLabelEnum label, ButtonTypeEnum type, boolean pressDown, - ButtonValidInterface validMethod, ButtonThenInterface buttonDoMethod) { - Station curStation = getStationByCode(simulation, stationCode); - Button curButton = getStationButtonByType(curStation, label, type); - // 检验操作 - if (validMethod != null) { - validMethod.valid(simulation, curButton); - } - // 修改状态 - curButton.setPressDown(pressDown); - // 后续动作 - if (buttonDoMethod != null) { - buttonDoMethod.doThen(simulation, curButton); - } - } - - /** - * 刷新区间灯状态 - */ - public void refreshSectionLightStatus(Simulation simulation, IndicatorButton indicatorButton) { - Indicator indicator = simulation.getRepository().getByCode(indicatorButton.getCode(), Indicator.class); - if (indicator == null || CollectionUtils.isEmpty(indicator.getSectionList())) { - return; - } - // 是否被占用,TRUE 未占用,FALSE 占用 - boolean isNotOccupied = indicator.getSectionList() - .stream() - .filter(section -> section.isOccupied()).findAny().isEmpty(); - // 占用为红色 - IndicatorStatusEnum statusEnum = isNotOccupied ? IndicatorStatusEnum.No : IndicatorStatusEnum.R; - // 占用点亮时,灭掉改方按钮 - if (IndicatorStatusEnum.R.equals(statusEnum)) { - indicator.getStation().getButtonsList() - .stream() - .filter(button -> indicator.getLabel().equals(button.getLabel()) && ButtonTypeEnum.CHANGE_DIRECTION.equals(button.getType())) - .forEach(button -> button.setPressDown(false)); - } - - indicator.setAspect(statusEnum); - } - - /** - * 各方向接、发车电灯状态刷新 - * - * @param curStation 当前站 - * @param labelEnum 方向标签 - */ - public void refreshReceiveAndDeliverLightStatus(Station curStation, DirectionLabelEnum labelEnum) { - // 获取接车指示灯 - Indicator receiveIndicator = getStationIndicatorByType(curStation, labelEnum, IndicatorTypeEnum.RECEIVE); - // 获取发车指示灯 - Indicator deliverIndicator = getStationIndicatorByType(curStation, labelEnum, IndicatorTypeEnum.DELIVER); - // 如果都没有亮 - if (deliverIndicator != null && receiveIndicator != null && !deliverIndicator.isOn() && !receiveIndicator.isOn()) { - // X、S方向为接车方向默认亮起 - if (DirectionLabelEnum.X.equals(labelEnum) || DirectionLabelEnum.S.equals(labelEnum)) { - receiveIndicator.setOn(true); - } else { // 其他方向默认发车灯亮起 - deliverIndicator.setOn(true); - } - } - IndicatorStatusEnum receiveStatus = getRDIndicatorStatusEnum(receiveIndicator, deliverIndicator); - IndicatorStatusEnum deliverStatus = getRDIndicatorStatusEnum(deliverIndicator, receiveIndicator); - if (receiveIndicator != null) { - receiveIndicator.setAspect(receiveStatus); - } - if (deliverIndicator != null) { - deliverIndicator.setAspect(deliverStatus); - } - } - - /** - * 改方按钮按下校验 - */ - public ButtonValidInterface turnDirectionPressDownValid = (simulation, button) -> { - if (button == null) { - throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:按钮不存在"); - } - if (button.getStand() == null) { - throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:按钮未绑定站台"); - } - // 由数据控制,不做逻辑判断 -// List stationList = simulation.getRepository().getStationList(); -// // 当前站位置 -// int index = stationList.indexOf(button.getStation()); -// // 检查是否是首站 -// if (index == 0 || index == stationList.size() - 1) { -// throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:首站不可改方"); -// } - // 获取区间指示灯 - Indicator sectionIndicator = getStationIndicatorByType(button.getStation(), button.getLabel(), IndicatorTypeEnum.SECTION); - // 获取区间路径,判断本站台与相邻站台是否空闲 - if (sectionIndicator != null && IndicatorStatusEnum.R.equals(sectionIndicator.getAspect())) { - throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:区段非空闲"); - } - // 判断接车灯进路是否办理 - Indicator receiveIndicator = getStationIndicatorByType(button.getStation(), button.getLabel(), IndicatorTypeEnum.RECEIVE); - if (receiveIndicator != null && receiveIndicator.getRoute() != null && receiveIndicator.getRoute().isLock()) { - throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:进路冲突"); - } - // 获取靠停列车 - VirtualRealityTrain train = getSandStopTrain(simulation, button.getStand().getSection().getCode()); - if (train == null || !train.isStop()) { - throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:未停靠列车"); - } - // 判断本站台是否是接车站台,这里不做判断,在改方实际操作时,判断列车 -// boolean isReceive = button.getStand().isRight() == train.isRight(); -// if (!isReceive) { -// throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:非接车方向"); -// } - }; - - /** - * 改方按钮后续操作 - */ - public ButtonThenInterface turnDirectionPressDownDo = (simulation, button) -> { - if (button == null) { - throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:按钮不存在"); - } - // 相邻站台是否也为接车状态,如果是要做辅助操作(目前不做) - // 获取靠停列车 - VirtualRealityTrain train = getSandStopTrain(simulation, button.getStand().getSection().getCode()); - if (train == null || !train.isStop()) { - throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:未停靠列车"); - } - // 判断列车是否要执行换端 - if (button.getStand().isRight() == train.isRight()) { - // 列车换端 - atpService.turnDirectionImmediately(train); - } - // 获取发车指示灯 - Indicator deliverIndicator = getStationIndicatorByType(button.getStation(), button.getLabel(), IndicatorTypeEnum.DELIVER); - // 办进路 - routeService.setRoute(simulation, deliverIndicator.getRoute()); - }; - - /** - * 获取当前车站实体 - * - * @param simulation 仿真实体数据 - * @param stationCode 车站编码 - * @return 车站实体 - */ - private Station getStationByCode(Simulation simulation, String stationCode) { - Optional stationOptional = simulation.getRepository().getStationList() - .stream() - .filter(station -> stationCode.equals(station.getCode())) - .findFirst(); - // 当前所在车站 - Station station; - if (stationOptional.isPresent()) { - station = stationOptional.get(); - } else { - throw new SimulationException(SimulationExceptionType.System_Fault, "操作异常:车站不存在"); - } - return station; - } - - /** - * 获取当前按钮实体 - * - * @param station 车站编码 - * @param label 按钮类型 - * @param type 类型 - * @return 操作按钮实体 - */ - private Button getStationButtonByType(Station station, DirectionLabelEnum label, ButtonTypeEnum type) { - Optional