zhangzengfei
2024-05-17 9e8d8b630affc4a4be428c775264ef4b0e5104b3
service/device.go
@@ -3,7 +3,6 @@
import (
   "encoding/json"
   "time"
   "errors"
   "gat1400Exchange/config"
   "gat1400Exchange/pkg/logger"
@@ -16,7 +15,7 @@
var deviceAliveCache *expirable.LRU[string, bool]
func init() {
   deviceAliveCache = expirable.NewLRU[string, bool](100, nil, time.Second*60) //过滤指定时间内的重复人物
   deviceAliveCache = expirable.NewLRU[string, bool](100, nil, time.Second*60)
}
type DevReportData struct {
@@ -42,18 +41,17 @@
      return nil
   }
   logger.Info("Start device info report task, server:%s.", config.ForwardConf.ReportServer)
   if config.ForwardConf.ReportServer == "" {
      return errors.New("Server addr is empty!")
      return nil
   }
   logger.Info("Start device info report task, server:%s.", config.ForwardConf.ReportServer)
   var d models.Device
   devices, err := d.FindAll()
   if err != nil {
      return err
   }
   for _, dev := range devices{
      if _, exists := deviceAliveCache.Get(dev.Id); !exists {