|
@@ -2,11 +2,14 @@ package service |
|
@@ -2,11 +2,14 @@ package service |
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
4
|
"fmt"
|
4
|
"fmt"
|
|
|
5
|
+ "strconv"
|
|
|
6
|
+ "time"
|
5
|
|
7
|
|
6
|
"github.com/linmadan/egglib-go/core/application"
|
8
|
"github.com/linmadan/egglib-go/core/application"
|
7
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
9
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter"
|
|
|
12
|
+ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
|
13
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
14
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
12
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
|
15
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
|
|
@@ -16,6 +19,11 @@ import ( |
|
@@ -16,6 +19,11 @@ import ( |
16
|
type StaffAssessServeice struct {
|
19
|
type StaffAssessServeice struct {
|
17
|
}
|
20
|
}
|
18
|
|
21
|
|
|
|
22
|
+func NewStaffAssessServeice() *StaffAssessServeice {
|
|
|
23
|
+ newService := &StaffAssessServeice{}
|
|
|
24
|
+ return newService
|
|
|
25
|
+}
|
|
|
26
|
+
|
19
|
// 获取我参与过的评估任务列表
|
27
|
// 获取我参与过的评估任务列表
|
20
|
func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) {
|
28
|
func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) {
|
21
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
29
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
@@ -70,7 +78,7 @@ func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQue |
|
@@ -70,7 +78,7 @@ func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQue |
70
|
}
|
78
|
}
|
71
|
|
79
|
|
72
|
// 获取项目评估进度描述
|
80
|
// 获取项目评估进度描述
|
73
|
-func (srv StaffAssessServeice) AssessTaskDesc(param query.AssessTaskDescQuery) (*adapter.AssessTaskDescResp, error) {
|
81
|
+func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) (*adapter.AssessTaskDescResp, error) {
|
74
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
82
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
75
|
if err != nil {
|
83
|
if err != nil {
|
76
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
84
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -204,7 +212,7 @@ func (srv StaffAssessServeice) AssessTaskDesc(param query.AssessTaskDescQuery) ( |
|
@@ -204,7 +212,7 @@ func (srv StaffAssessServeice) AssessTaskDesc(param query.AssessTaskDescQuery) ( |
204
|
}
|
212
|
}
|
205
|
|
213
|
|
206
|
// 获取个人的自评反馈历史记录列表
|
214
|
// 获取个人的自评反馈历史记录列表
|
207
|
-func (srv StaffAssessServeice) AssessSelfList(param query.AssessSelfListQuery) (map[string]interface{}, error) {
|
215
|
+func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) (map[string]interface{}, error) {
|
208
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
216
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
209
|
if err != nil {
|
217
|
if err != nil {
|
210
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
218
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -321,25 +329,419 @@ func (srv StaffAssessServeice) AssessSelfList(param query.AssessSelfListQuery) ( |
|
@@ -321,25 +329,419 @@ func (srv StaffAssessServeice) AssessSelfList(param query.AssessSelfListQuery) ( |
321
|
}
|
329
|
}
|
322
|
|
330
|
|
323
|
// 更具项目评估的配置,创建员工的评估任务
|
331
|
// 更具项目评估的配置,创建员工的评估任务
|
324
|
-func (srv StaffAssessServeice) CreateStaffAssessTask() error {
|
332
|
+func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) {
|
|
|
333
|
+
|
|
|
334
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
335
|
+ if err != nil {
|
|
|
336
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
337
|
+ }
|
|
|
338
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
339
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
340
|
+ }
|
|
|
341
|
+ defer func() {
|
|
|
342
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
343
|
+ }()
|
|
|
344
|
+
|
|
|
345
|
+ taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
|
|
|
346
|
+ if err != nil {
|
|
|
347
|
+ return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime)
|
|
|
348
|
+ }
|
|
|
349
|
+ taskEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.EndTime, time.Local)
|
|
|
350
|
+ if err != nil {
|
|
|
351
|
+ return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime)
|
|
|
352
|
+ }
|
|
|
353
|
+ nowTime := time.Now()
|
|
|
354
|
+ //建立评估任务
|
|
|
355
|
+ assessTask := domain.StaffAssessTask{
|
|
|
356
|
+ Id: 0,
|
|
|
357
|
+ CompanyId: param.CompanyId,
|
|
|
358
|
+ EvaluationProjectId: param.EvaluationProjectId,
|
|
|
359
|
+ EvaluationProjectName: param.EvaluationProjectName,
|
|
|
360
|
+ CycleId: param.CycleId,
|
|
|
361
|
+ CycleName: param.CycleName,
|
|
|
362
|
+ BeginTime: taskBeginTime,
|
|
|
363
|
+ EndTime: taskEndTime,
|
|
|
364
|
+ StepList: []domain.AssessTaskStep{},
|
|
|
365
|
+ ExecutorId: nil,
|
|
|
366
|
+ CreatedAt: nowTime,
|
|
|
367
|
+ UpdatedAt: nowTime,
|
|
|
368
|
+ DeletedAt: nil,
|
|
|
369
|
+ }
|
|
|
370
|
+ //填充评估环节
|
|
|
371
|
+ for _, v := range param.StepList {
|
|
|
372
|
+ stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
|
|
|
373
|
+ if err != nil {
|
|
|
374
|
+ return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime)
|
|
|
375
|
+ }
|
|
|
376
|
+ stepEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.EndTime, time.Local)
|
|
|
377
|
+ if err != nil {
|
|
|
378
|
+ return nil, application.ThrowError(application.ARG_ERROR, "评估环节结束时间填写错误,"+param.EndTime)
|
|
|
379
|
+ }
|
|
|
380
|
+ step := domain.AssessTaskStep{
|
|
|
381
|
+ SortBy: v.SortBy,
|
|
|
382
|
+ LinkNodeId: v.LinkNodeId,
|
|
|
383
|
+ LinkNodeName: v.LinkNodeName,
|
|
|
384
|
+ LinkNodeType: v.LinkNodeType,
|
|
|
385
|
+ BeginTime: stepBeginTime,
|
|
|
386
|
+ EndTime: stepEndTime,
|
|
|
387
|
+ }
|
|
|
388
|
+ assessTask.StepList = append(assessTask.StepList, step)
|
|
|
389
|
+ }
|
|
|
390
|
+
|
|
|
391
|
+ assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
392
|
+ "transactionContext": transactionContext,
|
|
|
393
|
+ })
|
|
|
394
|
+ _, err = assessTaskRepo.Save(&assessTask)
|
|
|
395
|
+ if err != nil {
|
|
|
396
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
|
|
|
397
|
+ }
|
|
|
398
|
+
|
|
|
399
|
+ assessList, err := srv.createStaffAssess(transactionContext, &assessTask)
|
|
|
400
|
+ if err != nil {
|
|
|
401
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error())
|
|
|
402
|
+ }
|
|
|
403
|
+
|
|
|
404
|
+ assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
405
|
+ "transactionContext": transactionContext,
|
|
|
406
|
+ })
|
|
|
407
|
+
|
|
|
408
|
+ for i := range assessList {
|
|
|
409
|
+ _, err = assessRepo.Save(&assessList[i])
|
|
|
410
|
+ if err != nil {
|
|
|
411
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error())
|
|
|
412
|
+ }
|
|
|
413
|
+ }
|
|
|
414
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
415
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
416
|
+ }
|
|
|
417
|
+ return map[string]interface{}{
|
|
|
418
|
+ "assessTaskId": assessTask.Id,
|
|
|
419
|
+ }, nil
|
|
|
420
|
+}
|
|
|
421
|
+
|
|
|
422
|
+// 添加自评节点任务
|
|
|
423
|
+func (srv StaffAssessServeice) createStaffAssess(transactionContext application.TransactionContext, param *domain.StaffAssessTask) ([]domain.StaffAssess, error) {
|
|
|
424
|
+ //评估的参与人
|
|
|
425
|
+ selfUserId := []int{}
|
|
|
426
|
+ userIdMap := map[int]struct{}{} //过滤重复的用户
|
|
|
427
|
+ for _, v := range param.ExecutorId {
|
|
|
428
|
+ if _, ok := userIdMap[v]; ok {
|
|
|
429
|
+ continue
|
|
|
430
|
+ }
|
|
|
431
|
+ selfUserId = append(selfUserId, v)
|
|
|
432
|
+ }
|
|
|
433
|
+ // 获取用户的信息
|
|
|
434
|
+ if len(selfUserId) == 0 {
|
|
|
435
|
+ return nil, application.ThrowError(application.ARG_ERROR, "未填写评估任务的执行人")
|
|
|
436
|
+ }
|
|
|
437
|
+ userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
438
|
+ "transactionContext": transactionContext,
|
|
|
439
|
+ })
|
|
|
440
|
+ //获取员工信息
|
|
|
441
|
+ _, userList, err := userRepo.Find(map[string]interface{}{
|
|
|
442
|
+ "ids": selfUserId,
|
|
|
443
|
+ })
|
|
|
444
|
+ if err != nil {
|
|
|
445
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取员工信息"+err.Error())
|
|
|
446
|
+ }
|
|
|
447
|
+ departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
448
|
+ "transactionContext": transactionContext,
|
|
|
449
|
+ })
|
|
|
450
|
+ //获取用户的部门
|
|
|
451
|
+ userDepartmentMap := map[int64][]*domain.Department{}
|
|
|
452
|
+ for _, v := range userList {
|
|
|
453
|
+ _, departmemtList, err := departmentRepo.Find(map[string]interface{}{
|
|
|
454
|
+ "ids": v.DepartmentId,
|
|
|
455
|
+ })
|
|
|
456
|
+ if err != nil {
|
|
|
457
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取员工的部门信息"+err.Error())
|
|
|
458
|
+ }
|
|
|
459
|
+ userDepartmentMap[v.Id] = departmemtList
|
|
|
460
|
+ }
|
|
|
461
|
+ assessList := []domain.StaffAssess{}
|
|
|
462
|
+ //数据样板
|
|
|
463
|
+ stepSelfTemp := domain.StaffAssess{
|
|
|
464
|
+ Id: 0,
|
|
|
465
|
+ CompanyId: param.CompanyId,
|
|
|
466
|
+ EvaluationProjectId: param.EvaluationProjectId,
|
|
|
467
|
+ EvaluationProjectName: param.EvaluationProjectName,
|
|
|
468
|
+ CycleId: param.CycleId,
|
|
|
469
|
+ CycleName: param.CycleName,
|
|
|
470
|
+ StaffAssessTaskId: param.Id,
|
|
|
471
|
+ // TargetUser: domain.StaffDesc{},
|
|
|
472
|
+ // TargetDepartment: nil,
|
|
|
473
|
+ // Executor: domain.StaffDesc{},
|
|
|
474
|
+ Types: domain.AssessSelf,
|
|
|
475
|
+ // LinkNodeId: v.LinkNodeId,
|
|
|
476
|
+ Status: domain.StaffAssessUncompleted,
|
|
|
477
|
+ // BeginTime: time.Time{},
|
|
|
478
|
+ // EndTime: time.Time{},
|
|
|
479
|
+ CreatedAt: param.CreatedAt,
|
|
|
480
|
+ UpdatedAt: param.UpdatedAt,
|
|
|
481
|
+ DeletedAt: nil,
|
|
|
482
|
+ }
|
|
|
483
|
+ for _, v := range param.StepList {
|
|
|
484
|
+ if v.LinkNodeType == domain.LinkNodeSelfAssessment {
|
|
|
485
|
+ //员工自评
|
|
|
486
|
+ stepSelfTemp.BeginTime = v.BeginTime
|
|
|
487
|
+ stepSelfTemp.EndTime = v.EndTime
|
|
|
488
|
+ stepSelfTemp.LinkNodeId = v.LinkNodeId
|
|
|
489
|
+ stepSelfTemp.LinkNodeName = v.LinkNodeName
|
|
|
490
|
+ assessListTemp := srv.createStaffAssessSelf(stepSelfTemp, userList, userDepartmentMap)
|
|
|
491
|
+ assessList = append(assessList, assessListTemp...)
|
|
|
492
|
+ }
|
|
|
493
|
+ if v.LinkNodeType == domain.LinkNodeSuperiorAssessment {
|
|
|
494
|
+ // TODO
|
|
|
495
|
+ stepSelfTemp.BeginTime = v.BeginTime
|
|
|
496
|
+ stepSelfTemp.EndTime = v.EndTime
|
|
|
497
|
+ stepSelfTemp.LinkNodeId = v.LinkNodeId
|
|
|
498
|
+ stepSelfTemp.LinkNodeName = v.LinkNodeName
|
|
|
499
|
+ assessListTemp, err := srv.createStaffAssessSupper(transactionContext, stepSelfTemp, userList, userDepartmentMap)
|
|
|
500
|
+ if err != nil {
|
|
|
501
|
+ return nil, err
|
|
|
502
|
+ }
|
|
|
503
|
+ assessList = append(assessList, assessListTemp...)
|
|
|
504
|
+ }
|
|
|
505
|
+ }
|
|
|
506
|
+ return assessList, nil
|
|
|
507
|
+}
|
|
|
508
|
+
|
|
|
509
|
+// 构建员工自评
|
|
|
510
|
+func (srv StaffAssessServeice) createStaffAssessSelf(assessTemp domain.StaffAssess,
|
|
|
511
|
+ userList []*domain.User, userDepartmentMap map[int64][]*domain.Department) []domain.StaffAssess {
|
|
|
512
|
+ result := []domain.StaffAssess{}
|
|
|
513
|
+ for _, usr := range userList {
|
|
|
514
|
+ assessTemp.TargetUser = domain.StaffDesc{
|
|
|
515
|
+ UserId: int(usr.Id),
|
|
|
516
|
+ Account: usr.Account,
|
|
|
517
|
+ UserName: usr.Account,
|
|
|
518
|
+ }
|
|
|
519
|
+ assessTemp.Executor = domain.StaffDesc{
|
|
|
520
|
+ UserId: int(usr.Id),
|
|
|
521
|
+ Account: usr.Account,
|
|
|
522
|
+ UserName: usr.Account,
|
|
|
523
|
+ }
|
|
|
524
|
+ if depList, ok := userDepartmentMap[usr.Id]; ok {
|
|
|
525
|
+ for _, dep := range depList {
|
|
|
526
|
+ assessTemp.TargetDepartment = append(assessTemp.TargetDepartment, domain.StaffDepartment{
|
|
|
527
|
+ DepartmentId: int(dep.Id),
|
|
|
528
|
+ DepartmentName: dep.Name,
|
|
|
529
|
+ })
|
|
|
530
|
+ }
|
|
|
531
|
+ }
|
|
|
532
|
+ result = append(result, assessTemp)
|
|
|
533
|
+ }
|
|
|
534
|
+ return result
|
|
|
535
|
+}
|
|
|
536
|
+
|
|
|
537
|
+// 构建员工上级评估
|
|
|
538
|
+func (srv StaffAssessServeice) createStaffAssessSupper(
|
|
|
539
|
+ transactionContext application.TransactionContext,
|
|
|
540
|
+ assessTemp domain.StaffAssess,
|
|
|
541
|
+ userList []*domain.User, userDepartmentMap map[int64][]*domain.Department,
|
|
|
542
|
+) ([]domain.StaffAssess, error) {
|
|
|
543
|
+
|
|
|
544
|
+ // 获取员工的上级用户
|
|
|
545
|
+
|
|
|
546
|
+ return nil, nil
|
|
|
547
|
+}
|
|
|
548
|
+
|
|
|
549
|
+// 获取某个员工360邀请的人员
|
|
|
550
|
+func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) {
|
325
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
551
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
326
|
if err != nil {
|
552
|
if err != nil {
|
327
|
- return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
553
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
328
|
}
|
554
|
}
|
329
|
if err := transactionContext.StartTransaction(); err != nil {
|
555
|
if err := transactionContext.StartTransaction(); err != nil {
|
330
|
- return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
556
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
331
|
}
|
557
|
}
|
332
|
defer func() {
|
558
|
defer func() {
|
333
|
_ = transactionContext.RollbackTransaction()
|
559
|
_ = transactionContext.RollbackTransaction()
|
334
|
}()
|
560
|
}()
|
335
|
|
561
|
|
|
|
562
|
+ assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
563
|
+ "transactionContext": transactionContext,
|
|
|
564
|
+ })
|
|
|
565
|
+
|
|
|
566
|
+ assessTaskReps := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
567
|
+ "transactionContext": transactionContext,
|
|
|
568
|
+ })
|
|
|
569
|
+ assessTaskData, err := assessTaskReps.FindOne(map[string]interface{}{
|
|
|
570
|
+ "id": param.AssessTaskId,
|
|
|
571
|
+ })
|
|
|
572
|
+ if err != nil {
|
|
|
573
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error())
|
|
|
574
|
+ }
|
|
|
575
|
+ _, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
576
|
+ "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
|
|
|
577
|
+ "staffAssessTaskId": param.AssessTaskId,
|
|
|
578
|
+ "targetUserId": param.UsrId,
|
|
|
579
|
+ })
|
|
|
580
|
+ if err != nil {
|
|
|
581
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
|
|
|
582
|
+ }
|
336
|
if err := transactionContext.CommitTransaction(); err != nil {
|
583
|
if err := transactionContext.CommitTransaction(); err != nil {
|
337
|
- return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
584
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
585
|
+ }
|
|
|
586
|
+
|
|
|
587
|
+ result := adapter.AssessInviteUserResp{
|
|
|
588
|
+ AssessTaskId: assessTaskData.Id,
|
|
|
589
|
+ }
|
|
|
590
|
+ for _, v := range assessTaskData.StepList {
|
|
|
591
|
+ if v.LinkNodeType != domain.LinkNodeAllInvite {
|
|
|
592
|
+ continue
|
|
|
593
|
+ }
|
|
|
594
|
+ result.LinkNodeId = v.LinkNodeId
|
|
|
595
|
+ result.LinkNodeName = v.LinkNodeName
|
|
|
596
|
+ result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05")
|
|
|
597
|
+ result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05")
|
|
|
598
|
+ break
|
|
|
599
|
+ }
|
|
|
600
|
+ for _, v := range assessList {
|
|
|
601
|
+ if v.Types == domain.AssessInviteDiffSuper {
|
|
|
602
|
+ result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor)
|
|
|
603
|
+ }
|
|
|
604
|
+ if v.Types == domain.AssessInviteSameSuper {
|
|
|
605
|
+ result.InviteSameSuper = append(result.InviteDiffSuper, v.Executor)
|
|
|
606
|
+ }
|
338
|
}
|
607
|
}
|
339
|
- return nil
|
608
|
+ return &result, nil
|
340
|
}
|
609
|
}
|
341
|
|
610
|
|
342
|
-// 获取员工自评详情
|
|
|
343
|
-func (srv StaffAssessServeice) StaffAssessSelfInfo() {
|
611
|
+// 获取某个员工360邀请的人员
|
|
|
612
|
+func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (*adapter.AssessInviteUserResp, error) {
|
|
|
613
|
+ inviteSameSuperId := []int{}
|
|
|
614
|
+ InviteDiffSuperId := []int{}
|
|
|
615
|
+ for _, v := range param.InviteDiffSuper {
|
|
|
616
|
+ id, err := strconv.Atoi(v)
|
|
|
617
|
+ if err != nil {
|
|
|
618
|
+ return nil, application.ThrowError(application.ARG_ERROR, "用户填写错误")
|
|
|
619
|
+ }
|
|
|
620
|
+ InviteDiffSuperId = append(InviteDiffSuperId, id)
|
|
|
621
|
+ }
|
|
|
622
|
+ for _, v := range param.InviteSameSuper {
|
|
|
623
|
+ id, err := strconv.Atoi(v)
|
|
|
624
|
+ if err != nil {
|
|
|
625
|
+ return nil, application.ThrowError(application.ARG_ERROR, "用户填写错误")
|
|
|
626
|
+ }
|
|
|
627
|
+ inviteSameSuperId = append(inviteSameSuperId, id)
|
|
|
628
|
+ }
|
|
|
629
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
630
|
+ if err != nil {
|
|
|
631
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
632
|
+ }
|
|
|
633
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
634
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
635
|
+ }
|
|
|
636
|
+ defer func() {
|
|
|
637
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
638
|
+ }()
|
|
|
639
|
+
|
|
|
640
|
+ assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
641
|
+ "transactionContext": transactionContext,
|
|
|
642
|
+ })
|
|
|
643
|
+ userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
644
|
+ "transactionContext": transactionContext,
|
|
|
645
|
+ })
|
|
|
646
|
+ departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
647
|
+ "transactionContext": transactionContext,
|
|
|
648
|
+ })
|
|
|
649
|
+
|
|
|
650
|
+ assessTaskReps := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
651
|
+ "transactionContext": transactionContext,
|
|
|
652
|
+ })
|
|
|
653
|
+ assessTaskData, err := assessTaskReps.FindOne(map[string]interface{}{
|
|
|
654
|
+ "id": param.AssessTaskId,
|
|
|
655
|
+ })
|
|
|
656
|
+ if err != nil {
|
|
|
657
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error())
|
|
|
658
|
+ }
|
|
|
659
|
+
|
|
|
660
|
+ targetUser, err := userRepo.FindOne(map[string]interface{}{
|
|
|
661
|
+ "id": param.TargetUserId,
|
|
|
662
|
+ })
|
|
|
663
|
+ //被评估人的部门
|
|
|
664
|
+ var targetUserDepartment []domain.StaffDepartment
|
|
|
665
|
+ if len(targetUser.DepartmentId) > 0 {
|
|
|
666
|
+ _, departmentList, err := departmentRepo.Find(map[string]interface{}{
|
|
|
667
|
+ "ids": targetUser.DepartmentId,
|
|
|
668
|
+ })
|
|
|
669
|
+ if err != nil {
|
|
|
670
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取部门信息"+err.Error())
|
|
|
671
|
+ }
|
|
|
672
|
+ for _, v := range departmentList {
|
|
|
673
|
+ targetUserDepartment = append(targetUserDepartment, domain.StaffDepartment{
|
|
|
674
|
+ DepartmentId: int(v.Id),
|
|
|
675
|
+ DepartmentName: v.Name,
|
|
|
676
|
+ })
|
|
|
677
|
+ }
|
|
|
678
|
+ }
|
|
|
679
|
+ //相同上级的员工
|
|
|
680
|
+ var inviteSameSuper []domain.StaffDesc
|
|
|
681
|
+ if len(inviteSameSuperId) > 0 {
|
|
|
682
|
+ _, userList, err := userRepo.Find(map[string]interface{}{
|
|
|
683
|
+ "ids": inviteSameSuperId,
|
|
|
684
|
+ })
|
|
|
685
|
+ if err != nil {
|
|
|
686
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error())
|
|
|
687
|
+ }
|
|
|
688
|
+ for _, v := range userList {
|
|
|
689
|
+ inviteSameSuper = append(inviteSameSuper, domain.StaffDesc{
|
|
|
690
|
+ UserId: int(v.Id),
|
|
|
691
|
+ UserName: v.Name,
|
|
|
692
|
+ Account: v.Account,
|
|
|
693
|
+ })
|
|
|
694
|
+ }
|
|
|
695
|
+ }
|
|
|
696
|
+ var inviteDiffSuper []domain.StaffDesc
|
|
|
697
|
+ if len(InviteDiffSuperId) > 0 {
|
|
|
698
|
+ _, userList, err := userRepo.Find(map[string]interface{}{
|
|
|
699
|
+ "ids": inviteSameSuperId,
|
|
|
700
|
+ })
|
|
|
701
|
+ if err != nil {
|
|
|
702
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error())
|
|
|
703
|
+ }
|
|
|
704
|
+ for _, v := range userList {
|
|
|
705
|
+ inviteSameSuper = append(inviteSameSuper, domain.StaffDesc{
|
|
|
706
|
+ UserId: int(v.Id),
|
|
|
707
|
+ UserName: v.Name,
|
|
|
708
|
+ Account: v.Account,
|
|
|
709
|
+ })
|
|
|
710
|
+ }
|
|
|
711
|
+ }
|
|
|
712
|
+ // _, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
713
|
+ // "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
|
|
|
714
|
+ // "staffAssessTaskId": param.AssessTaskId,
|
|
|
715
|
+ // "targetUserId": param.TargetUserId,
|
|
|
716
|
+ // })
|
|
|
717
|
+ // if err != nil {
|
|
|
718
|
+ // return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
|
|
|
719
|
+ // }
|
|
|
720
|
+
|
|
|
721
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
722
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
723
|
+ }
|
344
|
|
724
|
|
|
|
725
|
+ result := adapter.AssessInviteUserResp{
|
|
|
726
|
+ AssessTaskId: assessTaskData.Id,
|
|
|
727
|
+ }
|
|
|
728
|
+ // for _, v := range assessTaskData.StepList {
|
|
|
729
|
+ // if v.LinkNodeType != domain.LinkNodeAllInvite {
|
|
|
730
|
+ // continue
|
|
|
731
|
+ // }
|
|
|
732
|
+ // result.LinkNodeId = v.LinkNodeId
|
|
|
733
|
+ // result.LinkNodeName = v.LinkNodeName
|
|
|
734
|
+ // result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05")
|
|
|
735
|
+ // result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05")
|
|
|
736
|
+ // break
|
|
|
737
|
+ // }
|
|
|
738
|
+ // for _, v := range assessList {
|
|
|
739
|
+ // if v.Types == domain.AssessInviteDiffSuper {
|
|
|
740
|
+ // result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor)
|
|
|
741
|
+ // }
|
|
|
742
|
+ // if v.Types == domain.AssessInviteSameSuper {
|
|
|
743
|
+ // result.InviteSameSuper = append(result.InviteDiffSuper, v.Executor)
|
|
|
744
|
+ // }
|
|
|
745
|
+ // }
|
|
|
746
|
+ return &result, nil
|
345
|
} |
747
|
} |