From 4c431c605e18d86fefdca6878cd8d66f962b4411 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期四, 05 九月 2024 12:06:52 +0800
Subject: [PATCH] 数据中心返回率
---
ycl-server/src/main/java/com/ycl/platform/service/impl/DataCenterServiceImpl.java | 193 +++++++++++++++++++++++++++++++++++++++---------
1 files changed, 157 insertions(+), 36 deletions(-)
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/DataCenterServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/DataCenterServiceImpl.java
index f40c430..c1672df 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/DataCenterServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/DataCenterServiceImpl.java
@@ -1,11 +1,13 @@
package com.ycl.platform.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.mongodb.client.AggregateIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
+import com.ycl.platform.domain.entity.CheckIndexVideo;
import com.ycl.platform.domain.entity.ImageResourceSecurityDetail;
import com.ycl.platform.domain.entity.YwPoint;
import com.ycl.platform.domain.query.DataCenterQuery;
@@ -14,9 +16,12 @@
import com.ycl.platform.mapper.ImageResourceSecurityDetailMapper;
import com.ycl.platform.mapper.YwPointMapper;
import com.ycl.platform.service.DataCenterService;
+import com.ycl.platform.service.ICheckIndexCarService;
+import com.ycl.platform.service.ICheckIndexVideoService;
import com.ycl.platform.service.YwPointService;
import com.ycl.system.Result;
import com.ycl.system.page.PageUtil;
+import com.ycl.utils.DateUtils;
import com.ycl.utils.MongoUtil;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
@@ -28,6 +33,8 @@
import org.springframework.data.mongodb.core.query.TextCriteria;
import org.springframework.stereotype.Service;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
@@ -44,6 +51,7 @@
private final MongoTemplate mongoTemplate;
private final ImageResourceSecurityDetailMapper securityDetailMapper;
private final YwPointMapper pointMapper;
+ private final ICheckIndexVideoService checkIndexVideoService;
private final static String TIME_FIELD = "mongoCreateTime";
@@ -69,9 +77,19 @@
MongoDatabase database = mongoTemplate.getDb();
MongoCollection<Document> collection = database.getCollection("uy_online");
long distinctCount = collection.distinct("deviceId", String.class).into(new ArrayList<>()).size();
-
+ Date now = new Date();
+ List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper())
+ .select(CheckIndexVideo::getSiteOnline)
+ .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now))
+ .list();
+ BigDecimal onlineRate = BigDecimal.ZERO;
+ if (CollectionUtils.isNotEmpty(videoList)) {
+ BigDecimal sum = videoList.stream().map(CheckIndexVideo::getSiteOnline).reduce(BigDecimal.ZERO, BigDecimal::add);
+ BigDecimal count = BigDecimal.valueOf(videoList.size());
+ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
+ }
HashMap<String, Object> map = new HashMap<>();
- map.put("count", Arrays.asList(distinctCount));
+ map.put("count", Arrays.asList(distinctCount + "",onlineRate + "%"));
map.put("list", resultList);
return Result.ok().data(map).total(total);
}
@@ -114,9 +132,19 @@
uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds");
break; // 涓嶉渶瑕佺户缁亶鍘嗭紝鍥犱负 $count 鍙細浜х敓涓�涓粨鏋�
}
-
+ Date now = new Date();
+ List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper())
+ .select(CheckIndexVideo::getMinistrySiteOnline)
+ .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now))
+ .list();
+ BigDecimal onlineRate = BigDecimal.ZERO;
+ if (CollectionUtils.isNotEmpty(videoList)) {
+ BigDecimal sum = videoList.stream().map(CheckIndexVideo::getMinistrySiteOnline).reduce(BigDecimal.ZERO, BigDecimal::add);
+ BigDecimal count = BigDecimal.valueOf(videoList.size());
+ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
+ }
HashMap<String, Object> map = new HashMap<>();
- map.put("count", Arrays.asList(uniqueDeviceIdCount));
+ map.put("count", Arrays.asList(uniqueDeviceIdCount + "", onlineRate + "%"));
map.put("list", resultList);
return Result.ok().data(map).total(total);
}
@@ -157,13 +185,19 @@
break; // 涓嶉渶瑕佺户缁亶鍘嗭紝鍥犱负 $count 鍙細浜х敓涓�涓粨鏋�
}
-// long nonNetwork = mongoTemplate.count(new Query().addCriteria(Criteria.where("LWSX").is("0")), VideoOnlineResult.class);
-// long network = mongoTemplate.count(new Query().addCriteria(Criteria.where("LWSX").is("1")), VideoOnlineResult.class);
-// long video = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*1.*")), VideoOnlineResult.class);
-// long car = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*2.*")), VideoOnlineResult.class);
-// long face = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*3.*")), VideoOnlineResult.class);
+ Date now = new Date();
+ List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper())
+ .select(CheckIndexVideo::getKeySiteOnline)
+ .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now))
+ .list();
+ BigDecimal onlineRate = BigDecimal.ZERO;
+ if (CollectionUtils.isNotEmpty(videoList)) {
+ BigDecimal sum = videoList.stream().map(CheckIndexVideo::getKeySiteOnline).reduce(BigDecimal.ZERO, BigDecimal::add);
+ BigDecimal count = BigDecimal.valueOf(videoList.size());
+ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
+ }
HashMap<String, Object> map = new HashMap<>();
- map.put("count", Arrays.asList(uniqueDeviceIdCount));
+ map.put("count", Arrays.asList(uniqueDeviceIdCount + "", onlineRate + "%"));
map.put("list", resultList);
return Result.ok().data(map).total(total);
}
@@ -204,14 +238,19 @@
break; // 涓嶉渶瑕佺户缁亶鍘嗭紝鍥犱负 $count 鍙細浜х敓涓�涓粨鏋�
}
-// // 缁熻鏁�
-// long nonNetwork = mongoTemplate.count(new Query().addCriteria(Criteria.where("LWSX").is("0")), VideoOnlineResult.class);
-// long network = mongoTemplate.count(new Query().addCriteria(Criteria.where("LWSX").is("1")), VideoOnlineResult.class);
-// long video = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*1.*")), VideoOnlineResult.class);
-// long car = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*2.*")), VideoOnlineResult.class);
-// long face = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*3.*")), VideoOnlineResult.class);
+ Date now = new Date();
+ List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper())
+ .select(CheckIndexVideo::getKeyCommandImageOnline)
+ .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now))
+ .list();
+ BigDecimal onlineRate = BigDecimal.ZERO;
+ if (CollectionUtils.isNotEmpty(videoList)) {
+ BigDecimal sum = videoList.stream().map(CheckIndexVideo::getKeyCommandImageOnline).reduce(BigDecimal.ZERO, BigDecimal::add);
+ BigDecimal count = BigDecimal.valueOf(videoList.size());
+ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
+ }
HashMap<String, Object> map = new HashMap<>();
- map.put("count", Arrays.asList(uniqueDeviceIdCount));
+ map.put("count", Arrays.asList(uniqueDeviceIdCount + "", onlineRate + "%"));
map.put("list", resultList);
return Result.ok().data(map).total(total);
}
@@ -241,7 +280,7 @@
Document longitudeErrFilter = new Document("longitude.error", true);
List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter);
- List<Integer> rList = lists.stream().map(filter -> {
+ List<String> rList = lists.stream().map(filter -> {
// 鏋勫缓鑱氬悎绠¢亾
List<Document> pipeline = Arrays.asList(
new Document("$match", filter),
@@ -256,9 +295,21 @@
uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds");
break; // 涓嶉渶瑕佺户缁亶鍘嗭紝鍥犱负 $count 鍙細浜х敓涓�涓粨鏋�
}
- return uniqueDeviceIdCount;
+ return uniqueDeviceIdCount + "";
}).collect(Collectors.toList());
+ Date now = new Date();
+ List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper())
+ .select(CheckIndexVideo::getMonitorRegistration)
+ .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now))
+ .list();
+ BigDecimal onlineRate = BigDecimal.ZERO;
+ if (CollectionUtils.isNotEmpty(videoList)) {
+ BigDecimal sum = videoList.stream().map(CheckIndexVideo::getMonitorRegistration).reduce(BigDecimal.ZERO, BigDecimal::add);
+ BigDecimal count = BigDecimal.valueOf(videoList.size());
+ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
+ }
+ rList.add(onlineRate + "%");
HashMap<String, Object> map = new HashMap<>();
map.put("count", rList);
map.put("list", resultList);
@@ -290,7 +341,7 @@
Document longitudeErrFilter = new Document("longitude.error", true);
List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter);
- List<Integer> rList = lists.stream().map(filter -> {
+ List<String> rList = lists.stream().map(filter -> {
// 鏋勫缓鑱氬悎绠¢亾
List<Document> pipeline = Arrays.asList(
new Document("$match", filter),
@@ -305,9 +356,21 @@
uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds");
break; // 涓嶉渶瑕佺户缁亶鍘嗭紝鍥犱负 $count 鍙細浜х敓涓�涓粨鏋�
}
- return uniqueDeviceIdCount;
+ return uniqueDeviceIdCount + "";
}).collect(Collectors.toList());
+ Date now = new Date();
+ List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper())
+ .select(CheckIndexVideo::getMonitorQualification)
+ .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now))
+ .list();
+ BigDecimal onlineRate = BigDecimal.ZERO;
+ if (CollectionUtils.isNotEmpty(videoList)) {
+ BigDecimal sum = videoList.stream().map(CheckIndexVideo::getMonitorQualification).reduce(BigDecimal.ZERO, BigDecimal::add);
+ BigDecimal count = BigDecimal.valueOf(videoList.size());
+ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
+ }
+ rList.add(onlineRate + "%");
HashMap<String, Object> map = new HashMap<>();
map.put("count", rList);
map.put("list", resultList);
@@ -340,7 +403,7 @@
Document longitudeErrFilter = new Document("longitude.error", true);
List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter);
- List<Integer> rList = lists.stream().map(filter -> {
+ List<String> rList = lists.stream().map(filter -> {
// 鏋勫缓鑱氬悎绠¢亾
List<Document> pipeline = Arrays.asList(
new Document("$match", filter),
@@ -355,9 +418,10 @@
uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds");
break; // 涓嶉渶瑕佺户缁亶鍘嗭紝鍥犱负 $count 鍙細浜х敓涓�涓粨鏋�
}
- return uniqueDeviceIdCount;
+ return uniqueDeviceIdCount + "";
}).collect(Collectors.toList());
+ rList.add("0%");
HashMap<String, Object> map = new HashMap<>();
map.put("count", rList);
map.put("list", resultList);
@@ -383,7 +447,7 @@
MongoDatabase database = mongoTemplate.getDb();
MongoCollection<Document> collection = database.getCollection("uy_record_meta_d_sum");
List<Integer> status = Arrays.asList(1, 0, -1);
- List<Integer> resultCount = status.stream().map(item -> {
+ List<String> resultCount = status.stream().map(item -> {
Document filter = new Document("recordStatus", item);
// 鏋勫缓鑱氬悎绠¢亾
List<Document> pipeline = Arrays.asList(
@@ -399,10 +463,21 @@
uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds");
break; // 涓嶉渶瑕佺户缁亶鍘嗭紝鍥犱负 $count 鍙細浜х敓涓�涓粨鏋�
}
- return uniqueDeviceIdCount;
+ return uniqueDeviceIdCount + "";
}).collect(Collectors.toList());
-
+ Date now = new Date();
+ List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper())
+ .select(CheckIndexVideo::getVideoAvailable)
+ .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now))
+ .list();
+ BigDecimal onlineRate = BigDecimal.ZERO;
+ if (CollectionUtils.isNotEmpty(videoList)) {
+ BigDecimal sum = videoList.stream().map(CheckIndexVideo::getVideoAvailable).reduce(BigDecimal.ZERO, BigDecimal::add);
+ BigDecimal count = BigDecimal.valueOf(videoList.size());
+ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
+ }
+ resultCount.add(onlineRate + "%");
HashMap<String, Object> map = new HashMap<>();
map.put("count", resultCount);
map.put("list", resultList);
@@ -430,7 +505,7 @@
MongoDatabase database = mongoTemplate.getDb();
MongoCollection<Document> collection = database.getCollection("uy_record_meta_d_sum");
List<Integer> status = Arrays.asList(1, 0, -1);
- List<Integer> resultCount = status.stream().map(item -> {
+ List<String> resultCount = status.stream().map(item -> {
Document filter = new Document("$and", Arrays.asList(
new Document("deviceId", new Document("$in", deptGBList)), // $in 鏉′欢
new Document("recordStatus", item)
@@ -449,10 +524,21 @@
uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds");
break; // 涓嶉渶瑕佺户缁亶鍘嗭紝鍥犱负 $count 鍙細浜х敓涓�涓粨鏋�
}
- return uniqueDeviceIdCount;
+ return uniqueDeviceIdCount + "";
}).collect(Collectors.toList());
-
+ Date now = new Date();
+ List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper())
+ .select(CheckIndexVideo::getMinistryVideoAvailable)
+ .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now))
+ .list();
+ BigDecimal onlineRate = BigDecimal.ZERO;
+ if (CollectionUtils.isNotEmpty(videoList)) {
+ BigDecimal sum = videoList.stream().map(CheckIndexVideo::getMinistryVideoAvailable).reduce(BigDecimal.ZERO, BigDecimal::add);
+ BigDecimal count = BigDecimal.valueOf(videoList.size());
+ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
+ }
+ resultCount.add(onlineRate + "%");
HashMap<String, Object> map = new HashMap<>();
map.put("count", resultCount);
map.put("list", resultList);
@@ -480,7 +566,7 @@
MongoDatabase database = mongoTemplate.getDb();
MongoCollection<Document> collection = database.getCollection("uy_record_meta_d_sum");
List<Integer> status = Arrays.asList(1, 0, -1);
- List<Integer> resultCount = status.stream().map(item -> {
+ List<String> resultCount = status.stream().map(item -> {
Document filter = new Document("$and", Arrays.asList(
new Document("deviceId", new Document("$in", deptGBList)), // $in 鏉′欢
new Document("recordStatus", item)
@@ -499,9 +585,21 @@
uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds");
break; // 涓嶉渶瑕佺户缁亶鍘嗭紝鍥犱负 $count 鍙細浜х敓涓�涓粨鏋�
}
- return uniqueDeviceIdCount;
+ return uniqueDeviceIdCount + "%";
}).collect(Collectors.toList());
+ Date now = new Date();
+ List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper())
+ .select(CheckIndexVideo::getKeyVideoAvailable)
+ .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now))
+ .list();
+ BigDecimal onlineRate = BigDecimal.ZERO;
+ if (CollectionUtils.isNotEmpty(videoList)) {
+ BigDecimal sum = videoList.stream().map(CheckIndexVideo::getKeyVideoAvailable).reduce(BigDecimal.ZERO, BigDecimal::add);
+ BigDecimal count = BigDecimal.valueOf(videoList.size());
+ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
+ }
+ resultCount.add(onlineRate + "%");
HashMap<String, Object> map = new HashMap<>();
map.put("count", resultCount);
map.put("list", resultList);
@@ -559,7 +657,7 @@
Document osdTimeFilter = new Document("osdTimeCorrect", 1);
Document osdTimeErrFilter = new Document("osdTimeCorrect", -1);
List<Document> lists = Arrays.asList(osdNameFilter, osdNameErrFilter, osdTimeFilter, osdTimeErrFilter);
- List<Integer> rList = lists.stream().map(filter -> {
+ List<String> rList = lists.stream().map(filter -> {
// 鏋勫缓鑱氬悎绠¢亾
List<Document> pipeline = Arrays.asList(
new Document("$match", filter),
@@ -574,10 +672,21 @@
uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds");
break; // 涓嶉渶瑕佺户缁亶鍘嗭紝鍥犱负 $count 鍙細浜х敓涓�涓粨鏋�
}
- return uniqueDeviceIdCount;
+ return uniqueDeviceIdCount + "";
}).collect(Collectors.toList());
-
+ Date now = new Date();
+ List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper())
+ .select(CheckIndexVideo::getKeyAnnotationAccuracy)
+ .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now))
+ .list();
+ BigDecimal onlineRate = BigDecimal.ZERO;
+ if (CollectionUtils.isNotEmpty(videoList)) {
+ BigDecimal sum = videoList.stream().map(CheckIndexVideo::getKeyAnnotationAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add);
+ BigDecimal count = BigDecimal.valueOf(videoList.size());
+ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
+ }
+ rList.add(onlineRate + "%");
HashMap<String, Object> map = new HashMap<>();
map.put("count", rList);
map.put("list", resultList);
@@ -634,7 +743,7 @@
Document osdTimeFilter = new Document("osdTimeCorrect", 1);
Document osdTimeErrFilter = new Document("osdTimeCorrect", -1);
List<Document> lists = Arrays.asList(osdTimeFilter, osdTimeErrFilter);
- List<Integer> rList = lists.stream().map(filter -> {
+ List<String> rList = lists.stream().map(filter -> {
// 鏋勫缓鑱氬悎绠¢亾
List<Document> pipeline = Arrays.asList(
new Document("$match", filter),
@@ -649,9 +758,21 @@
uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds");
break; // 涓嶉渶瑕佺户缁亶鍘嗭紝鍥犱负 $count 鍙細浜х敓涓�涓粨鏋�
}
- return uniqueDeviceIdCount;
+ return uniqueDeviceIdCount + "";
}).collect(Collectors.toList());
+ Date now = new Date();
+ List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper())
+ .select(CheckIndexVideo::getKeyTimingAccuracy)
+ .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now))
+ .list();
+ BigDecimal onlineRate = BigDecimal.ZERO;
+ if (CollectionUtils.isNotEmpty(videoList)) {
+ BigDecimal sum = videoList.stream().map(CheckIndexVideo::getKeyTimingAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add);
+ BigDecimal count = BigDecimal.valueOf(videoList.size());
+ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
+ }
+ rList.add(onlineRate + "%");
HashMap<String, Object> map = new HashMap<>();
map.put("count", rList);
map.put("list", resultList);
--
Gitblit v1.8.0