...
|
...
|
@@ -483,203 +483,203 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app |
|
|
}
|
|
|
|
|
|
// 编辑综合自评详情
|
|
|
func (srv *SummaryEvaluationService) EditEvaluationSelf(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()
|
|
|
}()
|
|
|
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) EditEvaluationSelf(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()
|
|
|
// }()
|
|
|
// 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.EvaluationSelf {
|
|
|
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.EvaluationSelf {
|
|
|
// 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, "没有操作权限")
|
|
|
}
|
|
|
// if evaluationData.CompanyId != param.CompanyId {
|
|
|
// 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())
|
|
|
}
|
|
|
// _, 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,
|
|
|
})
|
|
|
// _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
// "summaryEvaluationId": evaluationData.Id,
|
|
|
// })
|
|
|
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
|
|
|
err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, nil, param.IsTemporary)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
// err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, nil, param.IsTemporary)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.BUSINESS_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 {
|
|
|
evaluationData.Status = domain.EvaluationCompleted
|
|
|
}
|
|
|
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.AfterCompletedEvaluationSelf(evaluationData)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
}
|
|
|
// //保存填写值
|
|
|
// for _, v := range itemValueList {
|
|
|
// err = itemValueRepo.Save(v)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// }
|
|
|
// if !param.IsTemporary {
|
|
|
// evaluationData.Status = domain.EvaluationCompleted
|
|
|
// }
|
|
|
// 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.AfterCompletedEvaluationSelf(evaluationData)
|
|
|
// if err != nil {
|
|
|
// return nil, err
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
|
|
|
return map[string][]adapter.EvaluationItemAdapter{
|
|
|
"EvaluationItems": itemValueAdapter,
|
|
|
}, nil
|
|
|
}
|
|
|
// itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
|
|
|
// return map[string][]adapter.EvaluationItemAdapter{
|
|
|
// "EvaluationItems": itemValueAdapter,
|
|
|
// }, nil
|
|
|
// }
|
|
|
|
|
|
// 员工提交自评内容后,
|
|
|
// 员工作为被评估人,
|
|
|
// 变更360评估/人资评估/的开始时间
|
|
|
// 或者变更上级评估的开始时间
|
|
|
// 或者生成考核结果
|
|
|
func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(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.Evaluation360), int(domain.EvaluationHrbp)},
|
|
|
"cycleId": param.CycleId,
|
|
|
"limit": 1000,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(evaluationList) == 0 {
|
|
|
//如果没有360评估和hrbp 评估,查找上级评估
|
|
|
_, evaluationList, err = evaluationRepo.Find(map[string]interface{}{
|
|
|
"targetUserId": param.TargetUser.UserId,
|
|
|
"typesList": []int{int(domain.EvaluationSuper)},
|
|
|
"cycleId": param.CycleId,
|
|
|
"limit": 10,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
nowTime := time.Now()
|
|
|
updatedId := []int{}
|
|
|
// 变更360评估/人资评估/上级评估的开始时间
|
|
|
for _, v := range evaluationList {
|
|
|
if v.BeginTime.After(nowTime) {
|
|
|
v.BeginTime = nowTime
|
|
|
updatedId = append(updatedId, v.Id)
|
|
|
}
|
|
|
}
|
|
|
evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
err = evaluationDao.UpdateBeginTime(updatedId, nowTime)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(evaluationList) == 0 {
|
|
|
//没有上级评估、360评估、hrbp 评估
|
|
|
//直接进入考核结果阶段
|
|
|
_, evaluationFinishList, 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(evaluationFinishList) > 0 {
|
|
|
//进入考核结果
|
|
|
//自评的结束时间
|
|
|
if evaluationFinishList[0].BeginTime.After(nowTime) {
|
|
|
evaluationFinishList[0].BeginTime = nowTime
|
|
|
}
|
|
|
evaluationFinishList[0].Status = domain.EvaluationCompleted
|
|
|
err = evaluationRepo.Save(evaluationFinishList[0])
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
|
|
|
}
|
|
|
//添加确认绩效成绩提醒短信提醒
|
|
|
err = notify.AddNotifyConfirmEvaluationScore(evaluationFinishList[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
|
|
|
}
|
|
|
// // 员工提交自评内容后,
|
|
|
// // 员工作为被评估人,
|
|
|
// // 变更360评估/人资评估/的开始时间
|
|
|
// // 或者变更上级评估的开始时间
|
|
|
// // 或者生成考核结果
|
|
|
// func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(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.Evaluation360), int(domain.EvaluationHrbp)},
|
|
|
// "cycleId": param.CycleId,
|
|
|
// "limit": 1000,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// if len(evaluationList) == 0 {
|
|
|
// //如果没有360评估和hrbp 评估,查找上级评估
|
|
|
// _, evaluationList, err = evaluationRepo.Find(map[string]interface{}{
|
|
|
// "targetUserId": param.TargetUser.UserId,
|
|
|
// "typesList": []int{int(domain.EvaluationSuper)},
|
|
|
// "cycleId": param.CycleId,
|
|
|
// "limit": 10,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// }
|
|
|
// nowTime := time.Now()
|
|
|
// updatedId := []int{}
|
|
|
// // 变更360评估/人资评估/上级评估的开始时间
|
|
|
// for _, v := range evaluationList {
|
|
|
// if v.BeginTime.After(nowTime) {
|
|
|
// v.BeginTime = nowTime
|
|
|
// updatedId = append(updatedId, v.Id)
|
|
|
// }
|
|
|
// }
|
|
|
// evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// })
|
|
|
// err = evaluationDao.UpdateBeginTime(updatedId, nowTime)
|
|
|
// if err != nil {
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// if len(evaluationList) == 0 {
|
|
|
// //没有上级评估、360评估、hrbp 评估
|
|
|
// //直接进入考核结果阶段
|
|
|
// _, evaluationFinishList, 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(evaluationFinishList) > 0 {
|
|
|
// //进入考核结果
|
|
|
// //自评的结束时间
|
|
|
// if evaluationFinishList[0].BeginTime.After(nowTime) {
|
|
|
// evaluationFinishList[0].BeginTime = nowTime
|
|
|
// }
|
|
|
// evaluationFinishList[0].Status = domain.EvaluationCompleted
|
|
|
// err = evaluationRepo.Save(evaluationFinishList[0])
|
|
|
// if err != nil {
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
|
|
|
// }
|
|
|
// //添加确认绩效成绩提醒短信提醒
|
|
|
// err = notify.AddNotifyConfirmEvaluationScore(evaluationFinishList[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
|
|
|
// }
|
|
|
|
|
|
// 提交员工的人资评估 或者 360 评估
|
|
|
// 变更上级评估的开始时间
|
...
|
...
|
@@ -2152,14 +2152,6 @@ func (srv *SummaryEvaluationService) editEvaluationValueUnlimited( |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 等待产品确认
|
|
|
// if evaluationData.Types == domain.EvaluationSelf {
|
|
|
// // 填充评估填写值
|
|
|
// err := newItemValue.EvaluationSelfFillValue(evaluationItem, v.Value, v.Remark)
|
|
|
// if err != nil {
|
|
|
// return err
|
|
|
// }
|
|
|
// } else {
|
|
|
//填充评估填写值
|
|
|
err := newItemValue.FillValue(evaluationItem, v.Value, v.Remark)
|
|
|
if err != nil {
|
...
|
...
|
|