作者 郑周

修复 定时任务 奔溃的BUG

1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
4 "strconv" 6 "strconv"
5 "time" 7 "time"
6 8
@@ -28,6 +30,10 @@ func (rs *NodeTaskService) SendEvaluationNode() error { @@ -28,6 +30,10 @@ func (rs *NodeTaskService) SendEvaluationNode() error {
28 } 30 }
29 defer func() { 31 defer func() {
30 transactionContext.RollbackTransaction() 32 transactionContext.RollbackTransaction()
  33 +
  34 + // 异常捕获
  35 + recError := recover()
  36 + log.Logger.Error(application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("定时发送评估任务异常:%s", recError)).Error())
31 }() 37 }()
32 taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) 38 taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
33 tasks, err := taskRepository.Find(map[string]interface{}{"now": time.Now().Local()}) 39 tasks, err := taskRepository.Find(map[string]interface{}{"now": time.Now().Local()})
@@ -75,9 +81,8 @@ func (rs *NodeTaskService) SendEvaluationNode() error { @@ -75,9 +81,8 @@ func (rs *NodeTaskService) SendEvaluationNode() error {
75 staffAssessService := service.NewStaffAssessServeice() 81 staffAssessService := service.NewStaffAssessServeice()
76 for i := range tasks { 82 for i := range tasks {
77 task := tasks[i] 83 task := tasks[i]
78 - // 项目  
79 - project, ok := projectIdsMap[task.ProjectId]  
80 - if ok { 84 + project, ok := projectIdsMap[task.ProjectId] // 项目
  85 + if ok && project != nil {
81 // 环节截止时间 86 // 环节截止时间
82 maxTime := task.TimeEnd.Local() 87 maxTime := task.TimeEnd.Local()
83 88