From 87b55a899bc1b4bc7d5a0f8d6ad1a1ede233ebd1 Mon Sep 17 00:00:00 2001
From: qixiaoning <jony.kee@outlook.com>
Date: 星期四, 04 九月 2025 17:35:24 +0800
Subject: [PATCH] 系统监控模型进程统计实时监控摄像机名称为空问题修复

---
 chanmanage-service/service/pollSetService.go |   48 ++++++++++++++++++++++++++++--------------------
 1 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/chanmanage-service/service/pollSetService.go b/chanmanage-service/service/pollSetService.go
index 0e5b5ff..32c0845 100644
--- a/chanmanage-service/service/pollSetService.go
+++ b/chanmanage-service/service/pollSetService.go
@@ -75,9 +75,9 @@
 	return false
 }
 
-//瑙﹀彂鏉′欢
-//1.瀹炴椂鎽勫儚鏈哄垏鎹负杞鎴栬�呯洃鎺э紝鎴栬�呭疄鏃剁敱鐩戞帶鍒囨崲涓哄疄鏃�
-//2.瀹炴椂鎽勫儚鏈鸿鍒橢nable鐘舵�佹敼鍙�
+// 瑙﹀彂鏉′欢
+// 1.瀹炴椂鎽勫儚鏈哄垏鎹负杞鎴栬�呯洃鎺э紝鎴栬�呭疄鏃剁敱鐩戞帶鍒囨崲涓哄疄鏃�
+// 2.瀹炴椂鎽勫儚鏈鸿鍒橢nable鐘舵�佹敼鍙�
 func (sv *PollSetService) ResetChannelCount() {
 	//1.璁$畻鍋氬疄鏃朵换鍔$殑璺暟
 	//2.鏈湴鏂囦欢鍗犵殑璺暟
@@ -104,7 +104,7 @@
 	sv.UpdateChannelCount(pollCount, videoCount)
 }
 
-//鎷栧姩鏀瑰彉杞鍜屾暟鎹爤鐨勬暟閲�
+// 鎷栧姩鏀瑰彉杞鍜屾暟鎹爤鐨勬暟閲�
 func (sv *PollSetService) UpdateChannelCount(pollChannelCount int, videoChannelCount int) bool {
 	var fasApi bhomedbapi.FileStackApi
 	var err error
@@ -176,12 +176,15 @@
 		}
 	}
 
+	//鑾峰彇鐫f煡浠诲姟
+	tasks := models.GetTasks()
+
 	rTotal := 0
 	pTotal := 0
 	for _, c := range camMap {
 		if c.RunType == bhomeclient.TYPE_RUNTYPE_REALTIME {
 			rTotal++
-			if crInfo, ok := ruleM[c.Id]; ok && crInfo.Rules != nil && len(crInfo.Rules) > 0 {
+			if taskInfo, ok := tasks[c.Id]; ok && taskInfo != nil && len(taskInfo) > 0 {
 				v.RealValidCount++
 			} else {
 				v.RealInvalidCount++
@@ -191,28 +194,33 @@
 				v.RealRunningCount++
 			}
 		} else if c.RunType == bhomeclient.TYPE_RUNTYPE_POLL {
-			pTotal++
-			if crInfo, ok := ruleM[c.Id]; ok && crInfo.Rules != nil && len(crInfo.Rules) > 0 {
-				v.PollValidCount++
-			} else {
-				v.PollInvalidCount++
-			}
-			if c.IsRunning {
-				v.PollRunningCount++
-			}
+			// pTotal++
+			// if crInfo, ok := ruleM[c.Id]; ok && crInfo.Rules != nil && len(crInfo.Rules) > 0 {
+			// 	v.PollValidCount++
+			// } else {
+			// 	v.PollInvalidCount++
+			// }
+			// if c.IsRunning {
+			// 	v.PollRunningCount++
+			// }
 		}
 	}
+
+	//鎬荤畻閲屾殏鏃跺彧缁熻瀹炴椂绠楀姏
+	v.ChannelTotal = rTotal
+
 	v.RealTotal = rTotal
 	v.PollTotal = pTotal
 	logger.Debug("statisticRunInfo 鑾峰彇瀹孍xistRunningTask鑰楁椂锛�", time.Since(timeStart))
 	timeStart = time.Now()
 
-	//杞閫氶亾鏁伴噺浠庤疆璇㈤厤缃腑鑾峰彇
-	var pollConf models.PollConfig
-	pcE, err2 := pollConf.GetOne()
-	if err2 == nil {
-		v.PollChannelCount = pcE.PollChannelCount
-	}
+	//杞閫氶亾鏁伴噺浠庤疆璇㈤厤缃腑鑾峰彇20250724绉婚櫎
+	// var pollConf models.PollConfig
+	// pcE, err2 := pollConf.GetOne()
+	// if err2 == nil {
+	// 	v.PollChannelCount = pcE.PollChannelCount
+	// }
+
 	//tmpPC := v.RealTotal - v.StackTotal
 	//if tmpPC < 0  {
 	//    v.PollChannelCount = 0

--
Gitblit v1.8.0