Commit f87ef47f authored by suhuiguang's avatar suhuiguang

1.新增消防建筑树接口

parent 829e7bcd
...@@ -4,6 +4,7 @@ import java.util.LinkedHashMap; ...@@ -4,6 +4,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
...@@ -302,4 +303,12 @@ public class BuildingController extends AbstractBaseController { ...@@ -302,4 +303,12 @@ public class BuildingController extends AbstractBaseController {
return buildService.getCompanyBuildingTree(null); return buildService.getCompanyBuildingTree(null);
} }
@ApiOperation(value = "查询指定单位的建筑树")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{bizOrgCode}/tree")
public List<BuildingTreeVo> buildingTree(
@ApiParam(value = "单位编码") @PathVariable String bizOrgCode){
return buildService.getBuildingTreeInOrgCode(bizOrgCode);
}
} }
...@@ -309,4 +309,11 @@ public interface IBuilldService extends IService<Building> { ...@@ -309,4 +309,11 @@ public interface IBuilldService extends IService<Building> {
* @return List<EquiplistSpecificBySystemVO> * @return List<EquiplistSpecificBySystemVO>
*/ */
List<EquiplistSpecificBySystemVO> getPointInFloor(Long floorId); List<EquiplistSpecificBySystemVO> getPointInFloor(Long floorId);
/**
* 建筑树
* @param bizOrgCode 所在公司
* @return List<BuildingTreeVo>
*/
List<BuildingTreeVo> getBuildingTreeInOrgCode(String bizOrgCode);
} }
...@@ -450,6 +450,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i ...@@ -450,6 +450,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
BuildingTreeVo treeNode = new BuildingTreeVo(); BuildingTreeVo treeNode = new BuildingTreeVo();
treeNode.setDetailPaneApi(address); treeNode.setDetailPaneApi(address);
treeNode.setApiUrl(apiUrl); treeNode.setApiUrl(apiUrl);
treeNode.setName(formGroup.getGroupName());
treeNode.setInstanceId(formGroup.getId()); treeNode.setInstanceId(formGroup.getId());
treeNode.setInstanceName(formGroup.getGroupName()); treeNode.setInstanceName(formGroup.getGroupName());
treeNode.setParentId("-1"); treeNode.setParentId("-1");
...@@ -1160,9 +1161,9 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i ...@@ -1160,9 +1161,9 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
List<BuildingTreeVo> companyBuildingList = buildBuildingAndCompanyListVos(buildVideoAuthKey); List<BuildingTreeVo> companyBuildingList = buildBuildingAndCompanyListVos(buildVideoAuthKey);
List<Map<String, Long>> countList = iFormInstanceService.getBuildVideoCount(); List<Map<String, Long>> countList = iFormInstanceService.getBuildVideoCount();
Map<Long, Long> countMap = countList.stream().collect(Collectors.toMap(p -> p.get("buildId"), p -> p.get("total"))); Map<Long, Long> countMap = countList.stream().collect(Collectors.toMap(p -> p.get("buildId"), p -> p.get("total")));
companyBuildingList.forEach(c-> { companyBuildingList.forEach(c -> {
// 建筑类型数据,填充本级及子级包含的摄像头数量 // 建筑类型数据,填充本级及子级包含的摄像头数量
if(!ALL_BUILDING.equals(c.getGroupType())){ if (!ALL_BUILDING.equals(c.getGroupType())) {
c.setTotal(countMap.get(c.getInstanceId()) == null ? 0L : countMap.get(c.getInstanceId())); c.setTotal(countMap.get(c.getInstanceId()) == null ? 0L : countMap.get(c.getInstanceId()));
} else { } else {
// 方法 复用,覆盖掉不需要的数据 // 方法 复用,覆盖掉不需要的数据
...@@ -1182,7 +1183,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i ...@@ -1182,7 +1183,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
return companyBuildingList.stream().filter(a -> parentId.equals(a.getParentId())).peek(a -> { return companyBuildingList.stream().filter(a -> parentId.equals(a.getParentId())).peek(a -> {
a.setChildren(getCompanyBuildingChildrenWithCount(a.getId().toString(), companyBuildingList)); a.setChildren(getCompanyBuildingChildrenWithCount(a.getId().toString(), companyBuildingList));
//单位类型节点才需要设置摄像头总数,建筑的下摄像头总数已经在sql计算出来 //单位类型节点才需要设置摄像头总数,建筑的下摄像头总数已经在sql计算出来
if(ALL_BUILDING.equals(a.getGroupType())){ if (ALL_BUILDING.equals(a.getGroupType())) {
a.setTotal(a.getChildren().stream().filter(c -> c.getTotal() != null).mapToLong(BuildingTreeVo::getTotal).sum()); a.setTotal(a.getChildren().stream().filter(c -> c.getTotal() != null).mapToLong(BuildingTreeVo::getTotal).sum());
} }
}).collect(Collectors.toList()); }).collect(Collectors.toList());
...@@ -1222,6 +1223,16 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i ...@@ -1222,6 +1223,16 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
return bySystemVOS; return bySystemVOS;
} }
@Override
public List<BuildingTreeVo> getBuildingTreeInOrgCode(String bizOrgCode) {
List<BuildingTreeVo> buildingTreeVos = this.getBuildingTreeVos(true);
List<BuildingTreeVo> orgBuildingTreeVos = buildingTreeVos.stream().filter(b-> b.getBizOrgCode() != null && b.getBizOrgCode().contains(bizOrgCode)).collect(Collectors.toList());
return buildingTreeVos.stream().filter(b -> "-1".equals(b.getParentId())).peek(b -> {
b.setId(0L);
b.setChildren(this.getCompanyBuildingChildrenTree(b.getId().toString(), orgBuildingTreeVos));
}).collect(Collectors.toList());
}
private List<BuildingTreeVo> getCompanyBuildingChildrenTree(String parentId, List<BuildingTreeVo> all) { private List<BuildingTreeVo> getCompanyBuildingChildrenTree(String parentId, List<BuildingTreeVo> all) {
return all.stream().filter(a -> parentId.equals(a.getParentId())).peek(a -> { return all.stream().filter(a -> parentId.equals(a.getParentId())).peek(a -> {
a.setChildren(getCompanyBuildingChildrenTree(a.getId().toString(), all)); a.setChildren(getCompanyBuildingChildrenTree(a.getId().toString(), all));
......
...@@ -122,7 +122,7 @@ public class WarehouseStructureServiceImpl extends ServiceImpl<WarehouseStructur ...@@ -122,7 +122,7 @@ public class WarehouseStructureServiceImpl extends ServiceImpl<WarehouseStructur
for (WarehouseStructure it : treeNodes) { for (WarehouseStructure it : treeNodes) {
if (treeNode.getId().equals(it.getParentId())) { if (treeNode.getId().equals(it.getParentId())) {
if (treeNode.getChildren() == null) { if (treeNode.getChildren() == null) {
treeNode.setChildren(new ArrayList<WarehouseStructure>()); treeNode.setChildren(new ArrayList<>());
} }
treeNode.getChildren().add(findChildren(it, treeNodes)); treeNode.getChildren().add(findChildren(it, treeNodes));
} }
......
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