...
|
...
|
@@ -15,6 +15,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis"
|
|
|
)
|
|
|
|
|
|
type SummaryEvaluationService struct {
|
...
|
...
|
@@ -59,12 +60,12 @@ func (srv *SummaryEvaluationService) GetExecutorCycleList(param *command.QueryCy |
|
|
offset = (param.PageNumber - 1) * param.PageSize
|
|
|
}
|
|
|
|
|
|
cycleData, err := evaluationDao.GetExecutorCycleList(param.UserId, offset, limit, isHrbp)
|
|
|
cycleData, err := evaluationDao.GetExecutorCycleList(param.CompanyId, param.UserId, offset, limit, isHrbp)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取周期列表"+err.Error())
|
|
|
}
|
|
|
|
|
|
cnt, err := evaluationDao.CountExecutorCycleList(param.UserId, domain.EvaluationSelf)
|
|
|
cnt, err := evaluationDao.CountExecutorCycleList(param.CompanyId, param.UserId, isHrbp)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -199,11 +200,12 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri |
|
|
}
|
|
|
|
|
|
//查找当前周期,我的考核结果
|
|
|
_, myEvaluationSuper, _ := evaluationRepo.Find(map[string]interface{}{
|
|
|
"types": int(domain.EvaluationSuper),
|
|
|
_, myEvaluationFinish, _ := evaluationRepo.Find(map[string]interface{}{
|
|
|
"types": int(domain.EvaluationFinish),
|
|
|
"limit": 1,
|
|
|
"targetUserId": param.UserId,
|
|
|
"cycleId": param.CycleId,
|
|
|
"beginTime": time.Now(),
|
|
|
})
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
...
|
...
|
@@ -242,15 +244,13 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri |
|
|
}
|
|
|
menu1.Child = append(menu1.Child, menu1_1)
|
|
|
}
|
|
|
if len(myEvaluationSuper) > 0 {
|
|
|
if myEvaluationSuper[0].CheckResult == domain.EvaluationCheckCompleted {
|
|
|
if len(myEvaluationFinish) > 0 {
|
|
|
if myEvaluationFinish[0].CheckResult == domain.EvaluationCheckCompleted {
|
|
|
menu1_2.StatusName = "已完成"
|
|
|
} else {
|
|
|
menu1_2.StatusName = "未完成"
|
|
|
}
|
|
|
if myEvaluationSuper[0].Status == domain.EvaluationCompleted {
|
|
|
menu1.Child = append(menu1.Child, menu1_2)
|
|
|
}
|
|
|
menu1.Child = append(menu1.Child, menu1_2)
|
|
|
}
|
|
|
|
|
|
if len(selfEvaluation) > 0 {
|
...
|
...
|
@@ -367,6 +367,7 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev |
|
|
item.Value = value.Value
|
|
|
item.Remark = value.Remark
|
|
|
item.Rating = value.Rating
|
|
|
item.EvaluatorName = value.Executor.UserName
|
|
|
}
|
|
|
itemValues = append(itemValues, item)
|
|
|
}
|
...
|
...
|
@@ -462,24 +463,14 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app |
|
|
TotalScore: evaluationData.TotalScore,
|
|
|
}
|
|
|
//获取用户信息
|
|
|
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
companyData, err := companyRepo.FindOne(map[string]interface{}{
|
|
|
"id": evaluationData.CompanyId,
|
|
|
})
|
|
|
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
|
|
companyData, err := companyRepo.FindOne(map[string]interface{}{"id": evaluationData.CompanyId})
|
|
|
if err != nil {
|
|
|
return result
|
|
|
}
|
|
|
|
|
|
userData, err := userRepo.FindOne(map[string]interface{}{
|
|
|
"id": evaluationData.TargetUser.UserId,
|
|
|
})
|
|
|
userData, err := userRepo.FindOne(map[string]interface{}{"id": evaluationData.TargetUser.UserId})
|
|
|
if err != nil {
|
|
|
return result
|
|
|
}
|
...
|
...
|
@@ -487,22 +478,18 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app |
|
|
result.CompanyLogo = companyData.Logo
|
|
|
result.CompanyName = companyData.Name
|
|
|
|
|
|
if userData.ParentId <= 0 {
|
|
|
return result
|
|
|
}
|
|
|
pUserData, err := userRepo.FindOne(map[string]interface{}{
|
|
|
"id": userData.ParentId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return result
|
|
|
if userData.ParentId > 0 {
|
|
|
pUserData, err := userRepo.FindOne(map[string]interface{}{"id": userData.ParentId})
|
|
|
if err != nil {
|
|
|
return result
|
|
|
}
|
|
|
result.SupperUser = pUserData.Name
|
|
|
}
|
|
|
result.SupperUser = pUserData.Name
|
|
|
return result
|
|
|
}
|
|
|
|
|
|
// 编辑综合自评详情
|
|
|
func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) {
|
|
|
// xredis.NewLockSummaryEvaluation(param.SummaryEvaluationId)
|
|
|
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
...
|
...
|
@@ -596,7 +583,17 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu |
|
|
// 员工提交自评内容后,
|
|
|
// 员工作为被评估人,
|
|
|
// 变更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())
|
...
|
...
|
@@ -619,7 +616,18 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain. |
|
|
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评估/人资评估/上级评估的开始时间
|
...
|
...
|
@@ -632,21 +640,52 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain. |
|
|
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 评估
|
|
|
//直接进入考核结果阶段
|
|
|
_, 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 {
|
|
|
// 进入考核结果阶段
|
|
|
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())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// 被评估员工的人资评估 或者 360 评估,
|
|
|
// 提交员工的人资评估 或者 360 评估
|
|
|
// 变更上级评估的开始时间
|
|
|
// 或者生成考核结果
|
|
|
func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(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())
|
...
|
...
|
@@ -684,7 +723,7 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma |
|
|
"targetUserId": param.TargetUser.UserId,
|
|
|
"typesList": []int{int(domain.EvaluationSuper)},
|
|
|
"cycleId": param.CycleId,
|
|
|
"limit": 1000,
|
|
|
"limit": 1,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -705,6 +744,82 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma |
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(evaluationList) == 0 {
|
|
|
//没有上级评估
|
|
|
//直接进入考核结果阶段
|
|
|
_, 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 {
|
|
|
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())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
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())
|
|
|
}
|
|
|
nowTime := time.Now()
|
|
|
if len(evaluationList) > 0 {
|
|
|
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())
|
|
|
}
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -1062,6 +1177,14 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval |
|
|
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,
|
...
|
...
|
@@ -1295,40 +1418,117 @@ func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command. |
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
// 员工确认综评考核结果
|
|
|
func (srv *SummaryEvaluationService) ConfirmScoreSuperEvaluation(param *command.ConfirmScore) error {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
// ConfirmScoreEvaluation 员工确认考核结果
|
|
|
func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.ConfirmScore) error {
|
|
|
transactionContext, err := factory.ValidateStartTransaction(param)
|
|
|
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())
|
|
|
return err
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
|
|
|
"id": param.SummaryEvaluationId,
|
|
|
})
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
|
|
// 考核结果
|
|
|
result, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if evaluationData.Types != domain.EvaluationSuper {
|
|
|
if result.Types != domain.EvaluationFinish {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, "操作方式错误")
|
|
|
}
|
|
|
if evaluationData.TargetUser.UserId != param.UserId {
|
|
|
if result.TargetUser.UserId != param.UserId {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, "没有操作权限")
|
|
|
}
|
|
|
if evaluationData.Status == domain.EvaluationUncompleted {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, "上级还未正式提交评估内容")
|
|
|
if result.CheckResult == domain.EvaluationCheckCompleted {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, "考核结果已确认过了!")
|
|
|
}
|
|
|
evaluationData.CheckResult = domain.EvaluationCheckCompleted
|
|
|
err = evaluationRepo.Save(evaluationData)
|
|
|
if result.Status == domain.EvaluationUncompleted {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, "前面流程暂未完成提交评估内容")
|
|
|
}
|
|
|
|
|
|
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"companyId": result.CompanyId,
|
|
|
"cycleId": result.CycleId,
|
|
|
"targetUserId": result.TargetUser.UserId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return 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
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 评估内容和值
|
|
|
var itemList []*domain.EvaluationItemUsed
|
|
|
var itemValues []*domain.SummaryEvaluationValue
|
|
|
|
|
|
// 获取自评模板内容
|
|
|
_, itemList, err = evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// 按评估项优先级顺序(已确认考核结果 ->上级评估 ->HR或360评估或自评)
|
|
|
if super != nil {
|
|
|
_, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": super.Id}) // 获取已填写的评估内容
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
// 更新填写值
|
|
|
itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, true)
|
|
|
if err != nil {
|
|
|
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)
|
|
|
}
|
|
|
}
|
|
|
if len(evaluationIds) > 0 {
|
|
|
// 获取已填写的评估内容
|
|
|
_, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds})
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// 更新填写值
|
|
|
itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, false)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for i := range itemValues {
|
|
|
if err := itemValueRepo.Save(itemValues[i]); err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
//重置评级汇总
|
|
|
result.TotalRating = nil
|
|
|
for i := range itemList {
|
|
|
result.ResetTotalRating(itemList[i])
|
|
|
}
|
|
|
if err := result.EvaluationTotalScore(itemValues); err != nil {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
result.CheckResult = domain.EvaluationCheckCompleted
|
|
|
if err := evaluationRepo.Save(result); err != nil {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
...
|
...
|
@@ -1337,107 +1537,184 @@ func (srv *SummaryEvaluationService) ConfirmScoreSuperEvaluation(param *command. |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// 按照周期和被评估的人 获取上级评估详情
|
|
|
func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command.QueryEvaluation) (*adapter.EvaluationInfoSuperAdapter, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// 处理优先级
|
|
|
func (srv *SummaryEvaluationService) updateItemValuePriority(
|
|
|
result *domain.SummaryEvaluation,
|
|
|
itemList []*domain.EvaluationItemUsed,
|
|
|
itemValues []*domain.SummaryEvaluationValue,
|
|
|
superior bool) ([]*domain.SummaryEvaluationValue, error) {
|
|
|
|
|
|
tempSelf := map[int]*domain.SummaryEvaluationValue{}
|
|
|
temp360 := map[int]*domain.SummaryEvaluationValue{}
|
|
|
tempHRBP := map[int]*domain.SummaryEvaluationValue{}
|
|
|
tempSuperior := map[int]*domain.SummaryEvaluationValue{}
|
|
|
|
|
|
for i := range itemValues {
|
|
|
it := itemValues[i]
|
|
|
if it.Types == domain.EvaluationSelf {
|
|
|
tempSelf[it.EvaluationItemId] = it
|
|
|
} else if it.Types == domain.Evaluation360 {
|
|
|
temp360[it.EvaluationItemId] = it
|
|
|
} else if it.Types == domain.EvaluationHrbp {
|
|
|
tempHRBP[it.EvaluationItemId] = it
|
|
|
} else if it.Types == domain.EvaluationSuper {
|
|
|
tempSuperior[it.EvaluationItemId] = it
|
|
|
}
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
nowTime := time.Now()
|
|
|
var newItemValues = make([]*domain.SummaryEvaluationValue, 0)
|
|
|
for i := range itemList {
|
|
|
it := itemList[i]
|
|
|
|
|
|
var tempValue domain.SummaryEvaluationValue
|
|
|
tempValue.SetBlankValue(result, it)
|
|
|
|
|
|
if superior /* 上级数据 */ {
|
|
|
if v, ok := tempSuperior[it.Id]; ok {
|
|
|
tempValue = *v
|
|
|
}
|
|
|
tempValue.Types = domain.EvaluationSuper
|
|
|
} else /* 其它数据 */ {
|
|
|
if it.EvaluatorId == 0 {
|
|
|
if v, ok := tempSelf[it.Id]; ok {
|
|
|
tempValue = *v
|
|
|
}
|
|
|
tempValue.Types = domain.EvaluationSelf
|
|
|
} else if it.EvaluatorId == -1 {
|
|
|
if v, ok := tempHRBP[it.Id]; ok {
|
|
|
tempValue = *v
|
|
|
}
|
|
|
tempValue.Types = domain.EvaluationHrbp
|
|
|
} else if it.EvaluatorId > 0 {
|
|
|
if v, ok := temp360[it.Id]; ok {
|
|
|
tempValue = *v
|
|
|
}
|
|
|
tempValue.Types = domain.Evaluation360
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// ID置空
|
|
|
tempValue.Id = 0
|
|
|
tempValue.CreatedAt = nowTime
|
|
|
tempValue.UpdatedAt = nowTime
|
|
|
newItemValues = append(newItemValues, &tempValue)
|
|
|
}
|
|
|
return newItemValues, nil
|
|
|
}
|
|
|
|
|
|
// GetTargetEvaluationResult 按照周期和被评估的人 获取考核结果
|
|
|
func (srv *SummaryEvaluationService) GetTargetEvaluationResult(param *command.QueryEvaluation) (*adapter.EvaluationInfoSuperAdapter, error) {
|
|
|
transactionContext, err := factory.ValidateStartTransaction(param)
|
|
|
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,
|
|
|
})
|
|
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
// 获取权限配置
|
|
|
_, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": param.CompanyId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
|
|
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"limit": 1,
|
|
|
"companyId": param.CompanyId,
|
|
|
"cycleId": param.CycleId,
|
|
|
"targetUserId": param.TargetUserId,
|
|
|
"types": domain.EvaluationSuper,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(evaluationList) == 0 {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有找到符合条件的数据")
|
|
|
}
|
|
|
evaluationData := evaluationList[0]
|
|
|
if evaluationData.CompanyId != param.CompanyId {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
|
|
|
|
|
|
var result *domain.SummaryEvaluation // 绩效考核结果项
|
|
|
var super *domain.SummaryEvaluation // 上级评估
|
|
|
for i := range evaluationList {
|
|
|
it := evaluationList[i]
|
|
|
if it.Types == domain.EvaluationFinish {
|
|
|
result = it
|
|
|
continue
|
|
|
}
|
|
|
if it.Types == domain.EvaluationSuper {
|
|
|
super = it
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
|
|
"evaluationProjectId": evaluationData.EvaluationProjectId,
|
|
|
"nodeType": int(domain.LinkNodeSelfAssessment),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
if result == nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有找到符合条件的数据")
|
|
|
}
|
|
|
//获取已填写的评估内容
|
|
|
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
"summaryEvaluationId": evaluationData.Id,
|
|
|
})
|
|
|
|
|
|
// 评估内容和值
|
|
|
var itemList []*domain.EvaluationItemUsed
|
|
|
var itemValues []*domain.SummaryEvaluationValue
|
|
|
|
|
|
// 获取自评模板内容
|
|
|
_, 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())
|
|
|
}
|
|
|
if len(itemValues) == 0 {
|
|
|
//上级还未填写评估,获取 360 ,人资评估
|
|
|
_, evaluationListOther, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},
|
|
|
"targetUserId": evaluationData.TargetUser.UserId,
|
|
|
"cycleId": evaluationData.CycleId,
|
|
|
})
|
|
|
|
|
|
// 按评估项优先级顺序(已确认考核结果 ->上级评估 ->HR或360评估或自评)
|
|
|
if result.CheckResult == domain.EvaluationCheckCompleted { /* 已完成考核*/
|
|
|
_, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": result.Id}) // 获取已填写的评估内容
|
|
|
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 {
|
|
|
_, itemValues, err = itemValueRepo.Find(map[string]interface{}{
|
|
|
"summaryEvaluationIdList": evaluationIds,
|
|
|
})
|
|
|
} else {
|
|
|
if super != nil {
|
|
|
_, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": super.Id}) // 获取已填写的评估内容
|
|
|
if err != nil {
|
|
|
return nil, 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)
|
|
|
}
|
|
|
}
|
|
|
if len(evaluationIds) > 0 {
|
|
|
// 获取已填写的评估内容
|
|
|
_, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// 更新填写值
|
|
|
itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, false)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationData)
|
|
|
// 未完成考核,需要重新计算分数
|
|
|
if result.CheckResult == domain.EvaluationCheckUncompleted {
|
|
|
result.TotalRating = nil
|
|
|
for i := range itemList {
|
|
|
result.ResetTotalRating(itemList[i])
|
|
|
}
|
|
|
if err = result.EvaluationTotalScore(itemValues); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 基础数据
|
|
|
evaluationBase := srv.getSummaryEvaluation(transactionContext, result)
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
//组合 评估填写的值和评估项
|
|
|
|
|
|
// 组合 评估填写的值和评估项
|
|
|
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
|
|
|
codeList := []*adapter.LevalCodeCount{}
|
|
|
|
|
|
codeMap := map[string]*adapter.LevalCodeCount{}
|
|
|
for i, v := range itemValuesAdapter {
|
|
|
if len(permissionList) > 0 {
|
|
|
if permissionList[0].OptEvalScore == domain.PermissionOff &&
|
|
|
v.EvaluatorId > 0 {
|
|
|
itemValuesAdapter[i].ForbidEdit = true
|
|
|
}
|
|
|
if permissionList[0].OptHrScore == domain.PermissionOff &&
|
|
|
v.EvaluatorId < 0 {
|
|
|
itemValuesAdapter[i].ForbidEdit = true
|
|
|
}
|
|
|
}
|
|
|
if v.Weight == 0 {
|
|
|
for _, v := range itemValuesAdapter {
|
|
|
//处理加分项评级汇总
|
|
|
if v.Weight == 0 && len(v.Value) > 0 {
|
|
|
if _, ok := codeMap[v.Value]; !ok {
|
|
|
code := &adapter.LevalCodeCount{
|
|
|
Code: v.Value,
|
...
|
...
|
@@ -1445,23 +1722,33 @@ func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command |
|
|
ItemList: []string{},
|
|
|
}
|
|
|
codeMap[v.Value] = code
|
|
|
codeList = append(codeList, code)
|
|
|
}
|
|
|
codeMap[v.Value].ItemList = append(codeMap[v.Value].ItemList, v.Name)
|
|
|
codeMap[v.Value].Number += 1
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result := adapter.EvaluationInfoSuperAdapter{
|
|
|
codeList := make([]*adapter.LevalCodeCount, 0)
|
|
|
for _, val := range result.TotalRating {
|
|
|
if codeItem, ok := codeMap[val.Code]; ok {
|
|
|
codeList = append(codeList, codeItem)
|
|
|
} else {
|
|
|
codeList = append(codeList, &adapter.LevalCodeCount{
|
|
|
Code: val.Code,
|
|
|
Number: 0,
|
|
|
ItemList: []string{},
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
eiAdapter := adapter.EvaluationInfoSuperAdapter{
|
|
|
EvaluationBaseAdapter: evaluationBase,
|
|
|
LevelCount: codeList,
|
|
|
EvaluationItems: itemValuesAdapter,
|
|
|
}
|
|
|
return &result, nil
|
|
|
return &eiAdapter, nil
|
|
|
}
|
|
|
|
|
|
// 获取周期综合评估下,周期评估列表
|
|
|
func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.QueryEvaluationList) (map[string]interface{}, error) {
|
|
|
// 按周期获取所有员工的评估考核结果
|
|
|
func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.QueryEvaluationList) (map[string]interface{}, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -1489,7 +1776,7 @@ func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.Query |
|
|
"parentId": param.UserId,
|
|
|
"limit": 1,
|
|
|
})
|
|
|
if len(parentUser) == 0 {
|
|
|
if len(parentUser) == 0 && flagHrbp != 1 {
|
|
|
return tool_funs.SimpleWrapGridMap(0, []string{}), nil
|
|
|
}
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
...
|
...
|
@@ -1505,7 +1792,7 @@ func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.Query |
|
|
//获取评估列表信息
|
|
|
condition1 := map[string]interface{}{
|
|
|
"cycleId": param.CycleId,
|
|
|
"types": int(domain.EvaluationSuper),
|
|
|
"types": int(domain.EvaluationFinish),
|
|
|
"limit": limit,
|
|
|
"beginTime": time.Now(),
|
|
|
}
|
...
|
...
|
@@ -1606,12 +1893,14 @@ func (srv *SummaryEvaluationService) editEvaluationValue( |
|
|
}
|
|
|
evaluationItemMap := map[int]*domain.EvaluationItemUsed{}
|
|
|
evaluationValueMap := map[int]*domain.SummaryEvaluationValue{}
|
|
|
evaluationValueSlice := []*domain.SummaryEvaluationValue{}
|
|
|
evaluationData.TotalRating = nil //清空评级数量统计
|
|
|
for _, v := range evaluationItems {
|
|
|
newValue := &domain.SummaryEvaluationValue{}
|
|
|
newValue.SetBlankValue(evaluationData, v)
|
|
|
evaluationValueMap[v.Id] = newValue
|
|
|
evaluationItemMap[v.Id] = v
|
|
|
evaluationValueSlice = append(evaluationValueSlice, newValue)
|
|
|
//重置计数
|
|
|
evaluationData.ResetTotalRating(v)
|
|
|
}
|
...
|
...
|
@@ -1669,10 +1958,14 @@ func (srv *SummaryEvaluationService) editEvaluationValue( |
|
|
}
|
|
|
}
|
|
|
//完全更新itemValueList
|
|
|
*itemValueList = (*itemValueList)[0:0]
|
|
|
for _, v := range evaluationValueMap {
|
|
|
*itemValueList = append(*itemValueList, v)
|
|
|
}
|
|
|
*itemValueList = evaluationValueSlice
|
|
|
// *itemValueList = (*itemValueList)[0:0]
|
|
|
// for _, v := range evaluationValueMap {
|
|
|
// *itemValueList = append(*itemValueList, v)
|
|
|
// }
|
|
|
// sort.Slice(*itemValueList, func(i, j int) bool {
|
|
|
// return (*itemValueList)[i].EvaluationItemId < (*itemValueList)[j].EvaluationItemId
|
|
|
// })
|
|
|
// 计算总得分
|
|
|
err := evaluationData.EvaluationTotalScore(*itemValueList)
|
|
|
if err != nil {
|
...
|
...
|
@@ -1685,7 +1978,7 @@ func (srv *SummaryEvaluationService) editEvaluationValue( |
|
|
func (srv *SummaryEvaluationService) ListExecutorNowEvaluationSelf(param *command.QueryExecutorEvaluationList) (map[string]interface{}, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
return nil, err
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
|