|
|
@@ -516,12 +516,20 @@ func (s *ServiceStatisticsLog) CreateComputerStatisticsData() {
|
|
|
onlineComputerMpa, _ := s.LogicalLog.GetOnlineComputerNumCache(ctx, s.LogicalLog.CurrentDate())
|
|
|
var computer log.Computer
|
|
|
computerData, _ := computer.OnlinePcCodeCache()
|
|
|
+ if computerData == nil {
|
|
|
+ global.GVA_LOG.Warn("电脑缓存数据获取失败TaskStatisticsDataCache")
|
|
|
+ return
|
|
|
+ }
|
|
|
var csReplys []*log.LogComputer
|
|
|
for code, r := range codeMps {
|
|
|
// 不统计不在电脑列表里的
|
|
|
if _, ok := computerData[code]; !ok {
|
|
|
continue
|
|
|
}
|
|
|
+ // 负责人为空的不统计
|
|
|
+ if computerData[code] == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
accountMps, err := s.LogicalLog.GetComputerPullAccountNumCache(ctx, s.LogicalLog.CurrentDate(), code)
|
|
|
if err != nil {
|
|
|
continue
|
|
|
@@ -980,56 +988,6 @@ func (s *ServiceStatisticsLog) ComputerTest(c context.Context) (interface{}, err
|
|
|
return mps, err
|
|
|
}
|
|
|
|
|
|
-// RegularCheckPc1 定时检查电脑情况
|
|
|
-func (s *ServiceStatisticsLog) RegularCheckPc1() {
|
|
|
- ctx := context.Background()
|
|
|
- date := s.LogicalLog.CurrentDate()
|
|
|
- // 获取当天已上报的电脑数据
|
|
|
- onlineComputerMpa, _ := s.LogicalLog.GetOnlineComputerNumCache(ctx, date)
|
|
|
- // 获取数据库的数据
|
|
|
- var computer log.Computer
|
|
|
- computers, err := computer.OnlinePcCodeCache()
|
|
|
- if err != nil {
|
|
|
- global.GVA_LOG.Error("获取租机表数据失败", zap.Error(err))
|
|
|
- }
|
|
|
- // 查询两小时内上报的数据
|
|
|
- var noReportingPc []string
|
|
|
- for pc, _ := range onlineComputerMpa {
|
|
|
- num := s.LogicalLog.GetPcReportingLog(ctx, pc)
|
|
|
- delete(computers, pc)
|
|
|
- if num == 0 {
|
|
|
- noReportingPc = append(noReportingPc, pc)
|
|
|
- }
|
|
|
- }
|
|
|
- // 未上报逻辑
|
|
|
- var errReportingPc []string
|
|
|
- for pc, name := range computers {
|
|
|
- if name == "备用" {
|
|
|
- continue
|
|
|
- }
|
|
|
- errReportingPc = append(errReportingPc, pc)
|
|
|
- }
|
|
|
- var content string
|
|
|
- if len(errReportingPc) != 0 {
|
|
|
- // 发信息数据群里
|
|
|
- content += fmt.Sprintf("异常租机数据<font color=\"warning\">%d台</font>: %s", len(errReportingPc), errReportingPc)
|
|
|
- }
|
|
|
- if len(noReportingPc) != 0 {
|
|
|
- // 发信息数据群里
|
|
|
- content += "\n"
|
|
|
- content += fmt.Sprintf("两小时内未检测到中控数据<font color=\"warning\">%d台</font>: %s", len(noReportingPc), noReportingPc)
|
|
|
- }
|
|
|
- if content != "" {
|
|
|
- var sendMsg SendMsg
|
|
|
- sendMsg.MsgType = "markdown"
|
|
|
- sendMsg.Markdown.Content = content
|
|
|
- //c ,_ := json.Marshal(sendMsg)
|
|
|
- url := global.GVA_CONFIG.SendUrl.ComputerSendUrl
|
|
|
- //url := "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=7d095d5b-8240-45fd-a68c-baff3628d83b"
|
|
|
- _, err = s.SendMsgData(url, sendMsg)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
// 定时检查电脑情况
|
|
|
func (s *ServiceStatisticsLog) RegularCheckPc() {
|
|
|
ctx := context.Background()
|
|
|
@@ -1038,6 +996,11 @@ func (s *ServiceStatisticsLog) RegularCheckPc() {
|
|
|
//computersF, err := computer.OnlinePcCodeCache()
|
|
|
if err != nil {
|
|
|
global.GVA_LOG.Error("获取租机表数据失败", zap.Error(err))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if computers == nil {
|
|
|
+ global.GVA_LOG.Warn("电脑缓存数据获取失败TaskStatisticsDataCache")
|
|
|
+ return
|
|
|
}
|
|
|
// 查询两小时内上报的数据
|
|
|
var computersF = map[string]string{}
|
|
|
@@ -1048,6 +1011,10 @@ func (s *ServiceStatisticsLog) RegularCheckPc() {
|
|
|
delete(computers, pc)
|
|
|
continue
|
|
|
}
|
|
|
+ if name == "" {
|
|
|
+ delete(computers, pc)
|
|
|
+ continue
|
|
|
+ }
|
|
|
num := s.LogicalLog.GetPcReportingLog(ctx, pc)
|
|
|
delete(computers, pc)
|
|
|
if num == 0 {
|