|
|
@@ -15,6 +15,7 @@ import (
|
|
|
"log-server/model/log/response"
|
|
|
"log-server/model/task"
|
|
|
"log-server/model/typeManage"
|
|
|
+ "log-server/service/cache"
|
|
|
loging2 "log-server/service/log/loging"
|
|
|
"log-server/utils"
|
|
|
"strconv"
|
|
|
@@ -838,6 +839,113 @@ func (s *ServiceStatisticsLog) OnlineComputerStatistics(ctx context.Context, api
|
|
|
return statisticsLogs, total, err
|
|
|
}
|
|
|
|
|
|
+// OnlineComputerStatistics 在线电脑
|
|
|
+func (s *ServiceStatisticsLog) OnlineComputerEfficiencyStatistics() {
|
|
|
+ date := s.CurrentDate()
|
|
|
+ db := global.GVA_DB.Model(&log.LogComputer{})
|
|
|
+ db = db.Select("SUM(pull_account_num) pull_account_total,SUM(enter_main) enter_main_total,operator,pc_code,status,create_date,remarks")
|
|
|
+ db = db.Where("create_date = ?", date)
|
|
|
+ db = db.Group("pc_code")
|
|
|
+ var statisticsLogs []*response.ComputerUseLogReply
|
|
|
+ err := db.Find(&statisticsLogs).Error
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 查询两小时内上报的数据
|
|
|
+ var computersF = map[string]string{}
|
|
|
+ var noReportingPc []string
|
|
|
+ ctx := context.Background()
|
|
|
+ for _, computer := range statisticsLogs {
|
|
|
+ computersF[computer.PcCode] = computer.Operator
|
|
|
+ if strings.Contains(computer.Operator, "备用") {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if computer.Operator == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ key := fmt.Sprintf(cache.ComputerEfficiency, date, computer.PcCode)
|
|
|
+
|
|
|
+ if computer.EnterMainTotal == 0 && computer.PullAccountTotal == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ if computer.EnterMainTotal == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ num := float64(computer.EnterMainTotal) / float64(computer.PullAccountTotal) * 100
|
|
|
+ formattedNumber := fmt.Sprintf("%.2f", num)
|
|
|
+ if num < 41 {
|
|
|
+ getNum, _ := global.GVA_REDIS.Get(ctx, key).Result()
|
|
|
+ if getNum != "" {
|
|
|
+ fmt.Println(computer.PcCode)
|
|
|
+ global.GVA_LOG.Info("===" + getNum + "===")
|
|
|
+ global.GVA_LOG.Info("===" + formattedNumber + "===")
|
|
|
+ getCacheNumFormat, _ := strconv.ParseFloat(getNum, 64)
|
|
|
+ formatNum, _ := strconv.ParseFloat(formattedNumber, 64)
|
|
|
+
|
|
|
+ fmt.Println(getCacheNumFormat)
|
|
|
+ fmt.Println(formatNum)
|
|
|
+ if getCacheNumFormat > formatNum {
|
|
|
+ noReportingPc = append(noReportingPc, computer.PcCode)
|
|
|
+ global.GVA_REDIS.Set(ctx, key, formattedNumber, time.Hour*10)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ global.GVA_REDIS.Set(ctx, key, formattedNumber, time.Hour*10)
|
|
|
+ noReportingPc = append(noReportingPc, computer.PcCode)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ global.GVA_REDIS.Del(ctx, key)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mpsPerson, _ := s.Person.GetUserInfoData()
|
|
|
+ var mobile []string
|
|
|
+ var content string
|
|
|
+ nameMps := map[string]string{}
|
|
|
+ if len(noReportingPc) != 0 {
|
|
|
+ content += fmt.Sprintf("检测电脑效率异常<font color=\"warning\">%d台</font>:", len(noReportingPc))
|
|
|
+ for _, pc := range noReportingPc {
|
|
|
+ content += "\n"
|
|
|
+ name := computersF[pc]
|
|
|
+ content += name + " : " + pc
|
|
|
+ if nameMps[name] == "" {
|
|
|
+ nameMps[name] = pc
|
|
|
+ } else {
|
|
|
+ nameMps[name] += ","
|
|
|
+ nameMps[name] += pc
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ c := "# 检测电脑效率异常"
|
|
|
+ c += "\n"
|
|
|
+ if len(nameMps) != 0 {
|
|
|
+ for name, ct := range nameMps {
|
|
|
+ if _, ok := mpsPerson[name]; ok {
|
|
|
+ mobile = append(mobile, mpsPerson[name].MobilePhoneNumber)
|
|
|
+ }
|
|
|
+ ct = fmt.Sprintf("<font color=\"warning\">%s</font>", ct)
|
|
|
+ ct = c + ct
|
|
|
+ global.GVA_LOG.Info(ct)
|
|
|
+ go s.SendContent(ct, mpsPerson[name].Url)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if content != "" {
|
|
|
+ var sendMsg SendMsg
|
|
|
+ sendMsg.MsgType = "markdown"
|
|
|
+ sendMsg.Markdown.Content = content
|
|
|
+ url := global.GVA_CONFIG.SendUrl.ComputerSendUrl
|
|
|
+ _, err = s.SendMsgData(url, sendMsg)
|
|
|
+ if len(mobile) != 0 {
|
|
|
+ var sendTextData SendTextMsg
|
|
|
+ sendTextData.MsgType = "text"
|
|
|
+ sendTextData.Text.MentionedMobileList = mobile
|
|
|
+ _, _ = s.SendMsgData(url, sendTextData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// GameStatistics 根据游戏id查询数据
|
|
|
func (s *ServiceStatisticsLog) GameStatistics(ctx context.Context, api log.LogComputer, info request.PageInfo) (interface{}, int64, error) {
|
|
|
date := api.CreateDate
|