Commit 8ec2deca authored by 高建强's avatar 高建强

item:解决单位建筑视频树统计单位无数据问题

parent b79105e9
...@@ -640,7 +640,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i ...@@ -640,7 +640,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
*/ */
@Override @Override
public Long equipmentTotal(Long instanceId, String groupType) { public Long equipmentTotal(Long instanceId, String groupType) {
Map<String, Object> map = getEveryCount(instanceId, groupType,null); Map<String, Object> map = getEveryCount(instanceId, groupType, null);
return Long.parseLong(String.valueOf(map.get("equipCount"))); return Long.parseLong(String.valueOf(map.get("equipCount")));
} }
...@@ -1130,7 +1130,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i ...@@ -1130,7 +1130,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
} }
List<BuildingTreeVo> allListVo = getBuildingTreeVos(); List<BuildingTreeVo> allListVo = getBuildingTreeVos();
// 获取公司部门list // 获取公司部门list
List<OrgUsrDto> orgUsrLists = jcsRemoteService.getCompanyDeptListWithAuth(authKey,"COMPANY"); List<OrgUsrDto> orgUsrLists = jcsRemoteService.getCompanyDeptListWithAuth(authKey, "COMPANY");
AtomicReference<Boolean> flag = new AtomicReference<>(false); AtomicReference<Boolean> flag = new AtomicReference<>(false);
List<BuildingTreeVo> collect = orgUsrLists.stream().map(orgUsrDto -> { List<BuildingTreeVo> collect = orgUsrLists.stream().map(orgUsrDto -> {
BuildingTreeVo vo = new BuildingTreeVo(); BuildingTreeVo vo = new BuildingTreeVo();
...@@ -1158,37 +1158,94 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i ...@@ -1158,37 +1158,94 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
@Override @Override
public List<BuildingTreeVo> getBuildingVideoTreeNew() { public List<BuildingTreeVo> getBuildingVideoTreeNew() {
List<BuildingTreeVo> list = getCompanyBuildingTree(buildVideoAuthKey); List<BuildingTreeVo> allListVo = getBuildingTreeVos();
if (!CollectionUtils.isEmpty(list)) { // 获取公司部门list
List<OrgUsrDto> orgUsrLists = jcsRemoteService.getCompanyDeptListWithAuth(buildVideoAuthKey, "COMPANY");
List<Map<String, Long>> countList = iFormInstanceService.getBuildVideoCount(); 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")));
Map<Long, Long> map = countList.stream().collect(Collectors.toMap(p->p.get("buildId"), p->p.get("total"))); AtomicReference<Boolean> flag = new AtomicReference<>(false);
for (BuildingTreeVo treeVo : list) { List<BuildingTreeVo> collect = orgUsrLists.stream().map(orgUsrDto -> {
List<BuildingTreeVo> children = treeVo.getChildren(); BuildingTreeVo vo = new BuildingTreeVo();
if (!CollectionUtils.isEmpty(children)) { vo.setGroupType("allBuilding");
List<BuildingTreeVo> treeVoList = getBuildingVideoTotal(children, map); vo.setGroupCode("allBuilding");
treeVo.setChildren(treeVoList); vo.setInstanceName(orgUsrDto.getBizOrgName());
} vo.setBizOrgCode(orgUsrDto.getBizOrgCode());
treeVo.setTotal(map.get(treeVo.getInstanceId())); vo.setInstanceId(orgUsrDto.getSequenceNbr());
} vo.setParentId(orgUsrDto.getParentId());
} vo.setName(orgUsrDto.getBizOrgName());
return list; vo.setId(orgUsrDto.getSequenceNbr());
} vo.setBizOrgName(orgUsrDto.getBizOrgName());
return Lists.newArrayList(); if ("".equals(orgUsrDto.getParentId()) || "-1".equals(orgUsrDto.getParentId()) || null == orgUsrDto.getParentId()) {
flag.set(true);
} }
return vo;
}).collect(Collectors.toList());
public List<BuildingTreeVo> getBuildingVideoTotal(List<BuildingTreeVo> children, Map<Long, Long> map) { allListVo.addAll(collect);
for (BuildingTreeVo treeVo : children) { return allListVo.stream().filter(s -> flag.get() ? "allBuilding".equals(s.getGroupType()) && s.getBizOrgCode() != null && ("".equals(s.getParentId()) || "-1".equals(s.getParentId()) || null == s.getParentId())
List<BuildingTreeVo> childrenList = treeVo.getChildren(); : "allBuilding".equals(s.getGroupType()) && s.getBizOrgCode() != null)
if (!CollectionUtils.isEmpty(childrenList)) { .peek(m -> {
getBuildingVideoTotal (childrenList, map); List<BuildingTreeVo> treeVos = this.getCompanyBuildingChildrenTreeNew(m, allListVo, map);
} m.setChildren(treeVos);
treeVo.setTotal(map.get(treeVo.getInstanceId())); Long total = 0L;
for (BuildingTreeVo vo : treeVos) {
Long aLong = vo.getTotal();
total += aLong == null ? 0 : aLong;
}
m.setTotal(total);
})
.collect(Collectors.toList());
} }
return children;
// @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> getCompanyBuildingChildrenTree(BuildingTreeVo root , List<BuildingTreeVo> all) { private List<BuildingTreeVo> getCompanyBuildingChildrenTreeNew(BuildingTreeVo root, List<BuildingTreeVo> all, Map<Long, Long> map) {
return all.stream().filter(b -> return all.stream().filter(b ->
(root.getId() != null && StringUtil.isNotEmpty(b.getParentId()) && b.getParentId().equals(root.getId().toString())) || (root.getId() != null && StringUtil.isNotEmpty(b.getParentId()) && b.getParentId().equals(root.getId().toString())) ||
("allBuilding".equals(root.getGroupType()) ("allBuilding".equals(root.getGroupType())
...@@ -1196,9 +1253,23 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i ...@@ -1196,9 +1253,23 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
&& StringUtil.isNotEmpty(root.getBizOrgCode()) && StringUtil.isNotEmpty(root.getBizOrgCode())
&& root.getBizOrgCode().equals(b.getBizOrgCode()) && root.getBizOrgCode().equals(b.getBizOrgCode())
&& !b.getId().equals(root.getId()))) && !b.getId().equals(root.getId())))
.peek(m -> {m.setChildren(getCompanyBuildingChildrenTree(m, all)); .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.setDetailPaneApi(address);
m.setApiUrl(apiUrl);}) m.setApiUrl(apiUrl);
})
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
} }
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