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 693293ce..e4d545f7 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 @@ -314,6 +314,7 @@ public class CensusControllerV2 { List> result = new CopyOnWriteArrayList<>(); CompletableFuture allAmount = null; switch (Constant.ProjectPlace.getByFlag(projectPlace)) { + case TSINGTAO: // 青岛市局 case BAOTOU: { // 包头 allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 return jdbcTemplate.queryForObject("SELECT COUNT(id) FROM tb_data_resource WHERE type = '基础设施' AND del_flag = 0", Long.class); @@ -327,26 +328,15 @@ public class CensusControllerV2 { }); } break; - case TSINGTAO: { // 青岛大数据局 - allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 - return jdbcTemplate.queryForObject("SELECT COUNT(*) FROM t_camera;", Long.class); - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "视频资源数量"); - } - }); - }); - } - break; case TSINGTAO_XHA: { // 青岛西海岸 allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 List result_ = new CopyOnWriteArrayList<>(); CompletableFuture cloud = CompletableFuture.runAsync(() -> { // 云脑专网 OkHttpClient client = new OkHttpClient(); - Request request = new Request.Builder().url(tsingtao_xhaProperties.getCloudcam()).build(); + String url = String.format(tsingtao_xhaProperties.getCloudcam(), "", 1, 10); + 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()); @@ -363,7 +353,9 @@ public class CensusControllerV2 { CompletableFuture local = CompletableFuture.runAsync(() -> { // 金宏网 OkHttpClient client = new OkHttpClient(); - Request request = new Request.Builder().url(tsingtao_xhaProperties.getLocalcam()).build(); + String url = String.format(tsingtao_xhaProperties.getLocalcam(), "", 1, 10); + 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()); 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 268cf96e..d1bbb8c9 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 @@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.renren.common.constant.Constant; +import io.renren.common.domain.Tsingtao_xhaProperties; import io.renren.common.service.impl.CrudServiceImpl; import io.renren.modules.resource.dao.AttrDao; import io.renren.modules.resource.dao.ResourceDao; @@ -113,6 +115,9 @@ public class ResourceServiceImpl extends CrudServiceImpl getWrapper(Map params) { QueryWrapper wrapper = new QueryWrapper<>(); @@ -221,24 +226,111 @@ public class ResourceServiceImpl extends CrudServiceImpl resultPage = new Page<>(pageNum, pageSize); - if (resourceDTO.getInfoList().isEmpty()) { - List resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType); - resultPage.setRecords(resourceDTOS); - resultPage.setTotal(resourceDao.selectDTOPage(resourceDTO, 0, 100000, orderField, orderType).size()); - } else { - List resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType); - int j = Math.min(pageNum * pageSize, resourceDTOS.size()); - if (resourceDTOS.isEmpty()) { - resultPage.setRecords(null); - resultPage.setTotal(0); - } else { - ArrayList recordLists = new ArrayList<>(); - for (int i = (pageNum - 1) * pageSize; i < j; i++) { - recordLists.add(resourceDTOS.get(i)); + switch (Constant.ProjectPlace.getByFlag(projectPlace)) { + case TSINGTAO: + case BAOTOU: { // 包头、青岛西海岸 + if (resourceDTO.getInfoList().isEmpty()) { + List resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType); + resultPage.setRecords(resourceDTOS); + resultPage.setTotal(resourceDao.selectDTOPage(resourceDTO, 0, 100000, orderField, orderType).size()); + } else { + List resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType); + int j = Math.min(pageNum * pageSize, resourceDTOS.size()); + if (resourceDTOS.isEmpty()) { + resultPage.setRecords(null); + resultPage.setTotal(0); + } else { + ArrayList recordLists = new ArrayList<>(); + for (int i = (pageNum - 1) * pageSize; i < j; i++) { + recordLists.add(resourceDTOS.get(i)); + } + resultPage.setRecords(recordLists); + resultPage.setTotal(resourceDTOS.size()); + } } - resultPage.setRecords(recordLists); - resultPage.setTotal(resourceDTOS.size()); } + break; + case TSINGTAO_XHA: { + if ("基础设施".equals(resourceDTO.getType())) { // 基础设施 + List result_ = new CopyOnWriteArrayList<>(); + CompletableFuture cloud = + CompletableFuture.runAsync(() -> { // 云脑专网 + OkHttpClient client = new OkHttpClient(); + String url = String.format(tsingtao_xhaProperties.getCloudcam(), resourceDTO.getName(), pageNum, pageSize); + 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")) { + if (jsonObject_.getJSONObject("data").containsKey("list")) { + resultPage.setTotal(jsonObject_.getJSONObject("data").getLongValue("total")); + resultPage.setRecords(jsonObject_.getJSONObject("data").getJSONArray("list").stream().map(index -> (JSONObject) JSON.toJSON(index)) + .map(index -> { + ResourceDTO resourceDTO1 = new ResourceDTO(); + resourceDTO1.setId(Long.valueOf(index.getString("id"))); + resourceDTO1.setDelFlag(0); + resourceDTO1.setLink(index.getString("id")); + resourceDTO1.setName(index.getString("name")); + return resourceDTO1; + }).collect(Collectors.toList())); + } else { + resultPage.setRecords(null); + resultPage.setTotal(0); + } + + } + } else { + logger.error("包头获取失败"); + } + } catch (Exception exception) { + logger.error("包头失败", exception); + } + }); + CompletableFuture local = + CompletableFuture.runAsync(() -> { // 金宏网 + OkHttpClient client = new OkHttpClient(); + String url = String.format(tsingtao_xhaProperties.getLocalcam(), resourceDTO.getName(), pageNum, pageSize); + 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")); + } + } else { + logger.error("包头获取失败"); + } + } catch (Exception exception) { + logger.error("包头失败", exception); + } + }); + CompletableFuture.allOf(cloud, local); + + } else { + if (resourceDTO.getInfoList().isEmpty()) { + List resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType); + resultPage.setRecords(resourceDTOS); + resultPage.setTotal(resourceDao.selectDTOPage(resourceDTO, 0, 100000, orderField, orderType).size()); + } else { + List resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType); + int j = Math.min(pageNum * pageSize, resourceDTOS.size()); + if (resourceDTOS.isEmpty()) { + resultPage.setRecords(null); + resultPage.setTotal(0); + } else { + ArrayList recordLists = new ArrayList<>(); + for (int i = (pageNum - 1) * pageSize; i < j; i++) { + recordLists.add(resourceDTOS.get(i)); + } + resultPage.setRecords(recordLists); + resultPage.setTotal(resourceDTOS.size()); + } + } + } + } + break; } return resultPage; } diff --git a/renren-admin/src/main/resources/domain/tsingtao-xha.properties b/renren-admin/src/main/resources/domain/tsingtao-xha.properties index 969361b4..8478ffc6 100644 --- a/renren-admin/src/main/resources/domain/tsingtao-xha.properties +++ b/renren-admin/src/main/resources/domain/tsingtao-xha.properties @@ -1,6 +1,6 @@ tsingtao-xha.cloudhls=http://10.10.30.9:8001/hx-weatherwarning/camera/getCameraLiveStreamByCode?cameraCode=%s&protocol=hls tsingtao-xha.localhls=http://10.134.135.9:8001/hx-weatherwarning/camera/getCameraLiveStreamByCode?cameraCode=%s&protocol=hls -tsingtao-xha.cloudcam=http://10.10.30.9:8001/hx-weather-warning/camera/getCameraListByName?name=&pageNo=1&pageSize=10 -tsingtao-xha.localcam=http://10.134.135.9:8001/hx-weather-warning/camera/getCameraListByName?name=&pageNo=1&pageSize=10 +tsingtao-xha.cloudcam=http://10.10.30.9:8001/hx-weather-warning/camera/getCameraListByName?name=%s&pageNo=%d&pageSize=%d +tsingtao-xha.localcam=http://10.134.135.9:8001/hx-weather-warning/camera/getCameraListByName?name=%s&pageNo=%d&pageSize=%d tsingtao-xha.resourcecount=http://10.16.3.224:30090/api/share-portal/platform/catalogue/query?catalogueId=&departmentId=&serviceName=&type=&orderField=requestNum&orderType=desc&pageNum=1&pageSize=10&serviceType=data&rq=1655106309671.43 tsingtao-xha.resourceapplyinfo=http://10.134.135.24:30058/shareportal/platform/index/abilityMarket/count \ No newline at end of file