|
@@ -3,6 +3,7 @@ package service |
|
@@ -3,6 +3,7 @@ package service |
3
|
import (
|
3
|
import (
|
4
|
"github.com/linmadan/egglib-go/core/application"
|
4
|
"github.com/linmadan/egglib-go/core/application"
|
5
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
5
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
|
|
6
|
+ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
|
7
|
"time"
|
8
|
"time"
|
8
|
)
|
9
|
)
|
|
@@ -25,6 +26,8 @@ func (rs *NodeTaskService) SendEvaluationNode() error { |
|
@@ -25,6 +26,8 @@ func (rs *NodeTaskService) SendEvaluationNode() error { |
25
|
transactionContext.RollbackTransaction()
|
26
|
transactionContext.RollbackTransaction()
|
26
|
}()
|
27
|
}()
|
27
|
taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
|
28
|
taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
29
|
+ projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
30
|
+ //cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
28
|
|
31
|
|
29
|
tasks, err := taskRepository.Find(map[string]interface{}{"now": time.Now().Local()})
|
32
|
tasks, err := taskRepository.Find(map[string]interface{}{"now": time.Now().Local()})
|
30
|
if err != nil {
|
33
|
if err != nil {
|
|
@@ -33,17 +36,53 @@ func (rs *NodeTaskService) SendEvaluationNode() error { |
|
@@ -33,17 +36,53 @@ func (rs *NodeTaskService) SendEvaluationNode() error { |
33
|
|
36
|
|
34
|
//ttaffAssessRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
|
37
|
//ttaffAssessRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
|
35
|
//
|
38
|
//
|
36
|
- //for i := range tasks {
|
|
|
37
|
- //
|
|
|
38
|
- // staffAssessService := service.NewStaffAssessServeice()
|
|
|
39
|
- // //staffAssessService.CreateStaffAssessTask()
|
|
|
40
|
- //
|
|
|
41
|
- // //task := tasks[i]
|
|
|
42
|
- //
|
39
|
+
|
|
|
40
|
+ projectIdsMap := map[int64]*domain.EvaluationProject{}
|
|
|
41
|
+ cycleIdsMap := map[int64]*domain.EvaluationCycle{}
|
|
|
42
|
+ for i := range tasks {
|
|
|
43
|
+ task := tasks[i]
|
|
|
44
|
+ projectIdsMap[task.ProjectId] = nil
|
|
|
45
|
+ cycleIdsMap[task.CycleId] = nil
|
|
|
46
|
+ }
|
|
|
47
|
+ projectIds := make([]int64, 0)
|
|
|
48
|
+ cycleIds := make([]int64, 0)
|
|
|
49
|
+ for k := range projectIdsMap {
|
|
|
50
|
+ projectIds = append(projectIds, k)
|
|
|
51
|
+ }
|
|
|
52
|
+ for k := range cycleIdsMap {
|
|
|
53
|
+ cycleIds = append(cycleIds, k)
|
|
|
54
|
+ }
|
|
|
55
|
+
|
|
|
56
|
+ _, projects, err := projectRepository.Find(map[string]interface{}{"ids": projectIds})
|
|
|
57
|
+ if err != nil {
|
|
|
58
|
+ return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
59
|
+ }
|
|
|
60
|
+ //_, cycles, err := cycleRepository.Find(map[string]interface{}{"ids": cycleIds})
|
|
|
61
|
+ //if err != nil {
|
|
|
62
|
+ // return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
43
|
//}
|
63
|
//}
|
44
|
|
64
|
|
|
|
65
|
+ for i := range projects {
|
|
|
66
|
+ projectIdsMap[projects[i].Id] = projects[i]
|
|
|
67
|
+ }
|
|
|
68
|
+
|
|
|
69
|
+ //staffAssessService := service.NewStaffAssessServeice()
|
|
|
70
|
+
|
45
|
for i := range tasks {
|
71
|
for i := range tasks {
|
46
|
task := tasks[i]
|
72
|
task := tasks[i]
|
|
|
73
|
+
|
|
|
74
|
+ //if project, ok := projectIdsMap[task.ProjectId]; ok {
|
|
|
75
|
+
|
|
|
76
|
+ //csat := &command.CreateStaffAssessTask{
|
|
|
77
|
+ // CompanyId: project.CompanyId,
|
|
|
78
|
+ // EvaluationProjectId: project.Id,
|
|
|
79
|
+ // EvaluationProjectName: project.Name,
|
|
|
80
|
+ // CycleId: project.CycleId,
|
|
|
81
|
+ //}
|
|
|
82
|
+ //
|
|
|
83
|
+ //staffAssessService.CreateStaffAssessTask(csat)
|
|
|
84
|
+ //}
|
|
|
85
|
+
|
47
|
// 下一次发送时间
|
86
|
// 下一次发送时间
|
48
|
nextTime := utils.NextTimeInc(task.NextSentAt, task.KpiCycle)
|
87
|
nextTime := utils.NextTimeInc(task.NextSentAt, task.KpiCycle)
|
49
|
task.NextSentAt = &nextTime
|
88
|
task.NextSentAt = &nextTime
|