正在显示
1 个修改的文件
包含
16 行增加
和
96 行删除
@@ -390,60 +390,20 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua | @@ -390,60 +390,20 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua | ||
390 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 390 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
391 | } | 391 | } |
392 | 392 | ||
393 | - evaluationValueMap := map[int]*domain.SummaryEvaluationValue{} | ||
394 | - evaluationItemMap := map[int]*domain.EvaluationItemUsed{} | ||
395 | - summaryEvaluation.TotalRating = nil //清空评级数量统计 | ||
396 | - for i, v := range itemList { | ||
397 | - newValue := &domain.SummaryEvaluationValue{} | ||
398 | - newValue.SetBlankValue(summaryEvaluation, v) | ||
399 | - evaluationValueMap[v.Id] = newValue | ||
400 | - evaluationItemMap[v.Id] = itemList[i] | ||
401 | - //重置计数 | ||
402 | - summaryEvaluation.ResetTotalRating(v) | ||
403 | - } | ||
404 | - for _, v := range itemValueList { | ||
405 | - if mValue, ok := evaluationValueMap[v.EvaluationItemId]; ok { | ||
406 | - mValue.Id = v.Id | ||
407 | - } | ||
408 | - } | ||
409 | - //nowTime := time.Now() | ||
410 | - for _, v := range param.EvaluationItems { | ||
411 | - updatedData, ok := evaluationValueMap[v.EvaluationItemId] | ||
412 | - if !ok { | ||
413 | - continue | ||
414 | - } | ||
415 | - if it, ok := evaluationItemMap[v.EvaluationItemId]; ok { | ||
416 | - err = updatedData.FillValue(it, v.Value, v.Remark) | ||
417 | - if err != nil { | ||
418 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
419 | - } | ||
420 | - } | ||
421 | - | ||
422 | - //updatedData.UpdatedAt = nowTime | ||
423 | - //updatedData.Value = v.Value | ||
424 | - //updatedData.Remark = v.Remark | ||
425 | - ////计算得分 | ||
426 | - //err = updatedData.SummaryEvaluationScore() | ||
427 | - //if err != nil { | ||
428 | - // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
429 | - //} | 393 | + err = srv.editEvaluationValue(summaryEvaluation, &itemValueList, itemList, param.EvaluationItems, nil) |
394 | + if err != nil { | ||
395 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
430 | } | 396 | } |
431 | 397 | ||
432 | - evaluationValueList := make([]*domain.SummaryEvaluationValue, 0) | ||
433 | - for _, v := range evaluationValueMap { | ||
434 | - //保存填写值 | 398 | + summaryEvaluation.Status = domain.EvaluationCompleted |
399 | + //保存填写值 | ||
400 | + for _, v := range itemValueList { | ||
435 | err = itemValueRepo.Save(v) | 401 | err = itemValueRepo.Save(v) |
436 | if err != nil { | 402 | if err != nil { |
437 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 403 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
438 | } | 404 | } |
439 | - evaluationValueList = append(evaluationValueList, v) | ||
440 | - } | ||
441 | - //计算总得分 | ||
442 | - err = summaryEvaluation.EvaluationTotalScore(evaluationValueList) | ||
443 | - if err != nil { | ||
444 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
445 | } | 405 | } |
446 | - //summaryEvaluation.UpdatedAt = nowTime | 406 | + |
447 | //保存填写值 | 407 | //保存填写值 |
448 | err = evaluationRepo.Save(summaryEvaluation) | 408 | err = evaluationRepo.Save(summaryEvaluation) |
449 | if err != nil { | 409 | if err != nil { |
@@ -452,7 +412,7 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua | @@ -452,7 +412,7 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua | ||
452 | if err := transactionContext.CommitTransaction(); err != nil { | 412 | if err := transactionContext.CommitTransaction(); err != nil { |
453 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 413 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
454 | } | 414 | } |
455 | - itemValueAdapter := srv.buildSummaryItemValue(itemList, evaluationValueList) | 415 | + itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList) |
456 | return map[string][]adapter.EvaluationItemAdapter{ | 416 | return map[string][]adapter.EvaluationItemAdapter{ |
457 | "evaluationItems": itemValueAdapter, | 417 | "evaluationItems": itemValueAdapter, |
458 | }, nil | 418 | }, nil |
@@ -745,57 +705,18 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu | @@ -745,57 +705,18 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu | ||
745 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 705 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
746 | } | 706 | } |
747 | 707 | ||
748 | - evaluationValueMap := map[int]*domain.SummaryEvaluationValue{} | ||
749 | - evaluationItemMap := map[int]*domain.EvaluationItemUsed{} | ||
750 | - summaryEvaluation.TotalRating = nil //清空评级数量统计 | ||
751 | - for i, v := range itemList { | ||
752 | - newValue := &domain.SummaryEvaluationValue{} | ||
753 | - newValue.SetBlankValue(summaryEvaluation, v) | ||
754 | - evaluationValueMap[v.Id] = newValue | ||
755 | - evaluationItemMap[v.Id] = itemList[i] | ||
756 | - //重置计数 | ||
757 | - summaryEvaluation.ResetTotalRating(v) | 708 | + err = srv.editEvaluationValue(summaryEvaluation, &itemValueList, itemList, param.EvaluationItems, nil) |
709 | + if err != nil { | ||
710 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
758 | } | 711 | } |
712 | + | ||
713 | + summaryEvaluation.Status = domain.EvaluationCompleted | ||
714 | + //保存填写值 | ||
759 | for _, v := range itemValueList { | 715 | for _, v := range itemValueList { |
760 | - if mValue, ok := evaluationValueMap[v.EvaluationItemId]; ok { | ||
761 | - mValue.Id = v.Id | ||
762 | - } | ||
763 | - } | ||
764 | - //nowTime := time.Now() | ||
765 | - for _, v := range param.EvaluationItems { | ||
766 | - updatedData, ok := evaluationValueMap[v.EvaluationItemId] | ||
767 | - if !ok { | ||
768 | - continue | ||
769 | - } | ||
770 | - if it, ok := evaluationItemMap[v.EvaluationItemId]; ok { | ||
771 | - err = updatedData.FillValue(it, v.Value, v.Remark) | ||
772 | - if err != nil { | ||
773 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
774 | - } | ||
775 | - } | ||
776 | - //updatedData.UpdatedAt = nowTime | ||
777 | - //updatedData.Value = v.Value | ||
778 | - //updatedData.Remark = v.Remark | ||
779 | - ////计算得分 | ||
780 | - //err = updatedData.SummaryEvaluationScore() | ||
781 | - //if err != nil { | ||
782 | - // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
783 | - //} | ||
784 | - } | ||
785 | - | ||
786 | - evaluationValueList := make([]*domain.SummaryEvaluationValue, 0) | ||
787 | - for _, v := range evaluationValueMap { | ||
788 | - //保存填写值 | ||
789 | err = itemValueRepo.Save(v) | 716 | err = itemValueRepo.Save(v) |
790 | if err != nil { | 717 | if err != nil { |
791 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 718 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
792 | } | 719 | } |
793 | - evaluationValueList = append(evaluationValueList, v) | ||
794 | - } | ||
795 | - //计算总得分 | ||
796 | - err = summaryEvaluation.EvaluationTotalScore(evaluationValueList) | ||
797 | - if err != nil { | ||
798 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
799 | } | 720 | } |
800 | 721 | ||
801 | // 针对HRBP类型,更新最后一次操作的HRBP人 | 722 | // 针对HRBP类型,更新最后一次操作的HRBP人 |
@@ -807,8 +728,7 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu | @@ -807,8 +728,7 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu | ||
807 | summaryEvaluation.Executor.Account = user.Account | 728 | summaryEvaluation.Executor.Account = user.Account |
808 | summaryEvaluation.Executor.UserName = user.Name | 729 | summaryEvaluation.Executor.UserName = user.Name |
809 | summaryEvaluation.Executor.CompanyName = "" // 暂时无用 | 730 | summaryEvaluation.Executor.CompanyName = "" // 暂时无用 |
810 | - | ||
811 | - //summaryEvaluation.UpdatedAt = nowTime | 731 | + summaryEvaluation.Status = domain.EvaluationCompleted |
812 | 732 | ||
813 | //保存填写值 | 733 | //保存填写值 |
814 | err = evaluationRepo.Save(summaryEvaluation) | 734 | err = evaluationRepo.Save(summaryEvaluation) |
@@ -818,7 +738,7 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu | @@ -818,7 +738,7 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu | ||
818 | if err := transactionContext.CommitTransaction(); err != nil { | 738 | if err := transactionContext.CommitTransaction(); err != nil { |
819 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 739 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
820 | } | 740 | } |
821 | - itemValueAdapter := srv.buildSummaryItemValue(itemList, evaluationValueList) | 741 | + itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList) |
822 | return map[string][]adapter.EvaluationItemAdapter{ | 742 | return map[string][]adapter.EvaluationItemAdapter{ |
823 | "evaluationItems": itemValueAdapter, | 743 | "evaluationItems": itemValueAdapter, |
824 | }, nil | 744 | }, nil |
-
请 注册 或 登录 后发表评论