| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | 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.ImageResourceSecurityDetail; |
| | | import com.ycl.platform.domain.entity.YwPoint; |
| | | import com.ycl.platform.domain.query.DataCenterQuery; |
| | |
| | | import com.ycl.utils.MongoUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.bson.Document; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 数据中心接口 |
| | |
| | | MongoUtil.setPage(query, params, TIME_FIELD); |
| | | List<VideoOnlineResult> resultList = mongoTemplate.find(query, VideoOnlineResult.class); |
| | | |
| | | // 统计数量 |
| | | MongoDatabase database = mongoTemplate.getDb(); |
| | | MongoCollection<Document> collection = database.getCollection("uy_online"); |
| | | long distinctCount = collection.distinct("deviceId", String.class).into(new ArrayList<>()).size(); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", Arrays.asList(total)); |
| | | map.put("count", Arrays.asList(distinctCount)); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |
| | |
| | | MongoUtil.setPage(query, params, TIME_FIELD); |
| | | List<VideoOnlineResult> resultList = mongoTemplate.find(query, VideoOnlineResult.class); |
| | | |
| | | // 统计数量 |
| | | MongoDatabase database = mongoTemplate.getDb(); |
| | | MongoCollection<Document> collection = database.getCollection("uy_online"); |
| | | Document filter = new Document("deviceId", new Document("$in", deptGBList)); |
| | | // 构建聚合管道 |
| | | List<Document> pipeline = Arrays.asList( |
| | | // 只要部级的 |
| | | new Document("$match", filter), |
| | | // $group 去重 |
| | | new Document("$group", new Document("_id", "$deviceId")), |
| | | new Document("$count", "uniqueDeviceIds") |
| | | ); |
| | | // 执行聚合查询并获取结果 |
| | | AggregateIterable<Document> result = collection.aggregate(pipeline); |
| | | Integer uniqueDeviceIdCount = 0; |
| | | for (Document doc : result) { |
| | | uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds"); |
| | | break; // 不需要继续遍历,因为 $count 只会产生一个结果 |
| | | } |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", Arrays.asList(total)); |
| | | map.put("count", Arrays.asList(uniqueDeviceIdCount)); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |
| | |
| | | long total = mongoTemplate.count(query, VideoOnlineResult.class); |
| | | MongoUtil.setPage(query, params, TIME_FIELD); |
| | | List<VideoOnlineResult> resultList = mongoTemplate.find(query, VideoOnlineResult.class); |
| | | // 统计数 |
| | | 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); |
| | | |
| | | // 统计数量 |
| | | MongoDatabase database = mongoTemplate.getDb(); |
| | | MongoCollection<Document> collection = database.getCollection("uy_online"); |
| | | Document filter = new Document("deviceId", new Document("$in", deptGBList)); |
| | | // 构建聚合管道 |
| | | List<Document> pipeline = Arrays.asList( |
| | | new Document("$match", filter), |
| | | // $group 去重 |
| | | new Document("$group", new Document("_id", "$deviceId")), |
| | | new Document("$count", "uniqueDeviceIds") |
| | | ); |
| | | // 执行聚合查询并获取结果 |
| | | AggregateIterable<Document> result = collection.aggregate(pipeline); |
| | | Integer uniqueDeviceIdCount = 0; |
| | | for (Document doc : result) { |
| | | uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds"); |
| | | 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); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", Arrays.asList(nonNetwork, network, video, car, face)); |
| | | map.put("count", Arrays.asList(uniqueDeviceIdCount)); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |
| | |
| | | long total = mongoTemplate.count(query, VideoOnlineResult.class); |
| | | MongoUtil.setPage(query, params, TIME_FIELD); |
| | | List<VideoOnlineResult> resultList = mongoTemplate.find(query, VideoOnlineResult.class); |
| | | // 统计数 |
| | | 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); |
| | | |
| | | // 统计数量 |
| | | MongoDatabase database = mongoTemplate.getDb(); |
| | | MongoCollection<Document> collection = database.getCollection("uy_online"); |
| | | Document filter = new Document("deviceId", new Document("$in", deptGBList)); |
| | | // 构建聚合管道 |
| | | List<Document> pipeline = Arrays.asList( |
| | | new Document("$match", filter), |
| | | // $group 去重 |
| | | new Document("$group", new Document("_id", "$deviceId")), |
| | | new Document("$count", "uniqueDeviceIds") |
| | | ); |
| | | // 执行聚合查询并获取结果 |
| | | AggregateIterable<Document> result = collection.aggregate(pipeline); |
| | | Integer uniqueDeviceIdCount = 0; |
| | | for (Document doc : result) { |
| | | uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds"); |
| | | 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); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", Arrays.asList(nonNetwork, network, video, car, face)); |
| | | map.put("count", Arrays.asList(uniqueDeviceIdCount)); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |
| | |
| | | long total = mongoTemplate.count(query, MonitorQualifyResult.class); |
| | | MongoUtil.setPage(query, params, TIME_FIELD); |
| | | List<MonitorQualifyResult> resultList = mongoTemplate.find(query, MonitorQualifyResult.class); |
| | | // 统计数 |
| | | long nonNetwork = mongoTemplate.count(new Query().addCriteria(Criteria.where("LWSX").is("0")), MonitorQualifyResult.class); |
| | | long network = mongoTemplate.count(new Query().addCriteria(Criteria.where("LWSX").is("1")), MonitorQualifyResult.class); |
| | | long video = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*1.*")), MonitorQualifyResult.class); |
| | | long car = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*2.*")), MonitorQualifyResult.class); |
| | | long face = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*3.*")), MonitorQualifyResult.class); |
| | | |
| | | // 统计数量 |
| | | MongoDatabase database = mongoTemplate.getDb(); |
| | | MongoCollection<Document> collection = database.getCollection("uy_monitor_qualify"); |
| | | |
| | | Document ipErrFilter = new Document("ip.error", true); |
| | | Document macdzErrFilter = new Document("macdz.error", true); |
| | | Document latitudeErrFilter = new Document("latitude.error", true); |
| | | Document longitudeErrFilter = new Document("longitude.error", true); |
| | | |
| | | List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter); |
| | | List<Integer> rList = lists.stream().map(filter -> { |
| | | // 构建聚合管道 |
| | | List<Document> pipeline = Arrays.asList( |
| | | new Document("$match", filter), |
| | | // $group 去重 |
| | | new Document("$group", new Document("_id", "$serialNumber.showValue")), |
| | | new Document("$count", "uniqueDeviceIds") |
| | | ); |
| | | // 执行聚合查询并获取结果 |
| | | AggregateIterable<Document> result = collection.aggregate(pipeline); |
| | | Integer uniqueDeviceIdCount = 0; |
| | | for (Document doc : result) { |
| | | uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds"); |
| | | break; // 不需要继续遍历,因为 $count 只会产生一个结果 |
| | | } |
| | | return uniqueDeviceIdCount; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", Arrays.asList(nonNetwork, network, video, car, face)); |
| | | map.put("count", rList); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |
| | |
| | | long total = mongoTemplate.count(query, MonitorQualifyResult.class); |
| | | MongoUtil.setPage(query, params, TIME_FIELD); |
| | | List<MonitorQualifyResult> resultList = mongoTemplate.find(query, MonitorQualifyResult.class); |
| | | // 统计数 |
| | | |
| | | // 统计数量 |
| | | MongoDatabase database = mongoTemplate.getDb(); |
| | | MongoCollection<Document> collection = database.getCollection("uy_monitor_qualify"); |
| | | |
| | | Document ipErrFilter = new Document("ip.error", true); |
| | | Document macdzErrFilter = new Document("macdz.error", true); |
| | | Document latitudeErrFilter = new Document("latitude.error", true); |
| | | Document longitudeErrFilter = new Document("longitude.error", true); |
| | | |
| | | List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter); |
| | | List<Integer> rList = lists.stream().map(filter -> { |
| | | // 构建聚合管道 |
| | | List<Document> pipeline = Arrays.asList( |
| | | new Document("$match", filter), |
| | | // $group 去重 |
| | | new Document("$group", new Document("_id", "$serialNumber.showValue")), |
| | | new Document("$count", "uniqueDeviceIds") |
| | | ); |
| | | // 执行聚合查询并获取结果 |
| | | AggregateIterable<Document> result = collection.aggregate(pipeline); |
| | | Integer uniqueDeviceIdCount = 0; |
| | | for (Document doc : result) { |
| | | uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds"); |
| | | break; // 不需要继续遍历,因为 $count 只会产生一个结果 |
| | | } |
| | | return uniqueDeviceIdCount; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", CollectionUtils.EMPTY_COLLECTION); |
| | | map.put("count", rList); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |
| | |
| | | long total = mongoTemplate.count(query, MonitorQualifyResult.class); |
| | | MongoUtil.setPage(query, params, TIME_FIELD); |
| | | List<MonitorQualifyResult> resultList = mongoTemplate.find(query, MonitorQualifyResult.class); |
| | | // 统计数 |
| | | long nonNetwork = mongoTemplate.count(new Query().addCriteria(Criteria.where("LWSX").is("0")), MonitorQualifyResult.class); |
| | | long network = mongoTemplate.count(new Query().addCriteria(Criteria.where("LWSX").is("1")), MonitorQualifyResult.class); |
| | | long video = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*1.*")), MonitorQualifyResult.class); |
| | | long car = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*2.*")), MonitorQualifyResult.class); |
| | | long face = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*3.*")), MonitorQualifyResult.class); |
| | | |
| | | // 统计数量 |
| | | MongoDatabase database = mongoTemplate.getDb(); |
| | | MongoCollection<Document> collection = database.getCollection("uy_monitor_qualify"); |
| | | |
| | | Document ipErrFilter = new Document("ip.error", true); |
| | | Document macdzErrFilter = new Document("macdz.error", true); |
| | | Document latitudeErrFilter = new Document("latitude.error", true); |
| | | Document longitudeErrFilter = new Document("longitude.error", true); |
| | | |
| | | List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter); |
| | | List<Integer> rList = lists.stream().map(filter -> { |
| | | // 构建聚合管道 |
| | | List<Document> pipeline = Arrays.asList( |
| | | new Document("$match", filter), |
| | | // $group 去重 |
| | | new Document("$group", new Document("_id", "$serialNumber.showValue")), |
| | | new Document("$count", "uniqueDeviceIds") |
| | | ); |
| | | // 执行聚合查询并获取结果 |
| | | AggregateIterable<Document> result = collection.aggregate(pipeline); |
| | | Integer uniqueDeviceIdCount = 0; |
| | | for (Document doc : result) { |
| | | uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds"); |
| | | break; // 不需要继续遍历,因为 $count 只会产生一个结果 |
| | | } |
| | | return uniqueDeviceIdCount; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", Arrays.asList(nonNetwork, network, video, car, face)); |
| | | map.put("count", rList); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |
| | |
| | | long total = mongoTemplate.count(query, RecordMetaDSumResult.class); |
| | | MongoUtil.setPage(query, params, "createTime"); |
| | | List<RecordMetaDSumResult> resultList = mongoTemplate.find(query, RecordMetaDSumResult.class); |
| | | // 统计数 |
| | | long one = mongoTemplate.count(new Query().addCriteria(Criteria.where("recordStatus").is("1")), RecordMetaDSumResult.class); |
| | | long two = mongoTemplate.count(new Query().addCriteria(Criteria.where("recordStatus").is("2")), RecordMetaDSumResult.class); |
| | | long three = mongoTemplate.count(new Query().addCriteria(Criteria.where("recordStatus").is("-1")), RecordMetaDSumResult.class); |
| | | |
| | | // 统计数量 |
| | | 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 -> { |
| | | Document filter = new Document("recordStatus", item); |
| | | // 构建聚合管道 |
| | | List<Document> pipeline = Arrays.asList( |
| | | new Document("$match", filter), |
| | | // $group 去重 |
| | | new Document("$group", new Document("_id", "$deviceId")), |
| | | new Document("$count", "uniqueDeviceIds") |
| | | ); |
| | | // 执行聚合查询并获取结果 |
| | | AggregateIterable<Document> result = collection.aggregate(pipeline); |
| | | Integer uniqueDeviceIdCount = 0; |
| | | for (Document doc : result) { |
| | | uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds"); |
| | | break; // 不需要继续遍历,因为 $count 只会产生一个结果 |
| | | } |
| | | return uniqueDeviceIdCount; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", Arrays.asList(one, two, three)); |
| | | map.put("count", resultCount); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |
| | |
| | | long total = mongoTemplate.count(query, RecordMetaDSumResult.class); |
| | | MongoUtil.setPage(query, params, "createTime"); |
| | | List<RecordMetaDSumResult> resultList = mongoTemplate.find(query, RecordMetaDSumResult.class); |
| | | // 统计数 |
| | | long one = mongoTemplate.count(new Query().addCriteria(Criteria.where("recordStatus").is("1")), RecordMetaDSumResult.class); |
| | | long two = mongoTemplate.count(new Query().addCriteria(Criteria.where("recordStatus").is("2")), RecordMetaDSumResult.class); |
| | | long three = mongoTemplate.count(new Query().addCriteria(Criteria.where("recordStatus").is("-1")), RecordMetaDSumResult.class); |
| | | |
| | | // 统计数量 |
| | | 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 -> { |
| | | Document filter = new Document("$and", Arrays.asList( |
| | | new Document("deviceId", new Document("$in", deptGBList)), // $in 条件 |
| | | new Document("recordStatus", item) |
| | | )); |
| | | // 构建聚合管道 |
| | | List<Document> pipeline = Arrays.asList( |
| | | new Document("$match", filter), |
| | | // $group 去重 |
| | | new Document("$group", new Document("_id", "$deviceId")), |
| | | new Document("$count", "uniqueDeviceIds") |
| | | ); |
| | | // 执行聚合查询并获取结果 |
| | | AggregateIterable<Document> result = collection.aggregate(pipeline); |
| | | Integer uniqueDeviceIdCount = 0; |
| | | for (Document doc : result) { |
| | | uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds"); |
| | | break; // 不需要继续遍历,因为 $count 只会产生一个结果 |
| | | } |
| | | return uniqueDeviceIdCount; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", Arrays.asList(one, two, three)); |
| | | map.put("count", resultCount); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |
| | |
| | | long total = mongoTemplate.count(query, RecordMetaDSumResult.class); |
| | | MongoUtil.setPage(query, params, "createTime"); |
| | | List<RecordMetaDSumResult> resultList = mongoTemplate.find(query, RecordMetaDSumResult.class); |
| | | // 统计数 |
| | | long one = mongoTemplate.count(new Query().addCriteria(Criteria.where("recordStatus").is("1")), OneMachineFileResult.class); |
| | | long two = mongoTemplate.count(new Query().addCriteria(Criteria.where("recordStatus").is("2")), OneMachineFileResult.class); |
| | | long three = mongoTemplate.count(new Query().addCriteria(Criteria.where("recordStatus").is("-1")), OneMachineFileResult.class); |
| | | |
| | | // 统计数量 |
| | | 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 -> { |
| | | Document filter = new Document("$and", Arrays.asList( |
| | | new Document("deviceId", new Document("$in", deptGBList)), // $in 条件 |
| | | new Document("recordStatus", item) |
| | | )); |
| | | // 构建聚合管道 |
| | | List<Document> pipeline = Arrays.asList( |
| | | new Document("$match", filter), |
| | | // $group 去重 |
| | | new Document("$group", new Document("_id", "$deviceId")), |
| | | new Document("$count", "uniqueDeviceIds") |
| | | ); |
| | | // 执行聚合查询并获取结果 |
| | | AggregateIterable<Document> result = collection.aggregate(pipeline); |
| | | Integer uniqueDeviceIdCount = 0; |
| | | for (Document doc : result) { |
| | | uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds"); |
| | | break; // 不需要继续遍历,因为 $count 只会产生一个结果 |
| | | } |
| | | return uniqueDeviceIdCount; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", Arrays.asList(one, two, three)); |
| | | map.put("count", resultCount); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |
| | |
| | | long total = mongoTemplate.count(query, OsdCheckResult.class); |
| | | MongoUtil.setPage(query, params, "checkTime"); |
| | | List<OsdCheckResult> resultList = mongoTemplate.find(query, OsdCheckResult.class); |
| | | // 统计数 |
| | | long nonNetwork = mongoTemplate.count(new Query().addCriteria(Criteria.where("LWSX").is("0")), OsdCheckResult.class); |
| | | long network = mongoTemplate.count(new Query().addCriteria(Criteria.where("LWSX").is("1")), OsdCheckResult.class); |
| | | long video = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*1.*")), OsdCheckResult.class); |
| | | long car = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*2.*")), OsdCheckResult.class); |
| | | long face = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*3.*")), OsdCheckResult.class); |
| | | |
| | | // 统计数量 |
| | | MongoDatabase database = mongoTemplate.getDb(); |
| | | MongoCollection<Document> collection = database.getCollection("osd_check_result"); |
| | | |
| | | Document osdNameFilter = new Document("osdNameCorrect", 1); |
| | | Document osdNameErrFilter = new Document("osdNameCorrect", -1); |
| | | 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<Document> pipeline = Arrays.asList( |
| | | new Document("$match", filter), |
| | | // $group 去重 |
| | | new Document("$group", new Document("_id", "$deviceNo")), |
| | | new Document("$count", "uniqueDeviceIds") |
| | | ); |
| | | // 执行聚合查询并获取结果 |
| | | AggregateIterable<Document> result = collection.aggregate(pipeline); |
| | | Integer uniqueDeviceIdCount = 0; |
| | | for (Document doc : result) { |
| | | uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds"); |
| | | break; // 不需要继续遍历,因为 $count 只会产生一个结果 |
| | | } |
| | | return uniqueDeviceIdCount; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", Arrays.asList(nonNetwork, network, video, car, face)); |
| | | map.put("count", rList); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |
| | |
| | | |
| | | List<String> deptGBList = pointMapper.getDeptPointGB(1); |
| | | |
| | | Query query = MongoUtil.getQuery(params, "deviceId", "checkTime", deptGBList); |
| | | Query query = MongoUtil.getQuery(params, "deviceNo", "checkTime", deptGBList); |
| | | |
| | | long total = mongoTemplate.count(query, OsdCheckResult.class); |
| | | MongoUtil.setPage(query, params, "checkTime"); |
| | | List<OsdCheckResult> resultList = mongoTemplate.find(query, OsdCheckResult.class); |
| | | // 统计数 |
| | | long nonNetwork = mongoTemplate.count(new Query().addCriteria(Criteria.where("LWSX").is("0")), OsdCheckResult.class); |
| | | long network = mongoTemplate.count(new Query().addCriteria(Criteria.where("LWSX").is("1")), OsdCheckResult.class); |
| | | long video = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*1.*")), OsdCheckResult.class); |
| | | long car = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*2.*")), OsdCheckResult.class); |
| | | long face = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*3.*")), OsdCheckResult.class); |
| | | |
| | | // 统计数量 |
| | | MongoDatabase database = mongoTemplate.getDb(); |
| | | MongoCollection<Document> collection = database.getCollection("osd_check_result"); |
| | | |
| | | 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<Document> pipeline = Arrays.asList( |
| | | new Document("$match", filter), |
| | | // $group 去重 |
| | | new Document("$group", new Document("_id", "$deviceNo")), |
| | | new Document("$count", "uniqueDeviceIds") |
| | | ); |
| | | // 执行聚合查询并获取结果 |
| | | AggregateIterable<Document> result = collection.aggregate(pipeline); |
| | | Integer uniqueDeviceIdCount = 0; |
| | | for (Document doc : result) { |
| | | uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds"); |
| | | break; // 不需要继续遍历,因为 $count 只会产生一个结果 |
| | | } |
| | | return uniqueDeviceIdCount; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", Arrays.asList(nonNetwork, network, video, car, face)); |
| | | map.put("count", rList); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |
| | |
| | | long total = mongoTemplate.count(query, SnapshotDataMonitorResult.class); |
| | | MongoUtil.setPage(query, params, TIME_FIELD); |
| | | List<SnapshotDataMonitorResult> resultList = mongoTemplate.find(query, SnapshotDataMonitorResult.class); |
| | | // 统计数 |
| | | long one = mongoTemplate.count(new Query().addCriteria(Criteria.where("resultType").is("1")), SnapshotDataMonitorResult.class); |
| | | long two = mongoTemplate.count(new Query().addCriteria(Criteria.where("resultType").is("2")), SnapshotDataMonitorResult.class); |
| | | long three = mongoTemplate.count(new Query().addCriteria(Criteria.where("resultType").is("3")), SnapshotDataMonitorResult.class); |
| | | long four = mongoTemplate.count(new Query().addCriteria(Criteria.where("resultType").is("4")), SnapshotDataMonitorResult.class); |
| | | |
| | | // 统计数量 |
| | | MongoDatabase database = mongoTemplate.getDb(); |
| | | MongoCollection<Document> collection = database.getCollection("hk_snapshot_data_monitor"); |
| | | |
| | | Document normalFilter = new Document("resultType", 1); |
| | | Document noDataFilter = new Document("resultType", 2); |
| | | Document trFilter = new Document("resultType", 3); |
| | | Document littleFilter = new Document("resultType", 4); |
| | | List<Document> lists = Arrays.asList(normalFilter, noDataFilter, trFilter, littleFilter); |
| | | List<Integer> rList = lists.stream().map(filter -> { |
| | | // 构建聚合管道 |
| | | List<Document> pipeline = Arrays.asList( |
| | | new Document("$match", filter), |
| | | // $group 去重 |
| | | new Document("$group", new Document("_id", "$externalIndexCode")), |
| | | new Document("$count", "uniqueDeviceIds") |
| | | ); |
| | | // 执行聚合查询并获取结果 |
| | | AggregateIterable<Document> result = collection.aggregate(pipeline); |
| | | Integer uniqueDeviceIdCount = 0; |
| | | for (Document doc : result) { |
| | | uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds"); |
| | | break; // 不需要继续遍历,因为 $count 只会产生一个结果 |
| | | } |
| | | return uniqueDeviceIdCount; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", Arrays.asList(one, two, three, four)); |
| | | map.put("count", rList); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |
| | |
| | | long total = mongoTemplate.count(query, SnapshotDataMonitorResult.class); |
| | | MongoUtil.setPage(query, params, TIME_FIELD); |
| | | List<SnapshotDataMonitorResult> resultList = mongoTemplate.find(query, SnapshotDataMonitorResult.class); |
| | | // 统计数 |
| | | long one = mongoTemplate.count(new Query().addCriteria(Criteria.where("resultType").is("1")), SnapshotDataMonitorResult.class); |
| | | long two = mongoTemplate.count(new Query().addCriteria(Criteria.where("resultType").is("2")), SnapshotDataMonitorResult.class); |
| | | long three = mongoTemplate.count(new Query().addCriteria(Criteria.where("resultType").is("3")), SnapshotDataMonitorResult.class); |
| | | long four = mongoTemplate.count(new Query().addCriteria(Criteria.where("resultType").is("4")), SnapshotDataMonitorResult.class); |
| | | |
| | | // 统计数量 |
| | | MongoDatabase database = mongoTemplate.getDb(); |
| | | MongoCollection<Document> collection = database.getCollection("hk_snapshot_data_monitor"); |
| | | long distinctCount = collection.distinct("externalIndexCode", String.class).into(new ArrayList<>()).size(); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", Arrays.asList(one, two, three, four)); |
| | | map.put("count", Arrays.asList(distinctCount)); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |
| | |
| | | long total = mongoTemplate.count(query, MonitorQualifyResult.class); |
| | | MongoUtil.setPage(query, params, TIME_FIELD); |
| | | List<MonitorQualifyResult> resultList = mongoTemplate.find(query, MonitorQualifyResult.class); |
| | | // 统计数 |
| | | long nonNetwork = mongoTemplate.count(new Query().addCriteria(Criteria.where("LWSX").is("0")), MonitorQualifyResult.class); |
| | | long network = mongoTemplate.count(new Query().addCriteria(Criteria.where("LWSX").is("1")), MonitorQualifyResult.class); |
| | | long video = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*1.*")), MonitorQualifyResult.class); |
| | | long car = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*2.*")), MonitorQualifyResult.class); |
| | | long face = mongoTemplate.count(new Query().addCriteria(Criteria.where("SXJGNLX").regex(".*3.*")), MonitorQualifyResult.class); |
| | | |
| | | // 统计数量 |
| | | MongoDatabase database = mongoTemplate.getDb(); |
| | | MongoCollection<Document> collection = database.getCollection("uy_monitor_qualify"); |
| | | |
| | | Document ipErrFilter = new Document("ip.error", true); |
| | | Document macdzErrFilter = new Document("macdz.error", true); |
| | | Document latitudeErrFilter = new Document("latitude.error", true); |
| | | Document longitudeErrFilter = new Document("longitude.error", true); |
| | | |
| | | List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter); |
| | | List<Integer> rList = lists.stream().map(filter -> { |
| | | // 构建聚合管道 |
| | | List<Document> pipeline = Arrays.asList( |
| | | new Document("$match", filter), |
| | | // $group 去重 |
| | | new Document("$group", new Document("_id", "$serialNumber.showValue")), |
| | | new Document("$count", "uniqueDeviceIds") |
| | | ); |
| | | // 执行聚合查询并获取结果 |
| | | AggregateIterable<Document> result = collection.aggregate(pipeline); |
| | | Integer uniqueDeviceIdCount = 0; |
| | | for (Document doc : result) { |
| | | uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds"); |
| | | break; // 不需要继续遍历,因为 $count 只会产生一个结果 |
| | | } |
| | | return uniqueDeviceIdCount; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", Arrays.asList(nonNetwork, network, video, car, face)); |
| | | map.put("count", rList); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |
| | |
| | | long total = mongoTemplate.count(query, CrossDetailResult.class); |
| | | MongoUtil.setPage(query, params, TIME_FIELD); |
| | | List<CrossDetailResult> resultList = mongoTemplate.find(query, CrossDetailResult.class); |
| | | // 统计数 |
| | | long one = mongoTemplate.count(new Query().addCriteria(Criteria.where("lalType").is("1")), CrossDetailResult.class); |
| | | long two = mongoTemplate.count(new Query().addCriteria(Criteria.where("lalType").is("2")), CrossDetailResult.class); |
| | | long three = mongoTemplate.count(new Query().addCriteria(Criteria.where("lalType").is("3")), CrossDetailResult.class); |
| | | long four = mongoTemplate.count(new Query().addCriteria(Criteria.where("lalType").is("4")), CrossDetailResult.class); |
| | | |
| | | // 统计数量 |
| | | MongoDatabase database = mongoTemplate.getDb(); |
| | | MongoCollection<Document> collection = database.getCollection("hk_cross_detail"); |
| | | |
| | | Document ipErrFilter = new Document("lalType", 1); |
| | | Document macdzErrFilter = new Document("lalType", 2); |
| | | Document latitudeErrFilter = new Document("lalType", 3); |
| | | Document longitudeErrFilter = new Document("lalType", 4); |
| | | |
| | | List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter); |
| | | List<Integer> rList = lists.stream().map(filter -> { |
| | | // 构建聚合管道 |
| | | List<Document> pipeline = Arrays.asList( |
| | | new Document("$match", filter), |
| | | // $group 去重 |
| | | new Document("$group", new Document("_id", "$externalIndexCode")), |
| | | new Document("$count", "uniqueDeviceIds") |
| | | ); |
| | | // 执行聚合查询并获取结果 |
| | | AggregateIterable<Document> result = collection.aggregate(pipeline); |
| | | Integer uniqueDeviceIdCount = 0; |
| | | for (Document doc : result) { |
| | | uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds"); |
| | | break; // 不需要继续遍历,因为 $count 只会产生一个结果 |
| | | } |
| | | return uniqueDeviceIdCount; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("count", Arrays.asList(one, two, three, four)); |
| | | map.put("count", rList); |
| | | map.put("list", resultList); |
| | | return Result.ok().data(map).total(total); |
| | | } |