get_evaluation.go
4.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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"
)
// 评估信息详情 根据页面需要提供不同的结构变体
// 人资稽查-页面列表,获取详情 用于编辑展示
func (srv *SummaryEvaluationService) GetEvaluationShow1(param command.QueryEvaluation) (result *adapter.EvaluationInfoAdapter, err error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
//每个人员每个周期的评估目录
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
// 评估的填写值
evaluationValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
//评估用到的题目
itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
//获取 评估考核结果
var evaluationList []*domain.SummaryEvaluation
var evaluationValueList []*domain.SummaryEvaluationValue
_, evaluationList, err = evaluationRepo.Find(map[string]interface{}{
"limit": 1,
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"types": domain.EvaluationFinish,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluationList) == 0 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "该人员缺少考评评估结果")
}
if len(evaluationList) > 0 {
_, evaluationValueList, err = evaluationValueRepo.Find(map[string]interface{}{"summaryEvaluationId": evaluationList[0].Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
//如果没有评估考核结果,就获取上级评估的内容
if len(evaluationValueList) == 0 {
_, evaluationList2, err := evaluationRepo.Find(map[string]interface{}{
"limit": 1,
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"types": domain.EvaluationSuper,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluationList2) > 0 {
_, evaluationValueList, err = evaluationValueRepo.Find(map[string]interface{}{"summaryEvaluationId": evaluationList2[0].Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
// 如果没有评估考核结果的填写内容
// 也没有上级评估
// 就查找 360 或人资评估数据
if len(evaluationList2) == 0 {
_, evaluationList3, err := evaluationRepo.Find(map[string]interface{}{
"limit": 500,
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"typesList": []int{int(domain.EvaluationHrbp), int(domain.Evaluation360)},
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
evaluationIds := []int{}
for _, val := range evaluationList3 {
evaluationIds = append(evaluationIds, val.Id)
}
if len(evaluationIds) > 0 {
_, evaluationValueList, err = evaluationValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
}
}
evaluationProjectId := evaluationList[0].EvaluationProjectId
//获取所有题目
_, itemUsedList, err := itemUsedRepo.Find(map[string]interface{}{
"evaluationProjectId": evaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
})
// 获取组装基本信息
evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationList[0])
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
itemValuesAdapter := srv.buildSummaryItemValue(itemUsedList, evaluationValueList)
result = &adapter.EvaluationInfoAdapter{
EvaluationBaseAdapter: evaluationBase,
EvaluationItems: itemValuesAdapter,
}
return
}