...
|
...
|
@@ -172,7 +172,7 @@ func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvalu |
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
// GetEvaluation360 获取360综评详情
|
|
|
// GetEvaluation360 获取360综评详情(登录人作为评估人,评估内容)
|
|
|
func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) {
|
|
|
transactionContext, err := factory.ValidateStartTransaction(param)
|
|
|
if err != nil {
|
...
|
...
|
@@ -205,7 +205,7 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua |
|
|
}
|
|
|
sEvaluation := evaluations[0]
|
|
|
|
|
|
// 自评评估内容(自评模板、筛选项目评估人)
|
|
|
// 360评估内容(自评模板、筛选项目评估人)
|
|
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
|
|
"evaluationProjectId": sEvaluation.EvaluationProjectId,
|
|
|
"nodeType": domain.LinkNodeSelfAssessment,
|
...
|
...
|
@@ -243,6 +243,98 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua |
|
|
return &result, nil
|
|
|
}
|
|
|
|
|
|
// GetEvaluation360All 获取360综评详情-上级综评(所有的评估人,评估内容)
|
|
|
func (srv *SummaryEvaluationService) GetEvaluation360All(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) {
|
|
|
transactionContext, err := factory.ValidateStartTransaction(param)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
_, evaluations, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"limit": 1,
|
|
|
"companyId": param.CompanyId,
|
|
|
"cycleId": param.CycleId,
|
|
|
"targetUserId": param.TargetUserId,
|
|
|
"types": domain.Evaluation360},
|
|
|
)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(evaluations) == 0 {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
|
|
|
}
|
|
|
sEvaluation := evaluations[0]
|
|
|
|
|
|
// 360评估内容(自评模板)
|
|
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
|
|
"evaluationProjectId": sEvaluation.EvaluationProjectId,
|
|
|
"nodeType": domain.LinkNodeSelfAssessment,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// 评估内容对应的分数
|
|
|
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": sEvaluation.Id})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// 评估人ID -> User
|
|
|
evaluatorMap := map[int]*domain.User{}
|
|
|
evaluatorIds := make([]int, 0)
|
|
|
filterItemList := make([]*domain.EvaluationItemUsed, 0) // 筛选有评估人的评估内容
|
|
|
for i := range itemList {
|
|
|
if itemList[i].EvaluatorId > 0 {
|
|
|
filterItemList = append(filterItemList, itemList[i])
|
|
|
evaluatorIds = append(evaluatorIds, itemList[i].EvaluatorId)
|
|
|
}
|
|
|
}
|
|
|
if len(evaluatorIds) > 0 {
|
|
|
_, users, err := userRepo.Find(map[string]interface{}{"ids": evaluatorIds})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
for i := range users {
|
|
|
evaluatorMap[int(users[i].Id)] = users[i]
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
itemValuesAdapter := srv.buildSummaryItemValue(filterItemList, itemValues)
|
|
|
for i := range itemValuesAdapter { // 评估人名称赋值
|
|
|
if user, ok := evaluatorMap[itemValuesAdapter[i].EvaluatorId]; ok {
|
|
|
itemValuesAdapter[i].EvaluatorName = user.Name
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result := adapter.EvaluationInfoAdapter{
|
|
|
SummaryEvaluationId: sEvaluation.Id,
|
|
|
CycleId: int(sEvaluation.CycleId),
|
|
|
CycleName: sEvaluation.CycleName,
|
|
|
EvaluationProjectId: sEvaluation.EvaluationProjectId,
|
|
|
EvaluationProjectName: sEvaluation.EvaluationProjectName,
|
|
|
LinkNodeId: sEvaluation.NodeId,
|
|
|
BeginTime: sEvaluation.BeginTime.Format("2006-01-02 15:04:05"),
|
|
|
EndTime: sEvaluation.EndTime.Format("2006-01-02 15:04:05"),
|
|
|
TargetUserId: sEvaluation.TargetUser.UserId,
|
|
|
TargetUserName: sEvaluation.TargetUser.UserName,
|
|
|
Status: string(sEvaluation.Status),
|
|
|
EvaluationItems: itemValuesAdapter,
|
|
|
}
|
|
|
return &result, nil
|
|
|
}
|
|
|
|
|
|
// EditEvaluation360 编辑提交360综评
|
|
|
func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
...
|
...
|
@@ -352,6 +444,12 @@ func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEval |
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
// 必须是HRBP权限的人才能编辑操作
|
|
|
hrbp, err := service.GetHRBP(transactionContext, param.CompanyId, param.UserId)
|
|
|
if hrbp != 1 {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
}
|
|
|
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
staffAssessDaoRepo := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
...
|
...
|
|