From 8f2e8522daf081ad4da027c39a776fdd9483b97e Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期一, 15 九月 2025 15:20:51 +0800
Subject: [PATCH] 新需求

---
 ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java |   52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 51 insertions(+), 1 deletions(-)

diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java
index e450615..625dd78 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java
@@ -71,6 +71,7 @@
 import java.util.*;
 import java.util.concurrent.*;
 import java.util.function.Function;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 /**
@@ -1269,6 +1270,7 @@
     @Override
     public Map<String, Object> videoHome(HomeQuery monitorQuery) throws ParseException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
         List<HomeVideoVO> results = new ArrayList<>();
+
         String month = monitorQuery.getDate();
         if (StringUtils.isEmpty(month)) {
             //濡傛灉涓虹┖鏌ユ湰鏈堢殑鏁版嵁
@@ -1295,13 +1297,30 @@
         MongoDatabase database = mongoTemplate.getDb();
         MongoCollection<Document> collection = database.getCollection("uy_record_meta_d_sum");
         Integer examineTag = monitorQuery.getExamineTag();
+        String arealayerno = monitorQuery.getArea();
         Document matchConditions = new Document("statTime", new Document("$gte", startDate).append("$lte", endDate));
         // 鏍规嵁examineTag鐨勫�煎姩鎬佹坊鍔犻澶栫殑鏉′欢
         if (examineTag != null && examineTag.equals(1)) {
             matchConditions.append("provinceTag", true);
         } else if (examineTag != null && examineTag.equals(2)) {
             matchConditions.append("deptTag", true);
+        } else if(StringUtils.isNotBlank(arealayerno)){
+            matchConditions.append("arealayerno",
+                    new Document("$regex", "^" + arealayerno));
         }
+        Document noExpr = new Document("$and", Arrays.asList(
+                new Document("$gte", Arrays.asList(new Document("$strLenCP", "$no"), 3)),
+                new Document("$ne", Arrays.asList(
+                        new Document("$substrCP", Arrays.asList(
+                                "$no",
+                                new Document("$subtract", Arrays.asList(new Document("$strLenCP", "$no"), 3)),
+                                1
+                        )),
+                        "3"
+                ))
+        ));
+// 姝g‘娣诲姞$expr鏉′欢锛堥敭涓�"$expr"锛屽�间负涓婇潰瀹氫箟鐨勬潯浠讹級
+        matchConditions.append("$expr", noExpr);
         // 鏋勫缓鑱氬悎绠¢亾
         List<Document> pipeline = Arrays.asList(
                 new Document("$match", matchConditions),
@@ -1337,6 +1356,7 @@
             homeVideoVO.setIntegrityNum(doc.getInteger("normalCount"));
             homeVideoVO.setLoseNum(doc.getInteger("loseCount"));
             homeVideoVO.setErrNum(doc.getInteger("errCount"));
+
             results.add(homeVideoVO);
         }
 
@@ -1350,8 +1370,24 @@
             onlineMatch.add(new Document("provinceTag", true));
         } else if (examineTag != null && examineTag.equals(2)) {
             onlineMatch.add(new Document("deptTag", true));
-        }
+        } else if(StringUtils.isNotBlank(arealayerno)){
+            Document noStartsWith = new Document("no", new Document("$regex", "^" + arealayerno));
 
+            // 鏋勫缓鍊掓暟绗笁浣嶄笉鏄�3鐨勬潯浠�
+            Document noThirdLastNot3 = new Document("$expr", new Document("$and", Arrays.asList(
+                    new Document("$gte", Arrays.asList(new Document("$strLenCP", "$no"), 3)),
+                    new Document("$ne", Arrays.asList(
+                            new Document("$substrCP", Arrays.asList(
+                                    "$no",
+                                    new Document("$subtract", Arrays.asList(new Document("$strLenCP", "$no"), 3)),
+                                    1
+                            )),
+                            "3"
+                    ))
+            )));
+            // 灏嗕袱涓潯浠剁敤$and缁勫悎鍚庢坊鍔犲埌鏉′欢鍒楄〃
+            onlineMatch.add(new Document("$and", Arrays.asList(noStartsWith, noThirdLastNot3)));
+        }
         // 鏋勫缓鑱氬悎绠¢亾
         List<Document> onlinePipeline = Arrays.asList(
                 new Document("$match", new Document("$and", onlineMatch)),
@@ -1365,6 +1401,10 @@
                         ))
                 )
         );
+        //鎺掗櫎鍗″彛闆嗗悎
+
+
+
         // 鎵ц鑱氬悎鏌ヨ骞惰幏鍙栫粨鏋�
         AggregateIterable<Document> onlineResult = onlineCollection.aggregate(onlinePipeline);
         for (Document doc : onlineResult) {
@@ -1496,10 +1536,13 @@
         Integer examineTag = monitorQuery.getExamineTag();
         // 鏋勫缓鍩烘湰鐨�$match鏉′欢
         List<Document> matchConditions = new ArrayList<>();
+        String arealayerno = monitorQuery.getArea();
         matchConditions.add(new Document("mongoCreateTime", new Document("$gte", startDate).append("$lte", endDate)));
         matchConditions.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_CAR)));
         if (examineTag != null && examineTag.equals(1)) {
             matchConditions.add(new Document("provinceTag", true));
+        }else if(StringUtils.isNotBlank(arealayerno)){
+            matchConditions.add(new Document("orgCode",new Document("$eq", arealayerno)));
         }
         // 鏋勫缓鑱氬悎绠¢亾
         List<Document> pipeline = Arrays.asList(
@@ -1524,6 +1567,8 @@
         onlineMatch.add(new Document("monitorType", new Document("$regex", "2")));
         if (examineTag != null && examineTag.equals(1)) {
             onlineMatch.add(new Document("provinceTag", true));
+        }else if(StringUtils.isNotBlank(arealayerno)){
+            onlineMatch.add(new Document("no", new Document("$regex", "^" + arealayerno)));
         }
         // 鏋勫缓鑱氬悎绠¢亾
         List<Document> onlinePipeline = Arrays.asList(
@@ -1602,6 +1647,7 @@
         calendar.add(Calendar.DAY_OF_MONTH, -1);
         // 鑾峰彇鏈堜唤鏈�鍚庝竴澶╃殑Date
         Date endDate = calendar.getTime();
+        String arealayerno = monitorQuery.getArea();
         //mongo鏌ユ姄鎷嶉噺
         MongoDatabase database = mongoTemplate.getDb();
         MongoCollection<Document> collection = database.getCollection("hk_snapshot_data_monitor");
@@ -1612,6 +1658,8 @@
         matchConditions.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_FACE)));
         if (examineTag != null && examineTag.equals(1)) {
             matchConditions.add(new Document("provinceTag", true));
+        }else if(StringUtils.isNotBlank(arealayerno)){
+            matchConditions.add(new Document("orgCode",new Document("$eq", arealayerno)));
         }
         // 鏋勫缓鑱氬悎绠¢亾
         List<Document> pipeline = Arrays.asList(
@@ -1638,6 +1686,8 @@
         onlineMatch.add(new Document("monitorType", new Document("$regex", "3")));
         if (examineTag != null && examineTag.equals(1)) {
             onlineMatch.add(new Document("provinceTag", true));
+        }else if(StringUtils.isNotBlank(arealayerno)){
+            onlineMatch.add(new Document("no", new Document("$regex", "^" + arealayerno)));
         }
         // 鏋勫缓鑱氬悎绠¢亾
         List<Document> onlinePipeline = Arrays.asList(

--
Gitblit v1.8.0