|
|
|
|
@@ -3,6 +3,7 @@ package com.njcn.device.pq.service.impl;
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
@@ -25,7 +26,6 @@ import com.njcn.supervision.api.UserLedgerFeignClient;
|
|
|
|
|
import com.njcn.supervision.pojo.param.user.UserReportParam;
|
|
|
|
|
import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
|
|
|
|
|
import com.njcn.system.api.AreaFeignClient;
|
|
|
|
|
import com.njcn.system.api.DicDataFeignClient;
|
|
|
|
|
import com.njcn.system.pojo.enums.StatisticsEnum;
|
|
|
|
|
import com.njcn.system.pojo.po.Area;
|
|
|
|
|
import com.njcn.web.utils.RequestUtil;
|
|
|
|
|
@@ -138,7 +138,12 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
|
|
|
|
|
|
|
|
|
private List<TerminalTree> specialDealSubChildren(TerminalTree sub,List<TerminalTree> lineUserList,List<TerminalTree> devOtherList,List<TerminalTree> busBarList,List<TerminalTree> devAllList,List<UserLedgerVO> userReportPOList){
|
|
|
|
|
List<TerminalTree> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
//电网侧
|
|
|
|
|
List<TerminalTree> devTree = devOtherList.stream().filter(it->it.getPid().equals(sub.getId())).collect(Collectors.toList());
|
|
|
|
|
if(CollectionUtil.isNotEmpty(devTree)){
|
|
|
|
|
list.addAll(devTree);
|
|
|
|
|
}
|
|
|
|
|
//非电网侧
|
|
|
|
|
if(CollUtil.isNotEmpty(userReportPOList)) {
|
|
|
|
|
Map<String, UserLedgerVO> userLedgerVOMap = userReportPOList.stream().collect(Collectors.toMap(UserLedgerVO::getId, Function.identity()));
|
|
|
|
|
|
|
|
|
|
@@ -160,6 +165,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
|
|
|
|
busCopy.setName(it.getName());
|
|
|
|
|
busCopy.setId(it.getId());
|
|
|
|
|
busCopy.setPid(it.getPid());
|
|
|
|
|
busCopy.setSort(it.getSort());
|
|
|
|
|
busCopy.setChildren(getChildren(it, lineList));
|
|
|
|
|
busCopy.setPowerFlag(1);
|
|
|
|
|
busCopy.setLevel(LineBaseEnum.SUB_V_LEVEL.getCode());
|
|
|
|
|
@@ -175,6 +181,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
|
|
|
|
devCopy.setName(it.getName());
|
|
|
|
|
devCopy.setId(it.getId());
|
|
|
|
|
devCopy.setPid(it.getPid());
|
|
|
|
|
devCopy.setSort(it.getSort());
|
|
|
|
|
devCopy.setChildren(getChildren(it, temBus));
|
|
|
|
|
devCopy.setPowerFlag(1);
|
|
|
|
|
devCopy.setLevel(LineBaseEnum.DEVICE_LEVEL.getCode());
|
|
|
|
|
@@ -192,18 +199,11 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
|
|
|
|
terminalTree.setPowerFlag(1);
|
|
|
|
|
terminalTree.setLevel(LineBaseEnum.USER_LEVEL.getCode());
|
|
|
|
|
terminalTree.setChildren(temDevList);
|
|
|
|
|
terminalTree.setSort(0);
|
|
|
|
|
list.add(terminalTree);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<TerminalTree> devTree = devOtherList.stream().filter(it->it.getPid().equals(sub.getId())).collect(Collectors.toList());
|
|
|
|
|
if(CollectionUtil.isNotEmpty(devTree)){
|
|
|
|
|
list.addAll(devTree);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -521,6 +521,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
|
|
|
|
sub.setId(collect.get(0).getId());
|
|
|
|
|
sub.setName(collect.get(0).getName());
|
|
|
|
|
sub.setPid(collect.get(0).getPid());
|
|
|
|
|
sub.setSort(0);
|
|
|
|
|
sub.setChildren(valueList);
|
|
|
|
|
|
|
|
|
|
TerminalTree powerTree=new TerminalTree();
|
|
|
|
|
@@ -551,7 +552,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
|
|
|
|
sub.setId(child.getId());
|
|
|
|
|
sub.setName(child.getName());
|
|
|
|
|
sub.setPid(child.getPid());
|
|
|
|
|
|
|
|
|
|
sub.setSort(0);
|
|
|
|
|
TerminalTree powerTree=new TerminalTree();
|
|
|
|
|
powerTree.setName("电网侧");
|
|
|
|
|
powerTree.setId(child.getId());
|
|
|
|
|
@@ -581,7 +582,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
|
|
|
|
sub.setId(child.getId());
|
|
|
|
|
sub.setName(child.getName());
|
|
|
|
|
sub.setPid(child.getPid());
|
|
|
|
|
|
|
|
|
|
sub.setSort(0);
|
|
|
|
|
TerminalTree powerTree = new TerminalTree();
|
|
|
|
|
powerTree.setName("电网侧");
|
|
|
|
|
powerTree.setId(child.getId());
|
|
|
|
|
@@ -620,7 +621,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
|
|
|
|
sub.setId(notSub.getId());
|
|
|
|
|
sub.setName(notSub.getName());
|
|
|
|
|
sub.setPid(notSub.getPid());
|
|
|
|
|
|
|
|
|
|
sub.setSort(0);
|
|
|
|
|
TerminalTree powerTree = new TerminalTree();
|
|
|
|
|
powerTree.setId(notSub.getId());
|
|
|
|
|
powerTree.setName("电网侧");
|
|
|
|
|
@@ -655,6 +656,49 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
|
|
|
|
return taiZhang;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<TerminalTree> getJbNewTerminalTree() {
|
|
|
|
|
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> gdList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.GD_LEVEL.getCode())).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
|
|
|
|
List<TerminalTree> subList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.SUB_LEVEL.getCode())).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
|
|
|
|
List<TerminalTree> devList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode())).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
|
|
|
|
List<TerminalTree> subvList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.SUB_V_LEVEL.getCode())).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
List<TerminalTree> linepowerList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode())&&item.getPowerFlag() != 1).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
|
|
|
|
List<TerminalTree> lineNotPowerList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode())&&item.getPowerFlag() == 1).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subvList.forEach(subv ->{
|
|
|
|
|
if(CollUtil.isEmpty(subv.getChildren())){
|
|
|
|
|
subv.setChildren(getRecursionChildren(subv, linepowerList));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
subvList.forEach(subv -> {
|
|
|
|
|
if(CollUtil.isEmpty(subv.getChildren())){
|
|
|
|
|
subv.setChildren(getRecursionChildren(subv, lineNotPowerList));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
subvList.stream().filter(x-> ObjUtil.isNull(x.getPowerFlag())).forEach(x->x.setPowerFlag(0));
|
|
|
|
|
devList.forEach(dev -> dev.setChildren(getRecursionChildren(dev, subvList)));
|
|
|
|
|
devList.stream().filter(x-> ObjUtil.isNull(x.getPowerFlag())).forEach(x->x.setPowerFlag(0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subList.forEach(sub -> sub.setChildren(getRecursionChildrenCs(sub, devList)));
|
|
|
|
|
gdList.forEach(gd -> gd.setChildren(getChildren(gd, subList)));
|
|
|
|
|
provinceList.forEach(province -> province.setChildren(getChildren(province, gdList)));
|
|
|
|
|
projectList.forEach(project -> project.setChildren(getChildren(project, provinceList)));
|
|
|
|
|
|
|
|
|
|
return projectList;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取全部子节点
|
|
|
|
|
@@ -663,7 +707,40 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
|
|
|
|
* @date 2021/7/19
|
|
|
|
|
*/
|
|
|
|
|
public List<TerminalTree> getChildren(TerminalTree item, List<TerminalTree> all) {
|
|
|
|
|
return all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
|
|
|
|
List<TerminalTree> collect = all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
|
|
|
|
if(CollUtil.isNotEmpty(collect)){
|
|
|
|
|
long sortSize = collect.stream().filter(x->ObjUtil.isNotNull(x.getSort())).filter(x -> x.getSort() == 0).count();
|
|
|
|
|
if(collect.size()-sortSize/collect.size()>50){
|
|
|
|
|
collect.sort(Comparator.comparing(x->x.getName()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return collect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<TerminalTree> getRecursionChildrenCs(TerminalTree item, List<TerminalTree> all){
|
|
|
|
|
List<TerminalTree> collect = all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
|
|
|
|
List<TerminalTree> list=new ArrayList<>();
|
|
|
|
|
TerminalTree power=new TerminalTree();
|
|
|
|
|
power.setName("电网侧");
|
|
|
|
|
power.setSort(0);
|
|
|
|
|
power.setChildren(collect.stream().filter(x -> 1 != x.getPowerFlag()).collect(Collectors.toList()));
|
|
|
|
|
list.add(power);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TerminalTree notPower=new TerminalTree();
|
|
|
|
|
notPower.setName("非电网侧");
|
|
|
|
|
notPower.setSort(1);
|
|
|
|
|
notPower.setChildren(collect.stream().filter(x -> 1 == x.getPowerFlag()).collect(Collectors.toList()));
|
|
|
|
|
list.add(notPower);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
public List<TerminalTree> getRecursionChildren(TerminalTree item, List<TerminalTree> all){
|
|
|
|
|
List<TerminalTree> list = all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
|
|
|
|
if(CollUtil.isNotEmpty(list)){
|
|
|
|
|
item.setPowerFlag(list.get(0).getPowerFlag());
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|