|
|
package service
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
|
"github.com/linmadan/egglib-go/core/application"
|
...
|
...
|
@@ -13,137 +15,136 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
|
|
|
)
|
|
|
|
|
|
//编辑上级周期评估
|
|
|
|
|
|
// 编辑上级周期评估
|
|
|
// EditEvaluationSuper 更新上级评估内容
|
|
|
func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEvaluationValue) (interface{}, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
// func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEvaluationValue) (interface{}, error) {
|
|
|
// transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// if err := transactionContext.StartTransaction(); err != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// defer func() {
|
|
|
// _ = transactionContext.RollbackTransaction()
|
|
|
// }()
|
|
|
// evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// })
|
|
|
// itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// })
|
|
|
|
|
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
|
|
|
"id": param.SummaryEvaluationId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if evaluationData.Types != domain.EvaluationSuper {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
}
|
|
|
// itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// })
|
|
|
// evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
|
|
|
// "id": param.SummaryEvaluationId,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// if evaluationData.Types != domain.EvaluationSuper {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
// }
|
|
|
|
|
|
if evaluationData.Executor.UserId != param.ExecutorId {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
}
|
|
|
// if evaluationData.Executor.UserId != param.ExecutorId {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
// }
|
|
|
|
|
|
if evaluationData.CompanyId != param.CompanyId {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
}
|
|
|
ok := evaluationData.EndTime.Before(time.Now())
|
|
|
if ok {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "评估时间已截止")
|
|
|
}
|
|
|
//按照被评估人id ,加锁
|
|
|
lock := xredis.NewLockSummaryEvaluation(evaluationData.TargetUser.UserId)
|
|
|
err = lock.Lock()
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
}
|
|
|
defer func() {
|
|
|
lock.UnLock()
|
|
|
}()
|
|
|
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"targetUserId": evaluationData.TargetUser.UserId,
|
|
|
"typesList": []int{int(domain.EvaluationFinish)},
|
|
|
"cycleId": evaluationData.CycleId,
|
|
|
"limit": 1,
|
|
|
})
|
|
|
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, "用户已经确认该周期的考核结果,不能再编辑!")
|
|
|
}
|
|
|
// if evaluationData.CompanyId != param.CompanyId {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
// }
|
|
|
// ok := evaluationData.EndTime.Before(time.Now())
|
|
|
// if ok {
|
|
|
// return nil, application.ThrowError(application.BUSINESS_ERROR, "评估时间已截止")
|
|
|
// }
|
|
|
// //按照被评估人id ,加锁
|
|
|
// lock := xredis.NewLockSummaryEvaluation(evaluationData.TargetUser.UserId)
|
|
|
// err = lock.Lock()
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
// }
|
|
|
// defer func() {
|
|
|
// lock.UnLock()
|
|
|
// }()
|
|
|
// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
// "targetUserId": evaluationData.TargetUser.UserId,
|
|
|
// "typesList": []int{int(domain.EvaluationFinish)},
|
|
|
// "cycleId": evaluationData.CycleId,
|
|
|
// "limit": 1,
|
|
|
// })
|
|
|
// 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, "用户已经确认该周期的考核结果,不能再编辑!")
|
|
|
// }
|
|
|
|
|
|
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{
|
|
|
"evaluationProjectId": evaluationData.EvaluationProjectId,
|
|
|
"nodeType": domain.LinkNodeSelfAssessment,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
//获取已填写的评估内容
|
|
|
_, itemValueList, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
"summaryEvaluationId": evaluationData.Id,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
//记录人资评估或者360评估的 填写项id
|
|
|
hrbpOr360ItemValue, err := srv.getEvaluationSuperDefaultValue(transactionContext, evaluationData)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
// _, itemList, err := itemUsedRepo.Find(map[string]interface{}{
|
|
|
// "evaluationProjectId": evaluationData.EvaluationProjectId,
|
|
|
// "nodeType": domain.LinkNodeSelfAssessment,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// //获取已填写的评估内容
|
|
|
// _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
// "summaryEvaluationId": evaluationData.Id,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// //记录人资评估或者360评估的 填写项id
|
|
|
// hrbpOr360ItemValue, err := srv.getEvaluationSuperDefaultValue(transactionContext, evaluationData)
|
|
|
// if err != nil {
|
|
|
// return nil, err
|
|
|
// }
|
|
|
|
|
|
err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, hrbpOr360ItemValue, param.IsTemporary)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if !param.IsTemporary {
|
|
|
//变更评估状态为已填写
|
|
|
evaluationData.Status = domain.EvaluationCompleted
|
|
|
//删除旧的填写值,使用新的填写内容
|
|
|
err = itemValueRepo.RemoveBySummaryEvaluationId(evaluationData.Id)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
for _, val := range itemValueList {
|
|
|
val.Id = 0
|
|
|
}
|
|
|
}
|
|
|
//保存填写值
|
|
|
err = evaluationRepo.Save(evaluationData)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
for _, v := range itemValueList {
|
|
|
//保存填写值
|
|
|
err = itemValueRepo.Save(v)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
if !param.IsTemporary {
|
|
|
err = srv.AfterCompletedEvaluationSuper(transactionContext, evaluationData, itemValueList)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
}
|
|
|
// err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, hrbpOr360ItemValue, param.IsTemporary)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// if !param.IsTemporary {
|
|
|
// //变更评估状态为已填写
|
|
|
// evaluationData.Status = domain.EvaluationCompleted
|
|
|
// //删除旧的填写值,使用新的填写内容
|
|
|
// err = itemValueRepo.RemoveBySummaryEvaluationId(evaluationData.Id)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// for _, val := range itemValueList {
|
|
|
// val.Id = 0
|
|
|
// }
|
|
|
// }
|
|
|
// //保存填写值
|
|
|
// err = evaluationRepo.Save(evaluationData)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// for _, v := range itemValueList {
|
|
|
// //保存填写值
|
|
|
// err = itemValueRepo.Save(v)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// }
|
|
|
// if !param.IsTemporary {
|
|
|
// err = srv.AfterCompletedEvaluationSuper(transactionContext, evaluationData, itemValueList)
|
|
|
// if err != nil {
|
|
|
// return nil, err
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
|
|
|
return map[string][]adapter.EvaluationItemAdapter{
|
|
|
"EvaluationItems": itemValueAdapter,
|
|
|
}, nil
|
|
|
}
|
|
|
// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
|
|
|
// return map[string][]adapter.EvaluationItemAdapter{
|
|
|
// "EvaluationItems": itemValueAdapter,
|
|
|
// }, nil
|
|
|
// }
|
|
|
|
|
|
// 员工提交上级评估后
|
|
|
// 生成考核结果
|
...
|
...
|
@@ -283,3 +284,264 @@ func (srv *SummaryEvaluationService) syncEvaluationFinishValue( |
|
|
return nil
|
|
|
|
|
|
}
|
|
|
|
|
|
// EditEvaluationSuper 更新上级评估内容
|
|
|
func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEvaluationValue) (interface{}, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
|
|
|
"id": param.SummaryEvaluationId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if evaluationData.Types != domain.EvaluationSuper {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
}
|
|
|
|
|
|
if evaluationData.Executor.UserId != param.ExecutorId {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
}
|
|
|
|
|
|
if evaluationData.CompanyId != param.CompanyId {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
}
|
|
|
ok := evaluationData.EndTime.Before(time.Now())
|
|
|
if ok {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "评估时间已截止")
|
|
|
}
|
|
|
//按照被评估人id ,加锁
|
|
|
lock := xredis.NewLockSummaryEvaluation(evaluationData.TargetUser.UserId)
|
|
|
err = lock.Lock()
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
}
|
|
|
defer func() {
|
|
|
lock.UnLock()
|
|
|
}()
|
|
|
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"targetUserId": evaluationData.TargetUser.UserId,
|
|
|
"typesList": []int{int(domain.EvaluationFinish)},
|
|
|
"cycleId": evaluationData.CycleId,
|
|
|
"limit": 1,
|
|
|
})
|
|
|
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, "用户已经确认该周期的考核结果,不能再编辑!")
|
|
|
}
|
|
|
|
|
|
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{
|
|
|
"evaluationProjectId": evaluationData.EvaluationProjectId,
|
|
|
"nodeType": domain.LinkNodeSelfAssessment,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
//获取已填写的评估内容
|
|
|
_, itemValueList, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
"summaryEvaluationId": evaluationData.Id,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
//记录人资评估或者360评估的 填写项id
|
|
|
hrbpOr360ItemValue, err := srv.getEvaluationSuperDefaultValue(transactionContext, evaluationData)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
//更新填写值
|
|
|
var evaluationValueSlice []*domain.SummaryEvaluationValue // 提交的填写值
|
|
|
{
|
|
|
evaluationItemMap := map[int]*domain.EvaluationItemUsed{} // 需要填写那些项 Id=>&domain.EvaluationItemUsed{}
|
|
|
evaluationValueMap := map[int]*domain.SummaryEvaluationValue{} // 提交的填写值 EvaluationItemId=>&domain.domain.SummaryEvaluationValue{}
|
|
|
evaluationData.TotalRating = nil // 清空评级数量统计
|
|
|
// 按照需要填写那些项 设置SummaryEvaluationValue的空白值
|
|
|
for _, v := range itemList {
|
|
|
newValue := &domain.SummaryEvaluationValue{}
|
|
|
newValue.SetBlankValue(evaluationData, v)
|
|
|
evaluationValueMap[v.Id] = newValue
|
|
|
evaluationItemMap[v.Id] = v
|
|
|
evaluationValueSlice = append(evaluationValueSlice, newValue)
|
|
|
}
|
|
|
//如果存在旧值
|
|
|
//新值的id 替换为旧值id
|
|
|
for _, v := range itemValueList {
|
|
|
if mValue, ok := evaluationValueMap[v.EvaluationItemId]; ok {
|
|
|
mValue.Id = v.Id
|
|
|
}
|
|
|
}
|
|
|
//填入提交的更新值
|
|
|
for _, v := range param.EvaluationItems {
|
|
|
v.Value = strings.TrimSpace(v.Value)
|
|
|
newItemValue, ok := evaluationValueMap[v.EvaluationItemId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
evaluationItem, ok := evaluationItemMap[v.EvaluationItemId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
if !param.IsTemporary {
|
|
|
//除了综合自评,其他的评估任务 评估项直接全部按必填项处理
|
|
|
if len(v.Value) == 0 {
|
|
|
e := fmt.Sprintf("%s-%s 未填写", evaluationItem.Category, evaluationItem.Name)
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, e)
|
|
|
}
|
|
|
}
|
|
|
//填充评估填写值
|
|
|
newItemValue.Remark = v.Remark
|
|
|
err := evaluationData.FillItemValue(evaluationItem, newItemValue, v.Value)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
// 填入固定的默认值
|
|
|
for _, v := range hrbpOr360ItemValue {
|
|
|
newItemValue, ok := evaluationValueMap[v.EvaluationItemId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
evaluationItem, ok := evaluationItemMap[v.EvaluationItemId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
//填充评估填写值
|
|
|
newItemValue.Remark = v.Remark
|
|
|
err := evaluationData.FillItemValue(evaluationItem, newItemValue, v.Value)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
evaluationData.EvaluationTotalScore(evaluationValueSlice)
|
|
|
}
|
|
|
|
|
|
if !param.IsTemporary {
|
|
|
//变更评估状态为已填写
|
|
|
evaluationData.Status = domain.EvaluationCompleted
|
|
|
//删除旧的填写值,使用新的填写内容
|
|
|
err = itemValueRepo.RemoveBySummaryEvaluationId(evaluationData.Id)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
for _, val := range evaluationValueSlice {
|
|
|
val.Id = 0
|
|
|
}
|
|
|
}
|
|
|
//保存填写值
|
|
|
err = evaluationRepo.Save(evaluationData)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
for _, v := range evaluationValueSlice {
|
|
|
//保存填写值
|
|
|
err = itemValueRepo.Save(v)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
if !param.IsTemporary {
|
|
|
err = srv.AfterCompletedEvaluationSuper(transactionContext, evaluationData, itemValueList)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
|
|
|
return map[string][]adapter.EvaluationItemAdapter{
|
|
|
"EvaluationItems": itemValueAdapter,
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
// getEvaluationSuperDefaultValue
|
|
|
// 按照权限设置,是否获取上级评估内容的默认值
|
|
|
func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionContext application.TransactionContext, evaluationData *domain.SummaryEvaluation) (
|
|
|
[]*domain.SummaryEvaluationValue, error) {
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
permissionData, err := getPermission(int64(evaluationData.CompanyId))
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if permissionData.OptEvalScore == domain.PermissionOn && permissionData.OptHrScore == domain.PermissionOn {
|
|
|
return nil, nil
|
|
|
}
|
|
|
// 获取360评估,人资评估填写的值
|
|
|
_, evaluationListOther, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},
|
|
|
"targetUserId": evaluationData.TargetUser.UserId,
|
|
|
"cycleId": evaluationData.CycleId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
evaluationIds := []int{}
|
|
|
for _, v := range evaluationListOther {
|
|
|
evaluationIds = append(evaluationIds, v.Id)
|
|
|
}
|
|
|
if len(evaluationIds) == 0 {
|
|
|
return nil, nil
|
|
|
}
|
|
|
// 将360评估,人资评估填写的值 作为默认值
|
|
|
_, itemValuesOther, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
"summaryEvaluationIdList": evaluationIds,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
// 记录人资评估或者360评估的 填写项id
|
|
|
hrbpOr360ItemValue := []*domain.SummaryEvaluationValue{}
|
|
|
if permissionData.OptEvalScore == domain.PermissionOff {
|
|
|
//上级是否可以修改360°综评分数
|
|
|
//获取360综合评分
|
|
|
for _, v := range itemValuesOther {
|
|
|
//记录人资评估或者360评估的填写值
|
|
|
if v.Types != domain.Evaluation360 {
|
|
|
continue
|
|
|
}
|
|
|
hrbpOr360ItemValue = append(hrbpOr360ItemValue, v)
|
|
|
}
|
|
|
}
|
|
|
if permissionData.OptHrScore == domain.PermissionOff {
|
|
|
//上级是否可以修改人资综评分数
|
|
|
//获取人资综合评分
|
|
|
for _, v := range itemValuesOther {
|
|
|
//记录人资评估或者360评估的填写值
|
|
|
if v.Types != domain.EvaluationHrbp {
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
hrbpOr360ItemValue = append(hrbpOr360ItemValue, v)
|
|
|
}
|
|
|
}
|
|
|
return hrbpOr360ItemValue, nil
|
|
|
} |
...
|
...
|
|