Commit 562212f5 by henry

添加获取资产树接口

1 parent a42075ac
package org.arch.analysis.controller; package org.arch.analysis.controller;
import io.jsonwebtoken.lang.Collections;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.list.TreeList;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.arch.analysis.dto.ArchMapDto; import org.arch.analysis.dto.ArchMapDto;
import org.arch.analysis.vo.ArchMapVo; import org.arch.analysis.vo.ArchMapVo;
...@@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 架构地图控制器 * 架构地图控制器
...@@ -77,4 +80,22 @@ public class ArchMapController { ...@@ -77,4 +80,22 @@ public class ArchMapController {
public Result getOverTechAppAsset() { public Result getOverTechAppAsset() {
return null; return null;
} }
/**
* 获取资产树型
* @return
*/
@PostMapping("getAssetTree")
@OperLog(value = LogOperTypeEnum.QUERY, logTypeValue = LogTypeEnum.BUSI_LOG, operDes = "获取架构多维分析树形结构数据", moduleName = "架构地图")
public Result getAssetTree(@RequestBody ArchMapDto mapDto) {
String archiType = mapDto.getArchiType();
if(StringUtils.isEmpty(archiType)){
return Result.error("架构类型不能为空;");
}
List<ArchMapVo> allDatas = archMapService.getAssetTree(mapDto);
return Result.success(allDatas);
}
} }
...@@ -24,4 +24,16 @@ public class ArchMapDto { ...@@ -24,4 +24,16 @@ public class ArchMapDto {
* 父级资产编号 * 父级资产编号
*/ */
private String parentAssetId; private String parentAssetId;
/**
* 架构类别 1:总体架构;2:系统架构
*/
private String archiStage;
/**
* 资产编号
*/
private String assetCode;
/**
* 资产id
*/
private String assetId;
} }
...@@ -8,4 +8,5 @@ import java.util.List; ...@@ -8,4 +8,5 @@ import java.util.List;
public interface ArchMapMapper { public interface ArchMapMapper {
List<ArchMapVo> getOverAllBusAsset(ArchMapDto mapDto); List<ArchMapVo> getOverAllBusAsset(ArchMapDto mapDto);
} }
...@@ -8,4 +8,6 @@ import java.util.List; ...@@ -8,4 +8,6 @@ import java.util.List;
public interface IArchMapService { public interface IArchMapService {
List<ArchMapVo> getOverAllBusAsset(ArchMapDto mapDto); List<ArchMapVo> getOverAllBusAsset(ArchMapDto mapDto);
List<ArchMapVo> getAssetTree(ArchMapDto mapDto);
} }
package org.arch.analysis.service.impl; package org.arch.analysis.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.jsonwebtoken.lang.Collections;
import org.apache.commons.collections4.list.TreeList;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang.StringUtils;
import org.arch.analysis.dto.ArchMapDto; import org.arch.analysis.dto.ArchMapDto;
import org.arch.analysis.vo.ArchMapVo; import org.arch.analysis.vo.ArchMapVo;
import org.arch.analysis.mapper.ArchMapMapper; import org.arch.analysis.mapper.ArchMapMapper;
import org.arch.analysis.service.IArchMapService; import org.arch.analysis.service.IArchMapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@Service @Service
public class ArchMapServiceImpl implements IArchMapService { public class ArchMapServiceImpl implements IArchMapService {
@Resource @Resource
private ArchMapMapper archMapMapper; private ArchMapMapper archMapMapper;
...@@ -19,4 +32,29 @@ public class ArchMapServiceImpl implements IArchMapService { ...@@ -19,4 +32,29 @@ public class ArchMapServiceImpl implements IArchMapService {
public List<ArchMapVo> getOverAllBusAsset(ArchMapDto mapDto) { public List<ArchMapVo> getOverAllBusAsset(ArchMapDto mapDto) {
return archMapMapper.getOverAllBusAsset(mapDto); return archMapMapper.getOverAllBusAsset(mapDto);
} }
@Override
public List<ArchMapVo> getAssetTree(ArchMapDto mapDto) {
List<ArchMapVo> allDatas = archMapMapper.getOverAllBusAsset(mapDto);
List<ArchMapVo> treeList = new ArrayList<>();
mapDto.setParentAssetId("0");
List<ArchMapVo> rootDatas = archMapMapper.getOverAllBusAsset(mapDto);
if (!Collections.isEmpty(rootDatas)) {
treeList = rootDatas.stream()
.filter(item -> !StringUtils.isEmpty(item.getParentAssetId()))
.filter(item -> item.getParentAssetId().equals("0"))
.peek(item -> item.setChildren(getChildrens(item, allDatas))).collect(Collectors.toList());
}
return treeList;
}
private List<ArchMapVo> getChildrens(ArchMapVo root, List<ArchMapVo> all) {
List<ArchMapVo> children = all.stream()
.filter(item -> !StringUtils.isEmpty(item.getParentAssetId()))
.filter(item -> item.getParentAssetId().equals(root.getAssetId()))
.peek(item -> {
item.setChildren(getChildrens(item, all));
}).collect(Collectors.toList());
return children;
}
} }
...@@ -4,6 +4,8 @@ import lombok.AllArgsConstructor; ...@@ -4,6 +4,8 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.List;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
...@@ -37,4 +39,7 @@ public class ArchMapVo { ...@@ -37,4 +39,7 @@ public class ArchMapVo {
*/ */
private String assetId; private String assetId;
private List<ArchMapVo> children;
} }
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
m.ea_level as eaLevel, m.ea_level as eaLevel,
n.parent_asset_id as parentAssetId, n.parent_asset_id as parentAssetId,
n.archi_type as archiType, n.archi_type as archiType,
n.asset_id as assetId n.asset_code as assetCode,
n.asset_id as assetId
from from
archi_asset_info n, archi_asset_info n,
archi_element m archi_element m
...@@ -19,12 +20,13 @@ ...@@ -19,12 +20,13 @@
<if test="eaLevel!=null and eaLevel!=''"> <if test="eaLevel!=null and eaLevel!=''">
and m.ea_level= #{eaLevel} and m.ea_level= #{eaLevel}
</if> </if>
and n.del_flag = 0 and n.del_flag = 0
and n.archi_stage = 1 and n.archi_stage = 1
and n.state = 1 and n.state = 1
and m.state=1 and m.state=1
and m.del_flag=0 and m.del_flag=0
<if test="parentAssetId!=null and parentAssetId!=''">
and n.parent_asset_id = #{parentAssetId} and n.parent_asset_id = #{parentAssetId}
</if>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!