作者 Your Name

更新

@@ -137,10 +137,10 @@ func CreateStaffAssessContentRepository(options map[string]interface{}) domain.S @@ -137,10 +137,10 @@ func CreateStaffAssessContentRepository(options map[string]interface{}) domain.S
137 return repository.NewStaffAssessContentRepository(transactionContext) 137 return repository.NewStaffAssessContentRepository(transactionContext)
138 } 138 }
139 139
140 -func CreateStaffAssessTaskRepository(options map[string]interface{}) domain.StaffAssessContentRepository { 140 +func CreateStaffAssessTaskRepository(options map[string]interface{}) domain.StaffAssessTaskRepository {
141 var transactionContext *pg.TransactionContext 141 var transactionContext *pg.TransactionContext
142 if value, ok := options["transactionContext"]; ok { 142 if value, ok := options["transactionContext"]; ok {
143 transactionContext = value.(*pg.TransactionContext) 143 transactionContext = value.(*pg.TransactionContext)
144 } 144 }
145 - return repository.NewStaffAssessContentRepository(transactionContext) 145 + return repository.NewStaffAssessTaskRepository(transactionContext)
146 } 146 }
@@ -4,7 +4,7 @@ type SearchAssessMeResp struct { @@ -4,7 +4,7 @@ type SearchAssessMeResp struct {
4 AssessTaskId int `json:"assessTaskId"` 4 AssessTaskId int `json:"assessTaskId"`
5 BeginTime string `json:"beginTime"` 5 BeginTime string `json:"beginTime"`
6 EndTime string `json:"endTime"` 6 EndTime string `json:"endTime"`
7 - CycleId int `json:"cycleId"` 7 + CycleId int64 `json:"cycleId"`
8 CycleName string `json:"cycleName"` 8 CycleName string `json:"cycleName"`
9 EvaluationProjectId int `json:"evaluationProjectId"` 9 EvaluationProjectId int `json:"evaluationProjectId"`
10 EvaluationProjectName string `json:"evaluationProjectName"` 10 EvaluationProjectName string `json:"evaluationProjectName"`
1 package query 1 package query
2 2
3 type AssessTaskDescQuery struct { 3 type AssessTaskDescQuery struct {
4 - AssessTaskId int 4 + AssessTaskId int `json:"assessTaskId"` //评估任务的id
  5 + UserId int `json:"userId"` //当前登录人的id
  6 + CompanyId int `json:"companyId"` //当前登录的公司
5 } 7 }
1 package query 1 package query
2 2
3 type SearchAssessMeQuery struct { 3 type SearchAssessMeQuery struct {
4 - UserId int // 当前登录人的用户id  
5 - CompanyId int //当前登录人的公司Id  
6 - CurrentTime string // 日期 2006-01-02 4 + UserId int `json:"userId"` // 当前登录人的用户id
  5 + CompanyId int `json:"companyId"` //当前登录人的公司Id
  6 + PageSize int `json:"pageSize"` //每页的记录数
  7 + PageNumber int `json:"pageNumber"` //页码
7 } 8 }
1 package service 1 package service
2 2
3 import ( 3 import (
4 - "time"  
5 -  
6 "github.com/linmadan/egglib-go/core/application" 4 "github.com/linmadan/egglib-go/core/application"
7 "github.com/linmadan/egglib-go/utils/tool_funs" 5 "github.com/linmadan/egglib-go/utils/tool_funs"
8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" 6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
@@ -13,8 +11,8 @@ import ( @@ -13,8 +11,8 @@ import (
13 type StaffAssessServeice struct { 11 type StaffAssessServeice struct {
14 } 12 }
15 13
16 -// 获取我参与过的评估项目列表  
17 -func (srv StaffAssessServeice) SearchAssessMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) { 14 +// 获取我参与过的评估任务列表
  15 +func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) {
18 transactionContext, err := factory.CreateTransactionContext(nil) 16 transactionContext, err := factory.CreateTransactionContext(nil)
19 if err != nil { 17 if err != nil {
20 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 18 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -25,35 +23,45 @@ func (srv StaffAssessServeice) SearchAssessMe(param *query.SearchAssessMeQuery) @@ -25,35 +23,45 @@ func (srv StaffAssessServeice) SearchAssessMe(param *query.SearchAssessMeQuery)
25 defer func() { 23 defer func() {
26 _ = transactionContext.RollbackTransaction() 24 _ = transactionContext.RollbackTransaction()
27 }() 25 }()
28 - cycleRepo := factory.CreateEvaluationCycleRepository(map[string]interface{}{ 26 + staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
29 "transactionContext": transactionContext, 27 "transactionContext": transactionContext,
30 }) 28 })
31 - currentTime, err := time.ParseInLocation("2006-01-02", param.CurrentTime, time.Local)  
32 - if err != nil {  
33 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "时间条件填写错误")  
34 - }  
35 - //获取param.CurrentTime 对应的周期  
36 - _, cycleList, err := cycleRepo.Find(map[string]interface{}{  
37 - "companyId": param.CompanyId,  
38 - "timeStart": currentTime,  
39 - "timeEnd": currentTime,  
40 - "limit": 1,  
41 - }) 29 + var limit int = 20
  30 + var offset int = 0
  31 + if param.PageSize > 0 {
  32 + limit = param.PageSize
  33 + }
  34 + offset = (param.PageNumber - 1) * param.PageSize
  35 + condition := map[string]interface{}{
  36 + "executorId": param.UserId,
  37 + "companyId": param.CompanyId,
  38 + "limit": limit,
  39 + }
  40 + if offset > 0 {
  41 + condition["offset"] = offset
  42 + }
  43 + cnt, assessTaskList, err := staffAssessTaskRepo.Find(condition)
42 if err != nil { 44 if err != nil {
43 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询周期"+err.Error()) 45 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询周期"+err.Error())
44 } 46 }
45 - if len(cycleList) == 0 {  
46 - listData := []adapter.SearchAssessMeResp{}  
47 - return tool_funs.SimpleWrapGridMap(0, listData), nil  
48 - }  
49 -  
50 - //更具周期和param.UserId 获取评估项目列表  
51 if err := transactionContext.CommitTransaction(); err != nil { 47 if err := transactionContext.CommitTransaction(); err != nil {
52 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 48 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
53 } 49 }
54 - var cnt int64  
55 - var listData []adapter.SearchAssessMeResp  
56 - return tool_funs.SimpleWrapGridMap(cnt, listData), nil 50 + listData := make([]adapter.SearchAssessMeResp, 0, len(assessTaskList))
  51 + var temp adapter.SearchAssessMeResp
  52 + for _, v := range assessTaskList {
  53 + temp = adapter.SearchAssessMeResp{
  54 + AssessTaskId: v.Id,
  55 + BeginTime: v.BeginTime.Format("2006-01-02 15:04:05"),
  56 + EndTime: v.EndTime.Format("2006-01-02 15:04:05"),
  57 + CycleId: v.CycleId,
  58 + CycleName: v.CycleName,
  59 + EvaluationProjectId: v.EvaluationProjectId,
  60 + EvaluationProjectName: v.EvaluationProjectName,
  61 + }
  62 + listData = append(listData, temp)
  63 + }
  64 + return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
57 } 65 }
58 66
59 // 获取项目评估进度描述 67 // 获取项目评估进度描述
@@ -98,3 +106,22 @@ func (srv StaffAssessServeice) AssessSelfList(param query.AssessTaskDescQuery) ( @@ -98,3 +106,22 @@ func (srv StaffAssessServeice) AssessSelfList(param query.AssessTaskDescQuery) (
98 result["userInfo"] = userInfo 106 result["userInfo"] = userInfo
99 return result, nil 107 return result, nil
100 } 108 }
  109 +
  110 +// 更具项目评估的配置,创建员工的评估任务
  111 +func (srv StaffAssessServeice) CreateStaffAssessTask() error {
  112 + transactionContext, err := factory.CreateTransactionContext(nil)
  113 + if err != nil {
  114 + return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  115 + }
  116 + if err := transactionContext.StartTransaction(); err != nil {
  117 + return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  118 + }
  119 + defer func() {
  120 + _ = transactionContext.RollbackTransaction()
  121 + }()
  122 +
  123 + if err := transactionContext.CommitTransaction(); err != nil {
  124 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  125 + }
  126 + return nil
  127 +}
@@ -21,7 +21,7 @@ const ( @@ -21,7 +21,7 @@ const (
21 StaffAssessCompleted StaffAssessStatus = "completed" //已完成 21 StaffAssessCompleted StaffAssessStatus = "completed" //已完成
22 ) 22 )
23 23
24 -// 记录用户需要的评估项 24 +// 记录用户需要的评估项
25 type StaffAssess struct { 25 type StaffAssess struct {
26 Id int `json:"id"` //id 26 Id int `json:"id"` //id
27 CompanyId int `json:"companyId"` //公司id 27 CompanyId int `json:"companyId"` //公司id
@@ -26,6 +26,7 @@ type StaffAssessTask struct { @@ -26,6 +26,7 @@ type StaffAssessTask struct {
26 BeginTime time.Time `json:"beginTime"` //绩效考核开始时间 26 BeginTime time.Time `json:"beginTime"` //绩效考核开始时间
27 EndTime time.Time `json:"endTime"` //绩效考核截止时间 27 EndTime time.Time `json:"endTime"` //绩效考核截止时间
28 StepList []AssessTaskStep `json:"steps"` //考评的流程 28 StepList []AssessTaskStep `json:"steps"` //考评的流程
  29 + ExecutorId []int `json:"executorId"` //参与此次考评的人
29 CreatedAt time.Time `json:"createdAt"` //数据创建时间 30 CreatedAt time.Time `json:"createdAt"` //数据创建时间
30 UpdatedAt time.Time `json:"updatedAt"` //数据更新时间 31 UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
31 DeletedAt time.Time `json:"deletedAt"` //数据删除时间 32 DeletedAt time.Time `json:"deletedAt"` //数据删除时间
1 package models 1 package models
2 2
3 -import "time" 3 +import (
  4 + "time"
  5 +
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  7 +)
4 8
5 // 执行评估的任务列表 9 // 执行评估的任务列表
6 type StaffAssessTask struct { 10 type StaffAssessTask struct {
7 - tableName struct{} `pg:"staff_assess_task" comment:"执行评估的任务列表"`  
8 - Id int `pg:",pk"`  
9 - CompanyId int `` //公司id  
10 - EvaluationProjectId int `` //项目id  
11 - EvaluationProjectName string `` //项目名称  
12 - CycleId int64 //对应的周期id  
13 - CycleName string //对应周期的名称  
14 - BeginTime time.Time //开始时间  
15 - EndTime time.Time //截止时间  
16 - CreatedAt time.Time //数据创建时间  
17 - UpdatedAt time.Time //数据更新时间  
18 - DeletedAt time.Time //数据删除时间 11 + tableName struct{} `pg:"staff_assess_task" comment:"执行评估的任务列表"`
  12 + Id int `pg:",pk"`
  13 + CompanyId int `` //公司id
  14 + EvaluationProjectId int `` //项目id
  15 + EvaluationProjectName string `` //项目名称
  16 + CycleId int64 //对应的周期id
  17 + CycleName string //对应周期的名称
  18 + ExecutorId []int //参与考评的人
  19 + StepList []domain.AssessTaskStep `` //考评的流程
  20 + BeginTime time.Time //开始时间
  21 + EndTime time.Time //截止时间
  22 + CreatedAt time.Time //数据创建时间
  23 + UpdatedAt time.Time //数据更新时间
  24 + DeletedAt time.Time //数据删除时间
19 } 25 }
@@ -107,7 +107,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in @@ -107,7 +107,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
107 tx := repo.transactionContext.PgTx 107 tx := repo.transactionContext.PgTx
108 var m []*models.StaffAssess 108 var m []*models.StaffAssess
109 query := tx.Model(&m). 109 query := tx.Model(&m).
110 - Where("deleted_at isnull").Limit(20) 110 + Where("deleted_at isnull")
111 if companyId, ok := queryOptions["companyId"]; ok { 111 if companyId, ok := queryOptions["companyId"]; ok {
112 query.Where("company_id = ?", companyId) 112 query.Where("company_id = ?", companyId)
113 } 113 }
@@ -117,7 +117,16 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in @@ -117,7 +117,16 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
117 if v, ok := queryOptions["offset"].(int); ok { 117 if v, ok := queryOptions["offset"].(int); ok {
118 query.Offset(v) 118 query.Offset(v)
119 } 119 }
  120 + if v, ok := queryOptions["targetUserId"].(int); ok && v > 0 {
  121 + query.Where(`target_user->>'userId'='?'`, v)
  122 + }
  123 + if v, ok := queryOptions["executorId"].(int); ok && v > 0 {
  124 + query.Where(`executor->>'userId'='?'`, v)
  125 + }
120 126
  127 + if v, ok := queryOptions["cycleId"].(int64); ok && v > 0 {
  128 + query.Where(`cycle_id=?`, v)
  129 + }
121 count, err := query.SelectAndCount() 130 count, err := query.SelectAndCount()
122 if err != nil { 131 if err != nil {
123 return 0, nil, err 132 return 0, nil, err
@@ -111,7 +111,9 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{}) @@ -111,7 +111,9 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{})
111 if v, ok := queryOptions["offset"].(int); ok { 111 if v, ok := queryOptions["offset"].(int); ok {
112 query.Offset(v) 112 query.Offset(v)
113 } 113 }
114 - 114 + if v, ok := queryOptions["executorId"].(int); ok && v > 0 {
  115 + query.Where(`executorId @>[?]`, v)
  116 + }
115 count, err := query.SelectAndCount() 117 count, err := query.SelectAndCount()
116 if err != nil { 118 if err != nil {
117 return 0, nil, err 119 return 0, nil, err