Commit 6ede7950 authored by chenhao's avatar chenhao

重点部位建筑类型树修改

parent 64277d6b
......@@ -404,37 +404,46 @@ public class KeySiteServiceImpl extends BaseService<KeySiteDto, KeySite, KeySite
@SuppressWarnings("unchecked")
@Override
public List<Map<String, Object>> keySiteCountAndBuildingTree(String bizOrgCode) {
int allCount=0;
Map<String, Integer> keySiteCountMap = parseKeySiteCount(bizOrgCode);
ResponseModel<Object> response = equipFeignClient.getBuildingTree();
List<Map<String, Object>> buildingMapList = (List<Map<String, Object>>) response.getResult();
if(buildingMapList==null || buildingMapList.size()<1) {
return null;
}
return parseTree((List<Map<String, Object>>)buildingMapList.get(0).get("children"),keySiteCountMap);
Map<String, Object> reMap = parseTree((List<Map<String, Object>>)buildingMapList.get(0).get("children"),keySiteCountMap,allCount);
Map<String, Object> fristMap= buildingMapList.get(0);
fristMap.put("name", fristMap.get("instanceName")+" ("+reMap.get("allCount")+")");
fristMap.put("children", fristMap.get("children"));
buildingMapList.clear();
buildingMapList.add(fristMap);
return buildingMapList;
}
@SuppressWarnings("unchecked")
private List<Map<String, Object>> parseTree(List<Map<String, Object>> children,
Map<String, Integer> keySiteCountMap) {
private Map<String, Object> parseTree(List<Map<String, Object>> children,
Map<String, Integer> keySiteCountMap,int allCount) {
Map<String, Object> resultMap= new HashMap<String, Object>();
if (!ValidationUtil.isEmpty(children)) {
for (Map<String, Object> child : children) {
if (child.get("id") != null) {
if (keySiteCountMap.containsKey(child.get("id").toString())) {
child.put("count",keySiteCountMap.get(child.get("id").toString()));
allCount = allCount + keySiteCountMap.get(child.get("id").toString()).intValue();
child.put("name",child.get("name") +" ("+keySiteCountMap.get(child.get("id").toString())+")");
}else {
child.put("count",0);
child.put("name",child.get("name") +" ("+0+")");
}
}else {
child.put("count",0);
child.put("name",child.get("name") +" ("+0+")");
}
if (!ValidationUtil.isEmpty(child.get("children"))) {
parseTree((List<Map<String, Object>>) child.get("children"), keySiteCountMap);
parseTree((List<Map<String, Object>>) child.get("children"), keySiteCountMap,allCount);
}
}
}
return children;
resultMap.put("children", children);
resultMap.put("allCount", allCount);
return resultMap;
}
private Map<String, Integer> parseKeySiteCount(String bizOrgCode) {
......
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