From f8889f7364adae89e45a5ec3fcf4b38e430cf389 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期二, 10 九月 2024 10:41:18 +0800 Subject: [PATCH] 工单详情 --- ycl-server/src/main/java/com/ycl/platform/service/impl/DataCenterServiceImpl.java | 723 +++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 484 insertions(+), 239 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 39fb39a..7d463d4 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 @@ -11,6 +11,7 @@ import com.ycl.platform.domain.query.DataCenterQuery; import com.ycl.platform.domain.result.HK.*; import com.ycl.platform.domain.result.UY.*; +import com.ycl.platform.domain.vo.PointDetailVO; import com.ycl.platform.mapper.ImageResourceSecurityDetailMapper; import com.ycl.platform.mapper.YwPointMapper; import com.ycl.platform.service.*; @@ -18,6 +19,7 @@ import com.ycl.system.page.PageUtil; import com.ycl.utils.DateUtils; import com.ycl.utils.MongoUtil; +import constant.CheckConstants; import lombok.RequiredArgsConstructor; import org.apache.commons.collections.CollectionUtils; import org.bson.Document; @@ -30,6 +32,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; +import java.text.DecimalFormat; import java.util.*; import java.util.stream.Collectors; @@ -53,6 +56,8 @@ private final static String TIME_FIELD = "mongoCreateTime"; + private static DecimalFormat DF = new DecimalFormat("#.####"); + /** * 瑙嗛锛氱偣浣嶅湪绾跨巼 * @@ -61,19 +66,14 @@ */ @Override public Result videoPointOnlineRate(DataCenterQuery params) { - // 鐢熸垚鏌ヨ - List<String> likeFileds = Arrays.asList("arealayerName", "ipAddr", "deviceName", "deviceId"); - Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, null); + params.setDeptTag(-1); + params.setDeviceType(1); + IPage<PointDetailVO> page = PageUtil.getPage(params, PointDetailVO.class); + pointMapper.dataCenterPage(page, params); - // 鍏堟煡鎬绘暟鍐嶅垎椤� - long total = mongoTemplate.count(query, VideoOnlineResult.class); - MongoUtil.setPage(query, params, TIME_FIELD); - List<VideoOnlineResult> resultList = mongoTemplate.find(query, VideoOnlineResult.class); + // 缁熻璁惧鏁伴噺 + Integer distinctCount = pointMapper.distinctCount(params); - // 缁熻鏁伴噺 - 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) @@ -86,9 +86,9 @@ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } HashMap<String, Object> map = new HashMap<>(); - map.put("count", Arrays.asList(distinctCount + "",onlineRate + "%")); - map.put("list", resultList); - return Result.ok().data(map).total(total); + map.put("count", Arrays.asList(distinctCount + "",this.remove0(onlineRate))); + map.put("list", page.getRecords()); + return Result.ok().data(map).total(page.getTotal()); } /** @@ -99,38 +99,18 @@ */ @Override public Result deptVideoPointOnlineRate(DataCenterQuery params) { + params.setDeptTag(1); + params.setDeviceType(1); + IPage<PointDetailVO> page = PageUtil.getPage(params, PointDetailVO.class); + pointMapper.dataCenterPage(page, params); - List<String> likeFileds = Arrays.asList("arealayerName", "ipAddr", "deviceName", "deviceId"); - // 鐢熸垚鏌ヨ - Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, 1); + // 缁熻璁惧鏁伴噺 + Integer distinctCount = pointMapper.distinctCount(params); - // 鍏堟煡鎬绘暟鍐嶅垎椤� - long total = mongoTemplate.count(query, VideoOnlineResult.class); - 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("deptTag", new Document("$eq", Boolean.TRUE)); - // 鏋勫缓鑱氬悎绠¢亾 - 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 鍙細浜х敓涓�涓粨鏋� - } Date now = new Date(); List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) .select(CheckIndexVideo::getMinistrySiteOnline) + .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -140,9 +120,9 @@ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } HashMap<String, Object> map = new HashMap<>(); - map.put("count", Arrays.asList(uniqueDeviceIdCount + "", onlineRate + "%")); - map.put("list", resultList); - return Result.ok().data(map).total(total); + map.put("count", Arrays.asList(distinctCount + "", this.remove0(onlineRate))); + map.put("list", page.getRecords()); + return Result.ok().data(map).total(page.getTotal()); } /** @@ -153,35 +133,18 @@ */ @Override public Result videoImportantPointOnlineRate(DataCenterQuery params) { - List<String> likeFileds = Arrays.asList("arealayerName", "ipAddr", "deviceName", "deviceId"); - Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, 3); + params.setDeptTag(3); + params.setDeviceType(1); + IPage<PointDetailVO> page = PageUtil.getPage(params, PointDetailVO.class); + pointMapper.dataCenterPage(page, params); - long total = mongoTemplate.count(query, VideoOnlineResult.class); - 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("importantTag", new Document("$eq", Boolean.TRUE)); - // 鏋勫缓鑱氬悎绠¢亾 - 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 鍙細浜х敓涓�涓粨鏋� - } + // 缁熻璁惧鏁伴噺 + Integer distinctCount = pointMapper.distinctCount(params); Date now = new Date(); List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) .select(CheckIndexVideo::getKeySiteOnline) + .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -191,9 +154,9 @@ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } HashMap<String, Object> map = new HashMap<>(); - map.put("count", Arrays.asList(uniqueDeviceIdCount + "", onlineRate + "%")); - map.put("list", resultList); - return Result.ok().data(map).total(total); + map.put("count", Arrays.asList(distinctCount + "", this.remove0(onlineRate))); + map.put("list", page.getRecords()); + return Result.ok().data(map).total(page.getTotal()); } /** @@ -204,35 +167,18 @@ */ @Override public Result videoImportantPointImageOnlineRate(DataCenterQuery params) { - List<String> likeFileds = Arrays.asList("arealayerName", "ipAddr", "deviceName", "deviceId"); - Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, 4); + params.setDeptTag(4); + params.setDeviceType(1); + IPage<PointDetailVO> page = PageUtil.getPage(params, PointDetailVO.class); + pointMapper.dataCenterPage(page, params); - long total = mongoTemplate.count(query, VideoOnlineResult.class); - 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("importantCommandImageTag", new Document("$eq", Boolean.TRUE)); - // 鏋勫缓鑱氬悎绠¢亾 - 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 鍙細浜х敓涓�涓粨鏋� - } + // 缁熻璁惧鏁伴噺 + Integer distinctCount = pointMapper.distinctCount(params); Date now = new Date(); List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) .select(CheckIndexVideo::getKeyCommandImageOnline) + .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -242,9 +188,9 @@ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } HashMap<String, Object> map = new HashMap<>(); - map.put("count", Arrays.asList(uniqueDeviceIdCount + "", onlineRate + "%")); - map.put("list", resultList); - return Result.ok().data(map).total(total); + map.put("count", Arrays.asList(distinctCount + "", this.remove0(onlineRate))); + map.put("list", page.getRecords()); + return Result.ok().data(map).total(page.getTotal()); } /** @@ -266,10 +212,30 @@ 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> dList1 = new ArrayList<>(2); + dList1.add(new Document("ip.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList1.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList2 = new ArrayList<>(2); + dList2.add(new Document("macdz.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList2.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList3 = new ArrayList<>(2); + dList3.add(new Document("latitude.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList3.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList4 = new ArrayList<>(2); + dList4.add(new Document("longitude.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList4.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document ipErrFilter = new Document("$and", dList1); + Document macdzErrFilter = new Document("$and", dList2); + Document latitudeErrFilter = new Document("$and", dList3); + Document longitudeErrFilter = new Document("$and", dList4); List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter); List<String> rList = lists.stream().map(filter -> { @@ -293,6 +259,7 @@ Date now = new Date(); List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) .select(CheckIndexVideo::getMonitorRegistration) + .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -301,7 +268,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - rList.add(onlineRate + "%"); + rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); map.put("list", resultList); @@ -327,10 +294,30 @@ 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> dList1 = new ArrayList<>(2); + dList1.add(new Document("ip.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList1.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList2 = new ArrayList<>(2); + dList2.add(new Document("macdz.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList2.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList3 = new ArrayList<>(2); + dList3.add(new Document("latitude.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList3.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList4 = new ArrayList<>(2); + dList4.add(new Document("longitude.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList4.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document ipErrFilter = new Document("$and", dList1); + Document macdzErrFilter = new Document("$and", dList2); + Document latitudeErrFilter = new Document("$and", dList3); + Document longitudeErrFilter = new Document("$and", dList4); List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter); List<String> rList = lists.stream().map(filter -> { @@ -354,6 +341,7 @@ Date now = new Date(); List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) .select(CheckIndexVideo::getMonitorQualification) + .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -362,7 +350,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - rList.add(onlineRate + "%"); + rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); map.put("list", resultList); @@ -389,10 +377,30 @@ 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> dList1 = new ArrayList<>(2); + dList1.add(new Document("ip.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList1.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList2 = new ArrayList<>(2); + dList2.add(new Document("macdz.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList2.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList3 = new ArrayList<>(2); + dList3.add(new Document("latitude.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList3.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList4 = new ArrayList<>(2); + dList4.add(new Document("longitude.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList4.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document ipErrFilter = new Document("$and", dList1); + Document macdzErrFilter = new Document("$and", dList2); + Document latitudeErrFilter = new Document("$and", dList3); + Document longitudeErrFilter = new Document("$and", dList4); List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter); List<String> rList = lists.stream().map(filter -> { @@ -440,7 +448,12 @@ MongoCollection<Document> collection = database.getCollection("uy_record_meta_d_sum"); List<Integer> status = Arrays.asList(1, 0, -1); List<String> resultCount = status.stream().map(item -> { - Document filter = new Document("recordStatus", item); + List<Document> dList = new ArrayList<>(2); + dList.add(new Document("recordStatus", new Document("$eq", item))); + if (params.getDataType().equals(1)) { + dList.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document filter = new Document("$and", dList); // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( new Document("$match", filter), @@ -461,6 +474,7 @@ Date now = new Date(); List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) .select(CheckIndexVideo::getVideoAvailable) + .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -469,7 +483,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - resultCount.add(onlineRate + "%"); + resultCount.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", resultCount); map.put("list", resultList); @@ -496,10 +510,13 @@ MongoCollection<Document> collection = database.getCollection("uy_record_meta_d_sum"); List<Integer> status = Arrays.asList(1, 0, -1); List<String> resultCount = status.stream().map(item -> { - Document filter = new Document("$and", Arrays.asList( - new Document("deptTag", new Document("$eq", Boolean.TRUE)), - new Document("recordStatus", item) - )); + List<Document> dList = new ArrayList<>(4); + dList.add(new Document("deptTag", new Document("$eq", Boolean.TRUE))); + dList.add(new Document("recordStatus", new Document("$eq", item))); + if (params.getDataType().equals(1)) { + dList.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document filter = new Document("$and", dList); // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( new Document("$match", filter), @@ -520,6 +537,7 @@ Date now = new Date(); List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) .select(CheckIndexVideo::getMinistryVideoAvailable) + .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -528,7 +546,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - resultCount.add(onlineRate + "%"); + resultCount.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", resultCount); map.put("list", resultList); @@ -555,10 +573,13 @@ MongoCollection<Document> collection = database.getCollection("uy_record_meta_d_sum"); List<Integer> status = Arrays.asList(1, 0, -1); List<String> resultCount = status.stream().map(item -> { - Document filter = new Document("$and", Arrays.asList( - new Document("importantTag", new Document("$eq", Boolean.TRUE)), - new Document("recordStatus", item) - )); + List<Document> dList = new ArrayList<>(4); + dList.add(new Document("importantTag", new Document("$eq", Boolean.TRUE))); + dList.add(new Document("recordStatus", new Document("$eq", item))); + if (params.getDataType().equals(1)) { + dList.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document filter = new Document("$and", dList); // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( new Document("$match", filter), @@ -579,6 +600,7 @@ Date now = new Date(); List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) .select(CheckIndexVideo::getKeyVideoAvailable) + .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -587,7 +609,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - resultCount.add(onlineRate + "%"); + resultCount.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", resultCount); map.put("list", resultList); @@ -638,11 +660,34 @@ MongoDatabase database = mongoTemplate.getDb(); MongoCollection<Document> collection = database.getCollection("osd_check_result"); - Document importantTag = new Document("importantTag", Boolean.TRUE); - Document osdNameFilter = new Document("$and", Arrays.asList(new Document("osdNameCorrect", 1), importantTag)); - Document osdNameErrFilter = new Document("$and", Arrays.asList(new Document("osdNameCorrect", -1), importantTag)); - Document osdTimeFilter = new Document("$and", Arrays.asList(new Document("osdTimeCorrect", 1), importantTag)); - Document osdTimeErrFilter = new Document("$and", Arrays.asList(new Document("osdTimeCorrect", -1), importantTag)); + List<Document> dList1 = new ArrayList<>(2); + dList1.add(new Document("importantTag", Boolean.TRUE)); + dList1.add(new Document("osdNameCorrect", new Document("$eq", 1))); + if (params.getDataType().equals(1)) { + dList1.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList2 = new ArrayList<>(2); + dList2.add(new Document("importantTag", Boolean.TRUE)); + dList2.add(new Document("osdNameCorrect", new Document("$eq", -1))); + if (params.getDataType().equals(1)) { + dList2.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList3 = new ArrayList<>(2); + dList3.add(new Document("importantTag", Boolean.TRUE)); + dList3.add(new Document("osdTimeCorrect", new Document("$eq", 1))); + if (params.getDataType().equals(1)) { + dList3.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList4 = new ArrayList<>(2); + dList4.add(new Document("importantTag", Boolean.TRUE)); + dList4.add(new Document("osdTimeCorrect", new Document("$eq", -1))); + if (params.getDataType().equals(1)) { + dList4.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document osdNameFilter = new Document("$and", dList1); + Document osdNameErrFilter = new Document("$and", dList2); + Document osdTimeFilter = new Document("$and", dList3); + Document osdTimeErrFilter = new Document("$and", dList4); List<Document> lists = Arrays.asList(osdNameFilter, osdNameErrFilter, osdTimeFilter, osdTimeErrFilter); List<String> rList = lists.stream().map(filter -> { // 鏋勫缓鑱氬悎绠¢亾 @@ -665,6 +710,7 @@ Date now = new Date(); List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) .select(CheckIndexVideo::getKeyAnnotationAccuracy) + .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -673,7 +719,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - rList.add(onlineRate + "%"); + rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); map.put("list", resultList); @@ -726,9 +772,20 @@ MongoDatabase database = mongoTemplate.getDb(); MongoCollection<Document> collection = database.getCollection("osd_check_result"); - Document importantTag = new Document("importantTag", Boolean.TRUE); - Document osdTimeFilter = new Document("$and", Arrays.asList(new Document("osdTimeCorrect", 1), importantTag)); - Document osdTimeErrFilter = new Document("$and", Arrays.asList(new Document("osdTimeCorrect", -1), importantTag)); + List<Document> dList1 = new ArrayList<>(2); + dList1.add(new Document("importantTag", Boolean.TRUE)); + dList1.add(new Document("osdTimeCorrect", new Document("$eq", 1))); + if (params.getDataType().equals(1)) { + dList1.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList2 = new ArrayList<>(2); + dList2.add(new Document("importantTag", Boolean.TRUE)); + dList2.add(new Document("osdTimeCorrect", new Document("$eq", -1))); + if (params.getDataType().equals(1)) { + dList2.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document osdTimeFilter = new Document("$and", dList1); + Document osdTimeErrFilter = new Document("$and", dList2); List<Document> lists = Arrays.asList(osdTimeFilter, osdTimeErrFilter); List<String> rList = lists.stream().map(filter -> { // 鏋勫缓鑱氬悎绠¢亾 @@ -751,6 +808,7 @@ Date now = new Date(); List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) .select(CheckIndexVideo::getKeyTimingAccuracy) + .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -759,7 +817,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - rList.add(onlineRate + "%"); + rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); map.put("list", resultList); @@ -786,10 +844,34 @@ 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> dList1 = new ArrayList<>(2); + dList1.add(new Document("importantTag", Boolean.TRUE)); + dList1.add(new Document("resultType", new Document("$eq", 1))); + if (params.getDataType().equals(1)) { + dList1.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList2 = new ArrayList<>(2); + dList2.add(new Document("importantTag", Boolean.TRUE)); + dList2.add(new Document("resultType", new Document("$eq", 2))); + if (params.getDataType().equals(1)) { + dList2.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList3 = new ArrayList<>(2); + dList3.add(new Document("importantTag", Boolean.TRUE)); + dList3.add(new Document("resultType", new Document("$eq", 3))); + if (params.getDataType().equals(1)) { + dList3.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList4 = new ArrayList<>(2); + dList4.add(new Document("importantTag", Boolean.TRUE)); + dList4.add(new Document("resultType", new Document("$eq", 4))); + if (params.getDataType().equals(1)) { + dList4.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document normalFilter = new Document("$and", dList1); + Document noDataFilter = new Document("$and", dList2); + Document trFilter = new Document("$and", dList3); + Document littleFilter = new Document("$and", dList4); List<Document> lists = Arrays.asList(normalFilter, noDataFilter, trFilter, littleFilter); List<String> rList = lists.stream().map(filter -> { // 鏋勫缓鑱氬悎绠¢亾 @@ -812,6 +894,7 @@ Date now = new Date(); List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) .select(CheckIndexCar::getViewConnectStability) + .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -820,7 +903,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - rList.add(onlineRate + "%"); + rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); map.put("list", resultList); @@ -835,21 +918,18 @@ */ @Override public Result vehiclePointOnlineRate(DataCenterQuery params) { - List<String> likeFileds = Arrays.asList("externalIndexCode", "deviceName"); - Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, null); + params.setDeptTag(-1); + params.setDeviceType(2); + IPage<PointDetailVO> page = PageUtil.getPage(params, PointDetailVO.class); + pointMapper.dataCenterPage(page, params); - long total = mongoTemplate.count(query, SnapshotDataMonitorResult.class); - MongoUtil.setPage(query, params, TIME_FIELD); - List<SnapshotDataMonitorResult> resultList = mongoTemplate.find(query, 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(); + // 缁熻璁惧鏁伴噺 + Integer distinctCount = pointMapper.distinctCount(params); Date now = new Date(); List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) .select(CheckIndexCar::getSiteOnline) + .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -859,9 +939,9 @@ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } HashMap<String, Object> map = new HashMap<>(); - map.put("count", Arrays.asList(distinctCount + "%", onlineRate + "%")); - map.put("list", resultList); - return Result.ok().data(map).total(total); + map.put("count", Arrays.asList(distinctCount + "", this.remove0(onlineRate))); + map.put("list", page.getRecords()); + return Result.ok().data(map).total(page.getTotal()); } /** @@ -883,11 +963,30 @@ 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> dList1 = new ArrayList<>(2); + dList1.add(new Document("ip.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList1.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList2 = new ArrayList<>(2); + dList2.add(new Document("macdz.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList2.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList3 = new ArrayList<>(2); + dList3.add(new Document("latitude.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList3.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList4 = new ArrayList<>(2); + dList4.add(new Document("longitude.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList4.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document ipErrFilter = new Document("$and", dList1); + Document macdzErrFilter = new Document("$and", dList2); + Document latitudeErrFilter = new Document("$and", dList3); + Document longitudeErrFilter = new Document("$and", dList4); List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter); List<String> rList = lists.stream().map(filter -> { // 鏋勫缓鑱氬悎绠¢亾 @@ -904,12 +1003,13 @@ uniqueDeviceIdCount = doc.getInteger("uniqueDeviceIds"); break; // 涓嶉渶瑕佺户缁亶鍘嗭紝鍥犱负 $count 鍙細浜х敓涓�涓粨鏋� } - return uniqueDeviceIdCount + "%"; + return uniqueDeviceIdCount + ""; }).collect(Collectors.toList()); Date now = new Date(); List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) .select(CheckIndexCar::getDeviceDirectoryConsistent) + .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -918,7 +1018,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - rList.add(onlineRate + "%"); + rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); map.put("list", resultList); @@ -944,10 +1044,30 @@ 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> dList1 = new ArrayList<>(2); + dList1.add(new Document("lalType", new Document("$eq", 1))); + if (params.getDataType().equals(1)) { + dList1.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList2 = new ArrayList<>(2); + dList2.add(new Document("lalType", new Document("$eq", 2))); + if (params.getDataType().equals(1)) { + dList2.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList3 = new ArrayList<>(2); + dList3.add(new Document("lalType", new Document("$eq", 3))); + if (params.getDataType().equals(1)) { + dList3.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList4 = new ArrayList<>(2); + dList4.add(new Document("lalType", new Document("$eq", 4))); + if (params.getDataType().equals(1)) { + dList4.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document ipErrFilter = new Document("$and", dList1); + Document macdzErrFilter = new Document("$and", dList2); + Document latitudeErrFilter = new Document("$and", dList3); + Document longitudeErrFilter = new Document("$and", dList4); List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter); List<String> rList = lists.stream().map(filter -> { @@ -971,6 +1091,7 @@ Date now = new Date(); List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) .select(CheckIndexCar::getVehicleInformationCollectionAccuracy) + .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -979,7 +1100,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - rList.add(onlineRate + "%"); + rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); map.put("list", resultList); @@ -1008,6 +1129,7 @@ Date now = new Date(); List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) .select(CheckIndexCar::getVehicleCaptureIntegrity) + .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -1018,7 +1140,7 @@ } HashMap<String, Object> map = new HashMap<>(); - map.put("count", Arrays.asList(onlineRate + "%")); + map.put("count", Arrays.asList(this.remove0(onlineRate))); map.put("list", resultList); return Result.ok().data(map).total(total); } @@ -1041,6 +1163,7 @@ Date now = new Date(); List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) .select(CheckIndexCar::getVehicleCaptureAccuracy) + .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -1050,7 +1173,7 @@ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } HashMap<String, Object> map = new HashMap<>(); - map.put("count", Arrays.asList(onlineRate + "%")); + map.put("count", Arrays.asList(this.remove0(onlineRate))); map.put("list", resultList); return Result.ok().data(map).total(total); } @@ -1075,9 +1198,24 @@ MongoDatabase database = mongoTemplate.getDb(); MongoCollection<Document> collection = database.getCollection("hk_vehicle_device_inspection"); - Document ipErrFilter = new Document("snapResult", 1); - Document macdzErrFilter = new Document("snapResult", 2); - Document longitudeErrFilter = new Document("snapResult", 4); + List<Document> dList1 = new ArrayList<>(2); + dList1.add(new Document("snapResult", new Document("$eq", 1))); + if (params.getDataType().equals(1)) { + dList1.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList2 = new ArrayList<>(2); + dList2.add(new Document("snapResult", new Document("$eq", 2))); + if (params.getDataType().equals(1)) { + dList2.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList3 = new ArrayList<>(2); + dList3.add(new Document("snapResult", new Document("$eq", 4))); + if (params.getDataType().equals(1)) { + dList3.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document ipErrFilter = new Document("$and", dList1); + Document macdzErrFilter = new Document("$and", dList2); + Document longitudeErrFilter = new Document("$and", dList3); List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, longitudeErrFilter); List<String> rList = lists.stream().map(filter -> { @@ -1101,6 +1239,7 @@ Date now = new Date(); List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) .select(CheckIndexCar::getVehicleTimingAccuracy) + .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -1109,7 +1248,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - rList.add(onlineRate + "%"); + rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); map.put("list", resultList); @@ -1135,6 +1274,7 @@ Date now = new Date(); List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) .select(CheckIndexCar::getVehicleUploadTimeliness) + .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -1144,7 +1284,7 @@ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } HashMap<String, Object> map = new HashMap<>(); - map.put("count", Arrays.asList(onlineRate + "%")); + map.put("count", Arrays.asList(this.remove0(onlineRate))); map.put("list", resultList); return Result.ok().data(map).total(total); } @@ -1168,6 +1308,7 @@ Date now = new Date(); List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) .select(CheckIndexCar::getVehicleUrlAvailability) + .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -1177,7 +1318,7 @@ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } HashMap<String, Object> map = new HashMap<>(); - map.put("count", Arrays.asList(onlineRate + "%")); + map.put("count", Arrays.asList(this.remove0(onlineRate))); map.put("list", resultList); return Result.ok().data(map).total(total); } @@ -1201,6 +1342,7 @@ Date now = new Date(); List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) .select(CheckIndexCar::getVehiclePictureAvailability) + .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -1210,7 +1352,7 @@ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } HashMap<String, Object> map = new HashMap<>(); - map.put("count", Arrays.asList(onlineRate + "%")); + map.put("count", Arrays.asList(this.remove0(onlineRate))); map.put("list", resultList); return Result.ok().data(map).total(total); } @@ -1234,10 +1376,30 @@ 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> dList1 = new ArrayList<>(2); + dList1.add(new Document("resultType", new Document("$eq", 1))); + if (params.getDataType().equals(1)) { + dList1.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList2 = new ArrayList<>(2); + dList2.add(new Document("resultType", new Document("$eq", 2))); + if (params.getDataType().equals(1)) { + dList2.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList3 = new ArrayList<>(2); + dList3.add(new Document("resultType", new Document("$eq", 3))); + if (params.getDataType().equals(1)) { + dList3.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList4 = new ArrayList<>(2); + dList4.add(new Document("resultType", new Document("$eq", 4))); + if (params.getDataType().equals(1)) { + dList4.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document normalFilter = new Document("$and", dList1); + Document noDataFilter = new Document("$and", dList2); + Document trFilter = new Document("$and", dList3); + Document littleFilter = new Document("$and", dList4); List<Document> lists = Arrays.asList(normalFilter, noDataFilter, trFilter, littleFilter); List<String> rList = lists.stream().map(filter -> { // 鏋勫缓鑱氬悎绠¢亾 @@ -1260,6 +1422,7 @@ Date now = new Date(); List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) .select(CheckIndexFace::getViewConnectStability) + .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -1268,7 +1431,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - rList.add(onlineRate + "%"); + rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); map.put("list", resultList); @@ -1283,43 +1446,18 @@ */ @Override public Result facePointOnlineRate(DataCenterQuery params) { - List<String> likeFileds = Arrays.asList("externalIndexCode", "deviceName"); - Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, null); + params.setDeptTag(-1); + params.setDeviceType(3); + IPage<PointDetailVO> page = PageUtil.getPage(params, PointDetailVO.class); + pointMapper.dataCenterPage(page, params); - long total = mongoTemplate.count(query, SnapshotDataMonitorResult.class); - MongoUtil.setPage(query, params, TIME_FIELD); - List<SnapshotDataMonitorResult> resultList = mongoTemplate.find(query, 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<String> 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()); + // 缁熻璁惧鏁伴噺 + Integer distinctCount = pointMapper.distinctCount(params); Date now = new Date(); List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) .select(CheckIndexFace::getSiteOnline) + .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -1328,11 +1466,13 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - rList.add(onlineRate + "%"); + List<String> rList = new ArrayList<>(2); + rList.add(distinctCount + ""); + rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); - map.put("list", resultList); - return Result.ok().data(map).total(total); + map.put("list", page.getRecords()); + return Result.ok().data(map).total(page.getTotal()); } /** @@ -1354,11 +1494,30 @@ 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> dList1 = new ArrayList<>(2); + dList1.add(new Document("ip.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList1.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList2 = new ArrayList<>(2); + dList2.add(new Document("macdz.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList2.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList3 = new ArrayList<>(2); + dList3.add(new Document("latitude.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList3.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList4 = new ArrayList<>(2); + dList4.add(new Document("longitude.error", new Document("$eq", Boolean.TRUE))); + if (params.getDataType().equals(1)) { + dList4.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document ipErrFilter = new Document("$and", dList1); + Document macdzErrFilter = new Document("$and", dList2); + Document latitudeErrFilter = new Document("$and", dList3); + Document longitudeErrFilter = new Document("$and", dList4); List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter); List<String> rList = lists.stream().map(filter -> { // 鏋勫缓鑱氬悎绠¢亾 @@ -1381,6 +1540,7 @@ Date now = new Date(); List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) .select(CheckIndexFace::getDeviceDirectoryConsistent) + .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -1389,7 +1549,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - rList.add(onlineRate + "%"); + rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); map.put("list", resultList); @@ -1415,11 +1575,30 @@ 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> dList1 = new ArrayList<>(2); + dList1.add(new Document("lalType", new Document("$eq", 1))); + if (params.getDataType().equals(1)) { + dList1.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList2 = new ArrayList<>(2); + dList2.add(new Document("lalType", new Document("$eq", 2))); + if (params.getDataType().equals(1)) { + dList2.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList3 = new ArrayList<>(2); + dList3.add(new Document("lalType", new Document("$eq", 3))); + if (params.getDataType().equals(1)) { + dList3.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList4 = new ArrayList<>(2); + dList4.add(new Document("lalType", new Document("$eq", 4))); + if (params.getDataType().equals(1)) { + dList4.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document ipErrFilter = new Document("$and", dList1); + Document macdzErrFilter = new Document("$and", dList2); + Document latitudeErrFilter = new Document("$and", dList3); + Document longitudeErrFilter = new Document("$and", dList4); List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter); List<String> rList = lists.stream().map(filter -> { // 鏋勫缓鑱氬悎绠¢亾 @@ -1442,6 +1621,7 @@ Date now = new Date(); List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) .select(CheckIndexFace::getFaceInformationCollectionAccuracy) + .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -1450,7 +1630,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - rList.add(onlineRate + "%"); + rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); map.put("list", resultList); @@ -1476,10 +1656,30 @@ MongoDatabase database = mongoTemplate.getDb(); MongoCollection<Document> collection = database.getCollection("hk_monitoring_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> dList1 = new ArrayList<>(2); + dList1.add(new Document("lalType", new Document("$eq", 1))); + if (params.getDataType().equals(1)) { + dList1.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList2 = new ArrayList<>(2); + dList2.add(new Document("lalType", new Document("$eq", 2))); + if (params.getDataType().equals(1)) { + dList2.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList3 = new ArrayList<>(2); + dList3.add(new Document("lalType", new Document("$eq", 3))); + if (params.getDataType().equals(1)) { + dList3.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList4 = new ArrayList<>(2); + dList4.add(new Document("lalType", new Document("$eq", 4))); + if (params.getDataType().equals(1)) { + dList4.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document ipErrFilter = new Document("$and", dList1); + Document macdzErrFilter = new Document("$and", dList2); + Document latitudeErrFilter = new Document("$and", dList3); + Document longitudeErrFilter = new Document("$and", dList4); List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, latitudeErrFilter, longitudeErrFilter); List<String> rList = lists.stream().map(filter -> { @@ -1503,6 +1703,7 @@ Date now = new Date(); List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) .select(CheckIndexFace::getFacePictureQualification) + .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -1511,7 +1712,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - rList.add(onlineRate + "%"); + rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); map.put("list", resultList); @@ -1537,9 +1738,24 @@ MongoDatabase database = mongoTemplate.getDb(); MongoCollection<Document> collection = database.getCollection("hk_vehicle_device_inspection"); - Document ipErrFilter = new Document("snapResult", 1); - Document macdzErrFilter = new Document("snapResult", 2); - Document longitudeErrFilter = new Document("snapResult", 4); + List<Document> dList1 = new ArrayList<>(2); + dList1.add(new Document("snapResult", new Document("$eq", 1))); + if (params.getDataType().equals(1)) { + dList1.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList2 = new ArrayList<>(2); + dList2.add(new Document("snapResult", new Document("$eq", 2))); + if (params.getDataType().equals(1)) { + dList2.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList3 = new ArrayList<>(2); + dList3.add(new Document("snapResult", new Document("$eq", 4))); + if (params.getDataType().equals(1)) { + dList3.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document ipErrFilter = new Document("$and", dList1); + Document macdzErrFilter = new Document("$and", dList2); + Document longitudeErrFilter = new Document("$and", dList3); List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, longitudeErrFilter); List<String> rList = lists.stream().map(filter -> { @@ -1563,6 +1779,7 @@ Date now = new Date(); List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) .select(CheckIndexFace::getFaceTimingAccuracy) + .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -1571,7 +1788,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - rList.add(onlineRate + "%"); + rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); map.put("list", resultList); @@ -1597,9 +1814,24 @@ MongoDatabase database = mongoTemplate.getDb(); MongoCollection<Document> collection = database.getCollection("hk_vehicle_device_inspection"); - Document ipErrFilter = new Document("snapResult", 1); - Document macdzErrFilter = new Document("snapResult", 2); - Document longitudeErrFilter = new Document("snapResult", 4); + List<Document> dList1 = new ArrayList<>(2); + dList1.add(new Document("snapResult", new Document("$eq", 1))); + if (params.getDataType().equals(1)) { + dList1.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList2 = new ArrayList<>(2); + dList2.add(new Document("snapResult", new Document("$eq", 2))); + if (params.getDataType().equals(1)) { + dList2.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + List<Document> dList3 = new ArrayList<>(2); + dList3.add(new Document("snapResult", new Document("$eq", 4))); + if (params.getDataType().equals(1)) { + dList3.add(new Document("provinceTag", new Document("$eq", Boolean.TRUE))); + } + Document ipErrFilter = new Document("$and", dList1); + Document macdzErrFilter = new Document("$and", dList2); + Document longitudeErrFilter = new Document("$and", dList3); List<Document> lists = Arrays.asList(ipErrFilter, macdzErrFilter, longitudeErrFilter); List<String> rList = lists.stream().map(filter -> { @@ -1623,6 +1855,7 @@ Date now = new Date(); List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) .select(CheckIndexFace::getFaceUploadTimeliness) + .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -1631,7 +1864,7 @@ BigDecimal count = BigDecimal.valueOf(videoList.size()); onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } - rList.add(onlineRate + "%"); + rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); map.put("list", resultList); @@ -1657,6 +1890,7 @@ Date now = new Date(); List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) .select(CheckIndexFace::getFacePictureAvailability) + .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(now), DateUtils.getDayEnd(now)) .list(); BigDecimal onlineRate = BigDecimal.ZERO; @@ -1665,8 +1899,9 @@ 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(onlineRate + "%")); + map.put("count", Arrays.asList(this.remove0(onlineRate))); map.put("list", resultList); return Result.ok().data(map).total(total); } @@ -1688,4 +1923,14 @@ return Result.ok().data(map).total(page.getTotal()); } + + /** + * 鍒犻櫎灏鹃儴鐨�0 + * @param rate + * @return + */ + private String remove0(BigDecimal rate) { + DF.setDecimalSeparatorAlwaysShown(false); + return DF.format(rate) + "%"; + } } -- Gitblit v1.8.0