【项目设置增加地图ID、功能ID】

This commit is contained in:
weizhihong 2022-11-24 17:23:53 +08:00
parent 8c86917bf2
commit 2c360a2c00
6 changed files with 120 additions and 13 deletions

View File

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

View File

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

View File

@ -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<ProjectInfoVO> 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<Long> mapIdSet = new HashSet<>();
Set<Long> functionIdSet = new HashSet<>();
projectList.stream().filter(p -> p.getMapId() != null).forEach(p -> {
mapIdSet.add(p.getMapId());
functionIdSet.add(p.getFunctionId());
});
// 地图信息
Map<Long,String> mapNameMap = new HashMap<>(mapIdSet.size());
if (!CollectionUtils.isEmpty(mapIdSet)) {
MapInfoExample mapInfoExample = new MapInfoExample();
mapInfoExample.createCriteria().andIdIn(new ArrayList<>(mapIdSet));
List<MapInfo> mapInfoList = mapInfoDAO.selectByExample(mapInfoExample);
mapNameMap = mapInfoList.stream().collect(Collectors.toMap(MapInfo::getId, MapInfo::getName));
}
Map<Long,String> functionNameMap = new HashMap<>(functionIdSet.size());
if (!CollectionUtils.isEmpty(functionIdSet)) {
RtsMapFunctionExample rtsMapFunctionExample = new RtsMapFunctionExample();
rtsMapFunctionExample.createCriteria().andIdIn(new ArrayList<>(functionIdSet));
List<RtsMapFunction> functionList = rtsMapFunctionDAO.selectByExample(rtsMapFunctionExample);
functionNameMap = functionList.stream().collect(Collectors.toMap(RtsMapFunction::getId, RtsMapFunction::getName));
}
// 包装projectVO
Map<Long, String> finalMapNameMap = mapNameMap;
Map<Long, String> finalFunctionNameMap = functionNameMap;
List<ProjectInfoVO> 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;

View File

@ -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<String> orgList) {

View File

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

View File

@ -9,6 +9,8 @@
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<result column="default_org" property="defaultOrg" jdbcType="BIGINT"/>
<result column="map_id" property="mapId" jdbcType="BIGINT"/>
<result column="function_id" property="functionId" jdbcType="BIGINT"/>
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="club.joylink.rtss.entity.project.Project" extends="BaseResultMap">
<result column="description" property="description" jdbcType="LONGVARCHAR"/>
@ -75,7 +77,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, code, name, create_time, update_time, status, default_org
id, code, name, create_time, update_time, status, default_org, map_id, function_id
</sql>
<sql id="Blob_Column_List">
description,server_setting
@ -146,10 +148,16 @@
</delete>
<insert id="insert" parameterType="club.joylink.rtss.entity.project.Project">
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}
)
</insert>
<insert id="insertSelective" parameterType="club.joylink.rtss.entity.project.Project">
@ -182,6 +190,13 @@
<if test="defaultOrg != null">
default_org,
</if>
<if test="mapId != null">
map_id,
</if>
<if test="functionId != null">
function_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -211,6 +226,13 @@
<if test="defaultOrg != null">
#{defaultOrg, jdbcType=BIGINT},
</if>
<if test="mapId != null">
#{mapId, jdbcType=BIGINT},
</if>
<if test="functionId != null">
#{functionId, jdbcType=BIGINT},
</if>
</trim>
</insert>
@ -241,6 +263,12 @@
<if test="defaultOrg != null">
default_org = #{defaultOrg, jdbcType=BIGINT},
</if>
<if test="mapId != null">
map_id = #{mapId, jdbcType=BIGINT},
</if>
<if test="functionId != null">
function_id = #{functionId, jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
@ -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}
</update>
@ -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}
</update>