作者 郑周

1. 增加360综评 - 所有评估人

... ... @@ -39,7 +39,7 @@ type EvaluationItemAdapter struct {
Score string `json:"score"` //计算的评定得分
Remark string `json:"remark"` //填写的内容反馈
EvaluatorId int `json:"evaluatorId"` //评估人id
//
EvaluatorName string `json:"evaluatorName"` //评估人名称
}
// 评级数量
... ...
... ... @@ -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})
... ...
... ... @@ -145,6 +145,22 @@ func (c *SummaryEvaluationController) GetEvaluation360() {
c.Response(data, err)
}
func (c *SummaryEvaluationController) GetEvaluation360All() {
srv := service.NewSummaryEvaluationService()
in := &command.QueryEvaluation360{}
err := c.BindJSON(in)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
in.CompanyId = int(userReq.CompanyId)
in.UserId = int(userReq.UserId)
data, err := srv.GetEvaluation360All(in)
c.Response(data, err)
}
func (c *SummaryEvaluationController) EditEvaluation360() {
srv := service.NewSummaryEvaluationService()
in := &command.EditEvaluationValue{}
... ...
... ... @@ -16,6 +16,7 @@ func init() {
web.NSCtrlPost("/evaluation-self", (*controllers.SummaryEvaluationController).GetEvaluationSelf),
web.NSCtrlPost("/evaluation-self/edit", (*controllers.SummaryEvaluationController).EditEvaluationSelf),
web.NSCtrlPost("/evaluation-360", (*controllers.SummaryEvaluationController).GetEvaluation360),
web.NSCtrlPost("/evaluation-360all", (*controllers.SummaryEvaluationController).GetEvaluation360All),
web.NSCtrlPost("/evaluation-360/edit", (*controllers.SummaryEvaluationController).EditEvaluation360),
web.NSCtrlPost("/evaluation-360/list", (*controllers.SummaryEvaluationController).Evaluation360List),
web.NSCtrlPost("/evaluation-hr", (*controllers.SummaryEvaluationController).GetEvaluationHRBP),
... ...