基础设施

This commit is contained in:
wangliwen 2022-06-21 17:00:56 +08:00
parent b029bac595
commit 6d400ff9ae
3 changed files with 117 additions and 33 deletions

View File

@ -314,6 +314,7 @@ public class CensusControllerV2 {
List<Map<String, Object>> result = new CopyOnWriteArrayList<>(); List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
CompletableFuture<Void> allAmount = null; CompletableFuture<Void> allAmount = null;
switch (Constant.ProjectPlace.getByFlag(projectPlace)) { switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
case TSINGTAO: // 青岛市局
case BAOTOU: { // 包头 case BAOTOU: { // 包头
allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目
return jdbcTemplate.queryForObject("SELECT COUNT(id) FROM tb_data_resource WHERE type = '基础设施' AND del_flag = 0", Long.class); 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; break;
case TSINGTAO: { // 青岛大数据局
allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目
return jdbcTemplate.queryForObject("SELECT COUNT(*) FROM t_camera;", Long.class);
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "视频资源数量");
}
});
});
}
break;
case TSINGTAO_XHA: { // 青岛西海岸 case TSINGTAO_XHA: { // 青岛西海岸
allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目
List<Long> result_ = new CopyOnWriteArrayList<>(); List<Long> result_ = new CopyOnWriteArrayList<>();
CompletableFuture cloud = CompletableFuture cloud =
CompletableFuture.runAsync(() -> { // 云脑专网 CompletableFuture.runAsync(() -> { // 云脑专网
OkHttpClient client = new OkHttpClient(); 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()) { try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string()); JSONObject jsonObject = JSON.parseObject(response.body().string());
@ -363,7 +353,9 @@ public class CensusControllerV2 {
CompletableFuture local = CompletableFuture local =
CompletableFuture.runAsync(() -> { // 金宏网 CompletableFuture.runAsync(() -> { // 金宏网
OkHttpClient client = new OkHttpClient(); 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()) { try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string()); JSONObject jsonObject = JSON.parseObject(response.body().string());

View File

@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.common.service.impl.CrudServiceImpl;
import io.renren.modules.resource.dao.AttrDao; import io.renren.modules.resource.dao.AttrDao;
import io.renren.modules.resource.dao.ResourceDao; import io.renren.modules.resource.dao.ResourceDao;
@ -113,6 +115,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Autowired @Autowired
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
@Autowired
private Tsingtao_xhaProperties tsingtao_xhaProperties;
@Override @Override
public QueryWrapper<ResourceEntity> getWrapper(Map<String, Object> params) { public QueryWrapper<ResourceEntity> getWrapper(Map<String, Object> params) {
QueryWrapper<ResourceEntity> wrapper = new QueryWrapper<>(); QueryWrapper<ResourceEntity> wrapper = new QueryWrapper<>();
@ -221,24 +226,111 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
String orderField = StringUtils.isBlank(jsonObject.getString("orderField")) ? "total" : jsonObject.getString("orderField"); String orderField = StringUtils.isBlank(jsonObject.getString("orderField")) ? "total" : jsonObject.getString("orderField");
String orderType = StringUtils.isBlank(jsonObject.getString("orderType")) ? "DESC" : jsonObject.getString("orderType"); String orderType = StringUtils.isBlank(jsonObject.getString("orderType")) ? "DESC" : jsonObject.getString("orderType");
Page<ResourceDTO> resultPage = new Page<>(pageNum, pageSize); Page<ResourceDTO> resultPage = new Page<>(pageNum, pageSize);
if (resourceDTO.getInfoList().isEmpty()) { switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
List<ResourceDTO> resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType); case TSINGTAO:
resultPage.setRecords(resourceDTOS); case BAOTOU: { // 包头青岛西海岸
resultPage.setTotal(resourceDao.selectDTOPage(resourceDTO, 0, 100000, orderField, orderType).size()); if (resourceDTO.getInfoList().isEmpty()) {
} else { List<ResourceDTO> resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType);
List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType); resultPage.setRecords(resourceDTOS);
int j = Math.min(pageNum * pageSize, resourceDTOS.size()); resultPage.setTotal(resourceDao.selectDTOPage(resourceDTO, 0, 100000, orderField, orderType).size());
if (resourceDTOS.isEmpty()) { } else {
resultPage.setRecords(null); List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType);
resultPage.setTotal(0); int j = Math.min(pageNum * pageSize, resourceDTOS.size());
} else { if (resourceDTOS.isEmpty()) {
ArrayList<ResourceDTO> recordLists = new ArrayList<>(); resultPage.setRecords(null);
for (int i = (pageNum - 1) * pageSize; i < j; i++) { resultPage.setTotal(0);
recordLists.add(resourceDTOS.get(i)); } else {
ArrayList<ResourceDTO> 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<Long> 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<ResourceDTO> 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<ResourceDTO> 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<ResourceDTO> 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; return resultPage;
} }

View File

@ -1,6 +1,6 @@
tsingtao-xha.cloudhls=http://10.10.30.9:8001/hx-weatherwarning/camera/getCameraLiveStreamByCode?cameraCode=%s&protocol=hls 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.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.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=&pageNo=1&pageSize=10 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.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 tsingtao-xha.resourceapplyinfo=http://10.134.135.24:30058/shareportal/platform/index/abilityMarket/count