| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | |
| | | private final MongoTemplate mongoTemplate; |
| | | private final ImageResourceSecurityDetailMapper securityDetailMapper; |
| | | private final YwPointMapper pointMapper; |
| | | private final ICheckIndexVideoService checkIndexVideoService; |
| | | |
| | | |
| | | private final static String TIME_FIELD = "mongoCreateTime"; |
| | |
| | | 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); |
| | | } |
| | |
| | | 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); |
| | | } |
| | |
| | | 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); |
| | | } |
| | |
| | | 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); |
| | | } |
| | |
| | | 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), |
| | |
| | | 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); |
| | |
| | | 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), |
| | |
| | | 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); |
| | |
| | | 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), |
| | |
| | | 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); |
| | |
| | | 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( |
| | |
| | | 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); |
| | |
| | | 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) |
| | |
| | | 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); |
| | |
| | | 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) |
| | |
| | | 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); |
| | |
| | | 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), |
| | |
| | | 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); |
| | |
| | | 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), |
| | |
| | | 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); |