Merge remote-tracking branch 'origin/test-training2' into test-training2

This commit is contained in:
joylink_zhangsai 2022-12-06 09:48:31 +08:00
commit 08e6344ae8
15 changed files with 1129 additions and 33 deletions

Binary file not shown.

13
pom.xml
View File

@ -140,6 +140,19 @@
<artifactId>pinyin4j</artifactId> <artifactId>pinyin4j</artifactId>
<version>2.5.0</version> <version>2.5.0</version>
</dependency> </dependency>
<!-- iscs -->
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.19.3</version>
</dependency>
<dependency>
<groupId>club.joylink</groupId>
<artifactId>iscs-message</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/iscs-message-0.0.1-SNAPSHOT.jar</systemPath>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -25,7 +25,7 @@ CREATE TABLE `rts_paper_composition` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '试卷蓝图id', `id` bigint NOT NULL AUTO_INCREMENT COMMENT '试卷蓝图id',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '试卷蓝图名称', `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 '试卷蓝图简介', `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', `org_id` bigint DEFAULT NULL COMMENT '组织id',
`start_time` datetime DEFAULT NULL COMMENT '启用起始时间', `start_time` datetime DEFAULT NULL COMMENT '启用起始时间',
`end_time` datetime DEFAULT NULL COMMENT '启用截止时间', `end_time` datetime DEFAULT NULL COMMENT '启用截止时间',

View File

@ -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;

View File

@ -9,7 +9,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication @SpringBootApplication
@EnableScheduling @EnableScheduling
@EnableCaching @EnableCaching
@MapperScan(basePackages = {"club.joylink.rtss.dao"}) @MapperScan(basePackages = {"club.joylink.rtss.dao","club.joylink.rtss.iscs.dao"})
//@EnableRetry //@EnableRetry
public class RtssApplication { public class RtssApplication {

View File

@ -33,6 +33,10 @@ public class CommonResponseBody implements ResponseBodyAdvice {
@Override @Override
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType,
Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) { Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
if(body instanceof byte[]){
response.getHeaders().setContentType(MediaType.APPLICATION_OCTET_STREAM);
return body;
}
if(body instanceof CommonJsonResponse) { if(body instanceof CommonJsonResponse) {
return body; return body;
} }

View File

@ -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 模型数据处理接口
* <p>
* [
* "Plan-设备运行图: Plan/DeviceRunning",<br>
* "Plan-站厅布局图: Plan/HallLayout",<br>
* "Plan-站台布局图: Plan/PlatformLayout",<br>
* "Plan-出入口布局图: Plan/EntranceLayout",<br>
* "PSCADA-一次图: PSCADA/OneTimeGraph",<br>
* "PSCADA-自动化系统图: PSCADA/AutoSysGraph",<br>
* "PSCADA-定值召唤: PSCADA/SettingCall",<br>
* "PSCADA-实时SOE: PSCADA/RealTimeSOE",<br>
* "PSCADA-历史SOE: PSCADA/HistoricalSOE",<br>
* "PSCADA-光字屏: PSCADA/Screen",<br>
* "BAS-大系统: BAS/BigSys",<br>
* "BAS-小系统: BAS/SmallSys",<br>
* "BAS-隧道通风系统: BAS/TunnelVentilationSys",<br>
* "BAS-水系统: BAS/WaterSys",<br>
* "BAS-给排水: BAS/DrainageSys",<br>
* "BAS-电扶梯: BAS/Escalator",<br>
* "BAS-照明系统: BAS/LightingSys",<br>
* "BAS-传感器: BAS/Sensor",<br>
* "BAS-导向标识/广告: BAS/WayfindingNAds",<br>
* "BAS-人防门: BAS/CivilDefense",<br>
* "BAS-BAS系统图: BAS/BASSys",<br>
* "BAS-模式控制: BAS/ModeControl",<br>
* "BAS-时间表: BAS/TimeTable",<br>
* "FAS-设备分区图: FAS/DevicePartition",<br>
* "FAS-火灾报警平面图: FAS/FireAlarmLayout",<br>
* "FAS-FAS气灭系统图: FAS/GaseousFireSuppressionSys",<br>
* "TFDS-感温光纤状态监视图: TFDS/TFDSState",<br>
* "AFC-自动售检票系统监视图: AFC/AFCState",<br>
* "CCTV-监控布局图: CCTV/MonitorLayout",<br>
* "CCTV-CCTV设备布局图: CCTV/CCTVEquipLayout",<br>
* "PIS-PIS监控: PIS/PIS",<br>
* "PSD-屏蔽门系统图: PSD/PSDSys",<br>
* "ACS-门禁总览图: ACS/ACSOverview",<br>
* "ACS-门禁监视布局图-站厅: ACS/ACSLayoutHall",<br>
* "ACS-门禁监视布局图-站台: ACS/ACSLayoutStation",<br>
* "FG-防淹门状态监视图: FG/FGState",<br>
* "PA-PA监控: PA/PA",<br>
* "NMS-网络状态监视图: NMS/NMS"<br>
* ]
*/
@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();
}
}

View File

@ -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<IscsModelData> selectByExampleWithBLOBs(IscsModelDataExample example);
List<IscsModelData> 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);
}

View File

@ -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一级系统(如FASPISAFC等)
*/
private String system;
/**
* iscs二级视图
*/
private String view;
/**
* 场所(车站变电所停车场等)
*/
private String place;
/**
* 场所整个所有的模型的数据
*/
private byte[] data;
private static final long serialVersionUID = 1L;
}

View File

@ -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<Criteria> oredCriteria;
private Integer limit;
private Long offset;
public IscsModelDataExample() {
oredCriteria = new ArrayList<Criteria>();
}
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<Criteria> 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<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> 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<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> 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<String> values) {
addCriterion("`system` in", values, "system");
return (Criteria) this;
}
public Criteria andSystemNotIn(List<String> 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<String> values) {
addCriterion("`view` in", values, "view");
return (Criteria) this;
}
public Criteria andViewNotIn(List<String> 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<String> values) {
addCriterion("place in", values, "place");
return (Criteria) this;
}
public Criteria andPlaceNotIn(List<String> 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);
}
}
}

View File

@ -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<IscsModelData> list = modelDataDao.selectByExample(example);
return null != list && list.size() > 0 ? list.get(0) : null;
}
}

View File

@ -0,0 +1,23 @@
package club.joylink.rtss.iscs.vo;
import lombok.Data;
@Data
public class IscsModelDataBasicInfo {
/**
* 模型数据记录id
*/
private Long id;
/**
* iscs一级系统(如FASPISAFC等)
*/
private String system;
/**
* iscs二级视图
*/
private String view;
/**
* 场所(车站变电所停车场等)
*/
private String place;
}

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.vo.training2.rule; package club.joylink.rtss.vo.training2.rule;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.RunLevel; import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
@ -236,12 +237,10 @@ public enum BgSceneStatusRule {
public String doHandle(Simulation simulation, MapElement mapElement) { public String doHandle(Simulation simulation, MapElement mapElement) {
Section section = (Section) mapElement; Section section = (Section) mapElement;
section.setRouteLock(true); section.setRouteLock(true);
section.setLockRight(true); if (section.isCross()) {
if(!CollectionUtils.isEmpty(section.getLogicList())) { section.getLogicList().get(0).setRouteLock(true);
section.getLogicList().forEach(s -> { } else if (section.isShowLogic()) {
s.setRouteLock(true); section.getLogicList().forEach(s -> s.setRouteLock(true));
s.setLockRight(true);
});
} }
return getBgScene(simulation); return getBgScene(simulation);
} }
@ -285,7 +284,7 @@ public enum BgSceneStatusRule {
public String doHandle(Simulation simulation, MapElement mapElement) { public String doHandle(Simulation simulation, MapElement mapElement) {
Section section = (Section) mapElement; Section section = (Section) mapElement;
section.setSpeedUpLimit(5); section.setSpeedUpLimit(5);
return null; return getBgScene(simulation);
} }
}, },
SECTION_CONFIRM_AXIS_VALID_BG_SCENE("设置计轴生效背景") { SECTION_CONFIRM_AXIS_VALID_BG_SCENE("设置计轴生效背景") {
@ -325,7 +324,7 @@ public enum BgSceneStatusRule {
VirtualRealityTrain train = (VirtualRealityTrain) simulation.getRepository().getVrDeviceMap().values().stream() VirtualRealityTrain train = (VirtualRealityTrain) simulation.getRepository().getVrDeviceMap().values().stream()
.filter(o -> o instanceof VirtualRealityTrain).findFirst().get(); .filter(o -> o instanceof VirtualRealityTrain).findFirst().get();
BgSceneStatusRule.trainOnline(simulation, train, section, stand.isRight()); BgSceneStatusRule.trainOnline(simulation, train, section, stand.isRight());
return null; return getBgScene(simulation);
} }
}, },
/** /**
@ -362,7 +361,13 @@ public enum BgSceneStatusRule {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement) { public String doHandle(Simulation simulation, MapElement mapElement) {
Stand stand = (Stand) 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); return getBgScene(simulation);
} }
}, },

View File

@ -4,10 +4,12 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.vo.map.graph.MapStationNewVO; import club.joylink.rtss.vo.map.graph.MapStationNewVO;
import lombok.Getter; import lombok.Getter;
import org.springframework.util.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Getter @Getter
@ -65,45 +67,32 @@ public enum MapDeviceRule {
SECTION_LIST("区段列表") { SECTION_LIST("区段列表") {
@Override @Override
public List<Section> filterMapDeviceList(Simulation simulation) { public List<Section> filterMapDeviceList(Simulation simulation) {
List<Route> routeList = ROUTE_LIST.filterMapDeviceList(simulation); List<Section> sectionList = querySectionListByFunction(simulation, Section::isAxleCounterSection);
List<Section> sectionList = new ArrayList<>(100);
routeList.forEach(route -> sectionList.addAll(route.getSectionList()));
return generateRandomElement(sectionList, 2); return generateRandomElement(sectionList, 2);
} }
}, },
SECTION_STAND_TURN_BACK_LIST("折返区段列表") { SECTION_LOGIC_LIST("逻辑区段列表") {
@Override @Override
public List<Section> filterMapDeviceList(Simulation simulation) { public List<Section> filterMapDeviceList(Simulation simulation) {
List<Section> sectionList = simulation.getRepository().getSectionList().stream() List<Section> sectionList = querySectionListByFunction(simulation, Section::isLogicSection);
.filter(section -> section.isStandTrack() && section.isTurnBackTrack()) return generateRandomElement(sectionList, 2);
.collect(Collectors.toList());
return MapDeviceRule.generateRandomElement(sectionList, 2);
} }
}, },
SECTION_NO_AXLE_COUNTER_LIST("非计轴区段列表") { SECTION_PHYSICAL_LIST("物理区段列表") {
@Override @Override
public List<Section> filterMapDeviceList(Simulation simulation) { public List<Section> filterMapDeviceList(Simulation simulation) {
List<String> stationCodeList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList() List<Section> sectionList = querySectionListByFunction(simulation, Section::isAxleCounterSection);
.stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode)
.collect(Collectors.toList());
List<Section> sectionList = simulation.getRepository().getSectionList().stream()
.filter(section -> stationCodeList.contains(section.getDeviceStation().getCode()) && !section.isAxleCounter())
.collect(Collectors.toList());
return generateRandomElement(sectionList, 2); return generateRandomElement(sectionList, 2);
} }
}, },
SECTION_AXLE_COUNTER_LIST("道岔计轴区段列表") { SECTION_AXLE_COUNTER_LIST("道岔计轴区段列表") {
@Override @Override
public List<Section> filterMapDeviceList(Simulation simulation) { public List<Section> filterMapDeviceList(Simulation simulation) {
List<String> stationCodeList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList() List<Section> sectionList = querySectionListByFunction(simulation, Section::isSwitchAxleCounterSection);
.stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode)
.collect(Collectors.toList());
List<Section> sectionList = simulation.getRepository().getSectionList().stream()
.filter(section -> stationCodeList.contains(section.getDeviceStation().getCode()) && section.isAxleCounter())
.collect(Collectors.toList());
return generateRandomElement(sectionList, 2); return generateRandomElement(sectionList, 2);
} }
} },
; ;
private String description; private String description;
@ -133,4 +122,36 @@ public enum MapDeviceRule {
} }
return givenList; return givenList;
} }
/**
* 筛选符合条件的方法
* @param simulation 仿真
* @param filterFunction 筛选条件
* @return 返回区段列表
*/
private static List<Section> querySectionListByFunction(Simulation simulation, Function<Section, Boolean> 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());
}
} }

View File

@ -0,0 +1,267 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="club.joylink.rtss.iscs.dao.IscsModelDataDAO">
<resultMap id="BaseResultMap" type="club.joylink.rtss.iscs.entity.IscsModelData">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="system" jdbcType="VARCHAR" property="system" />
<result column="view" jdbcType="VARCHAR" property="view" />
<result column="place" jdbcType="VARCHAR" property="place" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="club.joylink.rtss.iscs.entity.IscsModelData">
<result column="data" jdbcType="LONGVARBINARY" property="data" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, `system`, `view`, place
</sql>
<sql id="Blob_Column_List">
`data`
</sql>
<select id="selectByExampleWithBLOBs" parameterType="club.joylink.rtss.iscs.entity.IscsModelDataExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from rts_iscs_model_data
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limit != null">
<if test="offset != null">
limit ${offset}, ${limit}
</if>
<if test="offset == null">
limit ${limit}
</if>
</if>
</select>
<select id="selectByExample" parameterType="club.joylink.rtss.iscs.entity.IscsModelDataExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from rts_iscs_model_data
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limit != null">
<if test="offset != null">
limit ${offset}, ${limit}
</if>
<if test="offset == null">
limit ${limit}
</if>
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from rts_iscs_model_data
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from rts_iscs_model_data
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="club.joylink.rtss.iscs.entity.IscsModelDataExample">
delete from rts_iscs_model_data
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="club.joylink.rtss.iscs.entity.IscsModelData">
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>
<insert id="insertSelective" parameterType="club.joylink.rtss.iscs.entity.IscsModelData">
insert into rts_iscs_model_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="system != null">
`system`,
</if>
<if test="view != null">
`view`,
</if>
<if test="place != null">
place,
</if>
<if test="data != null">
`data`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="system != null">
#{system,jdbcType=VARCHAR},
</if>
<if test="view != null">
#{view,jdbcType=VARCHAR},
</if>
<if test="place != null">
#{place,jdbcType=VARCHAR},
</if>
<if test="data != null">
#{data,jdbcType=LONGVARBINARY},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="club.joylink.rtss.iscs.entity.IscsModelDataExample" resultType="java.lang.Long">
select count(*) from rts_iscs_model_data
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update rts_iscs_model_data
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.system != null">
`system` = #{record.system,jdbcType=VARCHAR},
</if>
<if test="record.view != null">
`view` = #{record.view,jdbcType=VARCHAR},
</if>
<if test="record.place != null">
place = #{record.place,jdbcType=VARCHAR},
</if>
<if test="record.data != null">
`data` = #{record.data,jdbcType=LONGVARBINARY},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.iscs.entity.IscsModelData">
update rts_iscs_model_data
<set>
<if test="system != null">
`system` = #{system,jdbcType=VARCHAR},
</if>
<if test="view != null">
`view` = #{view,jdbcType=VARCHAR},
</if>
<if test="place != null">
place = #{place,jdbcType=VARCHAR},
</if>
<if test="data != null">
`data` = #{data,jdbcType=LONGVARBINARY},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="club.joylink.rtss.iscs.entity.IscsModelData">
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>
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.iscs.entity.IscsModelData">
update rts_iscs_model_data
set `system` = #{system,jdbcType=VARCHAR},
`view` = #{view,jdbcType=VARCHAR},
place = #{place,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>