|
|
|
|
@@ -1,17 +1,21 @@
|
|
|
|
|
package com.njcn.device.pq.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.njcn.common.pojo.enums.common.ServerEnum;
|
|
|
|
|
import com.njcn.common.pojo.response.HttpResult;
|
|
|
|
|
import com.njcn.device.biz.pojo.vo.TerminalSelectTreeVO;
|
|
|
|
|
import com.njcn.device.pq.enums.LineBaseEnum;
|
|
|
|
|
import com.njcn.device.pq.mapper.DeptLineMapper;
|
|
|
|
|
import com.njcn.device.pq.mapper.LineDetailMapper;
|
|
|
|
|
import com.njcn.device.pq.mapper.LineMapper;
|
|
|
|
|
import com.njcn.device.pq.mapper.TreeMapper;
|
|
|
|
|
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
|
|
|
|
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
|
|
|
|
import com.njcn.device.pq.pojo.po.Line;
|
|
|
|
|
import com.njcn.device.pq.pojo.po.LineDetail;
|
|
|
|
|
import com.njcn.device.pq.pojo.vo.DeptLineTreeVO;
|
|
|
|
|
import com.njcn.device.pq.pojo.vo.TerminalTree;
|
|
|
|
|
import com.njcn.device.pq.service.TerminalTreeService;
|
|
|
|
|
@@ -24,10 +28,7 @@ import lombok.AllArgsConstructor;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
@@ -45,6 +46,8 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
|
|
|
|
|
|
|
|
|
private final LineMapper lineMapper;
|
|
|
|
|
|
|
|
|
|
private final LineDetailMapper lineDetailMapper;
|
|
|
|
|
|
|
|
|
|
private final AreaFeignClient areaFeignClient;
|
|
|
|
|
|
|
|
|
|
private final DicDataFeignClient dicDataFeignClient;
|
|
|
|
|
@@ -279,6 +282,127 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
|
|
|
|
return resultList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<TerminalTree> getJbTerminalTree() {
|
|
|
|
|
List<TerminalTree> taiZhang = new ArrayList<>();
|
|
|
|
|
List<TerminalTree> allList = lineMapper.getAllList();
|
|
|
|
|
List<TerminalTree> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
|
|
|
|
List<TerminalTree> provinceList = lineMapper.getProvinceList(null, 0);
|
|
|
|
|
|
|
|
|
|
List<TerminalTree> collect1 = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.SUB_LEVEL.getCode()) ||
|
|
|
|
|
item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode()) ||
|
|
|
|
|
item.getLevel().equals(LineBaseEnum.SUB_V_LEVEL.getCode())
|
|
|
|
|
).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<TerminalTree> gdList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.GD_LEVEL.getCode())
|
|
|
|
|
// && item.getName().equals("承德供电公司")
|
|
|
|
|
).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
|
|
|
|
List<TerminalTree> subList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.SUB_LEVEL.getCode())
|
|
|
|
|
// && item.getName().equals("110kV兴泉变电站")
|
|
|
|
|
|
|
|
|
|
).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
|
|
|
|
List<TerminalTree> lineList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode())).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
//赋值电网侧信息
|
|
|
|
|
List<String> lineIds = lineList.stream().map(TerminalTree::getId).collect(Collectors.toList());
|
|
|
|
|
List<LineDetail> list = lineDetailMapper.selectList(new LambdaQueryWrapper<LineDetail>().in(CollUtil.isNotEmpty(lineIds), LineDetail::getId, lineIds));
|
|
|
|
|
Map<String, LineDetail> powerFlagMap = list.stream().collect(Collectors.toMap(LineDetail::getId, Function.identity()));
|
|
|
|
|
for (TerminalTree x : lineList) {
|
|
|
|
|
if(powerFlagMap.containsKey(x.getId())){
|
|
|
|
|
x.setPowerFlag(powerFlagMap.get(x.getId()).getPowerFlag());
|
|
|
|
|
x.setPowerSubstationName(powerFlagMap.get(x.getId()).getPowerSubstationName());
|
|
|
|
|
}else{
|
|
|
|
|
x.setPowerFlag(LineBaseEnum.POWER_FLAG.getCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, List<TerminalTree>> lineObjNameMap = lineList.stream().filter(x -> StrUtil.isNotBlank(x.getPowerSubstationName())).collect(Collectors.groupingBy(TerminalTree::getPowerSubstationName));
|
|
|
|
|
//组织变电站信息
|
|
|
|
|
List<TerminalTree> subInfoList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
lineObjNameMap.forEach((key, value)->{
|
|
|
|
|
List<TerminalTree> valueList = new ArrayList<>();
|
|
|
|
|
//电网侧监测点
|
|
|
|
|
TerminalTree powerTree=new TerminalTree();
|
|
|
|
|
powerTree.setName("电网侧");
|
|
|
|
|
List<TerminalTree> powerFlag = value.stream().filter(x -> x.getPowerFlag().equals(LineBaseEnum.POWER_FLAG.getCode())).collect(Collectors.toList());
|
|
|
|
|
List<TerminalTree> subChildren = getRecursionChildren(powerFlag, collect1);
|
|
|
|
|
powerTree.setChildren(new ArrayList<>());
|
|
|
|
|
|
|
|
|
|
//非电网侧监测点
|
|
|
|
|
TerminalTree notPowerTree=new TerminalTree();
|
|
|
|
|
notPowerTree.setName("非电网侧");
|
|
|
|
|
List<TerminalTree> powerFlagNot = value.stream().filter(x -> x.getPowerFlag().equals(LineBaseEnum.POWER_FLAG_NOT.getCode())).collect(Collectors.toList());
|
|
|
|
|
List<TerminalTree> notSubChildren = getRecursionChildren(powerFlagNot, collect1);
|
|
|
|
|
notPowerTree.setChildren(new ArrayList<>());
|
|
|
|
|
valueList.add(powerTree);
|
|
|
|
|
valueList.add(notPowerTree);
|
|
|
|
|
//获取变电信息
|
|
|
|
|
List<TerminalTree> collect = subList.stream().filter(x -> x.getName().equals(key)).collect(Collectors.toList());
|
|
|
|
|
if(CollUtil.isNotEmpty(collect)){
|
|
|
|
|
TerminalTree sub=new TerminalTree();
|
|
|
|
|
sub.setId(collect.get(0).getId());
|
|
|
|
|
sub.setName(collect.get(0).getName());
|
|
|
|
|
sub.setPid(collect.get(0).getPid());
|
|
|
|
|
sub.setChildren(valueList);
|
|
|
|
|
powerTree.setChildren(subChildren);
|
|
|
|
|
notPowerTree.setChildren(notSubChildren);
|
|
|
|
|
subInfoList.add(sub);
|
|
|
|
|
}else{
|
|
|
|
|
//电网侧变电站能否找到
|
|
|
|
|
for (TerminalTree child : subChildren) {
|
|
|
|
|
List<TerminalTree> exist = subInfoList.stream().filter(x -> x.getId().equals(child.getId())).collect(Collectors.toList());
|
|
|
|
|
if(CollUtil.isNotEmpty(exist)){
|
|
|
|
|
//电网侧
|
|
|
|
|
exist.get(0).getChildren().get(0).getChildren().addAll(child.getChildren());
|
|
|
|
|
}else{
|
|
|
|
|
TerminalTree sub=new TerminalTree();
|
|
|
|
|
sub.setId(child.getId());
|
|
|
|
|
sub.setName(child.getName());
|
|
|
|
|
sub.setPid(child.getPid());
|
|
|
|
|
valueList.get(0).setChildren(Arrays.asList(child));
|
|
|
|
|
sub.setChildren(valueList);
|
|
|
|
|
subInfoList.add(sub);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (TerminalTree child : notSubChildren) {
|
|
|
|
|
List<TerminalTree> exist = subInfoList.stream().filter(x -> x.getId().equals(child.getId())).collect(Collectors.toList());
|
|
|
|
|
if(CollUtil.isNotEmpty(exist)){
|
|
|
|
|
//非电网侧
|
|
|
|
|
exist.get(1).getChildren().get(0).getChildren().addAll(child.getChildren());
|
|
|
|
|
}else{
|
|
|
|
|
TerminalTree sub=new TerminalTree();
|
|
|
|
|
sub.setId(child.getId());
|
|
|
|
|
sub.setName(child.getName());
|
|
|
|
|
sub.setPid(child.getPid());
|
|
|
|
|
valueList.get(1).setChildren(Arrays.asList(child));
|
|
|
|
|
sub.setChildren(valueList);
|
|
|
|
|
subInfoList.add(sub);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
gdList.forEach(gd -> gd.setChildren(getChildren(gd, subInfoList)));
|
|
|
|
|
provinceList.forEach(province -> province.setChildren(getChildren(province, gdList)));
|
|
|
|
|
projectList.forEach(project -> project.setChildren(getChildren(project, provinceList)));
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(allList)) {
|
|
|
|
|
TerminalTree terminalTree = new TerminalTree();
|
|
|
|
|
terminalTree.setId("9999999");
|
|
|
|
|
terminalTree.setLevel(0);
|
|
|
|
|
terminalTree.setName("台账管理");
|
|
|
|
|
if (CollectionUtil.isNotEmpty(projectList)) {
|
|
|
|
|
terminalTree.setChildren(projectList);
|
|
|
|
|
}
|
|
|
|
|
taiZhang.add(terminalTree);
|
|
|
|
|
}
|
|
|
|
|
return taiZhang;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取全部子节点
|
|
|
|
|
@@ -290,6 +414,53 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
|
|
|
|
return all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 变电站层级增加电网侧和非电网侧电站
|
|
|
|
|
* @param line 变电站对象
|
|
|
|
|
* @param all 检测对象
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<TerminalTree> getRecursionChildren(List<TerminalTree> line, List<TerminalTree> all) {
|
|
|
|
|
List<TerminalTree> info=new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
List<TerminalTree> aa=new ArrayList<>();
|
|
|
|
|
for (TerminalTree lineTree : line) {
|
|
|
|
|
findParentsRecursive(lineTree, all,aa);
|
|
|
|
|
aa.add(lineTree);
|
|
|
|
|
}
|
|
|
|
|
List<TerminalTree> distinctList = aa.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
List<TerminalTree> collect = distinctList.stream().filter(x -> x.getLevel() == LineBaseEnum.SUB_LEVEL.getCode()).collect(Collectors.toList());
|
|
|
|
|
if(CollUtil.isNotEmpty(collect)){
|
|
|
|
|
for (TerminalTree tree : collect) {
|
|
|
|
|
info.add(findParents(distinctList,tree));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
private TerminalTree findParents(List<TerminalTree> all,TerminalTree subTree) {
|
|
|
|
|
List<TerminalTree> collect = all.stream().filter(allItem -> allItem.getPid().equals(subTree.getId())).collect(Collectors.toList());
|
|
|
|
|
if (CollUtil.isNotEmpty(collect)) {
|
|
|
|
|
collect.forEach(treeMap -> {
|
|
|
|
|
subTree.setChildren(collect);
|
|
|
|
|
findParents( all,treeMap);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return subTree;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void findParentsRecursive(TerminalTree tree, List<TerminalTree> all,List<TerminalTree> newParents) {
|
|
|
|
|
if (tree.getLevel() == LineBaseEnum.SUB_LEVEL.getCode()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
List<TerminalTree> collect = all.stream().filter(allItem -> allItem.getId().equals(tree.getPid())).collect(Collectors.toList());
|
|
|
|
|
if (CollUtil.isNotEmpty(collect)) {
|
|
|
|
|
newParents.addAll(collect);
|
|
|
|
|
collect.forEach(treeMap -> {
|
|
|
|
|
findParentsRecursive(treeMap, all, newParents);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 未绑定监测点树
|
|
|
|
|
*
|
|
|
|
|
|