作者 郑周

Merge branch 'dev-zhengzhou' into test

@@ -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,13 +81,23 @@ func (srv *SummaryEvaluationService) GetEvaluationFinish(param *command.QueryEva @@ -79,13 +81,23 @@ 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
  88 + }
86 } 89 }
  90 + itemValues = selfValues
87 } 91 }
88 } 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())
89 } 101 }
90 } 102 }
91 103
@@ -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)
@@ -1622,15 +1622,12 @@ func (srv *SummaryEvaluationService) GetTargetEvaluationResult(param *command.Qu @@ -1622,15 +1622,12 @@ func (srv *SummaryEvaluationService) GetTargetEvaluationResult(param *command.Qu
1622 } 1622 }
1623 } 1623 }
1624 } 1624 }
1625 - }  
1626 // 未完成考核,需要重新计算分数 1625 // 未完成考核,需要重新计算分数
1627 if result.CheckResult == domain.EvaluationCheckUncompleted { 1626 if result.CheckResult == domain.EvaluationCheckUncompleted {
1628 result.TotalRating = nil 1627 result.TotalRating = nil
1629 for i := range itemList { 1628 for i := range itemList {
1630 result.ResetTotalRating(itemList[i]) 1629 result.ResetTotalRating(itemList[i])
1631 } 1630 }
1632 - //存在 超级管理员直接修改填写 总分的情况,此时不重新计算总分  
1633 - if result.TotalScore == "0" || result.TotalScore == "" {  
1634 if err = result.EvaluationTotalScore(itemValues); err != nil { 1631 if err = result.EvaluationTotalScore(itemValues); err != nil {
1635 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1632 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1636 } 1633 }