|
@@ -1663,3 +1663,39 @@ func (s *ServiceStatisticsLog) GetDeviceContrastInfo(ctx context.Context, api lo
|
|
|
}
|
|
}
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+func (s *ServiceStatisticsLog) ComputerUpdateStatus() {
|
|
|
|
|
+ var computer log.Computer
|
|
|
|
|
+ logComputers, err := computer.OnlinePcCodeCache()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ global.GVA_LOG.Error("ComputerUpdateStatus LogComputer 获取失败!", zap.Error(err))
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ date := s.CurrentDate()
|
|
|
|
|
+ ctx := context.Background()
|
|
|
|
|
+ for pcCode, _ := range logComputers {
|
|
|
|
|
+ // 检测5分钟内电脑是否上报了数据
|
|
|
|
|
+ num := s.LogicalLog.CheckPcReportingLog(ctx, pcCode, 60*1000*8)
|
|
|
|
|
+ status := -1
|
|
|
|
|
+ if num != 0 {
|
|
|
|
|
+ status = 1
|
|
|
|
|
+ }
|
|
|
|
|
+ var computerStatus log.ComputerStatus
|
|
|
|
|
+ result := global.GVA_DB.Where("create_date = ?", date).Where("pc_code = ?", pcCode).First(&computerStatus)
|
|
|
|
|
+ if result.Error != nil {
|
|
|
|
|
+ if result.Error == gorm.ErrRecordNotFound {
|
|
|
|
|
+ // 数据不存在,执行创建操作
|
|
|
|
|
+ computerStatus.Status = status
|
|
|
|
|
+ computerStatus.CreateDate = time.Now()
|
|
|
|
|
+ computerStatus.PcCode = pcCode
|
|
|
|
|
+ result = global.GVA_DB.Create(&computerStatus)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 其他错误
|
|
|
|
|
+ global.GVA_LOG.Error("ComputerUpdateStatus computerStatus 获取失败!", zap.Error(err))
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ global.GVA_DB.Model(&log.ComputerStatus{}).Where("create_date = ?", date).Where("pc_code = ?", pcCode).Update("status", status)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|