|
@@ -724,131 +724,7 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBPComplete(param *command.Qu |
|
@@ -724,131 +724,7 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBPComplete(param *command.Qu |
724
|
return &itemValuesAdapter, nil
|
724
|
return &itemValuesAdapter, nil
|
725
|
}
|
725
|
}
|
726
|
|
726
|
|
727
|
-// EditEvaluationHRBP 编辑提交人资综评
|
|
|
728
|
-// func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) {
|
|
|
729
|
-// lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)
|
|
|
730
|
-// err := lock.Lock()
|
|
|
731
|
-// if err != nil {
|
|
|
732
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
733
|
-// }
|
|
|
734
|
-// defer func() {
|
|
|
735
|
-// lock.UnLock()
|
|
|
736
|
-// }()
|
|
|
737
|
-// transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
738
|
-// if err != nil {
|
|
|
739
|
-// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
740
|
-// }
|
|
|
741
|
-// if err := transactionContext.StartTransaction(); err != nil {
|
|
|
742
|
-// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
743
|
-// }
|
|
|
744
|
-// defer func() {
|
|
|
745
|
-// _ = transactionContext.RollbackTransaction()
|
|
|
746
|
-// }()
|
|
|
747
|
-
|
|
|
748
|
-// userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
749
|
-// evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
750
|
-// itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
751
|
-// itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
752
|
-
|
|
|
753
|
-// // 必须是HRBP权限的人才能编辑操作
|
|
|
754
|
-// hrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.ExecutorId)
|
|
|
755
|
-// if err != nil {
|
|
|
756
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
757
|
-// }
|
|
|
758
|
-// if hrbp != domain.RoleTypeSystem {
|
|
|
759
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
760
|
-// }
|
|
|
761
|
-
|
|
|
762
|
-// summaryEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
|
|
|
763
|
-// if err != nil {
|
|
|
764
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
765
|
-// }
|
|
|
766
|
-// if summaryEvaluation.Types != domain.EvaluationHrbp {
|
|
|
767
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
768
|
-// }
|
|
|
769
|
-// if summaryEvaluation.CompanyId != param.CompanyId {
|
|
|
770
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
771
|
-// }
|
|
|
772
|
-
|
|
|
773
|
-// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
774
|
-// "targetUserId": summaryEvaluation.TargetUser.UserId,
|
|
|
775
|
-// "typesList": []int{int(domain.EvaluationFinish)},
|
|
|
776
|
-// "cycleId": summaryEvaluation.CycleId,
|
|
|
777
|
-// "limit": 1,
|
|
|
778
|
-// })
|
|
|
779
|
-// if err != nil {
|
|
|
780
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
781
|
-// }
|
|
|
782
|
-// // 如果目标员工已经确认考核结果,就不能在进行评估编辑
|
|
|
783
|
-// if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted {
|
|
|
784
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能再编辑!")
|
|
|
785
|
-// }
|
|
|
786
|
-
|
|
|
787
|
-// // 自评评估内容(自评模板、筛选项目评估人)
|
|
|
788
|
-// _, itemList, err := itemUsedRepo.Find(map[string]interface{}{
|
|
|
789
|
-// "evaluationProjectId": summaryEvaluation.EvaluationProjectId,
|
|
|
790
|
-// "nodeType": domain.LinkNodeSelfAssessment,
|
|
|
791
|
-// "evaluatorId": -1,
|
|
|
792
|
-// })
|
|
|
793
|
-// if err != nil {
|
|
|
794
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
795
|
-// }
|
|
|
796
|
-
|
|
|
797
|
-// // 评估内容对应的分数
|
|
|
798
|
-// _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": summaryEvaluation.Id})
|
|
|
799
|
-// if err != nil {
|
|
|
800
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
801
|
-// }
|
|
|
802
|
-
|
|
|
803
|
-// err = srv.editEvaluationValue(summaryEvaluation, &itemValueList, itemList, param.EvaluationItems, nil, param.IsTemporary)
|
|
|
804
|
-// if err != nil {
|
|
|
805
|
-// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
806
|
-// }
|
|
|
807
|
-// if !param.IsTemporary {
|
|
|
808
|
-// //变更评估状态为已填写
|
|
|
809
|
-// summaryEvaluation.Status = domain.EvaluationCompleted
|
|
|
810
|
-// }
|
|
|
811
|
-// //保存填写值
|
|
|
812
|
-// for _, v := range itemValueList {
|
|
|
813
|
-// err = itemValueRepo.Save(v)
|
|
|
814
|
-// if err != nil {
|
|
|
815
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
816
|
-// }
|
|
|
817
|
-// }
|
|
|
818
|
-
|
|
|
819
|
-// // 针对HRBP类型,更新最后一次操作的HRBP人
|
|
|
820
|
-// user, err := userRepo.FindOne(map[string]interface{}{"id": param.ExecutorId})
|
|
|
821
|
-// if err != nil {
|
|
|
822
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
823
|
-// }
|
|
|
824
|
-// summaryEvaluation.Executor.UserId = param.ExecutorId
|
|
|
825
|
-// summaryEvaluation.Executor.Account = user.Account
|
|
|
826
|
-// summaryEvaluation.Executor.UserName = user.Name
|
|
|
827
|
-// summaryEvaluation.Executor.CompanyName = "" // 暂时无用
|
|
|
828
|
-// summaryEvaluation.Status = domain.EvaluationCompleted
|
|
|
829
|
-
|
|
|
830
|
-// //保存填写值
|
|
|
831
|
-// err = evaluationRepo.Save(summaryEvaluation)
|
|
|
832
|
-// if err != nil {
|
|
|
833
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
834
|
-// }
|
|
|
835
|
-// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
836
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
837
|
-// }
|
|
|
838
|
-
|
|
|
839
|
-// if !param.IsTemporary {
|
|
|
840
|
-// err = srv.AfterCompletedEvaluation360Hrbp(summaryEvaluation)
|
|
|
841
|
-// if err != nil {
|
|
|
842
|
-// return nil, err
|
|
|
843
|
-// }
|
|
|
844
|
-// }
|
|
|
845
|
-// itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
|
|
|
846
|
-// return map[string][]adapter.EvaluationItemAdapter{
|
|
|
847
|
-// "evaluationItems": itemValueAdapter,
|
|
|
848
|
-// }, nil
|
|
|
849
|
-// }
|
|
|
850
|
-
|
|
|
851
|
-// 修改周期考核的分数
|
727
|
+// ModifyFinishScore 修改周期考核的分数
|
852
|
func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFinishScore) error {
|
728
|
func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFinishScore) error {
|
853
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
729
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
854
|
if err != nil {
|
730
|
if err != nil {
|
|
@@ -869,27 +745,115 @@ func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFini |
|
@@ -869,27 +745,115 @@ func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFini |
869
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
745
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
870
|
}
|
746
|
}
|
871
|
|
747
|
|
872
|
- //获取周期评估任务finish
|
748
|
+ // 获取周期评估任务finish
|
873
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
749
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
874
|
- _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
875
|
- "id": []int{param.SummaryEvaluationId},
|
|
|
876
|
- "companyId": param.CompanyId,
|
|
|
877
|
- })
|
750
|
+ itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
751
|
+
|
|
|
752
|
+ _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{"id": []int{param.SummaryEvaluationId}, "companyId": param.CompanyId})
|
878
|
if err != nil {
|
753
|
if err != nil {
|
879
|
return application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
754
|
return application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
880
|
}
|
755
|
}
|
881
|
if len(evaluationList) == 0 {
|
756
|
if len(evaluationList) == 0 {
|
882
|
return nil
|
757
|
return nil
|
883
|
}
|
758
|
}
|
884
|
- evaluationData := evaluationList[0]
|
|
|
885
|
- if evaluationData.Types != domain.EvaluationFinish {
|
759
|
+ result := evaluationList[0]
|
|
|
760
|
+ if result.Types != domain.EvaluationFinish {
|
886
|
return nil
|
761
|
return nil
|
887
|
}
|
762
|
}
|
|
|
763
|
+
|
|
|
764
|
+ // 获取考核结果评分
|
|
|
765
|
+ _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": result.Id})
|
|
|
766
|
+ if err != nil {
|
|
|
767
|
+ return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
768
|
+ }
|
|
|
769
|
+ // 如果已经存在考核结果分数,只更新分数(反之先默认生成考核结果,再更新分数)
|
|
|
770
|
+ if len(itemValues) > 0 {
|
|
|
771
|
+ // do nothing...
|
|
|
772
|
+ } else {
|
|
|
773
|
+ evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
774
|
+
|
|
|
775
|
+ // 周期内所有评估类型
|
|
|
776
|
+ _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
777
|
+ "companyId": result.CompanyId,
|
|
|
778
|
+ "cycleId": result.CycleId,
|
|
|
779
|
+ "targetUserId": result.TargetUser.UserId,
|
|
|
780
|
+ })
|
|
|
781
|
+ if err != nil {
|
|
|
782
|
+ return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
783
|
+ }
|
|
|
784
|
+
|
|
|
785
|
+ var super *domain.SummaryEvaluation // 上级评估
|
|
|
786
|
+ for i := range evaluationList {
|
|
|
787
|
+ it := evaluationList[i]
|
|
|
788
|
+ if it.Types == domain.EvaluationSuper {
|
|
|
789
|
+ super = it
|
|
|
790
|
+ break
|
|
|
791
|
+ }
|
|
|
792
|
+ }
|
|
|
793
|
+
|
|
|
794
|
+ // 获取自评模板
|
|
|
795
|
+ _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
|
|
|
796
|
+ if err != nil {
|
|
|
797
|
+ return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
798
|
+ }
|
|
|
799
|
+
|
|
|
800
|
+ if super != nil {
|
|
|
801
|
+ _, superValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": super.Id}) // 获取已填写的评估内容
|
|
|
802
|
+ if err != nil {
|
|
|
803
|
+ return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
804
|
+ }
|
|
|
805
|
+ // 更新填写值
|
|
|
806
|
+ itemValues, err = srv.updateItemValuePriority(result, itemList, superValues, true)
|
|
|
807
|
+ if err != nil {
|
|
|
808
|
+ return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
809
|
+ }
|
|
|
810
|
+ } else {
|
|
|
811
|
+ // 评估项ID(除考核结果和上级)
|
|
|
812
|
+ var evaluationIds = make([]int, 0)
|
|
|
813
|
+ for i := range evaluationList {
|
|
|
814
|
+ it := evaluationList[i]
|
|
|
815
|
+ if it.Types == domain.EvaluationSelf || it.Types == domain.Evaluation360 || it.Types == domain.EvaluationHrbp {
|
|
|
816
|
+ evaluationIds = append(evaluationIds, it.Id)
|
|
|
817
|
+ }
|
|
|
818
|
+ }
|
|
|
819
|
+ if len(evaluationIds) > 0 {
|
|
|
820
|
+ // 已填写的评估内容
|
|
|
821
|
+ _, otherValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds})
|
|
|
822
|
+ if err != nil {
|
|
|
823
|
+ return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
824
|
+ }
|
|
|
825
|
+
|
|
|
826
|
+ // 更新填写值
|
|
|
827
|
+ itemValues, err = srv.updateItemValuePriority(result, itemList, otherValues, false)
|
|
|
828
|
+ if err != nil {
|
|
|
829
|
+ return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
830
|
+ }
|
|
|
831
|
+ }
|
|
|
832
|
+ }
|
|
|
833
|
+ err = itemValueRepo.RemoveBySummaryEvaluationId(result.Id)
|
|
|
834
|
+ if err != nil {
|
|
|
835
|
+ return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
836
|
+ }
|
|
|
837
|
+ for i := range itemValues {
|
|
|
838
|
+ if err := itemValueRepo.Save(itemValues[i]); err != nil {
|
|
|
839
|
+ return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
840
|
+ }
|
|
|
841
|
+ }
|
|
|
842
|
+ // 重置评级汇总
|
|
|
843
|
+ result.TotalRating = nil
|
|
|
844
|
+ for i := range itemList {
|
|
|
845
|
+ result.ResetTotalRating(itemList[i])
|
|
|
846
|
+ }
|
|
|
847
|
+ //// 计算分数
|
|
|
848
|
+ //if err := result.EvaluationTotalScore(itemValues); err != nil {
|
|
|
849
|
+ // return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
850
|
+ //}
|
|
|
851
|
+ }
|
|
|
852
|
+
|
888
|
scoreStr := fmt.Sprintf("%.2f", param.Score)
|
853
|
scoreStr := fmt.Sprintf("%.2f", param.Score)
|
889
|
- evaluationData.TotalScore = scoreStr
|
|
|
890
|
- evaluationData.Status = domain.EvaluationCompleted
|
|
|
891
|
- // evaluationData.CheckResult = domain.EvaluationCheckCompleted
|
|
|
892
|
- err = evaluationRepo.Save(evaluationData)
|
854
|
+ result.TotalScore = scoreStr
|
|
|
855
|
+ result.Status = domain.EvaluationCompleted
|
|
|
856
|
+ err = evaluationRepo.Save(result)
|
893
|
if err != nil {
|
857
|
if err != nil {
|
894
|
return application.ThrowError(application.BUSINESS_ERROR, "修改考核结果"+err.Error())
|
858
|
return application.ThrowError(application.BUSINESS_ERROR, "修改考核结果"+err.Error())
|
895
|
}
|
859
|
}
|