1
|
package service
|
1
|
package service
|
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
|
|
4
|
+ "fmt"
|
4
|
"github.com/linmadan/egglib-go/core/application"
|
5
|
"github.com/linmadan/egglib-go/core/application"
|
|
|
6
|
+ "github.com/linmadan/egglib-go/utils/tool_funs"
|
5
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
6
|
service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
|
8
|
service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
12
|
+ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
|
|
|
13
|
+ "strings"
|
10
|
"time"
|
14
|
"time"
|
11
|
)
|
15
|
)
|
12
|
|
16
|
|
13
|
-// GetEvaluation360 获取360综评详情
|
17
|
+// Evaluation360List 获取360综评列表
|
|
|
18
|
+func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvaluation360List) (*adapter.SummaryEvaluationAdapter, error) {
|
|
|
19
|
+ transactionContext, err := factory.ValidateStartTransaction(param)
|
|
|
20
|
+ if err != nil {
|
|
|
21
|
+ return nil, err
|
|
|
22
|
+ }
|
|
|
23
|
+ defer func() {
|
|
|
24
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
25
|
+ }()
|
|
|
26
|
+
|
|
|
27
|
+ evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
28
|
+ evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
29
|
+ itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
30
|
+
|
|
|
31
|
+ var searchTargetName string
|
|
|
32
|
+ if len(param.SearchName) > 0 {
|
|
|
33
|
+ searchTargetName = "%" + param.SearchName + "%"
|
|
|
34
|
+ } else {
|
|
|
35
|
+ searchTargetName = ""
|
|
|
36
|
+ }
|
|
|
37
|
+ limit := param.PageSize
|
|
|
38
|
+ offset := limit * (param.PageNumber - 1)
|
|
|
39
|
+ if offset < 0 {
|
|
|
40
|
+ offset = 0
|
|
|
41
|
+ }
|
|
|
42
|
+ count, list, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
43
|
+ "companyId": param.CompanyId,
|
|
|
44
|
+ "cycleId": param.CycleId,
|
|
|
45
|
+ "executorId": param.UserId,
|
|
|
46
|
+ "types": domain.Evaluation360,
|
|
|
47
|
+ "targetUserName": searchTargetName,
|
|
|
48
|
+ "limit": limit,
|
|
|
49
|
+ "offset": offset,
|
|
|
50
|
+ })
|
|
|
51
|
+ if err != nil {
|
|
|
52
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
53
|
+ }
|
|
|
54
|
+
|
|
|
55
|
+ ids := make([]int, 0)
|
|
|
56
|
+ projectIds := make([]int, 0)
|
|
|
57
|
+ for i := range list {
|
|
|
58
|
+ ids = append(ids, list[i].Id)
|
|
|
59
|
+ projectIds = append(projectIds, list[i].EvaluationProjectId)
|
|
|
60
|
+ }
|
|
|
61
|
+
|
|
|
62
|
+ // 固定列
|
|
|
63
|
+ changeableHeader := []adapter.TableHeader{
|
|
|
64
|
+ {Key: "targetUserName", Name: "姓名"},
|
|
|
65
|
+ {Key: "statusVal", Name: "状态"},
|
|
|
66
|
+ {Key: "relation", Name: "360°评估关系"},
|
|
|
67
|
+ {Key: "endTime", Name: "360°评估截止日期"},
|
|
|
68
|
+ }
|
|
|
69
|
+ changeableRowMap := map[int]map[string]interface{}{} // k,v(用户ID -> 数据集合)行数据内容
|
|
|
70
|
+ itemMap := map[int][]*domain.EvaluationItemUsed{} // k,v(项目ID -> 评估数组)归类评估内容
|
|
|
71
|
+ valueMap := map[string]*domain.SummaryEvaluationValue{} // k,v(周期+评估 -> 提交值)
|
|
|
72
|
+ uniqueColumnsMap := map[string]string{} // 列名称唯一
|
|
|
73
|
+
|
|
|
74
|
+ if len(ids) > 0 {
|
|
|
75
|
+ // 评估内容(注.使用自评模板,并过滤出360综评人的评估内容)
|
|
|
76
|
+ _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectIds": projectIds, "node_type": domain.LinkNodeSelfAssessment, "evaluatorId": param.UserId})
|
|
|
77
|
+ if err != nil {
|
|
|
78
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
79
|
+ }
|
|
|
80
|
+ // 填写值
|
|
|
81
|
+ _, valueList, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": ids})
|
|
|
82
|
+ if err != nil {
|
|
|
83
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
84
|
+ }
|
|
|
85
|
+
|
|
|
86
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
87
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
88
|
+ }
|
|
|
89
|
+
|
|
|
90
|
+ for i := range valueList {
|
|
|
91
|
+ key := fmt.Sprintf("%d-%d", valueList[i].SummaryEvaluationId, valueList[i].EvaluationItemId)
|
|
|
92
|
+ valueMap[key] = valueList[i]
|
|
|
93
|
+ }
|
|
|
94
|
+
|
|
|
95
|
+ for i := range itemList {
|
|
|
96
|
+ item := itemList[i]
|
|
|
97
|
+ key := fmt.Sprintf("k%d", i)
|
|
|
98
|
+ name := fmt.Sprintf("%s-%s", item.Category, item.Name)
|
|
|
99
|
+ if _, ok := uniqueColumnsMap[name]; !ok {
|
|
|
100
|
+ changeableHeader = append(changeableHeader, adapter.TableHeader{Key: key, Name: name})
|
|
|
101
|
+ uniqueColumnsMap[name] = key
|
|
|
102
|
+ }
|
|
|
103
|
+
|
|
|
104
|
+ if pList, ok := itemMap[item.EvaluationProjectId]; !ok {
|
|
|
105
|
+ pList = make([]*domain.EvaluationItemUsed, 0)
|
|
|
106
|
+ itemMap[item.EvaluationProjectId] = pList
|
|
|
107
|
+ } else {
|
|
|
108
|
+ pList = append(pList, item)
|
|
|
109
|
+ }
|
|
|
110
|
+ }
|
|
|
111
|
+ }
|
|
|
112
|
+
|
|
|
113
|
+ now := time.Now().Local() // 当前时间
|
|
|
114
|
+ var rowMap map[string]interface{}
|
|
|
115
|
+ for i := range list {
|
|
|
116
|
+ v := list[i]
|
|
|
117
|
+ if rm, ok := changeableRowMap[v.TargetUser.UserId]; ok {
|
|
|
118
|
+ rowMap = rm
|
|
|
119
|
+ } else {
|
|
|
120
|
+ rowMap = map[string]interface{}{}
|
|
|
121
|
+ changeableRowMap[v.TargetUser.UserId] = rowMap
|
|
|
122
|
+ }
|
|
|
123
|
+
|
|
|
124
|
+ endTime := v.EndTime.Local()
|
|
|
125
|
+ statusVal := ""
|
|
|
126
|
+ if v.Status == domain.EvaluationCompleted {
|
|
|
127
|
+ statusVal = "已完成"
|
|
|
128
|
+ } else {
|
|
|
129
|
+ if now.After(endTime) {
|
|
|
130
|
+ statusVal = "已逾期"
|
|
|
131
|
+ } else {
|
|
|
132
|
+ statusVal = "待完成"
|
|
|
133
|
+ }
|
|
|
134
|
+ }
|
|
|
135
|
+ rowMap["id"] = v.Id
|
|
|
136
|
+ rowMap["targetUserName"] = v.TargetUser.UserName
|
|
|
137
|
+ rowMap["statusVal"] = statusVal
|
|
|
138
|
+ rowMap["relation"] = "项目组员"
|
|
|
139
|
+ rowMap["endTime"] = endTime.Format("2006-01-02 15:04")
|
|
|
140
|
+
|
|
|
141
|
+ // 当前项目所有评估内容
|
|
|
142
|
+ if pList, ok := itemMap[v.EvaluationProjectId]; ok {
|
|
|
143
|
+ for _, item := range pList {
|
|
|
144
|
+ name := fmt.Sprintf("%s-%s", item.Category, item.Name)
|
|
|
145
|
+ if key, ok := uniqueColumnsMap[name]; ok { // 动态列用name -> key
|
|
|
146
|
+ valueKey := fmt.Sprintf("%d-%d", v.Id, item.Id)
|
|
|
147
|
+ if it, ok := valueMap[valueKey]; ok {
|
|
|
148
|
+ rowMap[key] = it.Score
|
|
|
149
|
+ } else {
|
|
|
150
|
+ rowMap[key] = ""
|
|
|
151
|
+ }
|
|
|
152
|
+ }
|
|
|
153
|
+ }
|
|
|
154
|
+ }
|
|
|
155
|
+ }
|
|
|
156
|
+
|
|
|
157
|
+ targetList := make([]map[string]interface{}, 0)
|
|
|
158
|
+ for _, v1 := range list {
|
|
|
159
|
+ rowMap := changeableRowMap[v1.TargetUser.UserId]
|
|
|
160
|
+ for _, v2 := range changeableHeader { // 填充部分动态列缺失字段
|
|
|
161
|
+ if _, ok := rowMap[v2.Key]; !ok {
|
|
|
162
|
+ rowMap[v2.Key] = ""
|
|
|
163
|
+ }
|
|
|
164
|
+ }
|
|
|
165
|
+ targetList = append(targetList, rowMap)
|
|
|
166
|
+ }
|
|
|
167
|
+ result := &adapter.SummaryEvaluationAdapter{
|
|
|
168
|
+ TableHeader: changeableHeader,
|
|
|
169
|
+ Total: count,
|
|
|
170
|
+ List: targetList,
|
|
|
171
|
+ }
|
|
|
172
|
+ return result, nil
|
|
|
173
|
+}
|
|
|
174
|
+
|
|
|
175
|
+// GetEvaluation360 获取360综评详情(登录人作为评估人,评估内容)
|
14
|
func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) {
|
176
|
func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) {
|
15
|
transactionContext, err := factory.ValidateStartTransaction(param)
|
177
|
transactionContext, err := factory.ValidateStartTransaction(param)
|
16
|
if err != nil {
|
178
|
if err != nil {
|
|
@@ -24,12 +186,26 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua |
|
@@ -24,12 +186,26 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua |
24
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
186
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
25
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
187
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
26
|
|
188
|
|
27
|
- sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
|
189
|
+ //sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
|
|
|
190
|
+ //if err != nil {
|
|
|
191
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
192
|
+ //}
|
|
|
193
|
+ _, evaluations, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
194
|
+ "limit": 1,
|
|
|
195
|
+ "companyId": param.CompanyId,
|
|
|
196
|
+ "cycleId": param.CycleId,
|
|
|
197
|
+ "targetUserId": param.TargetUserId,
|
|
|
198
|
+ "types": domain.Evaluation360},
|
|
|
199
|
+ )
|
28
|
if err != nil {
|
200
|
if err != nil {
|
29
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
201
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
30
|
}
|
202
|
}
|
|
|
203
|
+ if len(evaluations) == 0 {
|
|
|
204
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
|
|
|
205
|
+ }
|
|
|
206
|
+ sEvaluation := evaluations[0]
|
31
|
|
207
|
|
32
|
- // 自评评估内容(自评模板、筛选项目评估人)
|
208
|
+ // 360评估内容(自评模板、筛选项目评估人)
|
33
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
209
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
34
|
"evaluationProjectId": sEvaluation.EvaluationProjectId,
|
210
|
"evaluationProjectId": sEvaluation.EvaluationProjectId,
|
35
|
"nodeType": domain.LinkNodeSelfAssessment,
|
211
|
"nodeType": domain.LinkNodeSelfAssessment,
|
|
@@ -67,6 +243,98 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua |
|
@@ -67,6 +243,98 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua |
67
|
return &result, nil
|
243
|
return &result, nil
|
68
|
}
|
244
|
}
|
69
|
|
245
|
|
|
|
246
|
+// GetEvaluation360All 获取360综评详情-上级综评(所有的评估人,评估内容)
|
|
|
247
|
+func (srv *SummaryEvaluationService) GetEvaluation360All(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) {
|
|
|
248
|
+ transactionContext, err := factory.ValidateStartTransaction(param)
|
|
|
249
|
+ if err != nil {
|
|
|
250
|
+ return nil, err
|
|
|
251
|
+ }
|
|
|
252
|
+ defer func() {
|
|
|
253
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
254
|
+ }()
|
|
|
255
|
+
|
|
|
256
|
+ userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
257
|
+ evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
258
|
+ evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
259
|
+ itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
260
|
+ _, evaluations, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
261
|
+ "limit": 1,
|
|
|
262
|
+ "companyId": param.CompanyId,
|
|
|
263
|
+ "cycleId": param.CycleId,
|
|
|
264
|
+ "targetUserId": param.TargetUserId,
|
|
|
265
|
+ "types": domain.Evaluation360},
|
|
|
266
|
+ )
|
|
|
267
|
+ if err != nil {
|
|
|
268
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
269
|
+ }
|
|
|
270
|
+ if len(evaluations) == 0 {
|
|
|
271
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
|
|
|
272
|
+ }
|
|
|
273
|
+ sEvaluation := evaluations[0]
|
|
|
274
|
+
|
|
|
275
|
+ // 360评估内容(自评模板)
|
|
|
276
|
+ _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
|
|
277
|
+ "evaluationProjectId": sEvaluation.EvaluationProjectId,
|
|
|
278
|
+ "nodeType": domain.LinkNodeSelfAssessment,
|
|
|
279
|
+ })
|
|
|
280
|
+ if err != nil {
|
|
|
281
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
282
|
+ }
|
|
|
283
|
+
|
|
|
284
|
+ // 评估内容对应的分数
|
|
|
285
|
+ _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": sEvaluation.Id})
|
|
|
286
|
+ if err != nil {
|
|
|
287
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
288
|
+ }
|
|
|
289
|
+
|
|
|
290
|
+ // 评估人ID -> User
|
|
|
291
|
+ evaluatorMap := map[int]*domain.User{}
|
|
|
292
|
+ evaluatorIds := make([]int, 0)
|
|
|
293
|
+ filterItemList := make([]*domain.EvaluationItemUsed, 0) // 筛选有评估人的评估内容
|
|
|
294
|
+ for i := range itemList {
|
|
|
295
|
+ if itemList[i].EvaluatorId > 0 {
|
|
|
296
|
+ filterItemList = append(filterItemList, itemList[i])
|
|
|
297
|
+ evaluatorIds = append(evaluatorIds, itemList[i].EvaluatorId)
|
|
|
298
|
+ }
|
|
|
299
|
+ }
|
|
|
300
|
+ if len(evaluatorIds) > 0 {
|
|
|
301
|
+ _, users, err := userRepo.Find(map[string]interface{}{"ids": evaluatorIds})
|
|
|
302
|
+ if err != nil {
|
|
|
303
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
304
|
+ }
|
|
|
305
|
+ for i := range users {
|
|
|
306
|
+ evaluatorMap[int(users[i].Id)] = users[i]
|
|
|
307
|
+ }
|
|
|
308
|
+ }
|
|
|
309
|
+
|
|
|
310
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
311
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
312
|
+ }
|
|
|
313
|
+
|
|
|
314
|
+ itemValuesAdapter := srv.buildSummaryItemValue(filterItemList, itemValues)
|
|
|
315
|
+ for i := range itemValuesAdapter { // 评估人名称赋值
|
|
|
316
|
+ if user, ok := evaluatorMap[itemValuesAdapter[i].EvaluatorId]; ok {
|
|
|
317
|
+ itemValuesAdapter[i].EvaluatorName = user.Name
|
|
|
318
|
+ }
|
|
|
319
|
+ }
|
|
|
320
|
+
|
|
|
321
|
+ result := adapter.EvaluationInfoAdapter{
|
|
|
322
|
+ SummaryEvaluationId: sEvaluation.Id,
|
|
|
323
|
+ CycleId: int(sEvaluation.CycleId),
|
|
|
324
|
+ CycleName: sEvaluation.CycleName,
|
|
|
325
|
+ EvaluationProjectId: sEvaluation.EvaluationProjectId,
|
|
|
326
|
+ EvaluationProjectName: sEvaluation.EvaluationProjectName,
|
|
|
327
|
+ LinkNodeId: sEvaluation.NodeId,
|
|
|
328
|
+ BeginTime: sEvaluation.BeginTime.Format("2006-01-02 15:04:05"),
|
|
|
329
|
+ EndTime: sEvaluation.EndTime.Format("2006-01-02 15:04:05"),
|
|
|
330
|
+ TargetUserId: sEvaluation.TargetUser.UserId,
|
|
|
331
|
+ TargetUserName: sEvaluation.TargetUser.UserName,
|
|
|
332
|
+ Status: string(sEvaluation.Status),
|
|
|
333
|
+ EvaluationItems: itemValuesAdapter,
|
|
|
334
|
+ }
|
|
|
335
|
+ return &result, nil
|
|
|
336
|
+}
|
|
|
337
|
+
|
70
|
// EditEvaluation360 编辑提交360综评
|
338
|
// EditEvaluation360 编辑提交360综评
|
71
|
func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) {
|
339
|
func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) {
|
72
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
340
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
@@ -166,6 +434,162 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua |
|
@@ -166,6 +434,162 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua |
166
|
}, nil
|
434
|
}, nil
|
167
|
}
|
435
|
}
|
168
|
|
436
|
|
|
|
437
|
+// EvaluationHRBPList 获取人资综评列表
|
|
|
438
|
+func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEvaluationHRList) (map[string]interface{}, error) {
|
|
|
439
|
+ transactionContext, err := factory.ValidateStartTransaction(param)
|
|
|
440
|
+ if err != nil {
|
|
|
441
|
+ return nil, err
|
|
|
442
|
+ }
|
|
|
443
|
+ defer func() {
|
|
|
444
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
445
|
+ }()
|
|
|
446
|
+
|
|
|
447
|
+ // 必须是HRBP权限的人才能编辑操作
|
|
|
448
|
+ hrbp, err := service.GetHRBP(transactionContext, param.CompanyId, param.UserId)
|
|
|
449
|
+ if hrbp != 1 {
|
|
|
450
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
451
|
+ }
|
|
|
452
|
+
|
|
|
453
|
+ evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
454
|
+ staffAssessDaoRepo := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
455
|
+ userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
456
|
+ positionRepo := factory.CreatePositionRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
457
|
+ var searchTargetName string
|
|
|
458
|
+ if len(param.SearchName) > 0 {
|
|
|
459
|
+ searchTargetName = "%" + param.SearchName + "%"
|
|
|
460
|
+ } else {
|
|
|
461
|
+ searchTargetName = ""
|
|
|
462
|
+ }
|
|
|
463
|
+ limit := param.PageSize
|
|
|
464
|
+ offset := limit * (param.PageNumber - 1)
|
|
|
465
|
+ if offset < 0 {
|
|
|
466
|
+ offset = 0
|
|
|
467
|
+ }
|
|
|
468
|
+ count, list, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
469
|
+ "companyId": param.CompanyId,
|
|
|
470
|
+ "cycleId": param.CycleId,
|
|
|
471
|
+ "executorId": -1,
|
|
|
472
|
+ "types": domain.EvaluationHrbp,
|
|
|
473
|
+ "targetUserName": searchTargetName,
|
|
|
474
|
+ "limit": limit,
|
|
|
475
|
+ "offset": offset,
|
|
|
476
|
+ })
|
|
|
477
|
+ if err != nil {
|
|
|
478
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
479
|
+ }
|
|
|
480
|
+
|
|
|
481
|
+ userIds := make([]int, 0)
|
|
|
482
|
+ positionIds := make([]int, 0)
|
|
|
483
|
+ projectIds := make([]int, 0)
|
|
|
484
|
+ projectCountMap := map[string]int{} // 自评逾期数量
|
|
|
485
|
+ userMap := map[int64]*domain.User{} // 用户
|
|
|
486
|
+ positionMap := map[int64]*domain.Position{} // 职位
|
|
|
487
|
+
|
|
|
488
|
+ for i := range list {
|
|
|
489
|
+ it := list[i]
|
|
|
490
|
+ userIds = append(userIds, it.TargetUser.UserId)
|
|
|
491
|
+ projectIds = append(projectIds, list[i].EvaluationProjectId)
|
|
|
492
|
+ }
|
|
|
493
|
+ _, users, err := userRepo.Find(map[string]interface{}{"ids": userIds, "companyId": param.CompanyId})
|
|
|
494
|
+ if err != nil {
|
|
|
495
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
496
|
+ }
|
|
|
497
|
+ for i := range users {
|
|
|
498
|
+ userMap[users[i].Id] = users[i]
|
|
|
499
|
+ for _, pid := range users[i].PositionId {
|
|
|
500
|
+ positionIds = append(positionIds, pid)
|
|
|
501
|
+ }
|
|
|
502
|
+ }
|
|
|
503
|
+ _, positions, err := positionRepo.Find(map[string]interface{}{"ids": positionIds, "companyId": param.CompanyId})
|
|
|
504
|
+ if err != nil {
|
|
|
505
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
506
|
+ }
|
|
|
507
|
+ for i := range positions {
|
|
|
508
|
+ positionMap[positions[i].Id] = positions[i]
|
|
|
509
|
+ }
|
|
|
510
|
+
|
|
|
511
|
+ if len(projectIds) > 0 {
|
|
|
512
|
+ targetCount, err := staffAssessDaoRepo.CountUncompletedSelfAssess(param.CompanyId, projectIds)
|
|
|
513
|
+ if err != nil {
|
|
|
514
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
515
|
+ }
|
|
|
516
|
+ for i := range targetCount {
|
|
|
517
|
+ key := fmt.Sprintf("%d-%d", targetCount[i].EvaluationProjectId, targetCount[i].TargetUserId)
|
|
|
518
|
+ projectCountMap[key] = targetCount[i].Cnt
|
|
|
519
|
+ }
|
|
|
520
|
+ }
|
|
|
521
|
+
|
|
|
522
|
+ now := time.Now().Local() // 当前时间
|
|
|
523
|
+ resultList := make([]*adapter.SummaryEvaluationHRBPAdapter, 0)
|
|
|
524
|
+ for i := range list {
|
|
|
525
|
+ v := list[i]
|
|
|
526
|
+ endTime := v.EndTime.Local()
|
|
|
527
|
+ // 状态
|
|
|
528
|
+ statusVal := ""
|
|
|
529
|
+ if v.Status == domain.EvaluationCompleted {
|
|
|
530
|
+ statusVal = "已完成"
|
|
|
531
|
+ } else {
|
|
|
532
|
+ if now.After(endTime) {
|
|
|
533
|
+ statusVal = "已逾期"
|
|
|
534
|
+ } else {
|
|
|
535
|
+ statusVal = "待完成"
|
|
|
536
|
+ }
|
|
|
537
|
+ }
|
|
|
538
|
+
|
|
|
539
|
+ // 部门拼接
|
|
|
540
|
+ var departmentBuild strings.Builder
|
|
|
541
|
+ departmentBuild.WriteString("")
|
|
|
542
|
+ for i2 := range v.TargetDepartment {
|
|
|
543
|
+ departmentBuild.WriteString(v.TargetDepartment[i2].DepartmentName)
|
|
|
544
|
+ if i2 != len(v.TargetDepartment)-1 {
|
|
|
545
|
+ departmentBuild.WriteString(",")
|
|
|
546
|
+ }
|
|
|
547
|
+ }
|
|
|
548
|
+ // 入职时间
|
|
|
549
|
+ entryTime := ""
|
|
|
550
|
+ // 职位拼接
|
|
|
551
|
+ var positionBuild strings.Builder
|
|
|
552
|
+ positionBuild.WriteString("")
|
|
|
553
|
+ if user, ok := userMap[int64(v.TargetUser.UserId)]; ok {
|
|
|
554
|
+ for i2 := range user.PositionId {
|
|
|
555
|
+ if position, ok := positionMap[int64(user.PositionId[i2])]; ok {
|
|
|
556
|
+ positionBuild.WriteString(position.Name)
|
|
|
557
|
+ if i2 != len(user.PositionId)-1 {
|
|
|
558
|
+ departmentBuild.WriteString(",")
|
|
|
559
|
+ }
|
|
|
560
|
+ }
|
|
|
561
|
+ }
|
|
|
562
|
+ entryTime = user.EntryTime
|
|
|
563
|
+ }
|
|
|
564
|
+
|
|
|
565
|
+ // 自评逾期数量
|
|
|
566
|
+ overdueCount := 0
|
|
|
567
|
+ key := fmt.Sprintf("%d-%d", v.EvaluationProjectId, v.TargetUser.UserId)
|
|
|
568
|
+ if cnt, ok := projectCountMap[key]; ok {
|
|
|
569
|
+ overdueCount = cnt
|
|
|
570
|
+ }
|
|
|
571
|
+
|
|
|
572
|
+ result := &adapter.SummaryEvaluationHRBPAdapter{
|
|
|
573
|
+ Id: v.Id,
|
|
|
574
|
+ TargetUserId: v.TargetUser.UserId,
|
|
|
575
|
+ TargetUserName: v.TargetUser.UserName,
|
|
|
576
|
+ Department: departmentBuild.String(),
|
|
|
577
|
+ Position: positionBuild.String(),
|
|
|
578
|
+ DutyTime: entryTime,
|
|
|
579
|
+ Status: statusVal,
|
|
|
580
|
+ EndTime: endTime.Format("2006-01-02 15:04"),
|
|
|
581
|
+ OverdueCount: overdueCount,
|
|
|
582
|
+ }
|
|
|
583
|
+ resultList = append(resultList, result)
|
|
|
584
|
+ }
|
|
|
585
|
+
|
|
|
586
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
587
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
588
|
+ }
|
|
|
589
|
+
|
|
|
590
|
+ return tool_funs.SimpleWrapGridMap(int64(count), resultList), nil
|
|
|
591
|
+}
|
|
|
592
|
+
|
169
|
// GetEvaluationHRBP 获取人资综评详情
|
593
|
// GetEvaluationHRBP 获取人资综评详情
|
170
|
func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvaluationHRBP) (*adapter.EvaluationInfoAdapter, error) {
|
594
|
func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvaluationHRBP) (*adapter.EvaluationInfoAdapter, error) {
|
171
|
transactionContext, err := factory.ValidateStartTransaction(param)
|
595
|
transactionContext, err := factory.ValidateStartTransaction(param)
|
|
@@ -180,10 +604,21 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu |
|
@@ -180,10 +604,21 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu |
180
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
604
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
181
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
605
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
182
|
|
606
|
|
183
|
- sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
|
607
|
+ _, evaluations, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
608
|
+ "limit": 1,
|
|
|
609
|
+ "companyId": param.CompanyId,
|
|
|
610
|
+ "cycleId": param.CycleId,
|
|
|
611
|
+ "targetUserId": param.TargetUserId,
|
|
|
612
|
+ "types": domain.EvaluationHrbp},
|
|
|
613
|
+ )
|
|
|
614
|
+ // sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
|
184
|
if err != nil {
|
615
|
if err != nil {
|
185
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
616
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
186
|
}
|
617
|
}
|
|
|
618
|
+ if len(evaluations) == 0 {
|
|
|
619
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
|
|
|
620
|
+ }
|
|
|
621
|
+ sEvaluation := evaluations[0]
|
187
|
|
622
|
|
188
|
// 自评评估内容(自评模板、筛选项目评估人)
|
623
|
// 自评评估内容(自评模板、筛选项目评估人)
|
189
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
624
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|