云图数据资源总况

This commit is contained in:
wangliwen 2022-06-21 16:06:20 +08:00
parent 0f554f188d
commit 0b7d80da4a
3 changed files with 157 additions and 1 deletions

View File

@ -395,4 +395,156 @@ public class CensusControllerV2 {
return new Result().ok(result); return new Result().ok(result);
} }
@GetMapping("/dataResourceInfo")
@ApiOperation("数据资源简况")
@LogOperation("数据资源简况")
public Result<List<Map<String, Object>>> dataResourceInfo() {
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
CompletableFuture<Void> allAmount = null;
CompletableFuture<Void> applyInfo = null; // 申请情况
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
case BAOTOU: { // TODO 包头
result.add(new HashMap<String, Object>() {
{
put("amount", 0L);
put("type", "总数据量");
}
});
result.add(new HashMap<String, Object>() {
{
put("amount", 0l);
put("type", "总申请次数");
}
});
result.add(new HashMap<String, Object>() {
{
put("amount", 1);
put("type", "满足率");
}
});
result.add(new HashMap<String, Object>() {
{
put("resourceTop5", new ArrayList<>());
}
});
}
break;
case TSINGTAO: { // TODO 青岛大数据局
result.add(new HashMap<String, Object>() {
{
put("amount", 0L);
put("type", "总数据量");
}
});
result.add(new HashMap<String, Object>() {
{
put("amount", 0l);
put("type", "总申请次数");
}
});
result.add(new HashMap<String, Object>() {
{
put("amount", 1);
put("type", "满足率");
}
});
result.add(new HashMap<String, Object>() {
{
put("resourceTop5", new ArrayList<>());
}
});
}
break;
case TSINGTAO_XHA: { // 青岛西海岸
allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台数据资源总数目
OkHttpClient client = new OkHttpClient();
Long total = 0L;
Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourcecount()).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("data")) {
total = jsonObject.getJSONObject("data").getLongValue("total");
}
} else {
logger.error("包头获取失败");
}
} catch (Exception exception) {
logger.error("包头失败", exception);
}
return total;
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "总数据量");
}
});
}); // 处理总数目
applyInfo = CompletableFuture.runAsync(() -> {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourceapplyinfo()).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("data")) {
result.add(new HashMap<String, Object>() {
{
put("amount", jsonObject.getJSONObject("data").getLongValue("requestCount"));
put("type", "总申请次数");
}
});
result.add(new HashMap<String, Object>() {
{
put("amount", jsonObject.getJSONObject("data").getIntValue("satisfactionRate"));
put("type", "满足率");
}
});
result.add(new HashMap<String, Object>() {
{
put("resourceTop5", jsonObject.getJSONObject("data").getJSONArray("resourceTop5").stream().map(index -> (JSONObject) JSON.toJSON(index)).map(index -> new HashMap<String, Object>() {
{
put("服务名称", index.getString("service_name"));
put("申请次数", index.getLongValue("count"));
}
}).collect(Collectors.toList()));
}
});
}
} else {
logger.error("包头获取失败");
}
} catch (Exception exception) {
logger.error("包头失败", exception);
}
});
}
break;
}
if (allAmount == null) {
allAmount = CompletableFuture.runAsync(() -> {
try {
Thread.sleep(100l);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
}
if (applyInfo == null) {
applyInfo = CompletableFuture.runAsync(() -> {
try {
Thread.sleep(100l);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
}
CompletableFuture<Void> all = CompletableFuture.allOf(allAmount, applyInfo);
all.join();
return new Result().ok(result);
}
} }

View File

@ -18,4 +18,6 @@ public class Tsingtao_xhaProperties {
private String localhls; private String localhls;
private String cloudcam; private String cloudcam;
private String localcam; private String localcam;
private String resourcecount;
private String resourceapplyinfo;
} }

View File

@ -2,3 +2,5 @@ tsingtao-xha.cloudhls=http://10.10.30.9:8001/hx-weatherwarning/camera/getCameraL
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=&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.localcam=http://10.134.135.9:8001/hx-weather-warning/camera/getCameraListByName?name=&pageNo=1&pageSize=10
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