diff --git a/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java b/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java index 22765634..ac89202f 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java +++ b/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java @@ -342,40 +342,36 @@ public class CensusControllerV2 { List> dbAmount = (List>) map.get("total"); return dbAmount.stream().filter(index -> "基础设施".equals(index.get("type").toString())) .mapToLong(index -> Long.parseLong(index.get("count").toString())).sum(); - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "视频资源数量"); - } - }); - }); + }).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "视频资源数量"); + } + })); } break; case BAOTOU: { // 包头 allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 return jdbcTemplate.queryForObject("SELECT COUNT(id) FROM tb_data_resource WHERE type = '基础设施' AND del_flag = 0", Long.class); - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "视频资源数量"); - } - }); - }); + }).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "视频资源数量"); + } + })); } break; case TSINGTAO_XHA: { // 青岛西海岸 allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 List result_ = new CopyOnWriteArrayList<>(); - String url = String.format(tsingtao_xhaProperties.getCloudcam(), "", 1, 10); + String url = tsingtao_xhaProperties.getCamCount(); logger.info(url); Request request = new Request.Builder().url(url).build(); try (Response response = client.newCall(request).execute()) { if (response.isSuccessful()) { JSONObject jsonObject = JSON.parseObject(response.body().string()); - if (jsonObject.containsKey("data")) { - result_.add(jsonObject.getJSONObject("data").getLongValue("total")); + if (jsonObject.containsKey("errorNo") && jsonObject.getLongValue("errorNo") == 200) { + result_.add(jsonObject.getLongValue("body")); } } else { logger.error("青岛西海岸获取失败"); @@ -383,15 +379,13 @@ public class CensusControllerV2 { } catch (Exception exception) { logger.error("青岛西海岸失败", exception); } - return result_.stream().filter(index -> index != null).findAny().orElse(0l); - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "视频资源数量"); - } - }); - }); + return result_.stream().filter(Objects::nonNull).findAny().orElse(0L); + }).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "视频资源数量"); + } + })); } break; } @@ -461,19 +455,17 @@ public class CensusControllerV2 { { List lists = (dataResource != null && dataResource.containsKey("data") && dataResource.get("data") != null) ? (List) dataResource.get("data") : new ArrayList<>(); ArrayList list = new ArrayList<>(); - lists.forEach(item -> { - list.add(new HashMap() {{ - put("服务名称", item.get("zyname")); - put("申请次数", item.get("syqk")); - }}); - }); + lists.forEach(item -> list.add(new HashMap() {{ + put("服务名称", item.get("zyname")); + put("申请次数", item.get("syqk")); + }})); put("resourceTop5", list); } }); } break; case TSINGTAO_XHA: { // 青岛西海岸 - Long total = 0L; + Long total; Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourcecount()).build(); try (Response response = client.newCall(request).execute()) { if (response.isSuccessful()) { diff --git a/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java index deaf2a61..157cba73 100644 --- a/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java +++ b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java @@ -1,6 +1,5 @@ package io.renren.common.domain; - import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.PropertySource; @@ -21,4 +20,5 @@ public class Tsingtao_xhaProperties { private String resourcecount; private String resourceapplyinfo; private String sjzy; + private String camCount; } diff --git a/renren-admin/src/main/java/io/renren/modules/monitor/mapper/CameraOrgenizationMapper.java b/renren-admin/src/main/java/io/renren/modules/monitor/mapper/CameraOrgenizationMapper.java index 32ecc0d6..9197e9a1 100644 --- a/renren-admin/src/main/java/io/renren/modules/monitor/mapper/CameraOrgenizationMapper.java +++ b/renren-admin/src/main/java/io/renren/modules/monitor/mapper/CameraOrgenizationMapper.java @@ -1,6 +1,5 @@ package io.renren.modules.monitor.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import io.renren.common.dao.BaseDao; import io.renren.modules.monitor.entity.CameraOrganization; import org.apache.ibatis.annotations.Mapper; diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index 3accaf62..51b4b34d 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -538,7 +538,7 @@ public class ResourceServiceImpl extends CrudServiceImpl result = new CopyOnWriteArrayList<>(); CompletableFuture cloud = CompletableFuture.runAsync(() -> { // 云脑专网 - String url = tsingtao_xhaProperties.getCloudcam(); + String url = tsingtao_xhaProperties.getCamCount(); logger.info(url); Request request = new Request.Builder().url(url).build(); try (Response response = client.newCall(request).execute()) { @@ -1874,35 +1874,75 @@ public class ResourceServiceImpl extends CrudServiceImpl selectDevelopDoc() { + //List result = new ArrayList<>(); + //List> dtoMaps = baseDao.selectDevelopDocResource(); + //Map>> resourceTypeMap = dtoMaps.stream().collect(Collectors.groupingBy(m -> m.get("type").toString())); + //resourceTypeMap.forEach((key, value) -> { + // if (!"组件服务".equals(key)) { + // Map map = new HashMap<>(); + // map.put("title", key); + // map.put("children", value); + // result.add(map); + // } + //}); + //if (resourceTypeMap.get("组件服务") != null) { + // Map componentMap = new HashMap(); + // componentMap.put("title", "组件服务"); + // Map map = new ConcurrentHashMap<>(); + // CompletableFuture.allOf(resourceTypeMap.get("组件服务").stream() + // .map(it -> CompletableFuture.runAsync(() -> selectAttrsByResourceId(Long.parseLong(it.get("id").toString())) + // .stream() + // .filter(temp -> "组件类型".equals(temp.getAttrType())) + // .forEach(attr -> { + // if (map.get(attr.getAttrValue()) != null) { + // map.get(attr.getAttrValue()).add(it); + // } else { + // map.put(attr.getAttrValue(), Collections.synchronizedList(new ArrayList() {{ + // add(it); + // }})); + // } + // }), executor)) + // .collect(Collectors.toList()) + // .toArray(new CompletableFuture[resourceTypeMap.get("组件服务").size()])) + // .join(); + // componentMap.put("children", map.entrySet().stream().map(it -> new HashMap() {{ + // put("title", it.getKey()); + // put("children", it.getValue()); + // }}).collect(Collectors.toList())); + // result.add(componentMap); + //} + //return result; List result = new ArrayList<>(); List> dtoMaps = baseDao.selectDevelopDocResource(); Map>> resourceTypeMap = dtoMaps.stream().collect(Collectors.groupingBy(m -> m.get("type").toString())); - resourceTypeMap.forEach((key, value) -> { - if (!"组件服务".equals(key)) { - Map map = new HashMap<>(); - map.put("title", key); - map.put("children", value); + resourceTypeMap.entrySet().stream().forEach(temp -> { + if (!"组件服务".equals(temp.getKey())) { + Map map = new HashMap(); + map.put("title", temp.getKey()); + map.put("children", temp.getValue()); result.add(map); } }); if (resourceTypeMap.get("组件服务") != null) { - Map componentMap = new HashMap<>(); + Map componentMap = new HashMap(); componentMap.put("title", "组件服务"); Map map = new ConcurrentHashMap<>(); - CompletableFuture[] completableFutures = resourceTypeMap.get("组件服务").stream().map(it -> CompletableFuture.runAsync(() -> selectAttrsByResourceId(Long.parseLong(it.get("id").toString())).stream() - .filter(temp -> "组件类型".equals(temp.getAttrType())).forEach(attr -> { + List tasks = resourceTypeMap.get("组件服务").stream().map(it -> { + CompletableFuture task = CompletableFuture.runAsync(() -> { + selectAttrsByResourceId(Long.parseLong(it.get("id").toString())).stream().filter(temp -> "组件类型".equals(temp.getAttrType())).forEach(attr -> { if (map.get(attr.getAttrValue()) != null) { map.get(attr.getAttrValue()).add(it); } else { - map.put(attr.getAttrValue(), Collections.synchronizedList(new ArrayList() {{ + map.put(attr.getAttrValue(), (List) Collections.synchronizedList(new ArrayList() {{ add(it); }})); } - }), executor)) - .collect(Collectors.toList()) - .toArray(new CompletableFuture[resourceTypeMap.get("组件服务").size()]); - CompletableFuture.allOf(completableFutures).join(); - componentMap.put("children", map.entrySet().stream().map(it -> new HashMap() {{ + }); + }, executor); + return task; + }).collect(Collectors.toList()); + CompletableFuture.allOf(tasks.toArray(new CompletableFuture[tasks.size()])).join(); + componentMap.put("children", map.entrySet().stream().map(it -> new HashMap() {{ put("title", it.getKey()); put("children", it.getValue()); }}).collect(Collectors.toList())); @@ -1910,6 +1950,7 @@ public class ResourceServiceImpl extends CrudServiceImpl