作者 郑周

1. 通用获取详情接口 增加获取任务里程碑数据

@@ -874,14 +874,9 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada @@ -874,14 +874,9 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
874 defer func() { 874 defer func() {
875 _ = transactionContext.RollbackTransaction() 875 _ = transactionContext.RollbackTransaction()
876 }() 876 }()
877 - assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{  
878 - "transactionContext": transactionContext,  
879 - }) 877 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext})
880 //获取员工的评估 878 //获取员工的评估
881 - _, assessList, err := assessReps.Find(map[string]interface{}{  
882 - "companyId": param.CompanyId,  
883 - "id": param.AssessId,  
884 - }) 879 + _, assessList, err := assessReps.Find(map[string]interface{}{"companyId": param.CompanyId, "id": param.AssessId})
885 if err != nil { 880 if err != nil {
886 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) 881 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
887 } 882 }
@@ -890,34 +885,52 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada @@ -890,34 +885,52 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
890 } 885 }
891 assessData := assessList[0] 886 assessData := assessList[0]
892 var assessContentList []*domain.StaffAssessContent 887 var assessContentList []*domain.StaffAssessContent
893 -  
894 //已完成 888 //已完成
895 - assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{  
896 - "transactionContext": transactionContext,  
897 - })  
898 - _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{  
899 - "staffAssessId": assessData.Id,  
900 - }) 889 + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{"transactionContext": transactionContext})
  890 + _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{"staffAssessId": assessData.Id})
901 if err != nil { 891 if err != nil {
902 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) 892 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
903 } 893 }
904 - if len(assessContentList) == 0 {  
905 - // 未完成 894 + if len(assessContentList) == 0 { // 未完成
906 assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData) 895 assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
907 if err != nil { 896 if err != nil {
908 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) 897 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
909 } 898 }
910 } 899 }
911 900
  901 + targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(assessData.TargetUser.UserId))
  902 + if err != nil {
  903 + log.Logger.Error("获取员工描述" + err.Error())
  904 + }
  905 +
912 // 恢复缓存数据 906 // 恢复缓存数据
913 if param.AcquireCache != 0 { 907 if param.AcquireCache != 0 {
914 srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList) 908 srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
915 } 909 }
916 910
917 - targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(assessData.TargetUser.UserId)) 911 + // 获取项目信息
  912 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  913 + project, err := projectRepository.FindOne(map[string]interface{}{"id": assessData.EvaluationProjectId})
918 if err != nil { 914 if err != nil {
919 - log.Logger.Error("获取员工描述" + err.Error()) 915 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目错误:"+err.Error())
920 } 916 }
  917 +
  918 + taskRecords := make([]*domain.TaskRecord, 0)
  919 + // 任务负责人才能显示里程碑数据
  920 + if project.PrincipalId == strconv.Itoa(assessData.TargetUser.UserId) {
  921 + // 获取里程碑数据
  922 + taskRecordRepository := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
  923 + _, taskRecords, err = taskRecordRepository.Find(map[string]interface{}{"staffAssessId": assessData.Id})
  924 + if err != nil {
  925 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取里程碑数据:"+err.Error())
  926 + }
  927 +
  928 + //// 恢复缓存数据(里程碑记录)这里可以不用恢复任务里程碑数据
  929 + //if param.AcquireCache != 0 {
  930 + // srv.recoverCacheWithTaskRecord(cache, taskRecords)
  931 + //}
  932 + }
  933 +
921 if err := transactionContext.CommitTransaction(); err != nil { 934 if err := transactionContext.CommitTransaction(); err != nil {
922 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 935 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
923 } 936 }
@@ -940,6 +953,7 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada @@ -940,6 +953,7 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
940 SupperUser: "", 953 SupperUser: "",
941 DutyTime: "", 954 DutyTime: "",
942 AssessContent: assessContentList, 955 AssessContent: assessContentList,
  956 + TaskRecords: taskRecords,
943 } 957 }
944 if len(assessContentList) == 0 { 958 if len(assessContentList) == 0 {
945 result.AssessContent = []*domain.StaffAssessContent{} 959 result.AssessContent = []*domain.StaffAssessContent{}