作者 郑周

1. 优化hrbp 和 360综评接口

... ... @@ -26,14 +26,20 @@ type QueryEvaluation360 struct {
CompanyId int `json:"-"` // 公司ID
}
// QueryEvaluationHRBPMy [HRBP] 对 [目标用户] 进行评估
type QueryEvaluationHRBPMy struct {
SummaryEvaluationId int `json:"summaryEvaluationId,string"`
CompanyId int `json:"-"` // 公司ID
}
// QueryEvaluationHRBP [HRBP] 对 [目标用户]进行评估,状态已完成
type QueryEvaluationHRBP struct {
//SummaryEvaluationId int `json:"summaryEvaluationId,string"`
CycleId int `json:"cycleId,string"` // 周期ID
TargetUserId int `json:"targetUserId,string"` // 目标人ID
CompanyId int `json:"-"` // 公司ID
}
// 获取上级评估详情
// QueryEvaluationSuper 获取上级评估详情
type QueryEvaluationSuper struct {
SummaryEvaluationId int `json:"summaryEvaluationId,string"`
CompanyId int `json:"-"`
... ...
... ... @@ -249,8 +249,8 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua
return &itemValuesAdapter, nil
}
// GetEvaluation360All 获取360综评详情-上级综评(所有的评估人,评估内容)
func (srv *SummaryEvaluationService) GetEvaluation360All(param *command.QueryEvaluation360) (*[]adapter.EvaluationItemAdapter, error) {
// GetEvaluation360Complete 获取360综评详情(他人评估目标用户)(已完成状态)
func (srv *SummaryEvaluationService) GetEvaluation360Complete(param *command.QueryEvaluation360) (*[]adapter.EvaluationItemAdapter, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
... ... @@ -263,12 +263,13 @@ func (srv *SummaryEvaluationService) GetEvaluation360All(param *command.QueryEva
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},
)
"types": domain.Evaluation360,
"status": domain.EvaluationCompleted,
"limit": 99999,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -583,7 +584,53 @@ func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEval
}
// GetEvaluationHRBP 获取人资综评详情
func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvaluationHRBP) (*[]adapter.EvaluationItemAdapter, error) {
func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvaluationHRBPMy) (*[]adapter.EvaluationItemAdapter, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
}
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})
sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 自评评估内容(自评模板、筛选项目评估人)
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": sEvaluation.EvaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
"evaluatorId": -1,
})
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())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
for i := range itemValuesAdapter { // 评估人名称赋值
itemValuesAdapter[i].EvaluatorName = sEvaluation.Executor.UserName
}
return &itemValuesAdapter, nil
}
// GetEvaluationHRBPComplete 获取人资综评详情(已完成状态)
func (srv *SummaryEvaluationService) GetEvaluationHRBPComplete(param *command.QueryEvaluationHRBP) (*[]adapter.EvaluationItemAdapter, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
... ... @@ -597,13 +644,13 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
_, evaluations, err := evaluationRepo.Find(map[string]interface{}{
"limit": 1,
"limit": 99999,
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"status": domain.EvaluationCompleted,
"types": domain.EvaluationHrbp},
)
// sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -653,21 +700,6 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu
itemValuesAdapter[i].EvaluatorName = executor.UserName
}
}
//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 &itemValuesAdapter, nil
}
... ...
... ... @@ -144,7 +144,7 @@ func (c *SummaryEvaluationController) GetEvaluation360() {
c.Response(data, err)
}
func (c *SummaryEvaluationController) GetEvaluation360All() {
func (c *SummaryEvaluationController) GetEvaluation360Complete() {
srv := service.NewSummaryEvaluationService()
in := &command.QueryEvaluation360{}
err := c.BindJSON(in)
... ... @@ -155,7 +155,7 @@ func (c *SummaryEvaluationController) GetEvaluation360All() {
}
userReq := middlewares.GetUser(c.Ctx)
in.CompanyId = int(userReq.CompanyId)
data, err := srv.GetEvaluation360All(in)
data, err := srv.GetEvaluation360Complete(in)
c.Response(data, err)
}
... ... @@ -193,7 +193,7 @@ func (c *SummaryEvaluationController) EvaluationHRBPList() {
func (c *SummaryEvaluationController) GetEvaluationHRBP() {
srv := service.NewSummaryEvaluationService()
in := &command.QueryEvaluationHRBP{}
in := &command.QueryEvaluationHRBPMy{}
err := c.BindJSON(in)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
... ... @@ -206,6 +206,21 @@ func (c *SummaryEvaluationController) GetEvaluationHRBP() {
c.Response(data, err)
}
func (c *SummaryEvaluationController) GetEvaluationHRBPComplete() {
srv := service.NewSummaryEvaluationService()
in := &command.QueryEvaluationHRBP{}
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)
data, err := srv.GetEvaluationHRBPComplete(in)
c.Response(data, err)
}
func (c *SummaryEvaluationController) EditEvaluationHRBP() {
srv := service.NewSummaryEvaluationService()
in := &command.EditEvaluationValue{}
... ...
... ... @@ -16,10 +16,11 @@ 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-360all", (*controllers.SummaryEvaluationController).GetEvaluation360Complete),
web.NSCtrlPost("/evaluation-360/edit", (*controllers.SummaryEvaluationController).EditEvaluation360),
web.NSCtrlPost("/evaluation-360/list", (*controllers.SummaryEvaluationController).Evaluation360List),
web.NSCtrlPost("/evaluation-hr", (*controllers.SummaryEvaluationController).GetEvaluationHRBP),
web.NSCtrlPost("/evaluation-hrAll", (*controllers.SummaryEvaluationController).GetEvaluationHRBPComplete),
web.NSCtrlPost("/evaluation-hr/edit", (*controllers.SummaryEvaluationController).EditEvaluationHRBP),
web.NSCtrlPost("/evaluation-hr/list", (*controllers.SummaryEvaluationController).EvaluationHRBPList),
web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevel),
... ...