From 4015a5f2fd84c027411922c8822fb11f9daaf8c9 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Mon, 19 Sep 2022 15:05:58 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87=E5=9C=B0=E5=9B=BE=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E6=95=B0=E6=8D=AE=E5=AD=98=E5=82=A8=E8=B0=83=E5=BA=A6?= =?UTF-8?q?=E5=8F=B0=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/20220919-xia-draft_map_dis_station.sql | 33 ++ .../draft/DraftMapDisStationController.java | 42 ++ .../rtss/dao/DraftMapDisStationDAO.java | 34 ++ .../rtss/entity/DraftMapDisStation.java | 38 ++ .../entity/DraftMapDisStationExample.java | 552 ++++++++++++++++++ .../rtss/services/DraftMapService.java | 19 +- .../draftData/DraftMapDisStationService.java | 118 ++++ .../cbtc/build/MapDeviceBuilder.java | 13 +- .../cbtc/build/SimulationBuilder.java | 6 +- .../simulation/cbtc/data/map/DisStation.java | 20 +- .../rtss/vo/map/MapGraphDataNewVO.java | 10 +- .../rtss/vo/map/MapLogicDataNewVO.java | 9 +- .../rtss/vo/map/graph/MapDisStationNewVO.java | 30 - .../rtss/vo/map/logic/MapDisStationNewVO.java | 43 ++ .../mybatis/mapper/DraftMapDisStationDAO.xml | 219 +++++++ 15 files changed, 1123 insertions(+), 63 deletions(-) create mode 100644 sql/20220919-xia-draft_map_dis_station.sql create mode 100644 src/main/java/club/joylink/rtss/controller/draft/DraftMapDisStationController.java create mode 100644 src/main/java/club/joylink/rtss/dao/DraftMapDisStationDAO.java create mode 100644 src/main/java/club/joylink/rtss/entity/DraftMapDisStation.java create mode 100644 src/main/java/club/joylink/rtss/entity/DraftMapDisStationExample.java create mode 100644 src/main/java/club/joylink/rtss/services/draftData/DraftMapDisStationService.java delete mode 100644 src/main/java/club/joylink/rtss/vo/map/graph/MapDisStationNewVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/map/logic/MapDisStationNewVO.java create mode 100644 src/main/resources/mybatis/mapper/DraftMapDisStationDAO.xml diff --git a/sql/20220919-xia-draft_map_dis_station.sql b/sql/20220919-xia-draft_map_dis_station.sql new file mode 100644 index 000000000..986e6a346 --- /dev/null +++ b/sql/20220919-xia-draft_map_dis_station.sql @@ -0,0 +1,33 @@ +/* + Navicat Premium Data Transfer + + Source Server : room + Source Server Type : MySQL + Source Server Version : 80029 + Source Host : 192.168.3.233:3306 + Source Schema : joylink + + Target Server Type : MySQL + Target Server Version : 80029 + File Encoding : 65001 + + Date: 19/09/2022 14:54:30 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for draft_map_dis_station +-- ---------------------------- +DROP TABLE IF EXISTS `draft_map_dis_station`; +CREATE TABLE `draft_map_dis_station` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '调度台逻辑数据记录id', + `map_id` bigint NULL DEFAULT NULL COMMENT '所属地图id', + `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '调度台编码', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '调度台名称', + `station_list` varchar(600) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '调度台下辖车站的code列表,array json', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapDisStationController.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapDisStationController.java new file mode 100644 index 000000000..b3462bcda --- /dev/null +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapDisStationController.java @@ -0,0 +1,42 @@ +package club.joylink.rtss.controller.draft; + +import club.joylink.rtss.services.draftData.DraftMapDisStationService; +import club.joylink.rtss.vo.map.logic.MapDisStationNewVO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 草稿地图 调度台 接口 + *

+ * 接口中路径参数id 为 mapId + */ +@RestController +@RequestMapping("/api/draftMap/{id}/disStation") +@Slf4j +public class DraftMapDisStationController { + @Autowired + private DraftMapDisStationService draftMapDisStationService; + + /** + * 创建调度台逻辑数据 + */ + @PostMapping + public void create(@RequestBody MapDisStationNewVO disStationNewVO){ + this.draftMapDisStationService.create(disStationNewVO); + } + /** + * 更新调度台业务 + */ + @PutMapping + public void update(@RequestBody MapDisStationNewVO vo){ + this.draftMapDisStationService.update(vo); + } + /** + * 删除调度台业务 + */ + @DeleteMapping("/{code}") + public void delete(@PathVariable("id") Long mapId,@PathVariable("code") String code){ + this.draftMapDisStationService.delete(mapId,code); + } +} diff --git a/src/main/java/club/joylink/rtss/dao/DraftMapDisStationDAO.java b/src/main/java/club/joylink/rtss/dao/DraftMapDisStationDAO.java new file mode 100644 index 000000000..341e68cb8 --- /dev/null +++ b/src/main/java/club/joylink/rtss/dao/DraftMapDisStationDAO.java @@ -0,0 +1,34 @@ +package club.joylink.rtss.dao; + +import club.joylink.rtss.entity.DraftMapDisStation; +import club.joylink.rtss.entity.DraftMapDisStationExample; +import java.util.List; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +@Mapper +@Repository +public interface DraftMapDisStationDAO { + long countByExample(DraftMapDisStationExample example); + + int deleteByExample(DraftMapDisStationExample example); + + int deleteByPrimaryKey(Long id); + + int insert(DraftMapDisStation record); + + int insertSelective(DraftMapDisStation record); + + List selectByExample(DraftMapDisStationExample example); + + DraftMapDisStation selectByPrimaryKey(Long id); + + int updateByExampleSelective(@Param("record") DraftMapDisStation record, @Param("example") DraftMapDisStationExample example); + + int updateByExample(@Param("record") DraftMapDisStation record, @Param("example") DraftMapDisStationExample example); + + int updateByPrimaryKeySelective(DraftMapDisStation record); + + int updateByPrimaryKey(DraftMapDisStation record); +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/DraftMapDisStation.java b/src/main/java/club/joylink/rtss/entity/DraftMapDisStation.java new file mode 100644 index 000000000..a0834f635 --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/DraftMapDisStation.java @@ -0,0 +1,38 @@ +package club.joylink.rtss.entity; + +import java.io.Serializable; +import lombok.Data; + +/** + * @author + * + */ +@Data +public class DraftMapDisStation implements Serializable { + /** + * 调度台逻辑数据记录id + */ + private Long id; + + /** + * 所属地图id + */ + private Long mapId; + + /** + * 调度台编码 + */ + private String code; + + /** + * 调度台名称 + */ + private String name; + + /** + * 调度台下辖车站的code列表,array json + */ + private String stationList; + + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/club/joylink/rtss/entity/DraftMapDisStationExample.java b/src/main/java/club/joylink/rtss/entity/DraftMapDisStationExample.java new file mode 100644 index 000000000..223a7545d --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/DraftMapDisStationExample.java @@ -0,0 +1,552 @@ +package club.joylink.rtss.entity; + +import java.util.ArrayList; +import java.util.List; + +public class DraftMapDisStationExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public DraftMapDisStationExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getLimit() { + return limit; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public Long getOffset() { + return offset; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andMapIdIsNull() { + addCriterion("map_id is null"); + return (Criteria) this; + } + + public Criteria andMapIdIsNotNull() { + addCriterion("map_id is not null"); + return (Criteria) this; + } + + public Criteria andMapIdEqualTo(Long value) { + addCriterion("map_id =", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdNotEqualTo(Long value) { + addCriterion("map_id <>", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdGreaterThan(Long value) { + addCriterion("map_id >", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdGreaterThanOrEqualTo(Long value) { + addCriterion("map_id >=", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdLessThan(Long value) { + addCriterion("map_id <", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdLessThanOrEqualTo(Long value) { + addCriterion("map_id <=", value, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdIn(List values) { + addCriterion("map_id in", values, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdNotIn(List values) { + addCriterion("map_id not in", values, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdBetween(Long value1, Long value2) { + addCriterion("map_id between", value1, value2, "mapId"); + return (Criteria) this; + } + + public Criteria andMapIdNotBetween(Long value1, Long value2) { + addCriterion("map_id not between", value1, value2, "mapId"); + return (Criteria) this; + } + + public Criteria andCodeIsNull() { + addCriterion("code is null"); + return (Criteria) this; + } + + public Criteria andCodeIsNotNull() { + addCriterion("code is not null"); + return (Criteria) this; + } + + public Criteria andCodeEqualTo(String value) { + addCriterion("code =", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotEqualTo(String value) { + addCriterion("code <>", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeGreaterThan(String value) { + addCriterion("code >", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeGreaterThanOrEqualTo(String value) { + addCriterion("code >=", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLessThan(String value) { + addCriterion("code <", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLessThanOrEqualTo(String value) { + addCriterion("code <=", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLike(String value) { + addCriterion("code like", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotLike(String value) { + addCriterion("code not like", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeIn(List values) { + addCriterion("code in", values, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotIn(List values) { + addCriterion("code not in", values, "code"); + return (Criteria) this; + } + + public Criteria andCodeBetween(String value1, String value2) { + addCriterion("code between", value1, value2, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotBetween(String value1, String value2) { + addCriterion("code not between", value1, value2, "code"); + return (Criteria) this; + } + + public Criteria andNameIsNull() { + addCriterion("`name` is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("`name` is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("`name` =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("`name` <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("`name` >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("`name` >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("`name` <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("`name` <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("`name` like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("`name` not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("`name` in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("`name` not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("`name` between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("`name` not between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andStationListIsNull() { + addCriterion("station_list is null"); + return (Criteria) this; + } + + public Criteria andStationListIsNotNull() { + addCriterion("station_list is not null"); + return (Criteria) this; + } + + public Criteria andStationListEqualTo(String value) { + addCriterion("station_list =", value, "stationList"); + return (Criteria) this; + } + + public Criteria andStationListNotEqualTo(String value) { + addCriterion("station_list <>", value, "stationList"); + return (Criteria) this; + } + + public Criteria andStationListGreaterThan(String value) { + addCriterion("station_list >", value, "stationList"); + return (Criteria) this; + } + + public Criteria andStationListGreaterThanOrEqualTo(String value) { + addCriterion("station_list >=", value, "stationList"); + return (Criteria) this; + } + + public Criteria andStationListLessThan(String value) { + addCriterion("station_list <", value, "stationList"); + return (Criteria) this; + } + + public Criteria andStationListLessThanOrEqualTo(String value) { + addCriterion("station_list <=", value, "stationList"); + return (Criteria) this; + } + + public Criteria andStationListLike(String value) { + addCriterion("station_list like", value, "stationList"); + return (Criteria) this; + } + + public Criteria andStationListNotLike(String value) { + addCriterion("station_list not like", value, "stationList"); + return (Criteria) this; + } + + public Criteria andStationListIn(List values) { + addCriterion("station_list in", values, "stationList"); + return (Criteria) this; + } + + public Criteria andStationListNotIn(List values) { + addCriterion("station_list not in", values, "stationList"); + return (Criteria) this; + } + + public Criteria andStationListBetween(String value1, String value2) { + addCriterion("station_list between", value1, value2, "stationList"); + return (Criteria) this; + } + + public Criteria andStationListNotBetween(String value1, String value2) { + addCriterion("station_list not between", value1, value2, "stationList"); + return (Criteria) this; + } + } + + /** + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/services/DraftMapService.java b/src/main/java/club/joylink/rtss/services/DraftMapService.java index 9322f9b6a..2e0350103 100644 --- a/src/main/java/club/joylink/rtss/services/DraftMapService.java +++ b/src/main/java/club/joylink/rtss/services/DraftMapService.java @@ -4,10 +4,7 @@ import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.dao.*; 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.services.draftData.*; import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder; import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.map.Section; @@ -101,6 +98,9 @@ public class DraftMapService implements IDraftMapService { @Autowired private IDraftMapStationDirectionService draftMapStationDirectionLabelService; + @Autowired + private DraftMapDisStationService draftMapDisStationService; + @Override public List list(AccountVO accountVO) { DraftMapExample example = new DraftMapExample(); @@ -444,7 +444,9 @@ public class DraftMapService implements IDraftMapService { private MapLogicDataNewVO getMapLogicDataNew(Long id) { MapLogicDataNewVO logicDataVO = new MapLogicDataNewVO(); - + // 调度台逻辑数据 + List disStationNewList = draftMapDisStationService.getAll(id); + logicDataVO.setDisStationList(disStationNewList); // 进路 DraftMapRouteExample routeExample = new DraftMapRouteExample(); routeExample.createCriteria().andMapIdEqualTo(id); @@ -520,6 +522,13 @@ public class DraftMapService implements IDraftMapService { if (Objects.isNull(logicDataVO)) { return; } + //调度台 + if (!CollectionUtils.isEmpty(logicDataVO.getDisStationList())){ + logicDataVO.getDisStationList().forEach(mapDisStationVo->{ + mapDisStationVo.setMapId(id); + draftMapDisStationService.store(mapDisStationVo); + }); + } if (!CollectionUtils.isEmpty(logicDataVO.getRouteList())) { logicDataVO.getRouteList().forEach(mapRouteVO -> { mapRouteVO.setMapId(id); diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapDisStationService.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapDisStationService.java new file mode 100644 index 000000000..a7e2edc1f --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapDisStationService.java @@ -0,0 +1,118 @@ +package club.joylink.rtss.services.draftData; + +import club.joylink.rtss.dao.DraftMapDisStationDAO; +import club.joylink.rtss.entity.DraftMapDisStation; +import club.joylink.rtss.entity.DraftMapDisStationExample; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.map.logic.MapDisStationNewVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class DraftMapDisStationService { + @Autowired + private DraftMapDisStationDAO draftMapDisStationDAO; + + /** + * 新建调度台业务 + */ + @Transactional(rollbackFor = Exception.class) + public void create(MapDisStationNewVO vo){ + List find = this.findByMapIdAndCode(vo.getMapId(),vo.getCode()); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(CollectionUtils.isEmpty(find), String.format("草稿[mapId=%s code=%s]调度台逻辑数据已经存在",vo.getMapId(),vo.getCode())); + DraftMapDisStation entity = convert(vo); + draftMapDisStationDAO.insertSelective(entity); + } + /** + * 存储 + */ + @Transactional(rollbackFor = Exception.class) + public void store(MapDisStationNewVO vo){ + List find = this.findByMapIdAndCode(vo.getMapId(),vo.getCode()); + if(CollectionUtils.isEmpty(find)){ + DraftMapDisStation entity = convert(vo); + this.draftMapDisStationDAO.insert(entity); + }else{ + DraftMapDisStation entity = convert(vo); + entity.setId(find.get(0).getId()); + this.draftMapDisStationDAO.updateByPrimaryKey(entity); + } + } + /** + * 更新调度台业务 + */ + @Transactional(rollbackFor = Exception.class) + public void update(MapDisStationNewVO vo){ + List find = this.findByMapIdAndCode(vo.getMapId(),vo.getCode()); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != find && find.size()==1, String.format("草稿[mapId=%s code=%s]调度台逻辑数据不存在或不唯一",vo.getMapId(),vo.getCode())); + DraftMapDisStation entity = convert(vo); + entity.setId(find.get(0).getId()); + // + this.draftMapDisStationDAO.updateByPrimaryKeySelective(entity); + } + /** + * 删除调度台业务 + */ + @Transactional(rollbackFor = Exception.class) + public void delete(Long mapId,String code){ + DraftMapDisStationExample example = new DraftMapDisStationExample(); + example.createCriteria().andMapIdEqualTo(mapId).andCodeEqualTo(code); + this.draftMapDisStationDAO.deleteByExample(example); + } + @Transactional(readOnly = true) + public MapDisStationNewVO getByMapIdAndCode(Long mapId, String code){ + List list = this.findByMapIdAndCode(mapId,code); + if(!CollectionUtils.isEmpty(list)){ + DraftMapDisStation entity = list.get(0); + return convert(entity); + } + return null; + } + @Transactional(readOnly = true) + public List getAll(Long mapId){ + List list = new ArrayList<>(); + DraftMapDisStationExample example = new DraftMapDisStationExample(); + example.createCriteria().andMapIdEqualTo(mapId); + List find = draftMapDisStationDAO.selectByExample(example); + if(!CollectionUtils.isEmpty(find)){ + find.forEach(entity->{ + list.add(convert(entity)); + }); + } + return list; + } + @Transactional(readOnly = true) + private List findByMapIdAndCode(Long mapId, String code){ + DraftMapDisStationExample example = new DraftMapDisStationExample(); + example.createCriteria().andMapIdEqualTo(mapId).andCodeEqualTo(code); + return draftMapDisStationDAO.selectByExample(example); + } + + ////////////////////////////////////////////////////////////////////// + public static MapDisStationNewVO convert(DraftMapDisStation from){ + MapDisStationNewVO vo = new MapDisStationNewVO(); + vo.setId(from.getId()); + vo.setCode(from.getCode()); + vo.setMapId(from.getMapId()); + vo.setStationList(JsonUtils.readCollection(from.getStationList(),ArrayList.class,String.class)); + vo.setName(from.getName()); + return vo; + } + public static DraftMapDisStation convert(MapDisStationNewVO from){ + DraftMapDisStation entity = new DraftMapDisStation(); + if(null!=from.getId()){ + entity.setId(from.getId()); + } + entity.setMapId(from.getMapId()); + entity.setCode(from.getCode()); + entity.setName(from.getName()); + entity.setStationList(JsonUtils.writeValueAsString(from.getStationList())); + return entity; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java index 3c6b3aaf1..38d4f53f5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java @@ -8,7 +8,10 @@ import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.support.StationTurnBackStrategyOption; import club.joylink.rtss.simulation.cbtc.data.vr.*; import club.joylink.rtss.vo.map.MapGraphDataNewVO; +import club.joylink.rtss.vo.map.MapLogicDataNewVO; +import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.map.graph.*; +import club.joylink.rtss.vo.map.logic.MapDisStationNewVO; import lombok.extern.slf4j.Slf4j; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; @@ -26,7 +29,8 @@ public class MapDeviceBuilder { /** * 校验并构建设备数据 */ - static void checkAndBuildMapDeviceData(MapGraphDataNewVO graphData, SimulationBuilder.SimulationDeviceBuildResult mapDataBuildResult) { + static void checkAndBuildMapDeviceData(MapVO mapVo, SimulationBuilder.SimulationDeviceBuildResult mapDataBuildResult) { + final MapGraphDataNewVO graphData = mapVo.getGraphDataNew(); Map elementMap = mapDataBuildResult.getDeviceMap(); Map deviceMap = mapDataBuildResult.getVrDeviceMap(); List errMsgList = mapDataBuildResult.getErrMsgList(); @@ -38,7 +42,7 @@ public class MapDeviceBuilder { // 车站 MapDeviceBuilder.buildStation(graphData, elementMap, deviceMap, errMsgList); // 调度台 - MapDeviceBuilder.buildDisStation(graphData,elementMap,errMsgList); + MapDeviceBuilder.buildDisStation(mapVo.getLogicDataNew().getDisStationList(),elementMap,errMsgList); // 区段 List sectionList = graphData.getSectionList(); MapDeviceBuilder.buildSections(elementMap, deviceMap, errMsgList, sectionList); @@ -739,10 +743,9 @@ public class MapDeviceBuilder { /** * 构建调度台 */ - private static List buildDisStation(MapGraphDataNewVO graphData, Map elementMap, List errMsgList){ - List disStationList = graphData.getDisStationList(); + private static List buildDisStation(List disStationList, Map elementMap, List errMsgList){ disStationList.forEach(disStationVo->{ - DisStation disStation = new DisStation(disStationVo.getCode(),disStationVo.getName(), MapElement.DeviceType.DIS_STATION); + DisStation disStation = new DisStation(disStationVo.getCode(),disStationVo.getName()); if (Objects.nonNull(elementMap.get(disStationVo.getCode()))) { errMsgList.add(String.format("编码为[%s]的调度台不唯一", disStationVo.getCode())); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java index 94eb3a7c0..864546fe3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java @@ -537,7 +537,7 @@ public class SimulationBuilder { */ public static SimulationDeviceBuildResult checkAndBuildBasicMapData(MapVO map) { SimulationDeviceBuildResult mapDataBuildResult = new SimulationDeviceBuildResult(); - MapDeviceBuilder.checkAndBuildMapDeviceData(map.getGraphDataNew(), mapDataBuildResult); + MapDeviceBuilder.checkAndBuildMapDeviceData(map, mapDataBuildResult); return mapDataBuildResult; } @@ -549,7 +549,7 @@ public class SimulationBuilder { */ public static SimulationDeviceBuildResult checkAndBuildMapData(MapVO map) { SimulationDeviceBuildResult mapDataBuildResult = new SimulationDeviceBuildResult(); - MapDeviceBuilder.checkAndBuildMapDeviceData(map.getGraphDataNew(), mapDataBuildResult); + MapDeviceBuilder.checkAndBuildMapDeviceData(map, mapDataBuildResult); if (CollectionUtils.isEmpty(mapDataBuildResult.getErrMsgList())) { // 基础数据没有问题,再构建逻辑数据 // InterlockBuilder.checkAndBuildMapCILogicData(map.getLogicDataNew(), mapDataBuildResult); InterlockBuilder2.checkAndBuildMapCILogicData(map, mapDataBuildResult); @@ -563,7 +563,7 @@ public class SimulationBuilder { public static SimulationDeviceBuildResult checkAndBuildMapDeviceData(MapVO map) { SimulationDeviceBuildResult mapDataBuildResult = new SimulationDeviceBuildResult(); - MapDeviceBuilder.checkAndBuildMapDeviceData(map.getGraphDataNew(), mapDataBuildResult); + MapDeviceBuilder.checkAndBuildMapDeviceData(map, mapDataBuildResult); return mapDataBuildResult; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/DisStation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/DisStation.java index 672694d83..baad064d4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/DisStation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/DisStation.java @@ -2,20 +2,20 @@ package club.joylink.rtss.simulation.cbtc.data.map; import lombok.Getter; import lombok.Setter; + import java.util.ArrayList; import java.util.List; -/** - * 调度台 - */ @Getter @Setter -public class DisStation extends MayOutOfOrderDevice{ - public DisStation(String code, String name, DeviceType deviceType) { - super(code, name, deviceType); +public class DisStation extends MapNamedElement{ + private List stationList = new ArrayList<>(); + public DisStation(String code,String name){ + super(code,name, DeviceType.DIS_STATION); + } + + @Override + public void reset() { + } - /** - * 调度台下辖车站 - */ - private List stationList = new ArrayList<>(); } diff --git a/src/main/java/club/joylink/rtss/vo/map/MapGraphDataNewVO.java b/src/main/java/club/joylink/rtss/vo/map/MapGraphDataNewVO.java index 942e580b5..22686147f 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapGraphDataNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/MapGraphDataNewVO.java @@ -1,11 +1,10 @@ package club.joylink.rtss.vo.map; -import club.joylink.rtss.entity.Ibp; import club.joylink.rtss.util.JsonUtils; -import club.joylink.rtss.vo.client.ibp.IbpVO; import club.joylink.rtss.vo.map.display.DisplayVO; import club.joylink.rtss.vo.map.display.PictureVO; import club.joylink.rtss.vo.map.graph.*; +import club.joylink.rtss.vo.map.logic.MapDisStationNewVO; import lombok.Getter; import lombok.Setter; import org.springframework.util.StringUtils; @@ -79,12 +78,6 @@ public class MapGraphDataNewVO { @Valid private List signalList; - /** - *调度台列表 - */ - @Valid - private List disStationList; - /** *车站列表 */ @@ -267,7 +260,6 @@ public class MapGraphDataNewVO { this.arrowList = new ArrayList<>(); this.directionRodList = new ArrayList<>(); this.responderList = new ArrayList<>(); - this.disStationList = new ArrayList<>(); } public static MapGraphDataNewVO parse(String graphData) { diff --git a/src/main/java/club/joylink/rtss/vo/map/MapLogicDataNewVO.java b/src/main/java/club/joylink/rtss/vo/map/MapLogicDataNewVO.java index c4576cfad..d02c5966f 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapLogicDataNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/MapLogicDataNewVO.java @@ -2,11 +2,13 @@ package club.joylink.rtss.vo.map; import club.joylink.rtss.entity.DraftMapStationDirection; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.vo.map.logic.MapDisStationNewVO; import club.joylink.rtss.vo.map.logic.*; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.Setter; +import javax.validation.Valid; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -15,7 +17,11 @@ import java.util.List; @Getter @Setter public class MapLogicDataNewVO { - + /** + * 调度台列表 + */ + @Valid + private List disStationList; /** * 进路数据列表 */ @@ -89,6 +95,7 @@ public class MapLogicDataNewVO { overrunList = new ArrayList<>(); autoReentryList = new ArrayList<>(); draftMapStationDirectionList = new ArrayList<>(); + disStationList = new ArrayList<>(); } @JsonIgnore diff --git a/src/main/java/club/joylink/rtss/vo/map/graph/MapDisStationNewVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapDisStationNewVO.java deleted file mode 100644 index d75016078..000000000 --- a/src/main/java/club/joylink/rtss/vo/map/graph/MapDisStationNewVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package club.joylink.rtss.vo.map.graph; - -import lombok.Getter; -import lombok.Setter; -import javax.validation.constraints.NotBlank; -import java.util.List; - -/** - * 调度台 - */ -@Getter -@Setter -public class MapDisStationNewVO { - /** - * 编码 - */ - @NotBlank(message="编码不能为空") - private String code; - /** - * 名称 - */ - @NotBlank(message="名称不能为空") - private String name; - - /** - * 下辖车站 - */ - @NotBlank(message="下辖车站编码不能为空") - private List stationList; -} diff --git a/src/main/java/club/joylink/rtss/vo/map/logic/MapDisStationNewVO.java b/src/main/java/club/joylink/rtss/vo/map/logic/MapDisStationNewVO.java new file mode 100644 index 000000000..f96b9e563 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/map/logic/MapDisStationNewVO.java @@ -0,0 +1,43 @@ +package club.joylink.rtss.vo.map.logic; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Getter; +import lombok.Setter; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +/** + * 调度台 + */ +@Getter +@Setter +public class MapDisStationNewVO { + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + /** + * 所属地图ID + */ + @JsonSerialize(using = ToStringSerializer.class) + @NotNull(message = "地图id不能为空") + private Long mapId; + /** + * 调度台编码 + */ + @NotBlank(message="编码不能为空") + private String code; + /** + * 调度台名称 + */ + @NotBlank(message="名称不能为空") + private String name; + + /** + * 调度台下辖车站 + */ + @NotBlank(message="下辖车站编码不能为空") + private List stationList = new ArrayList<>(); +} diff --git a/src/main/resources/mybatis/mapper/DraftMapDisStationDAO.xml b/src/main/resources/mybatis/mapper/DraftMapDisStationDAO.xml new file mode 100644 index 000000000..63726199d --- /dev/null +++ b/src/main/resources/mybatis/mapper/DraftMapDisStationDAO.xml @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, map_id, code, `name`, station_list + + + + + delete from draft_map_dis_station + where id = #{id,jdbcType=BIGINT} + + + delete from draft_map_dis_station + + + + + + insert into draft_map_dis_station (id, map_id, code, + `name`, station_list) + values (#{id,jdbcType=BIGINT}, #{mapId,jdbcType=BIGINT}, #{code,jdbcType=VARCHAR}, + #{name,jdbcType=VARCHAR}, #{stationList,jdbcType=VARCHAR}) + + + insert into draft_map_dis_station + + + id, + + + map_id, + + + code, + + + `name`, + + + station_list, + + + + + #{id,jdbcType=BIGINT}, + + + #{mapId,jdbcType=BIGINT}, + + + #{code,jdbcType=VARCHAR}, + + + #{name,jdbcType=VARCHAR}, + + + #{stationList,jdbcType=VARCHAR}, + + + + + + update draft_map_dis_station + + + id = #{record.id,jdbcType=BIGINT}, + + + map_id = #{record.mapId,jdbcType=BIGINT}, + + + code = #{record.code,jdbcType=VARCHAR}, + + + `name` = #{record.name,jdbcType=VARCHAR}, + + + station_list = #{record.stationList,jdbcType=VARCHAR}, + + + + + + + + update draft_map_dis_station + set id = #{record.id,jdbcType=BIGINT}, + map_id = #{record.mapId,jdbcType=BIGINT}, + code = #{record.code,jdbcType=VARCHAR}, + `name` = #{record.name,jdbcType=VARCHAR}, + station_list = #{record.stationList,jdbcType=VARCHAR} + + + + + + update draft_map_dis_station + + + map_id = #{mapId,jdbcType=BIGINT}, + + + code = #{code,jdbcType=VARCHAR}, + + + `name` = #{name,jdbcType=VARCHAR}, + + + station_list = #{stationList,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=BIGINT} + + + update draft_map_dis_station + set map_id = #{mapId,jdbcType=BIGINT}, + code = #{code,jdbcType=VARCHAR}, + `name` = #{name,jdbcType=VARCHAR}, + station_list = #{stationList,jdbcType=VARCHAR} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file