get_evaluation_360.go
3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// GetEvaluation360Complete 获取360综评详情(他人评估目标用户)(已完成状态)
func (srv *SummaryEvaluationService) GetEvaluation360CompleteV2(param *command.QueryEvaluation360) (*adapter.EvaluationInfoSelfAdapter, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
_, evaluations, err := evaluationRepo.Find(map[string]interface{}{
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"types": domain.Evaluation360,
"status": domain.EvaluationCompleted,
"limit": 1000,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluations) == 0 {
list := make([]adapter.EvaluationItemAdapter, 0)
res := adapter.EvaluationInfoSelfAdapter{
EvaluationItems: list,
}
return &res, nil
}
executorMap := map[int]domain.StaffDesc{} // 执行人
evaluationIds := make([]int, 0) // 评估周期ID
for i := range evaluations {
executor := evaluations[i].Executor
executorMap[executor.UserId] = executor
evaluationIds = append(evaluationIds, evaluations[i].Id)
}
// 得到项目ID
evaluationProjectId := evaluations[0].EvaluationProjectId
// 360评估内容(自评模板)
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": evaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 评估内容对应的分数
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{
"summaryEvaluationIdList": evaluationIds,
"types": domain.Evaluation360,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
filterItemList := make([]*domain.EvaluationItemUsed, 0) // 筛选有评估人的评估内容
for i := range itemList {
if itemList[i].EvaluatorId > 0 {
filterItemList = append(filterItemList, itemList[i])
}
}
// 获取组装基本信息
evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluations[0])
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
itemValuesAdapter := srv.buildSummaryItemValue(filterItemList, itemValues)
for i := range itemValuesAdapter { // 评估人名称赋值
if executor, ok := executorMap[itemValuesAdapter[i].EvaluatorId]; ok {
itemValuesAdapter[i].EvaluatorName = executor.UserName
}
}
result := adapter.EvaluationInfoSelfAdapter{
EvaluationBaseAdapter: evaluationBase,
EvaluationItems: itemValuesAdapter,
}
return &result, nil
}