Commit 3340cd50 authored by suhuiguang's avatar suhuiguang

1.视频矩阵修改

parent 1f4d98e2
......@@ -5,12 +5,6 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
import java.math.BigDecimal;
import java.util.List;
/**
......
......@@ -35,14 +35,14 @@ public class BuildingVideoController extends AbstractBaseController {
IBuilldService buildService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation("消防建筑视监控树")
@ApiOperation("消防建筑视监控树")
@GetMapping(value = "/tree")
public List<BuildingTreeVo> getBuildingTree() {
return buildService.getBuildingVideoTree();
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation("消防建筑视屏监控树")
@ApiOperation("物联监控->单位建筑树(视频节点数量)")
@GetMapping(value = "/getBuildingVideoTree")
public List<BuildingTreeVo> getBuildingVideoTree() {
return buildService.getBuildingVideoTreeNew();
......
......@@ -279,7 +279,7 @@ public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements IA
}
private List<UnitAreaTreeVo> getChildrenFromData(Long parentId, List<UnitAreaTreeVo> areaTreeList) {
return areaTreeList.stream().filter(a->a.getParentId().equals(parentId)).peek(e-> e.setChildren(getChildrenFromData(e.getId(),areaTreeList))).collect(Collectors.toList());
return areaTreeList.stream().filter(a->parentId.equals(a.getParentId())).peek(e-> e.setChildren(getChildrenFromData(e.getId(),areaTreeList))).collect(Collectors.toList());
}
......
......@@ -50,7 +50,6 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
......@@ -124,7 +123,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
@Value("${auth-key-fire-building:fire_building_info}")
private String authKey;
@Value("$auth-key-fire-build-video:auth-key-fire-build-video}")
@Value("${auth-key-fire-build-video:fire_build_video_info}")
private String buildVideoAuthKey;
@Autowired
......@@ -379,7 +378,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
@Override
public List<BuildingTreeVo> getBuildingTree() {
List<BuildingTreeVo> allListVo = getBuildingTreeVos();
List<BuildingTreeVo> allListVo = getBuildingTreeVos(true);
return allListVo.stream().filter(s -> "-1".equals(s.getParentId())).map(s -> {
BuildingTreeVo t = new BuildingTreeVo();
Bean.copyExistPropertis(s, t);
......@@ -390,10 +389,10 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
}).collect(Collectors.toList());
}
private List<BuildingTreeVo> getBuildingTreeVos() {
private List<BuildingTreeVo> getBuildingTreeVos(Boolean isContainRootNode) {
FormGroup formGroup = iFormGroupService.getByUniqueKey(GroupCodeEnum.ALL_BUILDING.getGroupCode());
List<Map<String, Object>> allList = iFormInstanceService.getSpecialChildrenList(null);
List<BuildingTreeVo> allListVo = buildBuildingData(formGroup, allList);
List<BuildingTreeVo> allListVo = buildBuildingData(formGroup, allList, isContainRootNode);
Map<Long, String> absolutePositionMap = getBuildingAbsolutePosition(allListVo);
allListVo.forEach(s -> s.setAbsolutePosition(absolutePositionMap.get(s.getId())));
return allListVo;
......@@ -402,7 +401,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
@Override
public List<BuildingTreeVo> getBuildingTierTree(Integer tier) {
if (tier != null) {
List<BuildingTreeVo> list = getBuildingTreeVos();
List<BuildingTreeVo> list = getBuildingTreeVos(true);
if (!CollectionUtils.isEmpty(list)) {
if (tier == 1) {
List<BuildingTreeVo> collect = list.stream().filter(x -> "-1".equals(x.getParentId()) || "building".equalsIgnoreCase(x.getGroupType())).collect(Collectors.toList());
......@@ -436,8 +435,9 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
}
}
private List<BuildingTreeVo> buildBuildingData(FormGroup formGroup, List<Map<String, Object>> allList) {
private List<BuildingTreeVo> buildBuildingData(FormGroup formGroup, List<Map<String, Object>> allList, Boolean isContainRootNode) {
List<BuildingTreeVo> allListVo = Bean.listMap2ListBean(allList, BuildingTreeVo.class);
if (isContainRootNode) {
BuildingTreeVo treeNode = new BuildingTreeVo();
treeNode.setDetailPaneApi(address);
treeNode.setApiUrl(apiUrl);
......@@ -447,6 +447,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
treeNode.setGroupType(formGroup.getGroupType());
treeNode.setGroupCode(formGroup.getGroupCode());
allListVo.add(treeNode);
}
return allListVo;
}
......@@ -1009,7 +1010,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
public Map<Long, String> getBuildingAbsolutePosition() {
FormGroup formGroup = iFormGroupService.getByUniqueKey(GroupCodeEnum.ALL_BUILDING.getGroupCode());
List<Map<String, Object>> allList = iFormInstanceService.getSpecialChildrenList(null);
List<BuildingTreeVo> allListVo = buildBuildingData(formGroup, allList);
List<BuildingTreeVo> allListVo = buildBuildingData(formGroup, allList, true);
return getBuildingAbsolutePosition(allListVo);
}
......@@ -1106,14 +1107,21 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
@Override
public List<BuildingTreeVo> getCompanyBuildingTree(String authKey) {
//1.组装数据
List<BuildingTreeVo> companyBuildingList = buildBuildingAndCompanyListVos(authKey);
//2.list to tree
return companyBuildingList.stream().filter(a -> companyBuildingList.stream().noneMatch(c -> c.getId().toString().equals(a.getParentId()))).peek(b -> b.setChildren(getCompanyBuildingChildrenTree(b.getId().toString(), companyBuildingList))).collect(Collectors.toList());
}
private List<BuildingTreeVo> buildBuildingAndCompanyListVos(String authKey) {
if (StringUtils.isEmpty(authKey)) {
authKey = this.authKey;
}
List<BuildingTreeVo> allListVo = getBuildingTreeVos();
// 获取公司部门list
List<BuildingTreeVo> buildingTreeVos = getBuildingTreeVos(false);
// 1.获取公司list
List<OrgUsrDto> orgUsrLists = jcsRemoteService.getCompanyDeptListWithAuth(authKey, "COMPANY");
AtomicReference<Boolean> flag = new AtomicReference<>(false);
List<BuildingTreeVo> collect = orgUsrLists.stream().map(orgUsrDto -> {
// 2.数据结构转换
List<BuildingTreeVo> companyList = orgUsrLists.stream().map(orgUsrDto -> {
BuildingTreeVo vo = new BuildingTreeVo();
vo.setGroupType("allBuilding");
vo.setGroupCode("allBuilding");
......@@ -1124,59 +1132,41 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
vo.setName(orgUsrDto.getBizOrgName());
vo.setId(orgUsrDto.getSequenceNbr());
vo.setBizOrgName(orgUsrDto.getBizOrgName());
vo.setTotal(allListVo.stream().filter(b -> b.getBizOrgCode() != null && b.getBizOrgCode().contains(vo.getBizOrgCode()) && "building".equals(b.getGroupType())).count());
if ("".equals(orgUsrDto.getParentId()) || "-1".equals(orgUsrDto.getParentId()) || null == orgUsrDto.getParentId()) {
flag.set(true);
}
vo.setTotal(buildingTreeVos.stream().filter(b -> b.getBizOrgCode() != null && b.getBizOrgCode().contains(vo.getBizOrgCode()) && "building".equals(b.getGroupType())).count());
return vo;
}).collect(Collectors.toList());
allListVo.addAll(collect);
return allListVo.stream().filter(s -> flag.get() ? "allBuilding".equals(s.getGroupType()) && s.getBizOrgCode() != null && ("".equals(s.getParentId()) || "-1".equals(s.getParentId()) || null == s.getParentId())
: "allBuilding".equals(s.getGroupType()) && s.getBizOrgCode() != null)
.peek(m -> m.setChildren(this.getCompanyBuildingChildrenTree(m, allListVo)))
.collect(Collectors.toList());
// 3.将建筑的bizOrgCode转换为parentId连接树 ,拼接数据准备
Map<String, Long> comMap = companyList.stream().collect(Collectors.toMap(BuildingTreeVo::getBizOrgCode, BuildingTreeVo::getId));
buildingTreeVos.forEach(b -> {
b.setParentId("0".equals(b.getParentId()) ? String.valueOf(comMap.get(b.getBizOrgCode())) : b.getParentId());
b.setDetailPaneApi(address);
b.setApiUrl(apiUrl);
});
// 4.组装树
companyList.addAll(buildingTreeVos);
return companyList;
}
@Override
public List<BuildingTreeVo> getBuildingVideoTreeNew() {
List<BuildingTreeVo> allListVo = getBuildingTreeVos();
// 获取公司部门list
List<OrgUsrDto> orgUsrLists = jcsRemoteService.getCompanyDeptListWithAuth(buildVideoAuthKey, "COMPANY");
//1.组装数据
List<BuildingTreeVo> companyBuildingList = buildBuildingAndCompanyListVos(buildVideoAuthKey);
List<Map<String, Long>> countList = iFormInstanceService.getBuildVideoCount();
Map<Long, Long> map = countList.stream().collect(Collectors.toMap(p -> p.get("buildId"), p -> p.get("total")));
AtomicReference<Boolean> flag = new AtomicReference<>(false);
List<BuildingTreeVo> collect = 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 ("".equals(orgUsrDto.getParentId()) || "-1".equals(orgUsrDto.getParentId()) || null == orgUsrDto.getParentId()) {
flag.set(true);
}
return vo;
Map<Long, Long> countMap = countList.stream().collect(Collectors.toMap(p -> p.get("buildId"), p -> p.get("total")));
//2.list to tree
return companyBuildingList.stream()
.filter(a -> companyBuildingList.stream().noneMatch(c -> c.getId().toString().equals(a.getParentId())))
.peek(b -> {
b.setChildren(getCompanyBuildingChildrenWithCount(b.getId().toString(), companyBuildingList));
b.setTotal(b.getChildren().stream().filter(c->c.getTotal() != null).mapToLong(BuildingTreeVo::getTotal).sum());
}).collect(Collectors.toList());
allListVo.addAll(collect);
return allListVo.stream().filter(s -> flag.get() ? "allBuilding".equals(s.getGroupType()) && s.getBizOrgCode() != null && ("".equals(s.getParentId()) || "-1".equals(s.getParentId()) || null == s.getParentId())
: "allBuilding".equals(s.getGroupType()) && s.getBizOrgCode() != null)
.peek(m -> {
List<BuildingTreeVo> treeVos = this.getCompanyBuildingChildrenTreeNew(m, allListVo, map);
m.setChildren(treeVos);
Long total = 0L;
for (BuildingTreeVo vo : treeVos) {
Long aLong = vo.getTotal();
total += aLong == null ? 0 : aLong;
}
m.setTotal(total);
})
.collect(Collectors.toList());
private List<BuildingTreeVo> getCompanyBuildingChildrenWithCount(String parentId, List<BuildingTreeVo> companyBuildingList) {
return companyBuildingList.stream().filter(a -> parentId.equals(a.getParentId())).peek(a -> {
a.setChildren(getCompanyBuildingChildrenWithCount(a.getId().toString(), companyBuildingList));
a.setTotal(a.getChildren().stream().filter(c->c.getTotal() != null).mapToLong(BuildingTreeVo::getTotal).sum());
}).collect(Collectors.toList());
}
@Override
......@@ -1190,7 +1180,8 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
String videoPointInScene = sourceScene.getVideoInScene() != null ? sourceScene.getVideoInScene() : "";
//1.查询楼层下的所有装备list
List<EquiplistSpecificBySystemVO> equipmentSpecifics = equipmentSpecificMapper.getListByWarehouseStructureId(floorId);
equipmentSpecifics.forEach(e->{
equipmentSpecifics.forEach(e -> {
//已经标记则为已绑定
e.setIsBound(equipPointInScene.contains(e.getId().toString()));
e.setType("装备点");
});
......@@ -1198,92 +1189,23 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
//2.查询楼层下的所有视频list
List<Video> videos = videoMapper.selectListBySourceId(floorId);
//3.数据加工
videos.forEach(v->{
videos.forEach(v -> {
EquiplistSpecificBySystemVO vo = new EquiplistSpecificBySystemVO();
vo.setId(v.getId());
vo.setCode(v.getCode());
vo.setCategoryName(v.getType());
vo.setEquipmentName(v.getName());
vo.setType("视频点");
//已经标记则为已绑定
vo.setIsBound(videoPointInScene.contains(v.getId().toString()));
bySystemVOS.add(vo);
});
return bySystemVOS;
}
// @Override
// public List<BuildingTreeVo> getBuildingVideoTreeNew() {
// List<BuildingTreeVo> list = getCompanyBuildingTree(buildVideoAuthKey);
// if (!CollectionUtils.isEmpty(list)) {
// List<Map<String, Long>> countList = iFormInstanceService.getBuildVideoCount();
// if (!CollectionUtils.isEmpty(countList)) {
// Map<Long, Long> map = countList.stream().collect(Collectors.toMap(p->p.get("buildId"), p->p.get("total")));
// for (BuildingTreeVo treeVo : list) {
// List<BuildingTreeVo> children = treeVo.getChildren();
// if (!CollectionUtils.isEmpty(children)) {
// List<BuildingTreeVo> treeVoList = getBuildingVideoTotal(children, map);
// treeVo.setChildren(treeVoList);
// }
// treeVo.setTotal(map.get(treeVo.getInstanceId()));
// }
// }
// return list;
// }
// return Lists.newArrayList();
// }
//
// public List<BuildingTreeVo> getBuildingVideoTotal(List<BuildingTreeVo> children, Map<Long, Long> map) {
// for (BuildingTreeVo treeVo : children) {
// List<BuildingTreeVo> childrenList = treeVo.getChildren();
// if (!CollectionUtils.isEmpty(childrenList)) {
// getBuildingVideoTotal (childrenList, map);
// }
// treeVo.setTotal(map.get(treeVo.getInstanceId()));
// }
// return children;
// }
private List<BuildingTreeVo> getCompanyBuildingChildrenTree(BuildingTreeVo root, List<BuildingTreeVo> all) {
return all.stream().filter(b ->
(root.getId() != null && StringUtil.isNotEmpty(b.getParentId()) && b.getParentId().equals(root.getId().toString())) ||
("allBuilding".equals(root.getGroupType())
&& "building".equals(b.getGroupType())
&& StringUtil.isNotEmpty(root.getBizOrgCode())
&& root.getBizOrgCode().equals(b.getBizOrgCode())
&& !b.getId().equals(root.getId())))
.peek(m -> {
m.setChildren(getCompanyBuildingChildrenTree(m, all));
m.setDetailPaneApi(address);
m.setApiUrl(apiUrl);
})
.collect(Collectors.toList());
}
private List<BuildingTreeVo> getCompanyBuildingChildrenTreeNew(BuildingTreeVo root, List<BuildingTreeVo> all, Map<Long, Long> map) {
return all.stream().filter(b ->
(root.getId() != null && StringUtil.isNotEmpty(b.getParentId()) && b.getParentId().equals(root.getId().toString())) ||
("allBuilding".equals(root.getGroupType())
&& "building".equals(b.getGroupType())
&& StringUtil.isNotEmpty(root.getBizOrgCode())
&& root.getBizOrgCode().equals(b.getBizOrgCode())
&& !b.getId().equals(root.getId())))
.peek(m -> {
List<BuildingTreeVo> treeVos = getCompanyBuildingChildrenTreeNew(m, all, map);
m.setChildren(treeVos);
Long aLong1 = map.get(m.getInstanceId());
if (aLong1 == null) {
Long total = 0L;
for (BuildingTreeVo vo : treeVos) {
Long aLong = vo.getTotal();
total += aLong == null ? 0 : aLong;
}
m.setTotal(total);
} else {
m.setTotal(map.get(m.getInstanceId()));
}
m.setDetailPaneApi(address);
m.setApiUrl(apiUrl);
})
.collect(Collectors.toList());
private List<BuildingTreeVo> getCompanyBuildingChildrenTree(String parentId, List<BuildingTreeVo> all) {
return all.stream().filter(a -> parentId.equals(a.getParentId())).peek(a -> {
a.setChildren(getCompanyBuildingChildrenTree(a.getId().toString(), all));
}).collect(Collectors.toList());
}
}
......@@ -502,7 +502,7 @@ WHERE
COUNT( vs.video_id ) AS total
FROM
get_building_tree b
LEFT JOIN wl_video_source vs ON FIND_IN_SET( vs.source_id, getBuildChildIdsByRootId ( b.instanceId ) )
LEFT JOIN wl_video_source vs ON FIND_IN_SET( b.instanceId, vs.parent_source_ids )
GROUP BY
b.instanceId
</select>
......
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