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

This commit is contained in:
joylink_zhangsai 2022-12-06 17:34:29 +08:00
commit f16362af53
16 changed files with 684 additions and 72 deletions

View File

@ -11,7 +11,7 @@
Target Server Version : 80029
File Encoding : 65001
Date: 05/12/2022 09:17:49
Date: 06/12/2022 09:53:18
*/
SET NAMES utf8mb4;
@ -27,6 +27,8 @@ CREATE TABLE `rts_iscs_model_data` (
`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 '场所整个所有的模型的数据',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

19
sql/20221206-wei.sql Normal file
View File

@ -0,0 +1,19 @@
CREATE TABLE `rts_training2_rule` (
`id` bigint NOT NULL AUTO_INCREMENT,
`sim_type` varchar(255) DEFAULT NULL COMMENT '仿真类型',
`line_code` varchar(255) DEFAULT NULL COMMENT '线路编码',
`device_rule` varchar(255) DEFAULT NULL COMMENT '设备列表规则',
`client` varchar(255) DEFAULT NULL COMMENT '客户端',
`name` varchar(255) DEFAULT NULL COMMENT '实训名称格式',
`description` varchar(255) DEFAULT NULL COMMENT '实训描述',
`type` varchar(255) DEFAULT NULL COMMENT '实训类型',
`labels` varchar(255) DEFAULT NULL COMMENT '实训标签',
`scene_rule` varchar(255) DEFAULT NULL COMMENT '背景生成规则',
`steps` text COMMENT '步骤列表',
`failure_rule` text COMMENT '失败规则',
`creator_id` bigint DEFAULT NULL COMMENT '创建者ID',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`location_rule` varchar(255) DEFAULT NULL COMMENT '地图定位规则',
PRIMARY KEY (`id`),
KEY `sim_type` (`sim_type`)
) ENGINE=InnoDB AUTO_INCREMENT=72 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

View File

@ -1,5 +1,7 @@
package club.joylink.rtss.controller.training2;
import club.joylink.rtss.constants.RoleEnum;
import club.joylink.rtss.controller.advice.Role;
import club.joylink.rtss.services.training2.Training2PublishService;
import club.joylink.rtss.services.training2.Training2TypeEnum;
import club.joylink.rtss.vo.client.PageVO;
@ -49,28 +51,19 @@ public class TrainingV2PublishController {
return this.publishService.deletePublishedTrainings(req);
}
/**
* 根据mapId查所有的已发布单操实训的基础信息
*/
@GetMapping("/{mapId}/singles")
public List<PublishedTraining2InfoRspVo> findSingleTrainingBasicInfo(@PathVariable("mapId") Long mapId){
return this.publishService.findAllSingleTrainingBasicInfoByMapId(mapId);
}
/**
* 根据mapId查所有的已发布场景实训的基础信息
*/
@GetMapping("/{mapId}/scenes")
public List<PublishedTraining2InfoRspVo> findSceneTrainingBasicInfo(@PathVariable("mapId") Long mapId){
return this.publishService.findAllSceneTrainingBasicInfoByMapId(mapId);
@GetMapping("/infos")
public List<PublishedTraining2InfoRspVo> findTrainingListInfos(@ModelAttribute PublishedTrainingListRspVo vo){
return this.publishService.findTrainingInfo(vo);
}
/**
* 查所有的已发布场景实训的基础信息
*/
@Role(value = RoleEnum.SuperAdmin)
@GetMapping("/list")
public List<PublishedTraining2InfoRspVo> findTrainingList(Long mapId,Training2TypeEnum type){
return this.publishService.findTrainingInfo(mapId, type);
public List<PublishedTraining2InfoRspVo> findTrainingList(@ModelAttribute PublishedTrainingListRspVo vo){
return this.publishService.findTrainingInfo(vo);
}
/**

View File

@ -3,11 +3,15 @@ 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.FindIscsModelDataBasicInfoByPageReqVo;
import club.joylink.rtss.iscs.vo.IscsModelDataBasicInfo;
import club.joylink.rtss.vo.client.PageVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
/**
* iscs 模型数据处理接口
* <p>
@ -54,7 +58,7 @@ import org.springframework.web.bind.annotation.*;
*/
@Slf4j
@RestController
@RequestMapping("/api/v2/iscs")
@RequestMapping("/api/v2/iscs/model")
public class IscsModelDataController {
@Autowired
private IscsModelDataService modelDataService;
@ -65,7 +69,7 @@ public class IscsModelDataController {
* @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) {
public IscsModelDataBasicInfo storeModelData(@PathVariable("system") @NotNull String system, @PathVariable("view") @NotNull String view, @PathVariable("place") @NotNull String place, @RequestBody @NotNull byte[] data) {
log.debug("==>>初始化模型数据 system = {} view = {} place = {}", system, view, place);
final IscsModelData param = new IscsModelData();
param.setSystem(system);
@ -82,7 +86,7 @@ public class IscsModelDataController {
*/
@GetMapping("/{system}/{view}/{place}")
@ResponseBody
public byte[] findModelData(@PathVariable("system") String system, @PathVariable("view") String view, @PathVariable("place") String place) {
public byte[] findModelDataByBasicInfo(@PathVariable("system") @NotNull String system, @PathVariable("view") @NotNull String view, @PathVariable("place") @NotNull String place) {
log.debug("==>>获取模型数据 system = {} view = {} place = {}", system, view, place);
final IscsModelDataBasicInfo param = new IscsModelDataBasicInfo();
param.setSystem(system);
@ -92,5 +96,25 @@ public class IscsModelDataController {
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != rt && null != rt.getData(), "模型数据不存在");
return rt.getData();
}
/**
* 获取模型数据
*
* @return 模型proto数据DataModelMap
*/
@GetMapping("/{id}")
@ResponseBody
public byte[] findModelDataById(@PathVariable("id") @NotNull Long id) {
log.debug("==>>获取模型数据 id = {}", id);
final IscsModelData rt = modelDataService.findModelData(id);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != rt && null != rt.getData(), "模型数据不存在");
return rt.getData();
}
/**
* 分页查询ISCS模型数据基本信息
*/
@PostMapping("/find/page")
public PageVO<IscsModelDataBasicInfo> findModelDataByPage(@RequestBody FindIscsModelDataBasicInfoByPageReqVo req) {
log.debug("==>>分页查询ISCS模型数据基本信息 : {}", req.toString());
return modelDataService.findModelDataByPage(req);
}
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.iscs.entity;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
/**
@ -29,6 +30,16 @@ public class IscsModelData implements Serializable {
*/
private String place;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 场所整个所有的模型的数据
*/

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.iscs.entity;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@ -393,6 +394,126 @@ public class IscsModelDataExample {
addCriterion("place not between", value1, value2, "place");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(LocalDateTime value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(LocalDateTime value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(LocalDateTime value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(LocalDateTime value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(LocalDateTime value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(LocalDateTime value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<LocalDateTime> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<LocalDateTime> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(LocalDateTime value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(LocalDateTime value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(LocalDateTime value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(LocalDateTime value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(LocalDateTime value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(LocalDateTime value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<LocalDateTime> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<LocalDateTime> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
}
/**

View File

@ -4,12 +4,21 @@ 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.FindIscsModelDataBasicInfoByPageReqVo;
import club.joylink.rtss.iscs.vo.IscsModelDataBasicInfo;
import club.joylink.rtss.vo.client.PageVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class IscsModelDataService {
@ -22,15 +31,18 @@ public class IscsModelDataService {
@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(),"参数校验失败");
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != md.getSystem() && null != md.getView() && null != md.getPlace(), "参数校验失败");
//
IscsModelData has = findBySystemViewAndPlace(md.getSystem(), md.getView(), md.getPlace());
IscsModelData has = findBasicBySystemViewAndPlace(md.getSystem(), md.getView(), md.getPlace());
final LocalDateTime now = LocalDateTime.now();
md.setUpdateTime(now);
if (null != has) {//更新
md.setId(has.getId());
md.setCreateTime(now);
modelDataDao.updateByPrimaryKeySelective(md);
} else {//新增
modelDataDao.insertSelective(md);
has = findBySystemViewAndPlace(md.getSystem(), md.getView(), md.getPlace());
has = findBasicBySystemViewAndPlace(md.getSystem(), md.getView(), md.getPlace());
}
//
IscsModelDataBasicInfo rt = new IscsModelDataBasicInfo();
@ -42,23 +54,114 @@ public class IscsModelDataService {
}
/**
* 根据完整基本模型信息获取模型数据
* 根据完整基本模型信息获取模型数据(包括大字段信息)
*/
@Transactional(readOnly = true, rollbackFor = Exception.class)
@Transactional(readOnly = true)
public IscsModelData findModelData(final IscsModelDataBasicInfo md) {
//参数校验
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != md.getSystem() && null != md.getView() && null != md.getPlace(),"参数校验失败");
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != md.getSystem() && null != md.getView() && null != md.getPlace(), "参数校验失败");
//
return findBySystemViewAndPlace(md.getSystem(), md.getView(), md.getPlace());
return findAllBySystemViewAndPlace(md.getSystem(), md.getView(), md.getPlace());
}
/**
* 根据完整基本模型信息获取模型数据(包括大字段信息)
*/
@Transactional(readOnly = true)
public IscsModelData findModelData(final Long id) {
return modelDataDao.selectByPrimaryKey(id);
}
/**
* 分页查询ISCS模型数据基本信息
*/
@Transactional(readOnly = true)
public PageVO<IscsModelDataBasicInfo> findModelDataByPage(FindIscsModelDataBasicInfoByPageReqVo req) {
IscsModelDataExample example = new IscsModelDataExample();
if (req.getLogicAnd()) {
final IscsModelDataExample.Criteria andCriteria = example.createCriteria();
if (StringUtils.hasText(req.getSystem())) {
if (req.getLike()) {
andCriteria.andSystemLike(String.format("%%%s%%", req.getSystem()));
} else {
andCriteria.andSystemEqualTo(req.getSystem());
}
}
if (StringUtils.hasText(req.getView())) {
if (req.getLike()) {
andCriteria.andViewLike(String.format("%%%s%%", req.getView()));
} else {
andCriteria.andViewEqualTo(req.getView());
}
}
if (StringUtils.hasText(req.getPlace())) {
if (req.getLike()) {
andCriteria.andPlaceLike(String.format("%%%s%%", req.getPlace()));
} else {
andCriteria.andPlaceEqualTo(req.getPlace());
}
}
} else {
if (StringUtils.hasText(req.getSystem())) {
if (req.getLike()) {
example.or().andSystemLike(String.format("%%%s%%", req.getSystem()));
} else {
example.or().andSystemEqualTo(req.getSystem());
}
}
if (StringUtils.hasText(req.getView())) {
if (req.getLike()) {
example.or().andViewLike(String.format("%%%s%%", req.getView()));
} else {
example.or().andViewEqualTo(req.getView());
}
}
if (StringUtils.hasText(req.getPlace())) {
if (req.getLike()) {
example.or().andPlaceLike(String.format("%%%s%%", req.getPlace()));
} else {
example.or().andPlaceEqualTo(req.getPlace());
}
}
}
//
final String orderBy = req.getOrderByType().with() + (req.getDesc() ? " desc" : "");
PageHelper.clearPage();
PageHelper.startPage(req.getPageNum(), req.getPageSize(), orderBy);
Page<IscsModelData> sqlPage = (Page<IscsModelData>) this.modelDataDao.selectByExample(example);
List<IscsModelDataBasicInfo> rtList = new ArrayList<>();
if (!CollectionUtils.isEmpty(sqlPage.getResult())) {
rtList = sqlPage.getResult().stream().map((IscsModelData md) -> {
final IscsModelDataBasicInfo bi = new IscsModelDataBasicInfo();
bi.setId(md.getId());
bi.setSystem(md.getSystem());
bi.setView(md.getView());
bi.setPlace(md.getPlace());
bi.setCreateTime(md.getCreateTime());
bi.setUpdateTime(md.getUpdateTime());
return bi;
}).collect(Collectors.toList());
}
return PageVO.convert(sqlPage, rtList);
}
/**
* 根据基本信息查询模型(不包括大字段信息)
*/
private IscsModelData findBySystemViewAndPlace(String system, String view, String place) {
private IscsModelData findBasicBySystemViewAndPlace(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;
}
/**
* 根据基本信息查询模型(包括大字段信息)
*/
private IscsModelData findAllBySystemViewAndPlace(String system, String view, String place) {
IscsModelDataExample example = new IscsModelDataExample();
example.createCriteria().andSystemEqualTo(system).andViewEqualTo(view).andPlaceEqualTo(place);
List<IscsModelData> list = modelDataDao.selectByExampleWithBLOBs(example);
return null != list && list.size() > 0 ? list.get(0) : null;
}
}

View File

@ -0,0 +1,91 @@
package club.joylink.rtss.iscs.vo;
import club.joylink.rtss.vo.client.PageQueryVO;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
/**
* 分页查询ISCS模型数据基本信息
*/
@Data
public class FindIscsModelDataBasicInfoByPageReqVo extends PageQueryVO {
/**
* iscs一级系统(如FASPISAFC等)
*/
private String system;
/**
* iscs二级视图
*/
private String view;
/**
* 场所(车站变电所停车场等)
*/
private String place;
/**
* 当查询条件有多个时条件间关系true-false-默认值为true
*/
private Boolean logicAnd = true;
/**
* 默认true,true-模糊查询false-精确查询
*/
private Boolean like = true;
/**
* 是否降序true-降序false-升序默认值为true;
*/
private Boolean desc = true;
/**
* 排序类型,默认按创建时间排序序列化为数值1-system2-view3-place4-create_time ,5-update_time
*/
private OrderByType orderByType = OrderByType.OrderByCreateTime;
/////////////////////////////////////////////
public static enum OrderByType {
OrderBySystem(1, "system"),
OrderByView(2, "view"),
OrderByPlace(3, "place"),
OrderByCreateTime(4, "create_time"),
OrderByUpdateTime(5, "update_time"),
;
private Integer value;
private String orderBy;
private OrderByType(Integer value, String orderBy) {
this.value = value;
this.orderBy = orderBy;
}
public String with() {
return this.orderBy;
}
@JsonCreator
public static OrderByType getItem(Integer value) {
return map.get(value);
}
@JsonValue
public Integer getValue() {
return this.value;
}
private static Map<Integer, OrderByType> map = new HashMap<>();
static {
for (OrderByType t : values()) {
map.put(t.value, t);
}
}
}
@Override
public String toString() {
return
"system='" + system + '\'' +
", view='" + view + '\'' +
", place='" + place + '\'' + super.toString();
}
}

View File

@ -2,6 +2,11 @@ package club.joylink.rtss.iscs.vo;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 模型数据基本信息
*/
@Data
public class IscsModelDataBasicInfo {
/**
@ -20,4 +25,13 @@ public class IscsModelDataBasicInfo {
* 场所(车站变电所停车场等)
*/
private String place;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
}

View File

@ -4,6 +4,9 @@ import club.joylink.rtss.dao.PublishedTraining2DAO;
import club.joylink.rtss.entity.training2.PublishedTraining2;
import club.joylink.rtss.entity.training2.PublishedTraining2Example;
import club.joylink.rtss.entity.training2.PublishedTraining2WithBLOBs;
import club.joylink.rtss.exception.BusinessException;
import club.joylink.rtss.exception.BusinessExceptionAssert;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.training2.publish.*;
import com.github.pagehelper.Page;
@ -160,33 +163,31 @@ public class Training2PublishService {
}
/**
* 根据mapId查找所有的单操实训的基础信息
* 根据mapId查所有的已发布单操或场景实训的基础信息
*
*/
@Transactional(readOnly = true)
public List<PublishedTraining2InfoRspVo> findAllSingleTrainingBasicInfoByMapId(Long mapId) {
return findTrainingInfo(mapId, Training2TypeEnum.single);
public List<PublishedTraining2InfoRspVo> findAllTrainingBasicInfoByMapIdAndType(PublishedTrainingListRspVo vo){
BusinessExceptionAssertEnum.DATA_INVALID.assertTrue(Objects.nonNull(vo.getMapId()),"请选择对应的地图");
BusinessExceptionAssertEnum.DATA_INVALID.assertTrue(Objects.nonNull(vo.getType()),"请选择对应的类型");
return findTrainingInfo(vo);
}
/**
* 根据mapId查找所有的场景实训的基础信息
*/
@Transactional(readOnly = true)
public List<PublishedTraining2InfoRspVo> findAllSceneTrainingBasicInfoByMapId(Long mapId) {
return findTrainingInfo(mapId, Training2TypeEnum.scene);
}
/**
* 根据地图ID和类型查询实训列表
*/
public List<PublishedTraining2InfoRspVo> findTrainingInfo(Long mapId, Training2TypeEnum type) {
public List<PublishedTraining2InfoRspVo> findTrainingInfo(PublishedTrainingListRspVo reqVO) {
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria criteria = example.createCriteria();
if (mapId != null) {
criteria.andMapIdEqualTo(mapId);
if (reqVO.getMapId() != null) {
criteria.andMapIdEqualTo(reqVO.getMapId());
}
if (type != null) {
criteria.andTypeEqualTo(type.value());
if (reqVO.getType() != null) {
criteria.andTypeEqualTo(reqVO.getType().value());
}
if(StringUtils.hasText(reqVO.getName())){
criteria.andNameLike(String.format("%%%s%%", reqVO.getName()));
}
List<PublishedTraining2> list = this.publishedDao.selectByExample(example);
if (CollectionUtils.isEmpty(list)) {

View File

@ -31,4 +31,10 @@ public class PageQueryVO {
this.pageSize = pageSize;
}
@Override
public String toString() {
return
" pageNum=" + pageNum +
", pageSize=" + pageSize;
}
}

View File

@ -0,0 +1,20 @@
package club.joylink.rtss.vo.training2.publish;
import club.joylink.rtss.services.training2.Training2TypeEnum;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
/**
* 已发布实训的所有信息
*/
@Data
public class PublishedTrainingListRspVo {
private Long mapId;
private Training2TypeEnum type;
private String name;
}

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.vo.training2.rule;
import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.Simulation;
@ -26,6 +27,7 @@ import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@Getter
public enum BgSceneStatusRule {
@ -218,6 +220,41 @@ public enum BgSceneStatusRule {
return getBgScene(simulation);
}
},
SIGNAL_ROUTE_CANCEL_AUTO_SET_BG_SCENE("取消联锁自动触发背景") {
@Override
public String doHandle(Simulation simulation, MapElement mapElement) {
Signal signal = (Signal) mapElement;
Route route = signal.getRouteList().get(0);
route.setCiControl(true);
return getBgScene(simulation);
}
},
SIGNAL_SET_CI_AUTO_BG_SCENE("联锁自动进路背景") {
@Override
public String doHandle(Simulation simulation, MapElement mapElement) {
Signal signal = (Signal) mapElement;
List<Route> fltRouteList = signal.getRouteList().stream().filter(Route::isFlt).collect(Collectors.toList());
boolean isSetFlt = simulation.getRepository().getConfig().isSetRouteBeforeSetFlt();
for (Route route : fltRouteList) {
if (isSetFlt) {
openRouteDirect(simulation, route);
}
}
return getBgScene(simulation);
}
},
SIGNAL_CANCEL_SET_CI_AUTO_BG_SCENE("取消联锁自动进路背景") {
@Override
public String doHandle(Simulation simulation, MapElement mapElement) {
Signal signal = (Signal) mapElement;
List<Route> fltRouteList = signal.getRouteList().stream().filter(Route::isFlt).collect(Collectors.toList());
fltRouteList.forEach(route -> {
openRouteDirect(simulation, route);
route.setFleetMode(true);
});
return getBgScene(simulation);
}
},
/**
* 区段区故解背景
*/
@ -338,6 +375,47 @@ public enum BgSceneStatusRule {
return getBgScene(simulation);
}
},
STATION_OPEN_AUTO_SETTING_BG_SCENE("全站进路交ATS自动控背景") {
@Override
public String doHandle(Simulation simulation, MapElement mapElement) {
Station station = (Station) mapElement;
if(!station.isInterlock()) {
throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error);
}
if (BusinessConsts.MapPrd.PrdType.Type01.equals(simulation.getBuildParams().getProdType())) {
if(station.isCentralized()) {
station.setControlMode(Station.ControlMode.Local);
}else{
station.getDeviceStation().setControlMode(Station.ControlMode.Local);
}
}
List<Route> routeList3 = simulation.getRepository().getRouteList();
for (Route route : routeList3) {
if (Objects.equals(route.getInterlockStation(), station)) {
if (route.isAtsControl()) {
route.setAtsControl(false);
}
}
}
return getBgScene(simulation);
}
},
STATION_CENTER_CONTROL_BG_SCENE ("车站设置中控背景") {
@Override
public String doHandle(Simulation simulation, MapElement mapElement) {
Station station = (Station) mapElement;
station.setControlMode(Station.ControlMode.Local);
return getBgScene(simulation);
}
},
STATION_STATION_CONTROL_BG_SCENE("车站转为站控背景") {
@Override
public String doHandle(Simulation simulation, MapElement mapElement) {
Station station = (Station) mapElement;
station.setControlMode(Station.ControlMode.Center);
return getBgScene(simulation);
}
},
STAND_EARLY_DEPART_BG_SCENE("提前发车背景") {
@Override
public String doHandle(Simulation simulation, MapElement mapElement) {
@ -379,15 +457,22 @@ public enum BgSceneStatusRule {
return getBgScene(simulation);
}
},
STAND_CANCEL_JUMP_STOP_BG_SCENE("站台取消设置跳停") {
STAND_CANCEL_JUMP_STOP_BG_SCENE("站台取消设置跳停背景") {
@Override
public String doHandle(Simulation simulation, MapElement mapElement) {
Stand stand = (Stand) mapElement;
stand.setAllSkip(true);
return getBgScene(simulation);
}
},
STAND_STRATEGY_BG_SCENE("人工折返策略设置背景") {
@Override
public String doHandle(Simulation simulation, MapElement mapElement) {
Stand stand = (Stand) mapElement;
stand.setTypeStrategy(Stand.TurnBackType.AUTO);
return getBgScene(simulation);
}
}
;
/**

View File

@ -4,9 +4,11 @@ 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.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
@ -18,29 +20,65 @@ public enum MapDeviceRule {
@Override
public List<Station> filterMapDeviceList(Simulation simulation) {
List<Station> stationList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList()
.stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode)
.stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation() && !s.isDepot())
.sorted(Comparator.comparing(MapStationNewVO::getSn))
.map(MapStationNewVO::getCode)
.map(code -> simulation.getRepository().getByCode(code, Station.class))
.collect(Collectors.toList());
return generateRandomElement(stationList, 1);
return generateRandomElement(stationList, NUMBER);
}
},
STAND_LIST("站台列表"){
@Override
public List<Stand> filterMapDeviceList(Simulation simulation) {
List<Station> stationList = STATION_LIST.filterMapDeviceList(simulation);
Station station = stationList.get(0);
return MapDeviceRule.generateRandomElement(station.getAllStandList(), 2);
// 车站列表
List<Station> stationList = simulation.getRepository().getStationList().stream()
.filter(station -> !station.isDepot()).sorted(Comparator.comparingInt(Station::getSn))
.collect(Collectors.toList());
Station firstStation = stationList.get(0);
Station lastStation = stationList.get(stationList.size() - 1);
List<Stand> standList = simulation.getRepository().getStandList().stream().filter(stand -> {
if (stand.getStation() != null && stand.getStation().isDepot())
return false;
// 去除第一个与最后一个站的站台
if (firstStation.equals(stand.getStation()) || lastStation.equals(stand.getStation())) {
return false;
}
if (!stand.isVisible() || !stand.hasDoor() || stand.isSmall()) { // 特殊站台
return false;
}
return true;
}).sorted(Comparator.comparingInt(stand -> stand.getStation().getSn())).collect(Collectors.toList());
return MapDeviceRule.generateRandomElement(standList, NUMBER);
}
},
ROUTE_LIST("进路列表") {
@Override
public List<Route> filterMapDeviceList(Simulation simulation) {
List<Station> stationList = STATION_LIST.filterMapDeviceList(simulation);
Station station = stationList.get(0);
List<Route> routeList = new ArrayList<>();
station.getAllStandList().stream().filter(stand -> stand.getSection().getSignalToRight() != null)
.forEach(stand -> routeList.addAll(stand.getSection().getSignalToRight().getRouteList()));
return generateRandomElement(routeList, 2);
boolean railway = simulation.getRepository().getConfig().isRailway();
List<Route> routeList = simulation.getRepository().getRouteList().stream().filter(route -> {
if (route.getStart() == null || route.getStart().isVirtual()) {
return false;
}
if (route.getStart().getStation()!= null && route.getStart().getStation().isDepot()) {
return false;
}
if (route.getStart().getDeviceStation()!= null && route.getStart().getDeviceStation().isDepot()) {
return false;
}
if (route.isGuide()) { // 引导进路跳过
return false;
}
if (railway) {
if (route.isPassRoute() || route.isLongShuntingRoute() ||
!(Route.Type.RECEIVING.equals(route.getType()) || Route.Type.DEPARTURE.equals(route.getType()))) {
return false;
}
}
return true;
}).collect(Collectors.toList());
return generateRandomElement(routeList, NUMBER);
}
},
SWITCH_LIST("道岔列表") {
@ -50,7 +88,7 @@ public enum MapDeviceRule {
Station station = stationList.get(0);
List<Switch> switchList = simulation.getRepository().getSwitchList().stream()
.filter(aSwitch -> station.equals(aSwitch.getDeviceStation())).collect(Collectors.toList());
return generateRandomElement(switchList, 2);
return generateRandomElement(switchList, 1);
}
},
SIGNAL_LIST("信号机列表") {
@ -61,42 +99,69 @@ public enum MapDeviceRule {
List<Signal> signalList = new ArrayList<>();
station.getAllStandList().stream().filter(stand -> stand.getSection().getSignalToRight() != null)
.forEach(stand -> signalList.add(stand.getSection().getSignalToRight()));
return generateRandomElement(signalList, 2);
return generateRandomElement(signalList, NUMBER);
}
},
SIGNAL_CI_AUTO_LIST("联锁自动触发信号机列表") {
@Override
public List<Signal> filterMapDeviceList(Simulation simulation) {
List<Signal> signalList = simulation.getRepository().getRouteList().stream().filter(route -> {
if (route.getStart() == null || route.getStart().isVirtual()
|| (route.getStart().getStation() != null && route.getStart().getStation().isDepot())) {
return false;
}
if (route.isArs() || route.isGuide()) {
return false;
}
return true;
}).map(route -> route.getStart()).distinct().collect(Collectors.toList());
return MapDeviceRule.generateRandomElement(signalList, NUMBER);
}
},
SECTION_LIST("区段列表") {
@Override
public List<Section> filterMapDeviceList(Simulation simulation) {
List<Section> sectionList = querySectionListByFunction(simulation, Section::isAxleCounterSection);
return generateRandomElement(sectionList, 2);
return generateRandomElement(sectionList, 1);
}
},
SECTION_LOGIC_LIST("逻辑区段列表") {
@Override
public List<Section> filterMapDeviceList(Simulation simulation) {
List<Section> sectionList = querySectionListByFunction(simulation, Section::isLogicSection);
return generateRandomElement(sectionList, 2);
return generateRandomElement(sectionList, NUMBER);
}
},
SECTION_PHYSICAL_LIST("物理区段列表") {
@Override
public List<Section> filterMapDeviceList(Simulation simulation) {
List<Section> sectionList = querySectionListByFunction(simulation, Section::isAxleCounterSection);
return generateRandomElement(sectionList, 2);
return generateRandomElement(sectionList, NUMBER);
}
},
SECTION_AXLE_COUNTER_LIST("道岔计轴区段列表") {
@Override
public List<Section> filterMapDeviceList(Simulation simulation) {
List<Section> sectionList = querySectionListByFunction(simulation, Section::isSwitchAxleCounterSection);
return generateRandomElement(sectionList, 2);
List<Section> sectionList = querySectionListByFunction(simulation,
(section) -> section.isAxleCounter() && !section.isSwitchAxleCounterSection());
return generateRandomElement(sectionList, NUMBER);
}
},
CONTROL_STATION_LIST("控制模式的车站列表") {
@Override
public List<Station> filterMapDeviceList(Simulation simulation) {
//找到所有有控制模式的车站
List<Station> stationList = simulation.getRepository().getStationList().stream()
.filter(Station::isHasControlMode).collect(Collectors.toList());
return MapDeviceRule.generateRandomElement(stationList, NUMBER);
}
}
;
private String description;
private static final int NUMBER = 1;
MapDeviceRule(String description) {
this.description = description;
}

View File

@ -113,14 +113,35 @@ public enum PropertyValueRule {
return buttonVO.getCode();
}
},
SIGNAL_FIRST_ROUTE_CODE_LIST("信号机关联的第一条进路编码列表") {
SIGNAL_FIRST_ROUTE_CODE_LIST("信号机关联的进路编码列表") {
@Override
public Object resolve(Simulation simulation, Object mapElement) {
Signal signal = (Signal) mapElement;
Route route = signal.getRouteList().get(0);
return List.of(route.getCode());
}
}
},
SIGNAL_FIRST_ROUTE_NAME("信号机关联的进路名称") {
@Override
public Object resolve(Simulation simulation, Object mapElement) {
Signal signal = (Signal) mapElement;
Route route = signal.getRouteList().get(0);
return route.getName();
}
},
CENTER_CONTROL_STATION_CODE_LIST("站控转中控时车站列表") {
@Override
public Object resolve(Simulation simulation, Object mapElement) {
Station station = (Station) mapElement;
return List.of(station.getCode());
}
},
CENTER_CONTROL_STATION_NAME("站控转中控时车站名称") {
@Override
public Object resolve(Simulation simulation, Object mapElement) {
return ((Station) mapElement).getName();
}
},
;
private final String description;

View File

@ -6,6 +6,8 @@
<result column="system" jdbcType="VARCHAR" property="system" />
<result column="view" jdbcType="VARCHAR" property="view" />
<result column="place" jdbcType="VARCHAR" property="place" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="club.joylink.rtss.iscs.entity.IscsModelData">
<result column="data" jdbcType="LONGVARBINARY" property="data" />
@ -69,7 +71,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, `system`, `view`, place
id, `system`, `view`, place, create_time, update_time
</sql>
<sql id="Blob_Column_List">
`data`
@ -140,9 +142,11 @@
</delete>
<insert id="insert" parameterType="club.joylink.rtss.iscs.entity.IscsModelData">
insert into rts_iscs_model_data (id, `system`, `view`,
place, `data`)
place, create_time, update_time,
`data`)
values (#{id,jdbcType=BIGINT}, #{system,jdbcType=VARCHAR}, #{view,jdbcType=VARCHAR},
#{place,jdbcType=VARCHAR}, #{data,jdbcType=LONGVARBINARY})
#{place,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{data,jdbcType=LONGVARBINARY})
</insert>
<insert id="insertSelective" parameterType="club.joylink.rtss.iscs.entity.IscsModelData">
insert into rts_iscs_model_data
@ -159,6 +163,12 @@
<if test="place != null">
place,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="data != null">
`data`,
</if>
@ -176,6 +186,12 @@
<if test="place != null">
#{place,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="data != null">
#{data,jdbcType=LONGVARBINARY},
</if>
@ -202,6 +218,12 @@
<if test="record.place != null">
place = #{record.place,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.data != null">
`data` = #{record.data,jdbcType=LONGVARBINARY},
</if>
@ -216,6 +238,8 @@
`system` = #{record.system,jdbcType=VARCHAR},
`view` = #{record.view,jdbcType=VARCHAR},
place = #{record.place,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
`data` = #{record.data,jdbcType=LONGVARBINARY}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -226,7 +250,9 @@
set id = #{record.id,jdbcType=BIGINT},
`system` = #{record.system,jdbcType=VARCHAR},
`view` = #{record.view,jdbcType=VARCHAR},
place = #{record.place,jdbcType=VARCHAR}
place = #{record.place,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -243,6 +269,12 @@
<if test="place != null">
place = #{place,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="data != null">
`data` = #{data,jdbcType=LONGVARBINARY},
</if>
@ -254,6 +286,8 @@
set `system` = #{system,jdbcType=VARCHAR},
`view` = #{view,jdbcType=VARCHAR},
place = #{place,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
`data` = #{data,jdbcType=LONGVARBINARY}
where id = #{id,jdbcType=BIGINT}
</update>
@ -261,7 +295,9 @@
update rts_iscs_model_data
set `system` = #{system,jdbcType=VARCHAR},
`view` = #{view,jdbcType=VARCHAR},
place = #{place,jdbcType=VARCHAR}
place = #{place,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>