Browse Source

中控异常通知

wangbin 2 years ago
parent
commit
0dd85139dd
4 changed files with 56 additions and 0 deletions
  1. 20 0
      api/v1/log/loging.go
  2. 5 0
      model/log/request/log_statistics.go
  3. 1 0
      router/log/loging.go
  4. 30 0
      service/log/log_statistics.go

+ 20 - 0
api/v1/log/loging.go

@@ -730,3 +730,23 @@ func (e *ApiLoging) GetWuYToken(c *gin.Context) {
 	response.OkWithDetailed(data, "获取成功", c)
 	return
 }
+
+// @Tags loging
+// @Summary 中控上报异常信息
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Success 200 {object} response.Response{data=interface{}} "中控上报异常信息"
+// @Router /loging/supConErr [post]
+func (s *ApiLoging) SupConErr(c *gin.Context) {
+	var paramsInfo request.SupConErrRequest
+	_ = c.ShouldBindJSON(&paramsInfo)
+	if paramsInfo.PcCode == "" || paramsInfo.Describe == "" {
+		global.GVA_LOG.Error("参数错误!")
+		response.FailWithMessage("参数错误", c)
+		return
+	}
+	num := ServiceStatisticsLog.SupConErr(paramsInfo.PcCode, paramsInfo.Describe)
+	global.GVA_LOG.Warn(fmt.Sprintf("中控上报异常pc_code=%s 描述=%s", paramsInfo.PcCode, paramsInfo.Describe))
+	response.OkWithDetailed(num, "上报成功", c)
+}

+ 5 - 0
model/log/request/log_statistics.go

@@ -24,6 +24,11 @@ type OnlineComputerRequest struct {
 	Operator string `json:"operator"`
 }
 
+type SupConErrRequest struct {
+	PcCode   string `json:"pc_code"`
+	Describe string `json:"describe"`
+}
+
 type TaskStatistics struct {
 	GameId                int    `json:"game_id"`
 	GameName              string `json:"game_name"`

+ 1 - 0
router/log/loging.go

@@ -34,5 +34,6 @@ func (e *LogingRouter) InitLogingRouter(Router *gin.RouterGroup) {
 		excelRouter.POST("getDeviceIdErr", logApi.GetDeviceIdErr)
 		excelRouter.POST("deviceErrRateExcel", logApi.DeviceErrRateExcel)
 		excelRouter.GET("getWuYToken", logApi.GetWuYToken)
+		excelRouter.POST("supConErr", logApi.SupConErr)
 	}
 }

+ 30 - 0
service/log/log_statistics.go

@@ -1709,3 +1709,33 @@ func (s *ServiceStatisticsLog) ComputerUpdateStatus() {
 		}
 	}
 }
+
+// 中控异常情况
+func (s *ServiceStatisticsLog) SupConErr(pcCode, describe string) (err error) {
+	var computer log.Computer
+	computers, err := computer.OnlinePcCodeCache()
+	//computersF, err := computer.OnlinePcCodeCache()
+	if err != nil {
+		global.GVA_LOG.Error("获取租机表数据失败", zap.Error(err))
+		return
+	}
+	if computers == nil {
+		global.GVA_LOG.Warn("电脑缓存数据获取失败TaskStatisticsDataCache")
+		return
+	}
+	name := computers[pcCode]
+	if strings.Contains(name, "备用") {
+		return
+	}
+	if name == "" {
+		return
+	}
+	c := "# 中控异常"
+	c += "\n"
+	ct := fmt.Sprintf("<font color=\"warning\">电脑%s; %s</font>", pcCode, describe)
+	ct = c + ct
+	global.GVA_LOG.Warn(ct)
+	mpsPerson, _ := s.Person.GetUserInfoData()
+	s.SendContent(ct, mpsPerson[name].Url)
+	return
+}