service2.go
22.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
package service
import (
"fmt"
"strconv"
"strings"
"time"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
roleService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
"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"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
)
// Evaluation360List 获取360综评列表
func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvaluation360List) (map[string]interface{}, 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})
var searchTargetName string
if len(param.SearchName) > 0 {
searchTargetName = "%" + param.SearchName + "%"
} else {
searchTargetName = ""
}
limit := param.PageSize
offset := limit * (param.PageNumber - 1)
if offset < 0 {
offset = 0
}
count, list, err := evaluationRepo.Find(map[string]interface{}{
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"executorId": param.UserId,
"types": domain.Evaluation360,
"targetUserName": searchTargetName,
"limit": limit,
"offset": offset,
"beginTime": time.Now(),
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
ids := make([]int, 0)
projectIds := make([]int, 0)
for i := range list {
ids = append(ids, list[i].Id)
projectIds = append(projectIds, list[i].EvaluationProjectId)
}
// 固定列
changeableHeader := []adapter.TableHeader{
{Key: "targetUserName", Name: "姓名"},
{Key: "statusVal", Name: "状态"},
{Key: "relation", Name: "360°评估关系"},
{Key: "endTime", Name: "360°评估截止日期"},
}
changeableRowMap := map[int]map[string]interface{}{} // k,v(用户ID -> 数据集合)行数据内容
itemMap := map[int][]*domain.EvaluationItemUsed{} // k,v(项目ID -> 评估数组)归类评估内容
valueMap := map[string]*domain.SummaryEvaluationValue{} // k,v(周期+评估 -> 提交值)
uniqueColumnsMap := map[string]string{} // 列名称唯一
if len(ids) > 0 {
// 评估内容(注.使用自评模板,并过滤出360综评人的评估内容)
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectIds": projectIds, "nodeType": domain.LinkNodeSelfAssessment, "evaluatorId": param.UserId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 填写值
_, valueList, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": ids})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for i := range valueList {
key := fmt.Sprintf("%d-%d", valueList[i].SummaryEvaluationId, valueList[i].EvaluationItemId)
valueMap[key] = valueList[i]
}
for i := range itemList {
item := itemList[i]
key := fmt.Sprintf("k%d", i)
name := fmt.Sprintf("%s-%s", item.Category, item.Name)
if _, ok := uniqueColumnsMap[name]; !ok {
changeableHeader = append(changeableHeader, adapter.TableHeader{Key: key, Name: name})
uniqueColumnsMap[name] = key
}
pList, ok := itemMap[item.EvaluationProjectId]
if !ok {
pList = make([]*domain.EvaluationItemUsed, 0)
}
itemMap[item.EvaluationProjectId] = append(pList, item)
}
}
now := time.Now().Local() // 当前时间
var rowMap map[string]interface{}
for i := range list {
v := list[i]
if rm, ok := changeableRowMap[v.TargetUser.UserId]; ok {
rowMap = rm
} else {
rowMap = map[string]interface{}{}
changeableRowMap[v.TargetUser.UserId] = rowMap
}
endTime := v.EndTime.Local()
statusVal := ""
if v.Status == domain.EvaluationCompleted {
statusVal = "已完成"
} else {
if now.After(endTime) {
statusVal = "已逾期"
} else {
statusVal = "待完成"
}
}
rowMap["id"] = v.Id
rowMap["targetUserId"] = strconv.Itoa(v.TargetUser.UserId)
rowMap["targetUserName"] = v.TargetUser.UserName
rowMap["statusVal"] = statusVal
rowMap["relation"] = "项目组员"
rowMap["endTime"] = endTime.Local().Format("2006-01-02 15:04")
// 当前项目所有评估内容
if pList, ok := itemMap[v.EvaluationProjectId]; ok {
for _, item := range pList {
name := fmt.Sprintf("%s-%s", item.Category, item.Name)
if key, ok := uniqueColumnsMap[name]; ok { // 动态列用name -> key
valueKey := fmt.Sprintf("%d-%d", v.Id, item.Id)
if it, ok := valueMap[valueKey]; ok {
if it.Weight > 0 {
rowMap[key] = it.Score
} else {
rowMap[key] = it.Rating.Code
}
} else {
rowMap[key] = ""
}
}
}
}
}
targetList := make([]map[string]interface{}, 0)
for _, v1 := range list {
rowMap := changeableRowMap[v1.TargetUser.UserId]
for _, v2 := range changeableHeader { // 填充部分动态列缺失字段
if _, ok := rowMap[v2.Key]; !ok {
rowMap[v2.Key] = ""
}
}
targetList = append(targetList, rowMap)
}
// 外层显示截止时间
endTime := ""
if len(list) > 0 {
endTime = list[0].EndTime.Local().Format("2006-01-02 15:04:05")
}
result := &adapter.SummaryEvaluationAdapter{
TableHeader: changeableHeader,
Total: count,
List: targetList,
}
grid := map[string]interface{}{
"grid": result,
"endTime": endTime,
}
return grid, nil
}
// GetEvaluation360 获取360综评详情(我评估目标用户)
func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvaluation360My) (map[string]interface{}, 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})
sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 360评估内容(自评模板、筛选项目评估人)
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": sEvaluation.EvaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
"companyId": param.CompanyId,
"evaluatorId": param.UserId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 评估内容对应的分数
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": sEvaluation.Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
for i := range itemValuesAdapter { // 评估人名称赋值
itemValuesAdapter[i].EvaluatorName = sEvaluation.Executor.UserName
}
// 评估项截止时间
endTime := sEvaluation.EndTime.Local().Format("2006-01-02 15:04:05")
return map[string]interface{}{"endTime": endTime, "version": sEvaluation.Version, "list": itemValuesAdapter}, nil
}
// GetEvaluation360Complete 获取360综评详情(他人评估目标用户)(已完成状态)
func (srv *SummaryEvaluationService) GetEvaluation360Complete(param *command.QueryEvaluation360) ([]adapter.EvaluationItemAdapter, 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)
return list, 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])
}
}
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
}
}
return itemValuesAdapter, nil
}
// EvaluationHRBPList 获取人资综评列表
func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEvaluationHRList) (map[string]interface{}, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 必须是HRBP权限的人才能编辑操作
hrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if hrbp != domain.RoleTypeSystem {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
}
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
staffAssessDaoRepo := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
positionRepo := factory.CreatePositionRepository(map[string]interface{}{"transactionContext": transactionContext})
limit := param.PageSize
offset := limit * (param.PageNumber - 1)
if offset < 0 {
offset = 0
}
condition := map[string]interface{}{
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"types": domain.EvaluationHrbp,
"limit": limit,
"offset": offset,
"beginTime": time.Now(),
}
if len(param.SearchName) > 0 {
condition["targetUserName"] = "%" + param.SearchName + "%"
}
count, list, err := evaluationRepo.Find(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
userIds := make([]int, 0)
projectIds := make([]int, 0)
projectCountMap := map[string]int{} // 自评逾期数量
userMap := map[int64]*domain.User{} // 用户
positionMap := map[int64]*domain.Position{} // 职位
for i := range list {
it := list[i]
userIds = append(userIds, it.TargetUser.UserId)
projectIds = append(projectIds, list[i].EvaluationProjectId)
}
if len(userIds) > 0 {
_, users, err := userRepo.Find(map[string]interface{}{"ids": userIds, "companyId": param.CompanyId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
positionIds := make([]int, 0)
for i := range users {
userMap[users[i].Id] = users[i]
positionIds = append(positionIds, users[i].PositionId...)
}
if len(positionIds) > 0 {
_, positions, err := positionRepo.Find(map[string]interface{}{"ids": positionIds, "companyId": param.CompanyId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for i := range positions {
positionMap[positions[i].Id] = positions[i]
}
}
}
if len(projectIds) > 0 {
targetCount, err := staffAssessDaoRepo.CountUncompletedSelfAssess(param.CompanyId, projectIds)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for i := range targetCount {
key := fmt.Sprintf("%d-%d", targetCount[i].EvaluationProjectId, targetCount[i].TargetUserId)
projectCountMap[key] = targetCount[i].Cnt
}
}
now := time.Now().Local() // 当前时间
resultList := make([]*adapter.SummaryEvaluationHRBPAdapter, 0)
for i := range list {
v := list[i]
endTime := v.EndTime.Local()
// 状态
statusVal := ""
if v.Status == domain.EvaluationCompleted {
statusVal = "已完成"
} else {
if now.After(endTime) {
statusVal = "已逾期"
} else {
statusVal = "待完成"
}
}
// 部门拼接
var departmentBuild strings.Builder
departmentBuild.WriteString("")
for i2 := range v.TargetDepartment {
departmentBuild.WriteString(v.TargetDepartment[i2].DepartmentName)
if i2 != len(v.TargetDepartment)-1 {
departmentBuild.WriteString(",")
}
}
// 入职时间
entryTime := ""
// 职位拼接
var positionBuild strings.Builder
positionBuild.WriteString("")
if user, ok := userMap[int64(v.TargetUser.UserId)]; ok {
for i2 := range user.PositionId {
if position, ok := positionMap[int64(user.PositionId[i2])]; ok {
positionBuild.WriteString(position.Name)
if i2 != len(user.PositionId)-1 {
departmentBuild.WriteString(",")
}
}
}
entryTime = user.EntryTime
}
// 自评逾期数量
overdueCount := 0
key := fmt.Sprintf("%d-%d", v.EvaluationProjectId, v.TargetUser.UserId)
if cnt, ok := projectCountMap[key]; ok {
overdueCount = cnt
}
result := &adapter.SummaryEvaluationHRBPAdapter{
Id: v.Id,
TargetUserId: v.TargetUser.UserId,
TargetUserName: v.TargetUser.UserName,
Department: departmentBuild.String(),
Position: positionBuild.String(),
DutyTime: entryTime,
Status: statusVal,
EndTime: endTime.Local().Format("2006-01-02 15:04"),
OverdueCount: overdueCount,
}
resultList = append(resultList, result)
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 外层显示截止时间
endTime := ""
if len(list) > 0 {
endTime = list[0].EndTime.Local().Format("2006-01-02 15:04:05")
}
grid := tool_funs.SimpleWrapGridMap(int64(count), resultList)
grid["endTime"] = endTime
return grid, nil
//return tool_funs.SimpleWrapGridMap(int64(count), resultList), nil
}
// GetEvaluationHRBP 获取人资综评详情
func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvaluationHRBPMy) (map[string]interface{}, 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})
sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 自评评估内容(自评模板、筛选项目评估人)
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": sEvaluation.EvaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
"evaluatorId": -1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 评估内容对应的分数
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": sEvaluation.Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
for i := range itemValuesAdapter { // 评估人名称赋值
itemValuesAdapter[i].EvaluatorName = sEvaluation.Executor.UserName
}
// 评估项截止时间
endTime := sEvaluation.EndTime.Local().Format("2006-01-02 15:04:05")
return map[string]interface{}{"endTime": endTime, "version": sEvaluation.Version, "list": itemValuesAdapter}, nil
}
// GetEvaluationHRBPComplete 获取人资综评详情(已完成状态)
func (srv *SummaryEvaluationService) GetEvaluationHRBPComplete(param *command.QueryEvaluationHRBP) (*[]adapter.EvaluationItemAdapter, 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{}{
"limit": 99999,
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"status": domain.EvaluationCompleted,
"types": domain.EvaluationHrbp},
)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluations) == 0 {
list := make([]adapter.EvaluationItemAdapter, 0)
return &list, nil
}
evaluationIds := make([]int, 0) // 评估周期ID
for i := range evaluations {
evaluationIds = append(evaluationIds, evaluations[i].Id)
}
// 得到项目ID
evaluationProjectId := evaluations[0].EvaluationProjectId
// 自评评估内容(自评模板、筛选项目评估人)
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": evaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
"evaluatorId": -1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 评估内容对应的分数
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{
"summaryEvaluationIdList": evaluationIds,
"types": domain.EvaluationHrbp,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
for i := range itemValuesAdapter { // 评估人名称赋值
itemValuesAdapter[i].EvaluatorName = evaluations[0].Executor.UserName
}
return &itemValuesAdapter, nil
}
// GetUnconfirmedCycleList 获取未确认绩效成绩的周期列表
func (srv *SummaryEvaluationService) GetUnconfirmedCycleList(companyId int, userId int) (map[string]interface{}, error) {
transactionContext, err := factory.StartTransaction()
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{"transactionContext": transactionContext})
cycles, err := evaluationDao.TargetUnconfirmedCycleList(companyId, userId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取周期列表"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var cycleList []adapter.CycleListAdapter
nowTime := time.Now()
for _, v := range cycles {
if nowTime.Before(v.EndTime) {
continue
}
cycleList = append(cycleList, adapter.CycleListAdapter{
CycleId: v.CycleId,
CycleName: v.CycleName,
})
}
return tool_funs.SimpleWrapGridMap(int64(len(cycleList)), cycleList), nil
}