|
@@ -3,14 +3,18 @@ package service |
|
@@ -3,14 +3,18 @@ package service |
3
|
import (
|
3
|
import (
|
4
|
"fmt"
|
4
|
"fmt"
|
5
|
"github.com/linmadan/egglib-go/core/application"
|
5
|
"github.com/linmadan/egglib-go/core/application"
|
|
|
6
|
+ "github.com/linmadan/egglib-go/utils/tool_funs"
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
7
|
service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
|
8
|
service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
|
10
|
"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"
|
11
|
"time"
|
14
|
"time"
|
12
|
)
|
15
|
)
|
13
|
|
16
|
|
|
|
17
|
+// Evaluation360List 获取360综评列表
|
14
|
func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvaluation360List) (*adapter.SummaryEvaluationAdapter, error) {
|
18
|
func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvaluation360List) (*adapter.SummaryEvaluationAdapter, error) {
|
15
|
transactionContext, err := factory.ValidateStartTransaction(param)
|
19
|
transactionContext, err := factory.ValidateStartTransaction(param)
|
16
|
if err != nil {
|
20
|
if err != nil {
|
|
@@ -182,10 +186,24 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua |
|
@@ -182,10 +186,24 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua |
182
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
186
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
183
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
187
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
184
|
|
188
|
|
185
|
- 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
|
+ )
|
186
|
if err != nil {
|
200
|
if err != nil {
|
187
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
201
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
188
|
}
|
202
|
}
|
|
|
203
|
+ if len(evaluations) == 0 {
|
|
|
204
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
|
|
|
205
|
+ }
|
|
|
206
|
+ sEvaluation := evaluations[0]
|
189
|
|
207
|
|
190
|
// 自评评估内容(自评模板、筛选项目评估人)
|
208
|
// 自评评估内容(自评模板、筛选项目评估人)
|
191
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
209
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
|
@@ -324,6 +342,156 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua |
|
@@ -324,6 +342,156 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua |
324
|
}, nil
|
342
|
}, nil
|
325
|
}
|
343
|
}
|
326
|
|
344
|
|
|
|
345
|
+// EvaluationHRBPList 获取人资综评列表
|
|
|
346
|
+func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEvaluationHRList) (map[string]interface{}, error) {
|
|
|
347
|
+ transactionContext, err := factory.ValidateStartTransaction(param)
|
|
|
348
|
+ if err != nil {
|
|
|
349
|
+ return nil, err
|
|
|
350
|
+ }
|
|
|
351
|
+ defer func() {
|
|
|
352
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
353
|
+ }()
|
|
|
354
|
+
|
|
|
355
|
+ evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
356
|
+ staffAssessDaoRepo := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
357
|
+ userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
358
|
+ positionRepo := factory.CreatePositionRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
359
|
+ var searchTargetName string
|
|
|
360
|
+ if len(param.SearchName) > 0 {
|
|
|
361
|
+ searchTargetName = "%" + param.SearchName + "%"
|
|
|
362
|
+ } else {
|
|
|
363
|
+ searchTargetName = ""
|
|
|
364
|
+ }
|
|
|
365
|
+ limit := param.PageSize
|
|
|
366
|
+ offset := limit * (param.PageNumber - 1)
|
|
|
367
|
+ if offset < 0 {
|
|
|
368
|
+ offset = 0
|
|
|
369
|
+ }
|
|
|
370
|
+ count, list, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
371
|
+ "companyId": param.CompanyId,
|
|
|
372
|
+ "cycleId": param.CycleId,
|
|
|
373
|
+ "executorId": -1,
|
|
|
374
|
+ "types": domain.EvaluationHrbp,
|
|
|
375
|
+ "searchTargetName": searchTargetName,
|
|
|
376
|
+ "limit": limit,
|
|
|
377
|
+ "offset": offset,
|
|
|
378
|
+ })
|
|
|
379
|
+ if err != nil {
|
|
|
380
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
381
|
+ }
|
|
|
382
|
+
|
|
|
383
|
+ userIds := make([]int, 0)
|
|
|
384
|
+ positionIds := make([]int, 0)
|
|
|
385
|
+ projectIds := make([]int, 0)
|
|
|
386
|
+ projectCountMap := map[string]int{} // 自评逾期数量
|
|
|
387
|
+ userMap := map[int64]*domain.User{} // 用户
|
|
|
388
|
+ positionMap := map[int64]*domain.Position{} // 职位
|
|
|
389
|
+
|
|
|
390
|
+ for i := range list {
|
|
|
391
|
+ it := list[i]
|
|
|
392
|
+ userIds = append(userIds, it.TargetUser.UserId)
|
|
|
393
|
+ projectIds = append(projectIds, list[i].EvaluationProjectId)
|
|
|
394
|
+ }
|
|
|
395
|
+ _, users, err := userRepo.Find(map[string]interface{}{"ids": userIds, "companyId": param.CompanyId})
|
|
|
396
|
+ if err != nil {
|
|
|
397
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
398
|
+ }
|
|
|
399
|
+ for i := range users {
|
|
|
400
|
+ userMap[users[i].Id] = users[i]
|
|
|
401
|
+ for _, pid := range users[i].PositionId {
|
|
|
402
|
+ positionIds = append(positionIds, pid)
|
|
|
403
|
+ }
|
|
|
404
|
+ }
|
|
|
405
|
+ _, positions, err := positionRepo.Find(map[string]interface{}{"ids": positionIds, "companyId": param.CompanyId})
|
|
|
406
|
+ if err != nil {
|
|
|
407
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
408
|
+ }
|
|
|
409
|
+ for i := range positions {
|
|
|
410
|
+ positionMap[positions[i].Id] = positions[i]
|
|
|
411
|
+ }
|
|
|
412
|
+
|
|
|
413
|
+ if len(projectIds) > 0 {
|
|
|
414
|
+ targetCount, err := staffAssessDaoRepo.CountUncompletedSelfAssess(param.CompanyId, projectIds)
|
|
|
415
|
+ if err != nil {
|
|
|
416
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
417
|
+ }
|
|
|
418
|
+ for i := range targetCount {
|
|
|
419
|
+ key := fmt.Sprintf("%d-%d", targetCount[i].EvaluationProjectId, targetCount[i].TargetUserId)
|
|
|
420
|
+ projectCountMap[key] = targetCount[i].Cnt
|
|
|
421
|
+ }
|
|
|
422
|
+ }
|
|
|
423
|
+
|
|
|
424
|
+ now := time.Now().Local() // 当前时间
|
|
|
425
|
+ resultList := make([]*adapter.SummaryEvaluationHRBPAdapter, 0)
|
|
|
426
|
+ for i := range list {
|
|
|
427
|
+ v := list[i]
|
|
|
428
|
+ endTime := v.EndTime.Local()
|
|
|
429
|
+ // 状态
|
|
|
430
|
+ statusVal := ""
|
|
|
431
|
+ if v.Status == domain.EvaluationCompleted {
|
|
|
432
|
+ statusVal = "已完成"
|
|
|
433
|
+ } else {
|
|
|
434
|
+ if now.After(endTime) {
|
|
|
435
|
+ statusVal = "已逾期"
|
|
|
436
|
+ } else {
|
|
|
437
|
+ statusVal = "待完成"
|
|
|
438
|
+ }
|
|
|
439
|
+ }
|
|
|
440
|
+
|
|
|
441
|
+ // 部门拼接
|
|
|
442
|
+ var departmentBuild strings.Builder
|
|
|
443
|
+ departmentBuild.WriteString("")
|
|
|
444
|
+ for i2 := range v.TargetDepartment {
|
|
|
445
|
+ departmentBuild.WriteString(v.TargetDepartment[i2].DepartmentName)
|
|
|
446
|
+ if i2 != len(v.TargetDepartment)-1 {
|
|
|
447
|
+ departmentBuild.WriteString(",")
|
|
|
448
|
+ }
|
|
|
449
|
+ }
|
|
|
450
|
+ // 入职时间
|
|
|
451
|
+ entryTime := ""
|
|
|
452
|
+ // 职位拼接
|
|
|
453
|
+ var positionBuild strings.Builder
|
|
|
454
|
+ positionBuild.WriteString("")
|
|
|
455
|
+ if user, ok := userMap[int64(v.TargetUser.UserId)]; ok {
|
|
|
456
|
+ for i2 := range user.PositionId {
|
|
|
457
|
+ if position, ok := positionMap[int64(user.PositionId[i2])]; ok {
|
|
|
458
|
+ positionBuild.WriteString(position.Name)
|
|
|
459
|
+ if i2 != len(user.PositionId)-1 {
|
|
|
460
|
+ departmentBuild.WriteString(",")
|
|
|
461
|
+ }
|
|
|
462
|
+ }
|
|
|
463
|
+ }
|
|
|
464
|
+ entryTime = user.EntryTime
|
|
|
465
|
+ }
|
|
|
466
|
+
|
|
|
467
|
+ // 自评逾期数量
|
|
|
468
|
+ overdueCount := 0
|
|
|
469
|
+ key := fmt.Sprintf("%d-%d", v.EvaluationProjectId, v.TargetUser.UserId)
|
|
|
470
|
+ if cnt, ok := projectCountMap[key]; ok {
|
|
|
471
|
+ overdueCount = cnt
|
|
|
472
|
+ }
|
|
|
473
|
+
|
|
|
474
|
+ result := &adapter.SummaryEvaluationHRBPAdapter{
|
|
|
475
|
+ Id: v.Id,
|
|
|
476
|
+ TargetUserId: v.TargetUser.UserId,
|
|
|
477
|
+ TargetUserName: v.TargetUser.UserName,
|
|
|
478
|
+ Department: departmentBuild.String(),
|
|
|
479
|
+ Position: positionBuild.String(),
|
|
|
480
|
+ DutyTime: entryTime,
|
|
|
481
|
+ Status: statusVal,
|
|
|
482
|
+ EndTime: endTime.Format("2006-01-02 15:04"),
|
|
|
483
|
+ OverdueCount: overdueCount,
|
|
|
484
|
+ }
|
|
|
485
|
+ resultList = append(resultList, result)
|
|
|
486
|
+ }
|
|
|
487
|
+
|
|
|
488
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
489
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
490
|
+ }
|
|
|
491
|
+
|
|
|
492
|
+ return tool_funs.SimpleWrapGridMap(int64(count), resultList), nil
|
|
|
493
|
+}
|
|
|
494
|
+
|
327
|
// GetEvaluationHRBP 获取人资综评详情
|
495
|
// GetEvaluationHRBP 获取人资综评详情
|
328
|
func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvaluationHRBP) (*adapter.EvaluationInfoAdapter, error) {
|
496
|
func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvaluationHRBP) (*adapter.EvaluationInfoAdapter, error) {
|
329
|
transactionContext, err := factory.ValidateStartTransaction(param)
|
497
|
transactionContext, err := factory.ValidateStartTransaction(param)
|
|
@@ -338,10 +506,21 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu |
|
@@ -338,10 +506,21 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu |
338
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
506
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
339
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
507
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
340
|
|
508
|
|
341
|
- sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
|
509
|
+ _, evaluations, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
510
|
+ "limit": 1,
|
|
|
511
|
+ "companyId": param.CompanyId,
|
|
|
512
|
+ "cycleId": param.CycleId,
|
|
|
513
|
+ "targetUserId": param.TargetUserId,
|
|
|
514
|
+ "types": domain.EvaluationHrbp},
|
|
|
515
|
+ )
|
|
|
516
|
+ // sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
|
342
|
if err != nil {
|
517
|
if err != nil {
|
343
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
518
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
344
|
}
|
519
|
}
|
|
|
520
|
+ if len(evaluations) == 0 {
|
|
|
521
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
|
|
|
522
|
+ }
|
|
|
523
|
+ sEvaluation := evaluations[0]
|
345
|
|
524
|
|
346
|
// 自评评估内容(自评模板、筛选项目评估人)
|
525
|
// 自评评估内容(自评模板、筛选项目评估人)
|
347
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
526
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|