staff_assess_controller.go
12.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
package controllers
import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/service"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
)
type StaffAssessController struct {
beego.BaseController
}
// 获取个人的自评反馈历史记录列表
func (c *StaffAssessController) AssessSelfMeList() {
srv := service.NewStaffAssessServeice()
paramReq := &query.AssessSelfListQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.AssessSelfList(paramReq)
c.Response(data, err)
}
// 更具项目评估的配置,创建员工的评估任务,(调试用)
func (c *StaffAssessController) CreateStaffAssessTask() {
srv := service.NewStaffAssessServeice()
paramReq := &command.CreateStaffAssessTask{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
//服务调用,实际由定时任务触发
data, err := srv.InvokCreateStaffAssessTask(paramReq)
c.Response(data, err)
}
// 保存我邀请的员工
func (c *StaffAssessController) SaveAssessMeInviteUser() {
srv := service.NewStaffAssessServeice()
paramReq := &command.SaveAssessInvite{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
//TODO 获取当前用户信息
// paramReq.CompanyId = 1
// paramReq.UserId = 1
userReq := middlewares.GetUser(c.Ctx)
paramReq.TargetUserId = int(userReq.UserId)
data, err := srv.SaveAssessInviteUser(paramReq)
c.Response(data, err)
}
// 员工邀请的人选择列表
func (c *StaffAssessController) SelectAssessInviteUser() {
srv := service.NewStaffAssessServeice()
paramReq := &query.SelectAssessInviteUser{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.TargetUserId = int(userReq.UserId)
data, err := srv.SelectAssessInviteUserV2(paramReq)
c.Response(data, err)
}
// 获取评估内容详情
func (c *StaffAssessController) GetAssessInfo() {
srv := service.NewStaffAssessServeice()
paramReq := &query.AssessInfoQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
// paramReq.CompanyId = 1
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.GetAssessInfo(paramReq)
c.Response(data, err)
}
// 保存评估内容详情
func (c *StaffAssessController) SaveAssessInfo() {
srv := service.NewStaffAssessServeice()
paramReq := &command.SaveAssessInfoCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.ExecutorId = int(userReq.UserId)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.SaveAssessInfo(paramReq)
c.Response(data, err)
}
// 获取周期列表
func (c *StaffAssessController) ListAssessCycle() {
srv := service.NewStaffAssessServeice()
userReq := middlewares.GetUser(c.Ctx)
data, err := srv.ListAllAssessCycle(int(userReq.CompanyId))
c.Response(data, err)
}
// 获取周期里的考核日期
func (c *StaffAssessController) ListAssessCycleDay() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListAssessCycleDay{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.ListAllAssessCycleDay(paramReq)
c.Response(data, err)
}
// 根据周期里的考核日期,获取员工填写评估内容列表
func (c *StaffAssessController) ListAssessContentCycleDay() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListAssessContentCycleDay{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.OperaterId = int(userReq.UserId)
data, err := srv.ListUserAssessContentCycleDay(paramReq)
c.Response(data, err)
}
// 根据周期里的考核日期,获取员工填写评估内容列表的评估项
func (c *StaffAssessController) ListAssessContentIndicator() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListAssessContentCycleDay{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.OperaterId = int(userReq.UserId)
data, err := srv.QueryPerformanceIndicator(paramReq)
c.Response(data, err)
}
// 根据周期里的考核日期,获取员工填写评估内容列表,导出为xlsx文件
func (c *StaffAssessController) ExportAssessContentCycleDay() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ExportAssessContentCycleDay{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.OperaterId = int(userReq.UserId)
data, err := srv.ExportUserAssess(paramReq)
if err != nil {
c.Response(nil, err)
return
}
c.Ctx.Output.Header("Content-Disposition", "attachment;filename=每日绩效汇总")
c.Ctx.Output.Header("Content-Description", "FileTransfer")
c.Ctx.Output.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
c.Ctx.Output.Header("Content-Transfer-Encoding", "binary")
c.Ctx.Output.Header("Expires", "0")
data.Write(c.Ctx.ResponseWriter)
}
// SaveAssessCache 保存评估内容(缓存)
func (c *StaffAssessController) SaveAssessCache() {
cacheService := service.NewStaffAssessCacheService()
in := &command.SaveAssessCacheCommand{}
if err := c.Unmarshal(in); err != nil {
c.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
} else {
c.Response(cacheService.SaveAssessCache(in))
}
}
// QuerySummary 员工绩效-项目管理-查询总览
func (c *StaffAssessController) QuerySummary() {
srv := service.NewStaffAssessServeice()
in := &query.SummaryCommand{}
if err := c.Unmarshal(in); err != nil {
c.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
} else {
if user := middlewares.GetUser(c.Ctx); user != nil {
in.CompanyId = int(user.CompanyId)
in.OperatorId = int(user.UserId)
}
c.Response(srv.QuerySummary(in))
}
}
// QueryMemberSummary 员工绩效-综合管理-成员列表统计
func (c *StaffAssessController) QueryMemberSummary() {
srv := service.NewStaffAssessServeice()
in := &query.MemberSummaryListCommand{}
if err := c.Unmarshal(in); err != nil {
c.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
} else {
if user := middlewares.GetUser(c.Ctx); user != nil {
in.CompanyId = int(user.CompanyId)
in.OperatorId = int(user.UserId)
}
c.Response(srv.QueryMemberSummary(in))
}
}
// QueryMemberPerformanceIndicator 员工绩效-综合管理-绩效导出指标
func (c *StaffAssessController) QueryMemberPerformanceIndicator() {
srv := service.NewStaffAssessServeice()
in := &query.MemberPerformanceIndicatorCommand{}
if err := c.Unmarshal(in); err != nil {
c.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
} else {
if user := middlewares.GetUser(c.Ctx); user != nil {
in.CompanyId = int(user.CompanyId)
in.OperatorId = int(user.UserId)
}
c.Response(srv.QueryMemberPerformanceIndicator(in))
}
}
// ExportPerformanceIndicator 导出表格-员工绩效-综合管理-绩效导出指标-
func (c *StaffAssessController) ExportPerformanceIndicator() {
srv := service.NewStaffAssessServeice()
in := &query.ExportPerformanceIndicatorCommand{}
if err := c.Unmarshal(in); err != nil {
c.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
} else {
if user := middlewares.GetUser(c.Ctx); user != nil {
in.CompanyId = int(user.CompanyId)
in.OperatorId = int(user.UserId)
}
f, err := srv.ExportPerformanceIndicator(in)
if err != nil {
c.Response(nil, err)
return
}
fileName := "个人绩效指标"
c.Ctx.Output.Header("Content-Disposition", "attachment;filename="+fileName)
c.Ctx.Output.Header("Content-Description", "FileTransfer")
c.Ctx.Output.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
c.Ctx.Output.Header("Content-Transfer-Encoding", "binary")
c.Ctx.Output.Header("Expires", "0")
f.Write(c.Ctx.ResponseWriter)
}
}
// 员工绩效-项目管理-矩阵分析
func (c *StaffAssessController) AnalysisData() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListAssessContentCycleDay{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.OperaterId = int(userReq.UserId)
data, err := srv.AnalysisData(paramReq)
c.Response(data, err)
}
// 根据周期里的考核日期,获取员工填写评估内容列表,导出为xlsx文件
func (c *StaffAssessController) ExportUserAssess2() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ExportUserAssess2Commad{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
if len(paramReq.ExportUserId) == 0 {
e := application.ThrowError(application.ARG_ERROR, "请选择人员进行绩效下载")
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.OperatorId = int(userReq.UserId)
data, err := srv.ExportUserAssess2V2(paramReq)
if err != nil {
c.Response(nil, err)
return
}
fileName := "个人绩效评估等级统计表"
c.Ctx.Output.Header("Content-Disposition", "attachment;filename="+fileName)
c.Ctx.Output.Header("Content-Description", "FileTransfer")
c.Ctx.Output.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
c.Ctx.Output.Header("Content-Transfer-Encoding", "binary")
c.Ctx.Output.Header("Expires", "0")
data.Write(c.Ctx.ResponseWriter)
}
// ListTargetUserSelfCycle 获取目标员工自评周期列表
func (c *StaffAssessController) ListTargetUserSelfCycle() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListTargetUserCycleQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.ListTargetUserSelfCycle(paramReq)
c.Response(data, err)
}
// ListTargetUserSelfCycle 按照周期获取员工的每日自评小结
func (c *StaffAssessController) GetStaffAsessSelfCountLevel() {
srv := service.NewStaffAssessServeice()
paramReq := &query.StaffAsessSelfCountLevel{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.GetStaffAsessSelfCountLevel(paramReq)
c.Response(data, err)
}
// 获取未完成评估任务的执行人员名单
func (c *StaffAssessController) ListExcutorUncompleted() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListExecutorQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.ListExcutorUncompleted(paramReq)
c.Response(data, err)
}