diff --git a/libs/iscs-message-0.0.1-SNAPSHOT.jar b/libs/iscs-message-0.0.1-SNAPSHOT.jar new file mode 100644 index 000000000..caa5b6cf2 Binary files /dev/null and b/libs/iscs-message-0.0.1-SNAPSHOT.jar differ diff --git a/pom.xml b/pom.xml index 92ac12d8b..4b185aee5 100644 --- a/pom.xml +++ b/pom.xml @@ -140,6 +140,19 @@ pinyin4j 2.5.0 + + + com.google.protobuf + protobuf-java + 3.19.3 + + + club.joylink + iscs-message + 0.0.1-SNAPSHOT + system + ${project.basedir}/libs/iscs-message-0.0.1-SNAPSHOT.jar + diff --git a/sql/20221012-xia-paper.sql b/sql/20221012-xia-paper.sql index 5fe745c7e..7f2cb09d9 100644 --- a/sql/20221012-xia-paper.sql +++ b/sql/20221012-xia-paper.sql @@ -25,7 +25,7 @@ CREATE TABLE `rts_paper_composition` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '试卷蓝图id', `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '试卷蓝图名称', `profile` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '试卷蓝图简介', - `map_id` bigint DEFAULT NULL COMMENT '对应的mapId', + `map_id` bigint NOT NULL COMMENT '对应的mapId', `org_id` bigint DEFAULT NULL COMMENT '组织id', `start_time` datetime DEFAULT NULL COMMENT '启用起始时间', `end_time` datetime DEFAULT NULL COMMENT '启用截止时间', diff --git a/sql/20221205-xia-rts_iscs_model_data.sql b/sql/20221205-xia-rts_iscs_model_data.sql new file mode 100644 index 000000000..6ad301d6a --- /dev/null +++ b/sql/20221205-xia-rts_iscs_model_data.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: 05/12/2022 09:17:49 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for rts_iscs_model_data +-- ---------------------------- +DROP TABLE IF EXISTS `rts_iscs_model_data`; +CREATE TABLE `rts_iscs_model_data` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'iscs数据模型id', + `system` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'iscs一级系统(如FAS、PIS、AFC等)', + `view` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'iscs二级视图', + `place` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '场所(车站、变电所、停车场等)', + `data` blob NULL COMMENT '场所整个所有的模型的数据', + 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/RtssApplication.java b/src/main/java/club/joylink/rtss/RtssApplication.java index 313ebf25c..54f2efe11 100644 --- a/src/main/java/club/joylink/rtss/RtssApplication.java +++ b/src/main/java/club/joylink/rtss/RtssApplication.java @@ -9,7 +9,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication @EnableScheduling @EnableCaching -@MapperScan(basePackages = {"club.joylink.rtss.dao"}) +@MapperScan(basePackages = {"club.joylink.rtss.dao","club.joylink.rtss.iscs.dao"}) //@EnableRetry public class RtssApplication { diff --git a/src/main/java/club/joylink/rtss/controller/advice/CommonResponseBody.java b/src/main/java/club/joylink/rtss/controller/advice/CommonResponseBody.java index 410ac9fdf..7254fd4b2 100644 --- a/src/main/java/club/joylink/rtss/controller/advice/CommonResponseBody.java +++ b/src/main/java/club/joylink/rtss/controller/advice/CommonResponseBody.java @@ -33,6 +33,10 @@ public class CommonResponseBody implements ResponseBodyAdvice { @Override public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) { + if(body instanceof byte[]){ + response.getHeaders().setContentType(MediaType.APPLICATION_OCTET_STREAM); + return body; + } if(body instanceof CommonJsonResponse) { return body; } diff --git a/src/main/java/club/joylink/rtss/iscs/controller/IscsModelDataController.java b/src/main/java/club/joylink/rtss/iscs/controller/IscsModelDataController.java new file mode 100644 index 000000000..9db52427d --- /dev/null +++ b/src/main/java/club/joylink/rtss/iscs/controller/IscsModelDataController.java @@ -0,0 +1,96 @@ +package club.joylink.rtss.iscs.controller; + +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.iscs.entity.IscsModelData; +import club.joylink.rtss.iscs.services.IscsModelDataService; +import club.joylink.rtss.iscs.vo.IscsModelDataBasicInfo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * iscs 模型数据处理接口 + *

+ * [ + * "Plan-设备运行图: Plan/DeviceRunning",
+ * "Plan-站厅布局图: Plan/HallLayout",
+ * "Plan-站台布局图: Plan/PlatformLayout",
+ * "Plan-出入口布局图: Plan/EntranceLayout",
+ * "PSCADA-一次图: PSCADA/OneTimeGraph",
+ * "PSCADA-自动化系统图: PSCADA/AutoSysGraph",
+ * "PSCADA-定值召唤: PSCADA/SettingCall",
+ * "PSCADA-实时SOE: PSCADA/RealTimeSOE",
+ * "PSCADA-历史SOE: PSCADA/HistoricalSOE",
+ * "PSCADA-光字屏: PSCADA/Screen",
+ * "BAS-大系统: BAS/BigSys",
+ * "BAS-小系统: BAS/SmallSys",
+ * "BAS-隧道通风系统: BAS/TunnelVentilationSys",
+ * "BAS-水系统: BAS/WaterSys",
+ * "BAS-给排水: BAS/DrainageSys",
+ * "BAS-电扶梯: BAS/Escalator",
+ * "BAS-照明系统: BAS/LightingSys",
+ * "BAS-传感器: BAS/Sensor",
+ * "BAS-导向标识/广告: BAS/WayfindingNAds",
+ * "BAS-人防门: BAS/CivilDefense",
+ * "BAS-BAS系统图: BAS/BASSys",
+ * "BAS-模式控制: BAS/ModeControl",
+ * "BAS-时间表: BAS/TimeTable",
+ * "FAS-设备分区图: FAS/DevicePartition",
+ * "FAS-火灾报警平面图: FAS/FireAlarmLayout",
+ * "FAS-FAS气灭系统图: FAS/GaseousFireSuppressionSys",
+ * "TFDS-感温光纤状态监视图: TFDS/TFDSState",
+ * "AFC-自动售检票系统监视图: AFC/AFCState",
+ * "CCTV-监控布局图: CCTV/MonitorLayout",
+ * "CCTV-CCTV设备布局图: CCTV/CCTVEquipLayout",
+ * "PIS-PIS监控: PIS/PIS",
+ * "PSD-屏蔽门系统图: PSD/PSDSys",
+ * "ACS-门禁总览图: ACS/ACSOverview",
+ * "ACS-门禁监视布局图-站厅: ACS/ACSLayoutHall",
+ * "ACS-门禁监视布局图-站台: ACS/ACSLayoutStation",
+ * "FG-防淹门状态监视图: FG/FGState",
+ * "PA-PA监控: PA/PA",
+ * "NMS-网络状态监视图: NMS/NMS"
+ * ] + */ +@Slf4j +@RestController +@RequestMapping("/api/v2/iscs") +public class IscsModelDataController { + @Autowired + private IscsModelDataService modelDataService; + + /** + * 初始化模型数据 + * + * @param data 模型proto数据DataModelMap + */ + @PostMapping("/{system}/{view}/{place}/init") + public IscsModelDataBasicInfo storeModelData(@PathVariable("system") String system, @PathVariable("view") String view, @PathVariable("place") String place, @RequestBody byte[] data) { + log.debug("==>>初始化模型数据 system = {} view = {} place = {}", system, view, place); + final IscsModelData param = new IscsModelData(); + param.setSystem(system); + param.setView(view); + param.setPlace(place); + param.setData(data); + return modelDataService.storeModelData(param); + } + + /** + * 获取模型数据 + * + * @return 模型proto数据DataModelMap + */ + @GetMapping("/{system}/{view}/{place}") + @ResponseBody + public byte[] findModelData(@PathVariable("system") String system, @PathVariable("view") String view, @PathVariable("place") String place) { + log.debug("==>>获取模型数据 system = {} view = {} place = {}", system, view, place); + final IscsModelDataBasicInfo param = new IscsModelDataBasicInfo(); + param.setSystem(system); + param.setView(view); + param.setPlace(place); + final IscsModelData rt = modelDataService.findModelData(param); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != rt && null != rt.getData(), "模型数据不存在"); + return rt.getData(); + } + +} diff --git a/src/main/java/club/joylink/rtss/iscs/dao/IscsModelDataDAO.java b/src/main/java/club/joylink/rtss/iscs/dao/IscsModelDataDAO.java new file mode 100644 index 000000000..3b1ee7126 --- /dev/null +++ b/src/main/java/club/joylink/rtss/iscs/dao/IscsModelDataDAO.java @@ -0,0 +1,40 @@ +package club.joylink.rtss.iscs.dao; + +import club.joylink.rtss.iscs.entity.IscsModelData; +import club.joylink.rtss.iscs.entity.IscsModelDataExample; +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 IscsModelDataDAO { + long countByExample(IscsModelDataExample example); + + int deleteByExample(IscsModelDataExample example); + + int deleteByPrimaryKey(Long id); + + int insert(IscsModelData record); + + int insertSelective(IscsModelData record); + + List selectByExampleWithBLOBs(IscsModelDataExample example); + + List selectByExample(IscsModelDataExample example); + + IscsModelData selectByPrimaryKey(Long id); + + int updateByExampleSelective(@Param("record") IscsModelData record, @Param("example") IscsModelDataExample example); + + int updateByExampleWithBLOBs(@Param("record") IscsModelData record, @Param("example") IscsModelDataExample example); + + int updateByExample(@Param("record") IscsModelData record, @Param("example") IscsModelDataExample example); + + int updateByPrimaryKeySelective(IscsModelData record); + + int updateByPrimaryKeyWithBLOBs(IscsModelData record); + + int updateByPrimaryKey(IscsModelData record); +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/iscs/entity/IscsModelData.java b/src/main/java/club/joylink/rtss/iscs/entity/IscsModelData.java new file mode 100644 index 000000000..5ccea41d8 --- /dev/null +++ b/src/main/java/club/joylink/rtss/iscs/entity/IscsModelData.java @@ -0,0 +1,38 @@ +package club.joylink.rtss.iscs.entity; + +import java.io.Serializable; +import lombok.Data; + +/** + * @author + * + */ +@Data +public class IscsModelData implements Serializable { + /** + * iscs数据模型id + */ + private Long id; + + /** + * iscs一级系统(如FAS、PIS、AFC等) + */ + private String system; + + /** + * iscs二级视图 + */ + private String view; + + /** + * 场所(车站、变电所、停车场等) + */ + private String place; + + /** + * 场所整个所有的模型的数据 + */ + private byte[] data; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/iscs/entity/IscsModelDataExample.java b/src/main/java/club/joylink/rtss/iscs/entity/IscsModelDataExample.java new file mode 100644 index 000000000..04fccffd5 --- /dev/null +++ b/src/main/java/club/joylink/rtss/iscs/entity/IscsModelDataExample.java @@ -0,0 +1,492 @@ +package club.joylink.rtss.iscs.entity; + +import java.util.ArrayList; +import java.util.List; + +public class IscsModelDataExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public IscsModelDataExample() { + 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 andSystemIsNull() { + addCriterion("`system` is null"); + return (Criteria) this; + } + + public Criteria andSystemIsNotNull() { + addCriterion("`system` is not null"); + return (Criteria) this; + } + + public Criteria andSystemEqualTo(String value) { + addCriterion("`system` =", value, "system"); + return (Criteria) this; + } + + public Criteria andSystemNotEqualTo(String value) { + addCriterion("`system` <>", value, "system"); + return (Criteria) this; + } + + public Criteria andSystemGreaterThan(String value) { + addCriterion("`system` >", value, "system"); + return (Criteria) this; + } + + public Criteria andSystemGreaterThanOrEqualTo(String value) { + addCriterion("`system` >=", value, "system"); + return (Criteria) this; + } + + public Criteria andSystemLessThan(String value) { + addCriterion("`system` <", value, "system"); + return (Criteria) this; + } + + public Criteria andSystemLessThanOrEqualTo(String value) { + addCriterion("`system` <=", value, "system"); + return (Criteria) this; + } + + public Criteria andSystemLike(String value) { + addCriterion("`system` like", value, "system"); + return (Criteria) this; + } + + public Criteria andSystemNotLike(String value) { + addCriterion("`system` not like", value, "system"); + return (Criteria) this; + } + + public Criteria andSystemIn(List values) { + addCriterion("`system` in", values, "system"); + return (Criteria) this; + } + + public Criteria andSystemNotIn(List values) { + addCriterion("`system` not in", values, "system"); + return (Criteria) this; + } + + public Criteria andSystemBetween(String value1, String value2) { + addCriterion("`system` between", value1, value2, "system"); + return (Criteria) this; + } + + public Criteria andSystemNotBetween(String value1, String value2) { + addCriterion("`system` not between", value1, value2, "system"); + return (Criteria) this; + } + + public Criteria andViewIsNull() { + addCriterion("`view` is null"); + return (Criteria) this; + } + + public Criteria andViewIsNotNull() { + addCriterion("`view` is not null"); + return (Criteria) this; + } + + public Criteria andViewEqualTo(String value) { + addCriterion("`view` =", value, "view"); + return (Criteria) this; + } + + public Criteria andViewNotEqualTo(String value) { + addCriterion("`view` <>", value, "view"); + return (Criteria) this; + } + + public Criteria andViewGreaterThan(String value) { + addCriterion("`view` >", value, "view"); + return (Criteria) this; + } + + public Criteria andViewGreaterThanOrEqualTo(String value) { + addCriterion("`view` >=", value, "view"); + return (Criteria) this; + } + + public Criteria andViewLessThan(String value) { + addCriterion("`view` <", value, "view"); + return (Criteria) this; + } + + public Criteria andViewLessThanOrEqualTo(String value) { + addCriterion("`view` <=", value, "view"); + return (Criteria) this; + } + + public Criteria andViewLike(String value) { + addCriterion("`view` like", value, "view"); + return (Criteria) this; + } + + public Criteria andViewNotLike(String value) { + addCriterion("`view` not like", value, "view"); + return (Criteria) this; + } + + public Criteria andViewIn(List values) { + addCriterion("`view` in", values, "view"); + return (Criteria) this; + } + + public Criteria andViewNotIn(List values) { + addCriterion("`view` not in", values, "view"); + return (Criteria) this; + } + + public Criteria andViewBetween(String value1, String value2) { + addCriterion("`view` between", value1, value2, "view"); + return (Criteria) this; + } + + public Criteria andViewNotBetween(String value1, String value2) { + addCriterion("`view` not between", value1, value2, "view"); + return (Criteria) this; + } + + public Criteria andPlaceIsNull() { + addCriterion("place is null"); + return (Criteria) this; + } + + public Criteria andPlaceIsNotNull() { + addCriterion("place is not null"); + return (Criteria) this; + } + + public Criteria andPlaceEqualTo(String value) { + addCriterion("place =", value, "place"); + return (Criteria) this; + } + + public Criteria andPlaceNotEqualTo(String value) { + addCriterion("place <>", value, "place"); + return (Criteria) this; + } + + public Criteria andPlaceGreaterThan(String value) { + addCriterion("place >", value, "place"); + return (Criteria) this; + } + + public Criteria andPlaceGreaterThanOrEqualTo(String value) { + addCriterion("place >=", value, "place"); + return (Criteria) this; + } + + public Criteria andPlaceLessThan(String value) { + addCriterion("place <", value, "place"); + return (Criteria) this; + } + + public Criteria andPlaceLessThanOrEqualTo(String value) { + addCriterion("place <=", value, "place"); + return (Criteria) this; + } + + public Criteria andPlaceLike(String value) { + addCriterion("place like", value, "place"); + return (Criteria) this; + } + + public Criteria andPlaceNotLike(String value) { + addCriterion("place not like", value, "place"); + return (Criteria) this; + } + + public Criteria andPlaceIn(List values) { + addCriterion("place in", values, "place"); + return (Criteria) this; + } + + public Criteria andPlaceNotIn(List values) { + addCriterion("place not in", values, "place"); + return (Criteria) this; + } + + public Criteria andPlaceBetween(String value1, String value2) { + addCriterion("place between", value1, value2, "place"); + return (Criteria) this; + } + + public Criteria andPlaceNotBetween(String value1, String value2) { + addCriterion("place not between", value1, value2, "place"); + 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/iscs/services/IscsModelDataService.java b/src/main/java/club/joylink/rtss/iscs/services/IscsModelDataService.java new file mode 100644 index 000000000..c558b3b45 --- /dev/null +++ b/src/main/java/club/joylink/rtss/iscs/services/IscsModelDataService.java @@ -0,0 +1,64 @@ +package club.joylink.rtss.iscs.services; + +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.iscs.dao.IscsModelDataDAO; +import club.joylink.rtss.iscs.entity.IscsModelData; +import club.joylink.rtss.iscs.entity.IscsModelDataExample; +import club.joylink.rtss.iscs.vo.IscsModelDataBasicInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +public class IscsModelDataService { + @Autowired + private IscsModelDataDAO modelDataDao; + + /** + * 存储模型数据 + */ + @Transactional(readOnly = false, rollbackFor = Exception.class) + public IscsModelDataBasicInfo storeModelData(final IscsModelData md) { + //参数校验 + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != md.getSystem() && null != md.getView() && null != md.getPlace(),"参数校验失败"); + // + IscsModelData has = findBySystemViewAndPlace(md.getSystem(), md.getView(), md.getPlace()); + if (null != has) {//更新 + md.setId(has.getId()); + modelDataDao.updateByPrimaryKeySelective(md); + } else {//新增 + modelDataDao.insertSelective(md); + has = findBySystemViewAndPlace(md.getSystem(), md.getView(), md.getPlace()); + } + // + IscsModelDataBasicInfo rt = new IscsModelDataBasicInfo(); + rt.setId(has.getId()); + rt.setSystem(has.getSystem()); + rt.setView(has.getView()); + rt.setPlace(has.getPlace()); + return rt; + } + + /** + * 根据完整基本模型信息获取模型数据 + */ + @Transactional(readOnly = true, rollbackFor = Exception.class) + public IscsModelData findModelData(final IscsModelDataBasicInfo md) { + //参数校验 + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != md.getSystem() && null != md.getView() && null != md.getPlace(),"参数校验失败"); + // + return findBySystemViewAndPlace(md.getSystem(), md.getView(), md.getPlace()); + } + + /** + * 根据基本信息查询模型(不包括大字段信息) + */ + private IscsModelData findBySystemViewAndPlace(String system, String view, String place) { + IscsModelDataExample example = new IscsModelDataExample(); + example.createCriteria().andSystemEqualTo(system).andViewEqualTo(view).andPlaceEqualTo(place); + List list = modelDataDao.selectByExample(example); + return null != list && list.size() > 0 ? list.get(0) : null; + } +} diff --git a/src/main/java/club/joylink/rtss/iscs/vo/IscsModelDataBasicInfo.java b/src/main/java/club/joylink/rtss/iscs/vo/IscsModelDataBasicInfo.java new file mode 100644 index 000000000..0fc525786 --- /dev/null +++ b/src/main/java/club/joylink/rtss/iscs/vo/IscsModelDataBasicInfo.java @@ -0,0 +1,23 @@ +package club.joylink.rtss.iscs.vo; + +import lombok.Data; + +@Data +public class IscsModelDataBasicInfo { + /** + * 模型数据记录id + */ + private Long id; + /** + * iscs一级系统(如FAS、PIS、AFC等) + */ + private String system; + /** + * iscs二级视图 + */ + private String view; + /** + * 场所(车站、变电所、停车场等) + */ + private String place; +} diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java index e64049f30..b9c7cd631 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java @@ -1,5 +1,6 @@ package club.joylink.rtss.vo.training2.rule; +import club.joylink.rtss.constants.MapPrdTypeEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.RunLevel; @@ -236,12 +237,10 @@ public enum BgSceneStatusRule { public String doHandle(Simulation simulation, MapElement mapElement) { Section section = (Section) mapElement; section.setRouteLock(true); - section.setLockRight(true); - if(!CollectionUtils.isEmpty(section.getLogicList())) { - section.getLogicList().forEach(s -> { - s.setRouteLock(true); - s.setLockRight(true); - }); + if (section.isCross()) { + section.getLogicList().get(0).setRouteLock(true); + } else if (section.isShowLogic()) { + section.getLogicList().forEach(s -> s.setRouteLock(true)); } return getBgScene(simulation); } @@ -285,7 +284,7 @@ public enum BgSceneStatusRule { public String doHandle(Simulation simulation, MapElement mapElement) { Section section = (Section) mapElement; section.setSpeedUpLimit(5); - return null; + return getBgScene(simulation); } }, SECTION_CONFIRM_AXIS_VALID_BG_SCENE("设置计轴生效背景") { @@ -325,7 +324,7 @@ public enum BgSceneStatusRule { VirtualRealityTrain train = (VirtualRealityTrain) simulation.getRepository().getVrDeviceMap().values().stream() .filter(o -> o instanceof VirtualRealityTrain).findFirst().get(); BgSceneStatusRule.trainOnline(simulation, train, section, stand.isRight()); - return null; + return getBgScene(simulation); } }, /** @@ -362,7 +361,13 @@ public enum BgSceneStatusRule { @Override public String doHandle(Simulation simulation, MapElement mapElement) { Stand stand = (Stand) mapElement; - stand.setTrainLimit(3); + if (MapPrdTypeEnum.LOCAL.equals(simulation.getBuildParams().getProdType())) { + // 现地,设置背景为现地扣车 + stand.setStationHoldTrain(true); + } else { + // 行调,设置背景为中心扣车 + stand.setCenterHoldTrain(true); + } return getBgScene(simulation); } }, diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java index 4d87f5f46..e5da48b39 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java @@ -4,10 +4,12 @@ import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.Getter; +import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.function.Function; import java.util.stream.Collectors; @Getter @@ -65,45 +67,32 @@ public enum MapDeviceRule { SECTION_LIST("区段列表") { @Override public List

filterMapDeviceList(Simulation simulation) { - List routeList = ROUTE_LIST.filterMapDeviceList(simulation); - List
sectionList = new ArrayList<>(100); - routeList.forEach(route -> sectionList.addAll(route.getSectionList())); + List
sectionList = querySectionListByFunction(simulation, Section::isAxleCounterSection); return generateRandomElement(sectionList, 2); } }, - SECTION_STAND_TURN_BACK_LIST("折返区段列表") { + SECTION_LOGIC_LIST("逻辑区段列表") { @Override public List
filterMapDeviceList(Simulation simulation) { - List
sectionList = simulation.getRepository().getSectionList().stream() - .filter(section -> section.isStandTrack() && section.isTurnBackTrack()) - .collect(Collectors.toList()); - return MapDeviceRule.generateRandomElement(sectionList, 2); + List
sectionList = querySectionListByFunction(simulation, Section::isLogicSection); + return generateRandomElement(sectionList, 2); } }, - SECTION_NO_AXLE_COUNTER_LIST("非计轴区段列表") { + SECTION_PHYSICAL_LIST("物理区段列表") { @Override public List
filterMapDeviceList(Simulation simulation) { - List stationCodeList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList() - .stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode) - .collect(Collectors.toList()); - List
sectionList = simulation.getRepository().getSectionList().stream() - .filter(section -> stationCodeList.contains(section.getDeviceStation().getCode()) && !section.isAxleCounter()) - .collect(Collectors.toList()); + List
sectionList = querySectionListByFunction(simulation, Section::isAxleCounterSection); return generateRandomElement(sectionList, 2); } }, SECTION_AXLE_COUNTER_LIST("道岔计轴区段列表") { @Override public List
filterMapDeviceList(Simulation simulation) { - List stationCodeList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList() - .stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode) - .collect(Collectors.toList()); - List
sectionList = simulation.getRepository().getSectionList().stream() - .filter(section -> stationCodeList.contains(section.getDeviceStation().getCode()) && section.isAxleCounter()) - .collect(Collectors.toList()); + List
sectionList = querySectionListByFunction(simulation, Section::isSwitchAxleCounterSection); return generateRandomElement(sectionList, 2); } - } + }, + ; private String description; @@ -133,4 +122,36 @@ public enum MapDeviceRule { } return givenList; } + + /** + * 筛选符合条件的方法 + * @param simulation 仿真 + * @param filterFunction 筛选条件 + * @return 返回区段列表 + */ + private static List
querySectionListByFunction(Simulation simulation, Function filterFunction) { + return simulation.getRepository().getSectionList().stream().filter(section -> { + Station deviceStation = section.getDeviceStation(); + if (deviceStation != null && deviceStation.isDepot()) { + return false; + } + Section axleCounterSection = section.findAxleCounterSection(); + if (axleCounterSection != null) { + Station axleDeviceStation = axleCounterSection.getDeviceStation(); + if (axleDeviceStation != null && axleDeviceStation.isDepot()) { + return false; + } + } + if(StringUtils.isEmpty(section.getName())){ + return false; + } + if (section.getParent() != null && section.getParent().isCross()) { + return false; + } + if (filterFunction != null) { + return filterFunction.apply(section); + } + return true; + }).collect(Collectors.toList()); + } } diff --git a/src/main/resources/mybatis/mapper/iscs/IscsModelDataDAO.xml b/src/main/resources/mybatis/mapper/iscs/IscsModelDataDAO.xml new file mode 100644 index 000000000..caf27fc99 --- /dev/null +++ b/src/main/resources/mybatis/mapper/iscs/IscsModelDataDAO.xml @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + 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, `system`, `view`, place + + + `data` + + + + + + delete from rts_iscs_model_data + where id = #{id,jdbcType=BIGINT} + + + delete from rts_iscs_model_data + + + + + + insert into rts_iscs_model_data (id, `system`, `view`, + place, `data`) + values (#{id,jdbcType=BIGINT}, #{system,jdbcType=VARCHAR}, #{view,jdbcType=VARCHAR}, + #{place,jdbcType=VARCHAR}, #{data,jdbcType=LONGVARBINARY}) + + + insert into rts_iscs_model_data + + + id, + + + `system`, + + + `view`, + + + place, + + + `data`, + + + + + #{id,jdbcType=BIGINT}, + + + #{system,jdbcType=VARCHAR}, + + + #{view,jdbcType=VARCHAR}, + + + #{place,jdbcType=VARCHAR}, + + + #{data,jdbcType=LONGVARBINARY}, + + + + + + update rts_iscs_model_data + + + id = #{record.id,jdbcType=BIGINT}, + + + `system` = #{record.system,jdbcType=VARCHAR}, + + + `view` = #{record.view,jdbcType=VARCHAR}, + + + place = #{record.place,jdbcType=VARCHAR}, + + + `data` = #{record.data,jdbcType=LONGVARBINARY}, + + + + + + + + update rts_iscs_model_data + set id = #{record.id,jdbcType=BIGINT}, + `system` = #{record.system,jdbcType=VARCHAR}, + `view` = #{record.view,jdbcType=VARCHAR}, + place = #{record.place,jdbcType=VARCHAR}, + `data` = #{record.data,jdbcType=LONGVARBINARY} + + + + + + update rts_iscs_model_data + set id = #{record.id,jdbcType=BIGINT}, + `system` = #{record.system,jdbcType=VARCHAR}, + `view` = #{record.view,jdbcType=VARCHAR}, + place = #{record.place,jdbcType=VARCHAR} + + + + + + update rts_iscs_model_data + + + `system` = #{system,jdbcType=VARCHAR}, + + + `view` = #{view,jdbcType=VARCHAR}, + + + place = #{place,jdbcType=VARCHAR}, + + + `data` = #{data,jdbcType=LONGVARBINARY}, + + + where id = #{id,jdbcType=BIGINT} + + + update rts_iscs_model_data + set `system` = #{system,jdbcType=VARCHAR}, + `view` = #{view,jdbcType=VARCHAR}, + place = #{place,jdbcType=VARCHAR}, + `data` = #{data,jdbcType=LONGVARBINARY} + where id = #{id,jdbcType=BIGINT} + + + update rts_iscs_model_data + set `system` = #{system,jdbcType=VARCHAR}, + `view` = #{view,jdbcType=VARCHAR}, + place = #{place,jdbcType=VARCHAR} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file