From 2c360a2c00d1fa6ae2955e42cdedabbcf962c5af Mon Sep 17 00:00:00 2001 From: weizhihong Date: Thu, 24 Nov 2022 17:23:53 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E9=A1=B9=E7=9B=AE=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9C=B0=E5=9B=BEID=E3=80=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BDID=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/20221124-wei-rts-project.sql | 3 ++ .../joylink/rtss/entity/project/Project.java | 10 ++++ .../services/project/ProjectServiceImpl.java | 44 +++++++++++++++--- .../rtss/vo/project/ProjectInfoVO.java | 22 +++++++++ .../joylink/rtss/vo/project/ProjectVO.java | 8 ++++ .../mybatis/mapper/ProjectDaoMapper.xml | 46 ++++++++++++++++--- 6 files changed, 120 insertions(+), 13 deletions(-) create mode 100644 sql/20221124-wei-rts-project.sql diff --git a/sql/20221124-wei-rts-project.sql b/sql/20221124-wei-rts-project.sql new file mode 100644 index 000000000..bf5bc0afe --- /dev/null +++ b/sql/20221124-wei-rts-project.sql @@ -0,0 +1,3 @@ +ALTER TABLE `joylink`.`rts_project` +ADD COLUMN `map_id` int NULL COMMENT '地图ID' AFTER `default_org`, +ADD COLUMN `function_id` int NULL COMMENT '功能ID' AFTER `map_id`; \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/project/Project.java b/src/main/java/club/joylink/rtss/entity/project/Project.java index ab6890c99..9d0a165d0 100644 --- a/src/main/java/club/joylink/rtss/entity/project/Project.java +++ b/src/main/java/club/joylink/rtss/entity/project/Project.java @@ -70,6 +70,16 @@ public class Project { */ private Long defaultOrg; + /** + * 设置地图ID + */ + private Long mapId; + + /** + * 功能ID + */ + private Long functionId; + @JsonIgnore public static boolean isDefault(String code) { return StringUtils.isEmpty(code) || DEFAULT_PROJECT_LABEL.contains(code); diff --git a/src/main/java/club/joylink/rtss/services/project/ProjectServiceImpl.java b/src/main/java/club/joylink/rtss/services/project/ProjectServiceImpl.java index b60d36616..9a9b28a07 100644 --- a/src/main/java/club/joylink/rtss/services/project/ProjectServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/project/ProjectServiceImpl.java @@ -1,11 +1,12 @@ package club.joylink.rtss.services.project; +import club.joylink.rtss.dao.MapInfoDAO; import club.joylink.rtss.dao.OrgDAO; +import club.joylink.rtss.dao.RtsMapFunctionDAO; import club.joylink.rtss.dao.org.OrgProjectDao; import club.joylink.rtss.dao.project.ProjectDAO; import club.joylink.rtss.dao.project.ProjectViewDAO; -import club.joylink.rtss.entity.Org; -import club.joylink.rtss.entity.OrgExample; +import club.joylink.rtss.entity.*; import club.joylink.rtss.entity.org.OrgProject; import club.joylink.rtss.entity.org.OrgProjectExample; import club.joylink.rtss.entity.project.Project; @@ -30,9 +31,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; @Service @@ -55,7 +54,10 @@ public class ProjectServiceImpl implements ProjectService { private OrgDAO orgDAO; @Autowired - private OrgService orgService; + private MapInfoDAO mapInfoDAO; + + @Autowired + private RtsMapFunctionDAO rtsMapFunctionDAO; @Override public PageVO pagingQuery(ProjectQueryVO queryVO) { @@ -338,7 +340,31 @@ public class ProjectServiceImpl implements ProjectService { orgMap.putAll(orgList.stream().collect(Collectors.toMap(Org::getId, o -> o))); orgProjectMap.putAll(orgProjectList.stream().collect(Collectors.groupingBy(OrgProject::getProjectCode, Collectors.mapping(OrgProject::getOrgId, Collectors.toList())))); } + // 地图信息列表 + Set mapIdSet = new HashSet<>(); + Set functionIdSet = new HashSet<>(); + projectList.stream().filter(p -> p.getMapId() != null).forEach(p -> { + mapIdSet.add(p.getMapId()); + functionIdSet.add(p.getFunctionId()); + }); + // 地图信息 + Map mapNameMap = new HashMap<>(mapIdSet.size()); + if (!CollectionUtils.isEmpty(mapIdSet)) { + MapInfoExample mapInfoExample = new MapInfoExample(); + mapInfoExample.createCriteria().andIdIn(new ArrayList<>(mapIdSet)); + List mapInfoList = mapInfoDAO.selectByExample(mapInfoExample); + mapNameMap = mapInfoList.stream().collect(Collectors.toMap(MapInfo::getId, MapInfo::getName)); + } + Map functionNameMap = new HashMap<>(functionIdSet.size()); + if (!CollectionUtils.isEmpty(functionIdSet)) { + RtsMapFunctionExample rtsMapFunctionExample = new RtsMapFunctionExample(); + rtsMapFunctionExample.createCriteria().andIdIn(new ArrayList<>(functionIdSet)); + List functionList = rtsMapFunctionDAO.selectByExample(rtsMapFunctionExample); + functionNameMap = functionList.stream().collect(Collectors.toMap(RtsMapFunction::getId, RtsMapFunction::getName)); + } // 包装projectVO + Map finalMapNameMap = mapNameMap; + Map finalFunctionNameMap = functionNameMap; List projectVOList = projectList.stream().map(p -> { ProjectInfoVO projectVO = new ProjectInfoVO(p); if (orgProjectMap.containsKey(p.getCode())) { @@ -351,6 +377,12 @@ public class ProjectServiceImpl implements ProjectService { if (p.getDefaultOrg() != null && orgMap.containsKey(p.getDefaultOrg())) { projectVO.setDefaultOrgName(orgMap.get(p.getDefaultOrg()).getName()); } + if (p.getMapId() != null && finalMapNameMap.containsKey(p.getMapId())) { + projectVO.setMapName(finalMapNameMap.get(p.getMapId())); + } + if (p.getFunctionId() != null && finalFunctionNameMap.containsKey(p.getFunctionId())) { + projectVO.setFunctionName(finalFunctionNameMap.get(p.getFunctionId())); + } return projectVO; }).collect(Collectors.toList()); return projectVOList; diff --git a/src/main/java/club/joylink/rtss/vo/project/ProjectInfoVO.java b/src/main/java/club/joylink/rtss/vo/project/ProjectInfoVO.java index d36262204..39402f865 100644 --- a/src/main/java/club/joylink/rtss/vo/project/ProjectInfoVO.java +++ b/src/main/java/club/joylink/rtss/vo/project/ProjectInfoVO.java @@ -58,6 +58,26 @@ public class ProjectInfoVO { */ private boolean createDefaultOrg; + /** + * 地图 + */ + private Long mapId; + + /** + * 地图名称 + */ + private String mapName; + + /** + * 功能ID + */ + private Long functionId; + + /** + * 功能名称 + */ + private String functionName; + public ProjectInfoVO(Project project) { this.id = project.getId(); this.code = project.getCode(); @@ -65,6 +85,8 @@ public class ProjectInfoVO { this.description = project.getDescription(); this.serverSetting = project.getServerSetting(); this.defaultOrg = project.getDefaultOrg(); + this.mapId = project.getMapId(); + this.functionId = project.getFunctionId(); } public void setOrgList(List orgList) { diff --git a/src/main/java/club/joylink/rtss/vo/project/ProjectVO.java b/src/main/java/club/joylink/rtss/vo/project/ProjectVO.java index 77ecf0437..fb804d029 100644 --- a/src/main/java/club/joylink/rtss/vo/project/ProjectVO.java +++ b/src/main/java/club/joylink/rtss/vo/project/ProjectVO.java @@ -27,9 +27,17 @@ public class ProjectVO { @JsonIgnore private Long defaultOrg; + @JsonIgnore + private Long mapId; + + @JsonIgnore + private Long functionId; + public ProjectVO(Project project) { this.label = project.getName(); this.value = project.getCode(); + this.mapId = project.getMapId(); + this.functionId = project.getFunctionId(); this.defaultOrg = project.getDefaultOrg(); if (StringUtils.isEmpty(project.getServerSetting())) { this.projectServerConfig = null; diff --git a/src/main/resources/mybatis/mapper/ProjectDaoMapper.xml b/src/main/resources/mybatis/mapper/ProjectDaoMapper.xml index fc1ec9394..eb9fa9be4 100644 --- a/src/main/resources/mybatis/mapper/ProjectDaoMapper.xml +++ b/src/main/resources/mybatis/mapper/ProjectDaoMapper.xml @@ -9,6 +9,8 @@ + + @@ -75,7 +77,7 @@ - id, code, name, create_time, update_time, status, default_org + id, code, name, create_time, update_time, status, default_org, map_id, function_id description,server_setting @@ -146,10 +148,16 @@ - insert into rts_project ( code, name, description, create_time, update_time, status, server_setting,default_org) - values (#{code,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR}, - #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, - #{serverSetting,jdbcType=LONGVARCHAR}, #{defaultOrg, jdbcType=BIGINT}) + insert into rts_project ( + code, name, description, create_time, update_time, status, + server_setting,default_org , map_id, function_id + ) + values ( + #{code,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR}, + #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, + #{serverSetting,jdbcType=LONGVARCHAR}, #{defaultOrg, jdbcType=BIGINT}, + #{mapId, jdbcType=BIGINT}, #{functionId, jdbcType=BIGINT} + ) @@ -182,6 +190,13 @@ default_org, + + + map_id, + + + function_id, + @@ -211,6 +226,13 @@ #{defaultOrg, jdbcType=BIGINT}, + + + #{mapId, jdbcType=BIGINT}, + + + #{functionId, jdbcType=BIGINT}, + @@ -241,6 +263,12 @@ default_org = #{defaultOrg, jdbcType=BIGINT}, + + map_id = #{mapId, jdbcType=BIGINT}, + + + function_id = #{functionId, jdbcType=BIGINT}, + where id = #{id,jdbcType=BIGINT} @@ -254,7 +282,9 @@ update_time = #{updateTime,jdbcType=TIMESTAMP}, status = #{status,jdbcType=INTEGER}, server_setting = #{serverSetting,jdbcType=LONGVARCHAR}, - default_org = #{defaultOrg, jdbcType=BIGINT} + default_org = #{defaultOrg, jdbcType=BIGINT}, + map_id = #{mapId, jdbcType=BIGINT}, + function_id = #{functionId, jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT} @@ -266,7 +296,9 @@ create_time = #{createTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP}, status = #{status,jdbcType=INTEGER}, - default_org = #{defaultOrg, jdbcType=BIGINT} + default_org = #{defaultOrg, jdbcType=BIGINT}, + map_id = #{mapId, jdbcType=BIGINT}, + function_id = #{functionId, jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}