作者 郑周

1. 优化hrbp 和 360综评接口

@@ -26,14 +26,20 @@ type QueryEvaluation360 struct { @@ -26,14 +26,20 @@ type QueryEvaluation360 struct {
26 CompanyId int `json:"-"` // 公司ID 26 CompanyId int `json:"-"` // 公司ID
27 } 27 }
28 28
  29 +// QueryEvaluationHRBPMy [HRBP] 对 [目标用户] 进行评估
  30 +type QueryEvaluationHRBPMy struct {
  31 + SummaryEvaluationId int `json:"summaryEvaluationId,string"`
  32 + CompanyId int `json:"-"` // 公司ID
  33 +}
  34 +
  35 +// QueryEvaluationHRBP [HRBP] 对 [目标用户]进行评估,状态已完成
29 type QueryEvaluationHRBP struct { 36 type QueryEvaluationHRBP struct {
30 - //SummaryEvaluationId int `json:"summaryEvaluationId,string"`  
31 CycleId int `json:"cycleId,string"` // 周期ID 37 CycleId int `json:"cycleId,string"` // 周期ID
32 TargetUserId int `json:"targetUserId,string"` // 目标人ID 38 TargetUserId int `json:"targetUserId,string"` // 目标人ID
33 CompanyId int `json:"-"` // 公司ID 39 CompanyId int `json:"-"` // 公司ID
34 } 40 }
35 41
36 -// 获取上级评估详情 42 +// QueryEvaluationSuper 获取上级评估详情
37 type QueryEvaluationSuper struct { 43 type QueryEvaluationSuper struct {
38 SummaryEvaluationId int `json:"summaryEvaluationId,string"` 44 SummaryEvaluationId int `json:"summaryEvaluationId,string"`
39 CompanyId int `json:"-"` 45 CompanyId int `json:"-"`
@@ -249,8 +249,8 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua @@ -249,8 +249,8 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua
249 return &itemValuesAdapter, nil 249 return &itemValuesAdapter, nil
250 } 250 }
251 251
252 -// GetEvaluation360All 获取360综评详情-上级综评(所有的评估人,评估内容)  
253 -func (srv *SummaryEvaluationService) GetEvaluation360All(param *command.QueryEvaluation360) (*[]adapter.EvaluationItemAdapter, error) { 252 +// GetEvaluation360Complete 获取360综评详情(他人评估目标用户)(已完成状态)
  253 +func (srv *SummaryEvaluationService) GetEvaluation360Complete(param *command.QueryEvaluation360) (*[]adapter.EvaluationItemAdapter, error) {
254 transactionContext, err := factory.ValidateStartTransaction(param) 254 transactionContext, err := factory.ValidateStartTransaction(param)
255 if err != nil { 255 if err != nil {
256 return nil, err 256 return nil, err
@@ -263,12 +263,13 @@ func (srv *SummaryEvaluationService) GetEvaluation360All(param *command.QueryEva @@ -263,12 +263,13 @@ func (srv *SummaryEvaluationService) GetEvaluation360All(param *command.QueryEva
263 evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) 263 evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
264 itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext}) 264 itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
265 _, evaluations, err := evaluationRepo.Find(map[string]interface{}{ 265 _, evaluations, err := evaluationRepo.Find(map[string]interface{}{
266 - "limit": 1,  
267 "companyId": param.CompanyId, 266 "companyId": param.CompanyId,
268 "cycleId": param.CycleId, 267 "cycleId": param.CycleId,
269 "targetUserId": param.TargetUserId, 268 "targetUserId": param.TargetUserId,
270 - "types": domain.Evaluation360},  
271 - ) 269 + "types": domain.Evaluation360,
  270 + "status": domain.EvaluationCompleted,
  271 + "limit": 99999,
  272 + })
272 if err != nil { 273 if err != nil {
273 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 274 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
274 } 275 }
@@ -583,7 +584,53 @@ func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEval @@ -583,7 +584,53 @@ func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEval
583 } 584 }
584 585
585 // GetEvaluationHRBP 获取人资综评详情 586 // GetEvaluationHRBP 获取人资综评详情
586 -func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvaluationHRBP) (*[]adapter.EvaluationItemAdapter, error) { 587 +func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvaluationHRBPMy) (*[]adapter.EvaluationItemAdapter, error) {
  588 + transactionContext, err := factory.ValidateStartTransaction(param)
  589 + if err != nil {
  590 + return nil, err
  591 + }
  592 + defer func() {
  593 + _ = transactionContext.RollbackTransaction()
  594 + }()
  595 +
  596 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
  597 + evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
  598 + itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
  599 +
  600 + sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
  601 + if err != nil {
  602 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  603 + }
  604 +
  605 + // 自评评估内容(自评模板、筛选项目评估人)
  606 + _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
  607 + "evaluationProjectId": sEvaluation.EvaluationProjectId,
  608 + "nodeType": domain.LinkNodeSelfAssessment,
  609 + "evaluatorId": -1,
  610 + })
  611 + if err != nil {
  612 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  613 + }
  614 +
  615 + // 评估内容对应的分数
  616 + _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": sEvaluation.Id})
  617 + if err != nil {
  618 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  619 + }
  620 +
  621 + if err := transactionContext.CommitTransaction(); err != nil {
  622 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  623 + }
  624 +
  625 + itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
  626 + for i := range itemValuesAdapter { // 评估人名称赋值
  627 + itemValuesAdapter[i].EvaluatorName = sEvaluation.Executor.UserName
  628 + }
  629 + return &itemValuesAdapter, nil
  630 +}
  631 +
  632 +// GetEvaluationHRBPComplete 获取人资综评详情(已完成状态)
  633 +func (srv *SummaryEvaluationService) GetEvaluationHRBPComplete(param *command.QueryEvaluationHRBP) (*[]adapter.EvaluationItemAdapter, error) {
587 transactionContext, err := factory.ValidateStartTransaction(param) 634 transactionContext, err := factory.ValidateStartTransaction(param)
588 if err != nil { 635 if err != nil {
589 return nil, err 636 return nil, err
@@ -597,13 +644,13 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu @@ -597,13 +644,13 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu
597 itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext}) 644 itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
598 645
599 _, evaluations, err := evaluationRepo.Find(map[string]interface{}{ 646 _, evaluations, err := evaluationRepo.Find(map[string]interface{}{
600 - "limit": 1, 647 + "limit": 99999,
601 "companyId": param.CompanyId, 648 "companyId": param.CompanyId,
602 "cycleId": param.CycleId, 649 "cycleId": param.CycleId,
603 "targetUserId": param.TargetUserId, 650 "targetUserId": param.TargetUserId,
  651 + "status": domain.EvaluationCompleted,
604 "types": domain.EvaluationHrbp}, 652 "types": domain.EvaluationHrbp},
605 ) 653 )
606 - // sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})  
607 if err != nil { 654 if err != nil {
608 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 655 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
609 } 656 }
@@ -653,21 +700,6 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu @@ -653,21 +700,6 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu
653 itemValuesAdapter[i].EvaluatorName = executor.UserName 700 itemValuesAdapter[i].EvaluatorName = executor.UserName
654 } 701 }
655 } 702 }
656 -  
657 - //result := adapter.EvaluationInfoAdapter{  
658 - // SummaryEvaluationId: sEvaluation.Id,  
659 - // CycleId: int(sEvaluation.CycleId),  
660 - // CycleName: sEvaluation.CycleName,  
661 - // EvaluationProjectId: sEvaluation.EvaluationProjectId,  
662 - // EvaluationProjectName: sEvaluation.EvaluationProjectName,  
663 - // LinkNodeId: sEvaluation.NodeId,  
664 - // BeginTime: sEvaluation.BeginTime.Format("2006-01-02 15:04:05"),  
665 - // EndTime: sEvaluation.EndTime.Format("2006-01-02 15:04:05"),  
666 - // TargetUserId: sEvaluation.TargetUser.UserId,  
667 - // TargetUserName: sEvaluation.TargetUser.UserName,  
668 - // Status: string(sEvaluation.Status),  
669 - // EvaluationItems: itemValuesAdapter,  
670 - //}  
671 return &itemValuesAdapter, nil 703 return &itemValuesAdapter, nil
672 } 704 }
673 705
@@ -144,7 +144,7 @@ func (c *SummaryEvaluationController) GetEvaluation360() { @@ -144,7 +144,7 @@ func (c *SummaryEvaluationController) GetEvaluation360() {
144 c.Response(data, err) 144 c.Response(data, err)
145 } 145 }
146 146
147 -func (c *SummaryEvaluationController) GetEvaluation360All() { 147 +func (c *SummaryEvaluationController) GetEvaluation360Complete() {
148 srv := service.NewSummaryEvaluationService() 148 srv := service.NewSummaryEvaluationService()
149 in := &command.QueryEvaluation360{} 149 in := &command.QueryEvaluation360{}
150 err := c.BindJSON(in) 150 err := c.BindJSON(in)
@@ -155,7 +155,7 @@ func (c *SummaryEvaluationController) GetEvaluation360All() { @@ -155,7 +155,7 @@ func (c *SummaryEvaluationController) GetEvaluation360All() {
155 } 155 }
156 userReq := middlewares.GetUser(c.Ctx) 156 userReq := middlewares.GetUser(c.Ctx)
157 in.CompanyId = int(userReq.CompanyId) 157 in.CompanyId = int(userReq.CompanyId)
158 - data, err := srv.GetEvaluation360All(in) 158 + data, err := srv.GetEvaluation360Complete(in)
159 c.Response(data, err) 159 c.Response(data, err)
160 } 160 }
161 161
@@ -193,7 +193,7 @@ func (c *SummaryEvaluationController) EvaluationHRBPList() { @@ -193,7 +193,7 @@ func (c *SummaryEvaluationController) EvaluationHRBPList() {
193 193
194 func (c *SummaryEvaluationController) GetEvaluationHRBP() { 194 func (c *SummaryEvaluationController) GetEvaluationHRBP() {
195 srv := service.NewSummaryEvaluationService() 195 srv := service.NewSummaryEvaluationService()
196 - in := &command.QueryEvaluationHRBP{} 196 + in := &command.QueryEvaluationHRBPMy{}
197 err := c.BindJSON(in) 197 err := c.BindJSON(in)
198 if err != nil { 198 if err != nil {
199 e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) 199 e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
@@ -206,6 +206,21 @@ func (c *SummaryEvaluationController) GetEvaluationHRBP() { @@ -206,6 +206,21 @@ func (c *SummaryEvaluationController) GetEvaluationHRBP() {
206 c.Response(data, err) 206 c.Response(data, err)
207 } 207 }
208 208
  209 +func (c *SummaryEvaluationController) GetEvaluationHRBPComplete() {
  210 + srv := service.NewSummaryEvaluationService()
  211 + in := &command.QueryEvaluationHRBP{}
  212 + err := c.BindJSON(in)
  213 + if err != nil {
  214 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  215 + c.Response(nil, e)
  216 + return
  217 + }
  218 + userReq := middlewares.GetUser(c.Ctx)
  219 + in.CompanyId = int(userReq.CompanyId)
  220 + data, err := srv.GetEvaluationHRBPComplete(in)
  221 + c.Response(data, err)
  222 +}
  223 +
209 func (c *SummaryEvaluationController) EditEvaluationHRBP() { 224 func (c *SummaryEvaluationController) EditEvaluationHRBP() {
210 srv := service.NewSummaryEvaluationService() 225 srv := service.NewSummaryEvaluationService()
211 in := &command.EditEvaluationValue{} 226 in := &command.EditEvaluationValue{}
@@ -16,10 +16,11 @@ func init() { @@ -16,10 +16,11 @@ 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-360all", (*controllers.SummaryEvaluationController).GetEvaluation360Complete),
20 web.NSCtrlPost("/evaluation-360/edit", (*controllers.SummaryEvaluationController).EditEvaluation360), 20 web.NSCtrlPost("/evaluation-360/edit", (*controllers.SummaryEvaluationController).EditEvaluation360),
21 web.NSCtrlPost("/evaluation-360/list", (*controllers.SummaryEvaluationController).Evaluation360List), 21 web.NSCtrlPost("/evaluation-360/list", (*controllers.SummaryEvaluationController).Evaluation360List),
22 web.NSCtrlPost("/evaluation-hr", (*controllers.SummaryEvaluationController).GetEvaluationHRBP), 22 web.NSCtrlPost("/evaluation-hr", (*controllers.SummaryEvaluationController).GetEvaluationHRBP),
  23 + web.NSCtrlPost("/evaluation-hrAll", (*controllers.SummaryEvaluationController).GetEvaluationHRBPComplete),
23 web.NSCtrlPost("/evaluation-hr/edit", (*controllers.SummaryEvaluationController).EditEvaluationHRBP), 24 web.NSCtrlPost("/evaluation-hr/edit", (*controllers.SummaryEvaluationController).EditEvaluationHRBP),
24 web.NSCtrlPost("/evaluation-hr/list", (*controllers.SummaryEvaluationController).EvaluationHRBPList), 25 web.NSCtrlPost("/evaluation-hr/list", (*controllers.SummaryEvaluationController).EvaluationHRBPList),
25 web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevel), 26 web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevel),