|
@@ -231,105 +231,250 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP |
|
@@ -231,105 +231,250 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP |
231
|
transactionContext.RollbackTransaction()
|
231
|
transactionContext.RollbackTransaction()
|
232
|
}()
|
232
|
}()
|
233
|
|
233
|
|
234
|
- hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId)
|
|
|
235
|
- if err != nil {
|
|
|
236
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
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 {
|
|
|
271
|
+ hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId)
|
|
|
272
|
+ if err != nil {
|
|
|
273
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
274
|
+ }
|
|
|
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
|
+ }
|
237
|
}
|
302
|
}
|
238
|
- assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
239
|
- list, err := assessDao.MemberPerformanceIndicator(
|
|
|
240
|
- in.UserName,
|
|
|
241
|
- in.CompanyId,
|
|
|
242
|
- in.OperatorId,
|
|
|
243
|
- in.CycleId,
|
|
|
244
|
- hrbp,
|
|
|
245
|
- string(domain.AssessSelf),
|
|
|
246
|
- in.UserIds)
|
|
|
247
|
- if err != nil {
|
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 {
|
248
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
321
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
249
|
}
|
322
|
}
|
250
|
|
323
|
|
251
|
- // (全部周期数据)筛选出第一个周期的数据,减少后续数据遍历
|
|
|
252
|
- dupleMap := map[string]string{}
|
|
|
253
|
- dupleList := make([]dao.PerformanceIndicatorAssess, 0)
|
|
|
254
|
- for i := range list {
|
|
|
255
|
- it := list[i]
|
|
|
256
|
- if v, ok := dupleMap[it.TargetUserId]; ok {
|
|
|
257
|
- if v == it.BeginDay {
|
|
|
258
|
- dupleList = append(dupleList, it)
|
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
|
259
|
}
|
347
|
}
|
260
|
- } else {
|
|
|
261
|
- // 有内容分类,才算正常数据,反之不显示
|
|
|
262
|
- if len(it.ContentCategory) > 0 {
|
|
|
263
|
- dupleMap[it.TargetUserId] = it.BeginDay
|
|
|
264
|
- dupleList = append(dupleList, it)
|
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
|
+ }
|
265
|
}
|
372
|
}
|
266
|
}
|
373
|
}
|
267
|
}
|
374
|
}
|
268
|
|
375
|
|
269
|
- piaMap := map[string]*adapter.PerformanceIndicatorAdapter{}
|
|
|
270
|
- categoryMap := map[string]int{} // 内容分类
|
|
|
271
|
- //categoryNameMap := map[string]int{} // 内容分类下的名称
|
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
|
+ }
|
272
|
|
382
|
|
273
|
- adapterList := make([]*adapter.PerformanceIndicatorAdapter, 0)
|
|
|
274
|
- for i := range dupleList {
|
|
|
275
|
- it := dupleList[i]
|
|
|
276
|
-
|
|
|
277
|
- var pia *adapter.PerformanceIndicatorAdapter
|
|
|
278
|
- if v, ok := piaMap[it.TargetUserId]; ok {
|
|
|
279
|
- pia = v
|
|
|
280
|
- } else {
|
|
|
281
|
- pia = &adapter.PerformanceIndicatorAdapter{
|
|
|
282
|
- TargetUserId: it.TargetUserId,
|
|
|
283
|
- TargetUserName: it.TargetUserName,
|
|
|
284
|
- PIContents: make([]adapter.PIContent, 0),
|
383
|
+ assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
384
|
+ list, err := assessDao.MemberPerformanceIndicator(
|
|
|
385
|
+ in.UserName,
|
|
|
386
|
+ in.CompanyId,
|
|
|
387
|
+ in.OperatorId,
|
|
|
388
|
+ in.CycleId,
|
|
|
389
|
+ hrbp,
|
|
|
390
|
+ string(domain.AssessSelf),
|
|
|
391
|
+ in.UserIds)
|
|
|
392
|
+ if err != nil {
|
|
|
393
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
394
|
+ }
|
|
|
395
|
+
|
|
|
396
|
+ // (全部周期数据)筛选出第一个周期的数据,减少后续数据遍历
|
|
|
397
|
+ dupleMap := map[string]string{}
|
|
|
398
|
+ dupleList := make([]dao.PerformanceIndicatorAssess, 0)
|
|
|
399
|
+ for i := range list {
|
|
|
400
|
+ it := list[i]
|
|
|
401
|
+ if v, ok := dupleMap[it.TargetUserId]; ok {
|
|
|
402
|
+ if v == it.BeginDay {
|
|
|
403
|
+ dupleList = append(dupleList, it)
|
|
|
404
|
+ }
|
|
|
405
|
+ } else {
|
|
|
406
|
+ // 有内容分类,才算正常数据,反之不显示
|
|
|
407
|
+ if len(it.ContentCategory) > 0 {
|
|
|
408
|
+ dupleMap[it.TargetUserId] = it.BeginDay
|
|
|
409
|
+ dupleList = append(dupleList, it)
|
|
|
410
|
+ }
|
285
|
}
|
411
|
}
|
286
|
- piaMap[it.TargetUserId] = pia
|
|
|
287
|
- adapterList = append(adapterList, pia)
|
|
|
288
|
}
|
412
|
}
|
289
|
|
413
|
|
290
|
- // 分类名称有值才能合并分类数组
|
|
|
291
|
- if len(it.ContentCategory) > 0 {
|
|
|
292
|
- onlyKey1 := it.TargetUserId + it.ContentCategory
|
|
|
293
|
- if _, ok := categoryMap[onlyKey1]; !ok {
|
|
|
294
|
- categoryMap[onlyKey1] = 0
|
|
|
295
|
-
|
|
|
296
|
- // 不存在分类时,创建分类内容
|
|
|
297
|
- pia.PIContents = append(pia.PIContents, adapter.PIContent{
|
|
|
298
|
- Category: it.ContentCategory,
|
|
|
299
|
- Names: make([]string, 0),
|
|
|
300
|
- })
|
414
|
+ piaMap := map[string]*adapter.PerformanceIndicatorAdapter{}
|
|
|
415
|
+ categoryMap := map[string]int{} // 内容分类
|
|
|
416
|
+ //categoryNameMap := map[string]int{} // 内容分类下的名称
|
|
|
417
|
+
|
|
|
418
|
+ adapterList := make([]*adapter.PerformanceIndicatorAdapter, 0)
|
|
|
419
|
+ for i := range dupleList {
|
|
|
420
|
+ it := dupleList[i]
|
|
|
421
|
+
|
|
|
422
|
+ var pia *adapter.PerformanceIndicatorAdapter
|
|
|
423
|
+ if v, ok := piaMap[it.TargetUserId]; ok {
|
|
|
424
|
+ pia = v
|
|
|
425
|
+ } else {
|
|
|
426
|
+ pia = &adapter.PerformanceIndicatorAdapter{
|
|
|
427
|
+ TargetUserId: it.TargetUserId,
|
|
|
428
|
+ TargetUserName: it.TargetUserName,
|
|
|
429
|
+ PIContents: make([]adapter.PIContent, 0),
|
|
|
430
|
+ }
|
|
|
431
|
+ piaMap[it.TargetUserId] = pia
|
|
|
432
|
+ adapterList = append(adapterList, pia)
|
301
|
}
|
433
|
}
|
302
|
|
434
|
|
303
|
- // 内容名称有值合并到数组
|
|
|
304
|
- if len(it.ContentName) > 0 {
|
|
|
305
|
- // 周期筛选过的,不再需要唯一值验证判断,直接添加到对应的分类下
|
|
|
306
|
- for index := range pia.PIContents {
|
|
|
307
|
- piContent := &pia.PIContents[index]
|
|
|
308
|
- if piContent.Category == it.ContentCategory {
|
|
|
309
|
- piContent.Names = append(piContent.Names, it.ContentName)
|
|
|
310
|
- break
|
435
|
+ // 分类名称有值才能合并分类数组
|
|
|
436
|
+ if len(it.ContentCategory) > 0 {
|
|
|
437
|
+ onlyKey1 := it.TargetUserId + it.ContentCategory
|
|
|
438
|
+ if _, ok := categoryMap[onlyKey1]; !ok {
|
|
|
439
|
+ categoryMap[onlyKey1] = 0
|
|
|
440
|
+
|
|
|
441
|
+ // 不存在分类时,创建分类内容
|
|
|
442
|
+ pia.PIContents = append(pia.PIContents, adapter.PIContent{
|
|
|
443
|
+ Category: it.ContentCategory,
|
|
|
444
|
+ Names: make([]string, 0),
|
|
|
445
|
+ })
|
|
|
446
|
+ }
|
|
|
447
|
+
|
|
|
448
|
+ // 内容名称有值合并到数组
|
|
|
449
|
+ if len(it.ContentName) > 0 {
|
|
|
450
|
+ // 周期筛选过的,不再需要唯一值验证判断,直接添加到对应的分类下
|
|
|
451
|
+ for index := range pia.PIContents {
|
|
|
452
|
+ piContent := &pia.PIContents[index]
|
|
|
453
|
+ if piContent.Category == it.ContentCategory {
|
|
|
454
|
+ piContent.Names = append(piContent.Names, it.ContentName)
|
|
|
455
|
+ break
|
|
|
456
|
+ }
|
311
|
}
|
457
|
}
|
|
|
458
|
+ //onlyKey2 := it.TargetUserId + it.ContentCategory + it.ContentName
|
|
|
459
|
+ //if _, ok := categoryNameMap[onlyKey2]; !ok {
|
|
|
460
|
+ // categoryNameMap[onlyKey2] = 0
|
|
|
461
|
+ //
|
|
|
462
|
+ // for index := range pia.PIContents {
|
|
|
463
|
+ // piContent := pia.PIContents[index]
|
|
|
464
|
+ // if piContent.Category == it.ContentCategory {
|
|
|
465
|
+ // piContent.Names = append(piContent.Names, it.ContentName)
|
|
|
466
|
+ // break
|
|
|
467
|
+ // }
|
|
|
468
|
+ // }
|
|
|
469
|
+ //}
|
312
|
}
|
470
|
}
|
313
|
- //onlyKey2 := it.TargetUserId + it.ContentCategory + it.ContentName
|
|
|
314
|
- //if _, ok := categoryNameMap[onlyKey2]; !ok {
|
|
|
315
|
- // categoryNameMap[onlyKey2] = 0
|
|
|
316
|
- //
|
|
|
317
|
- // for index := range pia.PIContents {
|
|
|
318
|
- // piContent := pia.PIContents[index]
|
|
|
319
|
- // if piContent.Category == it.ContentCategory {
|
|
|
320
|
- // piContent.Names = append(piContent.Names, it.ContentName)
|
|
|
321
|
- // break
|
|
|
322
|
- // }
|
|
|
323
|
- // }
|
|
|
324
|
- //}
|
|
|
325
|
}
|
471
|
}
|
326
|
- }
|
|
|
327
|
|
472
|
|
328
|
- }
|
|
|
329
|
-
|
|
|
330
|
- if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
331
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
332
|
- }
|
473
|
+ }
|
|
|
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
|