作者 tangxvhui

更新

  1 +package service
  2 +
  3 +import (
  4 + "time"
  5 +
  6 + "github.com/linmadan/egglib-go/core/application"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
  8 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify"
  9 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
  10 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
  11 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  12 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
  13 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis"
  14 +)
  15 +
  16 +// 编辑综合自评详情
  17 +func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) {
  18 + transactionContext, err := factory.CreateTransactionContext(nil)
  19 + if err != nil {
  20 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  21 + }
  22 + if err := transactionContext.StartTransaction(); err != nil {
  23 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  24 + }
  25 + defer func() {
  26 + _ = transactionContext.RollbackTransaction()
  27 + }()
  28 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
  29 + "transactionContext": transactionContext,
  30 + })
  31 + itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
  32 + "transactionContext": transactionContext,
  33 + })
  34 +
  35 + itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
  36 + "transactionContext": transactionContext,
  37 + })
  38 + evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
  39 + "id": param.SummaryEvaluationId,
  40 + })
  41 + if err != nil {
  42 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估"+err.Error())
  43 + }
  44 + if evaluationData.Types != domain.EvaluationSelf {
  45 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
  46 + }
  47 +
  48 + if evaluationData.Executor.UserId != param.ExecutorId {
  49 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
  50 + }
  51 + if evaluationData.CompanyId != param.CompanyId {
  52 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
  53 + }
  54 + lock := xredis.NewLockSummaryEvaluation(evaluationData.TargetUser.UserId)
  55 + err = lock.Lock()
  56 + if err != nil {
  57 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
  58 + }
  59 + defer func() {
  60 + lock.UnLock()
  61 + }()
  62 + _, itemList, err := itemUsedRepo.Find(map[string]interface{}{
  63 + "evaluationProjectId": evaluationData.EvaluationProjectId,
  64 + "nodeType": domain.LinkNodeSelfAssessment,
  65 + })
  66 + if err != nil {
  67 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  68 + }
  69 +
  70 + _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{
  71 + "summaryEvaluationId": evaluationData.Id,
  72 + })
  73 +
  74 + if err != nil {
  75 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  76 + }
  77 +
  78 + err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, nil, param.IsTemporary)
  79 + if err != nil {
  80 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  81 + }
  82 +
  83 + //保存填写值
  84 + for _, v := range itemValueList {
  85 + err = itemValueRepo.Save(v)
  86 + if err != nil {
  87 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  88 + }
  89 + }
  90 + if !param.IsTemporary {
  91 + evaluationData.Status = domain.EvaluationCompleted
  92 + //删除旧的填写值,使用新的填写内容
  93 + err = itemValueRepo.RemoveBySummaryEvaluationId(evaluationData.Id)
  94 + if err != nil {
  95 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  96 + }
  97 + for _, val := range itemValueList {
  98 + val.Id = 0
  99 + }
  100 + }
  101 + err = evaluationRepo.Save(evaluationData)
  102 + if err != nil {
  103 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  104 + }
  105 + if !param.IsTemporary {
  106 + err = srv.AfterCompletedEvaluationSelf(transactionContext, evaluationData, itemValueList)
  107 + if err != nil {
  108 + return nil, err
  109 + }
  110 + }
  111 + if err := transactionContext.CommitTransaction(); err != nil {
  112 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  113 + }
  114 + itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
  115 + return map[string][]adapter.EvaluationItemAdapter{
  116 + "EvaluationItems": itemValueAdapter,
  117 + }, nil
  118 +}
  119 +
  120 +// 员工提交自评内容后,
  121 +// 员工作为被评估人,
  122 +// 变更360评估/人资评估/的开始时间
  123 +// 或者变更上级评估的开始时间
  124 +// 或者生成考核结果
  125 +func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(
  126 + transactionContext application.TransactionContext,
  127 + evaluationData *domain.SummaryEvaluation,
  128 + evaluationValue []*domain.SummaryEvaluationValue,
  129 +) error {
  130 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
  131 + "transactionContext": transactionContext,
  132 + })
  133 + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
  134 + "targetUserId": evaluationData.TargetUser.UserId,
  135 + "typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},
  136 + "cycleId": evaluationData.CycleId,
  137 + "limit": 1000,
  138 + })
  139 + if err != nil {
  140 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  141 + }
  142 + if len(evaluationList) == 0 {
  143 + //如果没有360评估和hrbp 评估,查找上级评估
  144 + _, evaluationList, err = evaluationRepo.Find(map[string]interface{}{
  145 + "targetUserId": evaluationData.TargetUser.UserId,
  146 + "typesList": []int{int(domain.EvaluationSuper)},
  147 + "cycleId": evaluationData.CycleId,
  148 + "limit": 10,
  149 + })
  150 + if err != nil {
  151 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  152 + }
  153 + }
  154 + nowTime := time.Now()
  155 + updatedId := []int{}
  156 + // 变更360评估/人资评估/上级评估的开始时间
  157 + for _, v := range evaluationList {
  158 + if v.BeginTime.After(nowTime) {
  159 + v.BeginTime = nowTime
  160 + updatedId = append(updatedId, v.Id)
  161 + }
  162 + }
  163 + evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{
  164 + "transactionContext": transactionContext,
  165 + })
  166 + err = evaluationDao.UpdateBeginTime(updatedId, nowTime)
  167 + if err != nil {
  168 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  169 + }
  170 + if len(evaluationList) == 0 {
  171 + //没有上级评估、360评估、hrbp 评估
  172 + //直接进入考核结果阶段
  173 + _, evaluationFinishList, err := evaluationRepo.Find(map[string]interface{}{
  174 + "targetUserId": evaluationData.TargetUser.UserId,
  175 + "typesList": []int{int(domain.EvaluationFinish)},
  176 + "cycleId": evaluationData.CycleId,
  177 + "limit": 1,
  178 + })
  179 + if err != nil {
  180 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  181 + }
  182 + if len(evaluationFinishList) > 0 {
  183 + //进入考核结果
  184 + //自评的结束时间
  185 + if evaluationFinishList[0].BeginTime.After(nowTime) {
  186 + evaluationFinishList[0].BeginTime = nowTime
  187 + }
  188 + evaluationFinishList[0].Status = domain.EvaluationCompleted
  189 + err = evaluationRepo.Save(evaluationFinishList[0])
  190 + if err != nil {
  191 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
  192 + }
  193 + //添加确认绩效成绩提醒短信提醒
  194 + err = notify.AddNotifyConfirmEvaluationScore(evaluationFinishList[0])
  195 + if err != nil {
  196 + return application.ThrowError(application.TRANSACTION_ERROR, "创建短信提醒失败"+err.Error())
  197 + }
  198 + }
  199 + }
  200 + return nil
  201 +}
@@ -17,14 +17,6 @@ import ( @@ -17,14 +17,6 @@ import (
17 17
18 // EditEvaluationSuper 更新上级评估内容 18 // EditEvaluationSuper 更新上级评估内容
19 func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEvaluationValue) (interface{}, error) { 19 func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEvaluationValue) (interface{}, error) {
20 - // lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)  
21 - // err := lock.Lock()  
22 - // if err != nil {  
23 - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")  
24 - // }  
25 - // defer func() {  
26 - // lock.UnLock()  
27 - // }()  
28 transactionContext, err := factory.CreateTransactionContext(nil) 20 transactionContext, err := factory.CreateTransactionContext(nil)
29 if err != nil { 21 if err != nil {
30 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 22 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -62,6 +54,10 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval @@ -62,6 +54,10 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval
62 if evaluationData.CompanyId != param.CompanyId { 54 if evaluationData.CompanyId != param.CompanyId {
63 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") 55 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
64 } 56 }
  57 + ok := evaluationData.EndTime.Before(time.Now())
  58 + if ok {
  59 + return nil, application.ThrowError(application.BUSINESS_ERROR, "评估时间已截止")
  60 + }
65 //按照被评估人id ,加锁 61 //按照被评估人id ,加锁
66 lock := xredis.NewLockSummaryEvaluation(evaluationData.TargetUser.UserId) 62 lock := xredis.NewLockSummaryEvaluation(evaluationData.TargetUser.UserId)
67 err = lock.Lock() 63 err = lock.Lock()
@@ -112,23 +108,27 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval @@ -112,23 +108,27 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval
112 if !param.IsTemporary { 108 if !param.IsTemporary {
113 //变更评估状态为已填写 109 //变更评估状态为已填写
114 evaluationData.Status = domain.EvaluationCompleted 110 evaluationData.Status = domain.EvaluationCompleted
115 - }  
116 - for _, v := range itemValueList {  
117 - //保存填写值  
118 - err = itemValueRepo.Save(v) 111 + //删除旧的填写值,使用新的填写内容
  112 + err = itemValueRepo.RemoveBySummaryEvaluationId(evaluationData.Id)
119 if err != nil { 113 if err != nil {
120 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 114 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
121 } 115 }
  116 + for _, val := range itemValueList {
  117 + val.Id = 0
  118 + }
122 } 119 }
123 //保存填写值 120 //保存填写值
124 err = evaluationRepo.Save(evaluationData) 121 err = evaluationRepo.Save(evaluationData)
125 if err != nil { 122 if err != nil {
126 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 123 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
127 } 124 }
128 - if err := transactionContext.CommitTransaction(); err != nil {  
129 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 125 + for _, v := range itemValueList {
  126 + //保存填写值
  127 + err = itemValueRepo.Save(v)
  128 + if err != nil {
  129 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  130 + }
130 } 131 }
131 -  
132 if !param.IsTemporary { 132 if !param.IsTemporary {
133 err = srv.AfterCompletedEvaluationSuper(transactionContext, evaluationData, itemValueList) 133 err = srv.AfterCompletedEvaluationSuper(transactionContext, evaluationData, itemValueList)
134 if err != nil { 134 if err != nil {
@@ -136,6 +136,9 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval @@ -136,6 +136,9 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval
136 } 136 }
137 } 137 }
138 138
  139 + if err := transactionContext.CommitTransaction(); err != nil {
  140 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  141 + }
139 itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList) 142 itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
140 return map[string][]adapter.EvaluationItemAdapter{ 143 return map[string][]adapter.EvaluationItemAdapter{
141 "EvaluationItems": itemValueAdapter, 144 "EvaluationItems": itemValueAdapter,
@@ -247,6 +250,7 @@ func (srv *SummaryEvaluationService) syncEvaluationFinishValue( @@ -247,6 +250,7 @@ func (srv *SummaryEvaluationService) syncEvaluationFinishValue(
247 oldValue.Remark = item.Remark 250 oldValue.Remark = item.Remark
248 } 251 }
249 } 252 }
  253 + // 重置各个评级数量
250 evaluationData.TotalRating = nil 254 evaluationData.TotalRating = nil
251 for i := range itemList { 255 for i := range itemList {
252 evaluationData.ResetTotalRating(itemList[i]) 256 evaluationData.ResetTotalRating(itemList[i])
@@ -256,7 +260,7 @@ func (srv *SummaryEvaluationService) syncEvaluationFinishValue( @@ -256,7 +260,7 @@ func (srv *SummaryEvaluationService) syncEvaluationFinishValue(
256 for _, val := range oldEvaluationValue { 260 for _, val := range oldEvaluationValue {
257 newEvaluationValue = append(newEvaluationValue, val) 261 newEvaluationValue = append(newEvaluationValue, val)
258 } 262 }
259 - 263 + //计算总分
260 evaluationData.EvaluationTotalScore(newEvaluationValue) 264 evaluationData.EvaluationTotalScore(newEvaluationValue)
261 265
262 err = evaluationRepo.Save(evaluationData) 266 err = evaluationRepo.Save(evaluationData)
@@ -483,203 +483,203 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app @@ -483,203 +483,203 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app
483 } 483 }
484 484
485 // 编辑综合自评详情 485 // 编辑综合自评详情
486 -func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) {  
487 - lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)  
488 - err := lock.Lock()  
489 - if err != nil {  
490 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")  
491 - }  
492 - defer func() {  
493 - lock.UnLock()  
494 - }()  
495 - transactionContext, err := factory.CreateTransactionContext(nil)  
496 - if err != nil {  
497 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
498 - }  
499 - if err := transactionContext.StartTransaction(); err != nil {  
500 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
501 - }  
502 - defer func() {  
503 - _ = transactionContext.RollbackTransaction()  
504 - }()  
505 - evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{  
506 - "transactionContext": transactionContext,  
507 - })  
508 - itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{  
509 - "transactionContext": transactionContext,  
510 - }) 486 +// func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) {
  487 +// lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)
  488 +// err := lock.Lock()
  489 +// if err != nil {
  490 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
  491 +// }
  492 +// defer func() {
  493 +// lock.UnLock()
  494 +// }()
  495 +// transactionContext, err := factory.CreateTransactionContext(nil)
  496 +// if err != nil {
  497 +// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  498 +// }
  499 +// if err := transactionContext.StartTransaction(); err != nil {
  500 +// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  501 +// }
  502 +// defer func() {
  503 +// _ = transactionContext.RollbackTransaction()
  504 +// }()
  505 +// evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
  506 +// "transactionContext": transactionContext,
  507 +// })
  508 +// itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
  509 +// "transactionContext": transactionContext,
  510 +// })
511 511
512 - itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{  
513 - "transactionContext": transactionContext,  
514 - })  
515 - evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{  
516 - "id": param.SummaryEvaluationId,  
517 - })  
518 - if err != nil {  
519 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估"+err.Error())  
520 - }  
521 - if evaluationData.Types != domain.EvaluationSelf {  
522 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")  
523 - } 512 +// itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
  513 +// "transactionContext": transactionContext,
  514 +// })
  515 +// evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
  516 +// "id": param.SummaryEvaluationId,
  517 +// })
  518 +// if err != nil {
  519 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估"+err.Error())
  520 +// }
  521 +// if evaluationData.Types != domain.EvaluationSelf {
  522 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
  523 +// }
524 524
525 - if evaluationData.Executor.UserId != param.ExecutorId {  
526 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")  
527 - } 525 +// if evaluationData.Executor.UserId != param.ExecutorId {
  526 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
  527 +// }
528 528
529 - if evaluationData.CompanyId != param.CompanyId {  
530 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")  
531 - } 529 +// if evaluationData.CompanyId != param.CompanyId {
  530 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
  531 +// }
532 532
533 - _, itemList, err := itemUsedRepo.Find(map[string]interface{}{  
534 - "evaluationProjectId": evaluationData.EvaluationProjectId,  
535 - "nodeType": domain.LinkNodeSelfAssessment,  
536 - })  
537 - if err != nil {  
538 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
539 - } 533 +// _, itemList, err := itemUsedRepo.Find(map[string]interface{}{
  534 +// "evaluationProjectId": evaluationData.EvaluationProjectId,
  535 +// "nodeType": domain.LinkNodeSelfAssessment,
  536 +// })
  537 +// if err != nil {
  538 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  539 +// }
540 540
541 - _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{  
542 - "summaryEvaluationId": evaluationData.Id,  
543 - }) 541 +// _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{
  542 +// "summaryEvaluationId": evaluationData.Id,
  543 +// })
544 544
545 - if err != nil {  
546 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
547 - } 545 +// if err != nil {
  546 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  547 +// }
548 548
549 - err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, nil, param.IsTemporary)  
550 - if err != nil {  
551 - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())  
552 - } 549 +// err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, nil, param.IsTemporary)
  550 +// if err != nil {
  551 +// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  552 +// }
553 553
554 - //保存填写值  
555 - for _, v := range itemValueList {  
556 - err = itemValueRepo.Save(v)  
557 - if err != nil {  
558 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
559 - }  
560 - }  
561 - if !param.IsTemporary {  
562 - evaluationData.Status = domain.EvaluationCompleted  
563 - }  
564 - err = evaluationRepo.Save(evaluationData)  
565 - if err != nil {  
566 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
567 - }  
568 - if err := transactionContext.CommitTransaction(); err != nil {  
569 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
570 - }  
571 - if !param.IsTemporary {  
572 - err = srv.AfterCompletedEvaluationSelf(evaluationData)  
573 - if err != nil {  
574 - return nil, err  
575 - }  
576 - } 554 +// //保存填写值
  555 +// for _, v := range itemValueList {
  556 +// err = itemValueRepo.Save(v)
  557 +// if err != nil {
  558 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  559 +// }
  560 +// }
  561 +// if !param.IsTemporary {
  562 +// evaluationData.Status = domain.EvaluationCompleted
  563 +// }
  564 +// err = evaluationRepo.Save(evaluationData)
  565 +// if err != nil {
  566 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  567 +// }
  568 +// if err := transactionContext.CommitTransaction(); err != nil {
  569 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  570 +// }
  571 +// if !param.IsTemporary {
  572 +// err = srv.AfterCompletedEvaluationSelf(evaluationData)
  573 +// if err != nil {
  574 +// return nil, err
  575 +// }
  576 +// }
577 577
578 - itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)  
579 - return map[string][]adapter.EvaluationItemAdapter{  
580 - "EvaluationItems": itemValueAdapter,  
581 - }, nil  
582 -} 578 +// itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
  579 +// return map[string][]adapter.EvaluationItemAdapter{
  580 +// "EvaluationItems": itemValueAdapter,
  581 +// }, nil
  582 +// }
583 583
584 -// 员工提交自评内容后,  
585 -// 员工作为被评估人,  
586 -// 变更360评估/人资评估/的开始时间  
587 -// 或者变更上级评估的开始时间  
588 -// 或者生成考核结果  
589 -func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain.SummaryEvaluation) error {  
590 - lock := xredis.NewLockSummaryEvaluation(param.TargetUser.UserId)  
591 - err := lock.Lock()  
592 - if err != nil {  
593 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")  
594 - }  
595 - defer func() {  
596 - lock.UnLock()  
597 - }()  
598 - transactionContext, err := factory.CreateTransactionContext(nil)  
599 - if err != nil {  
600 - return application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
601 - }  
602 - if err := transactionContext.StartTransaction(); err != nil {  
603 - return application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
604 - }  
605 - defer func() {  
606 - _ = transactionContext.RollbackTransaction()  
607 - }()  
608 - evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{  
609 - "transactionContext": transactionContext,  
610 - })  
611 - _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{  
612 - "targetUserId": param.TargetUser.UserId,  
613 - "typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},  
614 - "cycleId": param.CycleId,  
615 - "limit": 1000,  
616 - })  
617 - if err != nil {  
618 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
619 - }  
620 - if len(evaluationList) == 0 {  
621 - //如果没有360评估和hrbp 评估,查找上级评估  
622 - _, evaluationList, err = evaluationRepo.Find(map[string]interface{}{  
623 - "targetUserId": param.TargetUser.UserId,  
624 - "typesList": []int{int(domain.EvaluationSuper)},  
625 - "cycleId": param.CycleId,  
626 - "limit": 10,  
627 - })  
628 - if err != nil {  
629 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
630 - }  
631 - }  
632 - nowTime := time.Now()  
633 - updatedId := []int{}  
634 - // 变更360评估/人资评估/上级评估的开始时间  
635 - for _, v := range evaluationList {  
636 - if v.BeginTime.After(nowTime) {  
637 - v.BeginTime = nowTime  
638 - updatedId = append(updatedId, v.Id)  
639 - }  
640 - }  
641 - evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{  
642 - "transactionContext": transactionContext,  
643 - })  
644 - err = evaluationDao.UpdateBeginTime(updatedId, nowTime)  
645 - if err != nil {  
646 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
647 - }  
648 - if len(evaluationList) == 0 {  
649 - //没有上级评估、360评估、hrbp 评估  
650 - //直接进入考核结果阶段  
651 - _, evaluationFinishList, err := evaluationRepo.Find(map[string]interface{}{  
652 - "targetUserId": param.TargetUser.UserId,  
653 - "typesList": []int{int(domain.EvaluationFinish)},  
654 - "cycleId": param.CycleId,  
655 - "limit": 1,  
656 - })  
657 - if err != nil {  
658 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
659 - }  
660 - if len(evaluationFinishList) > 0 {  
661 - //进入考核结果  
662 - //自评的结束时间  
663 - if evaluationFinishList[0].BeginTime.After(nowTime) {  
664 - evaluationFinishList[0].BeginTime = nowTime  
665 - }  
666 - evaluationFinishList[0].Status = domain.EvaluationCompleted  
667 - err = evaluationRepo.Save(evaluationFinishList[0])  
668 - if err != nil {  
669 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())  
670 - }  
671 - //添加确认绩效成绩提醒短信提醒  
672 - err = notify.AddNotifyConfirmEvaluationScore(evaluationFinishList[0])  
673 - if err != nil {  
674 - return application.ThrowError(application.TRANSACTION_ERROR, "创建短信提醒失败"+err.Error())  
675 - }  
676 - }  
677 - }  
678 - if err := transactionContext.CommitTransaction(); err != nil {  
679 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
680 - }  
681 - return nil  
682 -} 584 +// // 员工提交自评内容后,
  585 +// // 员工作为被评估人,
  586 +// // 变更360评估/人资评估/的开始时间
  587 +// // 或者变更上级评估的开始时间
  588 +// // 或者生成考核结果
  589 +// func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain.SummaryEvaluation) error {
  590 +// lock := xredis.NewLockSummaryEvaluation(param.TargetUser.UserId)
  591 +// err := lock.Lock()
  592 +// if err != nil {
  593 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
  594 +// }
  595 +// defer func() {
  596 +// lock.UnLock()
  597 +// }()
  598 +// transactionContext, err := factory.CreateTransactionContext(nil)
  599 +// if err != nil {
  600 +// return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  601 +// }
  602 +// if err := transactionContext.StartTransaction(); err != nil {
  603 +// return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  604 +// }
  605 +// defer func() {
  606 +// _ = transactionContext.RollbackTransaction()
  607 +// }()
  608 +// evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
  609 +// "transactionContext": transactionContext,
  610 +// })
  611 +// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
  612 +// "targetUserId": param.TargetUser.UserId,
  613 +// "typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},
  614 +// "cycleId": param.CycleId,
  615 +// "limit": 1000,
  616 +// })
  617 +// if err != nil {
  618 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  619 +// }
  620 +// if len(evaluationList) == 0 {
  621 +// //如果没有360评估和hrbp 评估,查找上级评估
  622 +// _, evaluationList, err = evaluationRepo.Find(map[string]interface{}{
  623 +// "targetUserId": param.TargetUser.UserId,
  624 +// "typesList": []int{int(domain.EvaluationSuper)},
  625 +// "cycleId": param.CycleId,
  626 +// "limit": 10,
  627 +// })
  628 +// if err != nil {
  629 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  630 +// }
  631 +// }
  632 +// nowTime := time.Now()
  633 +// updatedId := []int{}
  634 +// // 变更360评估/人资评估/上级评估的开始时间
  635 +// for _, v := range evaluationList {
  636 +// if v.BeginTime.After(nowTime) {
  637 +// v.BeginTime = nowTime
  638 +// updatedId = append(updatedId, v.Id)
  639 +// }
  640 +// }
  641 +// evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{
  642 +// "transactionContext": transactionContext,
  643 +// })
  644 +// err = evaluationDao.UpdateBeginTime(updatedId, nowTime)
  645 +// if err != nil {
  646 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  647 +// }
  648 +// if len(evaluationList) == 0 {
  649 +// //没有上级评估、360评估、hrbp 评估
  650 +// //直接进入考核结果阶段
  651 +// _, evaluationFinishList, err := evaluationRepo.Find(map[string]interface{}{
  652 +// "targetUserId": param.TargetUser.UserId,
  653 +// "typesList": []int{int(domain.EvaluationFinish)},
  654 +// "cycleId": param.CycleId,
  655 +// "limit": 1,
  656 +// })
  657 +// if err != nil {
  658 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  659 +// }
  660 +// if len(evaluationFinishList) > 0 {
  661 +// //进入考核结果
  662 +// //自评的结束时间
  663 +// if evaluationFinishList[0].BeginTime.After(nowTime) {
  664 +// evaluationFinishList[0].BeginTime = nowTime
  665 +// }
  666 +// evaluationFinishList[0].Status = domain.EvaluationCompleted
  667 +// err = evaluationRepo.Save(evaluationFinishList[0])
  668 +// if err != nil {
  669 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
  670 +// }
  671 +// //添加确认绩效成绩提醒短信提醒
  672 +// err = notify.AddNotifyConfirmEvaluationScore(evaluationFinishList[0])
  673 +// if err != nil {
  674 +// return application.ThrowError(application.TRANSACTION_ERROR, "创建短信提醒失败"+err.Error())
  675 +// }
  676 +// }
  677 +// }
  678 +// if err := transactionContext.CommitTransaction(); err != nil {
  679 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  680 +// }
  681 +// return nil
  682 +// }
683 683
684 // 提交员工的人资评估 或者 360 评估 684 // 提交员工的人资评估 或者 360 评估
685 // 变更上级评估的开始时间 685 // 变更上级评估的开始时间
@@ -2152,14 +2152,6 @@ func (srv *SummaryEvaluationService) editEvaluationValueUnlimited( @@ -2152,14 +2152,6 @@ func (srv *SummaryEvaluationService) editEvaluationValueUnlimited(
2152 } 2152 }
2153 } 2153 }
2154 } 2154 }
2155 - // 等待产品确认  
2156 - // if evaluationData.Types == domain.EvaluationSelf {  
2157 - // // 填充评估填写值  
2158 - // err := newItemValue.EvaluationSelfFillValue(evaluationItem, v.Value, v.Remark)  
2159 - // if err != nil {  
2160 - // return err  
2161 - // }  
2162 - // } else {  
2163 //填充评估填写值 2155 //填充评估填写值
2164 err := newItemValue.FillValue(evaluationItem, v.Value, v.Remark) 2156 err := newItemValue.FillValue(evaluationItem, v.Value, v.Remark)
2165 if err != nil { 2157 if err != nil {