作者 郑周

Merge branch 'dev-zhengzhou' into test

# Conflicts:
#	pkg/infrastructure/repository/pg_summary_evaluation_repository.go
#	pkg/infrastructure/repository/pg_summary_evaluation_value_repository.go
  1 +package adapter
  2 +
  3 +type TableHeader struct {
  4 + Key string `json:"key"`
  5 + Name string `json:"name"`
  6 +}
  7 +
  8 +type SummaryEvaluationAdapter struct {
  9 + TableHeader []TableHeader `json:"tableHeader"`
  10 + List []map[string]interface{} `json:"list"`
  11 + Total int `json:"total"`
  12 +}
  13 +
  14 +type SummaryEvaluationHRBPAdapter struct {
  15 + Id int `json:"id"` // 周期评估ID
  16 + TargetUserId int `json:"targetUserId"` // 目标用户ID
  17 + TargetUserName string `json:"targetUserName"` // 目标用户名称
  18 + Department string `json:"departmentVal"` // 部门(拼接文本)
  19 + Position string `json:"positionVal"` // 职位(拼接文本)
  20 + DutyTime string `json:"dutyTime"` // 入职时间(2006-01-02 15:04)
  21 + Status string `json:"statusVal"` // 完成状态(拼接文本)
  22 + EndTime string `json:"endTime"` // 截止时间(2006-01-02 15:04)
  23 + OverdueCount int `json:"overdueCount"` // 自评逾期次数
  24 +}
@@ -13,13 +13,19 @@ type QueryEvaluation struct { @@ -13,13 +13,19 @@ type QueryEvaluation struct {
13 } 13 }
14 14
15 type QueryEvaluation360 struct { 15 type QueryEvaluation360 struct {
16 - SummaryEvaluationId int `json:"summaryEvaluationId,string"`  
17 - UserId int `json:"-"` // 用户ID 16 + //SummaryEvaluationId int `json:"summaryEvaluationId,string"`
  17 + CycleId int `json:"cycleId,string"` // 周期ID
  18 + TargetUserId int `json:"targetUserId,string"` // 目标人ID
  19 + CompanyId int `json:"-"` // 公司ID
  20 + UserId int `json:"-"` // 用户ID
18 } 21 }
19 22
20 type QueryEvaluationHRBP struct { 23 type QueryEvaluationHRBP struct {
21 - SummaryEvaluationId int `json:"summaryEvaluationId,string"`  
22 - UserId int `json:"-"` // 用户ID 24 + //SummaryEvaluationId int `json:"summaryEvaluationId,string"`
  25 + //UserId int `json:"-"` // 用户ID
  26 + CycleId int `json:"cycleId,string"` // 周期ID
  27 + TargetUserId int `json:"targetUserId,string"` // 目标人ID
  28 + CompanyId int `json:"-"` // 公司ID
23 } 29 }
24 30
25 // 获取上级评估详情 31 // 获取上级评估详情
  1 +package command
  2 +
  3 +// QueryEvaluation360List 360综评列表
  4 +type QueryEvaluation360List struct {
  5 + CycleId int `cname:"周期ID" json:"cycleId,string" valid:"Required"`
  6 + PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"`
  7 + PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"`
  8 + SearchName string `cname:"用户名称" json:"searchName"`
  9 + CompanyId int `cname:"公司ID" json:"-"`
  10 + UserId int `cname:"用户ID" json:"-"`
  11 +}
  12 +
  13 +// QueryEvaluationHRList 人资综评列表
  14 +type QueryEvaluationHRList struct {
  15 + CycleId int `cname:"周期ID" json:"cycleId,string" valid:"Required"`
  16 + PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"`
  17 + PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"`
  18 + SearchName string `cname:"用户名称" json:"searchName"`
  19 + CompanyId int `cname:"公司ID" json:"-"`
  20 + UserId int `cname:"用户ID" json:"-"`
  21 +}
1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "fmt"
4 "github.com/linmadan/egglib-go/core/application" 5 "github.com/linmadan/egglib-go/core/application"
  6 + "github.com/linmadan/egglib-go/utils/tool_funs"
5 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" 7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
6 service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role" 8 service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter" 9 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command" 10 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
9 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 11 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  12 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
  13 + "strings"
10 "time" 14 "time"
11 ) 15 )
12 16
  17 +// Evaluation360List 获取360综评列表
  18 +func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvaluation360List) (*adapter.SummaryEvaluationAdapter, error) {
  19 + transactionContext, err := factory.ValidateStartTransaction(param)
  20 + if err != nil {
  21 + return nil, err
  22 + }
  23 + defer func() {
  24 + _ = transactionContext.RollbackTransaction()
  25 + }()
  26 +
  27 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
  28 + evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
  29 + itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
  30 +
  31 + var searchTargetName string
  32 + if len(param.SearchName) > 0 {
  33 + searchTargetName = "%" + param.SearchName + "%"
  34 + } else {
  35 + searchTargetName = ""
  36 + }
  37 + limit := param.PageSize
  38 + offset := limit * (param.PageNumber - 1)
  39 + if offset < 0 {
  40 + offset = 0
  41 + }
  42 + count, list, err := evaluationRepo.Find(map[string]interface{}{
  43 + "companyId": param.CompanyId,
  44 + "cycleId": param.CycleId,
  45 + "executorId": param.UserId,
  46 + "types": domain.Evaluation360,
  47 + "searchTargetName": searchTargetName,
  48 + "limit": limit,
  49 + "offset": offset,
  50 + })
  51 + if err != nil {
  52 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  53 + }
  54 +
  55 + ids := make([]int, 0)
  56 + projectIds := make([]int, 0)
  57 + for i := range list {
  58 + ids = append(ids, list[i].Id)
  59 + projectIds = append(projectIds, list[i].EvaluationProjectId)
  60 + }
  61 +
  62 + // 固定列
  63 + changeableHeader := []adapter.TableHeader{
  64 + {Key: "targetUserName", Name: "姓名"},
  65 + {Key: "statusVal", Name: "状态"},
  66 + {Key: "relation", Name: "360°评估关系"},
  67 + {Key: "endTime", Name: "360°评估截止日期"},
  68 + }
  69 + changeableRowMap := map[int]map[string]interface{}{} // k,v(用户ID -> 数据集合)行数据内容
  70 + itemMap := map[int][]*domain.EvaluationItemUsed{} // k,v(项目ID -> 评估数组)归类评估内容
  71 + valueMap := map[string]*domain.SummaryEvaluationValue{} // k,v(周期+评估 -> 提交值)
  72 + uniqueColumnsMap := map[string]string{} // 列名称唯一
  73 +
  74 + if len(ids) > 0 {
  75 + // 评估内容(注.使用自评模板,并过滤出360综评人的评估内容)
  76 + _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectIds": projectIds, "node_type": domain.LinkNodeSelfAssessment, "evaluatorId": param.UserId})
  77 + if err != nil {
  78 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  79 + }
  80 + // 填写值
  81 + _, valueList, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIds": ids})
  82 + if err != nil {
  83 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  84 + }
  85 +
  86 + if err := transactionContext.CommitTransaction(); err != nil {
  87 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  88 + }
  89 +
  90 + for i := range valueList {
  91 + key := fmt.Sprintf("%d-%d", valueList[i].SummaryEvaluationId, valueList[i].EvaluationItemId)
  92 + valueMap[key] = valueList[i]
  93 + }
  94 +
  95 + for i := range itemList {
  96 + item := itemList[i]
  97 + key := fmt.Sprintf("k%d", i)
  98 + name := fmt.Sprintf("%s-%s", item.Category, item.Name)
  99 + if _, ok := uniqueColumnsMap[name]; !ok {
  100 + changeableHeader = append(changeableHeader, adapter.TableHeader{Key: key, Name: name})
  101 + uniqueColumnsMap[name] = key
  102 + }
  103 +
  104 + if pList, ok := itemMap[item.EvaluationProjectId]; !ok {
  105 + pList = make([]*domain.EvaluationItemUsed, 0)
  106 + itemMap[item.EvaluationProjectId] = pList
  107 + } else {
  108 + pList = append(pList, item)
  109 + }
  110 + }
  111 + }
  112 +
  113 + now := time.Now().Local() // 当前时间
  114 + var rowMap map[string]interface{}
  115 + for i := range list {
  116 + v := list[i]
  117 + if rm, ok := changeableRowMap[v.TargetUser.UserId]; ok {
  118 + rowMap = rm
  119 + } else {
  120 + rowMap = map[string]interface{}{}
  121 + changeableRowMap[v.TargetUser.UserId] = rowMap
  122 + }
  123 +
  124 + endTime := v.EndTime.Local()
  125 + statusVal := ""
  126 + if v.Status == domain.EvaluationCompleted {
  127 + statusVal = "已完成"
  128 + } else {
  129 + if now.After(endTime) {
  130 + statusVal = "已逾期"
  131 + } else {
  132 + statusVal = "待完成"
  133 + }
  134 + }
  135 + rowMap["id"] = v.Id
  136 + rowMap["targetUserName"] = v.TargetUser.UserName
  137 + rowMap["statusVal"] = statusVal
  138 + rowMap["relation"] = "项目组员"
  139 + rowMap["endTime"] = endTime.Format("2006-01-02 15:04")
  140 +
  141 + // 当前项目所有评估内容
  142 + if pList, ok := itemMap[v.EvaluationProjectId]; ok {
  143 + for _, item := range pList {
  144 + name := fmt.Sprintf("%s-%s", item.Category, item.Name)
  145 + if key, ok := uniqueColumnsMap[name]; ok { // 动态列用name -> key
  146 + valueKey := fmt.Sprintf("%d-%d", v.Id, item.Id)
  147 + if it, ok := valueMap[valueKey]; ok {
  148 + rowMap[key] = it.Score
  149 + } else {
  150 + rowMap[key] = ""
  151 + }
  152 + }
  153 + }
  154 + }
  155 + }
  156 +
  157 + targetList := make([]map[string]interface{}, 0)
  158 + for _, v1 := range list {
  159 + rowMap := changeableRowMap[v1.TargetUser.UserId]
  160 + for _, v2 := range changeableHeader { // 填充部分动态列缺失字段
  161 + if _, ok := rowMap[v2.Key]; !ok {
  162 + rowMap[v2.Key] = ""
  163 + }
  164 + }
  165 + targetList = append(targetList, rowMap)
  166 + }
  167 + result := &adapter.SummaryEvaluationAdapter{
  168 + TableHeader: changeableHeader,
  169 + Total: count,
  170 + List: targetList,
  171 + }
  172 + return result, nil
  173 +}
  174 +
13 // GetEvaluation360 获取360综评详情 175 // GetEvaluation360 获取360综评详情
14 func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) { 176 func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) {
15 transactionContext, err := factory.ValidateStartTransaction(param) 177 transactionContext, err := factory.ValidateStartTransaction(param)
@@ -24,10 +186,24 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua @@ -24,10 +186,24 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua
24 evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) 186 evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
25 itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext}) 187 itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
26 188
27 - sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId}) 189 + //sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
  190 + //if err != nil {
  191 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  192 + //}
  193 + _, evaluations, err := evaluationRepo.Find(map[string]interface{}{
  194 + "limit": 1,
  195 + "companyId": param.CompanyId,
  196 + "cycleId": param.CycleId,
  197 + "targetUserId": param.TargetUserId,
  198 + "types": domain.Evaluation360},
  199 + )
28 if err != nil { 200 if err != nil {
29 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 201 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
30 } 202 }
  203 + if len(evaluations) == 0 {
  204 + return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
  205 + }
  206 + sEvaluation := evaluations[0]
31 207
32 // 自评评估内容(自评模板、筛选项目评估人) 208 // 自评评估内容(自评模板、筛选项目评估人)
33 _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{ 209 _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
@@ -166,6 +342,156 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua @@ -166,6 +342,156 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
166 }, nil 342 }, nil
167 } 343 }
168 344
  345 +// EvaluationHRBPList 获取人资综评列表
  346 +func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEvaluationHRList) (map[string]interface{}, error) {
  347 + transactionContext, err := factory.ValidateStartTransaction(param)
  348 + if err != nil {
  349 + return nil, err
  350 + }
  351 + defer func() {
  352 + _ = transactionContext.RollbackTransaction()
  353 + }()
  354 +
  355 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
  356 + staffAssessDaoRepo := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
  357 + userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
  358 + positionRepo := factory.CreatePositionRepository(map[string]interface{}{"transactionContext": transactionContext})
  359 + var searchTargetName string
  360 + if len(param.SearchName) > 0 {
  361 + searchTargetName = "%" + param.SearchName + "%"
  362 + } else {
  363 + searchTargetName = ""
  364 + }
  365 + limit := param.PageSize
  366 + offset := limit * (param.PageNumber - 1)
  367 + if offset < 0 {
  368 + offset = 0
  369 + }
  370 + count, list, err := evaluationRepo.Find(map[string]interface{}{
  371 + "companyId": param.CompanyId,
  372 + "cycleId": param.CycleId,
  373 + "executorId": -1,
  374 + "types": domain.EvaluationHrbp,
  375 + "searchTargetName": searchTargetName,
  376 + "limit": limit,
  377 + "offset": offset,
  378 + })
  379 + if err != nil {
  380 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  381 + }
  382 +
  383 + userIds := make([]int, 0)
  384 + positionIds := make([]int, 0)
  385 + projectIds := make([]int, 0)
  386 + projectCountMap := map[string]int{} // 自评逾期数量
  387 + userMap := map[int64]*domain.User{} // 用户
  388 + positionMap := map[int64]*domain.Position{} // 职位
  389 +
  390 + for i := range list {
  391 + it := list[i]
  392 + userIds = append(userIds, it.TargetUser.UserId)
  393 + projectIds = append(projectIds, list[i].EvaluationProjectId)
  394 + }
  395 + _, users, err := userRepo.Find(map[string]interface{}{"ids": userIds, "companyId": param.CompanyId})
  396 + if err != nil {
  397 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  398 + }
  399 + for i := range users {
  400 + userMap[users[i].Id] = users[i]
  401 + for _, pid := range users[i].PositionId {
  402 + positionIds = append(positionIds, pid)
  403 + }
  404 + }
  405 + _, positions, err := positionRepo.Find(map[string]interface{}{"ids": positionIds, "companyId": param.CompanyId})
  406 + if err != nil {
  407 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  408 + }
  409 + for i := range positions {
  410 + positionMap[positions[i].Id] = positions[i]
  411 + }
  412 +
  413 + if len(projectIds) > 0 {
  414 + targetCount, err := staffAssessDaoRepo.CountUncompletedSelfAssess(param.CompanyId, projectIds)
  415 + if err != nil {
  416 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  417 + }
  418 + for i := range targetCount {
  419 + key := fmt.Sprintf("%d-%d", targetCount[i].EvaluationProjectId, targetCount[i].TargetUserId)
  420 + projectCountMap[key] = targetCount[i].Cnt
  421 + }
  422 + }
  423 +
  424 + now := time.Now().Local() // 当前时间
  425 + resultList := make([]*adapter.SummaryEvaluationHRBPAdapter, 0)
  426 + for i := range list {
  427 + v := list[i]
  428 + endTime := v.EndTime.Local()
  429 + // 状态
  430 + statusVal := ""
  431 + if v.Status == domain.EvaluationCompleted {
  432 + statusVal = "已完成"
  433 + } else {
  434 + if now.After(endTime) {
  435 + statusVal = "已逾期"
  436 + } else {
  437 + statusVal = "待完成"
  438 + }
  439 + }
  440 +
  441 + // 部门拼接
  442 + var departmentBuild strings.Builder
  443 + departmentBuild.WriteString("")
  444 + for i2 := range v.TargetDepartment {
  445 + departmentBuild.WriteString(v.TargetDepartment[i2].DepartmentName)
  446 + if i2 != len(v.TargetDepartment)-1 {
  447 + departmentBuild.WriteString(",")
  448 + }
  449 + }
  450 + // 入职时间
  451 + entryTime := ""
  452 + // 职位拼接
  453 + var positionBuild strings.Builder
  454 + positionBuild.WriteString("")
  455 + if user, ok := userMap[int64(v.TargetUser.UserId)]; ok {
  456 + for i2 := range user.PositionId {
  457 + if position, ok := positionMap[int64(user.PositionId[i2])]; ok {
  458 + positionBuild.WriteString(position.Name)
  459 + if i2 != len(user.PositionId)-1 {
  460 + departmentBuild.WriteString(",")
  461 + }
  462 + }
  463 + }
  464 + entryTime = user.EntryTime
  465 + }
  466 +
  467 + // 自评逾期数量
  468 + overdueCount := 0
  469 + key := fmt.Sprintf("%d-%d", v.EvaluationProjectId, v.TargetUser.UserId)
  470 + if cnt, ok := projectCountMap[key]; ok {
  471 + overdueCount = cnt
  472 + }
  473 +
  474 + result := &adapter.SummaryEvaluationHRBPAdapter{
  475 + Id: v.Id,
  476 + TargetUserId: v.TargetUser.UserId,
  477 + TargetUserName: v.TargetUser.UserName,
  478 + Department: departmentBuild.String(),
  479 + Position: positionBuild.String(),
  480 + DutyTime: entryTime,
  481 + Status: statusVal,
  482 + EndTime: endTime.Format("2006-01-02 15:04"),
  483 + OverdueCount: overdueCount,
  484 + }
  485 + resultList = append(resultList, result)
  486 + }
  487 +
  488 + if err := transactionContext.CommitTransaction(); err != nil {
  489 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  490 + }
  491 +
  492 + return tool_funs.SimpleWrapGridMap(int64(count), resultList), nil
  493 +}
  494 +
169 // GetEvaluationHRBP 获取人资综评详情 495 // GetEvaluationHRBP 获取人资综评详情
170 func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvaluationHRBP) (*adapter.EvaluationInfoAdapter, error) { 496 func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvaluationHRBP) (*adapter.EvaluationInfoAdapter, error) {
171 transactionContext, err := factory.ValidateStartTransaction(param) 497 transactionContext, err := factory.ValidateStartTransaction(param)
@@ -180,10 +506,21 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu @@ -180,10 +506,21 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu
180 evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) 506 evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
181 itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext}) 507 itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
182 508
183 - sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId}) 509 + _, evaluations, err := evaluationRepo.Find(map[string]interface{}{
  510 + "limit": 1,
  511 + "companyId": param.CompanyId,
  512 + "cycleId": param.CycleId,
  513 + "targetUserId": param.TargetUserId,
  514 + "types": domain.EvaluationHrbp},
  515 + )
  516 + // sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
184 if err != nil { 517 if err != nil {
185 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 518 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
186 } 519 }
  520 + if len(evaluations) == 0 {
  521 + return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
  522 + }
  523 + sEvaluation := evaluations[0]
187 524
188 // 自评评估内容(自评模板、筛选项目评估人) 525 // 自评评估内容(自评模板、筛选项目评估人)
189 _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{ 526 _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
@@ -1223,3 +1223,33 @@ group by level_value,category,"name" ` @@ -1223,3 +1223,33 @@ group by level_value,category,"name" `
1223 _, err := tx.Query(&result, sqlStr, condition...) 1223 _, err := tx.Query(&result, sqlStr, condition...)
1224 return result, err 1224 return result, err
1225 } 1225 }
  1226 +
  1227 +type CountUncompletedSelfAssess struct {
  1228 + EvaluationProjectId int
  1229 + TargetUserId int
  1230 + Cnt int
  1231 +}
  1232 +
  1233 +// CountUncompletedSelfAssess 统计整个项目周期内,相关人自评未完成数量
  1234 +func (d *StaffAssessDao) CountUncompletedSelfAssess(companyId int, projectIds []int) ([]CountUncompletedSelfAssess, error) {
  1235 + sqlStr := `
  1236 + SELECT
  1237 + staff_assess.evaluation_project_id,
  1238 + staff_assess.target_user ->> 'userId' AS target_user_id,
  1239 + COUNT ( staff_assess.ID ) AS cnt
  1240 + FROM
  1241 + staff_assess
  1242 + WHERE
  1243 + staff_assess.company_id = ?
  1244 + AND staff_assess.types = 'self'
  1245 + AND staff_assess.evaluation_project_id IN (?)
  1246 + AND staff_assess.status = 'uncompleted'
  1247 + GROUP BY
  1248 + evaluation_project_id, target_user_id`
  1249 +
  1250 + condition := []interface{}{companyId, pg.In(projectIds)}
  1251 + tx := d.transactionContext.PgTx
  1252 + result := make([]CountUncompletedSelfAssess, 0)
  1253 + _, err := tx.Query(&result, sqlStr, condition...)
  1254 + return result, err
  1255 +}
1 package repository 1 package repository
2 2
3 import ( 3 import (
  4 + "github.com/go-pg/pg/v10"
4 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 5 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
5 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" 7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
@@ -85,6 +86,10 @@ func (repo *EvaluationItemUsedRepository) Find(queryOptions map[string]interface @@ -85,6 +86,10 @@ func (repo *EvaluationItemUsedRepository) Find(queryOptions map[string]interface
85 query.Where("evaluation_project_id=?", v) 86 query.Where("evaluation_project_id=?", v)
86 } 87 }
87 88
  89 + if v, ok := queryOptions["evaluationProjectIds"]; ok {
  90 + query.Where("evaluation_project_id in(?)", pg.In(v))
  91 + }
  92 +
88 if v, ok := queryOptions["nodeType"]; ok { 93 if v, ok := queryOptions["nodeType"]; ok {
89 query.Where("node_type=?", v) 94 query.Where("node_type=?", v)
90 } 95 }
@@ -128,6 +128,10 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{ @@ -128,6 +128,10 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{
128 query.Offset(v) 128 query.Offset(v)
129 } 129 }
130 130
  131 + if v, ok := queryOptions["companyId"]; ok {
  132 + query.Where("company_id=?", v)
  133 + }
  134 +
131 if v, ok := queryOptions["types"]; ok { 135 if v, ok := queryOptions["types"]; ok {
132 query.Where("types=?", v) 136 query.Where("types=?", v)
133 } 137 }
@@ -95,9 +95,27 @@ func (c *SummaryEvaluationController) GetTargetUserCycleList() { @@ -95,9 +95,27 @@ func (c *SummaryEvaluationController) GetTargetUserCycleList() {
95 c.Response(data, err) 95 c.Response(data, err)
96 } 96 }
97 97
98 -func (c *SummaryEvaluationController) GetEvaluation360() { 98 +// CountEvaluationSelfLevel 获取自评小结
  99 +func (c *SummaryEvaluationController) CountEvaluationSelfLevel() {
99 srv := service.NewSummaryEvaluationService() 100 srv := service.NewSummaryEvaluationService()
100 - in := &command.QueryEvaluation360{} 101 + paramReq := &command.QueryEvaluation{}
  102 + err := c.BindJSON(paramReq)
  103 + if err != nil {
  104 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  105 + c.Response(nil, e)
  106 + return
  107 + }
  108 + userReq := middlewares.GetUser(c.Ctx)
  109 + paramReq.UserId = int(userReq.UserId)
  110 + paramReq.CompanyId = int(userReq.CompanyId)
  111 + data, err := srv.CountEvaluationSelfLevel(paramReq)
  112 + c.Response(data, err)
  113 +
  114 +}
  115 +
  116 +func (c *SummaryEvaluationController) Evaluation360List() {
  117 + srv := service.NewSummaryEvaluationService()
  118 + in := &command.QueryEvaluation360List{}
101 err := c.BindJSON(in) 119 err := c.BindJSON(in)
102 if err != nil { 120 if err != nil {
103 e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) 121 e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
@@ -105,27 +123,26 @@ func (c *SummaryEvaluationController) GetEvaluation360() { @@ -105,27 +123,26 @@ func (c *SummaryEvaluationController) GetEvaluation360() {
105 return 123 return
106 } 124 }
107 userReq := middlewares.GetUser(c.Ctx) 125 userReq := middlewares.GetUser(c.Ctx)
  126 + in.CompanyId = int(userReq.CompanyId)
108 in.UserId = int(userReq.UserId) 127 in.UserId = int(userReq.UserId)
109 - data, err := srv.GetEvaluation360(in) 128 + data, err := srv.Evaluation360List(in)
110 c.Response(data, err) 129 c.Response(data, err)
111 } 130 }
112 131
113 -// CountEvaluationSelfLevel 获取自评小结  
114 -func (c *SummaryEvaluationController) CountEvaluationSelfLevel() { 132 +func (c *SummaryEvaluationController) GetEvaluation360() {
115 srv := service.NewSummaryEvaluationService() 133 srv := service.NewSummaryEvaluationService()
116 - paramReq := &command.QueryEvaluation{}  
117 - err := c.BindJSON(paramReq) 134 + in := &command.QueryEvaluation360{}
  135 + err := c.BindJSON(in)
118 if err != nil { 136 if err != nil {
119 e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) 137 e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
120 c.Response(nil, e) 138 c.Response(nil, e)
121 return 139 return
122 } 140 }
123 userReq := middlewares.GetUser(c.Ctx) 141 userReq := middlewares.GetUser(c.Ctx)
124 - paramReq.UserId = int(userReq.UserId)  
125 - paramReq.CompanyId = int(userReq.CompanyId)  
126 - data, err := srv.CountEvaluationSelfLevel(paramReq) 142 + in.CompanyId = int(userReq.CompanyId)
  143 + in.UserId = int(userReq.UserId)
  144 + data, err := srv.GetEvaluation360(in)
127 c.Response(data, err) 145 c.Response(data, err)
128 -  
129 } 146 }
130 147
131 func (c *SummaryEvaluationController) EditEvaluation360() { 148 func (c *SummaryEvaluationController) EditEvaluation360() {
@@ -144,6 +161,22 @@ func (c *SummaryEvaluationController) EditEvaluation360() { @@ -144,6 +161,22 @@ func (c *SummaryEvaluationController) EditEvaluation360() {
144 c.Response(data, err) 161 c.Response(data, err)
145 } 162 }
146 163
  164 +func (c *SummaryEvaluationController) EvaluationHRBPList() {
  165 + srv := service.NewSummaryEvaluationService()
  166 + in := &command.QueryEvaluationHRList{}
  167 + err := c.BindJSON(in)
  168 + if err != nil {
  169 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  170 + c.Response(nil, e)
  171 + return
  172 + }
  173 + userReq := middlewares.GetUser(c.Ctx)
  174 + in.CompanyId = int(userReq.CompanyId)
  175 + in.UserId = int(userReq.UserId)
  176 + data, err := srv.EvaluationHRBPList(in)
  177 + c.Response(data, err)
  178 +}
  179 +
147 func (c *SummaryEvaluationController) GetEvaluationHRBP() { 180 func (c *SummaryEvaluationController) GetEvaluationHRBP() {
148 srv := service.NewSummaryEvaluationService() 181 srv := service.NewSummaryEvaluationService()
149 in := &command.QueryEvaluationHRBP{} 182 in := &command.QueryEvaluationHRBP{}
@@ -154,7 +187,8 @@ func (c *SummaryEvaluationController) GetEvaluationHRBP() { @@ -154,7 +187,8 @@ func (c *SummaryEvaluationController) GetEvaluationHRBP() {
154 return 187 return
155 } 188 }
156 userReq := middlewares.GetUser(c.Ctx) 189 userReq := middlewares.GetUser(c.Ctx)
157 - in.UserId = int(userReq.UserId) 190 + //in.UserId = int(userReq.UserId)
  191 + in.CompanyId = int(userReq.CompanyId)
158 data, err := srv.GetEvaluationHRBP(in) 192 data, err := srv.GetEvaluationHRBP(in)
159 c.Response(data, err) 193 c.Response(data, err)
160 } 194 }
@@ -17,8 +17,10 @@ func init() { @@ -17,8 +17,10 @@ func init() {
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-360/edit", (*controllers.SummaryEvaluationController).EditEvaluation360), 19 web.NSCtrlPost("/evaluation-360/edit", (*controllers.SummaryEvaluationController).EditEvaluation360),
  20 + web.NSCtrlPost("/evaluation-360/list", (*controllers.SummaryEvaluationController).Evaluation360List),
20 web.NSCtrlPost("/evaluation-hr", (*controllers.SummaryEvaluationController).GetEvaluationHRBP), 21 web.NSCtrlPost("/evaluation-hr", (*controllers.SummaryEvaluationController).GetEvaluationHRBP),
21 web.NSCtrlPost("/evaluation-hr/edit", (*controllers.SummaryEvaluationController).EditEvaluationHRBP), 22 web.NSCtrlPost("/evaluation-hr/edit", (*controllers.SummaryEvaluationController).EditEvaluationHRBP),
  23 + web.NSCtrlPost("/evaluation-hr/list", (*controllers.SummaryEvaluationController).EvaluationHRBPList),
22 web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevel), 24 web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevel),
23 web.NSCtrlPost("/evaluation-super", (*controllers.SummaryEvaluationController).GetEvaluationSuper), 25 web.NSCtrlPost("/evaluation-super", (*controllers.SummaryEvaluationController).GetEvaluationSuper),
24 web.NSCtrlPost("/evaluation-super/edit", (*controllers.SummaryEvaluationController).EditEvaluationSuper), 26 web.NSCtrlPost("/evaluation-super/edit", (*controllers.SummaryEvaluationController).EditEvaluationSuper),