|
|
@@ -125,11 +125,9 @@ public class StruServiceImpl implements StruService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
* @author luorui
|
|
|
* @date 2025/6/25 17:01
|
|
|
* @discription 从缓存中查询组织树
|
|
|
- *
|
|
|
* @discription 根据登录用户所属的组织机构,查询出对应的三级信息。根据用户所属单位类型返回结果集合不一致.
|
|
|
* 示例:
|
|
|
* 用户为“湖北”,返回 地市-区县-线路 n-n-n
|
|
|
@@ -155,19 +153,19 @@ public class StruServiceImpl implements StruService {
|
|
|
}
|
|
|
//2.获取线路缓存
|
|
|
Map<String, Object> cacheMap = dwdShbDsFeederBaseService.getAllFeederCache();
|
|
|
- if(CollUtil.isEmpty(cacheMap)){
|
|
|
+ if (CollUtil.isEmpty(cacheMap)) {
|
|
|
throw new BusinessException("线路缓存信息为空!");
|
|
|
}
|
|
|
Map<String, FeederCacheDTO> resultMap = cacheMap.entrySet().stream().collect(Collectors.toMap(e -> e.getKey(), e -> (FeederCacheDTO) e.getValue()));
|
|
|
|
|
|
//K->区县的 ISC组织机构ID ,V->线路信息集合
|
|
|
- Map<String, List<FeederCacheDTO>> maintOrgFeederMap = resultMap.values().parallelStream().filter(e->StrUtil.isNotBlank(e.getMaintOrg())).collect(Collectors.groupingByConcurrent((FeederCacheDTO::getMaintOrg)));
|
|
|
+ Map<String, List<FeederCacheDTO>> maintOrgFeederMap = resultMap.values().parallelStream().filter(e -> StrUtil.isNotBlank(e.getMaintOrg())).collect(Collectors.groupingByConcurrent((FeederCacheDTO::getMaintOrg)));
|
|
|
|
|
|
//将线路信息再按照变压器分组,K->区县ISC组织机构ID,V->变电站信息集合,(变电站信息保护信息信息)
|
|
|
Map<String, List<StationDTO>> stationFeedMap = maintOrgFeederMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey,
|
|
|
entry -> {
|
|
|
//对同一个区县下的线路按 变电站分组, 过滤掉变电站信息为空的数据
|
|
|
- Map<String, List<FeederCacheDTO>> stationMap = entry.getValue().stream().filter(e->StrUtil.isNotBlank(e.getStartStation())).collect(Collectors.groupingBy(FeederCacheDTO::getStartStation));
|
|
|
+ Map<String, List<FeederCacheDTO>> stationMap = entry.getValue().stream().filter(e -> StrUtil.isNotBlank(e.getStartStation())).collect(Collectors.groupingBy(FeederCacheDTO::getStartStation));
|
|
|
//将数据构建成 变电站数据
|
|
|
return stationMap.entrySet().stream().map(e -> StationDTO.builder()
|
|
|
.station(e.getKey())
|
|
|
@@ -211,21 +209,21 @@ public class StruServiceImpl implements StruService {
|
|
|
}
|
|
|
|
|
|
//省份的数据构建
|
|
|
- private void buildProvinceByCache(List<StruDTO> departmentList, StruTreeCacheDTO struTreeByCache, Map<String, List<StationDTO>> stationFeedMap) {
|
|
|
+ private void buildProvinceByCache(List<StruDTO> departmentList, StruTreeCacheDTO struTreeByCache, Map<String, List<StationDTO>> stationFeedMap) {
|
|
|
StruDTO struDTO = cloneTree(struTreeByCache, stationFeedMap);
|
|
|
//省份的话,取 市->区县->线路,去除根节点
|
|
|
departmentList.addAll(struDTO.getChildren());
|
|
|
}
|
|
|
|
|
|
//市的数据构建
|
|
|
- private void buildCityByCache(List<StruDTO> departmentList, StruTreeCacheDTO struTreeByCache, Map<String, List<StationDTO>> stationFeedMap) {
|
|
|
+ private void buildCityByCache(List<StruDTO> departmentList, StruTreeCacheDTO struTreeByCache, Map<String, List<StationDTO>> stationFeedMap) {
|
|
|
StruDTO struDTO = cloneTree(struTreeByCache, stationFeedMap);
|
|
|
//市的话直接返回重构树
|
|
|
departmentList.add(struDTO);
|
|
|
}
|
|
|
|
|
|
//区县的数据构建,向上找到他的父节点
|
|
|
- private void buildCountyByCache(List<StruDTO> departmentList, StruTreeCacheDTO struTreeByCache, Map<String, List<StationDTO>> stationFeedMap) {
|
|
|
+ private void buildCountyByCache(List<StruDTO> departmentList, StruTreeCacheDTO struTreeByCache, Map<String, List<StationDTO>> stationFeedMap) {
|
|
|
//构建子节点
|
|
|
StruDTO childDTO = cloneTree(struTreeByCache, stationFeedMap);
|
|
|
//构建父节点
|
|
|
@@ -248,7 +246,7 @@ public class StruServiceImpl implements StruService {
|
|
|
}
|
|
|
|
|
|
//复制树结构转换成目标结构类型,递归遍历每个节点,拷贝属性,如果是区县则添加上变电站、线路信息
|
|
|
- private StruDTO cloneTree(StruTreeCacheDTO originalRoot, Map<String, List<StationDTO>> stationFeedMap) {
|
|
|
+ private StruDTO cloneTree(StruTreeCacheDTO originalRoot, Map<String, List<StationDTO>> stationFeedMap) {
|
|
|
if (originalRoot == null) {
|
|
|
return null;
|
|
|
}
|
|
|
@@ -355,7 +353,6 @@ public class StruServiceImpl implements StruService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* @author luorui
|
|
|
* @date 2025/5/13 11:49
|
|
|
@@ -416,7 +413,7 @@ public class StruServiceImpl implements StruService {
|
|
|
List<String> psrIdList = feederBaseList.stream().map(FeederBase::getPsrId).collect(Collectors.toList());
|
|
|
List<FhzgDistMappingFileDTO> fhzgDistMappingFileDTOList = fhzgDistMappingFileMapper.getMappingFileById(psrIdList);
|
|
|
//K->psrId V->图形文件集合
|
|
|
- Map<String,List<FhzgDistMappingFileDTO>> psrIdMap = fhzgDistMappingFileDTOList.stream().collect(Collectors.groupingBy(FhzgDistMappingFileDTO::getLineId));
|
|
|
+ Map<String, List<FhzgDistMappingFileDTO>> psrIdMap = fhzgDistMappingFileDTOList.stream().collect(Collectors.groupingBy(FhzgDistMappingFileDTO::getLineId));
|
|
|
List<FeederDTO> feederList = new ArrayList<>();
|
|
|
if (CollUtil.isNotEmpty(feederBaseList)) {
|
|
|
feederBaseList.forEach(e -> {
|
|
|
@@ -490,6 +487,7 @@ public class StruServiceImpl implements StruService {
|
|
|
|
|
|
/**
|
|
|
* 查询省,市,区县的组织树(根据用户所属组织机构,从缓存中取)
|
|
|
+ *
|
|
|
* @param
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -507,11 +505,9 @@ public class StruServiceImpl implements StruService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
* @author luorui
|
|
|
* @date 2025/7/17 15:44
|
|
|
* @discription 根据struId获取其下级所有区县id
|
|
|
- *
|
|
|
**/
|
|
|
@Override
|
|
|
public List<Long> getCountyCodeListByStruId(Long struId) {
|
|
|
@@ -557,16 +553,14 @@ public class StruServiceImpl implements StruService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
* @author luorui
|
|
|
* @date 2025/7/17 15:01
|
|
|
- * @discription
|
|
|
- * 根据StruId 查询市->区县两级结构
|
|
|
- * 1.用户如果是省公司,返回->市-区县,
|
|
|
- * 2.用户如果是市公司,返回->所属市->区县,
|
|
|
- * 3.用户如果是区县,返回上级市->当前区县。
|
|
|
+ * @discription 根据StruId 查询市->区县两级结构
|
|
|
+ * 1.用户如果是省公司,返回->市-区县,
|
|
|
+ * 2.用户如果是市公司,返回->所属市->区县,
|
|
|
+ * 3.用户如果是区县,返回上级市->当前区县。
|
|
|
**/
|
|
|
- private List<StruTreeVO> getStruTreeById(Long struId){
|
|
|
+ private List<StruTreeVO> getStruTreeById(Long struId) {
|
|
|
//查询所属机构的组织结构
|
|
|
StruTreeCacheDTO struTreeCacheDTO = sysStruService.getStruTreeByCache(struId);
|
|
|
List<StruTreeVO> result = new ArrayList<>();
|
|
|
@@ -613,10 +607,32 @@ public class StruServiceImpl implements StruService {
|
|
|
} else {
|
|
|
log.info("查询组织机构信息不存在struId:{}", struId);//返回空数据
|
|
|
}
|
|
|
+ removeSecondChildNode(result);
|
|
|
setEmptyArr(result);//将子节点为空的数据去掉
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ //删除第二层后组织机构数据
|
|
|
+ private void removeSecondChildNode(List<StruTreeVO> list) {
|
|
|
+ if (list == null || list.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (StruTreeVO parent : list) {
|
|
|
+ if (!Objects.equals(parent.getStruType(), CITY)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<StruTreeVO> children = parent.getChildren();
|
|
|
+ if (children == null || children.isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (StruTreeVO child : children) {
|
|
|
+ if (child.getChildren() != null) {
|
|
|
+ child.getChildren().clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void setEmptyArr(List<StruTreeVO> struTreeVOList) {
|
|
|
if (struTreeVOList == null || struTreeVOList.isEmpty()) {
|
|
|
return;
|