|
@@ -231,11 +231,156 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP |
|
@@ -231,11 +231,156 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP |
231
|
transactionContext.RollbackTransaction()
|
231
|
transactionContext.RollbackTransaction()
|
232
|
}()
|
232
|
}()
|
233
|
|
233
|
|
|
|
234
|
+ var projectItemUsed = map[int][]*domain.EvaluationItemUsed{} // 项目ID-> 评估内容项
|
|
|
235
|
+ var userProjectMap = map[int][]*dao.IndicatorUserProject{} // 用户ID-> 用户评估的项目(用户在周期内可能有多个项目模板,激活状态只能是1个)
|
|
|
236
|
+ var projectIds = make([]int, 0)
|
|
|
237
|
+
|
|
|
238
|
+ if len(in.UserIds) > 0 {
|
|
|
239
|
+ staffAssessRepository := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
240
|
+ _, assessList, err := staffAssessRepository.Find(map[string]interface{}{
|
|
|
241
|
+ "cycleId": in.CycleId,
|
|
|
242
|
+ "targetUserIds": in.UserIds,
|
|
|
243
|
+ "types": domain.AssessSelf,
|
|
|
244
|
+ })
|
|
|
245
|
+ if err != nil {
|
|
|
246
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
247
|
+ }
|
|
|
248
|
+
|
|
|
249
|
+ projectIdsMap := map[int]int{}
|
|
|
250
|
+ for i := range assessList {
|
|
|
251
|
+ it := assessList[i]
|
|
|
252
|
+ projectIdsMap[it.EvaluationProjectId] = it.EvaluationProjectId
|
|
|
253
|
+
|
|
|
254
|
+ // 用户存在多个项目模板
|
|
|
255
|
+ array, ok := userProjectMap[it.TargetUser.UserId]
|
|
|
256
|
+ if !ok {
|
|
|
257
|
+ array = make([]*dao.IndicatorUserProject, 0)
|
|
|
258
|
+ }
|
|
|
259
|
+ userProjectMap[it.TargetUser.UserId] = append(array, &dao.IndicatorUserProject{
|
|
|
260
|
+ AssessId: it.Id,
|
|
|
261
|
+ EvaluationProjectId: it.EvaluationProjectId,
|
|
|
262
|
+ TargetUserId: it.TargetUser.UserId,
|
|
|
263
|
+ TargetUserName: it.TargetUser.UserName,
|
|
|
264
|
+ })
|
|
|
265
|
+ }
|
|
|
266
|
+ for k, _ := range projectIdsMap {
|
|
|
267
|
+ projectIds = append(projectIds, k)
|
|
|
268
|
+ }
|
|
|
269
|
+
|
|
|
270
|
+ } else {
|
234
|
hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId)
|
271
|
hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId)
|
235
|
if err != nil {
|
272
|
if err != nil {
|
236
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
273
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
237
|
}
|
274
|
}
|
238
|
assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
|
275
|
assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
276
|
+ list, err := assessDao.MemberAllProjectId(
|
|
|
277
|
+ in.CompanyId,
|
|
|
278
|
+ in.UserName,
|
|
|
279
|
+ in.OperatorId,
|
|
|
280
|
+ in.CycleId,
|
|
|
281
|
+ hrbp)
|
|
|
282
|
+ if err != nil {
|
|
|
283
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
284
|
+ }
|
|
|
285
|
+
|
|
|
286
|
+ projectIdsMap := map[int]int{}
|
|
|
287
|
+ for i := range list {
|
|
|
288
|
+ it := list[i]
|
|
|
289
|
+ projectIdsMap[it.EvaluationProjectId] = it.EvaluationProjectId
|
|
|
290
|
+
|
|
|
291
|
+ // 用户存在多个项目模板
|
|
|
292
|
+ array, ok := userProjectMap[it.TargetUserId]
|
|
|
293
|
+ if !ok {
|
|
|
294
|
+ array = make([]*dao.IndicatorUserProject, 0)
|
|
|
295
|
+ }
|
|
|
296
|
+ userProjectMap[it.TargetUserId] = append(array, &it)
|
|
|
297
|
+ }
|
|
|
298
|
+
|
|
|
299
|
+ for k, _ := range projectIdsMap {
|
|
|
300
|
+ projectIds = append(projectIds, k)
|
|
|
301
|
+ }
|
|
|
302
|
+ }
|
|
|
303
|
+
|
|
|
304
|
+ // 项目ID->查询所有评估项
|
|
|
305
|
+ if len(projectIds) > 0 {
|
|
|
306
|
+ itemUsedRepository := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
307
|
+ _, itemList, err := itemUsedRepository.Find(map[string]interface{}{"evaluationProjectIds": projectIds, "nodeType": domain.LinkNodeSelfAssessment})
|
|
|
308
|
+ if err != nil {
|
|
|
309
|
+ return nil, err
|
|
|
310
|
+ }
|
|
|
311
|
+ for i := range itemList {
|
|
|
312
|
+ it := itemList[i]
|
|
|
313
|
+ array, ok := projectItemUsed[it.EvaluationProjectId]
|
|
|
314
|
+ if !ok {
|
|
|
315
|
+ array = make([]*domain.EvaluationItemUsed, 0)
|
|
|
316
|
+ }
|
|
|
317
|
+ projectItemUsed[it.EvaluationProjectId] = append(array, it)
|
|
|
318
|
+ }
|
|
|
319
|
+ }
|
|
|
320
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
321
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
322
|
+ }
|
|
|
323
|
+
|
|
|
324
|
+ adapterList := make([]*adapter.PerformanceIndicatorAdapter, 0)
|
|
|
325
|
+ categoryMap := map[string]int{} // 内容分类
|
|
|
326
|
+ for i := range in.UserIds {
|
|
|
327
|
+ userId := in.UserIds[i]
|
|
|
328
|
+ userIdInt, err := strconv.Atoi(userId)
|
|
|
329
|
+ if err != nil {
|
|
|
330
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
331
|
+ }
|
|
|
332
|
+
|
|
|
333
|
+ iupArray, ok := userProjectMap[userIdInt]
|
|
|
334
|
+ if !ok {
|
|
|
335
|
+ continue
|
|
|
336
|
+ }
|
|
|
337
|
+ var pia = &adapter.PerformanceIndicatorAdapter{
|
|
|
338
|
+ TargetUserId: userId,
|
|
|
339
|
+ TargetUserName: iupArray[0].TargetUserName,
|
|
|
340
|
+ PIContents: make([]adapter.PIContent, 0),
|
|
|
341
|
+ }
|
|
|
342
|
+ adapterList = append(adapterList, pia)
|
|
|
343
|
+ for _, assess := range iupArray {
|
|
|
344
|
+ items, ok := projectItemUsed[assess.EvaluationProjectId]
|
|
|
345
|
+ if !ok {
|
|
|
346
|
+ continue
|
|
|
347
|
+ }
|
|
|
348
|
+ for _, item := range items {
|
|
|
349
|
+ if len(item.Category) == 0 {
|
|
|
350
|
+ continue
|
|
|
351
|
+ }
|
|
|
352
|
+ onlyKey1 := userId + item.Category
|
|
|
353
|
+ if _, ok := categoryMap[onlyKey1]; !ok {
|
|
|
354
|
+ categoryMap[onlyKey1] = 0
|
|
|
355
|
+ // 不存在分类时,创建分类内容
|
|
|
356
|
+ pia.PIContents = append(pia.PIContents, adapter.PIContent{
|
|
|
357
|
+ Category: item.Category,
|
|
|
358
|
+ Names: make([]string, 0),
|
|
|
359
|
+ })
|
|
|
360
|
+ }
|
|
|
361
|
+
|
|
|
362
|
+ // 内容名称有值合并到数组
|
|
|
363
|
+ if len(item.Name) > 0 {
|
|
|
364
|
+ for index := range pia.PIContents {
|
|
|
365
|
+ piContent := &pia.PIContents[index]
|
|
|
366
|
+ if piContent.Category == item.Category {
|
|
|
367
|
+ piContent.Names = append(piContent.Names, item.Name)
|
|
|
368
|
+ break
|
|
|
369
|
+ }
|
|
|
370
|
+ }
|
|
|
371
|
+ }
|
|
|
372
|
+ }
|
|
|
373
|
+ }
|
|
|
374
|
+ }
|
|
|
375
|
+
|
|
|
376
|
+ /*
|
|
|
377
|
+ // 旧版(如果未填写自评会出现数据评估项丢失的BUG)
|
|
|
378
|
+ hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId)
|
|
|
379
|
+ if err != nil {
|
|
|
380
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
381
|
+ }
|
|
|
382
|
+
|
|
|
383
|
+ assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
|
239
|
list, err := assessDao.MemberPerformanceIndicator(
|
384
|
list, err := assessDao.MemberPerformanceIndicator(
|
240
|
in.UserName,
|
385
|
in.UserName,
|
241
|
in.CompanyId,
|
386
|
in.CompanyId,
|
|
@@ -326,10 +471,10 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP |
|
@@ -326,10 +471,10 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP |
326
|
}
|
471
|
}
|
327
|
|
472
|
|
328
|
}
|
473
|
}
|
329
|
-
|
|
|
330
|
- if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
331
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
332
|
- }
|
474
|
+ */
|
|
|
475
|
+ //if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
476
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
477
|
+ //}
|
333
|
|
478
|
|
334
|
return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil
|
479
|
return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil
|
335
|
}
|
480
|
}
|
|
@@ -374,8 +519,7 @@ func (srv StaffAssessServeice) ExportPerformanceIndicator(in *query.ExportPerfor |
|
@@ -374,8 +519,7 @@ func (srv StaffAssessServeice) ExportPerformanceIndicator(in *query.ExportPerfor |
374
|
for i := range list {
|
519
|
for i := range list {
|
375
|
it := list[i]
|
520
|
it := list[i]
|
376
|
if v, ok := selectedMap[it.TargetUserId]; ok {
|
521
|
if v, ok := selectedMap[it.TargetUserId]; ok {
|
377
|
- v.UserName = it.TargetUserName
|
|
|
378
|
-
|
522
|
+ //v.UserName = it.TargetUserName
|
379
|
if v.Category == it.ContentCategory && v.Name == it.ContentName {
|
523
|
if v.Category == it.ContentCategory && v.Name == it.ContentName {
|
380
|
conditionList = append(conditionList, it)
|
524
|
conditionList = append(conditionList, it)
|
381
|
conditionMap[it.TargetUserId+it.BeginDay] = it
|
525
|
conditionMap[it.TargetUserId+it.BeginDay] = it
|