作者 tangxvhui

调整逻辑 ,编辑综合评估

@@ -93,19 +93,19 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua @@ -93,19 +93,19 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
93 93
94 //保存填写值 94 //保存填写值
95 for _, v := range itemValueList { 95 for _, v := range itemValueList {
  96 + v.Id = 0
96 err = itemValueRepo.Save(v) 97 err = itemValueRepo.Save(v)
97 if err != nil { 98 if err != nil {
98 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 99 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
99 } 100 }
100 } 101 }
101 -  
102 //保存填写值 102 //保存填写值
103 err = evaluationRepo.Save(summaryEvaluation) 103 err = evaluationRepo.Save(summaryEvaluation)
104 if err != nil { 104 if err != nil {
105 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 105 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
106 } 106 }
107 if !param.IsTemporary { 107 if !param.IsTemporary {
108 - err = srv.AfterCompletedEvaluation360Hrbp(transactionContext, summaryEvaluation) 108 + err = srv.AfterCompletedEvaluation360Hrbp(transactionContext, summaryEvaluation, itemValueList)
109 if err != nil { 109 if err != nil {
110 return nil, err 110 return nil, err
111 } 111 }
@@ -131,7 +131,7 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu @@ -131,7 +131,7 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
131 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 131 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
132 } 132 }
133 if !param.IsTemporary { 133 if !param.IsTemporary {
134 - err = srv.AfterCompletedEvaluation360Hrbp(transactionContext, summaryEvaluation) 134 + err = srv.AfterCompletedEvaluation360Hrbp(transactionContext, summaryEvaluation, itemValueList)
135 if err != nil { 135 if err != nil {
136 return nil, err 136 return nil, err
137 } 137 }
@@ -152,6 +152,7 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu @@ -152,6 +152,7 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
152 func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp( 152 func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(
153 transactionContext application.TransactionContext, 153 transactionContext application.TransactionContext,
154 evaluationData *domain.SummaryEvaluation, 154 evaluationData *domain.SummaryEvaluation,
  155 + evaluationValue []*domain.SummaryEvaluationValue,
155 ) error { 156 ) error {
156 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ 157 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
157 "transactionContext": transactionContext, 158 "transactionContext": transactionContext,
@@ -160,7 +161,7 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp( @@ -160,7 +161,7 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(
160 "targetUserId": evaluationData.TargetUser.UserId, 161 "targetUserId": evaluationData.TargetUser.UserId,
161 "typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)}, 162 "typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},
162 "cycleId": evaluationData.CycleId, 163 "cycleId": evaluationData.CycleId,
163 - "limit": 1000, 164 + "limit": 500,
164 }) 165 })
165 if err != nil { 166 if err != nil {
166 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 167 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -172,9 +173,6 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp( @@ -172,9 +173,6 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(
172 break 173 break
173 } 174 }
174 } 175 }
175 - if !allCompleted {  
176 - return nil  
177 - }  
178 _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ 176 _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
179 "targetUserId": evaluationData.TargetUser.UserId, 177 "targetUserId": evaluationData.TargetUser.UserId,
180 "typesList": []int{int(domain.EvaluationSuper)}, 178 "typesList": []int{int(domain.EvaluationSuper)},
@@ -184,6 +182,30 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp( @@ -184,6 +182,30 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(
184 if err != nil { 182 if err != nil {
185 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 183 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
186 } 184 }
  185 +
  186 + noSuper := (len(evaluationList) == 0)
  187 +
  188 + _, evaluationFinishList, err := evaluationRepo.Find(map[string]interface{}{
  189 + "targetUserId": evaluationData.TargetUser.UserId,
  190 + "typesList": []int{int(domain.EvaluationFinish)},
  191 + "cycleId": evaluationData.CycleId,
  192 + "limit": 1,
  193 + })
  194 + if err != nil {
  195 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  196 + }
  197 + if !allCompleted {
  198 + //仅同步评估内容到考核结果
  199 + if noSuper && len(evaluationFinishList) > 0 {
  200 + //不存在上级评估
  201 + err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinishList[0], evaluationValue)
  202 + if err != nil {
  203 + return err
  204 + }
  205 + }
  206 + return nil
  207 + }
  208 +
187 nowTime := time.Now() 209 nowTime := time.Now()
188 updatedId := []int{} 210 updatedId := []int{}
189 // 变更上级评估的开始时间 211 // 变更上级评估的开始时间
@@ -203,31 +225,29 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp( @@ -203,31 +225,29 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(
203 if len(evaluationList) == 0 { 225 if len(evaluationList) == 0 {
204 //没有上级评估 226 //没有上级评估
205 //直接进入考核结果阶段 227 //直接进入考核结果阶段
206 - _, evaluationFinishList, err := evaluationRepo.Find(map[string]interface{}{  
207 - "targetUserId": evaluationData.TargetUser.UserId,  
208 - "typesList": []int{int(domain.EvaluationFinish)},  
209 - "cycleId": evaluationData.CycleId,  
210 - "limit": 1,  
211 - })  
212 - if err != nil {  
213 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
214 - }  
215 if len(evaluationFinishList) > 0 { 228 if len(evaluationFinishList) > 0 {
216 if evaluationFinishList[0].BeginTime.After(nowTime) { 229 if evaluationFinishList[0].BeginTime.After(nowTime) {
217 evaluationFinishList[0].BeginTime = nowTime 230 evaluationFinishList[0].BeginTime = nowTime
218 } 231 }
219 evaluationFinishList[0].Status = domain.EvaluationCompleted 232 evaluationFinishList[0].Status = domain.EvaluationCompleted
220 - err = evaluationRepo.Save(evaluationFinishList[0])  
221 - if err != nil {  
222 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())  
223 - }  
224 //添加确认绩效成绩提醒短信提醒 233 //添加确认绩效成绩提醒短信提醒
225 err = notify.AddNotifyConfirmEvaluationScore(evaluationFinishList[0]) 234 err = notify.AddNotifyConfirmEvaluationScore(evaluationFinishList[0])
226 if err != nil { 235 if err != nil {
227 return application.ThrowError(application.TRANSACTION_ERROR, "创建短信提醒失败"+err.Error()) 236 return application.ThrowError(application.TRANSACTION_ERROR, "创建短信提醒失败"+err.Error())
228 } 237 }
229 } 238 }
230 - 239 + }
  240 + if noSuper && len(evaluationFinishList) > 0 {
  241 + //不存在上级评估
  242 + err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinishList[0], evaluationValue)
  243 + if err != nil {
  244 + return err
  245 + }
  246 + } else if len(evaluationList) == 0 && len(evaluationFinishList) > 0 {
  247 + err = evaluationRepo.Save(evaluationFinishList[0])
  248 + if err != nil {
  249 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
  250 + }
231 } 251 }
232 return nil 252 return nil
233 } 253 }
@@ -121,7 +121,6 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu @@ -121,7 +121,6 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
121 // 变更360评估/人资评估/的开始时间 或者变更上级评估的开始时间 121 // 变更360评估/人资评估/的开始时间 或者变更上级评估的开始时间
122 // evaluationData 综合自评 122 // evaluationData 综合自评
123 // evaluationValue 自评的填写内容 123 // evaluationValue 自评的填写内容
124 -  
125 func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf( 124 func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(
126 transactionContext application.TransactionContext, 125 transactionContext application.TransactionContext,
127 evaluationData *domain.SummaryEvaluation, 126 evaluationData *domain.SummaryEvaluation,
@@ -173,11 +172,14 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf( @@ -173,11 +172,14 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(
173 } 172 }
174 173
175 var evaluationFinish *domain.SummaryEvaluation 174 var evaluationFinish *domain.SummaryEvaluation
  175 + noSuper := true
176 //查找综合评估结果 176 //查找综合评估结果
177 for _, v := range evaluationList { 177 for _, v := range evaluationList {
178 if v.Types == domain.EvaluationFinish { 178 if v.Types == domain.EvaluationFinish {
179 evaluationFinish = v 179 evaluationFinish = v
180 - break 180 + }
  181 + if v.Types == domain.EvaluationSuper {
  182 + noSuper = false
181 } 183 }
182 } 184 }
183 if len(targetEvaluation) == 0 { 185 if len(targetEvaluation) == 0 {
@@ -190,10 +192,6 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf( @@ -190,10 +192,6 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(
190 evaluationFinish.BeginTime = nowTime 192 evaluationFinish.BeginTime = nowTime
191 } 193 }
192 evaluationFinish.Status = domain.EvaluationCompleted 194 evaluationFinish.Status = domain.EvaluationCompleted
193 - err = evaluationRepo.Save(evaluationFinish)  
194 - if err != nil {  
195 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())  
196 - }  
197 //添加确认绩效成绩提醒短信提醒 195 //添加确认绩效成绩提醒短信提醒
198 err = notify.AddNotifyConfirmEvaluationScore(evaluationFinish) 196 err = notify.AddNotifyConfirmEvaluationScore(evaluationFinish)
199 if err != nil { 197 if err != nil {
@@ -202,5 +200,44 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf( @@ -202,5 +200,44 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(
202 } 200 }
203 } 201 }
204 202
  203 + if noSuper && evaluationFinish != nil {
  204 + //没有上级评估 同步数据到考核结果
  205 + //提取非360,hrbp 的评估项
  206 + itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
  207 + "transactionContext": transactionContext,
  208 + })
  209 + _, itemList, err := itemUsedRepo.Find(map[string]interface{}{
  210 + "evaluationProjectId": evaluationData.EvaluationProjectId,
  211 + "nodeType": domain.LinkNodeSelfAssessment,
  212 + })
  213 + if err != nil {
  214 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  215 + }
  216 +
  217 + updateValue := []*domain.SummaryEvaluationValue{}
  218 + for _, val := range itemList {
  219 + if val.EvaluatorId != 0 {
  220 + continue
  221 + }
  222 + for _, val2 := range evaluationValue {
  223 + if val.Id == val2.EvaluationItemId {
  224 + updateValue = append(updateValue, val2)
  225 + break
  226 + }
  227 + }
  228 + }
  229 + //同步数据
  230 + err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinish, updateValue)
  231 + if err != nil {
  232 + return err
  233 + }
  234 +
  235 + } else if len(targetEvaluation) == 0 && evaluationFinish != nil {
  236 + err = evaluationRepo.Save(evaluationFinish)
  237 + if err != nil {
  238 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
  239 + }
  240 + }
  241 +
205 return nil 242 return nil
206 } 243 }
@@ -15,7 +15,6 @@ import ( @@ -15,7 +15,6 @@ import (
15 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command" 15 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
16 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 16 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
17 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" 17 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
18 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis"  
19 ) 18 )
20 19
21 type SummaryEvaluationService struct { 20 type SummaryEvaluationService struct {
@@ -1448,12 +1447,11 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi @@ -1448,12 +1447,11 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi
1448 for i := range itemList { 1447 for i := range itemList {
1449 result.ResetTotalRating(itemList[i]) 1448 result.ResetTotalRating(itemList[i])
1450 } 1449 }
1451 - //存在 超级管理员直接修改填写 总分的情况,此时不重新计算总分  
1452 - if result.TotalScore == "0" || result.TotalScore == "" {  
1453 - if err := result.EvaluationTotalScore(itemValues); err != nil {  
1454 - return application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
1455 - } 1450 + //重新计算总分
  1451 + if err := result.EvaluationTotalScore(itemValues); err != nil {
  1452 + return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1456 } 1453 }
  1454 +
1457 result.CheckResult = domain.EvaluationCheckCompleted 1455 result.CheckResult = domain.EvaluationCheckCompleted
1458 if err := evaluationRepo.Save(result); err != nil { 1456 if err := evaluationRepo.Save(result); err != nil {
1459 return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1457 return application.ThrowError(application.TRANSACTION_ERROR, err.Error())