qixiaoning
2025-07-31 1fda1e433489e43387dbd082f8aba37d136755b2
chanmanage-service/service/pollSetService.go
@@ -75,9 +75,9 @@
   return false
}
//触发条件
//1.实时摄像机切换为轮询或者监控,或者实时由监控切换为实时
//2.实时摄像机规则Enable状态改变
// 触发条件
// 1.实时摄像机切换为轮询或者监控,或者实时由监控切换为实时
// 2.实时摄像机规则Enable状态改变
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 @@
      }
   }
   //获取督查任务
   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 获取完ExistRunningTask耗时:", 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