From a4a904acc5f4de80d30eafe19dd97f3cc8f56a0b Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期一, 29 九月 2025 17:17:34 +0800
Subject: [PATCH] 新问题 25-9-28
---
ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 53 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..beebaa8 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;
/**
@@ -1160,6 +1161,8 @@
exportForm.setDeptIds(deptIds);
}
Query query = getQuery(exportForm);
+
+
//鏈堜唤姣忔棩鍦ㄧ嚎鏁版嵁
List<TMonitorResult> onlineResult = mongoTemplate.find(query, TMonitorResult.class);
// 浣跨敤 Collectors.toMap 鍘婚噸锛屼繚鐣欐瘡涓� No 鐨勭涓�涓亣鍒扮殑鍏冪礌
@@ -1269,6 +1272,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 +1299,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 +1358,7 @@
homeVideoVO.setIntegrityNum(doc.getInteger("normalCount"));
homeVideoVO.setLoseNum(doc.getInteger("loseCount"));
homeVideoVO.setErrNum(doc.getInteger("errCount"));
+
results.add(homeVideoVO);
}
@@ -1350,8 +1372,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 +1403,10 @@
))
)
);
+ //鎺掗櫎鍗″彛闆嗗悎
+
+
+
// 鎵ц鑱氬悎鏌ヨ骞惰幏鍙栫粨鏋�
AggregateIterable<Document> onlineResult = onlineCollection.aggregate(onlinePipeline);
for (Document doc : onlineResult) {
@@ -1496,10 +1538,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 +1569,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 +1649,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 +1660,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 +1688,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