作者 tangxvhui

更新 填写 自评是同步 评估结果

... ... @@ -268,9 +268,9 @@ func (srv *SummaryEvaluationService) EditEvaluationSelfV2(param *command.EditEva
}
//更新填写值
var evaluationValueSlice []*domain.SummaryEvaluationValue // 提交的填写值
evaluationItemMap := map[int]*domain.EvaluationItemUsed{}
{
evaluationItemMap := map[int]*domain.EvaluationItemUsed{} // 需要填写那些项 Id=>&domain.EvaluationItemUsed{}
// 需要填写那些项 Id=>&domain.EvaluationItemUsed{}
evaluationValueMap := map[int]*domain.SummaryEvaluationValue{} // 提交的填写值 EvaluationItemId=>&domain.domain.SummaryEvaluationValue{}
evaluationData.TotalRating = nil // 清空评级数量统计
// 按照需要填写那些项 设置SummaryEvaluationValue的空白值
... ... @@ -345,6 +345,44 @@ func (srv *SummaryEvaluationService) EditEvaluationSelfV2(param *command.EditEva
if err != nil {
return nil, err
}
//查看是否存在上级评估
_, evaluationSuperList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": evaluationData.TargetUser.UserId,
"typesList": []int{int(domain.EvaluationSuper)},
"cycleId": evaluationData.CycleId,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//不存在 上级评估,进行同步评估结果
if len(evaluationSuperList) == 0 {
_, evaluationFinishList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": evaluationData.TargetUser.UserId,
"typesList": []int{int(domain.EvaluationFinish)},
"cycleId": evaluationData.CycleId,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
itemValuesFinish := []*domain.SummaryEvaluationValue{}
for _, val := range evaluationValueSlice {
item, ok := evaluationItemMap[val.EvaluationItemId]
if !ok {
continue
}
if item.EvaluatorId == 0 {
itemValuesFinish = append(itemValuesFinish, val)
}
}
if len(evaluationFinishList) > 0 {
err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinishList[0], itemValuesFinish)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...