|
@@ -264,6 +264,7 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev |
|
@@ -264,6 +264,7 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev |
|
264
|
Value: "",
|
264
|
Value: "",
|
|
265
|
Score: "",
|
265
|
Score: "",
|
|
266
|
Remark: "",
|
266
|
Remark: "",
|
|
|
|
267
|
+ EvaluatorId: v.EvaluatorId,
|
|
267
|
}
|
268
|
}
|
|
268
|
value, ok := valueMap[v.Id]
|
269
|
value, ok := valueMap[v.Id]
|
|
269
|
if ok {
|
270
|
if ok {
|
|
@@ -277,7 +278,7 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev |
|
@@ -277,7 +278,7 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev |
|
277
|
}
|
278
|
}
|
|
278
|
|
279
|
|
|
279
|
// 获取综合自评详情
|
280
|
// 获取综合自评详情
|
|
280
|
-func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvaluation) (*adapter.EvaluationInfoAdapter, error) {
|
281
|
+func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvaluation) (*adapter.EvaluationInfoSelfAdapter, error) {
|
|
281
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
282
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
282
|
if err != nil {
|
283
|
if err != nil {
|
|
283
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
284
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -299,7 +300,7 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu |
|
@@ -299,7 +300,7 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu |
|
299
|
})
|
300
|
})
|
|
300
|
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
301
|
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
301
|
"limit": 1,
|
302
|
"limit": 1,
|
|
302
|
- "cycleId": param.CompanyId,
|
303
|
+ "cycleId": param.CycleId,
|
|
303
|
"executorId": param.UserId,
|
304
|
"executorId": param.UserId,
|
|
304
|
"types": domain.EvaluationSelf,
|
305
|
"types": domain.EvaluationSelf,
|
|
305
|
})
|
306
|
})
|
|
@@ -325,18 +326,23 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu |
|
@@ -325,18 +326,23 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu |
|
325
|
if err != nil {
|
326
|
if err != nil {
|
|
326
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
327
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
327
|
}
|
328
|
}
|
|
328
|
- result := srv.getSummaryEvaluation(transactionContext, evaluationData)
|
329
|
+ //获取组装基本信息
|
|
|
|
330
|
+ evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationData)
|
|
329
|
if err := transactionContext.CommitTransaction(); err != nil {
|
331
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
330
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
332
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
331
|
}
|
333
|
}
|
|
332
|
|
334
|
|
|
333
|
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
|
335
|
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
|
|
|
|
336
|
+
|
|
|
|
337
|
+ result := adapter.EvaluationInfoSelfAdapter{
|
|
|
|
338
|
+ EvaluationBaseAdapter: evaluationBase,
|
|
|
|
339
|
+ }
|
|
334
|
result.EvaluationItems = itemValuesAdapter
|
340
|
result.EvaluationItems = itemValuesAdapter
|
|
335
|
- return result, nil
|
341
|
+ return &result, nil
|
|
336
|
}
|
342
|
}
|
|
337
|
|
343
|
|
|
338
|
-func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext application.TransactionContext, evaluationData *domain.SummaryEvaluation) *adapter.EvaluationInfoAdapter {
|
|
|
|
339
|
- result := adapter.EvaluationInfoAdapter{
|
344
|
+func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext application.TransactionContext, evaluationData *domain.SummaryEvaluation) adapter.EvaluationBaseAdapter {
|
|
|
|
345
|
+ result := adapter.EvaluationBaseAdapter{
|
|
340
|
SummaryEvaluationId: evaluationData.Id,
|
346
|
SummaryEvaluationId: evaluationData.Id,
|
|
341
|
CycleId: int(evaluationData.CycleId),
|
347
|
CycleId: int(evaluationData.CycleId),
|
|
342
|
CycleName: evaluationData.CycleName,
|
348
|
CycleName: evaluationData.CycleName,
|
|
@@ -352,7 +358,6 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app |
|
@@ -352,7 +358,6 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app |
|
352
|
SupperUser: "",
|
358
|
SupperUser: "",
|
|
353
|
DutyTime: "",
|
359
|
DutyTime: "",
|
|
354
|
Status: string(evaluationData.Status),
|
360
|
Status: string(evaluationData.Status),
|
|
355
|
- EvaluationItems: []adapter.EvaluationItemAdapter{},
|
|
|
|
356
|
}
|
361
|
}
|
|
357
|
//获取用户信息
|
362
|
//获取用户信息
|
|
358
|
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
|
363
|
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
|
|
@@ -367,30 +372,30 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app |
|
@@ -367,30 +372,30 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app |
|
367
|
})
|
372
|
})
|
|
368
|
|
373
|
|
|
369
|
if err != nil {
|
374
|
if err != nil {
|
|
370
|
- return &result
|
375
|
+ return result
|
|
371
|
}
|
376
|
}
|
|
372
|
|
377
|
|
|
373
|
userData, err := userRepo.FindOne(map[string]interface{}{
|
378
|
userData, err := userRepo.FindOne(map[string]interface{}{
|
|
374
|
"id": evaluationData.TargetUser.UserId,
|
379
|
"id": evaluationData.TargetUser.UserId,
|
|
375
|
})
|
380
|
})
|
|
376
|
if err != nil {
|
381
|
if err != nil {
|
|
377
|
- return &result
|
382
|
+ return result
|
|
378
|
}
|
383
|
}
|
|
379
|
result.DutyTime = userData.EntryTime
|
384
|
result.DutyTime = userData.EntryTime
|
|
380
|
result.CompanyLogo = companyData.Logo
|
385
|
result.CompanyLogo = companyData.Logo
|
|
381
|
result.CompanyName = companyData.Name
|
386
|
result.CompanyName = companyData.Name
|
|
382
|
|
387
|
|
|
383
|
if userData.ParentId <= 0 {
|
388
|
if userData.ParentId <= 0 {
|
|
384
|
- return &result
|
389
|
+ return result
|
|
385
|
}
|
390
|
}
|
|
386
|
pUserData, err := userRepo.FindOne(map[string]interface{}{
|
391
|
pUserData, err := userRepo.FindOne(map[string]interface{}{
|
|
387
|
"id": userData.ParentId,
|
392
|
"id": userData.ParentId,
|
|
388
|
})
|
393
|
})
|
|
389
|
if err != nil {
|
394
|
if err != nil {
|
|
390
|
- return &result
|
395
|
+ return result
|
|
391
|
}
|
396
|
}
|
|
392
|
result.SupperUser = pUserData.Name
|
397
|
result.SupperUser = pUserData.Name
|
|
393
|
- return &result
|
398
|
+ return result
|
|
394
|
}
|
399
|
}
|
|
395
|
|
400
|
|
|
396
|
// 编辑综合自评详情
|
401
|
// 编辑综合自评详情
|
|
@@ -556,23 +561,7 @@ func (srv *SummaryEvaluationService) GetTargetUserCycleList(param *command.Query |
|
@@ -556,23 +561,7 @@ func (srv *SummaryEvaluationService) GetTargetUserCycleList(param *command.Query |
|
556
|
}
|
561
|
}
|
|
557
|
|
562
|
|
|
558
|
// 自评小结详情
|
563
|
// 自评小结详情
|
|
559
|
-func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.QueryEvaluation) (*adapter.EvaluationInfoAdapter, error) {
|
|
|
|
560
|
- evaluationInfo, err := srv.GetEvaluationSelf(param)
|
|
|
|
561
|
- if err != nil {
|
|
|
|
562
|
- return nil, err
|
|
|
|
563
|
- }
|
|
|
|
564
|
- levelCodeMap := map[int][]adapter.LevalCodeCount{}
|
|
|
|
565
|
- for _, v := range evaluationInfo.EvaluationItems {
|
|
|
|
566
|
- codes := v.Rule.GetLevelCodes()
|
|
|
|
567
|
- levelCode := []adapter.LevalCodeCount{}
|
|
|
|
568
|
- for _, v2 := range codes {
|
|
|
|
569
|
- levelCode = append(levelCode, adapter.LevalCodeCount{
|
|
|
|
570
|
- Code: v2,
|
|
|
|
571
|
- Number: 0,
|
|
|
|
572
|
- })
|
|
|
|
573
|
- }
|
|
|
|
574
|
- levelCodeMap[v.EvaluationItemId] = levelCode
|
|
|
|
575
|
- }
|
564
|
+func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.QueryEvaluation) (*adapter.EvaluationInfoCountCodeAdapter, error) {
|
|
576
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
565
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
577
|
if err != nil {
|
566
|
if err != nil {
|
|
578
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
567
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -593,43 +582,396 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que |
|
@@ -593,43 +582,396 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que |
|
593
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
582
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
594
|
}
|
583
|
}
|
|
595
|
|
584
|
|
|
|
|
585
|
+ evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
|
586
|
+ "transactionContext": transactionContext,
|
|
|
|
587
|
+ })
|
|
|
|
588
|
+ evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
|
589
|
+ "transactionContext": transactionContext,
|
|
|
|
590
|
+ })
|
|
|
|
591
|
+ itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
|
|
|
|
592
|
+ "transactionContext": transactionContext,
|
|
|
|
593
|
+ })
|
|
|
|
594
|
+ _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
|
595
|
+ "limit": 1,
|
|
|
|
596
|
+ "cycleId": param.CycleId,
|
|
|
|
597
|
+ "executorId": param.UserId,
|
|
|
|
598
|
+ "types": domain.EvaluationSelf,
|
|
|
|
599
|
+ })
|
|
|
|
600
|
+ if err != nil {
|
|
|
|
601
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
602
|
+ }
|
|
|
|
603
|
+ if len(evaluationList) == 0 {
|
|
|
|
604
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
605
|
+ }
|
|
|
|
606
|
+ evaluationData := evaluationList[0]
|
|
|
|
607
|
+ _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
|
|
|
608
|
+ "evaluationProjectId": evaluationData.EvaluationProjectId,
|
|
|
|
609
|
+ "nodeType": int(domain.LinkNodeSelfAssessment),
|
|
|
|
610
|
+ })
|
|
|
|
611
|
+ if err != nil {
|
|
|
|
612
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
613
|
+ }
|
|
|
|
614
|
+
|
|
|
|
615
|
+ _, itemValues, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
|
616
|
+ "summaryEvaluationId": evaluationData.Id,
|
|
|
|
617
|
+ })
|
|
|
|
618
|
+
|
|
|
|
619
|
+ if err != nil {
|
|
|
|
620
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
621
|
+ }
|
|
|
|
622
|
+ // 获取组装基本信息
|
|
|
|
623
|
+ evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationData)
|
|
|
|
624
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
|
625
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
626
|
+ }
|
|
|
|
627
|
+
|
|
|
|
628
|
+ evaluationItems := srv.buildSummaryItemValue(itemList, itemValues)
|
|
|
|
629
|
+
|
|
|
|
630
|
+ levelCodeMap := map[int][]adapter.LevalCodeCount{}
|
|
|
|
631
|
+ for _, v := range evaluationItems {
|
|
|
|
632
|
+ codes := v.Rule.GetLevelCodes()
|
|
|
|
633
|
+ levelCode := []adapter.LevalCodeCount{}
|
|
|
|
634
|
+ for _, v2 := range codes {
|
|
|
|
635
|
+ levelCode = append(levelCode, adapter.LevalCodeCount{
|
|
|
|
636
|
+ Code: v2,
|
|
|
|
637
|
+ Number: 0,
|
|
|
|
638
|
+ })
|
|
|
|
639
|
+ }
|
|
|
|
640
|
+ levelCodeMap[v.EvaluationItemId] = levelCode
|
|
|
|
641
|
+ }
|
|
596
|
levelCodeCountMap := map[string]int{}
|
642
|
levelCodeCountMap := map[string]int{}
|
|
597
|
for _, v := range levelCodeCountList {
|
643
|
for _, v := range levelCodeCountList {
|
|
598
|
key := fmt.Sprintf("%s-%s-%s", v.Category, v.Name, v.LevelValue)
|
644
|
key := fmt.Sprintf("%s-%s-%s", v.Category, v.Name, v.LevelValue)
|
|
599
|
levelCodeCountMap[key] = v.Cnt
|
645
|
levelCodeCountMap[key] = v.Cnt
|
|
600
|
}
|
646
|
}
|
|
601
|
|
647
|
|
|
602
|
- for i := range evaluationInfo.EvaluationItems {
|
|
|
|
603
|
- itemId := evaluationInfo.EvaluationItems[i].EvaluationItemId
|
648
|
+ evaluationItemCount := []adapter.EvaluationItemCountCodeAdapter{}
|
|
|
|
649
|
+ for i := range evaluationItems {
|
|
|
|
650
|
+ itemCount := adapter.EvaluationItemCountCodeAdapter{
|
|
|
|
651
|
+ EvaluationItemAdapter: evaluationItems[i],
|
|
|
|
652
|
+ LevelCount: []adapter.LevalCodeCount{},
|
|
|
|
653
|
+ }
|
|
|
|
654
|
+ evaluationItemCount = append(evaluationItemCount, itemCount)
|
|
|
|
655
|
+ itemId := evaluationItems[i].EvaluationItemId
|
|
604
|
levelCodes, ok := levelCodeMap[itemId]
|
656
|
levelCodes, ok := levelCodeMap[itemId]
|
|
605
|
if !ok {
|
657
|
if !ok {
|
|
606
|
continue
|
658
|
continue
|
|
607
|
}
|
659
|
}
|
|
608
|
- evaluationInfo.EvaluationItems[i].LevelCount = levelCodes
|
660
|
+ evaluationItemCount[i].LevelCount = levelCodes
|
|
609
|
for i2 := range levelCodes {
|
661
|
for i2 := range levelCodes {
|
|
610
|
key := fmt.Sprintf("%s-%s-%s",
|
662
|
key := fmt.Sprintf("%s-%s-%s",
|
|
611
|
- evaluationInfo.EvaluationItems[i].Category,
|
|
|
|
612
|
- evaluationInfo.EvaluationItems[i].Name,
|
663
|
+ evaluationItems[i].Category,
|
|
|
|
664
|
+ evaluationItems[i].Name,
|
|
613
|
levelCodes[i2].Code,
|
665
|
levelCodes[i2].Code,
|
|
614
|
)
|
666
|
)
|
|
615
|
-
|
|
|
|
616
|
if mVal, ok := levelCodeCountMap[key]; ok {
|
667
|
if mVal, ok := levelCodeCountMap[key]; ok {
|
|
617
|
levelCodes[i2].Number = mVal
|
668
|
levelCodes[i2].Number = mVal
|
|
618
|
}
|
669
|
}
|
|
619
|
}
|
670
|
}
|
|
620
|
}
|
671
|
}
|
|
|
|
672
|
+ evaluationInfo := adapter.EvaluationInfoCountCodeAdapter{
|
|
|
|
673
|
+ EvaluationBaseAdapter: evaluationBase,
|
|
|
|
674
|
+ EvaluationItems: evaluationItemCount,
|
|
|
|
675
|
+ }
|
|
|
|
676
|
+ return &evaluationInfo, nil
|
|
|
|
677
|
+}
|
|
|
|
678
|
+
|
|
|
|
679
|
+// GetEvaluationSuper 根据执行人获取上级评估详情
|
|
|
|
680
|
+func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEvaluationSuper) (*adapter.EvaluationInfoSuperAdapter, error) {
|
|
|
|
681
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
|
682
|
+ if err != nil {
|
|
|
|
683
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
684
|
+ }
|
|
|
|
685
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
|
686
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
687
|
+ }
|
|
|
|
688
|
+ defer func() {
|
|
|
|
689
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
|
690
|
+ }()
|
|
|
|
691
|
+ evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
|
692
|
+ "transactionContext": transactionContext,
|
|
|
|
693
|
+ })
|
|
|
|
694
|
+ evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
|
695
|
+ "transactionContext": transactionContext,
|
|
|
|
696
|
+ })
|
|
|
|
697
|
+ itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
|
|
|
|
698
|
+ "transactionContext": transactionContext,
|
|
|
|
699
|
+ })
|
|
|
|
700
|
+ evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
|
|
|
|
701
|
+ "id": param.SummaryEvaluationId,
|
|
|
|
702
|
+ })
|
|
|
|
703
|
+ if err != nil {
|
|
|
|
704
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
705
|
+ }
|
|
|
|
706
|
+ if evaluationData.Types == domain.EvaluationSuper {
|
|
|
|
707
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
|
|
|
|
708
|
+ }
|
|
|
|
709
|
+ if evaluationData.CompanyId == param.CompanyId {
|
|
|
|
710
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
|
|
|
|
711
|
+ }
|
|
|
|
712
|
+ _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
|
|
|
713
|
+ "evaluationProjectId": evaluationData.EvaluationProjectId,
|
|
|
|
714
|
+ "nodeType": int(domain.LinkNodeSelfAssessment),
|
|
|
|
715
|
+ })
|
|
|
|
716
|
+ if err != nil {
|
|
|
|
717
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
718
|
+ }
|
|
|
|
719
|
+ //获取已填写的评估内容
|
|
|
|
720
|
+ _, itemValues, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
|
721
|
+ "summaryEvaluationId": evaluationData.Id,
|
|
|
|
722
|
+ })
|
|
|
|
723
|
+
|
|
|
|
724
|
+ if err != nil {
|
|
|
|
725
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
726
|
+ }
|
|
|
|
727
|
+ if len(itemValues) == 0 {
|
|
|
|
728
|
+ //上级还未填写评估,获取 360 ,人资评估
|
|
|
|
729
|
+ _, evaluationListOther, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
|
730
|
+ "typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},
|
|
|
|
731
|
+ "targetUserId": evaluationData.TargetUser.UserId,
|
|
|
|
732
|
+ "cycleId": evaluationData.CycleId,
|
|
|
|
733
|
+ })
|
|
|
|
734
|
+ if err != nil {
|
|
|
|
735
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
736
|
+ }
|
|
|
|
737
|
+ evaluationIds := []int{}
|
|
|
|
738
|
+ for _, v := range evaluationListOther {
|
|
|
|
739
|
+ evaluationIds = append(evaluationIds, v.Id)
|
|
|
|
740
|
+ }
|
|
|
|
741
|
+ if len(evaluationIds) > 0 {
|
|
|
|
742
|
+ _, itemValues, err = itemValueRepo.Find(map[string]interface{}{
|
|
|
|
743
|
+ "summaryEvaluationIdList": evaluationIds,
|
|
|
|
744
|
+ })
|
|
|
|
745
|
+ if err != nil {
|
|
|
|
746
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
747
|
+ }
|
|
|
|
748
|
+ }
|
|
|
|
749
|
+ }
|
|
|
|
750
|
+ evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationData)
|
|
621
|
if err := transactionContext.CommitTransaction(); err != nil {
|
751
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
622
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
752
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
623
|
}
|
753
|
}
|
|
624
|
- return evaluationInfo, nil
|
754
|
+ //组合 评估填写的值和评估项
|
|
|
|
755
|
+ itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
|
|
|
|
756
|
+ codeList := []*adapter.LevalCodeCount{}
|
|
|
|
757
|
+ codeMap := map[string]*adapter.LevalCodeCount{}
|
|
|
|
758
|
+ for _, v := range itemValuesAdapter {
|
|
|
|
759
|
+ if v.Weight > 0 {
|
|
|
|
760
|
+ continue
|
|
|
|
761
|
+ }
|
|
|
|
762
|
+ if _, ok := codeMap[v.Value]; !ok {
|
|
|
|
763
|
+ code := &adapter.LevalCodeCount{
|
|
|
|
764
|
+ Code: v.Value,
|
|
|
|
765
|
+ Number: 0,
|
|
|
|
766
|
+ ItemList: []string{},
|
|
|
|
767
|
+ }
|
|
|
|
768
|
+ codeMap[v.Value] = code
|
|
|
|
769
|
+ codeList = append(codeList, code)
|
|
|
|
770
|
+ }
|
|
|
|
771
|
+ codeMap[v.Value].ItemList = append(codeMap[v.Value].ItemList, v.Name)
|
|
|
|
772
|
+ codeMap[v.Value].Number += 1
|
|
|
|
773
|
+ }
|
|
|
|
774
|
+ result := adapter.EvaluationInfoSuperAdapter{
|
|
|
|
775
|
+ EvaluationBaseAdapter: evaluationBase,
|
|
|
|
776
|
+ LevelCount: codeList,
|
|
|
|
777
|
+ EvaluationItems: itemValuesAdapter,
|
|
|
|
778
|
+ }
|
|
|
|
779
|
+ return &result, nil
|
|
625
|
}
|
780
|
}
|
|
626
|
|
781
|
|
|
627
|
-// GetEvaluationSuper 根据执行人获取上级评估详情
|
|
|
|
628
|
-func (srv *SummaryEvaluationService) GetEvaluationSuper() {
|
782
|
+// EditEvaluationSuper 更新上级评估内容
|
|
|
|
783
|
+func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEvaluationValue) (interface{}, error) {
|
|
|
|
784
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
|
785
|
+ if err != nil {
|
|
|
|
786
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
787
|
+ }
|
|
|
|
788
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
|
789
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
790
|
+ }
|
|
|
|
791
|
+ defer func() {
|
|
|
|
792
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
|
793
|
+ }()
|
|
|
|
794
|
+ evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
|
795
|
+ "transactionContext": transactionContext,
|
|
|
|
796
|
+ })
|
|
|
|
797
|
+ itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
|
798
|
+ "transactionContext": transactionContext,
|
|
|
|
799
|
+ })
|
|
629
|
|
800
|
|
|
|
|
801
|
+ itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
|
|
|
|
802
|
+ "transactionContext": transactionContext,
|
|
|
|
803
|
+ })
|
|
|
|
804
|
+ evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
|
|
|
|
805
|
+ "id": param.SummaryEvaluationId,
|
|
|
|
806
|
+ })
|
|
|
|
807
|
+ if err != nil {
|
|
|
|
808
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
809
|
+ }
|
|
|
|
810
|
+ if evaluationData.Types != domain.EvaluationSuper {
|
|
|
|
811
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
|
812
|
+ }
|
|
|
|
813
|
+
|
|
|
|
814
|
+ if evaluationData.Executor.UserId != param.ExecutorId {
|
|
|
|
815
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
|
816
|
+ }
|
|
|
|
817
|
+
|
|
|
|
818
|
+ if evaluationData.CompanyId != param.CompanyId {
|
|
|
|
819
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
|
820
|
+ }
|
|
|
|
821
|
+
|
|
|
|
822
|
+ _, itemList, err := itemUsedRepo.Find(map[string]interface{}{
|
|
|
|
823
|
+ "evaluationProjectId": evaluationData.EvaluationProjectId,
|
|
|
|
824
|
+ "nodeType": domain.LinkNodeSelfAssessment,
|
|
|
|
825
|
+ })
|
|
|
|
826
|
+ if err != nil {
|
|
|
|
827
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
828
|
+ }
|
|
|
|
829
|
+ //获取已填写的评估内容
|
|
|
|
830
|
+ _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
|
831
|
+ "summaryEvaluationId": evaluationData.Id,
|
|
|
|
832
|
+ })
|
|
|
|
833
|
+ if err != nil {
|
|
|
|
834
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
835
|
+ }
|
|
|
|
836
|
+ //记录人资评估或者360评估的 填写项id
|
|
|
|
837
|
+ hrbpOr360ItemValue, err := srv.getEvaluationSuperDefaultValue(transactionContext, evaluationData)
|
|
|
|
838
|
+ if err != nil {
|
|
|
|
839
|
+ return nil, err
|
|
|
|
840
|
+ }
|
|
|
|
841
|
+ evaluationValueMap := map[int]*domain.SummaryEvaluationValue{}
|
|
|
|
842
|
+ for _, v := range itemList {
|
|
|
|
843
|
+ newValue := &domain.SummaryEvaluationValue{}
|
|
|
|
844
|
+ newValue.SetBlankValue(evaluationData, v)
|
|
|
|
845
|
+ evaluationValueMap[v.Id] = newValue
|
|
|
|
846
|
+ }
|
|
|
|
847
|
+ for _, v := range itemValueList {
|
|
|
|
848
|
+ if mValue, ok := evaluationValueMap[v.EvaluationItemId]; ok {
|
|
|
|
849
|
+ mValue.Id = v.Id
|
|
|
|
850
|
+ }
|
|
|
|
851
|
+ }
|
|
|
|
852
|
+ nowTime := time.Now()
|
|
|
|
853
|
+ for _, v := range param.EvaluationItems {
|
|
|
|
854
|
+ updatedData, ok := evaluationValueMap[v.EvaluationItemId]
|
|
|
|
855
|
+ if !ok {
|
|
|
|
856
|
+ continue
|
|
|
|
857
|
+ }
|
|
|
|
858
|
+ if defaultValue, ok := hrbpOr360ItemValue[v.EvaluationItemId]; ok {
|
|
|
|
859
|
+ updatedData.Value = defaultValue.Value
|
|
|
|
860
|
+ } else {
|
|
|
|
861
|
+ updatedData.Value = v.Value
|
|
|
|
862
|
+ }
|
|
|
|
863
|
+ updatedData.UpdatedAt = nowTime
|
|
|
|
864
|
+ updatedData.Remark = v.Remark
|
|
|
|
865
|
+ //计算得分
|
|
|
|
866
|
+ err = updatedData.SummaryEvaluationScore()
|
|
|
|
867
|
+ if err != nil {
|
|
|
|
868
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
|
869
|
+ }
|
|
|
|
870
|
+ }
|
|
|
|
871
|
+ evaluationValueList := []*domain.SummaryEvaluationValue{}
|
|
|
|
872
|
+ for _, v := range evaluationValueMap {
|
|
|
|
873
|
+ //保存填写值
|
|
|
|
874
|
+ err = itemValueRepo.Save(v)
|
|
|
|
875
|
+ if err != nil {
|
|
|
|
876
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
877
|
+ }
|
|
|
|
878
|
+ evaluationValueList = append(evaluationValueList, v)
|
|
|
|
879
|
+ }
|
|
|
|
880
|
+ //计算总得分
|
|
|
|
881
|
+ err = evaluationData.EvaluationTotalScore(evaluationValueList)
|
|
|
|
882
|
+ if err != nil {
|
|
|
|
883
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
884
|
+ }
|
|
|
|
885
|
+ evaluationData.UpdatedAt = nowTime
|
|
|
|
886
|
+ evaluationData.Status = domain.EvaluationCompleted
|
|
|
|
887
|
+ //保存填写值
|
|
|
|
888
|
+ err = evaluationRepo.Save(evaluationData)
|
|
|
|
889
|
+ if err != nil {
|
|
|
|
890
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
891
|
+ }
|
|
|
|
892
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
|
893
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
894
|
+ }
|
|
|
|
895
|
+ itemValueAdapter := srv.buildSummaryItemValue(itemList, evaluationValueList)
|
|
|
|
896
|
+ return map[string][]adapter.EvaluationItemAdapter{
|
|
|
|
897
|
+ "EvaluationItems": itemValueAdapter,
|
|
|
|
898
|
+ }, nil
|
|
630
|
}
|
899
|
}
|
|
631
|
|
900
|
|
|
632
|
-// EditEvaluationSuper 更新上级评估
|
|
|
|
633
|
-func (srv *SummaryEvaluationService) EditEvaluationSuper() {
|
901
|
+// getEvaluationSuperDefaultValue
|
|
|
|
902
|
+// 按照权限设置,是否获取上级评估内容的默认值
|
|
|
|
903
|
+func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionContext application.TransactionContext, evaluationData *domain.SummaryEvaluation) (
|
|
|
|
904
|
+ map[int]*domain.SummaryEvaluationValue, error) {
|
|
|
|
905
|
+ evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
|
906
|
+ "transactionContext": transactionContext,
|
|
|
|
907
|
+ })
|
|
|
|
908
|
+
|
|
|
|
909
|
+ itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
|
|
|
|
910
|
+ "transactionContext": transactionContext,
|
|
|
|
911
|
+ })
|
|
|
|
912
|
+
|
|
|
|
913
|
+ permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
914
|
+ // 获取权限配置
|
|
|
|
915
|
+ _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": evaluationData.CompanyId})
|
|
|
|
916
|
+ if err != nil {
|
|
|
|
917
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
918
|
+ }
|
|
|
|
919
|
+ if len(permissionList) == 0 {
|
|
|
|
920
|
+ return nil, nil
|
|
|
|
921
|
+ }
|
|
|
|
922
|
+ permissionData := permissionList[0]
|
|
|
|
923
|
+ if permissionData.OptEvalScore == domain.PermissionOn && permissionData.OptHrScore == domain.PermissionOn {
|
|
|
|
924
|
+ return nil, nil
|
|
|
|
925
|
+ }
|
|
|
|
926
|
+ // 获取360评估,人资评估填写的值
|
|
|
|
927
|
+ _, evaluationListOther, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
|
928
|
+ "typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},
|
|
|
|
929
|
+ "targetUserId": evaluationData.TargetUser.UserId,
|
|
|
|
930
|
+ "cycleId": evaluationData.CycleId,
|
|
|
|
931
|
+ })
|
|
|
|
932
|
+ if err != nil {
|
|
|
|
933
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
934
|
+ }
|
|
|
|
935
|
+ evaluationIds := []int{}
|
|
|
|
936
|
+ for _, v := range evaluationListOther {
|
|
|
|
937
|
+ evaluationIds = append(evaluationIds, v.Id)
|
|
|
|
938
|
+ }
|
|
|
|
939
|
+ if len(evaluationIds) == 0 {
|
|
|
|
940
|
+ return nil, nil
|
|
|
|
941
|
+ }
|
|
|
|
942
|
+ // 将360评估,人资评估填写的值 作为默认值
|
|
|
|
943
|
+ _, itemValuesOther, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
|
944
|
+ "summaryEvaluationIdList": evaluationIds,
|
|
|
|
945
|
+ })
|
|
|
|
946
|
+ if err != nil {
|
|
|
|
947
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
948
|
+ }
|
|
|
|
949
|
+ // 记录人资评估或者360评估的 填写项id
|
|
|
|
950
|
+ hrbpOr360ItemValue := map[int]*domain.SummaryEvaluationValue{}
|
|
|
|
951
|
+
|
|
|
|
952
|
+ result := map[int]*domain.SummaryEvaluationValue{}
|
|
|
|
953
|
+ if permissionData.OptEvalScore == domain.PermissionOff {
|
|
|
|
954
|
+ //上级是否可以修改360°综评分数
|
|
|
|
955
|
+ //获取360综合评分
|
|
|
|
956
|
+ for _, v := range itemValuesOther {
|
|
|
|
957
|
+ //记录人资评估或者360评估的填写值
|
|
|
|
958
|
+ if v.Types != domain.Evaluation360 {
|
|
|
|
959
|
+ continue
|
|
|
|
960
|
+ }
|
|
|
|
961
|
+ hrbpOr360ItemValue[v.EvaluationItemId] = v
|
|
|
|
962
|
+ }
|
|
|
|
963
|
+ }
|
|
|
|
964
|
+ if permissionData.OptHrScore == domain.PermissionOff {
|
|
|
|
965
|
+ //上级是否可以修改人资综评分数
|
|
|
|
966
|
+ //获取人资综合评分
|
|
|
|
967
|
+ for _, v := range itemValuesOther {
|
|
|
|
968
|
+ //记录人资评估或者360评估的填写值
|
|
|
|
969
|
+ if v.Types != domain.EvaluationHrbp {
|
|
|
|
970
|
+ continue
|
|
|
|
971
|
+ }
|
|
634
|
|
972
|
|
|
|
|
973
|
+ hrbpOr360ItemValue[v.EvaluationItemId] = v
|
|
|
|
974
|
+ }
|
|
|
|
975
|
+ }
|
|
|
|
976
|
+ return result, nil
|
|
635
|
} |
977
|
} |