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

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

parent b79105e9
......@@ -640,7 +640,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
*/
@Override
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")));
}
......@@ -1130,7 +1130,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
}
List<BuildingTreeVo> allListVo = getBuildingTreeVos();
// 获取公司部门list
List<OrgUsrDto> orgUsrLists = jcsRemoteService.getCompanyDeptListWithAuth(authKey,"COMPANY");
List<OrgUsrDto> orgUsrLists = jcsRemoteService.getCompanyDeptListWithAuth(authKey, "COMPANY");
AtomicReference<Boolean> flag = new AtomicReference<>(false);
List<BuildingTreeVo> collect = orgUsrLists.stream().map(orgUsrDto -> {
BuildingTreeVo vo = new BuildingTreeVo();
......@@ -1151,54 +1151,125 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
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)
: "allBuilding".equals(s.getGroupType()) && s.getBizOrgCode() != null)
.peek(m -> m.setChildren(this.getCompanyBuildingChildrenTree(m, allListVo)))
.collect(Collectors.toList());
}
@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()));
}
List<BuildingTreeVo> allListVo = getBuildingTreeVos();
// 获取公司部门list
List<OrgUsrDto> orgUsrLists = jcsRemoteService.getCompanyDeptListWithAuth(buildVideoAuthKey, "COMPANY");
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 list;
}
return Lists.newArrayList();
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 -> {
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());
}
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;
// @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) {
return all.stream().filter(b ->
(root.getId() != null && StringUtil.isNotEmpty(b.getParentId()) && b.getParentId().equals(root.getId().toString())) ||
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 -> {m.setChildren(getCompanyBuildingChildrenTree(m, all));
m.setDetailPaneApi(address);
m.setApiUrl(apiUrl);})
.collect(Collectors.toList());
&& "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());
}
}
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