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();
...@@ -1151,54 +1151,125 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i ...@@ -1151,54 +1151,125 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
allListVo.addAll(collect); 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()) 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))) .peek(m -> m.setChildren(this.getCompanyBuildingChildrenTree(m, allListVo)))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@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<Map<String, Long>> countList = iFormInstanceService.getBuildVideoCount(); List<OrgUsrDto> orgUsrLists = jcsRemoteService.getCompanyDeptListWithAuth(buildVideoAuthKey, "COMPANY");
if (!CollectionUtils.isEmpty(countList)) { List<Map<String, Long>> countList = iFormInstanceService.getBuildVideoCount();
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")));
for (BuildingTreeVo treeVo : list) { AtomicReference<Boolean> flag = new AtomicReference<>(false);
List<BuildingTreeVo> children = treeVo.getChildren(); List<BuildingTreeVo> collect = orgUsrLists.stream().map(orgUsrDto -> {
if (!CollectionUtils.isEmpty(children)) { BuildingTreeVo vo = new BuildingTreeVo();
List<BuildingTreeVo> treeVoList = getBuildingVideoTotal(children, map); vo.setGroupType("allBuilding");
treeVo.setChildren(treeVoList); vo.setGroupCode("allBuilding");
} vo.setInstanceName(orgUsrDto.getBizOrgName());
treeVo.setTotal(map.get(treeVo.getInstanceId())); 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 vo;
} }).collect(Collectors.toList());
return Lists.newArrayList();
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) { // @Override
for (BuildingTreeVo treeVo : children) { // public List<BuildingTreeVo> getBuildingVideoTreeNew() {
List<BuildingTreeVo> childrenList = treeVo.getChildren(); // List<BuildingTreeVo> list = getCompanyBuildingTree(buildVideoAuthKey);
if (!CollectionUtils.isEmpty(childrenList)) { // if (!CollectionUtils.isEmpty(list)) {
getBuildingVideoTotal (childrenList, map); // List<Map<String, Long>> countList = iFormInstanceService.getBuildVideoCount();
} // if (!CollectionUtils.isEmpty(countList)) {
treeVo.setTotal(map.get(treeVo.getInstanceId())); // Map<Long, Long> map = countList.stream().collect(Collectors.toMap(p->p.get("buildId"), p->p.get("total")));
} // for (BuildingTreeVo treeVo : list) {
return children; // 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())
&& "building".equals(b.getGroupType()) && "building".equals(b.getGroupType())
&& 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 -> {
m.setDetailPaneApi(address); List<BuildingTreeVo> treeVos = getCompanyBuildingChildrenTreeNew(m, all, map);
m.setApiUrl(apiUrl);}) m.setChildren(treeVos);
.collect(Collectors.toList()); 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