正在显示
8 个修改的文件
包含
436 行增加
和
118 行删除
1 | +package adapter | ||
2 | + | ||
3 | +import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" | ||
4 | + | ||
5 | +// MemberSummaryAdapter 综合管理-成员列表 | ||
6 | +type MemberSummaryAdapter struct { | ||
7 | + dao.MemberSummaryAssess | ||
8 | + DepartmentNames []string `json:"departmentNames"` // 被评估人部门列表 | ||
9 | + PositionNames []string `json:"positionNames"` // 被评估人职位列表 | ||
10 | +} |
1 | +package query | ||
2 | + | ||
3 | +// MemberSummaryListCommand 员工绩效-综合管理-成员列表统计 | ||
4 | +type MemberSummaryListCommand struct { | ||
5 | + CycleId int `cname:"周期ID" json:"cycleId,string"` | ||
6 | + UserName string `cname:"用户名称" json:"userName"` | ||
7 | + PageNumber int `cname:"页码" json:"pageNumber"` | ||
8 | + PageSize int `cname:"总数" json:"pageSize"` | ||
9 | + CompanyId int `cname:"公司ID" json:"companyId"` | ||
10 | + OperatorId int `cname:"操作人ID" json:"operatorId"` | ||
11 | +} |
@@ -25,6 +25,34 @@ func NewStaffAssessServeice() *StaffAssessServeice { | @@ -25,6 +25,34 @@ func NewStaffAssessServeice() *StaffAssessServeice { | ||
25 | return newService | 25 | return newService |
26 | } | 26 | } |
27 | 27 | ||
28 | +// 获取HRBP标记值 | ||
29 | +func (srv StaffAssessServeice) getHRBP(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) { | ||
30 | + roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
31 | + roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
32 | + _, roleList, err := roleRepo.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": companyId}) | ||
33 | + if err != nil { | ||
34 | + return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) | ||
35 | + } | ||
36 | + _, userRoleList, err := roleUserRepo.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId}) | ||
37 | + if err != nil { | ||
38 | + return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) | ||
39 | + } | ||
40 | + // 拥有HRBP权限 | ||
41 | + hrbp := -1 | ||
42 | + for _, v := range userRoleList { | ||
43 | + for _, v2 := range roleList { | ||
44 | + if v.RoleId == v2.Id { | ||
45 | + hrbp = 1 | ||
46 | + break | ||
47 | + } | ||
48 | + } | ||
49 | + if hrbp == 1 { | ||
50 | + break | ||
51 | + } | ||
52 | + } | ||
53 | + return hrbp, nil | ||
54 | +} | ||
55 | + | ||
28 | // 获取我参与过的评估任务列表 | 56 | // 获取我参与过的评估任务列表 |
29 | // func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) { | 57 | // func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) { |
30 | // transactionContext, err := factory.CreateTransactionContext(nil) | 58 | // transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -2,15 +2,17 @@ package service | @@ -2,15 +2,17 @@ package service | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/linmadan/egglib-go/core/application" | 4 | "github.com/linmadan/egglib-go/core/application" |
5 | + "github.com/linmadan/egglib-go/utils/tool_funs" | ||
5 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter" | 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter" |
7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" |
8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" |
9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
10 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" | 11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" |
12 | + "strconv" | ||
11 | ) | 13 | ) |
12 | 14 | ||
13 | -//调试用,手动调用CreateStaffAssessTask | 15 | +// 调试用,手动调用CreateStaffAssessTask |
14 | func (srv StaffAssessServeice) InvokCreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) { | 16 | func (srv StaffAssessServeice) InvokCreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) { |
15 | transactionContext, err := factory.CreateTransactionContext(nil) | 17 | transactionContext, err := factory.CreateTransactionContext(nil) |
16 | if err != nil { | 18 | if err != nil { |
@@ -42,30 +44,10 @@ func (srv StaffAssessServeice) QuerySummary(in *query.SummaryCommand) (map[strin | @@ -42,30 +44,10 @@ func (srv StaffAssessServeice) QuerySummary(in *query.SummaryCommand) (map[strin | ||
42 | transactionContext.RollbackTransaction() | 44 | transactionContext.RollbackTransaction() |
43 | }() | 45 | }() |
44 | 46 | ||
45 | - roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
46 | - roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
47 | - _, roleList, err := roleRepo.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": in.CompanyId}) | 47 | + hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId) |
48 | if err != nil { | 48 | if err != nil { |
49 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) | ||
50 | - } | ||
51 | - _, userRoleList, err := roleUserRepo.Find(map[string]interface{}{"companyId": in.CompanyId, "userId": in.OperatorId}) | ||
52 | - if err != nil { | ||
53 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) | ||
54 | - } | ||
55 | - // 拥有HRBP权限 | ||
56 | - hrbp := -1 | ||
57 | - for _, v := range userRoleList { | ||
58 | - for _, v2 := range roleList { | ||
59 | - if v.RoleId == v2.Id { | ||
60 | - hrbp = 1 | ||
61 | - break | ||
62 | - } | ||
63 | - } | ||
64 | - if hrbp == 1 { | ||
65 | - break | ||
66 | - } | 49 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
67 | } | 50 | } |
68 | - | ||
69 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext}) | 51 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext}) |
70 | data, err := assessDao.SummaryAssess(in.CompanyId, in.OperatorId, in.CycleId, in.BeginDay, hrbp) | 52 | data, err := assessDao.SummaryAssess(in.CompanyId, in.OperatorId, in.CycleId, in.BeginDay, hrbp) |
71 | if err != nil { | 53 | if err != nil { |
@@ -127,3 +109,111 @@ func (srv StaffAssessServeice) QuerySummary(in *query.SummaryCommand) (map[strin | @@ -127,3 +109,111 @@ func (srv StaffAssessServeice) QuerySummary(in *query.SummaryCommand) (map[strin | ||
127 | } | 109 | } |
128 | return map[string]interface{}{"list": []adapter.SummaryBlock{self, invite, inviteAssess, supper}}, nil | 110 | return map[string]interface{}{"list": []adapter.SummaryBlock{self, invite, inviteAssess, supper}}, nil |
129 | } | 111 | } |
112 | + | ||
113 | +func (srv StaffAssessServeice) QueryMemberSummary(in *query.MemberSummaryListCommand) (map[string]interface{}, error) { | ||
114 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
115 | + if err != nil { | ||
116 | + return nil, err | ||
117 | + } | ||
118 | + defer func() { | ||
119 | + transactionContext.RollbackTransaction() | ||
120 | + }() | ||
121 | + | ||
122 | + hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId) | ||
123 | + if err != nil { | ||
124 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
125 | + } | ||
126 | + assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext}) | ||
127 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
128 | + departmentRepository := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
129 | + positionRepository := factory.CreatePositionRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
130 | + | ||
131 | + total, list, err := assessDao.MemberSummaryList(in.UserName, in.CompanyId, in.OperatorId, in.CycleId, hrbp, in.PageNumber, in.PageSize) | ||
132 | + if err != nil { | ||
133 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
134 | + } | ||
135 | + userMap := map[int]*domain.User{} | ||
136 | + departmentMap := map[int]*domain.Department{} | ||
137 | + positionMap := map[int]*domain.Position{} | ||
138 | + | ||
139 | + userIds := make([]int, 0) | ||
140 | + for i := range list { | ||
141 | + id, _ := strconv.Atoi(list[i].TargetUserId) | ||
142 | + userIds = append(userIds, id) | ||
143 | + } | ||
144 | + if len(userIds) > 0 { | ||
145 | + _, users, err := userRepository.Find(map[string]interface{}{"ids": userIds}) | ||
146 | + if err != nil { | ||
147 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
148 | + } | ||
149 | + for i := range users { | ||
150 | + user := users[i] | ||
151 | + userMap[int(user.Id)] = user | ||
152 | + | ||
153 | + for i2 := range user.DepartmentId { | ||
154 | + departmentMap[user.DepartmentId[i2]] = nil | ||
155 | + } | ||
156 | + for i2 := range user.PositionId { | ||
157 | + positionMap[user.PositionId[i2]] = nil | ||
158 | + } | ||
159 | + } | ||
160 | + departmentIds := make([]int, 0) | ||
161 | + positionIds := make([]int, 0) | ||
162 | + for k := range departmentMap { | ||
163 | + departmentIds = append(departmentIds, k) | ||
164 | + } | ||
165 | + for k := range positionMap { | ||
166 | + positionIds = append(positionIds, k) | ||
167 | + } | ||
168 | + | ||
169 | + if len(departmentIds) > 0 { | ||
170 | + _, departments, err := departmentRepository.Find(map[string]interface{}{"ids": departmentIds}) | ||
171 | + if err != nil { | ||
172 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
173 | + } | ||
174 | + for i := range departments { | ||
175 | + departmentMap[int(departments[i].Id)] = departments[i] | ||
176 | + } | ||
177 | + } | ||
178 | + | ||
179 | + if len(positionIds) > 0 { | ||
180 | + _, positions, err := positionRepository.Find(map[string]interface{}{"ids": positionIds}) | ||
181 | + if err != nil { | ||
182 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
183 | + } | ||
184 | + for i := range positions { | ||
185 | + positionMap[int(positions[i].Id)] = positions[i] | ||
186 | + } | ||
187 | + } | ||
188 | + } | ||
189 | + | ||
190 | + adapters := make([]adapter.MemberSummaryAdapter, 0) | ||
191 | + for i := range list { | ||
192 | + it := list[i] | ||
193 | + id, _ := strconv.Atoi(it.TargetUserId) | ||
194 | + | ||
195 | + out := adapter.MemberSummaryAdapter{MemberSummaryAssess: it} | ||
196 | + if v := userMap[id]; v != nil { | ||
197 | + out.DepartmentNames = make([]string, 0) | ||
198 | + out.PositionNames = make([]string, 0) | ||
199 | + | ||
200 | + for i := range v.DepartmentId { | ||
201 | + if v := departmentMap[v.DepartmentId[i]]; v != nil { | ||
202 | + out.DepartmentNames = append(out.DepartmentNames, v.Name) | ||
203 | + } | ||
204 | + } | ||
205 | + for i := range v.PositionId { | ||
206 | + if v := positionMap[v.PositionId[i]]; v != nil { | ||
207 | + out.PositionNames = append(out.PositionNames, v.Name) | ||
208 | + } | ||
209 | + } | ||
210 | + } | ||
211 | + adapters = append(adapters, out) | ||
212 | + } | ||
213 | + | ||
214 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
215 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
216 | + } | ||
217 | + | ||
218 | + return tool_funs.SimpleWrapGridMap(int64(total), adapters), nil | ||
219 | +} |
@@ -88,38 +88,43 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs | @@ -88,38 +88,43 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs | ||
88 | _ = transactionContext.RollbackTransaction() | 88 | _ = transactionContext.RollbackTransaction() |
89 | }() | 89 | }() |
90 | 90 | ||
91 | - roleRepo := factory.CreateRoleRepository(map[string]interface{}{ | ||
92 | - "transactionContext": transactionContext, | ||
93 | - }) | ||
94 | - roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{ | ||
95 | - "transactionContext": transactionContext, | ||
96 | - }) | ||
97 | - _, roleList, err := roleRepo.Find(map[string]interface{}{ | ||
98 | - "type": domain.RoleTypeSystem, | ||
99 | - "companyId": param.CompanyId, | ||
100 | - }) | 91 | + hrbp, err := srv.getHRBP(transactionContext, param.CompanyId, param.OperaterId) |
101 | if err != nil { | 92 | if err != nil { |
102 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) | ||
103 | - } | ||
104 | - _, userRoleList, err := roleUserRepo.Find(map[string]interface{}{ | ||
105 | - "companyId": param.CompanyId, | ||
106 | - "userId": param.OperaterId, | ||
107 | - }) | ||
108 | - if err != nil { | ||
109 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) | ||
110 | - } | ||
111 | - hrbp := -1 | ||
112 | - for _, v := range userRoleList { | ||
113 | - for _, v2 := range roleList { | ||
114 | - if v.RoleId == v2.Id { | ||
115 | - hrbp = 1 | ||
116 | - break | ||
117 | - } | ||
118 | - } | ||
119 | - if hrbp == 1 { | ||
120 | - break | ||
121 | - } | 93 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
122 | } | 94 | } |
95 | + | ||
96 | + //roleRepo := factory.CreateRoleRepository(map[string]interface{}{ | ||
97 | + // "transactionContext": transactionContext, | ||
98 | + //}) | ||
99 | + //roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{ | ||
100 | + // "transactionContext": transactionContext, | ||
101 | + //}) | ||
102 | + //_, roleList, err := roleRepo.Find(map[string]interface{}{ | ||
103 | + // "type": domain.RoleTypeSystem, | ||
104 | + // "companyId": param.CompanyId, | ||
105 | + //}) | ||
106 | + //if err != nil { | ||
107 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) | ||
108 | + //} | ||
109 | + //_, userRoleList, err := roleUserRepo.Find(map[string]interface{}{ | ||
110 | + // "companyId": param.CompanyId, | ||
111 | + // "userId": param.OperaterId, | ||
112 | + //}) | ||
113 | + //if err != nil { | ||
114 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) | ||
115 | + //} | ||
116 | + //hrbp := -1 | ||
117 | + //for _, v := range userRoleList { | ||
118 | + // for _, v2 := range roleList { | ||
119 | + // if v.RoleId == v2.Id { | ||
120 | + // hrbp = 1 | ||
121 | + // break | ||
122 | + // } | ||
123 | + // } | ||
124 | + // if hrbp == 1 { | ||
125 | + // break | ||
126 | + // } | ||
127 | + //} | ||
123 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{ | 128 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{ |
124 | "transactionContext": transactionContext, | 129 | "transactionContext": transactionContext, |
125 | }) | 130 | }) |
@@ -225,38 +230,42 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy | @@ -225,38 +230,42 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy | ||
225 | _ = transactionContext.RollbackTransaction() | 230 | _ = transactionContext.RollbackTransaction() |
226 | }() | 231 | }() |
227 | 232 | ||
228 | - roleRepo := factory.CreateRoleRepository(map[string]interface{}{ | ||
229 | - "transactionContext": transactionContext, | ||
230 | - }) | ||
231 | - roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{ | ||
232 | - "transactionContext": transactionContext, | ||
233 | - }) | ||
234 | - _, roleList, err := roleRepo.Find(map[string]interface{}{ | ||
235 | - "type": domain.RoleTypeSystem, | ||
236 | - "companyId": param.CompanyId, | ||
237 | - }) | 233 | + hrbp, err := srv.getHRBP(transactionContext, param.CompanyId, param.OperaterId) |
238 | if err != nil { | 234 | if err != nil { |
239 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) | ||
240 | - } | ||
241 | - _, userRoleList, err := roleUserRepo.Find(map[string]interface{}{ | ||
242 | - "companyId": param.CompanyId, | ||
243 | - "userId": param.OperaterId, | ||
244 | - }) | ||
245 | - if err != nil { | ||
246 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) | ||
247 | - } | ||
248 | - hrbp := -1 | ||
249 | - for _, v := range userRoleList { | ||
250 | - for _, v2 := range roleList { | ||
251 | - if v.RoleId == v2.Id { | ||
252 | - hrbp = 1 | ||
253 | - break | ||
254 | - } | ||
255 | - } | ||
256 | - if hrbp == 1 { | ||
257 | - break | ||
258 | - } | 235 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
259 | } | 236 | } |
237 | + //roleRepo := factory.CreateRoleRepository(map[string]interface{}{ | ||
238 | + // "transactionContext": transactionContext, | ||
239 | + //}) | ||
240 | + //roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{ | ||
241 | + // "transactionContext": transactionContext, | ||
242 | + //}) | ||
243 | + //_, roleList, err := roleRepo.Find(map[string]interface{}{ | ||
244 | + // "type": domain.RoleTypeSystem, | ||
245 | + // "companyId": param.CompanyId, | ||
246 | + //}) | ||
247 | + //if err != nil { | ||
248 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) | ||
249 | + //} | ||
250 | + //_, userRoleList, err := roleUserRepo.Find(map[string]interface{}{ | ||
251 | + // "companyId": param.CompanyId, | ||
252 | + // "userId": param.OperaterId, | ||
253 | + //}) | ||
254 | + //if err != nil { | ||
255 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) | ||
256 | + //} | ||
257 | + //hrbp := -1 | ||
258 | + //for _, v := range userRoleList { | ||
259 | + // for _, v2 := range roleList { | ||
260 | + // if v.RoleId == v2.Id { | ||
261 | + // hrbp = 1 | ||
262 | + // break | ||
263 | + // } | ||
264 | + // } | ||
265 | + // if hrbp == 1 { | ||
266 | + // break | ||
267 | + // } | ||
268 | + //} | ||
260 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{ | 269 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{ |
261 | "transactionContext": transactionContext, | 270 | "transactionContext": transactionContext, |
262 | }) | 271 | }) |
@@ -457,38 +466,42 @@ func (srv StaffAssessServeice) AnalysisData(param *query.ListAssessContentCycleD | @@ -457,38 +466,42 @@ func (srv StaffAssessServeice) AnalysisData(param *query.ListAssessContentCycleD | ||
457 | _ = transactionContext.RollbackTransaction() | 466 | _ = transactionContext.RollbackTransaction() |
458 | }() | 467 | }() |
459 | 468 | ||
460 | - roleRepo := factory.CreateRoleRepository(map[string]interface{}{ | ||
461 | - "transactionContext": transactionContext, | ||
462 | - }) | ||
463 | - roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{ | ||
464 | - "transactionContext": transactionContext, | ||
465 | - }) | ||
466 | - _, roleList, err := roleRepo.Find(map[string]interface{}{ | ||
467 | - "type": domain.RoleTypeSystem, | ||
468 | - "companyId": param.CompanyId, | ||
469 | - }) | ||
470 | - if err != nil { | ||
471 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) | ||
472 | - } | ||
473 | - _, userRoleList, err := roleUserRepo.Find(map[string]interface{}{ | ||
474 | - "companyId": param.CompanyId, | ||
475 | - "userId": param.OperaterId, | ||
476 | - }) | 469 | + hrbp, err := srv.getHRBP(transactionContext, param.CompanyId, param.OperaterId) |
477 | if err != nil { | 470 | if err != nil { |
478 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) | ||
479 | - } | ||
480 | - hrbp := -1 | ||
481 | - for _, v := range userRoleList { | ||
482 | - for _, v2 := range roleList { | ||
483 | - if v.RoleId == v2.Id { | ||
484 | - hrbp = 1 | ||
485 | - break | ||
486 | - } | ||
487 | - } | ||
488 | - if hrbp == 1 { | ||
489 | - break | ||
490 | - } | 471 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
491 | } | 472 | } |
473 | + //roleRepo := factory.CreateRoleRepository(map[string]interface{}{ | ||
474 | + // "transactionContext": transactionContext, | ||
475 | + //}) | ||
476 | + //roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{ | ||
477 | + // "transactionContext": transactionContext, | ||
478 | + //}) | ||
479 | + //_, roleList, err := roleRepo.Find(map[string]interface{}{ | ||
480 | + // "type": domain.RoleTypeSystem, | ||
481 | + // "companyId": param.CompanyId, | ||
482 | + //}) | ||
483 | + //if err != nil { | ||
484 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) | ||
485 | + //} | ||
486 | + //_, userRoleList, err := roleUserRepo.Find(map[string]interface{}{ | ||
487 | + // "companyId": param.CompanyId, | ||
488 | + // "userId": param.OperaterId, | ||
489 | + //}) | ||
490 | + //if err != nil { | ||
491 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) | ||
492 | + //} | ||
493 | + //hrbp := -1 | ||
494 | + //for _, v := range userRoleList { | ||
495 | + // for _, v2 := range roleList { | ||
496 | + // if v.RoleId == v2.Id { | ||
497 | + // hrbp = 1 | ||
498 | + // break | ||
499 | + // } | ||
500 | + // } | ||
501 | + // if hrbp == 1 { | ||
502 | + // break | ||
503 | + // } | ||
504 | + //} | ||
492 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{ | 505 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{ |
493 | "transactionContext": transactionContext, | 506 | "transactionContext": transactionContext, |
494 | }) | 507 | }) |
@@ -502,6 +502,156 @@ func (d *StaffAssessDao) SummaryAssess(companyId int, operatorId int, cycleId in | @@ -502,6 +502,156 @@ func (d *StaffAssessDao) SummaryAssess(companyId int, operatorId int, cycleId in | ||
502 | return result, err | 502 | return result, err |
503 | } | 503 | } |
504 | 504 | ||
505 | +type MemberSummaryAssess struct { | ||
506 | + TargetUserId string `json:"targetUserId"` // 被评估人的id | ||
507 | + TargetUserName string `json:"targetUserName"` // 被评估人名称 | ||
508 | + SelfCompleted int `json:"selfCompleted"` // 自评完成数量 | ||
509 | + SupperCompleted int `json:"supperCompleted"` // 上级评价完成数量 | ||
510 | + InviteCompleted int `json:"inviteCompleted"` // 邀请完成数量 | ||
511 | + InviteTotal int `json:"inviteTotal"` // 邀请总数 | ||
512 | +} | ||
513 | + | ||
514 | +func (d *StaffAssessDao) MemberSummaryList(likeUserName string, companyId int, operatorId int, cycleId int, hrbp int, pageNumber int, pageSize int) (int, []MemberSummaryAssess, error) { | ||
515 | + limit := pageSize | ||
516 | + if limit < 0 { | ||
517 | + limit = 20 | ||
518 | + } | ||
519 | + offset := limit * (pageNumber - 1) | ||
520 | + if offset < 0 { | ||
521 | + offset = 0 | ||
522 | + } | ||
523 | + | ||
524 | + sqlString := ` | ||
525 | + set time zone 'PRC'; | ||
526 | + with t_user_department as ( | ||
527 | + select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user" | ||
528 | + where "user".company_id= %d and "user".deleted_at isnull | ||
529 | + ), | ||
530 | + t_department as ( | ||
531 | + select department.id::text as depart_id from department where charge_user_ids @>'[%d]' | ||
532 | + and "department".deleted_at isnull | ||
533 | + ), | ||
534 | + -- 部门主管(所有下级用户ID) | ||
535 | + t_user_1 as ( | ||
536 | + select t_user_department.user_id::text from t_user_department | ||
537 | + join t_department on t_user_department.depart_id = t_department.depart_id | ||
538 | + ), | ||
539 | + -- 如果是HRBP | ||
540 | + t_project_1 as( | ||
541 | + select evaluation_project.id as project_id | ||
542 | + from evaluation_project | ||
543 | + where evaluation_project.cycle_id =%d | ||
544 | + and evaluation_project.hr_bp = %d | ||
545 | + and evaluation_project.deleted_at isnull | ||
546 | + ), | ||
547 | + -- 如果的项目管理员 | ||
548 | + t_project_2 as( | ||
549 | + select evaluation_project.id as project_id | ||
550 | + from evaluation_project | ||
551 | + where evaluation_project.cycle_id =%d | ||
552 | + and evaluation_project.pmp =1 | ||
553 | + and evaluation_project.pmp_ids @>'["%d"]' | ||
554 | + and evaluation_project.deleted_at isnull | ||
555 | + ), | ||
556 | + -- 合并数据 | ||
557 | + t_project_3 as ( | ||
558 | + select t_project_2.project_id from t_project_2 | ||
559 | + union | ||
560 | + select t_project_1.project_id from t_project_1 | ||
561 | + ), | ||
562 | + -- 初步过滤数据 | ||
563 | + t_staff_assess_0 as ( | ||
564 | + select | ||
565 | + staff_assess.id as assess_id, | ||
566 | + staff_assess.cycle_id, | ||
567 | + staff_assess.target_user->>'userId' as target_user_id, | ||
568 | + staff_assess.target_user->>'userName' as target_user_name, | ||
569 | + staff_assess.evaluation_project_id, | ||
570 | + staff_assess.types, | ||
571 | + staff_assess.status | ||
572 | + from staff_assess | ||
573 | + join staff_assess_task on staff_assess.staff_assess_task_id = staff_assess_task.id | ||
574 | + and staff_assess_task.deleted_at isnull | ||
575 | + where staff_assess.cycle_id = %d | ||
576 | + ), | ||
577 | + -- 根据查看权限过滤合并数据 | ||
578 | + merge_assess as ( | ||
579 | + ( select | ||
580 | + t_staff_assess_0.assess_id, | ||
581 | + t_staff_assess_0.target_user_id, | ||
582 | + t_staff_assess_0.target_user_name, | ||
583 | + t_staff_assess_0.cycle_id, | ||
584 | + t_staff_assess_0.evaluation_project_id, | ||
585 | + t_staff_assess_0.types, | ||
586 | + t_staff_assess_0.status | ||
587 | + from t_staff_assess_0 | ||
588 | + join t_project_3 on t_staff_assess_0.evaluation_project_id = t_project_3.project_id | ||
589 | + ) union | ||
590 | + ( select | ||
591 | + t_staff_assess_0.assess_id, | ||
592 | + t_staff_assess_0.target_user_id, | ||
593 | + t_staff_assess_0.target_user_name, | ||
594 | + t_staff_assess_0.cycle_id, | ||
595 | + t_staff_assess_0.evaluation_project_id, | ||
596 | + t_staff_assess_0.types, | ||
597 | + t_staff_assess_0.status | ||
598 | + from t_staff_assess_0 | ||
599 | + join t_user_1 on t_staff_assess_0.target_user_id = t_user_1.user_id | ||
600 | + ) | ||
601 | + ) | ||
602 | + ` | ||
603 | + params := []interface{}{companyId, operatorId, cycleId, hrbp, cycleId, operatorId, cycleId} | ||
604 | + // 筛选结果的所有评估数据 | ||
605 | + sqlString = fmt.Sprintf(sqlString, params...) | ||
606 | + | ||
607 | + // 根据用户ID进行分组 | ||
608 | + groupString := ` | ||
609 | + SELECT | ||
610 | + merge_assess.target_user_id, | ||
611 | + merge_assess.target_user_name, | ||
612 | + SUM ( CASE WHEN merge_assess.types = 'self' AND merge_assess.status = 'completed' THEN 1 ELSE 0 END ) AS self_completed, | ||
613 | + SUM ( CASE WHEN merge_assess.types = 'supper' AND merge_assess.status = 'completed' THEN 1 ELSE 0 END ) AS supper_completed, | ||
614 | + SUM ( CASE WHEN ( merge_assess.types = 'invite_diff_super' OR merge_assess.types = 'invite_same_super' ) AND merge_assess.status = 'completed' THEN 1 ELSE 0 END ) AS invite_completed, | ||
615 | + SUM ( CASE WHEN merge_assess.types = 'invite_diff_super' OR merge_assess.types = 'invite_same_super' THEN 1 ELSE 0 END ) AS invite_total | ||
616 | + ` | ||
617 | + whereFrom := ` | ||
618 | + FROM | ||
619 | + merge_assess | ||
620 | + WHERE 1=1 | ||
621 | + ` | ||
622 | + if len(likeUserName) > 0 { | ||
623 | + whereFrom += fmt.Sprintf(" AND merge_assess.target_user_name LIKE '%s'", "%"+likeUserName+"%") | ||
624 | + } | ||
625 | + groupBy := ` | ||
626 | + GROUP BY | ||
627 | + merge_assess.target_user_id, | ||
628 | + merge_assess.target_user_name | ||
629 | + ORDER BY | ||
630 | + convert_to( merge_assess.target_user_name, 'GBK' ) | ||
631 | + ` | ||
632 | + groupString += whereFrom | ||
633 | + groupString += groupBy | ||
634 | + groupString = fmt.Sprintf("%s limit %d offset %d", groupString, limit, offset) | ||
635 | + | ||
636 | + // 查询所有目标用户数量 | ||
637 | + countSql := ` SELECT COUNT ( DISTINCT merge_assess.target_user_id ) ` + whereFrom | ||
638 | + | ||
639 | + tx := d.transactionContext.PgTx | ||
640 | + var result = make([]MemberSummaryAssess, 0) | ||
641 | + _, err := tx.Query(&result, sqlString+groupString) | ||
642 | + if err != nil { | ||
643 | + return 0, result, err | ||
644 | + } | ||
645 | + | ||
646 | + var total int // 获取总数量 | ||
647 | + _, err = tx.QueryOne(pg.Scan(&total), sqlString+countSql) | ||
648 | + if err != nil { | ||
649 | + return 0, result, err | ||
650 | + } | ||
651 | + | ||
652 | + return total, result, err | ||
653 | +} | ||
654 | + | ||
505 | type ExportData1 struct { | 655 | type ExportData1 struct { |
506 | AssessId string | 656 | AssessId string |
507 | ContentId int | 657 | ContentId int |
@@ -359,7 +359,7 @@ func (c *StaffAssessController) SaveAssessCache() { | @@ -359,7 +359,7 @@ func (c *StaffAssessController) SaveAssessCache() { | ||
359 | } | 359 | } |
360 | } | 360 | } |
361 | 361 | ||
362 | -// QuerySummary 项目管理-查询总览 | 362 | +// QuerySummary 员工绩效-项目管理-查询总览 |
363 | func (c *StaffAssessController) QuerySummary() { | 363 | func (c *StaffAssessController) QuerySummary() { |
364 | srv := service.NewStaffAssessServeice() | 364 | srv := service.NewStaffAssessServeice() |
365 | in := &query.SummaryCommand{} | 365 | in := &query.SummaryCommand{} |
@@ -374,6 +374,21 @@ func (c *StaffAssessController) QuerySummary() { | @@ -374,6 +374,21 @@ func (c *StaffAssessController) QuerySummary() { | ||
374 | } | 374 | } |
375 | } | 375 | } |
376 | 376 | ||
377 | +// QueryMemberSummary 员工绩效-综合管理-成员列表统计 | ||
378 | +func (c *StaffAssessController) QueryMemberSummary() { | ||
379 | + srv := service.NewStaffAssessServeice() | ||
380 | + in := &query.MemberSummaryListCommand{} | ||
381 | + if err := c.Unmarshal(in); err != nil { | ||
382 | + c.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
383 | + } else { | ||
384 | + if user := middlewares.GetUser(c.Ctx); user != nil { | ||
385 | + in.CompanyId = int(user.CompanyId) | ||
386 | + in.OperatorId = int(user.UserId) | ||
387 | + } | ||
388 | + c.Response(srv.QueryMemberSummary(in)) | ||
389 | + } | ||
390 | +} | ||
391 | + | ||
377 | // 员工绩效-项目管理-矩阵分析 | 392 | // 员工绩效-项目管理-矩阵分析 |
378 | func (c *StaffAssessController) AnalysisData() { | 393 | func (c *StaffAssessController) AnalysisData() { |
379 | srv := service.NewStaffAssessServeice() | 394 | srv := service.NewStaffAssessServeice() |
@@ -29,10 +29,11 @@ func init() { | @@ -29,10 +29,11 @@ func init() { | ||
29 | web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工 | 29 | web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工 |
30 | //web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessController).ListMeInviteUserAssess), //我要执行的360评估的用户列表 | 30 | //web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessController).ListMeInviteUserAssess), //我要执行的360评估的用户列表 |
31 | //web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessController).ListMeSupperAssess), //我要执行的360评估的用户列表 | 31 | //web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessController).ListMeSupperAssess), //我要执行的360评估的用户列表 |
32 | - web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情 | ||
33 | - web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情 | ||
34 | - web.NSCtrlPut("/info-cache", (*controllers.StaffAssessController).SaveAssessCache), //通用保存员工评估的详情(缓存) | ||
35 | - web.NSCtrlPost("/summary", (*controllers.StaffAssessController).QuerySummary), //项目管理-总览 | 32 | + web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情 |
33 | + web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情 | ||
34 | + web.NSCtrlPut("/info-cache", (*controllers.StaffAssessController).SaveAssessCache), //通用保存员工评估的详情(缓存) | ||
35 | + web.NSCtrlPost("/summary", (*controllers.StaffAssessController).QuerySummary), //员工绩效-项目管理-总览 | ||
36 | + web.NSCtrlPost("/summary/users", (*controllers.StaffAssessController).QueryMemberSummary), //员工绩效-综合管理-成员列表 | ||
36 | // web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工360评估的列表 | 37 | // web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工360评估的列表 |
37 | //web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessController).ListTargetUserMeSupperAssess), //获取我被上级评估的列表 | 38 | //web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessController).ListTargetUserMeSupperAssess), //获取我被上级评估的列表 |
38 | // web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情 | 39 | // web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情 |
-
请 注册 或 登录 后发表评论