作者 tangxvhui

更新

@@ -40,10 +40,12 @@ func startNodeTask() { @@ -40,10 +40,12 @@ func startNodeTask() {
40 duration = time.Minute * 1 40 duration = time.Minute * 1
41 } 41 }
42 timer := time.NewTimer(duration) 42 timer := time.NewTimer(duration)
  43 + var nowTime time.Time
  44 + var err error
43 for { 45 for {
44 <-timer.C 46 <-timer.C
45 - nowTime := time.Now()  
46 - if err := nodeTaskService.SendEvaluationNode(nowTime); err != nil { 47 + nowTime = time.Now()
  48 + if err = nodeTaskService.SendEvaluationNode(nowTime); err != nil {
47 log.Logger.Error(err.Error()) 49 log.Logger.Error(err.Error())
48 } 50 }
49 timer.Reset(duration) // 重置定时 51 timer.Reset(duration) // 重置定时
@@ -61,9 +63,10 @@ func startSummaryEvaluation() { @@ -61,9 +63,10 @@ func startSummaryEvaluation() {
61 duration = time.Minute * 1 63 duration = time.Minute * 1
62 } 64 }
63 timer := time.NewTimer(duration) 65 timer := time.NewTimer(duration)
  66 + var err error
64 for { 67 for {
65 <-timer.C 68 <-timer.C
66 - if err := serviceSummary.TaskSendSummaryEvaluationV2(); err != nil { 69 + if err = serviceSummary.TaskSendSummaryEvaluationV2(); err != nil {
67 log.Logger.Error(err.Error()) 70 log.Logger.Error(err.Error())
68 } 71 }
69 timer.Reset(duration) // 重置定时 72 timer.Reset(duration) // 重置定时
@@ -81,9 +84,10 @@ func startConfirmEvaluationScore() { @@ -81,9 +84,10 @@ func startConfirmEvaluationScore() {
81 duration = time.Minute * 1 84 duration = time.Minute * 1
82 } 85 }
83 timer := time.NewTimer(duration) 86 timer := time.NewTimer(duration)
  87 + var err error
84 for { 88 for {
85 <-timer.C 89 <-timer.C
86 - if err := serviceSummary.TaskConfirmScore(); err != nil { 90 + if err = serviceSummary.TaskConfirmScore(); err != nil {
87 log.Logger.Error(err.Error()) 91 log.Logger.Error(err.Error())
88 } 92 }
89 timer.Reset(duration) // 重置定时 93 timer.Reset(duration) // 重置定时
1 package service 1 package service
2 2
3 import ( 3 import (
4 - "fmt"  
5 -  
6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" 4 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
7 5
8 "time" 6 "time"
@@ -21,12 +19,18 @@ func CheckYesterdayTaskRecord() { @@ -21,12 +19,18 @@ func CheckYesterdayTaskRecord() {
21 interval = (24 * time.Hour) + interval 19 interval = (24 * time.Hour) + interval
22 } 20 }
23 timer := time.NewTimer(interval) 21 timer := time.NewTimer(interval)
  22 + var (
  23 + nowDay string
  24 + err error
  25 + taskRecordList []*domain.TaskRecord
  26 + )
24 for { 27 for {
25 <-timer.C 28 <-timer.C
26 - nowDay := time.Now().Format("2006-01-02")  
27 - taskRecordList, err := getYesterdayTaskRecord(nowDay) 29 + nowDay = time.Now().Format("2006-01-02")
  30 + taskRecordList, err = getYesterdayTaskRecord(nowDay)
28 if err != nil { 31 if err != nil {
29 - log.Logger.Info("获取每日任务反馈" + err.Error()) 32 + log.Logger.Error("获取每日任务反馈" + err.Error())
  33 + continue
30 } 34 }
31 for _, val := range taskRecordList { 35 for _, val := range taskRecordList {
32 err = checkTaskRecordV3(val) 36 err = checkTaskRecordV3(val)
@@ -39,44 +43,44 @@ func CheckYesterdayTaskRecord() { @@ -39,44 +43,44 @@ func CheckYesterdayTaskRecord() {
39 43
40 } 44 }
41 45
42 -func checkTaskRecord(param *domain.TaskRecord) error {  
43 - transactionContext, err := factory.CreateTransactionContext(nil)  
44 - if err != nil {  
45 - return err  
46 - }  
47 - if err := transactionContext.StartTransaction(); err != nil {  
48 - return err  
49 - }  
50 - defer func() {  
51 - _ = transactionContext.RollbackTransaction()  
52 - }()  
53 - taskRepo := factory.CreateTaskRepository(map[string]interface{}{  
54 - "transactionContext": transactionContext,  
55 - }) 46 +// func checkTaskRecord(param *domain.TaskRecord) error {
  47 +// transactionContext, err := factory.CreateTransactionContext(nil)
  48 +// if err != nil {
  49 +// return err
  50 +// }
  51 +// if err := transactionContext.StartTransaction(); err != nil {
  52 +// return err
  53 +// }
  54 +// defer func() {
  55 +// _ = transactionContext.RollbackTransaction()
  56 +// }()
  57 +// taskRepo := factory.CreateTaskRepository(map[string]interface{}{
  58 +// "transactionContext": transactionContext,
  59 +// })
56 60
57 - _, taskDataList, err := taskRepo.Find(map[string]interface{}{"id": param.TaskId})  
58 - if err != nil {  
59 - return fmt.Errorf("获取任务数据失败:%s", err)  
60 - }  
61 - if len(taskDataList) == 0 {  
62 - return nil  
63 - }  
64 - taskData := taskDataList[0]  
65 - if param.AnomalyState != domain.AnomalyState1 {  
66 - taskData.Anomaly += 1  
67 - } else {  
68 - taskData.Anomaly = 0  
69 - } 61 +// _, taskDataList, err := taskRepo.Find(map[string]interface{}{"id": param.TaskId})
  62 +// if err != nil {
  63 +// return fmt.Errorf("获取任务数据失败:%s", err)
  64 +// }
  65 +// if len(taskDataList) == 0 {
  66 +// return nil
  67 +// }
  68 +// taskData := taskDataList[0]
  69 +// if param.AnomalyState != domain.AnomalyState1 {
  70 +// taskData.Anomaly += 1
  71 +// } else {
  72 +// taskData.Anomaly = 0
  73 +// }
70 74
71 - err = taskRepo.Save(taskData)  
72 - if err != nil {  
73 - return fmt.Errorf("保存任务数据:%s", err)  
74 - }  
75 - if err := transactionContext.CommitTransaction(); err != nil {  
76 - return err  
77 - }  
78 - return nil  
79 -} 75 +// err = taskRepo.Save(taskData)
  76 +// if err != nil {
  77 +// return fmt.Errorf("保存任务数据:%s", err)
  78 +// }
  79 +// if err := transactionContext.CommitTransaction(); err != nil {
  80 +// return err
  81 +// }
  82 +// return nil
  83 +// }
80 84
81 func getYesterdayTaskRecord(nowDay string) ([]*domain.TaskRecord, error) { 85 func getYesterdayTaskRecord(nowDay string) ([]*domain.TaskRecord, error) {
82 transactionContext, err := factory.CreateTransactionContext(nil) 86 transactionContext, err := factory.CreateTransactionContext(nil)