From a5366241efc2c6bcda551bc56ae61d7bee1c3c20 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Mon, 20 Feb 2023 17:25:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9C=B0=E5=9B=BE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86=E5=8F=8A[?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=A8=A1=E6=9D=BF=E7=94=9F=E6=88=90=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E5=8A=9F=E8=83=BD]=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../publish/MapFunctionController.java | 81 ++- .../rtss/dao/MapFunctionTemplateDAO.java | 39 ++ .../rtss/entity/MapFunctionTemplate.java | 154 ++++ .../entity/MapFunctionTemplateExample.java | 663 ++++++++++++++++++ .../mapFunction/RtsMapFunctionService.java | 19 +- .../RtsMapFunctionServiceImpl.java | 255 ++++--- .../MapFunctionTemplateService.java | 22 + .../MapFunctionTemplateServiceImpl.java | 77 ++ .../OldPermissionDataSyncService.java | 8 +- .../permission/SystemAbilityService.java | 23 +- .../cbtc/SimulationServiceImpl.java | 26 +- .../mapFunction/MapFunctionBatchModifyVO.java | 62 ++ ...CreateVO.java => MapFunctionCreateVO.java} | 2 +- ...O.java => MapFunctionGenerateParamVO.java} | 2 +- .../mapFunction/MapFunctionGenerateVO.java | 24 + ...onQueryVO.java => MapFunctionQueryVO.java} | 8 +- ...UpdateVO.java => MapFunctionUpdateVO.java} | 15 +- ...sMapFunctionVO.java => MapFunctionVO.java} | 10 +- .../RtsMapFunctionDescModifyVO.java | 35 - .../mapFunctionTemplate/AssistantParamVO.java | 18 + .../MapFunctionTemplateCreateVO.java | 31 + .../MapFunctionTemplateQueryVO.java | 10 + .../MapFunctionTemplateVO.java | 54 ++ .../convertor/SystemAbilityConvertor.java | 9 +- .../mybatis/mapper/MapFunctionTemplateDAO.xml | 314 +++++++++ .../RtsMapFunctionServiceImplTest.java | 14 +- 26 files changed, 1771 insertions(+), 204 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/dao/MapFunctionTemplateDAO.java create mode 100644 src/main/java/club/joylink/rtss/entity/MapFunctionTemplate.java create mode 100644 src/main/java/club/joylink/rtss/entity/MapFunctionTemplateExample.java create mode 100644 src/main/java/club/joylink/rtss/services/mapFunctionTemplate/MapFunctionTemplateService.java create mode 100644 src/main/java/club/joylink/rtss/services/mapFunctionTemplate/MapFunctionTemplateServiceImpl.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionBatchModifyVO.java rename src/main/java/club/joylink/rtss/vo/client/mapFunction/{RtsMapFunctionCreateVO.java => MapFunctionCreateVO.java} (96%) rename src/main/java/club/joylink/rtss/vo/client/mapFunction/{RtsMapFunctionGenerateParamVO.java => MapFunctionGenerateParamVO.java} (91%) create mode 100644 src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionGenerateVO.java rename src/main/java/club/joylink/rtss/vo/client/mapFunction/{RtsMapFunctionQueryVO.java => MapFunctionQueryVO.java} (70%) rename src/main/java/club/joylink/rtss/vo/client/mapFunction/{RtsMapFunctionUpdateVO.java => MapFunctionUpdateVO.java} (71%) rename src/main/java/club/joylink/rtss/vo/client/mapFunction/{RtsMapFunctionVO.java => MapFunctionVO.java} (81%) delete mode 100644 src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionDescModifyVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/AssistantParamVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/MapFunctionTemplateCreateVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/MapFunctionTemplateQueryVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/MapFunctionTemplateVO.java create mode 100644 src/main/resources/mybatis/mapper/MapFunctionTemplateDAO.xml diff --git a/src/main/java/club/joylink/rtss/controller/publish/MapFunctionController.java b/src/main/java/club/joylink/rtss/controller/publish/MapFunctionController.java index 57a15d0a4..758659bbb 100644 --- a/src/main/java/club/joylink/rtss/controller/publish/MapFunctionController.java +++ b/src/main/java/club/joylink/rtss/controller/publish/MapFunctionController.java @@ -5,11 +5,15 @@ import club.joylink.rtss.controller.advice.Role; import club.joylink.rtss.dao.RtsMapFunctionDAO; import club.joylink.rtss.services.IMapService; import club.joylink.rtss.services.mapFunction.RtsMapFunctionService; +import club.joylink.rtss.services.mapFunctionTemplate.MapFunctionTemplateService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.mapFunction.*; +import club.joylink.rtss.vo.client.mapFunctionTemplate.MapFunctionTemplateCreateVO; +import club.joylink.rtss.vo.client.mapFunctionTemplate.MapFunctionTemplateQueryVO; +import club.joylink.rtss.vo.client.mapFunctionTemplate.MapFunctionTemplateVO; import club.joylink.rtss.vo.map.MapVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; @@ -21,7 +25,7 @@ import java.util.List; import java.util.Map; /** - * 地图功能管理接口 + * 地图功能及模板管理接口 */ @RestController @RequestMapping("/api/mapFunction") @@ -29,12 +33,15 @@ public class MapFunctionController { @Autowired private RtsMapFunctionService rtsMapFunctionService; + @Autowired + private MapFunctionTemplateService mapFunctionTemplateService; + /** * 创建地图功能 */ @Role(RoleEnum.Admin) @PostMapping("") - public void create(@RequestBody RtsMapFunctionCreateVO createVO, @RequestAttribute LoginUserInfoVO loginInfo) { + public void create(@RequestBody MapFunctionCreateVO createVO, @RequestAttribute LoginUserInfoVO loginInfo) { rtsMapFunctionService.create(createVO, loginInfo.getAccountVO().getId()); } @@ -43,7 +50,7 @@ public class MapFunctionController { */ @Role(RoleEnum.Admin) @PostMapping("/{mapId}/generate") - public List generate(@PathVariable long mapId, @RequestBody @Validated RtsMapFunctionGenerateParamVO paramVO, + public List generate(@PathVariable long mapId, @RequestBody @Validated MapFunctionGenerateParamVO paramVO, @RequestAttribute LoginUserInfoVO loginInfo) { return rtsMapFunctionService.generate(mapId, paramVO, loginInfo.getAccountVO().getId()); } @@ -52,7 +59,7 @@ public class MapFunctionController { * 列表查询地图功能(新) */ @GetMapping("/list") - public List listQuery(RtsMapFunctionQueryVO queryVO) { + public List listQuery(MapFunctionQueryVO queryVO) { return rtsMapFunctionService.listQuery(queryVO); } @@ -60,7 +67,7 @@ public class MapFunctionController { * 分页查询地图功能 */ @GetMapping("/paged") - public PageVO pagedQuery(RtsMapFunctionQueryVO queryVO) { + public PageVO pagedQuery(MapFunctionQueryVO queryVO) { return rtsMapFunctionService.pagedQuery(queryVO); } @@ -87,7 +94,7 @@ public class MapFunctionController { */ @Role(RoleEnum.Admin) @PutMapping("/{id}") - public void update(@PathVariable long id, @RequestBody RtsMapFunctionUpdateVO updateVO, @RequestAttribute LoginUserInfoVO loginInfo) { + public void update(@PathVariable long id, @RequestBody MapFunctionUpdateVO updateVO, @RequestAttribute LoginUserInfoVO loginInfo) { rtsMapFunctionService.update(id, updateVO, loginInfo.getAccountVO().getId()); } @@ -95,7 +102,7 @@ public class MapFunctionController { * 根据ID获取地图功能信息 */ @GetMapping("/{id}") - public RtsMapFunctionVO queryOne(@PathVariable Long id) { + public MapFunctionVO queryOne(@PathVariable Long id) { return rtsMapFunctionService.get(id); } @@ -110,11 +117,61 @@ public class MapFunctionController { } /** - * 批量修改描述 + * 跨线路批量修改线路功能 */ - @PutMapping("/desc/batch") - public void batchModifyDesc(@RequestBody RtsMapFunctionDescModifyVO vo) { - rtsMapFunctionService.batchModifyDesc(vo); + @PutMapping("/crossMap/batch") + public void batchModifyDesc(@RequestBody MapFunctionBatchModifyVO vo) { + rtsMapFunctionService.batchModify(vo); + } + + /** + * 创建 + */ + @PostMapping("/template") + public void create(@RequestBody MapFunctionTemplateCreateVO createVO, @RequestAttribute AccountVO user) { + mapFunctionTemplateService.create(createVO, user.getId()); + } + + /** + * 列表查询 + */ + @GetMapping("/template/list") + public List listQuery(MapFunctionTemplateQueryVO queryVO) { + return mapFunctionTemplateService.listQuery(queryVO); + } + + /** + * 分页查询 + */ + @GetMapping("/template/paged") + public PageVO pagedQuery(MapFunctionTemplateQueryVO queryVO) { + return mapFunctionTemplateService.pagedQuery(queryVO); + } + + /** + * 更新 + */ + @PutMapping("/template/{id}") + public MapFunctionTemplateVO update(@PathVariable long id, @RequestBody MapFunctionTemplateCreateVO createVO, + @RequestAttribute AccountVO user) { + return mapFunctionTemplateService.update(id, createVO, user.getId()); + } + + /** + * 删除 + */ + @DeleteMapping("/template/{id}") + public void deleteTemplate(@PathVariable long id) { + mapFunctionTemplateService.delete(id); + } + + /** + * 根据模板生成地图功能 + * @return 生成过程中的特殊情况日志 + */ + @PostMapping("/generate/from/template") + public List generateFromTemplate(@RequestBody MapFunctionGenerateVO vo, @RequestAttribute AccountVO user) { + return rtsMapFunctionService.generateFromTemplate(vo, user.getId()); } @Autowired @@ -147,7 +204,7 @@ public class MapFunctionController { public void generateAll(@RequestAttribute LoginUserInfoVO loginInfo) { for (MapVO mapVO : iMapService.listOnline()) { MapVO mapDetail = iMapService.getMapDetail(mapVO.getId()); - RtsMapFunctionGenerateParamVO paramVO = new RtsMapFunctionGenerateParamVO(); + MapFunctionGenerateParamVO paramVO = new MapFunctionGenerateParamVO(); List types = new ArrayList<>(); if (mapDetail.getConfigVO().isRailway()) { types.add(Simulation.Type.RAILWAY); diff --git a/src/main/java/club/joylink/rtss/dao/MapFunctionTemplateDAO.java b/src/main/java/club/joylink/rtss/dao/MapFunctionTemplateDAO.java new file mode 100644 index 000000000..fa0a9cf7c --- /dev/null +++ b/src/main/java/club/joylink/rtss/dao/MapFunctionTemplateDAO.java @@ -0,0 +1,39 @@ +package club.joylink.rtss.dao; + +import club.joylink.rtss.entity.MapFunctionTemplate; +import club.joylink.rtss.entity.MapFunctionTemplateExample; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface MapFunctionTemplateDAO { + long countByExample(MapFunctionTemplateExample example); + + int deleteByExample(MapFunctionTemplateExample example); + + int deleteByPrimaryKey(Long id); + + int insert(MapFunctionTemplate record); + + int insertSelective(MapFunctionTemplate record); + + List selectByExampleWithBLOBs(MapFunctionTemplateExample example); + + List selectByExample(MapFunctionTemplateExample example); + + MapFunctionTemplate selectByPrimaryKey(Long id); + + int updateByExampleSelective(@Param("record") MapFunctionTemplate record, @Param("example") MapFunctionTemplateExample example); + + int updateByExampleWithBLOBs(@Param("record") MapFunctionTemplate record, @Param("example") MapFunctionTemplateExample example); + + int updateByExample(@Param("record") MapFunctionTemplate record, @Param("example") MapFunctionTemplateExample example); + + int updateByPrimaryKeySelective(MapFunctionTemplate record); + + int updateByPrimaryKeyWithBLOBs(MapFunctionTemplate record); + + int updateByPrimaryKey(MapFunctionTemplate record); +} diff --git a/src/main/java/club/joylink/rtss/entity/MapFunctionTemplate.java b/src/main/java/club/joylink/rtss/entity/MapFunctionTemplate.java new file mode 100644 index 000000000..9b6f1617a --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/MapFunctionTemplate.java @@ -0,0 +1,154 @@ +package club.joylink.rtss.entity; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * @author + * 地图功能模板 + */ +public class MapFunctionTemplate implements Serializable { + private Long id; + + private String name; + + /** + * 辅助参数(如默认角色类型) + */ + private String assistantParam; + + private LocalDateTime createTime; + + private Long creatorId; + + private LocalDateTime updateTime; + + private Long updaterId; + + /** + * 地图功能参数 + */ + private String mapFunctionParam; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAssistantParam() { + return assistantParam; + } + + public void setAssistantParam(String assistantParam) { + this.assistantParam = assistantParam; + } + + public LocalDateTime getCreateTime() { + return createTime; + } + + public void setCreateTime(LocalDateTime createTime) { + this.createTime = createTime; + } + + public Long getCreatorId() { + return creatorId; + } + + public void setCreatorId(Long creatorId) { + this.creatorId = creatorId; + } + + public LocalDateTime getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(LocalDateTime updateTime) { + this.updateTime = updateTime; + } + + public Long getUpdaterId() { + return updaterId; + } + + public void setUpdaterId(Long updaterId) { + this.updaterId = updaterId; + } + + public String getMapFunctionParam() { + return mapFunctionParam; + } + + public void setMapFunctionParam(String mapFunctionParam) { + this.mapFunctionParam = mapFunctionParam; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + MapFunctionTemplate other = (MapFunctionTemplate) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName())) + && (this.getAssistantParam() == null ? other.getAssistantParam() == null : this.getAssistantParam().equals(other.getAssistantParam())) + && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) + && (this.getCreatorId() == null ? other.getCreatorId() == null : this.getCreatorId().equals(other.getCreatorId())) + && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) + && (this.getUpdaterId() == null ? other.getUpdaterId() == null : this.getUpdaterId().equals(other.getUpdaterId())) + && (this.getMapFunctionParam() == null ? other.getMapFunctionParam() == null : this.getMapFunctionParam().equals(other.getMapFunctionParam())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); + result = prime * result + ((getAssistantParam() == null) ? 0 : getAssistantParam().hashCode()); + result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); + result = prime * result + ((getCreatorId() == null) ? 0 : getCreatorId().hashCode()); + result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); + result = prime * result + ((getUpdaterId() == null) ? 0 : getUpdaterId().hashCode()); + result = prime * result + ((getMapFunctionParam() == null) ? 0 : getMapFunctionParam().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", name=").append(name); + sb.append(", assistantParam=").append(assistantParam); + sb.append(", createTime=").append(createTime); + sb.append(", creatorId=").append(creatorId); + sb.append(", updateTime=").append(updateTime); + sb.append(", updaterId=").append(updaterId); + sb.append(", mapFunctionParam=").append(mapFunctionParam); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} diff --git a/src/main/java/club/joylink/rtss/entity/MapFunctionTemplateExample.java b/src/main/java/club/joylink/rtss/entity/MapFunctionTemplateExample.java new file mode 100644 index 000000000..ec8cb4268 --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/MapFunctionTemplateExample.java @@ -0,0 +1,663 @@ +package club.joylink.rtss.entity; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +public class MapFunctionTemplateExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public MapFunctionTemplateExample() { + 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 andNameIsNull() { + addCriterion("`name` is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("`name` is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("`name` =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("`name` <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("`name` >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("`name` >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("`name` <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("`name` <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("`name` like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("`name` not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("`name` in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("`name` not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("`name` between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("`name` not between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andAssistantParamIsNull() { + addCriterion("assistant_param is null"); + return (Criteria) this; + } + + public Criteria andAssistantParamIsNotNull() { + addCriterion("assistant_param is not null"); + return (Criteria) this; + } + + public Criteria andAssistantParamEqualTo(String value) { + addCriterion("assistant_param =", value, "assistantParam"); + return (Criteria) this; + } + + public Criteria andAssistantParamNotEqualTo(String value) { + addCriterion("assistant_param <>", value, "assistantParam"); + return (Criteria) this; + } + + public Criteria andAssistantParamGreaterThan(String value) { + addCriterion("assistant_param >", value, "assistantParam"); + return (Criteria) this; + } + + public Criteria andAssistantParamGreaterThanOrEqualTo(String value) { + addCriterion("assistant_param >=", value, "assistantParam"); + return (Criteria) this; + } + + public Criteria andAssistantParamLessThan(String value) { + addCriterion("assistant_param <", value, "assistantParam"); + return (Criteria) this; + } + + public Criteria andAssistantParamLessThanOrEqualTo(String value) { + addCriterion("assistant_param <=", value, "assistantParam"); + return (Criteria) this; + } + + public Criteria andAssistantParamLike(String value) { + addCriterion("assistant_param like", value, "assistantParam"); + return (Criteria) this; + } + + public Criteria andAssistantParamNotLike(String value) { + addCriterion("assistant_param not like", value, "assistantParam"); + return (Criteria) this; + } + + public Criteria andAssistantParamIn(List values) { + addCriterion("assistant_param in", values, "assistantParam"); + return (Criteria) this; + } + + public Criteria andAssistantParamNotIn(List values) { + addCriterion("assistant_param not in", values, "assistantParam"); + return (Criteria) this; + } + + public Criteria andAssistantParamBetween(String value1, String value2) { + addCriterion("assistant_param between", value1, value2, "assistantParam"); + return (Criteria) this; + } + + public Criteria andAssistantParamNotBetween(String value1, String value2) { + addCriterion("assistant_param not between", value1, value2, "assistantParam"); + 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 values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List 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 andCreatorIdIsNull() { + addCriterion("creator_id is null"); + return (Criteria) this; + } + + public Criteria andCreatorIdIsNotNull() { + addCriterion("creator_id is not null"); + return (Criteria) this; + } + + public Criteria andCreatorIdEqualTo(Long value) { + addCriterion("creator_id =", value, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdNotEqualTo(Long value) { + addCriterion("creator_id <>", value, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdGreaterThan(Long value) { + addCriterion("creator_id >", value, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdGreaterThanOrEqualTo(Long value) { + addCriterion("creator_id >=", value, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdLessThan(Long value) { + addCriterion("creator_id <", value, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdLessThanOrEqualTo(Long value) { + addCriterion("creator_id <=", value, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdIn(List values) { + addCriterion("creator_id in", values, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdNotIn(List values) { + addCriterion("creator_id not in", values, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdBetween(Long value1, Long value2) { + addCriterion("creator_id between", value1, value2, "creatorId"); + return (Criteria) this; + } + + public Criteria andCreatorIdNotBetween(Long value1, Long value2) { + addCriterion("creator_id not between", value1, value2, "creatorId"); + 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 values) { + addCriterion("update_time in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotIn(List 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; + } + + public Criteria andUpdaterIdIsNull() { + addCriterion("updater_id is null"); + return (Criteria) this; + } + + public Criteria andUpdaterIdIsNotNull() { + addCriterion("updater_id is not null"); + return (Criteria) this; + } + + public Criteria andUpdaterIdEqualTo(Long value) { + addCriterion("updater_id =", value, "updaterId"); + return (Criteria) this; + } + + public Criteria andUpdaterIdNotEqualTo(Long value) { + addCriterion("updater_id <>", value, "updaterId"); + return (Criteria) this; + } + + public Criteria andUpdaterIdGreaterThan(Long value) { + addCriterion("updater_id >", value, "updaterId"); + return (Criteria) this; + } + + public Criteria andUpdaterIdGreaterThanOrEqualTo(Long value) { + addCriterion("updater_id >=", value, "updaterId"); + return (Criteria) this; + } + + public Criteria andUpdaterIdLessThan(Long value) { + addCriterion("updater_id <", value, "updaterId"); + return (Criteria) this; + } + + public Criteria andUpdaterIdLessThanOrEqualTo(Long value) { + addCriterion("updater_id <=", value, "updaterId"); + return (Criteria) this; + } + + public Criteria andUpdaterIdIn(List values) { + addCriterion("updater_id in", values, "updaterId"); + return (Criteria) this; + } + + public Criteria andUpdaterIdNotIn(List values) { + addCriterion("updater_id not in", values, "updaterId"); + return (Criteria) this; + } + + public Criteria andUpdaterIdBetween(Long value1, Long value2) { + addCriterion("updater_id between", value1, value2, "updaterId"); + return (Criteria) this; + } + + public Criteria andUpdaterIdNotBetween(Long value1, Long value2) { + addCriterion("updater_id not between", value1, value2, "updaterId"); + 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); + } + } +} diff --git a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionService.java b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionService.java index fcb1d6fb2..5eda7810b 100644 --- a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionService.java +++ b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionService.java @@ -7,23 +7,23 @@ import java.util.List; import java.util.Map; public interface RtsMapFunctionService { - void create(RtsMapFunctionCreateVO createVO, long creatorId); + void create(MapFunctionCreateVO createVO, long creatorId); void delete(long id); - void update(long id, RtsMapFunctionUpdateVO updateVO, long updaterId); + void update(long id, MapFunctionUpdateVO updateVO, long updaterId); - RtsMapFunctionVO get(long id); + MapFunctionVO get(long id); /** * 列表查询地图子系统 */ - List listQuery(RtsMapFunctionQueryVO queryVO); + List listQuery(MapFunctionQueryVO queryVO); /** * 分页查询地图子系统 */ - PageVO pagedQuery(RtsMapFunctionQueryVO queryVO); + PageVO pagedQuery(MapFunctionQueryVO queryVO); /** * 生成线路功能 @@ -32,7 +32,7 @@ public interface RtsMapFunctionService { * @param paramVO 指示生成内容的参数 * @return 一些特殊的,但是算不上异常的信息 */ - List generate(long mapId, RtsMapFunctionGenerateParamVO paramVO, long creatorId); + List generate(long mapId, MapFunctionGenerateParamVO paramVO, long creatorId); /** * 生成大客流线路功能 @@ -51,5 +51,10 @@ public interface RtsMapFunctionService { void updateGroup(Map> groupMap, Long updaterId); - void batchModifyDesc(RtsMapFunctionDescModifyVO vo); + /** + * 批量修改线路功能数据。目前所有的where条件(见参数的注释)为或 + */ + void batchModify(MapFunctionBatchModifyVO vo); + + List generateFromTemplate(MapFunctionGenerateVO vo, Long userId); } diff --git a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java index 9ff80b77c..01904ecf1 100644 --- a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java @@ -11,6 +11,7 @@ import club.joylink.rtss.entity.RtsMapFunction; import club.joylink.rtss.entity.RtsMapFunctionExample; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.IMapService; +import club.joylink.rtss.services.mapFunctionTemplate.MapFunctionTemplateService; import club.joylink.rtss.services.publishData.MapPassengerFlowDataService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; @@ -18,6 +19,7 @@ import club.joylink.rtss.simulation.cbtc.training2.Training2; import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.mapFunction.*; +import club.joylink.rtss.vo.client.mapFunctionTemplate.MapFunctionTemplateVO; import club.joylink.rtss.vo.client.passenger.MapPassengerFlowVO; import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.map.graph.MapMemberVO; @@ -32,6 +34,7 @@ import org.springframework.util.StringUtils; import java.time.LocalDateTime; import java.util.*; +import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -43,9 +46,11 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { private IMapService iMapService; @Autowired private MapPassengerFlowDataService mapPassengerFlowDataService; + @Autowired + private MapFunctionTemplateService mapFunctionTemplateService; @Override - public void create(RtsMapFunctionCreateVO createVO, long creatorId) { + public void create(MapFunctionCreateVO createVO, long creatorId) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(createVO.getMapId()); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(createVO.getName()); confirmNameNotExist(createVO.getMapId(), createVO.getName()); @@ -61,7 +66,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { } @Override - public void update(long id, RtsMapFunctionUpdateVO updateVO, long updaterId) { + public void update(long id, MapFunctionUpdateVO updateVO, long updaterId) { RtsMapFunction entity = getEntity(id); updateVO.override(entity); entity.setUpdaterId(updaterId); @@ -70,13 +75,13 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { } @Override - public RtsMapFunctionVO get(long id) { + public MapFunctionVO get(long id) { RtsMapFunction entity = getEntity(id); - return new RtsMapFunctionVO(entity); + return new MapFunctionVO(entity); } @Override - public List listQuery(RtsMapFunctionQueryVO queryVO) { + public List listQuery(MapFunctionQueryVO queryVO) { RtsMapFunctionExample example = new RtsMapFunctionExample(); RtsMapFunctionExample.Criteria criteria = example.createCriteria(); if (queryVO.getMapId() != null) @@ -85,20 +90,25 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { criteria.andNameLike(queryVO.getName()); if (queryVO.getSimType() != null) criteria.andTypeEqualTo(queryVO.getSimType().name()); - List entities = rtsMapFunctionDAO.selectByExampleWithBLOBs(example); - return entities.stream().map(RtsMapFunctionVO::new).collect(Collectors.toList()); + List entities; + if (queryVO.isDetail()) { + entities = rtsMapFunctionDAO.selectByExampleWithBLOBs(example); + } else { + entities = rtsMapFunctionDAO.selectByExample(example); + } + return entities.stream().map(MapFunctionVO::new).collect(Collectors.toList()); } @Override - public PageVO pagedQuery(RtsMapFunctionQueryVO queryVO) { + public PageVO pagedQuery(MapFunctionQueryVO queryVO) { Page page = PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); - List list = listQuery(queryVO); + List list = listQuery(queryVO); return PageVO.convert(page, list); } @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) @Override - public List generate(long mapId, RtsMapFunctionGenerateParamVO paramVO, long creatorId) { + public List generate(long mapId, MapFunctionGenerateParamVO paramVO, long creatorId) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(paramVO.getSimTypes(), "要生成子系统的仿真系统类型不能为空"); //查询所有旧数据 @@ -110,7 +120,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { String msgPrefix; List mapMemberVOS; - List> createVOSuppliers; + List> createVOSuppliers; for (Simulation.Type simType : paramVO.getSimTypes()) { mapMemberVOS = mapData.getGraphDataNew().getMemberMap().get(simType); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertCollectionNotEmpty(mapMemberVOS, @@ -132,8 +142,8 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { throw new IllegalStateException("Unexpected value: " + simType); } //填充参数并创建子系统 - for (Supplier supplier : createVOSuppliers) { - RtsMapFunctionCreateVO createVO = supplier.get(); + for (Supplier supplier : createVOSuppliers) { + MapFunctionCreateVO createVO = supplier.get(); if (createVO != null) { create(createVO, creatorId); } @@ -172,8 +182,8 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { Map itemMap = new HashMap<>(); itemMap.put(SimulationWorkParamVO.Item.LPF, pfDataList.get(0).getId().toString()); //配置加载大客流数据 dispatcherOptional.ifPresent(mapMemberVO -> itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, mapMemberVO.getId())); //配置默认成员 - RtsMapFunctionCreateVO rtsMapFunctionCreateVO = buildCreateVO(mapId, name, name, Simulation.Type.METRO, null, itemMap, domConfig); - create(rtsMapFunctionCreateVO, creatorId); + MapFunctionCreateVO mapFunctionCreateVO = buildCreateVO(mapId, name, name, Simulation.Type.METRO, null, itemMap, domConfig); + create(mapFunctionCreateVO, creatorId); return msgList; } @@ -231,7 +241,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { boolean hasTraining = false; boolean hasExam = false; for (MapSystem mapSystem : mapSystems) { - Supplier supplier; + Supplier supplier; if (mapSystem.getType().equals("Simulation")) { MapPrdTypeEnum prdType = MapPrdTypeEnum.getMapPrdTypeEnumByCode(mapSystem.getPrdType()); switch (prdType) { @@ -277,24 +287,24 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { default: throw new RuntimeException(); } - RtsMapFunctionCreateVO rtsMapFunctionCreateVO = supplier.get(); - if (rtsMapFunctionCreateVO != null) { - create(rtsMapFunctionCreateVO, 1); + MapFunctionCreateVO mapFunctionCreateVO = supplier.get(); + if (mapFunctionCreateVO != null) { + create(mapFunctionCreateVO, 1); } } else if (mapSystem.getType().equals("Lesson")) { if (!hasTraining) { hasTraining = true; - RtsMapFunctionCreateVO rtsMapFunctionCreateVO = getSingleOperationTrainingFunctionSupplier(mapId, systemNameSet, msgList, simType).get(); - if (rtsMapFunctionCreateVO != null) { - create(rtsMapFunctionCreateVO, 1); + MapFunctionCreateVO mapFunctionCreateVO = getSingleOperationTrainingFunctionSupplier(mapId, systemNameSet, msgList, simType).get(); + if (mapFunctionCreateVO != null) { + create(mapFunctionCreateVO, 1); } } } else if (mapSystem.getType().equals("Exam")) { if (!hasExam) { hasExam = true; - RtsMapFunctionCreateVO rtsMapFunctionCreateVO = getExamFunctionSupplier(mapId, systemNameSet, msgList, simType).get(); - if (rtsMapFunctionCreateVO != null) { - create(rtsMapFunctionCreateVO, 1); + MapFunctionCreateVO mapFunctionCreateVO = getExamFunctionSupplier(mapId, systemNameSet, msgList, simType).get(); + if (mapFunctionCreateVO != null) { + create(mapFunctionCreateVO, 1); } } } else { @@ -324,23 +334,72 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { } @Override - public void batchModifyDesc(RtsMapFunctionDescModifyVO vo) { - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(StringUtils.hasText(vo.getFunctionName()) || StringUtils.hasText(vo.getOriginalDesc()), - "功能名称和原描述至少填一个"); - - RtsMapFunctionExample example = new RtsMapFunctionExample(); - if (StringUtils.hasText(vo.getFunctionName())) { - example.or().andNameEqualTo(vo.getFunctionName()); - } - if (StringUtils.hasText(vo.getOriginalDesc())) { - example.or().andDescEqualTo(vo.getOriginalDesc()); - } - rtsMapFunctionDAO.updateByExampleSelective(vo.convert2DB(), example); + public void batchModify(MapFunctionBatchModifyVO vo) { + MapFunctionBatchModifyVO.DescModifyParamVO descModifyParamVO = vo.getDescModifyParamVO(); + MapFunctionBatchModifyVO.BgUrlModifyParamVO bgUrlModifyParamVO = vo.getBgUrlModifyParamVO(); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(descModifyParamVO != null || bgUrlModifyParamVO != null); +// descModifyParamVO. } - private RtsMapFunctionCreateVO buildCreateVO(long mapId, String name, String desc, Simulation.Type simType, String group, - Map itemMap, SimulationWorkParamVO.DomConfigVO domConfig) { - RtsMapFunctionCreateVO createVO = new RtsMapFunctionCreateVO(); + @Override + public List generateFromTemplate(MapFunctionGenerateVO generateVO, Long userId) { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(generateVO.getTemplateIds()); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(generateVO.getMapIds()); + + List msgList = new ArrayList<>(); + List templates = mapFunctionTemplateService.queryWithBLOBs(generateVO.getTemplateIds()); + List checkedTemplates = new ArrayList<>(); + for (MapFunctionTemplateVO template : templates) { + if (template.getMapFunctionParam() != null && StringUtils.hasText(template.getMapFunctionParam().getName()) && template.getMapFunctionParam().getParamVO() != null) { + checkedTemplates.add(template); + } else { + msgList.add(String.format("模板[id:%s][名称:%s]地图功能必要参数不足,未生成功能", template.getId(), template.getName())); + } + } + + + MapFunctionQueryVO mapFunctionQueryVO = new MapFunctionQueryVO(); + for (Long mapId : generateVO.getMapIds()) { + MapVO mapDetail = iMapService.getMapDetail(mapId); + mapFunctionQueryVO.setMapId(mapId); + Map existMapFuncMap = listQuery(mapFunctionQueryVO).stream() + .collect(Collectors.toMap(MapFunctionVO::getName, Function.identity())); + for (MapFunctionTemplateVO template : checkedTemplates) { + MapFunctionCreateVO mapFunctionParam = template.getMapFunctionParam(); + MapFunctionVO existMapFunc = existMapFuncMap.get(mapFunctionParam.getName()); + if (existMapFunc != null && !generateVO.isOverwrite()) { + msgList.add(String.format("模板[名称:%s]指定的地图功能名称[%s]已存在,未生成", template.getName(), mapFunctionParam.getName())); + } + if (template.getAssistantParam() != null && StringUtils.hasText(template.getAssistantParam().getDefaultMemberType())) { + String memberType = template.getAssistantParam().getDefaultMemberType(); + List mapMemberVOS = mapDetail.getGraphDataNew().getMemberMap().get(mapFunctionParam.getParamVO().getType()); + if (!CollectionUtils.isEmpty(mapMemberVOS)) { + Optional optional = mapMemberVOS.stream() + .filter(member -> member.getType().name().equals(memberType)) + .findFirst(); + if (optional.isEmpty()) { + msgList.add(String.format("地图[名:%s]不存在模板[名:%s]所指定类型[%s]的角色", mapDetail.getName(), template.getName(), memberType)); + } else { + mapFunctionParam.getParamVO().getItemMap().put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, optional.get().getId()); + } + } + } + mapFunctionParam.setMapId(mapId); + if (existMapFunc != null && generateVO.isOverwrite()) { + update(existMapFunc.getId(), new MapFunctionUpdateVO(mapFunctionParam), userId); + } + if (existMapFunc == null) { + create(mapFunctionParam, userId); + } + } + } + return msgList; + } + + + private MapFunctionCreateVO buildCreateVO(long mapId, String name, String desc, Simulation.Type simType, String group, + Map itemMap, SimulationWorkParamVO.DomConfigVO domConfig) { + MapFunctionCreateVO createVO = new MapFunctionCreateVO(); createVO.setMapId(mapId); createVO.setName(name); createVO.setDesc(desc); @@ -354,7 +413,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { } /** - * 构建提供{@link RtsMapFunctionCreateVO}的方法 + * 构建提供{@link MapFunctionCreateVO}的方法 * * @param mapId * @param systemNameSet 已存在的子系统名称,这些子系统不再生成 @@ -362,26 +421,26 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { * @param msgPrefix 特殊信息的统一前缀 * @param simType 仿真类型 * @param mapMemberVOS 地图成员列表 - * @return 调用apply方法时,当该地图子系统无法或无需创建时,返回null,否则返回填充好所有参数的{@link RtsMapFunctionCreateVO} + * @return 调用apply方法时,当该地图子系统无法或无需创建时,返回null,否则返回填充好所有参数的{@link MapFunctionCreateVO} */ - private List> buildMetroSystemCreateVOSuppliers(long mapId, Set systemNameSet, List msgList, String msgPrefix, Simulation.Type simType, List mapMemberVOS) { - List> fillFunctions = new ArrayList<>(); + private List> buildMetroSystemCreateVOSuppliers(long mapId, Set systemNameSet, List msgList, String msgPrefix, Simulation.Type simType, List mapMemberVOS) { + List> fillFunctions = new ArrayList<>(); Optional dispatcherOptional = mapMemberVOS.stream() .filter(member -> Objects.equals(member.getType(), SimulationMember.Type.DISPATCHER)) .findFirst(); Optional stationSupervisorOptional = mapMemberVOS.stream() .filter(member -> Objects.equals(member.getType(), SimulationMember.Type.STATION_SUPERVISOR)) .findFirst(); - Supplier dispatchSystem = getDispatcherFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); - Supplier stationSystem = getStationFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, stationSupervisorOptional); - Supplier driveSystem = getDriverFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, mapMemberVOS); - Supplier dispatchTrainingSystem = getSingleOperationTrainingFunctionSupplier(mapId, systemNameSet, msgList, simType); - Supplier stationTrainingSystem = getSceneTrainingFunctionSupplier(mapId, systemNameSet, msgList, simType); - Supplier stationExamSystem = getExamFunctionSupplier(mapId, systemNameSet, msgList, simType); - Supplier joint = getJointFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); - Supplier trainingDesign = getTrainingDesignFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); - Supplier trainingRoom = getTrainingRoomFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType); - Supplier runPlanDesign = getRunPlanDesignFunctionSupplier(mapId, systemNameSet, msgList, simType); + Supplier dispatchSystem = getDispatcherFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); + Supplier stationSystem = getStationFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, stationSupervisorOptional); + Supplier driveSystem = getDriverFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, mapMemberVOS); + Supplier dispatchTrainingSystem = getSingleOperationTrainingFunctionSupplier(mapId, systemNameSet, msgList, simType); + Supplier stationTrainingSystem = getSceneTrainingFunctionSupplier(mapId, systemNameSet, msgList, simType); + Supplier stationExamSystem = getExamFunctionSupplier(mapId, systemNameSet, msgList, simType); + Supplier joint = getJointFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); + Supplier trainingDesign = getTrainingDesignFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); + Supplier trainingRoom = getTrainingRoomFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType); + Supplier runPlanDesign = getRunPlanDesignFunctionSupplier(mapId, systemNameSet, msgList, simType); fillFunctions.add(dispatchSystem); fillFunctions.add(stationSystem); @@ -396,7 +455,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { return fillFunctions; } - private Supplier getTrainingRoomFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, Simulation.Type simType) { + private Supplier getTrainingRoomFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, Simulation.Type simType) { return () -> { String name = "实训室"; String desc = "根据用户需求不同,搭配硬件设备组件实训室,进行软硬件的联动培训。"; @@ -414,7 +473,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { }; } - private Supplier getTrainingDesignFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, Simulation.Type simType, Optional dispatcherOptional) { + private Supplier getTrainingDesignFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, Simulation.Type simType, Optional dispatcherOptional) { return () -> { String name = "实训设计"; String desc = "可编制单岗位的站场图设备操作或设计多岗位的脚本化场景以供单操实训或场景实训使用。"; @@ -438,7 +497,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { }; } - private Supplier getJointFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, Simulation.Type simType, Optional dispatcherOptional) { + private Supplier getJointFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, Simulation.Type simType, Optional dispatcherOptional) { //综合演练 return () -> { String name = "综合演练"; @@ -463,7 +522,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { }; } - private Supplier getExamFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { + private Supplier getExamFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { return () -> { String name = "考试"; String desc = "从理论、单操实训、场景实训三个方面进行设计、用户可在该功能中在线实时考试,自动评分。"; @@ -479,7 +538,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { }; } - private Supplier getSceneTrainingFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { + private Supplier getSceneTrainingFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { return () -> { String name = "场景实训"; String desc = "以不同故障场景为剧本,培训各岗位在故障情境下的配合调度能力,包含各个故障场景下的标准应急流程及联动用语。" + @@ -498,7 +557,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { }; } - private Supplier getSingleOperationTrainingFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { + private Supplier getSingleOperationTrainingFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { return () -> { String name = "单操实训"; String desc = "针对行调及行值人员的具体功能操作进行解析形成专业实操课程。单操实训系统具有教学、练习及测验三种模式。"; @@ -515,8 +574,8 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { }; } - private Supplier getDriverFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, - Simulation.Type simType, List mapMemberVOS) { + private Supplier getDriverFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, List mapMemberVOS) { return () -> { String name = "模拟驾驶"; String desc = "桌面版模拟驾驶仿真系统,操作驾驶界面与真实车辆驾驶台保持一致,可完成对列车驾驶的操作动作、技术、规则和技巧的练习。"; @@ -541,8 +600,8 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { }; } - private Supplier getStationFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, - Simulation.Type simType, Optional stationSupervisorOptional) { + private Supplier getStationFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, Optional stationSupervisorOptional) { //ATS现地工作站 return () -> { String name = "车站仿真"; @@ -566,8 +625,8 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { }; } - private Supplier getDispatcherFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, - Simulation.Type simType, Optional dispatcherOptional) { + private Supplier getDispatcherFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, Optional dispatcherOptional) { return () -> { String name = "调度仿真"; String desc = "调度仿真是面向地铁运营的行车调度员操作技能和专业能力培训的功能,能够实现设备的各种正常操作及常见故障仿真。"; @@ -591,30 +650,30 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { } /** - * 构建大铁填充{@link RtsMapFunctionCreateVO}的方法列表 + * 构建大铁填充{@link MapFunctionCreateVO}的方法列表 * * @param systemNameSet 已存在的子系统名称的集合 * @param msgList 记录特殊的,但是不算异常的信息 * @param msgPrefix msgList内容的统一前缀 * @param mapMemberVOS 地图数据中的成员列表 - * @return 调用apply方法时,当地图子系统的参数有问题无法创建子系统时,返回null,否则返回填充好所有参数的{@link RtsMapFunctionCreateVO} + * @return 调用apply方法时,当地图子系统的参数有问题无法创建子系统时,返回null,否则返回填充好所有参数的{@link MapFunctionCreateVO} */ - private List> buildRailwayFillCreateVOSuppliers(long mapId, Set systemNameSet, List msgList, String msgPrefix, - Simulation.Type simType, List mapMemberVOS) { - List> fillFunctions = new ArrayList<>(); + private List> buildRailwayFillCreateVOSuppliers(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, List mapMemberVOS) { + List> fillFunctions = new ArrayList<>(); Optional dispatcherOptional = mapMemberVOS.stream() .filter(member -> Objects.equals(member.getType(), SimulationMember.Type.DISPATCHER)) .findFirst(); Optional stationSupervisorOptional = mapMemberVOS.stream() .filter(member -> Objects.equals(member.getType(), SimulationMember.Type.STATION_SUPERVISOR)) .findFirst(); - Supplier dispatchSystem = getRailDispatcherFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); - Supplier stationSystem = getRailStationFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, stationSupervisorOptional); - Supplier singleOperationTrainingFunctionSupplier = getSingleOperationTrainingFunctionSupplier(mapId, systemNameSet, msgList, simType); - Supplier sceneTrainingFunctionSupplier = getSceneTrainingFunctionSupplier(mapId, systemNameSet, msgList, simType); - Supplier examFunctionSupplier = getExamFunctionSupplier(mapId, systemNameSet, msgList, simType); - Supplier joint = getJointFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); - Supplier trainingDesign = getTrainingDesignFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); + Supplier dispatchSystem = getRailDispatcherFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); + Supplier stationSystem = getRailStationFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, stationSupervisorOptional); + Supplier singleOperationTrainingFunctionSupplier = getSingleOperationTrainingFunctionSupplier(mapId, systemNameSet, msgList, simType); + Supplier sceneTrainingFunctionSupplier = getSceneTrainingFunctionSupplier(mapId, systemNameSet, msgList, simType); + Supplier examFunctionSupplier = getExamFunctionSupplier(mapId, systemNameSet, msgList, simType); + Supplier joint = getJointFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); + Supplier trainingDesign = getTrainingDesignFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional); fillFunctions.add(dispatchSystem); fillFunctions.add(stationSystem); @@ -627,8 +686,8 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { return fillFunctions; } - private Supplier getRailStationFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, - Simulation.Type simType, Optional stationSupervisorOptional) { + private Supplier getRailStationFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, Optional stationSupervisorOptional) { return () -> { String name = "车站"; String desc = "模拟列车值班员工作站,用于完成铁路运输接发列车工作、铁路运输行车指挥协调、组织管理。仿真包括:联锁操作终端、车务终端、车务管理终端等终端。"; @@ -651,8 +710,8 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { }; } - private Supplier getRailDispatcherFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, - Simulation.Type simType, Optional dispatcherOptional) { + private Supplier getRailDispatcherFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, Optional dispatcherOptional) { return () -> { String name = "调度台"; String desc = "模拟列车调度员工作站,具有运行计划的管理、阶段计划下达、调度命令下达等功能。"; @@ -674,8 +733,8 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { }; } - private Supplier getSchedulingFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, - Simulation.Type simType, Optional dispatcherOptional) { + private Supplier getSchedulingFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, Optional dispatcherOptional) { return () -> { String name = "派班"; String desc = "模拟真实派班员的岗位操作系统,与真实城轨派班员的工作站操控保持一致,学员可根据列车运行图要求和车辆完好情况," + @@ -698,8 +757,8 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { }; } - private Supplier getIscsFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, - Simulation.Type simType, Optional dispatcherOptional) { + private Supplier getIscsFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, Optional dispatcherOptional) { return () -> { String name = "综合监控"; if (systemNameSet.contains(name)) { @@ -720,7 +779,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { }; } - private Supplier getRunPlanDesignFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { + private Supplier getRunPlanDesignFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { return () -> { String name = "运行图编制"; String desc = "运行图编辑系统是一套在线运行图编辑测试工具软件,具有运行图导入、导出功能及新图测试功能。" + @@ -737,7 +796,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { }; } - private Supplier getBigScreenFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { + private Supplier getBigScreenFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { return () -> { String name = "中心大屏"; if (systemNameSet.contains(name)) { @@ -752,8 +811,8 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { }; } - private Supplier getDepotILFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, - Simulation.Type simType, List mapMemberVOS) { + private Supplier getDepotILFunctionSupplier(long mapId, Set systemNameSet, List msgList, String msgPrefix, + Simulation.Type simType, List mapMemberVOS) { return () -> { String name = "车辆段调度"; String desc = "模拟真实车辆段调度员岗位的操作系统,停车场/车辆段是对车辆进行运营管理、停放及维修、保养的场所,由车场调度员统一指挥。"; @@ -775,20 +834,20 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { }; } - private List> buildEmergencyFillCreateVOSuppliers(long mapId, Set systemNameSet, - List msgList, String msgPrefix, - Simulation.Type simType, List mapMemberVOS) { - List> fillFunctions = new ArrayList<>(); - Supplier system = getEmergencyFunctionSupplier(mapId, systemNameSet, msgList, simType); + private List> buildEmergencyFillCreateVOSuppliers(long mapId, Set systemNameSet, + List msgList, String msgPrefix, + Simulation.Type simType, List mapMemberVOS) { + List> fillFunctions = new ArrayList<>(); + Supplier system = getEmergencyFunctionSupplier(mapId, systemNameSet, msgList, simType); fillFunctions.add(system); return fillFunctions; } - private Supplier getEmergencyFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { + private Supplier getEmergencyFunctionSupplier(long mapId, Set systemNameSet, List msgList, Simulation.Type simType) { //应急调度指挥系统 - Supplier system = () -> { + Supplier system = () -> { String name = "应急调度指挥仿真"; if (systemNameSet.contains(name)) { msgList.add(String.format("%s已存在,不生成", name)); @@ -831,7 +890,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { return rtsMapFunctionDAO.selectByExample(example); } - private interface Group{ + private interface Group { String SIMULATION = "仿真功能"; String TEACH = "教考功能"; String DESIGN = "设计功能"; diff --git a/src/main/java/club/joylink/rtss/services/mapFunctionTemplate/MapFunctionTemplateService.java b/src/main/java/club/joylink/rtss/services/mapFunctionTemplate/MapFunctionTemplateService.java new file mode 100644 index 000000000..b274c2f66 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/mapFunctionTemplate/MapFunctionTemplateService.java @@ -0,0 +1,22 @@ +package club.joylink.rtss.services.mapFunctionTemplate; + +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.mapFunctionTemplate.MapFunctionTemplateCreateVO; +import club.joylink.rtss.vo.client.mapFunctionTemplate.MapFunctionTemplateQueryVO; +import club.joylink.rtss.vo.client.mapFunctionTemplate.MapFunctionTemplateVO; + +import java.util.List; + +public interface MapFunctionTemplateService { + void create(MapFunctionTemplateCreateVO createVO, long creatorId); + + List listQuery(MapFunctionTemplateQueryVO queryVO); + + MapFunctionTemplateVO update(long id, MapFunctionTemplateCreateVO createVO, long updaterId); + + void delete(long id); + + List queryWithBLOBs(List templateIds); + + PageVO pagedQuery(MapFunctionTemplateQueryVO queryVO); +} diff --git a/src/main/java/club/joylink/rtss/services/mapFunctionTemplate/MapFunctionTemplateServiceImpl.java b/src/main/java/club/joylink/rtss/services/mapFunctionTemplate/MapFunctionTemplateServiceImpl.java new file mode 100644 index 000000000..93737c5f8 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/mapFunctionTemplate/MapFunctionTemplateServiceImpl.java @@ -0,0 +1,77 @@ +package club.joylink.rtss.services.mapFunctionTemplate; + +import club.joylink.rtss.dao.MapFunctionTemplateDAO; +import club.joylink.rtss.entity.MapFunctionTemplate; +import club.joylink.rtss.entity.MapFunctionTemplateExample; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.client.mapFunctionTemplate.MapFunctionTemplateCreateVO; +import club.joylink.rtss.vo.client.mapFunctionTemplate.MapFunctionTemplateQueryVO; +import club.joylink.rtss.vo.client.mapFunctionTemplate.MapFunctionTemplateVO; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.List; + +@Service +public class MapFunctionTemplateServiceImpl implements MapFunctionTemplateService { + @Autowired + private MapFunctionTemplateDAO mapFunctionTemplateDAO; + + @Override + public void create(MapFunctionTemplateCreateVO createVO, long creatorId) { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(createVO.getName()); + MapFunctionTemplate template = createVO.convert2DB(); + template.setCreateTime(LocalDateTime.now()); + template.setCreatorId(creatorId); + mapFunctionTemplateDAO.insert(template); + } + + @Override + public List listQuery(MapFunctionTemplateQueryVO queryVO) { + List entities = mapFunctionTemplateDAO.selectByExampleWithBLOBs(null); + return MapFunctionTemplateVO.convertFrom(entities); + } + + @Override + public MapFunctionTemplateVO update(long id, MapFunctionTemplateCreateVO createVO, long updaterId) { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(createVO.getName()); + MapFunctionTemplate entity = createVO.convert2DB(); + entity.setId(id); + entity.setUpdateTime(LocalDateTime.now()); + entity.setUpdaterId(updaterId); + mapFunctionTemplateDAO.updateByPrimaryKeySelective(entity); + return new MapFunctionTemplateVO(entity); + } + + @Override + public void delete(long id) { + mapFunctionTemplateDAO.deleteByPrimaryKey(id); + } + + @Override + public List queryWithBLOBs(List templateIds) { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(templateIds); + MapFunctionTemplateExample example = new MapFunctionTemplateExample(); + example.createCriteria().andIdIn(templateIds); + List templates = mapFunctionTemplateDAO.selectByExampleWithBLOBs(example); + return MapFunctionTemplateVO.convertFrom(templates); + } + + @Override + public PageVO pagedQuery(MapFunctionTemplateQueryVO queryVO) { + Page page = PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); + List vos = listQuery(queryVO); + return PageVO.convert(page, vos); + } + + private MapFunctionTemplate get(long id) { + MapFunctionTemplate mapFunctionTemplate = mapFunctionTemplateDAO.selectByPrimaryKey(id); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(mapFunctionTemplate, + String.format("[id:%s]的模板不存在", id)); + return mapFunctionTemplate; + } +} diff --git a/src/main/java/club/joylink/rtss/services/permission/OldPermissionDataSyncService.java b/src/main/java/club/joylink/rtss/services/permission/OldPermissionDataSyncService.java index 4183469dc..a3ac5210b 100644 --- a/src/main/java/club/joylink/rtss/services/permission/OldPermissionDataSyncService.java +++ b/src/main/java/club/joylink/rtss/services/permission/OldPermissionDataSyncService.java @@ -7,7 +7,7 @@ import club.joylink.rtss.entity.permission.*; import club.joylink.rtss.services.IPermissionService; import club.joylink.rtss.services.mapFunction.RtsMapFunctionService; import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.vo.client.mapFunction.RtsMapFunctionGenerateParamVO; +import club.joylink.rtss.vo.client.mapFunction.MapFunctionGenerateParamVO; import club.joylink.rtss.vo.client.permission.PermissionQueryVO; import club.joylink.rtss.vo.client.permission.PermissionVO; import club.joylink.rtss.vo.permission.PermissionDistributeStatusEnum; @@ -30,10 +30,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; @@ -347,7 +343,7 @@ public class OldPermissionDataSyncService { } } private void generate(Simulation.Type type,MapInfo mi){ - RtsMapFunctionGenerateParamVO paramVO = new RtsMapFunctionGenerateParamVO(); + MapFunctionGenerateParamVO paramVO = new MapFunctionGenerateParamVO(); paramVO.setSimTypes(Arrays.asList(type)); try{ this.rtsMapFunctionService.generate(mi.getId(),paramVO,0L); diff --git a/src/main/java/club/joylink/rtss/services/permission/SystemAbilityService.java b/src/main/java/club/joylink/rtss/services/permission/SystemAbilityService.java index 231bac6a0..2ea3ef0b7 100644 --- a/src/main/java/club/joylink/rtss/services/permission/SystemAbilityService.java +++ b/src/main/java/club/joylink/rtss/services/permission/SystemAbilityService.java @@ -2,17 +2,17 @@ package club.joylink.rtss.services.permission; import club.joylink.rtss.dao.permission.PermissionSystemAbilityDAO; import club.joylink.rtss.dao.permission.SystemAbilityDAO; -import club.joylink.rtss.entity.permission.PermissionSystemAbility; import club.joylink.rtss.entity.permission.PermissionSystemAbilityExample; import club.joylink.rtss.entity.permission.SystemAbility; import club.joylink.rtss.entity.permission.SystemAbilityExample; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.mapFunction.RtsMapFunctionService; -import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.client.mapFunction.RtsMapFunctionQueryVO; -import club.joylink.rtss.vo.client.mapFunction.RtsMapFunctionVO; -import club.joylink.rtss.vo.permission.*; +import club.joylink.rtss.vo.client.mapFunction.MapFunctionQueryVO; +import club.joylink.rtss.vo.client.mapFunction.MapFunctionVO; +import club.joylink.rtss.vo.permission.FindAbilityBasicByPageReqVo; +import club.joylink.rtss.vo.permission.PermissionSystemAbilityVO; +import club.joylink.rtss.vo.permission.SystemAbilityRspVo; import club.joylink.rtss.vo.permission.convertor.SystemAbilityConvertor; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; @@ -34,9 +34,6 @@ import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; -import static club.joylink.rtss.vo.permission.SystemAbilityStatus.Editing; -import static club.joylink.rtss.vo.permission.SystemAbilityStatus.Enable; - @Slf4j @Service public class SystemAbilityService { @@ -112,10 +109,10 @@ public class SystemAbilityService { @Transactional(rollbackFor = Exception.class) public void autoSynchMapSystemData(Long userId){ - List voList = this.rtsMapFunctionService.listQuery(new RtsMapFunctionQueryVO()); + List voList = this.rtsMapFunctionService.listQuery(new MapFunctionQueryVO()); List abilities = this.systemAbilityDAO.selectByExample(new SystemAbilityExample()); List deleteList = Lists.newArrayList(); - List saveList = Lists.newArrayList(); + List saveList = Lists.newArrayList(); List updateList = Lists.newArrayList(); if(CollectionUtils.isEmpty(abilities)){ this.batchInsert(voList,userId); @@ -125,7 +122,7 @@ public class SystemAbilityService { Map abilityMap = abilities.stream().filter(d->Objects.nonNull(d.getType()) && Objects.nonNull(d.getAbilityId()) || Objects.nonNull(d.getMapId())) .collect(Collectors.toMap(k->k.getType() + k.getAbilityId() + k.getMapId(), Function.identity())); - Map mapSystemMap = voList.stream().collect(Collectors.toMap(k->k.getSimType().name() + k.getId() + k.getMapId(), Function.identity())); + Map mapSystemMap = voList.stream().collect(Collectors.toMap(k->k.getSimType().name() + k.getId() + k.getMapId(), Function.identity())); abilityMap.forEach((k,v)->{ if(!mapSystemMap.containsKey(k)){ deleteList.add(v); @@ -145,7 +142,7 @@ public class SystemAbilityService { } } - private void batchInsert(List list, Long userId){ + private void batchInsert(List list, Long userId){ List lists = SystemAbilityConvertor.converMapSystemVOToAbility(list); for (SystemAbility sa : lists) { sa.setCreateTime(LocalDateTime.now()); @@ -183,7 +180,7 @@ public class SystemAbilityService { @Data @AllArgsConstructor public static class SynUpdateVO{ - private RtsMapFunctionVO vo; + private MapFunctionVO vo; private Long abilityId; } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationServiceImpl.java index 43aaf190a..cca5200b9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationServiceImpl.java @@ -18,7 +18,7 @@ import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.client.SocketMessageVO; import club.joylink.rtss.vo.client.factory.SocketMessageFactory; -import club.joylink.rtss.vo.client.mapFunction.RtsMapFunctionVO; +import club.joylink.rtss.vo.client.mapFunction.MapFunctionVO; import club.joylink.rtss.vo.client.runplan.RunPlanVO; import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam; import club.joylink.rtss.vo.permission.PermissionSubjectTypeEnum; @@ -72,7 +72,7 @@ public class SimulationServiceImpl implements SimulationService { } //只获取所有与该功能相关的权限信息 - private List filterUserPermission(List subjectVOList,RtsMapFunctionVO functionVO,LoginUserInfoVO loginUserInfoVO){ + private List filterUserPermission(List subjectVOList, MapFunctionVO functionVO, LoginUserInfoVO loginUserInfoVO){ List newVoList = Lists.newArrayList(); for (PermissionSubjectVO subjectVO : subjectVOList) { if(subjectVO.getStartTime().isAfter(LocalDateTime.now())){ @@ -110,7 +110,7 @@ public class SimulationServiceImpl implements SimulationService { * @param loginInfo */ - private Map checkUserPermission(RtsMapFunctionVO functionVO,LoginUserInfoVO loginInfo){ + private Map checkUserPermission(MapFunctionVO functionVO, LoginUserInfoVO loginInfo){ if(loginInfo.getAccountVO().isAdmin()){ return Collections.emptyMap(); } @@ -157,7 +157,7 @@ public class SimulationServiceImpl implements SimulationService { return resultMap2; } - private List findCanUsedPermission(List newVOLIst, RtsMapFunctionVO functionVO, LoginUserInfoVO loginInfo){ + private List findCanUsedPermission(List newVOLIst, MapFunctionVO functionVO, LoginUserInfoVO loginInfo){ List canUseSubjectList = newVOLIst.stream().filter(d->Objects.equals(true,d.getForever())).collect(Collectors.toList()); if(CollectionUtils.isEmpty(canUseSubjectList)){ List timeOverIdList = newVOLIst.stream().filter(d->Objects.nonNull(d.getEndTime()) && d.getEndTime().isAfter(LocalDateTime.now())) @@ -171,7 +171,7 @@ public class SimulationServiceImpl implements SimulationService { } return canUseSubjectList; } - private boolean checkUserPermissionDetail(List newVOLIst,RtsMapFunctionVO functionVO,LoginUserInfoVO loginInfo){ + private boolean checkUserPermissionDetail(List newVOLIst, MapFunctionVO functionVO, LoginUserInfoVO loginInfo){ boolean isForever = newVOLIst.stream().anyMatch(d->Objects.equals(true,d.getForever())); if(Objects.equals(false,isForever)){ boolean timeOver = newVOLIst.stream().allMatch(d->Objects.nonNull(d.getEndTime()) && d.getEndTime().isBefore(LocalDateTime.now())); @@ -187,11 +187,11 @@ public class SimulationServiceImpl implements SimulationService { @Override public String createSimulation(Long mapFunctionId, LoginUserInfoVO loginInfo) { - RtsMapFunctionVO rtsMapFunctionVO = rtsMapFunctionService.get(mapFunctionId); - Long mapId = rtsMapFunctionVO.getMapId(); + MapFunctionVO mapFunctionVO = rtsMapFunctionService.get(mapFunctionId); + Long mapId = mapFunctionVO.getMapId(); - Map createUserType = this.checkUserPermission(rtsMapFunctionVO,loginInfo); - SimulationWorkParamVO workParamVO = rtsMapFunctionVO.getParamVO(); + Map createUserType = this.checkUserPermission(mapFunctionVO,loginInfo); + SimulationWorkParamVO workParamVO = mapFunctionVO.getParamVO(); if (workParamVO.containsRealDeviceItem()) { //有实体设备加载项的地图功能(实训室)同时只能存在一个 @@ -320,13 +320,13 @@ public class SimulationServiceImpl implements SimulationService { @Override public Simulation createSimulationPojo(Long mapFunctionId, LoginUserInfoVO loginInfo, boolean checkAuth) { - RtsMapFunctionVO rtsMapFunctionVO = rtsMapFunctionService.get(mapFunctionId); - Long mapId = rtsMapFunctionVO.getMapId(); + MapFunctionVO mapFunctionVO = rtsMapFunctionService.get(mapFunctionId); + Long mapId = mapFunctionVO.getMapId(); Map createUserType = Maps.newHashMap(); if (checkAuth) { - createUserType = this.checkUserPermission(rtsMapFunctionVO,loginInfo); + createUserType = this.checkUserPermission(mapFunctionVO,loginInfo); } - SimulationWorkParamVO workParamVO = rtsMapFunctionVO.getParamVO(); + SimulationWorkParamVO workParamVO = mapFunctionVO.getParamVO(); if (workParamVO.containsRealDeviceItem()) { //有实体设备加载项的地图功能(实训室)同时只能存在一个 diff --git a/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionBatchModifyVO.java b/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionBatchModifyVO.java new file mode 100644 index 000000000..62ac58dfd --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionBatchModifyVO.java @@ -0,0 +1,62 @@ +package club.joylink.rtss.vo.client.mapFunction; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + * 地图功能描述修改参数 + */ +@Getter +@Setter +@NoArgsConstructor +public class MapFunctionBatchModifyVO { + /** + * 线路功能描述修改参数 + */ + private DescModifyParamVO descModifyParamVO; + /** + * 线路功能bgUrl修改参数 + */ + private BgUrlModifyParamVO bgUrlModifyParamVO; + + @Getter + @Setter + @NoArgsConstructor + public class DescModifyParamVO { + /** + * 线路功能名称。作为where条件 + */ + private String functionName; + + /** + * 原来的描述。作为where条件 + */ + private String originDesc; + + /** + * 新的描述 + */ + private String newDesc; + } + + @Getter + @Setter + @NoArgsConstructor + public class BgUrlModifyParamVO { + /** + * 线路功能名称。作为where条件 + */ + private String functionName; + + /** + * 原来的bgUrl。作为where条件 + */ + private String originBgUrl; + + /** + * 新的bgUrl + */ + private String newBgUrl; + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionCreateVO.java b/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionCreateVO.java similarity index 96% rename from src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionCreateVO.java rename to src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionCreateVO.java index ea09c8143..f67f3700a 100644 --- a/src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionCreateVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionCreateVO.java @@ -13,7 +13,7 @@ import javax.validation.constraints.NotNull; @Getter @Setter @NoArgsConstructor -public class RtsMapFunctionCreateVO { +public class MapFunctionCreateVO { @NotNull(message = "地图id不能为空") private Long mapId; diff --git a/src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionGenerateParamVO.java b/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionGenerateParamVO.java similarity index 91% rename from src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionGenerateParamVO.java rename to src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionGenerateParamVO.java index f3cda25f9..1e7afc977 100644 --- a/src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionGenerateParamVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionGenerateParamVO.java @@ -14,7 +14,7 @@ import java.util.List; @Getter @Setter @NoArgsConstructor -public class RtsMapFunctionGenerateParamVO { +public class MapFunctionGenerateParamVO { /** 要生成子系统的仿真系统类型 */ @NotEmpty(message = "要生成子系统的仿真系统类型不能为空") private List simTypes; diff --git a/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionGenerateVO.java b/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionGenerateVO.java new file mode 100644 index 000000000..d99ee85c5 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionGenerateVO.java @@ -0,0 +1,24 @@ +package club.joylink.rtss.vo.client.mapFunction; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.List; + +/** + * 地图功能生成参数 + */ +@Getter +@Setter +@NoArgsConstructor +public class MapFunctionGenerateVO { + private List templateIds; + + private List mapIds; + + /** + * 覆盖同名地图功能? + */ + private boolean overwrite; +} diff --git a/src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionQueryVO.java b/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionQueryVO.java similarity index 70% rename from src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionQueryVO.java rename to src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionQueryVO.java index 04a651a55..d3ba292fa 100644 --- a/src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionQueryVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionQueryVO.java @@ -9,10 +9,16 @@ import lombok.Setter; @Getter @Setter @NoArgsConstructor -public class RtsMapFunctionQueryVO extends PageQueryVO { +public class MapFunctionQueryVO extends PageQueryVO { private Long mapId; private String name; private Simulation.Type simType; + + /** + * 是否需要详细信息 + * todo + */ + private boolean detail = true; } diff --git a/src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionUpdateVO.java b/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionUpdateVO.java similarity index 71% rename from src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionUpdateVO.java rename to src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionUpdateVO.java index 7549c9c74..94a374342 100644 --- a/src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionUpdateVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionUpdateVO.java @@ -13,7 +13,7 @@ import javax.validation.constraints.NotNull; @Getter @Setter @NoArgsConstructor -public class RtsMapFunctionUpdateVO { +public class MapFunctionUpdateVO { @NotBlank(message = "名称不能为空") private String name; @@ -21,14 +21,27 @@ public class RtsMapFunctionUpdateVO { private String bgUrl; + private String subset; + @NotNull(message = "参数不能为空") private SimulationWorkParamVO paramVO; + public MapFunctionUpdateVO(MapFunctionCreateVO createVO) { + name = createVO.getName(); + desc = createVO.getDesc(); + bgUrl = createVO.getBgUrl(); + subset = createVO.getSubset(); + paramVO = createVO.getParamVO(); + } + public void override(RtsMapFunction entity) { entity.setName(name); entity.setDesc(desc); entity.setBgUrl(bgUrl); + entity.setGroup(subset); entity.setType(paramVO.getType().name()); entity.setParam(JsonUtils.writeValueAsString(paramVO)); } + + } diff --git a/src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionVO.java b/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionVO.java similarity index 81% rename from src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionVO.java rename to src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionVO.java index 029efd0d5..c0f37f9ae 100644 --- a/src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/mapFunction/MapFunctionVO.java @@ -7,13 +7,14 @@ import club.joylink.rtss.util.JsonUtils; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import org.springframework.util.StringUtils; import java.time.LocalDateTime; @Getter @Setter @NoArgsConstructor -public class RtsMapFunctionVO { +public class MapFunctionVO { private Long id; private Long mapId; @@ -38,8 +39,7 @@ public class RtsMapFunctionVO { private LocalDateTime updateTime; - - public RtsMapFunctionVO(RtsMapFunction entity) { + public MapFunctionVO(RtsMapFunction entity) { id = entity.getId(); mapId = entity.getMapId(); name = entity.getName(); @@ -47,7 +47,9 @@ public class RtsMapFunctionVO { bgUrl = entity.getBgUrl(); simType = Simulation.Type.valueOf(entity.getType()); subset = entity.getGroup(); - paramVO = JsonUtils.read(entity.getParam(), SimulationWorkParamVO.class); + if (StringUtils.hasText(entity.getParam())) { + paramVO = JsonUtils.read(entity.getParam(), SimulationWorkParamVO.class); + } creatorId = entity.getCreatorId(); createTime = entity.getCreateTime(); updaterId = entity.getUpdaterId(); diff --git a/src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionDescModifyVO.java b/src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionDescModifyVO.java deleted file mode 100644 index 61144c98c..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/mapFunction/RtsMapFunctionDescModifyVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package club.joylink.rtss.vo.client.mapFunction; - -import club.joylink.rtss.entity.RtsMapFunction; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -/** - * 地图功能描述修改参数 - */ -@Getter -@Setter -@NoArgsConstructor -public class RtsMapFunctionDescModifyVO { - /** - * 功能名称。与下面的原描述以或的关系作为更新条件 - */ - private String functionName; - - /** - * 原描述 - */ - private String originalDesc; - - /** - * 新描述 - */ - private String newDesc; - - public RtsMapFunction convert2DB() { - RtsMapFunction entity = new RtsMapFunction(); - entity.setDesc(newDesc); - return entity; - } -} diff --git a/src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/AssistantParamVO.java b/src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/AssistantParamVO.java new file mode 100644 index 000000000..538bf0b11 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/AssistantParamVO.java @@ -0,0 +1,18 @@ +package club.joylink.rtss.vo.client.mapFunctionTemplate; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + * 地图功能模板辅助参数 + */ +@Getter +@Setter +@NoArgsConstructor +public class AssistantParamVO { + /** + * 默认成员类型 + */ + private String defaultMemberType; +} diff --git a/src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/MapFunctionTemplateCreateVO.java b/src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/MapFunctionTemplateCreateVO.java new file mode 100644 index 000000000..7204ff0cc --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/MapFunctionTemplateCreateVO.java @@ -0,0 +1,31 @@ +package club.joylink.rtss.vo.client.mapFunctionTemplate; + +import club.joylink.rtss.entity.MapFunctionTemplate; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.mapFunction.MapFunctionCreateVO; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +public class MapFunctionTemplateCreateVO { + private String name; + + private MapFunctionCreateVO mapFunctionParam; + + private AssistantParamVO assistantParam; + + public MapFunctionTemplate convert2DB() { + MapFunctionTemplate entity = new MapFunctionTemplate(); + entity.setName(name); + if (assistantParam != null) { + entity.setAssistantParam(JsonUtils.writeValueAsString(assistantParam)); + } + if (mapFunctionParam != null) { + entity.setMapFunctionParam(JsonUtils.writeValueAsString(mapFunctionParam)); + } + return entity; + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/MapFunctionTemplateQueryVO.java b/src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/MapFunctionTemplateQueryVO.java new file mode 100644 index 000000000..481a7e4c1 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/MapFunctionTemplateQueryVO.java @@ -0,0 +1,10 @@ +package club.joylink.rtss.vo.client.mapFunctionTemplate; + +import club.joylink.rtss.vo.client.PageQueryVO; + +public class MapFunctionTemplateQueryVO extends PageQueryVO { + /** + * 需要详细信息? + */ + private boolean detail; +} diff --git a/src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/MapFunctionTemplateVO.java b/src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/MapFunctionTemplateVO.java new file mode 100644 index 000000000..2bc18dc60 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/mapFunctionTemplate/MapFunctionTemplateVO.java @@ -0,0 +1,54 @@ +package club.joylink.rtss.vo.client.mapFunctionTemplate; + +import club.joylink.rtss.entity.MapFunctionTemplate; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.mapFunction.MapFunctionCreateVO; +import lombok.Getter; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +@Getter +public class MapFunctionTemplateVO { + private Long id; + + private String name; + + private MapFunctionCreateVO mapFunctionParam; + + private AssistantParamVO assistantParam; + + private LocalDateTime createTime; + + private Long creatorId; + + private LocalDateTime updateTime; + + private Long updaterId; + + public MapFunctionTemplateVO(MapFunctionTemplate entity) { + id = entity.getId(); + name = entity.getName(); + mapFunctionParam = StringUtils.hasText(entity.getMapFunctionParam()) ? + JsonUtils.read(entity.getMapFunctionParam(), MapFunctionCreateVO.class) : null; + assistantParam = StringUtils.hasText(entity.getAssistantParam()) ? + JsonUtils.read(entity.getAssistantParam(), AssistantParamVO.class) : null; + createTime = entity.getCreateTime(); + creatorId = entity.getCreatorId(); + updateTime = entity.getUpdateTime(); + updaterId = entity.getUpdaterId(); + } + + public static List convertFrom(Collection entities) { + if (!CollectionUtils.isEmpty(entities)) { + return entities.stream().map(MapFunctionTemplateVO::new).collect(Collectors.toList()); + } else { + return new ArrayList<>(); + } + } +} diff --git a/src/main/java/club/joylink/rtss/vo/permission/convertor/SystemAbilityConvertor.java b/src/main/java/club/joylink/rtss/vo/permission/convertor/SystemAbilityConvertor.java index 21693cd2b..43788ca23 100644 --- a/src/main/java/club/joylink/rtss/vo/permission/convertor/SystemAbilityConvertor.java +++ b/src/main/java/club/joylink/rtss/vo/permission/convertor/SystemAbilityConvertor.java @@ -2,10 +2,9 @@ package club.joylink.rtss.vo.permission.convertor; import club.joylink.rtss.entity.permission.SystemAbility; import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.vo.client.mapFunction.RtsMapFunctionVO; +import club.joylink.rtss.vo.client.mapFunction.MapFunctionVO; import club.joylink.rtss.vo.permission.PermissionAbilityRspVo; import club.joylink.rtss.vo.permission.PermissionSystemAbilityVO; -import club.joylink.rtss.vo.permission.SystemAbilityType; import com.google.common.collect.Lists; import java.util.List; @@ -24,7 +23,7 @@ public class SystemAbilityConvertor { return rt; } - public static SystemAbility converMapSystemVOToAbility(RtsMapFunctionVO vo){ + public static SystemAbility converMapSystemVOToAbility(MapFunctionVO vo){ SystemAbility sa = new SystemAbility(); sa.setName(vo.getName()); sa.setAbilityId(vo.getId()); @@ -33,9 +32,9 @@ public class SystemAbilityConvertor { return sa; } - public static List converMapSystemVOToAbility(List vo){ + public static List converMapSystemVOToAbility(List vo){ List list = Lists.newArrayList(); - for (RtsMapFunctionVO mapSystemVO : vo) { + for (MapFunctionVO mapSystemVO : vo) { list.add(converMapSystemVOToAbility(mapSystemVO)); } return list; diff --git a/src/main/resources/mybatis/mapper/MapFunctionTemplateDAO.xml b/src/main/resources/mybatis/mapper/MapFunctionTemplateDAO.xml new file mode 100644 index 000000000..8c4baf218 --- /dev/null +++ b/src/main/resources/mybatis/mapper/MapFunctionTemplateDAO.xml @@ -0,0 +1,314 @@ + + + + + + + + + + + + + + + + + + + + + + + + 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, `name`, assistant_param, create_time, creator_id, update_time, updater_id + + + map_function_param + + + + + + delete from rts_map_function_template + where id = #{id,jdbcType=BIGINT} + + + delete from rts_map_function_template + + + + + + insert into rts_map_function_template (`name`, assistant_param, create_time, + creator_id, update_time, updater_id, + map_function_param) + values (#{name,jdbcType=VARCHAR}, #{assistantParam,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, + #{creatorId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, #{updaterId,jdbcType=BIGINT}, + #{mapFunctionParam,jdbcType=LONGVARCHAR}) + + + insert into rts_map_function_template + + + `name`, + + + assistant_param, + + + create_time, + + + creator_id, + + + update_time, + + + updater_id, + + + map_function_param, + + + + + #{name,jdbcType=VARCHAR}, + + + #{assistantParam,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{creatorId,jdbcType=BIGINT}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{updaterId,jdbcType=BIGINT}, + + + #{mapFunctionParam,jdbcType=LONGVARCHAR}, + + + + + + update rts_map_function_template + + + id = #{record.id,jdbcType=BIGINT}, + + + `name` = #{record.name,jdbcType=VARCHAR}, + + + assistant_param = #{record.assistantParam,jdbcType=VARCHAR}, + + + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + + + creator_id = #{record.creatorId,jdbcType=BIGINT}, + + + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + + + updater_id = #{record.updaterId,jdbcType=BIGINT}, + + + map_function_param = #{record.mapFunctionParam,jdbcType=LONGVARCHAR}, + + + + + + + + update rts_map_function_template + set id = #{record.id,jdbcType=BIGINT}, + `name` = #{record.name,jdbcType=VARCHAR}, + assistant_param = #{record.assistantParam,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + creator_id = #{record.creatorId,jdbcType=BIGINT}, + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + updater_id = #{record.updaterId,jdbcType=BIGINT}, + map_function_param = #{record.mapFunctionParam,jdbcType=LONGVARCHAR} + + + + + + update rts_map_function_template + set id = #{record.id,jdbcType=BIGINT}, + `name` = #{record.name,jdbcType=VARCHAR}, + assistant_param = #{record.assistantParam,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + creator_id = #{record.creatorId,jdbcType=BIGINT}, + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + updater_id = #{record.updaterId,jdbcType=BIGINT} + + + + + + update rts_map_function_template + + + `name` = #{name,jdbcType=VARCHAR}, + + + assistant_param = #{assistantParam,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + creator_id = #{creatorId,jdbcType=BIGINT}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + updater_id = #{updaterId,jdbcType=BIGINT}, + + + map_function_param = #{mapFunctionParam,jdbcType=LONGVARCHAR}, + + + where id = #{id,jdbcType=BIGINT} + + + update rts_map_function_template + set `name` = #{name,jdbcType=VARCHAR}, + assistant_param = #{assistantParam,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + creator_id = #{creatorId,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=TIMESTAMP}, + updater_id = #{updaterId,jdbcType=BIGINT}, + map_function_param = #{mapFunctionParam,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=BIGINT} + + + update rts_map_function_template + set `name` = #{name,jdbcType=VARCHAR}, + assistant_param = #{assistantParam,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + creator_id = #{creatorId,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=TIMESTAMP}, + updater_id = #{updaterId,jdbcType=BIGINT} + where id = #{id,jdbcType=BIGINT} + + diff --git a/src/test/java/club/joylink/rtss/services/mapSystem/RtsMapFunctionServiceImplTest.java b/src/test/java/club/joylink/rtss/services/mapSystem/RtsMapFunctionServiceImplTest.java index 38954e40a..a96879a1b 100644 --- a/src/test/java/club/joylink/rtss/services/mapSystem/RtsMapFunctionServiceImplTest.java +++ b/src/test/java/club/joylink/rtss/services/mapSystem/RtsMapFunctionServiceImplTest.java @@ -5,9 +5,9 @@ import club.joylink.rtss.services.mapFunction.RtsMapFunctionServiceImpl; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO; -import club.joylink.rtss.vo.client.mapFunction.RtsMapFunctionCreateVO; -import club.joylink.rtss.vo.client.mapFunction.RtsMapFunctionQueryVO; -import club.joylink.rtss.vo.client.mapFunction.RtsMapFunctionVO; +import club.joylink.rtss.vo.client.mapFunction.MapFunctionCreateVO; +import club.joylink.rtss.vo.client.mapFunction.MapFunctionQueryVO; +import club.joylink.rtss.vo.client.mapFunction.MapFunctionVO; import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.map.graph.MapMemberVO; import org.junit.jupiter.api.Test; @@ -54,7 +54,7 @@ class RtsMapFunctionServiceImplTest { .filter(mVO -> Objects.equals(mVO.getType(), SimulationMember.Type.DISPATCHER)) .findFirst().get(); - RtsMapFunctionCreateVO createVO = new RtsMapFunctionCreateVO(); + MapFunctionCreateVO createVO = new MapFunctionCreateVO(); createVO.setMapId(mapId); createVO.setName(systemName); SimulationWorkParamVO paramVO = new SimulationWorkParamVO(); @@ -63,10 +63,10 @@ class RtsMapFunctionServiceImplTest { paramVO.setDomConfig(SimulationWorkParamVO.DomConfigVO.builder().singleMember(true).build()); rtsMapFunctionService.create(createVO, creatorId); - RtsMapFunctionQueryVO queryVO = new RtsMapFunctionQueryVO(); + MapFunctionQueryVO queryVO = new MapFunctionQueryVO(); queryVO.setMapId(mapId); - List list = rtsMapFunctionService.listQuery(queryVO); - Set collect = list.stream().map(RtsMapFunctionVO::getName).collect(Collectors.toSet()); + List list = rtsMapFunctionService.listQuery(queryVO); + Set collect = list.stream().map(MapFunctionVO::getName).collect(Collectors.toSet()); assertTrue(collect.contains(systemName), "地图子系统创建后查询不到记录"); //error }