...
|
...
|
@@ -786,68 +786,70 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// 员工提交上级评估后
|
|
|
// 生成考核结果
|
|
|
func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain.SummaryEvaluation) error {
|
|
|
lock := xredis.NewLockSummaryEvaluation(param.TargetUser.UserId)
|
|
|
err := lock.Lock()
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
}
|
|
|
defer func() {
|
|
|
lock.UnLock()
|
|
|
}()
|
|
|
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()
|
|
|
}()
|
|
|
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
//没有上级评估
|
|
|
//直接进入考核结果阶段
|
|
|
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"targetUserId": param.TargetUser.UserId,
|
|
|
"typesList": []int{int(domain.EvaluationFinish)},
|
|
|
"cycleId": param.CycleId,
|
|
|
"limit": 1,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if len(evaluationList) > 0 {
|
|
|
//上级评估的结束时间
|
|
|
// evaluationList[0].BeginTime = param.EndTime
|
|
|
nowTime := time.Now()
|
|
|
if evaluationList[0].BeginTime.After(nowTime) {
|
|
|
evaluationList[0].BeginTime = nowTime
|
|
|
}
|
|
|
evaluationList[0].Status = domain.EvaluationCompleted
|
|
|
err = evaluationRepo.Save(evaluationList[0])
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
|
|
|
}
|
|
|
//添加确认绩效成绩提醒短信提醒
|
|
|
err = notify.AddNotifyConfirmEvaluationScore(evaluationList[0])
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, "创建短信提醒失败"+err.Error())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
}
|
|
|
// // 员工提交上级评估后
|
|
|
// // 生成考核结果
|
|
|
// func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain.SummaryEvaluation) error {
|
|
|
// lock := xredis.NewLockSummaryEvaluation(param.TargetUser.UserId)
|
|
|
// err := lock.Lock()
|
|
|
// if err != nil {
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
// }
|
|
|
// defer func() {
|
|
|
// lock.UnLock()
|
|
|
// }()
|
|
|
// 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()
|
|
|
// }()
|
|
|
|
|
|
// evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// })
|
|
|
// //没有上级评估
|
|
|
// //直接进入考核结果阶段
|
|
|
// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
// "targetUserId": param.TargetUser.UserId,
|
|
|
// "typesList": []int{int(domain.EvaluationFinish)},
|
|
|
// "cycleId": param.CycleId,
|
|
|
// "limit": 1,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
|
|
|
// if len(evaluationList) > 0 {
|
|
|
// //上级评估的结束时间
|
|
|
// // evaluationList[0].BeginTime = param.EndTime
|
|
|
// nowTime := time.Now()
|
|
|
// if evaluationList[0].BeginTime.After(nowTime) {
|
|
|
// evaluationList[0].BeginTime = nowTime
|
|
|
// }
|
|
|
// evaluationList[0].Status = domain.EvaluationCompleted
|
|
|
// err = evaluationRepo.Save(evaluationList[0])
|
|
|
// if err != nil {
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
|
|
|
// }
|
|
|
// //TODO 更新考核成绩
|
|
|
|
|
|
// //添加确认绩效成绩提醒短信提醒
|
|
|
// err = notify.AddNotifyConfirmEvaluationScore(evaluationList[0])
|
|
|
// if err != nil {
|
|
|
// return application.ThrowError(application.TRANSACTION_ERROR, "创建短信提醒失败"+err.Error())
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
|
|
|
// return nil
|
|
|
// }
|
|
|
|
|
|
// GetTargetUserCycleList
|
|
|
// 获取周期列表,被评估的周期列表
|
...
|
...
|
@@ -1195,124 +1197,124 @@ func (srv *SummaryEvaluationService) GetEvaluationSuperForAdmin(param *command.Q |
|
|
return &result, nil
|
|
|
}
|
|
|
|
|
|
// EditEvaluationSuper 更新上级评估内容
|
|
|
func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEvaluationValue) (interface{}, error) {
|
|
|
lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)
|
|
|
err := lock.Lock()
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
}
|
|
|
defer func() {
|
|
|
lock.UnLock()
|
|
|
}()
|
|
|
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, "没有操作权限")
|
|
|
}
|
|
|
|
|
|
_, 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
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
for _, v := range itemValueList {
|
|
|
//保存填写值
|
|
|
err = itemValueRepo.Save(v)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
//保存填写值
|
|
|
err = evaluationRepo.Save(evaluationData)
|
|
|
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())
|
|
|
}
|
|
|
|
|
|
if !param.IsTemporary {
|
|
|
err = srv.AfterCompletedEvaluationSuper(evaluationData)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
}
|
|
|
|
|
|
itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
|
|
|
return map[string][]adapter.EvaluationItemAdapter{
|
|
|
"EvaluationItems": itemValueAdapter,
|
|
|
}, nil
|
|
|
}
|
|
|
// // EditEvaluationSuper 更新上级评估内容
|
|
|
// func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEvaluationValue) (interface{}, error) {
|
|
|
// lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)
|
|
|
// err := lock.Lock()
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
// }
|
|
|
// defer func() {
|
|
|
// lock.UnLock()
|
|
|
// }()
|
|
|
// 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, "没有操作权限")
|
|
|
// }
|
|
|
|
|
|
// _, 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
|
|
|
// }
|
|
|
|
|
|
// 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
|
|
|
// }
|
|
|
// for _, v := range itemValueList {
|
|
|
// //保存填写值
|
|
|
// err = itemValueRepo.Save(v)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// }
|
|
|
// //保存填写值
|
|
|
// err = evaluationRepo.Save(evaluationData)
|
|
|
// 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())
|
|
|
// }
|
|
|
|
|
|
// if !param.IsTemporary {
|
|
|
// err = srv.AfterCompletedEvaluationSuper(evaluationData)
|
|
|
// if err != nil {
|
|
|
// return nil, err
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
|
|
|
// return map[string][]adapter.EvaluationItemAdapter{
|
|
|
// "EvaluationItems": itemValueAdapter,
|
|
|
// }, nil
|
|
|
// }
|
|
|
|
|
|
// EditEvaluationSuperForAdmin 更新上级评估内容(超级管理员)
|
|
|
func (srv *SummaryEvaluationService) EditEvaluationSuperForAdmin(param *command.EditEvaluationValue) (interface{}, error) {
|
...
|
...
|
@@ -1400,10 +1402,10 @@ func (srv *SummaryEvaluationService) EditEvaluationSuperForAdmin(param *command. |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
err = srv.AfterCompletedEvaluationSuper(evaluationData)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
// err = srv.AfterCompletedEvaluationSuper(evaluationData)
|
|
|
// if err != nil {
|
|
|
// return nil, err
|
|
|
// }
|
|
|
|
|
|
itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
|
|
|
return map[string][]adapter.EvaluationItemAdapter{"EvaluationItems": itemValueAdapter}, nil
|
...
|
...
|
|