正在显示
8 个修改的文件
包含
234 行增加
和
11 行删除
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 `json:"cycleId,string"` // 周期ID | ||
16 | + SearchName string `json:"searchName"` // 模糊搜索(用户名称) | ||
17 | + CompanyId int `json:"-"` // 公司ID | ||
18 | + UserId int `json:"-"` // 用户ID | ||
19 | +} |
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" |
5 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
6 | service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role" | 7 | service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role" |
@@ -10,6 +11,163 @@ import ( | @@ -10,6 +11,163 @@ import ( | ||
10 | "time" | 11 | "time" |
11 | ) | 12 | ) |
12 | 13 | ||
14 | +func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvaluation360List) (*adapter.SummaryEvaluationAdapter, error) { | ||
15 | + transactionContext, err := factory.ValidateStartTransaction(param) | ||
16 | + if err != nil { | ||
17 | + return nil, err | ||
18 | + } | ||
19 | + defer func() { | ||
20 | + _ = transactionContext.RollbackTransaction() | ||
21 | + }() | ||
22 | + | ||
23 | + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
24 | + evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
25 | + itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
26 | + | ||
27 | + var searchTargetName string | ||
28 | + if len(param.SearchName) > 0 { | ||
29 | + searchTargetName = "%" + param.SearchName + "%" | ||
30 | + } else { | ||
31 | + searchTargetName = "" | ||
32 | + } | ||
33 | + limit := param.PageSize | ||
34 | + offset := limit * (param.PageNumber - 1) | ||
35 | + if offset < 0 { | ||
36 | + offset = 0 | ||
37 | + } | ||
38 | + count, list, err := evaluationRepo.Find(map[string]interface{}{ | ||
39 | + "companyId": param.CompanyId, | ||
40 | + "cycleId": param.CycleId, | ||
41 | + "executorId": param.UserId, | ||
42 | + "types": domain.Evaluation360, | ||
43 | + "searchTargetName": searchTargetName, | ||
44 | + "limit": limit, | ||
45 | + "offset": offset, | ||
46 | + }) | ||
47 | + if err != nil { | ||
48 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
49 | + } | ||
50 | + | ||
51 | + ids := make([]int, 0) | ||
52 | + projectIds := make([]int, 0) | ||
53 | + for i := range list { | ||
54 | + ids = append(ids, list[i].Id) | ||
55 | + projectIds = append(projectIds, list[i].EvaluationProjectId) | ||
56 | + } | ||
57 | + | ||
58 | + // 固定列 | ||
59 | + changeableHeader := []adapter.TableHeader{ | ||
60 | + {Key: "targetUserName", Name: "姓名"}, | ||
61 | + {Key: "statusVal", Name: "状态"}, | ||
62 | + {Key: "relation", Name: "360°评估关系"}, | ||
63 | + {Key: "endTime", Name: "360°评估截止日期"}, | ||
64 | + } | ||
65 | + changeableRowMap := map[int]map[string]interface{}{} // k,v(用户ID -> 数据集合)行数据内容 | ||
66 | + itemMap := map[int][]*domain.EvaluationItemUsed{} // k,v(项目ID -> 评估数组)归类评估内容 | ||
67 | + valueMap := map[string]*domain.SummaryEvaluationValue{} // k,v(周期+评估 -> 提交值) | ||
68 | + uniqueColumnsMap := map[string]string{} // 列名称唯一 | ||
69 | + | ||
70 | + if len(ids) > 0 { | ||
71 | + // 评估内容(注.使用自评模板,并过滤出360综评人的评估内容) | ||
72 | + _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectIds": projectIds, "node_type": domain.LinkNodeSelfAssessment, "evaluatorId": param.UserId}) | ||
73 | + if err != nil { | ||
74 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
75 | + } | ||
76 | + // 填写值 | ||
77 | + _, valueList, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIds": ids}) | ||
78 | + if err != nil { | ||
79 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
80 | + } | ||
81 | + | ||
82 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
83 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
84 | + } | ||
85 | + | ||
86 | + for i := range valueList { | ||
87 | + key := fmt.Sprintf("%d-%d", valueList[i].SummaryEvaluationId, valueList[i].EvaluationItemId) | ||
88 | + valueMap[key] = valueList[i] | ||
89 | + } | ||
90 | + | ||
91 | + for i := range itemList { | ||
92 | + item := itemList[i] | ||
93 | + key := fmt.Sprintf("k%d", i) | ||
94 | + name := fmt.Sprintf("%s-%s", item.Category, item.Name) | ||
95 | + if _, ok := uniqueColumnsMap[name]; !ok { | ||
96 | + changeableHeader = append(changeableHeader, adapter.TableHeader{Key: key, Name: name}) | ||
97 | + uniqueColumnsMap[name] = key | ||
98 | + } | ||
99 | + | ||
100 | + if pList, ok := itemMap[item.EvaluationProjectId]; !ok { | ||
101 | + pList = make([]*domain.EvaluationItemUsed, 0) | ||
102 | + itemMap[item.EvaluationProjectId] = pList | ||
103 | + } else { | ||
104 | + pList = append(pList, item) | ||
105 | + } | ||
106 | + } | ||
107 | + } | ||
108 | + | ||
109 | + now := time.Now().Local() // 当前时间 | ||
110 | + var rowMap map[string]interface{} | ||
111 | + for i := range list { | ||
112 | + v := list[i] | ||
113 | + if rm, ok := changeableRowMap[v.TargetUser.UserId]; ok { | ||
114 | + rowMap = rm | ||
115 | + } else { | ||
116 | + rowMap = map[string]interface{}{} | ||
117 | + changeableRowMap[v.TargetUser.UserId] = rowMap | ||
118 | + } | ||
119 | + | ||
120 | + endTime := v.EndTime.Local() | ||
121 | + statusVal := "" | ||
122 | + if v.Status == domain.EvaluationCompleted { | ||
123 | + statusVal = "已完成" | ||
124 | + } else { | ||
125 | + if now.After(endTime) { | ||
126 | + statusVal = "已逾期" | ||
127 | + } else { | ||
128 | + statusVal = "待完成" | ||
129 | + } | ||
130 | + } | ||
131 | + rowMap["id"] = v.Id | ||
132 | + rowMap["targetUserName"] = v.TargetUser.UserName | ||
133 | + rowMap["statusVal"] = statusVal | ||
134 | + rowMap["relation"] = "项目组员" | ||
135 | + rowMap["endTime"] = endTime.Format("2006-01-02 15:04") | ||
136 | + | ||
137 | + // 当前项目所有评估内容 | ||
138 | + if pList, ok := itemMap[v.EvaluationProjectId]; ok { | ||
139 | + for _, item := range pList { | ||
140 | + name := fmt.Sprintf("%s-%s", item.Category, item.Name) | ||
141 | + if key, ok := uniqueColumnsMap[name]; ok { // 动态列用name -> key | ||
142 | + valueKey := fmt.Sprintf("%d-%d", v.Id, item.Id) | ||
143 | + if it, ok := valueMap[valueKey]; ok { | ||
144 | + rowMap[key] = it.Score | ||
145 | + } else { | ||
146 | + rowMap[key] = "" | ||
147 | + } | ||
148 | + } | ||
149 | + } | ||
150 | + } | ||
151 | + } | ||
152 | + | ||
153 | + targetList := make([]map[string]interface{}, 0) | ||
154 | + for _, v1 := range list { | ||
155 | + rowMap := changeableRowMap[v1.TargetUser.UserId] | ||
156 | + for _, v2 := range changeableHeader { // 填充部分动态列缺失字段 | ||
157 | + if _, ok := rowMap[v2.Key]; !ok { | ||
158 | + rowMap[v2.Key] = "" | ||
159 | + } | ||
160 | + } | ||
161 | + targetList = append(targetList, rowMap) | ||
162 | + } | ||
163 | + result := &adapter.SummaryEvaluationAdapter{ | ||
164 | + TableHeader: changeableHeader, | ||
165 | + Total: count, | ||
166 | + List: targetList, | ||
167 | + } | ||
168 | + return result, nil | ||
169 | +} | ||
170 | + | ||
13 | // GetEvaluation360 获取360综评详情 | 171 | // GetEvaluation360 获取360综评详情 |
14 | func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) { | 172 | func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) { |
15 | transactionContext, err := factory.ValidateStartTransaction(param) | 173 | transactionContext, err := factory.ValidateStartTransaction(param) |
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 | } |
@@ -125,6 +125,10 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{ | @@ -125,6 +125,10 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{ | ||
125 | query.Offset(v) | 125 | query.Offset(v) |
126 | } | 126 | } |
127 | 127 | ||
128 | + if v, ok := queryOptions["companyId"]; ok { | ||
129 | + query.Where("company_id=?", v) | ||
130 | + } | ||
131 | + | ||
128 | if v, ok := queryOptions["types"]; ok { | 132 | if v, ok := queryOptions["types"]; ok { |
129 | query.Where("types=?", v) | 133 | query.Where("types=?", v) |
130 | } | 134 | } |
@@ -140,6 +144,10 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{ | @@ -140,6 +144,10 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{ | ||
140 | query.Where(`summary_evaluation.target_user->>'userId'='?'`, v) | 144 | query.Where(`summary_evaluation.target_user->>'userId'='?'`, v) |
141 | } | 145 | } |
142 | 146 | ||
147 | + if v, ok := queryOptions["searchTargetName"]; ok { | ||
148 | + query.Where(`summary_evaluation.target_user->>'userName' LIKE '?'`, v) | ||
149 | + } | ||
150 | + | ||
143 | if v, ok := queryOptions["executorId"]; ok { | 151 | if v, ok := queryOptions["executorId"]; ok { |
144 | query.Where(`summary_evaluation.executor->>'userId'='?'`, v) | 152 | query.Where(`summary_evaluation.executor->>'userId'='?'`, v) |
145 | } | 153 | } |
@@ -108,6 +108,10 @@ func (repo *SummaryEvaluationValueRepository) Find(queryOptions map[string]inter | @@ -108,6 +108,10 @@ func (repo *SummaryEvaluationValueRepository) Find(queryOptions map[string]inter | ||
108 | if v, ok := queryOptions["summaryEvaluationId"]; ok { | 108 | if v, ok := queryOptions["summaryEvaluationId"]; ok { |
109 | query.Where("summary_evaluation_id=?", v) | 109 | query.Where("summary_evaluation_id=?", v) |
110 | } | 110 | } |
111 | + if v, ok := queryOptions["summaryEvaluationIds"]; ok { | ||
112 | + query.Where("summary_evaluation_id in(?)", pg.In(v)) | ||
113 | + } | ||
114 | + | ||
111 | count, err := query.SelectAndCount() | 115 | count, err := query.SelectAndCount() |
112 | if err != nil { | 116 | if err != nil { |
113 | return 0, nil, err | 117 | return 0, nil, err |
@@ -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,25 @@ func (c *SummaryEvaluationController) GetEvaluation360() { | @@ -105,27 +123,25 @@ 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.UserId = int(userReq.UserId) |
143 | + data, err := srv.GetEvaluation360(in) | ||
127 | c.Response(data, err) | 144 | c.Response(data, err) |
128 | - | ||
129 | } | 145 | } |
130 | 146 | ||
131 | func (c *SummaryEvaluationController) EditEvaluation360() { | 147 | func (c *SummaryEvaluationController) EditEvaluation360() { |
@@ -17,6 +17,7 @@ func init() { | @@ -17,6 +17,7 @@ func init() { | ||
17 | web.NSCtrlPost("/self/edit", (*controllers.SummaryEvaluationController).EditEvaluationSelf), | 17 | web.NSCtrlPost("/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), |
22 | web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevel), | 23 | web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevel), |
-
请 注册 或 登录 后发表评论