|
|
1
|
+package service
|
|
|
2
|
+
|
|
|
3
|
+import (
|
|
|
4
|
+ "fmt"
|
|
|
5
|
+ "strconv"
|
|
|
6
|
+ "time"
|
|
|
7
|
+
|
|
|
8
|
+ "github.com/linmadan/egglib-go/core/application"
|
|
|
9
|
+ "github.com/linmadan/egglib-go/utils/tool_funs"
|
|
|
10
|
+ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
|
|
11
|
+ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter"
|
|
|
12
|
+ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
|
|
|
13
|
+ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
|
|
|
14
|
+ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
15
|
+ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
|
|
|
16
|
+)
|
|
|
17
|
+
|
|
|
18
|
+// 员工评绩效评估
|
|
|
19
|
+type StaffAssessServeice struct {
|
|
|
20
|
+}
|
|
|
21
|
+
|
|
|
22
|
+func NewStaffAssessServeice() *StaffAssessServeice {
|
|
|
23
|
+ newService := &StaffAssessServeice{}
|
|
|
24
|
+ return newService
|
|
|
25
|
+}
|
|
|
26
|
+
|
|
|
27
|
+// 获取我参与过的评估任务列表
|
|
|
28
|
+func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) {
|
|
|
29
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
30
|
+ if err != nil {
|
|
|
31
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
32
|
+ }
|
|
|
33
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
34
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
35
|
+ }
|
|
|
36
|
+ defer func() {
|
|
|
37
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
38
|
+ }()
|
|
|
39
|
+ staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
40
|
+ "transactionContext": transactionContext,
|
|
|
41
|
+ })
|
|
|
42
|
+ var limit int = 20
|
|
|
43
|
+ var offset int = 0
|
|
|
44
|
+ if param.PageSize > 0 {
|
|
|
45
|
+ limit = param.PageSize
|
|
|
46
|
+ }
|
|
|
47
|
+ offset = (param.PageNumber - 1) * param.PageSize
|
|
|
48
|
+ condition := map[string]interface{}{
|
|
|
49
|
+ "executorId": param.UserId,
|
|
|
50
|
+ "companyId": param.CompanyId,
|
|
|
51
|
+ "limit": limit,
|
|
|
52
|
+ }
|
|
|
53
|
+ if offset > 0 {
|
|
|
54
|
+ condition["offset"] = offset
|
|
|
55
|
+ }
|
|
|
56
|
+ cnt, assessTaskList, err := staffAssessTaskRepo.Find(condition)
|
|
|
57
|
+ if err != nil {
|
|
|
58
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询周期"+err.Error())
|
|
|
59
|
+ }
|
|
|
60
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
61
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
62
|
+ }
|
|
|
63
|
+ listData := make([]adapter.SearchAssessMeResp, 0, len(assessTaskList))
|
|
|
64
|
+ var temp adapter.SearchAssessMeResp
|
|
|
65
|
+ for _, v := range assessTaskList {
|
|
|
66
|
+ temp = adapter.SearchAssessMeResp{
|
|
|
67
|
+ AssessTaskId: v.Id,
|
|
|
68
|
+ BeginTime: v.BeginTime.Format("2006-01-02 15:04:05"),
|
|
|
69
|
+ EndTime: v.EndTime.Format("2006-01-02 15:04:05"),
|
|
|
70
|
+ CycleId: v.CycleId,
|
|
|
71
|
+ CycleName: v.CycleName,
|
|
|
72
|
+ EvaluationProjectId: v.EvaluationProjectId,
|
|
|
73
|
+ EvaluationProjectName: v.EvaluationProjectName,
|
|
|
74
|
+ }
|
|
|
75
|
+ listData = append(listData, temp)
|
|
|
76
|
+ }
|
|
|
77
|
+ return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
|
|
|
78
|
+}
|
|
|
79
|
+
|
|
|
80
|
+// 获取项目评估进度描述
|
|
|
81
|
+func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) (*adapter.AssessTaskDescResp, error) {
|
|
|
82
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
83
|
+ if err != nil {
|
|
|
84
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
85
|
+ }
|
|
|
86
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
87
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
88
|
+ }
|
|
|
89
|
+ defer func() {
|
|
|
90
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
91
|
+ }()
|
|
|
92
|
+ // 获取评估任务
|
|
|
93
|
+ staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
94
|
+ "transactionContext": transactionContext,
|
|
|
95
|
+ })
|
|
|
96
|
+ //获取个人参与的评估流程
|
|
|
97
|
+ staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
98
|
+ "transactionContext": transactionContext,
|
|
|
99
|
+ })
|
|
|
100
|
+ assessTaskData, err := staffAssessTaskRepo.FindOne(map[string]interface{}{
|
|
|
101
|
+ "id": param.AssessTaskId,
|
|
|
102
|
+ })
|
|
|
103
|
+ if err != nil {
|
|
|
104
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error())
|
|
|
105
|
+ }
|
|
|
106
|
+ //返回的数据结果
|
|
|
107
|
+ result := adapter.AssessTaskDescResp{
|
|
|
108
|
+ AssessTaskId: assessTaskData.Id,
|
|
|
109
|
+ EvaluationProjectId: assessTaskData.EvaluationProjectId,
|
|
|
110
|
+ EvaluationProjectName: assessTaskData.EvaluationProjectName,
|
|
|
111
|
+ CycleName: assessTaskData.CycleName,
|
|
|
112
|
+ BeginTime: assessTaskData.BeginTime.Local().Format("2006-01-02 15:04-05"),
|
|
|
113
|
+ EndTime: assessTaskData.EndTime.Local().Format("2006-01-02 15:04-05"),
|
|
|
114
|
+ StepList: []adapter.AssessTaskStep{},
|
|
|
115
|
+ }
|
|
|
116
|
+
|
|
|
117
|
+ for _, v := range assessTaskData.StepList {
|
|
|
118
|
+ stepItem := adapter.AssessTaskStep{
|
|
|
119
|
+ SortBy: v.SortBy,
|
|
|
120
|
+ LinkNodeName: v.LinkNodeName,
|
|
|
121
|
+ BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
122
|
+ EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
123
|
+ LinkNodeType: v.LinkNodeType,
|
|
|
124
|
+ Desc: fmt.Sprintf("截止日期:%s", v.EndTime.Local().Format("2006-01-02 15:04:05")),
|
|
|
125
|
+ Status: "",
|
|
|
126
|
+ }
|
|
|
127
|
+ switch v.LinkNodeType {
|
|
|
128
|
+ case domain.LinkNodeSelfAssessment:
|
|
|
129
|
+ //个人自评完成情况
|
|
|
130
|
+ _, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{
|
|
|
131
|
+ "staffAssessTaskId": assessTaskData.Id,
|
|
|
132
|
+ "executorId": param.UserId,
|
|
|
133
|
+ "typesList": []string{string(domain.AssessSelf)},
|
|
|
134
|
+ })
|
|
|
135
|
+ if err != nil {
|
|
|
136
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
|
|
|
137
|
+ }
|
|
|
138
|
+ if len(assessSelfData) > 0 {
|
|
|
139
|
+ stepItem.Status = string(assessSelfData[0].Status)
|
|
|
140
|
+ }
|
|
|
141
|
+ stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
|
|
|
142
|
+ case domain.LinkNodeAllInvite:
|
|
|
143
|
+ //邀请别人评估自己
|
|
|
144
|
+ _, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{
|
|
|
145
|
+ "staffAssessTaskId": assessTaskData.Id,
|
|
|
146
|
+ "targetUserId": param.UserId,
|
|
|
147
|
+ "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
|
|
|
148
|
+ "limit": 5,
|
|
|
149
|
+ })
|
|
|
150
|
+ if err != nil {
|
|
|
151
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
|
|
|
152
|
+ }
|
|
|
153
|
+ //待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可
|
|
|
154
|
+ if len(assessInviteData) > 5 {
|
|
|
155
|
+ stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
|
|
|
156
|
+ stepItem.Status = string(domain.StaffAssessCompleted)
|
|
|
157
|
+ } else {
|
|
|
158
|
+ stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData))
|
|
|
159
|
+ stepItem.Status = string(domain.StaffAssessUncompleted)
|
|
|
160
|
+ }
|
|
|
161
|
+ case domain.LinkNodeAllAssessment:
|
|
|
162
|
+ //我评估别人,被邀请评估
|
|
|
163
|
+ _, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{
|
|
|
164
|
+ "staffAssessTaskId": assessTaskData.Id,
|
|
|
165
|
+ "executorId": param.UserId,
|
|
|
166
|
+ "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
|
|
|
167
|
+ })
|
|
|
168
|
+ if err != nil {
|
|
|
169
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
|
|
|
170
|
+ }
|
|
|
171
|
+
|
|
|
172
|
+ if len(assessInviteList) > 0 {
|
|
|
173
|
+ stepItem.Status = string(domain.StaffAssessCompleted)
|
|
|
174
|
+ stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
|
|
|
175
|
+ for _, v := range assessInviteList {
|
|
|
176
|
+ if v.Status == domain.StaffAssessUncompleted {
|
|
|
177
|
+ stepItem.Status = string(domain.StaffAssessUncompleted)
|
|
|
178
|
+ break
|
|
|
179
|
+ }
|
|
|
180
|
+ }
|
|
|
181
|
+ }
|
|
|
182
|
+ case domain.LinkNodeSuperiorAssessment:
|
|
|
183
|
+ //我评估别人,上级评估
|
|
|
184
|
+ _, assessSupperList, err := staffAssessRepo.Find(map[string]interface{}{
|
|
|
185
|
+ "staffAssessTaskId": assessTaskData.Id,
|
|
|
186
|
+ "executorId": param.UserId,
|
|
|
187
|
+ "typesList": []string{string(domain.AssessSuper)},
|
|
|
188
|
+ })
|
|
|
189
|
+ if err != nil {
|
|
|
190
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
|
|
|
191
|
+ }
|
|
|
192
|
+ if len(assessSupperList) > 0 {
|
|
|
193
|
+ stepItem.Status = string(domain.StaffAssessCompleted)
|
|
|
194
|
+ stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
|
|
|
195
|
+ uncompletedNum := 0
|
|
|
196
|
+ for _, v := range assessSupperList {
|
|
|
197
|
+ if v.Status == domain.StaffAssessUncompleted {
|
|
|
198
|
+ uncompletedNum += 1
|
|
|
199
|
+ }
|
|
|
200
|
+ }
|
|
|
201
|
+ if uncompletedNum > 0 {
|
|
|
202
|
+ stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum)
|
|
|
203
|
+ }
|
|
|
204
|
+ }
|
|
|
205
|
+ }
|
|
|
206
|
+ result.StepList = append(result.StepList, stepItem)
|
|
|
207
|
+ }
|
|
|
208
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
209
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
210
|
+ }
|
|
|
211
|
+ return &result, nil
|
|
|
212
|
+}
|
|
|
213
|
+
|
|
|
214
|
+// 获取个人的自评反馈历史记录列表
|
|
|
215
|
+func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) (map[string]interface{}, error) {
|
|
|
216
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
217
|
+ if err != nil {
|
|
|
218
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
219
|
+ }
|
|
|
220
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
221
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
222
|
+ }
|
|
|
223
|
+ defer func() {
|
|
|
224
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
225
|
+ }()
|
|
|
226
|
+ //获取个人参与的评估流程
|
|
|
227
|
+ staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
228
|
+ "transactionContext": transactionContext,
|
|
|
229
|
+ })
|
|
|
230
|
+ var limit int = 20
|
|
|
231
|
+ var offset int = 0
|
|
|
232
|
+ if param.PageSize > 0 {
|
|
|
233
|
+ limit = param.PageSize
|
|
|
234
|
+ }
|
|
|
235
|
+ offset = (param.PageNumber - 1) * param.PageSize
|
|
|
236
|
+ condition := map[string]interface{}{
|
|
|
237
|
+ "executorId": param.UserId,
|
|
|
238
|
+ "companyId": param.CompanyId,
|
|
|
239
|
+ "typesList": []string{string(domain.AssessSelf)},
|
|
|
240
|
+ "limit": limit,
|
|
|
241
|
+ "status": string(domain.StaffAssessCompleted),
|
|
|
242
|
+ }
|
|
|
243
|
+ if offset > 0 {
|
|
|
244
|
+ condition["offset"] = offset
|
|
|
245
|
+ }
|
|
|
246
|
+ //获取历史列表
|
|
|
247
|
+ cnt, assessList, err := staffAssessRepo.Find(condition)
|
|
|
248
|
+ if err != nil {
|
|
|
249
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务列表,"+err.Error())
|
|
|
250
|
+ }
|
|
|
251
|
+
|
|
|
252
|
+ //获取公司数据
|
|
|
253
|
+ companyRep := factory.CreateCompanyRepository(map[string]interface{}{
|
|
|
254
|
+ "transactionContext": transactionContext,
|
|
|
255
|
+ })
|
|
|
256
|
+
|
|
|
257
|
+ companyData, err := companyRep.FindOne(map[string]interface{}{
|
|
|
258
|
+ "id": param.CompanyId,
|
|
|
259
|
+ })
|
|
|
260
|
+ if err != nil {
|
|
|
261
|
+ log.Logger.Error("获取公司信息," + err.Error())
|
|
|
262
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取公司信息,"+err.Error())
|
|
|
263
|
+ }
|
|
|
264
|
+
|
|
|
265
|
+ //获取用户数据
|
|
|
266
|
+ userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
267
|
+ "transactionContext": transactionContext,
|
|
|
268
|
+ })
|
|
|
269
|
+ userData, err := userRepo.FindOne(map[string]interface{}{
|
|
|
270
|
+ "id": param.UserId,
|
|
|
271
|
+ })
|
|
|
272
|
+ if err != nil {
|
|
|
273
|
+ log.Logger.Error("获取用户信息," + err.Error())
|
|
|
274
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取用户信息,"+err.Error())
|
|
|
275
|
+ }
|
|
|
276
|
+ departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
277
|
+ "transactionContext": transactionContext,
|
|
|
278
|
+ })
|
|
|
279
|
+ var supperUserList []*domain.User
|
|
|
280
|
+ if len(userData.DepartmentId) > 0 {
|
|
|
281
|
+ _, departmentList, err := departmentRepo.Find(map[string]interface{}{
|
|
|
282
|
+ "ids": userData.DepartmentId,
|
|
|
283
|
+ })
|
|
|
284
|
+ if err != nil {
|
|
|
285
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取部门信息,"+err.Error())
|
|
|
286
|
+ }
|
|
|
287
|
+ var chargeUserIds []int64
|
|
|
288
|
+ for _, v := range departmentList {
|
|
|
289
|
+ chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
|
|
|
290
|
+ }
|
|
|
291
|
+ if len(chargeUserIds) > 0 {
|
|
|
292
|
+ _, supperUserList, err = userRepo.Find(map[string]interface{}{
|
|
|
293
|
+ "ids": chargeUserIds,
|
|
|
294
|
+ })
|
|
|
295
|
+ if err != nil {
|
|
|
296
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取员工上级信息,"+err.Error())
|
|
|
297
|
+ }
|
|
|
298
|
+ }
|
|
|
299
|
+ }
|
|
|
300
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
301
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
302
|
+ }
|
|
|
303
|
+ listData := make([]adapter.AssessSelfList, 0, len(assessList))
|
|
|
304
|
+ var itemTemp adapter.AssessSelfList
|
|
|
305
|
+ for _, v := range assessList {
|
|
|
306
|
+ itemTemp = adapter.AssessSelfList{
|
|
|
307
|
+ AssessId: v.Id,
|
|
|
308
|
+ BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
309
|
+ EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
310
|
+ CycleId: v.CycleId,
|
|
|
311
|
+ CycleName: v.CycleName,
|
|
|
312
|
+ EvaluationProjectId: v.EvaluationProjectId,
|
|
|
313
|
+ EvaluationProjectName: v.EvaluationProjectName,
|
|
|
314
|
+ }
|
|
|
315
|
+ listData = append(listData, itemTemp)
|
|
|
316
|
+ }
|
|
|
317
|
+ userInfo := adapter.StaffInfo{
|
|
|
318
|
+ UserName: userData.Name,
|
|
|
319
|
+ CompanyName: companyData.Name,
|
|
|
320
|
+ SupperUserName: "",
|
|
|
321
|
+ DutyTime: userData.CreateAt.Local().Format("2006-01-02 15:04:05"),
|
|
|
322
|
+ }
|
|
|
323
|
+ for _, v := range supperUserList {
|
|
|
324
|
+ userInfo.SupperUserName = userInfo.SupperUserName + v.Name + ";"
|
|
|
325
|
+ }
|
|
|
326
|
+ result := tool_funs.SimpleWrapGridMap(int64(cnt), listData)
|
|
|
327
|
+ result["userInfo"] = userInfo
|
|
|
328
|
+ return result, nil
|
|
|
329
|
+}
|
|
|
330
|
+
|
|
|
331
|
+// 更具项目评估的配置,创建员工的评估任务
|
|
|
332
|
+func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) {
|
|
|
333
|
+
|
|
|
334
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
335
|
+ if err != nil {
|
|
|
336
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
337
|
+ }
|
|
|
338
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
339
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
340
|
+ }
|
|
|
341
|
+ defer func() {
|
|
|
342
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
343
|
+ }()
|
|
|
344
|
+
|
|
|
345
|
+ taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
|
|
|
346
|
+ if err != nil {
|
|
|
347
|
+ return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime)
|
|
|
348
|
+ }
|
|
|
349
|
+ taskEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.EndTime, time.Local)
|
|
|
350
|
+ if err != nil {
|
|
|
351
|
+ return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime)
|
|
|
352
|
+ }
|
|
|
353
|
+ nowTime := time.Now()
|
|
|
354
|
+ //建立评估任务
|
|
|
355
|
+ assessTask := domain.StaffAssessTask{
|
|
|
356
|
+ Id: 0,
|
|
|
357
|
+ CompanyId: param.CompanyId,
|
|
|
358
|
+ EvaluationProjectId: param.EvaluationProjectId,
|
|
|
359
|
+ EvaluationProjectName: param.EvaluationProjectName,
|
|
|
360
|
+ CycleId: param.CycleId,
|
|
|
361
|
+ CycleName: param.CycleName,
|
|
|
362
|
+ BeginTime: taskBeginTime,
|
|
|
363
|
+ EndTime: taskEndTime,
|
|
|
364
|
+ StepList: []domain.AssessTaskStep{},
|
|
|
365
|
+ ExecutorId: nil,
|
|
|
366
|
+ CreatedAt: nowTime,
|
|
|
367
|
+ UpdatedAt: nowTime,
|
|
|
368
|
+ DeletedAt: nil,
|
|
|
369
|
+ }
|
|
|
370
|
+ //填充评估环节
|
|
|
371
|
+ for _, v := range param.StepList {
|
|
|
372
|
+ stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
|
|
|
373
|
+ if err != nil {
|
|
|
374
|
+ return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime)
|
|
|
375
|
+ }
|
|
|
376
|
+ stepEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.EndTime, time.Local)
|
|
|
377
|
+ if err != nil {
|
|
|
378
|
+ return nil, application.ThrowError(application.ARG_ERROR, "评估环节结束时间填写错误,"+param.EndTime)
|
|
|
379
|
+ }
|
|
|
380
|
+ step := domain.AssessTaskStep{
|
|
|
381
|
+ SortBy: v.SortBy,
|
|
|
382
|
+ LinkNodeId: v.LinkNodeId,
|
|
|
383
|
+ LinkNodeName: v.LinkNodeName,
|
|
|
384
|
+ LinkNodeType: v.LinkNodeType,
|
|
|
385
|
+ BeginTime: stepBeginTime,
|
|
|
386
|
+ EndTime: stepEndTime,
|
|
|
387
|
+ }
|
|
|
388
|
+ assessTask.StepList = append(assessTask.StepList, step)
|
|
|
389
|
+ }
|
|
|
390
|
+
|
|
|
391
|
+ assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
392
|
+ "transactionContext": transactionContext,
|
|
|
393
|
+ })
|
|
|
394
|
+ _, err = assessTaskRepo.Save(&assessTask)
|
|
|
395
|
+ if err != nil {
|
|
|
396
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
|
|
|
397
|
+ }
|
|
|
398
|
+
|
|
|
399
|
+ assessList, err := srv.createStaffAssess(transactionContext, &assessTask)
|
|
|
400
|
+ if err != nil {
|
|
|
401
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error())
|
|
|
402
|
+ }
|
|
|
403
|
+
|
|
|
404
|
+ assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
405
|
+ "transactionContext": transactionContext,
|
|
|
406
|
+ })
|
|
|
407
|
+
|
|
|
408
|
+ for i := range assessList {
|
|
|
409
|
+ _, err = assessRepo.Save(&assessList[i])
|
|
|
410
|
+ if err != nil {
|
|
|
411
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error())
|
|
|
412
|
+ }
|
|
|
413
|
+ }
|
|
|
414
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
415
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
416
|
+ }
|
|
|
417
|
+ return map[string]interface{}{
|
|
|
418
|
+ "assessTaskId": assessTask.Id,
|
|
|
419
|
+ }, nil
|
|
|
420
|
+}
|
|
|
421
|
+
|
|
|
422
|
+// 添加自评节点任务
|
|
|
423
|
+func (srv StaffAssessServeice) createStaffAssess(transactionContext application.TransactionContext, param *domain.StaffAssessTask) ([]domain.StaffAssess, error) {
|
|
|
424
|
+ //评估的参与人
|
|
|
425
|
+ selfUserId := []int{}
|
|
|
426
|
+ userIdMap := map[int]struct{}{} //过滤重复的用户
|
|
|
427
|
+ for _, v := range param.ExecutorId {
|
|
|
428
|
+ if _, ok := userIdMap[v]; ok {
|
|
|
429
|
+ continue
|
|
|
430
|
+ }
|
|
|
431
|
+ selfUserId = append(selfUserId, v)
|
|
|
432
|
+ }
|
|
|
433
|
+ // 获取用户的信息
|
|
|
434
|
+ if len(selfUserId) == 0 {
|
|
|
435
|
+ return nil, application.ThrowError(application.ARG_ERROR, "未填写评估任务的执行人")
|
|
|
436
|
+ }
|
|
|
437
|
+ userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
438
|
+ "transactionContext": transactionContext,
|
|
|
439
|
+ })
|
|
|
440
|
+ //获取员工信息
|
|
|
441
|
+ _, userList, err := userRepo.Find(map[string]interface{}{
|
|
|
442
|
+ "ids": selfUserId,
|
|
|
443
|
+ })
|
|
|
444
|
+ if err != nil {
|
|
|
445
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取员工信息"+err.Error())
|
|
|
446
|
+ }
|
|
|
447
|
+ departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
448
|
+ "transactionContext": transactionContext,
|
|
|
449
|
+ })
|
|
|
450
|
+ //获取用户的部门
|
|
|
451
|
+ userDepartmentMap := map[int64][]*domain.Department{}
|
|
|
452
|
+ for _, v := range userList {
|
|
|
453
|
+ _, departmemtList, err := departmentRepo.Find(map[string]interface{}{
|
|
|
454
|
+ "ids": v.DepartmentId,
|
|
|
455
|
+ })
|
|
|
456
|
+ if err != nil {
|
|
|
457
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取员工的部门信息"+err.Error())
|
|
|
458
|
+ }
|
|
|
459
|
+ userDepartmentMap[v.Id] = departmemtList
|
|
|
460
|
+ }
|
|
|
461
|
+ assessList := []domain.StaffAssess{}
|
|
|
462
|
+ //数据样板
|
|
|
463
|
+ stepSelfTemp := domain.StaffAssess{
|
|
|
464
|
+ Id: 0,
|
|
|
465
|
+ CompanyId: param.CompanyId,
|
|
|
466
|
+ EvaluationProjectId: param.EvaluationProjectId,
|
|
|
467
|
+ EvaluationProjectName: param.EvaluationProjectName,
|
|
|
468
|
+ CycleId: param.CycleId,
|
|
|
469
|
+ CycleName: param.CycleName,
|
|
|
470
|
+ StaffAssessTaskId: param.Id,
|
|
|
471
|
+ // TargetUser: domain.StaffDesc{},
|
|
|
472
|
+ // TargetDepartment: nil,
|
|
|
473
|
+ // Executor: domain.StaffDesc{},
|
|
|
474
|
+ Types: domain.AssessSelf,
|
|
|
475
|
+ // LinkNodeId: v.LinkNodeId,
|
|
|
476
|
+ Status: domain.StaffAssessUncompleted,
|
|
|
477
|
+ // BeginTime: time.Time{},
|
|
|
478
|
+ // EndTime: time.Time{},
|
|
|
479
|
+ CreatedAt: param.CreatedAt,
|
|
|
480
|
+ UpdatedAt: param.UpdatedAt,
|
|
|
481
|
+ DeletedAt: nil,
|
|
|
482
|
+ }
|
|
|
483
|
+ for _, v := range param.StepList {
|
|
|
484
|
+ if v.LinkNodeType == domain.LinkNodeSelfAssessment {
|
|
|
485
|
+ //员工自评
|
|
|
486
|
+ stepSelfTemp.BeginTime = v.BeginTime
|
|
|
487
|
+ stepSelfTemp.EndTime = v.EndTime
|
|
|
488
|
+ stepSelfTemp.LinkNodeId = v.LinkNodeId
|
|
|
489
|
+ stepSelfTemp.LinkNodeName = v.LinkNodeName
|
|
|
490
|
+ assessListTemp := srv.createStaffAssessSelf(stepSelfTemp, userList, userDepartmentMap)
|
|
|
491
|
+ assessList = append(assessList, assessListTemp...)
|
|
|
492
|
+ }
|
|
|
493
|
+ if v.LinkNodeType == domain.LinkNodeSuperiorAssessment {
|
|
|
494
|
+ // TODO
|
|
|
495
|
+ stepSelfTemp.BeginTime = v.BeginTime
|
|
|
496
|
+ stepSelfTemp.EndTime = v.EndTime
|
|
|
497
|
+ stepSelfTemp.LinkNodeId = v.LinkNodeId
|
|
|
498
|
+ stepSelfTemp.LinkNodeName = v.LinkNodeName
|
|
|
499
|
+ assessListTemp, err := srv.createStaffAssessSupper(transactionContext, stepSelfTemp, userList, userDepartmentMap)
|
|
|
500
|
+ if err != nil {
|
|
|
501
|
+ return nil, err
|
|
|
502
|
+ }
|
|
|
503
|
+ assessList = append(assessList, assessListTemp...)
|
|
|
504
|
+ }
|
|
|
505
|
+ }
|
|
|
506
|
+ return assessList, nil
|
|
|
507
|
+}
|
|
|
508
|
+
|
|
|
509
|
+// 构建员工自评
|
|
|
510
|
+func (srv StaffAssessServeice) createStaffAssessSelf(assessTemp domain.StaffAssess,
|
|
|
511
|
+ userList []*domain.User, userDepartmentMap map[int64][]*domain.Department) []domain.StaffAssess {
|
|
|
512
|
+ result := []domain.StaffAssess{}
|
|
|
513
|
+ for _, usr := range userList {
|
|
|
514
|
+ assessTemp.TargetUser = domain.StaffDesc{
|
|
|
515
|
+ UserId: int(usr.Id),
|
|
|
516
|
+ Account: usr.Account,
|
|
|
517
|
+ UserName: usr.Account,
|
|
|
518
|
+ }
|
|
|
519
|
+ assessTemp.Executor = domain.StaffDesc{
|
|
|
520
|
+ UserId: int(usr.Id),
|
|
|
521
|
+ Account: usr.Account,
|
|
|
522
|
+ UserName: usr.Account,
|
|
|
523
|
+ }
|
|
|
524
|
+ if depList, ok := userDepartmentMap[usr.Id]; ok {
|
|
|
525
|
+ for _, dep := range depList {
|
|
|
526
|
+ assessTemp.TargetDepartment = append(assessTemp.TargetDepartment, domain.StaffDepartment{
|
|
|
527
|
+ DepartmentId: int(dep.Id),
|
|
|
528
|
+ DepartmentName: dep.Name,
|
|
|
529
|
+ })
|
|
|
530
|
+ }
|
|
|
531
|
+ }
|
|
|
532
|
+ result = append(result, assessTemp)
|
|
|
533
|
+ }
|
|
|
534
|
+ return result
|
|
|
535
|
+}
|
|
|
536
|
+
|
|
|
537
|
+// 构建员工上级评估
|
|
|
538
|
+func (srv StaffAssessServeice) createStaffAssessSupper(
|
|
|
539
|
+ transactionContext application.TransactionContext,
|
|
|
540
|
+ assessTemp domain.StaffAssess,
|
|
|
541
|
+ userList []*domain.User, userDepartmentMap map[int64][]*domain.Department,
|
|
|
542
|
+) ([]domain.StaffAssess, error) {
|
|
|
543
|
+
|
|
|
544
|
+ // 获取员工的上级用户
|
|
|
545
|
+
|
|
|
546
|
+ return nil, nil
|
|
|
547
|
+}
|
|
|
548
|
+
|
|
|
549
|
+// 获取某个员工360邀请的人员
|
|
|
550
|
+func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) {
|
|
|
551
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
552
|
+ if err != nil {
|
|
|
553
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
554
|
+ }
|
|
|
555
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
556
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
557
|
+ }
|
|
|
558
|
+ defer func() {
|
|
|
559
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
560
|
+ }()
|
|
|
561
|
+
|
|
|
562
|
+ assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
563
|
+ "transactionContext": transactionContext,
|
|
|
564
|
+ })
|
|
|
565
|
+
|
|
|
566
|
+ assessTaskReps := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
567
|
+ "transactionContext": transactionContext,
|
|
|
568
|
+ })
|
|
|
569
|
+ assessTaskData, err := assessTaskReps.FindOne(map[string]interface{}{
|
|
|
570
|
+ "id": param.AssessTaskId,
|
|
|
571
|
+ })
|
|
|
572
|
+ if err != nil {
|
|
|
573
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error())
|
|
|
574
|
+ }
|
|
|
575
|
+ _, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
576
|
+ "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
|
|
|
577
|
+ "staffAssessTaskId": param.AssessTaskId,
|
|
|
578
|
+ "targetUserId": param.UsrId,
|
|
|
579
|
+ })
|
|
|
580
|
+ if err != nil {
|
|
|
581
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
|
|
|
582
|
+ }
|
|
|
583
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
584
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
585
|
+ }
|
|
|
586
|
+
|
|
|
587
|
+ result := adapter.AssessInviteUserResp{
|
|
|
588
|
+ AssessTaskId: assessTaskData.Id,
|
|
|
589
|
+ }
|
|
|
590
|
+ for _, v := range assessTaskData.StepList {
|
|
|
591
|
+ if v.LinkNodeType != domain.LinkNodeAllInvite {
|
|
|
592
|
+ continue
|
|
|
593
|
+ }
|
|
|
594
|
+ result.LinkNodeId = v.LinkNodeId
|
|
|
595
|
+ result.LinkNodeName = v.LinkNodeName
|
|
|
596
|
+ result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05")
|
|
|
597
|
+ result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05")
|
|
|
598
|
+ break
|
|
|
599
|
+ }
|
|
|
600
|
+ for _, v := range assessList {
|
|
|
601
|
+ if v.Types == domain.AssessInviteDiffSuper {
|
|
|
602
|
+ result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor)
|
|
|
603
|
+ }
|
|
|
604
|
+ if v.Types == domain.AssessInviteSameSuper {
|
|
|
605
|
+ result.InviteSameSuper = append(result.InviteDiffSuper, v.Executor)
|
|
|
606
|
+ }
|
|
|
607
|
+ }
|
|
|
608
|
+ return &result, nil
|
|
|
609
|
+}
|
|
|
610
|
+
|
|
|
611
|
+// 获取某个员工360邀请的人员
|
|
|
612
|
+func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (*adapter.AssessInviteUserResp, error) {
|
|
|
613
|
+ inviteSameSuperId := []int{}
|
|
|
614
|
+ InviteDiffSuperId := []int{}
|
|
|
615
|
+ for _, v := range param.InviteDiffSuper {
|
|
|
616
|
+ id, err := strconv.Atoi(v)
|
|
|
617
|
+ if err != nil {
|
|
|
618
|
+ return nil, application.ThrowError(application.ARG_ERROR, "用户填写错误")
|
|
|
619
|
+ }
|
|
|
620
|
+ InviteDiffSuperId = append(InviteDiffSuperId, id)
|
|
|
621
|
+ }
|
|
|
622
|
+ for _, v := range param.InviteSameSuper {
|
|
|
623
|
+ id, err := strconv.Atoi(v)
|
|
|
624
|
+ if err != nil {
|
|
|
625
|
+ return nil, application.ThrowError(application.ARG_ERROR, "用户填写错误")
|
|
|
626
|
+ }
|
|
|
627
|
+ inviteSameSuperId = append(inviteSameSuperId, id)
|
|
|
628
|
+ }
|
|
|
629
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
630
|
+ if err != nil {
|
|
|
631
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
632
|
+ }
|
|
|
633
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
634
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
635
|
+ }
|
|
|
636
|
+ defer func() {
|
|
|
637
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
638
|
+ }()
|
|
|
639
|
+
|
|
|
640
|
+ assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
641
|
+ "transactionContext": transactionContext,
|
|
|
642
|
+ })
|
|
|
643
|
+ userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
644
|
+ "transactionContext": transactionContext,
|
|
|
645
|
+ })
|
|
|
646
|
+ departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
647
|
+ "transactionContext": transactionContext,
|
|
|
648
|
+ })
|
|
|
649
|
+
|
|
|
650
|
+ assessTaskReps := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
651
|
+ "transactionContext": transactionContext,
|
|
|
652
|
+ })
|
|
|
653
|
+ assessTaskData, err := assessTaskReps.FindOne(map[string]interface{}{
|
|
|
654
|
+ "id": param.AssessTaskId,
|
|
|
655
|
+ })
|
|
|
656
|
+ if err != nil {
|
|
|
657
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error())
|
|
|
658
|
+ }
|
|
|
659
|
+
|
|
|
660
|
+ targetUser, err := userRepo.FindOne(map[string]interface{}{
|
|
|
661
|
+ "id": param.TargetUserId,
|
|
|
662
|
+ })
|
|
|
663
|
+ if err != nil {
|
|
|
664
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取被评估员工"+err.Error())
|
|
|
665
|
+ }
|
|
|
666
|
+ //被评估人的部门
|
|
|
667
|
+ var targetUserDepartment []domain.StaffDepartment
|
|
|
668
|
+ if len(targetUser.DepartmentId) > 0 {
|
|
|
669
|
+ _, departmentList, err := departmentRepo.Find(map[string]interface{}{
|
|
|
670
|
+ "ids": targetUser.DepartmentId,
|
|
|
671
|
+ })
|
|
|
672
|
+ if err != nil {
|
|
|
673
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取部门信息"+err.Error())
|
|
|
674
|
+ }
|
|
|
675
|
+ for _, v := range departmentList {
|
|
|
676
|
+ targetUserDepartment = append(targetUserDepartment, domain.StaffDepartment{
|
|
|
677
|
+ DepartmentId: int(v.Id),
|
|
|
678
|
+ DepartmentName: v.Name,
|
|
|
679
|
+ })
|
|
|
680
|
+ }
|
|
|
681
|
+ }
|
|
|
682
|
+ //邀请的相同上级的员工
|
|
|
683
|
+ var inviteSameSuper []domain.StaffDesc
|
|
|
684
|
+ if len(inviteSameSuperId) > 0 {
|
|
|
685
|
+ _, userList, err := userRepo.Find(map[string]interface{}{
|
|
|
686
|
+ "ids": inviteSameSuperId,
|
|
|
687
|
+ })
|
|
|
688
|
+ if err != nil {
|
|
|
689
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error())
|
|
|
690
|
+ }
|
|
|
691
|
+ for _, v := range userList {
|
|
|
692
|
+ inviteSameSuper = append(inviteSameSuper, domain.StaffDesc{
|
|
|
693
|
+ UserId: int(v.Id),
|
|
|
694
|
+ UserName: v.Name,
|
|
|
695
|
+ Account: v.Account,
|
|
|
696
|
+ })
|
|
|
697
|
+ }
|
|
|
698
|
+ }
|
|
|
699
|
+ //邀请的不同上级的员工
|
|
|
700
|
+ var inviteDiffSuper []domain.StaffDesc
|
|
|
701
|
+ if len(InviteDiffSuperId) > 0 {
|
|
|
702
|
+ _, userList, err := userRepo.Find(map[string]interface{}{
|
|
|
703
|
+ "ids": InviteDiffSuperId,
|
|
|
704
|
+ })
|
|
|
705
|
+ if err != nil {
|
|
|
706
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error())
|
|
|
707
|
+ }
|
|
|
708
|
+ for _, v := range userList {
|
|
|
709
|
+ inviteDiffSuper = append(inviteDiffSuper, domain.StaffDesc{
|
|
|
710
|
+ UserId: int(v.Id),
|
|
|
711
|
+ UserName: v.Name,
|
|
|
712
|
+ Account: v.Account,
|
|
|
713
|
+ })
|
|
|
714
|
+ }
|
|
|
715
|
+ }
|
|
|
716
|
+ _ = assessReps
|
|
|
717
|
+ _ = inviteSameSuper
|
|
|
718
|
+ _ = inviteDiffSuper
|
|
|
719
|
+ _ = targetUserDepartment
|
|
|
720
|
+ // _, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
721
|
+ // "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
|
|
|
722
|
+ // "staffAssessTaskId": param.AssessTaskId,
|
|
|
723
|
+ // "targetUserId": param.TargetUserId,
|
|
|
724
|
+ // })
|
|
|
725
|
+ // if err != nil {
|
|
|
726
|
+ // return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
|
|
|
727
|
+ // }
|
|
|
728
|
+ // TODO
|
|
|
729
|
+
|
|
|
730
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
731
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
732
|
+ }
|
|
|
733
|
+
|
|
|
734
|
+ result := adapter.AssessInviteUserResp{
|
|
|
735
|
+ AssessTaskId: assessTaskData.Id,
|
|
|
736
|
+ }
|
|
|
737
|
+ // for _, v := range assessTaskData.StepList {
|
|
|
738
|
+ // if v.LinkNodeType != domain.LinkNodeAllInvite {
|
|
|
739
|
+ // continue
|
|
|
740
|
+ // }
|
|
|
741
|
+ // result.LinkNodeId = v.LinkNodeId
|
|
|
742
|
+ // result.LinkNodeName = v.LinkNodeName
|
|
|
743
|
+ // result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05")
|
|
|
744
|
+ // result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05")
|
|
|
745
|
+ // break
|
|
|
746
|
+ // }
|
|
|
747
|
+ // for _, v := range assessList {
|
|
|
748
|
+ // if v.Types == domain.AssessInviteDiffSuper {
|
|
|
749
|
+ // result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor)
|
|
|
750
|
+ // }
|
|
|
751
|
+ // if v.Types == domain.AssessInviteSameSuper {
|
|
|
752
|
+ // result.InviteSameSuper = append(result.InviteDiffSuper, v.Executor)
|
|
|
753
|
+ // }
|
|
|
754
|
+ // }
|
|
|
755
|
+ return &result, nil
|
|
|
756
|
+}
|
|
|
757
|
+
|
|
|
758
|
+// 获取员工自评的评估内容详情
|
|
|
759
|
+func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
|
|
|
760
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
761
|
+ if err != nil {
|
|
|
762
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
763
|
+ }
|
|
|
764
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
765
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
766
|
+ }
|
|
|
767
|
+ defer func() {
|
|
|
768
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
769
|
+ }()
|
|
|
770
|
+ assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
771
|
+ "transactionContext": transactionContext,
|
|
|
772
|
+ })
|
|
|
773
|
+
|
|
|
774
|
+ //获取员工的评估
|
|
|
775
|
+ _, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
776
|
+ "companyId": param.CompanyId,
|
|
|
777
|
+ "staffAssessTaskId": param.AssessTaskId,
|
|
|
778
|
+ "targetUserId": param.TargetUserId,
|
|
|
779
|
+ "typesList": []string{string(domain.AssessSelf)},
|
|
|
780
|
+ })
|
|
|
781
|
+ if err != nil {
|
|
|
782
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
|
|
|
783
|
+ }
|
|
|
784
|
+ if len(assessList) == 0 {
|
|
|
785
|
+ return &adapter.AssessInfoResp{}, nil
|
|
|
786
|
+ }
|
|
|
787
|
+ assessData := assessList[0]
|
|
|
788
|
+ projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{
|
|
|
789
|
+ "transactionContext": transactionContext,
|
|
|
790
|
+ })
|
|
|
791
|
+ projectData, err := projectRepo.FindOne(map[string]interface{}{
|
|
|
792
|
+ "id": assessData.EvaluationProjectId,
|
|
|
793
|
+ })
|
|
|
794
|
+ if err != nil {
|
|
|
795
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目评估配置"+err.Error())
|
|
|
796
|
+ }
|
|
|
797
|
+ if projectData.Template == nil {
|
|
|
798
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获取到项目评估配置模板")
|
|
|
799
|
+ }
|
|
|
800
|
+ var selfLinkNode *domain.LinkNode
|
|
|
801
|
+ for _, v := range projectData.Template.LinkNodes {
|
|
|
802
|
+ if v.Type == domain.LinkNodeSelfAssessment {
|
|
|
803
|
+ selfLinkNode = v
|
|
|
804
|
+ break
|
|
|
805
|
+ }
|
|
|
806
|
+ }
|
|
|
807
|
+ if selfLinkNode == nil {
|
|
|
808
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获取到项目评估自评配置")
|
|
|
809
|
+ }
|
|
|
810
|
+ //获取员工评估的填写内容
|
|
|
811
|
+ // assessContentReps := factory.CreateStaffAssessContentRepository(map[string]interface{}{
|
|
|
812
|
+ // "transactionContext": transactionContext,
|
|
|
813
|
+ // })
|
|
|
814
|
+ // _, assessContentList, err := assessContentReps.Find(map[string]interface{}{
|
|
|
815
|
+ // "staffAssessId": assessData.Id,
|
|
|
816
|
+ // })
|
|
|
817
|
+ // if err != nil {
|
|
|
818
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目评估员工填写的内容"+err.Error())
|
|
|
819
|
+ // }
|
|
|
820
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
821
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
822
|
+ }
|
|
|
823
|
+
|
|
|
824
|
+ result := adapter.AssessInfoResp{
|
|
|
825
|
+ CycleId: assessData.CycleId,
|
|
|
826
|
+ CycleName: assessData.CycleName,
|
|
|
827
|
+ EvaluationProjectId: assessData.EvaluationProjectId,
|
|
|
828
|
+ EvaluationProjectName: assessData.EvaluationProjectName,
|
|
|
829
|
+ BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
830
|
+ EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
831
|
+ Status: string(assessData.Status),
|
|
|
832
|
+ TargetUserId: assessData.TargetUser.UserId,
|
|
|
833
|
+ TargetUserName: assessData.TargetUser.UserName,
|
|
|
834
|
+ AssessContent: nil,
|
|
|
835
|
+ }
|
|
|
836
|
+ assessContent := make([]adapter.AssessContent, 0)
|
|
|
837
|
+ for _, v := range selfLinkNode.NodeContents {
|
|
|
838
|
+ assessContent = append(assessContent, adapter.AssessContent{
|
|
|
839
|
+ Category: v.Category,
|
|
|
840
|
+ Name: v.Name,
|
|
|
841
|
+ PromptTitle: v.PromptTitle,
|
|
|
842
|
+ PromptText: v.PromptText,
|
|
|
843
|
+ EntryItems: v.EntryItems,
|
|
|
844
|
+ })
|
|
|
845
|
+ }
|
|
|
846
|
+ result.AssessContent = assessContent
|
|
|
847
|
+ return &result, nil
|
|
|
848
|
+} |