作者 tangxvhui

日常保存

@@ -11,6 +11,7 @@ import ( @@ -11,6 +11,7 @@ import (
11 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" 11 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
12 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 12 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
13 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" 13 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
  14 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
14 ) 15 )
15 16
16 //获取我的项目周期列表 17 //获取我的项目周期列表
@@ -510,7 +511,7 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec @@ -510,7 +511,7 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec
510 if err != nil { 511 if err != nil {
511 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 512 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
512 } 513 }
513 - 514 + //获取目标用户
514 userIds := []int{} 515 userIds := []int{}
515 for _, v := range assessList { 516 for _, v := range assessList {
516 userIds = append(userIds, v.TargetUser.UserId) 517 userIds = append(userIds, v.TargetUser.UserId)
@@ -540,33 +541,26 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec @@ -540,33 +541,26 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec
540 }) 541 })
541 userPositionMap[v.Id] = positionList 542 userPositionMap[v.Id] = positionList
542 } 543 }
543 -  
544 - //获取员工邀请的人完成360评估的数量 544 + //获取目标员工邀请的人完成360评估的数量
545 var inviteCompletedCount []dao.CountData 545 var inviteCompletedCount []dao.CountData
546 - if len(userIds) > 0 {  
547 - // d := dao.NewStaffAssessDao(map[string]interface{}{  
548 - // "transactionContext": transactionContext,  
549 - // })  
550 - // inviteCompletedCount, err = d.CountInviteAssessByTargetUser(userIds, param.AssessTaskId)  
551 - // if err != nil {  
552 - // log.Logger.Error("获取员工邀请的人完成情况" + err.Error())  
553 - // }  
554 - }  
555 - assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ 546 + d := dao.NewStaffAssessDao(map[string]interface{}{
556 "transactionContext": transactionContext, 547 "transactionContext": transactionContext,
557 }) 548 })
558 - assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{  
559 - // "id": param.AssessTaskId,  
560 - })  
561 - if err != nil {  
562 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error()) 549 + if len(userIds) > 0 {
  550 + inviteCompletedCount, err = d.CountTargetUserInviteAssess1(userIds, param.CycleId, param.BeginDay)
  551 + if err != nil {
  552 + log.Logger.Error("获取员工邀请的人完成情况" + err.Error())
  553 + }
563 } 554 }
  555 +
564 //我评估别人,被邀请评估 556 //我评估别人,被邀请评估
565 cnnt, _, err := assessRepo.Find(map[string]interface{}{ 557 cnnt, _, err := assessRepo.Find(map[string]interface{}{
566 - // "staffAssessTaskId": param.AssessTaskId, 558 + "beginDay": param.BeginDay,
  559 + "cycleId": param.CycleId,
567 "executorId": param.ExecutorId, 560 "executorId": param.ExecutorId,
568 "typesList": []string{string(domain.AssessSuper)}, 561 "typesList": []string{string(domain.AssessSuper)},
569 "status": string(domain.StaffAssessUncompleted), 562 "status": string(domain.StaffAssessUncompleted),
  563 + "limit": 1,
570 }) 564 })
571 if err != nil { 565 if err != nil {
572 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) 566 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
@@ -616,15 +610,9 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec @@ -616,15 +610,9 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec
616 resultList = append(resultList, item) 610 resultList = append(resultList, item)
617 } 611 }
618 result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList) 612 result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList)
619 - result["linkNodeName"] = ""  
620 - result["linkNodeId"] = ""  
621 result["lintNodeDesc"] = "" 613 result["lintNodeDesc"] = ""
622 - for _, v := range assessTaskData.StepList {  
623 - if v.LinkNodeType == domain.LinkNodeSuperiorAssessment {  
624 - result["linkNodeName"] = v.LinkNodeName  
625 - result["linkNodeId"] = fmt.Sprintf("%d", v.LinkNodeId)  
626 - result["lintNodeDesc"] = fmt.Sprintf("截止时间 %s 待评估 %d 人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)  
627 - } 614 + if len(assessList) > 0 {
  615 + result["lintNodeDesc"] = fmt.Sprintf("截止时间 %s 待评估 %d 人", assessList[0].EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
628 } 616 }
629 return result, nil 617 return result, nil
630 } 618 }
@@ -57,6 +57,34 @@ func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTask @@ -57,6 +57,34 @@ func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTask
57 return result, err 57 return result, err
58 } 58 }
59 59
  60 +func (d *StaffAssessDao) CountTargetUserInviteAssess1(userIds []int, cycleId int, beginDay string) ([]CountData, error) {
  61 + sqlStr := `SELECT
  62 + staff_assess.target_user->>'userId' as target_user_id,
  63 + count(staff_assess."id") AS invite_total,
  64 + sum(
  65 + case WHEN staff_assess.status='completed' THEN 1
  66 + ELSE 0 END
  67 + ) as invite_completed
  68 + FROM staff_assess
  69 + WHERE staff_assess.target_user->>'userId' IN(?)
  70 + AND staff_assess.types IN ('invite_same_super','invite_diff_super')
  71 + and to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD') = ?
  72 + and staff_assess.cycle_id =?
  73 + GROUP BY target_user_id`
  74 + userIdStr := []string{}
  75 + for _, v := range userIds {
  76 + str := strconv.Itoa(v)
  77 + userIdStr = append(userIdStr, str)
  78 + }
  79 + condition := []interface{}{
  80 + pg.In(userIdStr), beginDay, cycleId,
  81 + }
  82 + tx := d.transactionContext.PgTx
  83 + result := []CountData{}
  84 + _, err := tx.Query(&result, sqlStr, condition...)
  85 + return result, err
  86 +}
  87 +
60 // 根据评估的人执行人id,搜索 executorId参与的评估任务 88 // 根据评估的人执行人id,搜索 executorId参与的评估任务
61 func (d *StaffAssessDao) SearchAssessTaskMe(executorId int, companyId int, limit int, offset int) ([]*domain.StaffAssessTask, error) { 89 func (d *StaffAssessDao) SearchAssessTaskMe(executorId int, companyId int, limit int, offset int) ([]*domain.StaffAssessTask, error) {
62 90