作者 郑周

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

@@ -39,7 +39,7 @@ type EvaluationItemAdapter struct { @@ -39,7 +39,7 @@ type EvaluationItemAdapter struct {
39 Score string `json:"score"` //计算的评定得分 39 Score string `json:"score"` //计算的评定得分
40 Remark string `json:"remark"` //填写的内容反馈 40 Remark string `json:"remark"` //填写的内容反馈
41 EvaluatorId int `json:"evaluatorId"` //评估人id 41 EvaluatorId int `json:"evaluatorId"` //评估人id
42 - // 42 + EvaluatorName string `json:"evaluatorName"` //评估人名称
43 } 43 }
44 44
45 // 评级数量 45 // 评级数量
@@ -172,7 +172,7 @@ func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvalu @@ -172,7 +172,7 @@ func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvalu
172 return result, nil 172 return result, nil
173 } 173 }
174 174
175 -// GetEvaluation360 获取360综评详情 175 +// GetEvaluation360 获取360综评详情(登录人作为评估人,评估内容)
176 func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) { 176 func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) {
177 transactionContext, err := factory.ValidateStartTransaction(param) 177 transactionContext, err := factory.ValidateStartTransaction(param)
178 if err != nil { 178 if err != nil {
@@ -205,7 +205,7 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua @@ -205,7 +205,7 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua
205 } 205 }
206 sEvaluation := evaluations[0] 206 sEvaluation := evaluations[0]
207 207
208 - // 自评评估内容(自评模板、筛选项目评估人) 208 + // 360评估内容(自评模板、筛选项目评估人)
209 _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{ 209 _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
210 "evaluationProjectId": sEvaluation.EvaluationProjectId, 210 "evaluationProjectId": sEvaluation.EvaluationProjectId,
211 "nodeType": domain.LinkNodeSelfAssessment, 211 "nodeType": domain.LinkNodeSelfAssessment,
@@ -243,6 +243,98 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua @@ -243,6 +243,98 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua
243 return &result, nil 243 return &result, nil
244 } 244 }
245 245
  246 +// GetEvaluation360All 获取360综评详情-上级综评(所有的评估人,评估内容)
  247 +func (srv *SummaryEvaluationService) GetEvaluation360All(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) {
  248 + transactionContext, err := factory.ValidateStartTransaction(param)
  249 + if err != nil {
  250 + return nil, err
  251 + }
  252 + defer func() {
  253 + _ = transactionContext.RollbackTransaction()
  254 + }()
  255 +
  256 + userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
  257 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
  258 + evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
  259 + itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
  260 + _, evaluations, err := evaluationRepo.Find(map[string]interface{}{
  261 + "limit": 1,
  262 + "companyId": param.CompanyId,
  263 + "cycleId": param.CycleId,
  264 + "targetUserId": param.TargetUserId,
  265 + "types": domain.Evaluation360},
  266 + )
  267 + if err != nil {
  268 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  269 + }
  270 + if len(evaluations) == 0 {
  271 + return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
  272 + }
  273 + sEvaluation := evaluations[0]
  274 +
  275 + // 360评估内容(自评模板)
  276 + _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
  277 + "evaluationProjectId": sEvaluation.EvaluationProjectId,
  278 + "nodeType": domain.LinkNodeSelfAssessment,
  279 + })
  280 + if err != nil {
  281 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  282 + }
  283 +
  284 + // 评估内容对应的分数
  285 + _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": sEvaluation.Id})
  286 + if err != nil {
  287 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  288 + }
  289 +
  290 + // 评估人ID -> User
  291 + evaluatorMap := map[int]*domain.User{}
  292 + evaluatorIds := make([]int, 0)
  293 + filterItemList := make([]*domain.EvaluationItemUsed, 0) // 筛选有评估人的评估内容
  294 + for i := range itemList {
  295 + if itemList[i].EvaluatorId > 0 {
  296 + filterItemList = append(filterItemList, itemList[i])
  297 + evaluatorIds = append(evaluatorIds, itemList[i].EvaluatorId)
  298 + }
  299 + }
  300 + if len(evaluatorIds) > 0 {
  301 + _, users, err := userRepo.Find(map[string]interface{}{"ids": evaluatorIds})
  302 + if err != nil {
  303 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  304 + }
  305 + for i := range users {
  306 + evaluatorMap[int(users[i].Id)] = users[i]
  307 + }
  308 + }
  309 +
  310 + if err := transactionContext.CommitTransaction(); err != nil {
  311 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  312 + }
  313 +
  314 + itemValuesAdapter := srv.buildSummaryItemValue(filterItemList, itemValues)
  315 + for i := range itemValuesAdapter { // 评估人名称赋值
  316 + if user, ok := evaluatorMap[itemValuesAdapter[i].EvaluatorId]; ok {
  317 + itemValuesAdapter[i].EvaluatorName = user.Name
  318 + }
  319 + }
  320 +
  321 + result := adapter.EvaluationInfoAdapter{
  322 + SummaryEvaluationId: sEvaluation.Id,
  323 + CycleId: int(sEvaluation.CycleId),
  324 + CycleName: sEvaluation.CycleName,
  325 + EvaluationProjectId: sEvaluation.EvaluationProjectId,
  326 + EvaluationProjectName: sEvaluation.EvaluationProjectName,
  327 + LinkNodeId: sEvaluation.NodeId,
  328 + BeginTime: sEvaluation.BeginTime.Format("2006-01-02 15:04:05"),
  329 + EndTime: sEvaluation.EndTime.Format("2006-01-02 15:04:05"),
  330 + TargetUserId: sEvaluation.TargetUser.UserId,
  331 + TargetUserName: sEvaluation.TargetUser.UserName,
  332 + Status: string(sEvaluation.Status),
  333 + EvaluationItems: itemValuesAdapter,
  334 + }
  335 + return &result, nil
  336 +}
  337 +
246 // EditEvaluation360 编辑提交360综评 338 // EditEvaluation360 编辑提交360综评
247 func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) { 339 func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) {
248 transactionContext, err := factory.CreateTransactionContext(nil) 340 transactionContext, err := factory.CreateTransactionContext(nil)
@@ -352,6 +444,12 @@ func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEval @@ -352,6 +444,12 @@ func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEval
352 _ = transactionContext.RollbackTransaction() 444 _ = transactionContext.RollbackTransaction()
353 }() 445 }()
354 446
  447 + // 必须是HRBP权限的人才能编辑操作
  448 + hrbp, err := service.GetHRBP(transactionContext, param.CompanyId, param.UserId)
  449 + if hrbp != 1 {
  450 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
  451 + }
  452 +
355 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) 453 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
356 staffAssessDaoRepo := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext}) 454 staffAssessDaoRepo := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
357 userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) 455 userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
@@ -145,6 +145,22 @@ func (c *SummaryEvaluationController) GetEvaluation360() { @@ -145,6 +145,22 @@ func (c *SummaryEvaluationController) GetEvaluation360() {
145 c.Response(data, err) 145 c.Response(data, err)
146 } 146 }
147 147
  148 +func (c *SummaryEvaluationController) GetEvaluation360All() {
  149 + srv := service.NewSummaryEvaluationService()
  150 + in := &command.QueryEvaluation360{}
  151 + err := c.BindJSON(in)
  152 + if err != nil {
  153 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  154 + c.Response(nil, e)
  155 + return
  156 + }
  157 + userReq := middlewares.GetUser(c.Ctx)
  158 + in.CompanyId = int(userReq.CompanyId)
  159 + in.UserId = int(userReq.UserId)
  160 + data, err := srv.GetEvaluation360All(in)
  161 + c.Response(data, err)
  162 +}
  163 +
148 func (c *SummaryEvaluationController) EditEvaluation360() { 164 func (c *SummaryEvaluationController) EditEvaluation360() {
149 srv := service.NewSummaryEvaluationService() 165 srv := service.NewSummaryEvaluationService()
150 in := &command.EditEvaluationValue{} 166 in := &command.EditEvaluationValue{}
@@ -16,6 +16,7 @@ func init() { @@ -16,6 +16,7 @@ func init() {
16 web.NSCtrlPost("/evaluation-self", (*controllers.SummaryEvaluationController).GetEvaluationSelf), 16 web.NSCtrlPost("/evaluation-self", (*controllers.SummaryEvaluationController).GetEvaluationSelf),
17 web.NSCtrlPost("/evaluation-self/edit", (*controllers.SummaryEvaluationController).EditEvaluationSelf), 17 web.NSCtrlPost("/evaluation-self/edit", (*controllers.SummaryEvaluationController).EditEvaluationSelf),
18 web.NSCtrlPost("/evaluation-360", (*controllers.SummaryEvaluationController).GetEvaluation360), 18 web.NSCtrlPost("/evaluation-360", (*controllers.SummaryEvaluationController).GetEvaluation360),
  19 + web.NSCtrlPost("/evaluation-360all", (*controllers.SummaryEvaluationController).GetEvaluation360All),
19 web.NSCtrlPost("/evaluation-360/edit", (*controllers.SummaryEvaluationController).EditEvaluation360), 20 web.NSCtrlPost("/evaluation-360/edit", (*controllers.SummaryEvaluationController).EditEvaluation360),
20 web.NSCtrlPost("/evaluation-360/list", (*controllers.SummaryEvaluationController).Evaluation360List), 21 web.NSCtrlPost("/evaluation-360/list", (*controllers.SummaryEvaluationController).Evaluation360List),
21 web.NSCtrlPost("/evaluation-hr", (*controllers.SummaryEvaluationController).GetEvaluationHRBP), 22 web.NSCtrlPost("/evaluation-hr", (*controllers.SummaryEvaluationController).GetEvaluationHRBP),