From d49b037cd6d42cff6e8a15b3590a3edac2c4568b Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期五, 06 九月 2024 16:38:55 +0800
Subject: [PATCH] 点位在线监测

---
 ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml                       |   85 +++++++++
 ycl-pojo/src/main/java/com/ycl/platform/domain/query/DataCenterQuery.java         |    6 
 ycl-pojo/src/main/java/com/ycl/platform/domain/vo/PointDetailVO.java              |  167 ++++++++++++++++++
 ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java               |   10 +
 ycl-server/src/main/java/com/ycl/platform/service/impl/DataCenterServiceImpl.java |  234 ++++++--------------------
 5 files changed, 322 insertions(+), 180 deletions(-)

diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/query/DataCenterQuery.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/query/DataCenterQuery.java
index 293fe40..b3f2239 100644
--- a/ycl-pojo/src/main/java/com/ycl/platform/domain/query/DataCenterQuery.java
+++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/query/DataCenterQuery.java
@@ -35,6 +35,12 @@
     /** 鏁版嵁绫诲瀷锛�0 鍏ㄩ儴  1鐪佸巺 */
     private Integer dataType = 0;
 
+    /** 鏍囩锛�1 閮ㄧ骇  2 鐪佸巺  3 閲嶇偣  4 閲嶇偣鎸囨尌鍥惧儚  5 鏂拌澶� */
+    private Integer deptTag;
+
+    /** 1 瑙嗛 2 杞﹁締 3 浜鸿劯 */
+    private Integer deviceType;
+
 
     public void setTime() {
         if (Objects.nonNull(this.startTime)) {
diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/vo/PointDetailVO.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/vo/PointDetailVO.java
new file mode 100644
index 0000000..301ffb3
--- /dev/null
+++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/vo/PointDetailVO.java
@@ -0,0 +1,167 @@
+package com.ycl.platform.domain.vo;
+
+import annotation.Excel;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author锛歺p
+ * @date锛�2024/9/6 15:18
+ */
+@Data
+public class PointDetailVO {
+
+    /**
+     * 璁惧缂栫爜
+     */
+    private String serialNumber;
+
+    /**
+     * 璁惧鍚嶇О
+     */
+    private String name;
+
+    /**
+     * 鐩戞帶鐐逛綅绫诲瀷 [1.涓�绫昏棰戠洃鎺х偣;2.浜岀被瑙嗛鐩戞帶鐐�;3.涓夌被瑙嗛鐩戞帶鐐�;4.鍏畨鍐呴儴瑙嗛鐩戞帶鐐�;9.鍏朵粬鐐逛綅;]
+     */
+    private Long siteType;
+
+    /**
+     * 鎽勫儚鏈篗ac鍦板潃
+     */
+    private String macAddr;
+
+    /**
+     * 鎽勫儚鏈篒PV4鎴朓PV6鍦板潃
+     */
+    private String ip;
+
+    /**
+     * 鎽勫儚鏈哄姛鑳界被鍨媅1.瑙嗛鐩戞帶;2.杞﹁締璇嗗埆;3.浜哄憳璇嗗埆;] 鏁版嵁鏍煎紡[濉叆澶氫釜鍊煎苟浠�/闅斿紑銆備緥濡�  1/2]
+     */
+    private String cameraFunType;
+
+    /**
+     * 璁惧缁忓害锛岃嚦灏戜繚鐣欏叚浣嶅皬鏁�
+     */
+    private String longitude;
+
+    /**
+     * 璁惧缁村害锛岃嚦灏戜繚鐣欏叚浣嶅皬鏁�
+     */
+    private String latitude;
+
+    /**
+     * 鎽勫儚鏈洪噰闆嗗尯鍩熷弬鑰冨瓧鍏歌〃锛屾暟鎹閫変互/闅斿紑
+     */
+    private String cameraCaptureArea;
+
+    /**
+     * 璁惧鐘舵�� 1/2 鍙敤/涓嶅彲鐢�
+     */
+    private Long onState;
+
+    /**
+     * 琛屾斂鍖哄煙
+     */
+    private String civilCode;
+
+    /**
+     * 鏄惁闆嗘垚璁惧锛�0/1 涓嶆槸/鏄�
+     */
+    private Long integratedDevice;
+
+    /**
+     * 鎽勫儚鏈哄搧鐗� [1.娴峰悍濞佽;2.澶у崕;3.澶╁湴浼熶笟;4.绉戣揪;5.瀹夎澹�;6.鍗氫笘;7.浜氬畨;8.鑻遍鎷�;9.瀹囪;10.娴蜂俊;11.涓槦鐢靛瓙;12.鏄庢櫙;13.鑱旀兂;14.涓叴;15.绱㈠凹;16.涓夋槦;99.鍏跺畠;
+     */
+    private Long cameraBrand;
+
+    /**
+     * 瀹夎鍦板潃
+     */
+    private String address;
+
+    /**
+     * 鑱旂綉灞炴�� 0/1 宸茶仈缃�/鏈仈缃�
+     */
+    private Long netWorking;
+
+    /**
+     * 鎵�灞炶緰鍖哄叕瀹夋満鍏�
+     */
+    private String publicSecurity;
+
+    /**
+     * 瀹夎鏃堕棿 yyyy-MM-dd HH:mm:ss
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date installedTime;
+
+    /**
+     * 绠$悊鍗曚綅
+     */
+    private String managementUnit;
+
+    /**
+     * 绠$悊鍗曚綅鑱旂郴鏂瑰紡
+     */
+    private String muContactInfo;
+
+    /**
+     * 褰曡薄淇濆瓨澶╂暟 0 - 2147483647
+     */
+    private Long storageDays;
+
+    /**
+     * 鐩戣鏂逛綅 [1.涓�;2.瑗�;3.鍗�;4.鍖�;5.涓滃崡;6.涓滃寳;7.瑗垮崡;8.瑗垮寳;9.鍏ㄥ悜;]
+     */
+    private Long monitorAzimuth;
+
+    /**
+     * 鎽勫儚鏈哄満鏅璁剧収鐗嘦RL
+     */
+    private String scenePhotoAddr;
+
+    /**
+     * 璁惧鍨嬪彿
+     */
+    private String model;
+
+    /**
+     * 鐐逛綅淇楃О
+     */
+    private String siteVulgo;
+
+    /**
+     * 鎽勫儚鏈虹被鍨� [1.鐞冩満;2.鍗婄悆;3.鍥哄畾鏋満;4.閬ユ帶鏋満;5.鍗″彛鏋満;99.鏈煡;
+     */
+    private Long cameraType;
+
+    /**
+     * 琛ュ厜灞炴�1.鏃犺ˉ鍏�;2.绾㈠琛ュ厜;3.鐧藉厜琛ュ厜;9.鍏朵粬琛ュ厜;]
+     */
+    private Long cameraLightType;
+
+    /**
+     * 鎽勫儚鏈虹紪鐮佹牸寮� [1.MPEG-4;2.H.264;3.SVAC;4.H.265;]
+     */
+    private Long encodedFormat;
+
+    /**
+     * 鎵�灞為儴闂�/琛屼笟 鍙栧�艰寖鍥�(澶氶��) : [1.鍏畨鏈哄叧;2.鐜繚閮ㄩ棬;3.鏂囧崥閮ㄩ棬;4.鍖荤枟閮ㄩ棬;5.鏃呮父绠$悊;6.鏂伴椈骞跨數;7.椋熷搧鍖昏嵂鐩戠潱绠$悊閮ㄩ棬;8.鏁欒偛绠$悊閮ㄩ棬;9.妫�瀵熼櫌;10.娉曢櫌;11.閲戣瀺閮ㄩ棬;12.浜ら�氶儴闂�;13.浣忔埧鍜屽煄涔″缓璁鹃儴闂�;14.姘村埄閮ㄩ棬;15.鏋椾笟閮ㄩ棬;16.瀹夊叏鐢熶骇鐩戠潱閮ㄩ棬;17.甯傛斂甯傚濮�;18.鍥藉湡灞�;] 鏁版嵁鏍煎紡[濉叆澶氫釜鍊煎苟浠�/闅斿紑銆備緥濡�  1/2]
+     */
+    private String cameraDept;
+
+    /**
+     * 琛屼笟缂栫爜 [00.绀句細娌诲畨璺潰鎺ュ叆;01.绀句細娌诲畨绀惧尯鎺ュ叆;02.绀句細娌诲畨鍐呴儴鎺ュ叆;03.绀句細娌诲畨鍏朵粬鎺ュ叆;04.浜ら�氳矾闈㈡帴鍏�;05.浜ら�氬崱鍙f帴鍏�;06.浜ら�氬唴閮ㄦ帴鍏�;07.浜ら�氬叾浠栨帴鍏�;08.鍩庡競绠$悊鎺ュ叆;09.鍗敓鐜繚鎺ュ叆;10.鍟嗘娴峰叧鎺ュ叆;11.鏁欒偛閮ㄩ棬鎺ュ叆;]
+     */
+    private String hybm;
+
+    /**
+     * 绫诲瀷缂栫爜 : [131.鎽勫儚鏈虹紪鐮�;132.缃戠粶鎽勫儚鏈虹紪鐮�;]
+     */
+    private Long lxbm;
+
+}
diff --git a/ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java b/ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java
index 9ec669c..bc2ce19 100644
--- a/ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java
+++ b/ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java
@@ -5,8 +5,10 @@
 import com.ycl.platform.base.BaseSelect;
 import com.ycl.platform.domain.entity.ReportAuditingRecord;
 import com.ycl.platform.domain.entity.YwPoint;
+import com.ycl.platform.domain.query.DataCenterQuery;
 import com.ycl.platform.domain.query.YwPointQuery;
 import com.ycl.platform.domain.vo.CheckTagVO;
+import com.ycl.platform.domain.vo.PointDetailVO;
 import com.ycl.platform.domain.vo.ReportAuditingRecordVO;
 import com.ycl.platform.domain.vo.YwPointVO;
 import com.ycl.platform.domain.excel.PointExport;
@@ -33,6 +35,8 @@
     List<BaseSelect> selectData(@Param("keyword") String keyword, @Param("unitId") Integer unitId);
 
     IPage page(IPage<YwPointVO> page, @Param("query") YwPointQuery query);
+
+    IPage dataCenterPage(IPage<PointDetailVO> page, @Param("query") DataCenterQuery query);
 
     /**
      * 棣栭〉鍒版湡棰勮
@@ -113,4 +117,10 @@
      * @return
      */
     List<CheckTagVO> getTagsByGB(@Param("gbList") List<String> gbList);
+
+    /**
+     * 鏌ヨ璁惧鎬绘暟
+     * @return
+     */
+    Integer distinctCount(@Param("query") DataCenterQuery query);
 }
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 f7b2e36..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.*;
@@ -65,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)
@@ -91,8 +87,8 @@
         }
         HashMap<String, Object> map = new HashMap<>();
         map.put("count", Arrays.asList(distinctCount + "",this.remove0(onlineRate)));
-        map.put("list", resultList);
-        return Result.ok().data(map).total(total);
+        map.put("list", page.getRecords());
+        return Result.ok().data(map).total(page.getTotal());
     }
 
     /**
@@ -103,40 +99,14 @@
      */
     @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");
-        List<Document> dList = new ArrayList<>(2);
-        dList.add(new Document("deptTag", new Document("$eq", Boolean.TRUE)));
-        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),
-                // $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)
@@ -150,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 + "", this.remove0(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());
     }
 
     /**
@@ -163,37 +133,13 @@
      */
     @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");
-
-        List<Document> dList = new ArrayList<>(2);
-        dList.add(new Document("importantTag", new Document("$eq", Boolean.TRUE)));
-        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),
-                // $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())
@@ -208,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 + "", this.remove0(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());
     }
 
     /**
@@ -221,37 +167,13 @@
      */
     @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");
-
-        List<Document> dList = new ArrayList<>(2);
-        dList.add(new Document("importantCommandImageTag", new Document("$eq", Boolean.TRUE)));
-        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),
-                // $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())
@@ -266,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 + "", this.remove0(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());
     }
 
     /**
@@ -996,17 +918,13 @@
      */
     @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())
@@ -1022,8 +940,8 @@
         }
         HashMap<String, Object> map = new HashMap<>();
         map.put("count", Arrays.asList(distinctCount + "", this.remove0(onlineRate)));
-        map.put("list", resultList);
-        return Result.ok().data(map).total(total);
+        map.put("list", page.getRecords());
+        return Result.ok().data(map).total(page.getTotal());
     }
 
     /**
@@ -1528,59 +1446,13 @@
      */
     @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");
-
-        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 -> {
-            // 鏋勫缓鑱氬悎绠¢亾
-            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())
@@ -1594,11 +1466,13 @@
             BigDecimal count = BigDecimal.valueOf(videoList.size());
             onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
         }
+        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());
     }
 
     /**
diff --git a/ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml b/ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml
index e5dfe33..34b5f19 100644
--- a/ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml
+++ b/ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml
@@ -55,6 +55,90 @@
         </where>
     </select>
 
+    <select id="dataCenterPage">
+        SELECT
+               m.*
+        FROM
+             t_yw_point p INNER JOIN t_monitor m ON p.serial_number = m.serial_number
+        <where>
+            AND p.create_time between #{query.startTime} and #{query.endTime}
+            <if test="query.keyword != null and query.keyword != ''">
+                AND (m.name like concat('%', #{query.keyword}, '%') OR m.serial_number like concat('%', #{query.keyword}, '%'))
+            </if>
+            <if test="query.dataType == 1">
+                AND p.province_tag = 1
+            </if>
+            <choose>
+                <when test="query.deptTag == 1">
+                    AND p.dept_tag = 1
+                </when>
+                <when test="query.deptTag == 2">
+                    AND p.province_tag = 1
+                </when>
+                <when test="query.deptTag == 3">
+                    AND p.important_tag = 1
+                </when>
+                <when test="query.deptTag == 4">
+                    AND p.important_command_image_tag = 1
+                </when>
+                <when test="query.deptTag == 5">
+                    AND p.new_device = 1
+                </when>
+            </choose>
+            <choose>
+                <when test="query.deviceType == 1">
+                    AND m.camera_fun_type like '%1%'
+                </when>
+                <when test="query.deviceType == 2">
+                    AND m.camera_fun_type like '%2%'
+                </when>
+                <when test="query.deviceType == 3">
+                    AND m.camera_fun_type like '%3%'
+                </when>
+            </choose>
+        </where>
+    </select>
+
+    <select id="distinctCount" resultType="integer">
+        SELECT
+            count(DISTINCT m.serial_number)
+        FROM
+            t_yw_point p INNER JOIN t_monitor m ON p.serial_number = m.serial_number
+        <where>
+            <if test="query.dataType == 1">
+                AND p.province_tag = 1
+            </if>
+            <choose>
+                <when test="query.deptTag == 1">
+                    AND dept_tag = 1
+                </when>
+                <when test="query.deptTag == 2">
+                    AND province_tag = 1
+                </when>
+                <when test="query.deptTag == 3">
+                    AND important_tag = 1
+                </when>
+                <when test="query.deptTag == 4">
+                    AND important_command_image_tag = 1
+                </when>
+                <when test="query.deptTag == 5">
+                    AND new_device = 1
+                </when>
+            </choose>
+            <choose>
+                <when test="query.deviceType == 1">
+                    AND m.camera_fun_type like '%1%'
+                </when>
+                <when test="query.deviceType == 2">
+                    AND m.camera_fun_type like '%2%'
+                </when>
+                <when test="query.deviceType == 3">
+                    AND m.camera_fun_type like '%3%'
+                </when>
+            </choose>
+        </where>
+    </select>
+
     <select id="home" resultType="com.ycl.platform.domain.entity.YwPoint">
         <![CDATA[
         SELECT t_yw_point.id, point_name, start_time, end_time, status, unit_name AS remark
@@ -225,4 +309,5 @@
             serial_number, province_tag, important_tag, important_command_image_tag, dept_tag
     </select>
 
+
 </mapper>

--
Gitblit v1.8.0