Commit a6b025f4 authored by 张森's avatar 张森

/equip/building/video/getBuildingVideoTreeVideoList

建筑 + 监控视频
parent c1c49a24
package com.yeejoin.equipmanage.controller; package com.yeejoin.equipmanage.controller;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.equipmanage.common.entity.vo.BuildingListVO; import com.yeejoin.equipmanage.common.entity.vo.BuildingListVO;
import com.yeejoin.equipmanage.common.entity.vo.BuildingVideoListVO; import com.yeejoin.equipmanage.common.entity.vo.BuildingVideoListVO;
...@@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import java.util.Iterator;
import java.util.List; import java.util.List;
/** /**
...@@ -48,7 +50,32 @@ public class BuildingVideoController extends AbstractBaseController { ...@@ -48,7 +50,32 @@ public class BuildingVideoController extends AbstractBaseController {
@ApiOperation("物联监控->单位建筑树(节点上绑定视频集合数据)") @ApiOperation("物联监控->单位建筑树(节点上绑定视频集合数据)")
@GetMapping(value = "/getBuildingVideoTreeVideoList") @GetMapping(value = "/getBuildingVideoTreeVideoList")
public List<BuildingTreeVo> getBuildingVideoTreeVideoList() { public List<BuildingTreeVo> getBuildingVideoTreeVideoList() {
return buildService.getBuildingVideoTreeVideoList(); List<BuildingTreeVo> buildingVideoTreeVideoList = buildService.getBuildingVideoTreeVideoList();
Iterator<BuildingTreeVo> iterator = buildingVideoTreeVideoList.iterator();
while (iterator.hasNext()) {
BuildingTreeVo item = iterator.next();
if (CollUtil.isEmpty(item.getVideoList())) {
iterator.remove();
} else {
removeZeroTotalNodes(item);
}
}
return buildingVideoTreeVideoList;
}
public void removeZeroTotalNodes(BuildingTreeVo root) {
if (root == null) {
return;
}
Iterator<BuildingTreeVo> iterator = root.getChildren().iterator();
while (iterator.hasNext()) {
BuildingTreeVo child = iterator.next();
if (CollUtil.isEmpty(child.getVideoList())) {
iterator.remove();
} else {
removeZeroTotalNodes(child);
}
}
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
......
...@@ -1485,6 +1485,63 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i ...@@ -1485,6 +1485,63 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
} }
private List<BuildingTreeVo> buildBuildingAndCompanyListVosNew(String authKey, String type, String ment) {
if (StringUtils.isEmpty(authKey)) {
authKey = this.authKey;
}
CompletableFuture<List<BuildingTreeVo>> companyListFuture = CompletableFuture.supplyAsync(() -> getBuildingTreeVos(false, null));
String finalAuthKey = authKey;
String appKey = RequestContext.getAppKey();
String product = RequestContext.getProduct();
String token = RequestContext.getToken();
CompletableFuture<List<OrgUsrDto>> orgUsrListFuture = CompletableFuture.supplyAsync(() -> {
RequestContext.setAppKey(appKey);
RequestContext.setProduct(product);
RequestContext.setToken(token);
return jcsRemoteService.getCompanyDeptListWithAuth(finalAuthKey, "COMPANY", type);
});
CompletableFuture.allOf(companyListFuture, orgUsrListFuture).join();
List<BuildingTreeVo> buildingTreeVos = companyListFuture.join();
List<OrgUsrDto> orgUsrLists = orgUsrListFuture.join();
if(orgUsrLists.isEmpty()){
return new ArrayList<>();
}
// 2.数据结构转换
List<BuildingTreeVo> companyList = orgUsrLists.stream().map(orgUsrDto -> {
BuildingTreeVo vo = new BuildingTreeVo();
vo.setGroupType("allBuilding");
vo.setGroupCode("allBuilding");
vo.setInstanceName(orgUsrDto.getBizOrgName());
vo.setBizOrgCode(orgUsrDto.getBizOrgCode());
vo.setInstanceId(orgUsrDto.getSequenceNbr());
vo.setParentId(orgUsrDto.getParentId());
vo.setName(orgUsrDto.getBizOrgName());
vo.setId(orgUsrDto.getSequenceNbr());
vo.setBizOrgName(orgUsrDto.getBizOrgName());
//此处为公共接口 未区分导致消防建筑页面树统计错误
if(ment.equals("video")){
vo.setTotal(!StringUtils.isEmpty(orgUsrDto.getBizOrgCode()) ? formInstanceMapper.queryVideoCountByBizOrgCode(orgUsrDto.getBizOrgCode()) : 0L);
}else {
vo.setTotal(buildingTreeVos.stream().filter(b -> !ObjectUtils.isEmpty(b.getBizOrgCode()) && b.getBizOrgCode().contains(ObjectUtils.isEmpty(vo.getBizOrgCode())?"":vo.getBizOrgCode()) && "building".equals(b.getGroupType())).count());
}
return vo;
}).collect(Collectors.toList());
// 3.将建筑的bizOrgCode转换为parentId连接树 ,拼接数据准备
Map<String, Long> comMap = orgUsrLists.stream().collect(Collectors.toMap(OrgUsrDto::getBizOrgCode, OrgUsrDto::getSequenceNbr));
//增加了一层对树的过滤,过滤掉指定公司外的其他建筑。
List<BuildingTreeVo> collect = buildingTreeVos.stream().filter(build ->companyList.stream().map(m -> {
String bizOrgCode = m.getBizOrgCode();
return bizOrgCode;
}).collect(Collectors.toList()).contains(build.getBizOrgCode())).collect(Collectors.toList());
collect.forEach(b -> {
b.setParentId("0".equals(b.getParentId()) ? String.valueOf(comMap.get(b.getBizOrgCode())) : b.getParentId());
b.setDetailPaneApi(address);
b.setApiUrl(apiUrl);
});
return collect;
}
private List<BuildingTreeVo> buildBuildingAndCompanyListVos(String authKey, String type, String ment) { private List<BuildingTreeVo> buildBuildingAndCompanyListVos(String authKey, String type, String ment) {
if (StringUtils.isEmpty(authKey)) { if (StringUtils.isEmpty(authKey)) {
...@@ -1582,7 +1639,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i ...@@ -1582,7 +1639,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
@Override @Override
public List<BuildingTreeVo> getBuildingVideoTreeVideoList() { public List<BuildingTreeVo> getBuildingVideoTreeVideoList() {
//1.组装数据 //1.组装数据
List<BuildingTreeVo> companyBuildingList = buildBuildingAndCompanyListVos(buildVideoAuthKey, null,"video"); List<BuildingTreeVo> companyBuildingList = buildBuildingAndCompanyListVosNew(buildVideoAuthKey, null,"video");
List<Map<String, Long>> countList = iFormInstanceService.getBuildVideoCount(); List<Map<String, Long>> countList = iFormInstanceService.getBuildVideoCount();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment