作者 tangxvhui
@@ -56,13 +56,15 @@ func (srv *SummaryEvaluationService) GetEvaluationFinish(param *command.QueryEva @@ -56,13 +56,15 @@ func (srv *SummaryEvaluationService) GetEvaluationFinish(param *command.QueryEva
56 } 56 }
57 // 考核结果不存在 -> 获取上级考核 -> 获取360+HRBP+自评 57 // 考核结果不存在 -> 获取上级考核 -> 获取360+HRBP+自评
58 if len(itemValues) == 0 { 58 if len(itemValues) == 0 {
59 - itemValues, evaluationList, err := srv.findCycleItemValueByType(transactionContext, result.CycleId, result.TargetUser.UserId, []int{int(domain.EvaluationSuper)}) 59 + superValues, evaluationList, err := srv.findCycleItemValueByType(transactionContext, result.CycleId, result.TargetUser.UserId, []int{int(domain.EvaluationSuper)})
60 if err != nil { 60 if err != nil {
61 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 61 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
62 } 62 }
63 - // 上级评估不存在(有上级考核类型时,不管分数有没有填写都算,没填写当作零)  
64 - if len(evaluationList) == 0 {  
65 - itemValues, _, err = srv.findCycleItemValueByType(transactionContext, result.CycleId, result.TargetUser.UserId, []int{int(domain.EvaluationSelf)}) 63 + // 上级评估存在(有上级考核类型时,不管分数有没有填写都算,没填写当作零)
  64 + if len(evaluationList) > 0 {
  65 + itemValues = superValues
  66 + } else {
  67 + selfValues, _, err := srv.findCycleItemValueByType(transactionContext, result.CycleId, result.TargetUser.UserId, []int{int(domain.EvaluationSelf)})
66 if err != nil { 68 if err != nil {
67 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 69 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
68 } 70 }
@@ -71,7 +73,7 @@ func (srv *SummaryEvaluationService) GetEvaluationFinish(param *command.QueryEva @@ -71,7 +73,7 @@ func (srv *SummaryEvaluationService) GetEvaluationFinish(param *command.QueryEva
71 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 73 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
72 } 74 }
73 // 自评分数 75 // 自评分数
74 - if len(itemValues) == 0 { 76 + if len(selfValues) == 0 {
75 itemValues = hrItemValues 77 itemValues = hrItemValues
76 } else { 78 } else {
77 // HR360分数 替换 自评分数 79 // HR360分数 替换 自评分数
@@ -79,14 +81,24 @@ func (srv *SummaryEvaluationService) GetEvaluationFinish(param *command.QueryEva @@ -79,14 +81,24 @@ func (srv *SummaryEvaluationService) GetEvaluationFinish(param *command.QueryEva
79 for i := range hrItemValues { 81 for i := range hrItemValues {
80 hrItemMap[hrItemValues[i].EvaluationItemId] = hrItemValues[i] 82 hrItemMap[hrItemValues[i].EvaluationItemId] = hrItemValues[i]
81 } 83 }
82 - for i := range itemValues {  
83 - it := itemValues[i] 84 + for i := range selfValues {
  85 + it := selfValues[i]
84 if v, ok := hrItemMap[it.EvaluationItemId]; ok { 86 if v, ok := hrItemMap[it.EvaluationItemId]; ok {
85 - itemValues[i] = v 87 + selfValues[i] = v
86 } 88 }
87 } 89 }
  90 + itemValues = selfValues
88 } 91 }
89 } 92 }
  93 +
  94 + // 重新计算成绩
  95 + result.TotalRating = nil
  96 + for i := range itemList {
  97 + result.ResetTotalRating(itemList[i])
  98 + }
  99 + if err = result.EvaluationTotalScore(itemValues); err != nil {
  100 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  101 + }
90 } 102 }
91 103
92 evaluationBase := srv.getSummaryEvaluation(transactionContext, result) 104 evaluationBase := srv.getSummaryEvaluation(transactionContext, result)
@@ -203,6 +215,7 @@ func (srv *SummaryEvaluationService) EditEvaluationFinish(param *command.EditEva @@ -203,6 +215,7 @@ func (srv *SummaryEvaluationService) EditEvaluationFinish(param *command.EditEva
203 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 215 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
204 } 216 }
205 } 217 }
  218 +
206 result.Status = domain.EvaluationCompleted 219 result.Status = domain.EvaluationCompleted
207 result.CheckResult = domain.EvaluationCheckUncompleted 220 result.CheckResult = domain.EvaluationCheckUncompleted
208 err = evaluationRepo.Save(result) 221 err = evaluationRepo.Save(result)
@@ -1349,7 +1349,6 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi @@ -1349,7 +1349,6 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi
1349 }() 1349 }()
1350 1350
1351 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) 1351 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
1352 - evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})  
1353 itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext}) 1352 itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
1354 1353
1355 // 考核结果 1354 // 考核结果
@@ -1380,6 +1379,8 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi @@ -1380,6 +1379,8 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi
1380 if len(itemValues) > 0 { 1379 if len(itemValues) > 0 {
1381 // do nothing... 1380 // do nothing...
1382 } else { 1381 } else {
  1382 + evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
  1383 +
1383 // 周期内所有评估类型 1384 // 周期内所有评估类型
1384 _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ 1385 _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
1385 "companyId": result.CompanyId, 1386 "companyId": result.CompanyId,
@@ -1399,23 +1400,19 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi @@ -1399,23 +1400,19 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi
1399 } 1400 }
1400 } 1401 }
1401 1402
1402 - // 评估内容和值  
1403 - var itemList []*domain.EvaluationItemUsed  
1404 - var itemValues []*domain.SummaryEvaluationValue  
1405 -  
1406 // 获取自评模板 1403 // 获取自评模板
1407 - _, itemList, err = evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment}) 1404 + _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
1408 if err != nil { 1405 if err != nil {
1409 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1406 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1410 } 1407 }
1411 1408
1412 if super != nil { 1409 if super != nil {
1413 - _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": super.Id}) // 获取已填写的评估内容 1410 + _, superValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": super.Id}) // 获取已填写的评估内容
1414 if err != nil { 1411 if err != nil {
1415 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1412 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1416 } 1413 }
1417 // 更新填写值 1414 // 更新填写值
1418 - itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, true) 1415 + itemValues, err = srv.updateItemValuePriority(result, itemList, superValues, true)
1419 if err != nil { 1416 if err != nil {
1420 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1417 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1421 } 1418 }
@@ -1430,13 +1427,13 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi @@ -1430,13 +1427,13 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi
1430 } 1427 }
1431 if len(evaluationIds) > 0 { 1428 if len(evaluationIds) > 0 {
1432 // 已填写的评估内容 1429 // 已填写的评估内容
1433 - _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds}) 1430 + _, otherValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds})
1434 if err != nil { 1431 if err != nil {
1435 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1432 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1436 } 1433 }
1437 1434
1438 // 更新填写值 1435 // 更新填写值
1439 - itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, false) 1436 + itemValues, err = srv.updateItemValuePriority(result, itemList, otherValues, false)
1440 if err != nil { 1437 if err != nil {
1441 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1438 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1442 } 1439 }
@@ -1559,41 +1556,41 @@ func (srv *SummaryEvaluationService) GetTargetEvaluationResult(param *command.Qu @@ -1559,41 +1556,41 @@ func (srv *SummaryEvaluationService) GetTargetEvaluationResult(param *command.Qu
1559 if err != nil { 1556 if err != nil {
1560 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1557 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1561 } 1558 }
1562 -  
1563 var result *domain.SummaryEvaluation // 绩效考核结果项 1559 var result *domain.SummaryEvaluation // 绩效考核结果项
1564 - var super *domain.SummaryEvaluation // 上级评估  
1565 for i := range evaluationList { 1560 for i := range evaluationList {
1566 it := evaluationList[i] 1561 it := evaluationList[i]
1567 if it.Types == domain.EvaluationFinish { 1562 if it.Types == domain.EvaluationFinish {
1568 result = it 1563 result = it
1569 - continue  
1570 - }  
1571 - if it.Types == domain.EvaluationSuper {  
1572 - super = it  
1573 - continue 1564 + break
1574 } 1565 }
1575 } 1566 }
1576 if result == nil { 1567 if result == nil {
1577 return &adapter.EvaluationInfoSuperAdapter{}, nil 1568 return &adapter.EvaluationInfoSuperAdapter{}, nil
1578 } 1569 }
1579 - // 评估内容和值  
1580 - var itemList []*domain.EvaluationItemUsed  
1581 - var itemValues []*domain.SummaryEvaluationValue  
1582 1570
1583 // 获取自评模板内容 1571 // 获取自评模板内容
1584 - _, itemList, err = evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment}) 1572 + _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
1585 if err != nil { 1573 if err != nil {
1586 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1574 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1587 } 1575 }
1588 1576
1589 // 获取考核结果评分 1577 // 获取考核结果评分
1590 - _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": result.Id}) 1578 + _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": result.Id})
1591 if err != nil { 1579 if err != nil {
1592 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1580 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1593 } 1581 }
1594 1582
1595 // 不存在考核结果评分时(考核评分 -> 上级评分 -> 360+HR+自评) 1583 // 不存在考核结果评分时(考核评分 -> 上级评分 -> 360+HR+自评)
1596 if len(itemValues) == 0 { 1584 if len(itemValues) == 0 {
  1585 + var super *domain.SummaryEvaluation // 上级评估
  1586 + for i := range evaluationList {
  1587 + it := evaluationList[i]
  1588 + if it.Types == domain.EvaluationSuper {
  1589 + super = it
  1590 + break
  1591 + }
  1592 + }
  1593 +
1597 if super != nil { 1594 if super != nil {
1598 _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": super.Id}) // 获取已填写的评估内容 1595 _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": super.Id}) // 获取已填写的评估内容
1599 if err != nil { 1596 if err != nil {
@@ -1610,27 +1607,24 @@ func (srv *SummaryEvaluationService) GetTargetEvaluationResult(param *command.Qu @@ -1610,27 +1607,24 @@ func (srv *SummaryEvaluationService) GetTargetEvaluationResult(param *command.Qu
1610 } 1607 }
1611 if len(evaluationIds) > 0 { 1608 if len(evaluationIds) > 0 {
1612 // 获取已填写的评估内容 1609 // 获取已填写的评估内容
1613 - _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds}) 1610 + _, otherValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds})
1614 if err != nil { 1611 if err != nil {
1615 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1612 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1616 } 1613 }
1617 1614
1618 // 更新填写值 1615 // 更新填写值
1619 - itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, false) 1616 + itemValues, err = srv.updateItemValuePriority(result, itemList, otherValues, false)
1620 if err != nil { 1617 if err != nil {
1621 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1618 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1622 } 1619 }
1623 } 1620 }
1624 } 1621 }
1625 - }  
1626 - // 未完成考核,需要重新计算分数  
1627 - if result.CheckResult == domain.EvaluationCheckUncompleted {  
1628 - result.TotalRating = nil  
1629 - for i := range itemList {  
1630 - result.ResetTotalRating(itemList[i])  
1631 - }  
1632 - //存在 超级管理员直接修改填写 总分的情况,此时不重新计算总分  
1633 - if result.TotalScore == "0" || result.TotalScore == "" { 1622 + // 未完成考核,需要重新计算分数
  1623 + if result.CheckResult == domain.EvaluationCheckUncompleted {
  1624 + result.TotalRating = nil
  1625 + for i := range itemList {
  1626 + result.ResetTotalRating(itemList[i])
  1627 + }
1634 if err = result.EvaluationTotalScore(itemValues); err != nil { 1628 if err = result.EvaluationTotalScore(itemValues); err != nil {
1635 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1629 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1636 } 1630 }
@@ -724,131 +724,7 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBPComplete(param *command.Qu @@ -724,131 +724,7 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBPComplete(param *command.Qu
724 return &itemValuesAdapter, nil 724 return &itemValuesAdapter, nil
725 } 725 }
726 726
727 -// EditEvaluationHRBP 编辑提交人资综评  
728 -// func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) {  
729 -// lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)  
730 -// err := lock.Lock()  
731 -// if err != nil {  
732 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")  
733 -// }  
734 -// defer func() {  
735 -// lock.UnLock()  
736 -// }()  
737 -// transactionContext, err := factory.CreateTransactionContext(nil)  
738 -// if err != nil {  
739 -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
740 -// }  
741 -// if err := transactionContext.StartTransaction(); err != nil {  
742 -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
743 -// }  
744 -// defer func() {  
745 -// _ = transactionContext.RollbackTransaction()  
746 -// }()  
747 -  
748 -// userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})  
749 -// evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})  
750 -// itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})  
751 -// itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})  
752 -  
753 -// // 必须是HRBP权限的人才能编辑操作  
754 -// hrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.ExecutorId)  
755 -// if err != nil {  
756 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
757 -// }  
758 -// if hrbp != domain.RoleTypeSystem {  
759 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")  
760 -// }  
761 -  
762 -// summaryEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})  
763 -// if err != nil {  
764 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
765 -// }  
766 -// if summaryEvaluation.Types != domain.EvaluationHrbp {  
767 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")  
768 -// }  
769 -// if summaryEvaluation.CompanyId != param.CompanyId {  
770 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")  
771 -// }  
772 -  
773 -// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{  
774 -// "targetUserId": summaryEvaluation.TargetUser.UserId,  
775 -// "typesList": []int{int(domain.EvaluationFinish)},  
776 -// "cycleId": summaryEvaluation.CycleId,  
777 -// "limit": 1,  
778 -// })  
779 -// if err != nil {  
780 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
781 -// }  
782 -// // 如果目标员工已经确认考核结果,就不能在进行评估编辑  
783 -// if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted {  
784 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能再编辑!")  
785 -// }  
786 -  
787 -// // 自评评估内容(自评模板、筛选项目评估人)  
788 -// _, itemList, err := itemUsedRepo.Find(map[string]interface{}{  
789 -// "evaluationProjectId": summaryEvaluation.EvaluationProjectId,  
790 -// "nodeType": domain.LinkNodeSelfAssessment,  
791 -// "evaluatorId": -1,  
792 -// })  
793 -// if err != nil {  
794 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
795 -// }  
796 -  
797 -// // 评估内容对应的分数  
798 -// _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": summaryEvaluation.Id})  
799 -// if err != nil {  
800 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
801 -// }  
802 -  
803 -// err = srv.editEvaluationValue(summaryEvaluation, &itemValueList, itemList, param.EvaluationItems, nil, param.IsTemporary)  
804 -// if err != nil {  
805 -// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())  
806 -// }  
807 -// if !param.IsTemporary {  
808 -// //变更评估状态为已填写  
809 -// summaryEvaluation.Status = domain.EvaluationCompleted  
810 -// }  
811 -// //保存填写值  
812 -// for _, v := range itemValueList {  
813 -// err = itemValueRepo.Save(v)  
814 -// if err != nil {  
815 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
816 -// }  
817 -// }  
818 -  
819 -// // 针对HRBP类型,更新最后一次操作的HRBP人  
820 -// user, err := userRepo.FindOne(map[string]interface{}{"id": param.ExecutorId})  
821 -// if err != nil {  
822 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
823 -// }  
824 -// summaryEvaluation.Executor.UserId = param.ExecutorId  
825 -// summaryEvaluation.Executor.Account = user.Account  
826 -// summaryEvaluation.Executor.UserName = user.Name  
827 -// summaryEvaluation.Executor.CompanyName = "" // 暂时无用  
828 -// summaryEvaluation.Status = domain.EvaluationCompleted  
829 -  
830 -// //保存填写值  
831 -// err = evaluationRepo.Save(summaryEvaluation)  
832 -// if err != nil {  
833 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
834 -// }  
835 -// if err := transactionContext.CommitTransaction(); err != nil {  
836 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
837 -// }  
838 -  
839 -// if !param.IsTemporary {  
840 -// err = srv.AfterCompletedEvaluation360Hrbp(summaryEvaluation)  
841 -// if err != nil {  
842 -// return nil, err  
843 -// }  
844 -// }  
845 -// itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)  
846 -// return map[string][]adapter.EvaluationItemAdapter{  
847 -// "evaluationItems": itemValueAdapter,  
848 -// }, nil  
849 -// }  
850 -  
851 -// 修改周期考核的分数 727 +// ModifyFinishScore 修改周期考核的分数
852 // func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFinishScore) error { 728 // func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFinishScore) error {
853 // transactionContext, err := factory.CreateTransactionContext(nil) 729 // transactionContext, err := factory.CreateTransactionContext(nil)
854 // if err != nil { 730 // if err != nil {
@@ -869,27 +745,115 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBPComplete(param *command.Qu @@ -869,27 +745,115 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBPComplete(param *command.Qu
869 // return application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") 745 // return application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
870 // } 746 // }
871 747
872 -// //获取周期评估任务finish 748 +// // 获取周期评估任务finish
873 // evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) 749 // evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
874 -// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{  
875 -// "id": []int{param.SummaryEvaluationId},  
876 -// "companyId": param.CompanyId,  
877 -// }) 750 +// itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
  751 +
  752 +// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{"id": []int{param.SummaryEvaluationId}, "companyId": param.CompanyId})
878 // if err != nil { 753 // if err != nil {
879 // return application.ThrowError(application.BUSINESS_ERROR, err.Error()) 754 // return application.ThrowError(application.BUSINESS_ERROR, err.Error())
880 // } 755 // }
881 // if len(evaluationList) == 0 { 756 // if len(evaluationList) == 0 {
882 // return nil 757 // return nil
883 // } 758 // }
884 -// evaluationData := evaluationList[0]  
885 -// if evaluationData.Types != domain.EvaluationFinish { 759 +// result := evaluationList[0]
  760 +// if result.Types != domain.EvaluationFinish {
886 // return nil 761 // return nil
887 // } 762 // }
  763 +
  764 +// // 获取考核结果评分
  765 +// _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": result.Id})
  766 +// if err != nil {
  767 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  768 +// }
  769 +// // 如果已经存在考核结果分数,只更新分数(反之先默认生成考核结果,再更新分数)
  770 +// if len(itemValues) > 0 {
  771 +// // do nothing...
  772 +// } else {
  773 +// evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
  774 +
  775 +// // 周期内所有评估类型
  776 +// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
  777 +// "companyId": result.CompanyId,
  778 +// "cycleId": result.CycleId,
  779 +// "targetUserId": result.TargetUser.UserId,
  780 +// })
  781 +// if err != nil {
  782 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  783 +// }
  784 +
  785 +// var super *domain.SummaryEvaluation // 上级评估
  786 +// for i := range evaluationList {
  787 +// it := evaluationList[i]
  788 +// if it.Types == domain.EvaluationSuper {
  789 +// super = it
  790 +// break
  791 +// }
  792 +// }
  793 +
  794 +// // 获取自评模板
  795 +// _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
  796 +// if err != nil {
  797 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  798 +// }
  799 +
  800 +// if super != nil {
  801 +// _, superValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": super.Id}) // 获取已填写的评估内容
  802 +// if err != nil {
  803 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  804 +// }
  805 +// // 更新填写值
  806 +// itemValues, err = srv.updateItemValuePriority(result, itemList, superValues, true)
  807 +// if err != nil {
  808 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  809 +// }
  810 +// } else {
  811 +// // 评估项ID(除考核结果和上级)
  812 +// var evaluationIds = make([]int, 0)
  813 +// for i := range evaluationList {
  814 +// it := evaluationList[i]
  815 +// if it.Types == domain.EvaluationSelf || it.Types == domain.Evaluation360 || it.Types == domain.EvaluationHrbp {
  816 +// evaluationIds = append(evaluationIds, it.Id)
  817 +// }
  818 +// }
  819 +// if len(evaluationIds) > 0 {
  820 +// // 已填写的评估内容
  821 +// _, otherValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds})
  822 +// if err != nil {
  823 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  824 +// }
  825 +
  826 +// // 更新填写值
  827 +// itemValues, err = srv.updateItemValuePriority(result, itemList, otherValues, false)
  828 +// if err != nil {
  829 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  830 +// }
  831 +// }
  832 +// }
  833 +// err = itemValueRepo.RemoveBySummaryEvaluationId(result.Id)
  834 +// if err != nil {
  835 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  836 +// }
  837 +// for i := range itemValues {
  838 +// if err := itemValueRepo.Save(itemValues[i]); err != nil {
  839 +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  840 +// }
  841 +// }
  842 +// // 重置评级汇总
  843 +// result.TotalRating = nil
  844 +// for i := range itemList {
  845 +// result.ResetTotalRating(itemList[i])
  846 +// }
  847 +// //// 计算分数
  848 +// //if err := result.EvaluationTotalScore(itemValues); err != nil {
  849 +// // return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  850 +// //}
  851 +// }
  852 +
888 // scoreStr := fmt.Sprintf("%.2f", param.Score) 853 // scoreStr := fmt.Sprintf("%.2f", param.Score)
889 -// evaluationData.TotalScore = scoreStr  
890 -// evaluationData.Status = domain.EvaluationCompleted  
891 -// // evaluationData.CheckResult = domain.EvaluationCheckCompleted  
892 -// err = evaluationRepo.Save(evaluationData) 854 +// result.TotalScore = scoreStr
  855 +// result.Status = domain.EvaluationCompleted
  856 +// err = evaluationRepo.Save(result)
893 // if err != nil { 857 // if err != nil {
894 // return application.ThrowError(application.BUSINESS_ERROR, "修改考核结果"+err.Error()) 858 // return application.ThrowError(application.BUSINESS_ERROR, "修改考核结果"+err.Error())
895 // } 859 // }