...
|
...
|
@@ -724,172 +724,136 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBPComplete(param *command.Qu |
|
|
return &itemValuesAdapter, nil
|
|
|
}
|
|
|
|
|
|
// EditEvaluationHRBP 编辑提交人资综评
|
|
|
// func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) {
|
|
|
// lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)
|
|
|
// err := lock.Lock()
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
// }
|
|
|
// defer func() {
|
|
|
// lock.UnLock()
|
|
|
// }()
|
|
|
// ModifyFinishScore 修改周期考核的分数
|
|
|
// func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFinishScore) error {
|
|
|
// transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// if err := transactionContext.StartTransaction(); err != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// defer func() {
|
|
|
// _ = transactionContext.RollbackTransaction()
|
|
|
// }()
|
|
|
// // 只有超级管理员可以使用的功能
|
|
|
// superAdmin, err := roleService.GetSuperAdmin(transactionContext, param.CompanyId, param.UserId)
|
|
|
// if err != nil {
|
|
|
// return err
|
|
|
// }
|
|
|
// if superAdmin != domain.RoleTypeSuperAdmin {
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
// }
|
|
|
|
|
|
// userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
// // 获取周期评估任务finish
|
|
|
// evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
// itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
// itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
|
|
// // 必须是HRBP权限的人才能编辑操作
|
|
|
// hrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.ExecutorId)
|
|
|
// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{"id": []int{param.SummaryEvaluationId}, "companyId": param.CompanyId})
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// return application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
// }
|
|
|
// if hrbp != domain.RoleTypeSystem {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
// if len(evaluationList) == 0 {
|
|
|
// return nil
|
|
|
// }
|
|
|
// result := evaluationList[0]
|
|
|
// if result.Types != domain.EvaluationFinish {
|
|
|
// return nil
|
|
|
// }
|
|
|
|
|
|
// summaryEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
|
|
|
// // 获取考核结果评分
|
|
|
// _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": result.Id})
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// if summaryEvaluation.Types != domain.EvaluationHrbp {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
// }
|
|
|
// if summaryEvaluation.CompanyId != param.CompanyId {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// // 如果已经存在考核结果分数,只更新分数(反之先默认生成考核结果,再更新分数)
|
|
|
// if len(itemValues) > 0 {
|
|
|
// // do nothing...
|
|
|
// } else {
|
|
|
// evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
|
|
// // 周期内所有评估类型
|
|
|
// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
// "targetUserId": summaryEvaluation.TargetUser.UserId,
|
|
|
// "typesList": []int{int(domain.EvaluationFinish)},
|
|
|
// "cycleId": summaryEvaluation.CycleId,
|
|
|
// "limit": 1,
|
|
|
// "companyId": result.CompanyId,
|
|
|
// "cycleId": result.CycleId,
|
|
|
// "targetUserId": result.TargetUser.UserId,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// // 如果目标员工已经确认考核结果,就不能在进行评估编辑
|
|
|
// if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能再编辑!")
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
|
|
|
// // 自评评估内容(自评模板、筛选项目评估人)
|
|
|
// _, itemList, err := itemUsedRepo.Find(map[string]interface{}{
|
|
|
// "evaluationProjectId": summaryEvaluation.EvaluationProjectId,
|
|
|
// "nodeType": domain.LinkNodeSelfAssessment,
|
|
|
// "evaluatorId": -1,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// var super *domain.SummaryEvaluation // 上级评估
|
|
|
// for i := range evaluationList {
|
|
|
// it := evaluationList[i]
|
|
|
// if it.Types == domain.EvaluationSuper {
|
|
|
// super = it
|
|
|
// break
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// // 评估内容对应的分数
|
|
|
// _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": summaryEvaluation.Id})
|
|
|
// // 获取自评模板
|
|
|
// _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
|
|
|
// err = srv.editEvaluationValue(summaryEvaluation, &itemValueList, itemList, param.EvaluationItems, nil, param.IsTemporary)
|
|
|
// if super != nil {
|
|
|
// _, superValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": super.Id}) // 获取已填写的评估内容
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
// }
|
|
|
// if !param.IsTemporary {
|
|
|
// //变更评估状态为已填写
|
|
|
// summaryEvaluation.Status = domain.EvaluationCompleted
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// //保存填写值
|
|
|
// for _, v := range itemValueList {
|
|
|
// err = itemValueRepo.Save(v)
|
|
|
// // 更新填写值
|
|
|
// itemValues, err = srv.updateItemValuePriority(result, itemList, superValues, true)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// } else {
|
|
|
// // 评估项ID(除考核结果和上级)
|
|
|
// var evaluationIds = make([]int, 0)
|
|
|
// for i := range evaluationList {
|
|
|
// it := evaluationList[i]
|
|
|
// if it.Types == domain.EvaluationSelf || it.Types == domain.Evaluation360 || it.Types == domain.EvaluationHrbp {
|
|
|
// evaluationIds = append(evaluationIds, it.Id)
|
|
|
// }
|
|
|
|
|
|
// // 针对HRBP类型,更新最后一次操作的HRBP人
|
|
|
// user, err := userRepo.FindOne(map[string]interface{}{"id": param.ExecutorId})
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// summaryEvaluation.Executor.UserId = param.ExecutorId
|
|
|
// summaryEvaluation.Executor.Account = user.Account
|
|
|
// summaryEvaluation.Executor.UserName = user.Name
|
|
|
// summaryEvaluation.Executor.CompanyName = "" // 暂时无用
|
|
|
// summaryEvaluation.Status = domain.EvaluationCompleted
|
|
|
|
|
|
// //保存填写值
|
|
|
// err = evaluationRepo.Save(summaryEvaluation)
|
|
|
// if len(evaluationIds) > 0 {
|
|
|
// // 已填写的评估内容
|
|
|
// _, otherValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds})
|
|
|
// 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())
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
|
|
|
// if !param.IsTemporary {
|
|
|
// err = srv.AfterCompletedEvaluation360Hrbp(summaryEvaluation)
|
|
|
// // 更新填写值
|
|
|
// itemValues, err = srv.updateItemValuePriority(result, itemList, otherValues, false)
|
|
|
// if err != nil {
|
|
|
// return nil, err
|
|
|
// }
|
|
|
// }
|
|
|
// itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
|
|
|
// return map[string][]adapter.EvaluationItemAdapter{
|
|
|
// "evaluationItems": itemValueAdapter,
|
|
|
// }, nil
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
|
|
|
// 修改周期考核的分数
|
|
|
// func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFinishScore) error {
|
|
|
// transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
// if err != nil {
|
|
|
// return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// if err := transactionContext.StartTransaction(); err != nil {
|
|
|
// return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// defer func() {
|
|
|
// _ = transactionContext.RollbackTransaction()
|
|
|
// }()
|
|
|
// // 只有超级管理员可以使用的功能
|
|
|
// superAdmin, err := roleService.GetSuperAdmin(transactionContext, param.CompanyId, param.UserId)
|
|
|
// err = itemValueRepo.RemoveBySummaryEvaluationId(result.Id)
|
|
|
// if err != nil {
|
|
|
// return err
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// if superAdmin != domain.RoleTypeSuperAdmin {
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
// for i := range itemValues {
|
|
|
// if err := itemValueRepo.Save(itemValues[i]); err != nil {
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
|
|
|
// //获取周期评估任务finish
|
|
|
// evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
// "id": []int{param.SummaryEvaluationId},
|
|
|
// "companyId": param.CompanyId,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
// }
|
|
|
// if len(evaluationList) == 0 {
|
|
|
// return nil
|
|
|
// // 重置评级汇总
|
|
|
// result.TotalRating = nil
|
|
|
// for i := range itemList {
|
|
|
// result.ResetTotalRating(itemList[i])
|
|
|
// }
|
|
|
// evaluationData := evaluationList[0]
|
|
|
// if evaluationData.Types != domain.EvaluationFinish {
|
|
|
// return nil
|
|
|
// //// 计算分数
|
|
|
// //if err := result.EvaluationTotalScore(itemValues); err != nil {
|
|
|
// // return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// //}
|
|
|
// }
|
|
|
|
|
|
// scoreStr := fmt.Sprintf("%.2f", param.Score)
|
|
|
// evaluationData.TotalScore = scoreStr
|
|
|
// evaluationData.Status = domain.EvaluationCompleted
|
|
|
// // evaluationData.CheckResult = domain.EvaluationCheckCompleted
|
|
|
// err = evaluationRepo.Save(evaluationData)
|
|
|
// result.TotalScore = scoreStr
|
|
|
// result.Status = domain.EvaluationCompleted
|
|
|
// err = evaluationRepo.Save(result)
|
|
|
// if err != nil {
|
|
|
// return application.ThrowError(application.BUSINESS_ERROR, "修改考核结果"+err.Error())
|
|
|
// }
|
...
|
...
|
|