作者 tangxvhui

更新每日评估的选项

@@ -920,7 +920,7 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada @@ -920,7 +920,7 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
920 } 920 }
921 } else if assessData.Status == domain.StaffAssessUncompleted { 921 } else if assessData.Status == domain.StaffAssessUncompleted {
922 //未完成 922 //未完成
923 - assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData) 923 + assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
924 if err != nil { 924 if err != nil {
925 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) 925 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
926 } 926 }
@@ -1059,7 +1059,7 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma @@ -1059,7 +1059,7 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
1059 } 1059 }
1060 } else if assessData.Status == domain.StaffAssessUncompleted { 1060 } else if assessData.Status == domain.StaffAssessUncompleted {
1061 //未完成 1061 //未完成
1062 - assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData) 1062 + assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
1063 if err != nil { 1063 if err != nil {
1064 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) 1064 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
1065 } 1065 }
@@ -1077,9 +1077,13 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma @@ -1077,9 +1077,13 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
1077 if !ok { 1077 if !ok {
1078 continue 1078 continue
1079 } 1079 }
1080 - if v.Required == domain.NodeRequiredYes && len(item.Value) == 0 {  
1081 - return nil, application.ThrowError(application.BUSINESS_ERROR, v.Category+"-"+v.Name+":必填项") 1080 + if assessData.Types == domain.AssessSelf {
  1081 + //每日自评需要检查必填项
  1082 + if v.Required == domain.NodeRequiredYes && len(item.Value) == 0 {
  1083 + return nil, application.ThrowError(application.BUSINESS_ERROR, v.Category+"-"+v.Name+":必填项")
  1084 + }
1082 } 1085 }
  1086 +
1083 v.Value = item.Value 1087 v.Value = item.Value
1084 if len(item.Value) > 0 { 1088 if len(item.Value) > 0 {
1085 // 转换填入的评估值 1089 // 转换填入的评估值
@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ import (
4 "fmt" 4 "fmt"
5 "sort" 5 "sort"
6 "strconv" 6 "strconv"
  7 + "time"
7 8
8 "github.com/linmadan/egglib-go/core/application" 9 "github.com/linmadan/egglib-go/core/application"
9 "github.com/linmadan/egglib-go/utils/tool_funs" 10 "github.com/linmadan/egglib-go/utils/tool_funs"
@@ -924,63 +925,63 @@ func (srv StaffAssessServeice) SelectAssessInviteUserV2(param *query.SelectAsses @@ -924,63 +925,63 @@ func (srv StaffAssessServeice) SelectAssessInviteUserV2(param *query.SelectAsses
924 } 925 }
925 926
926 // 获取未完成的员工评估内容 927 // 获取未完成的员工评估内容
927 -// func (srv StaffAssessServeice) getAssessInfoUncompletedV2(transactionContext application.TransactionContext,  
928 -// assess *domain.StaffAssess) ([]*domain.StaffAssessContent, error) {  
929 -// evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{  
930 -// "transactionContext": transactionContext,  
931 -// })  
932 -// var evaluationItemList []*domain.EvaluationItemUsed  
933 -// var err error  
934 -// _, evaluationItemList, err = evaluationItemRepo.Find(map[string]interface{}{  
935 -// "evaluationProjectId": assess.EvaluationProjectId,  
936 -// "nodeId": assess.LinkNodeId,  
937 -// })  
938 -// if err != nil {  
939 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())  
940 -// }  
941 -// if len(evaluationItemList) == 0 {  
942 -// //如果当前节点没有评估内容,就去 使用自评节点的评估内容  
943 -// _, evaluationItemList, err = evaluationItemRepo.Find(map[string]interface{}{  
944 -// "evaluationProjectId": assess.EvaluationProjectId,  
945 -// "nodeType": domain.LinkNodeSelfAssessment,  
946 -// })  
947 -// if err != nil {  
948 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取自评项目填写内容"+err.Error())  
949 -// }  
950 -// }  
951 -// var contentList []*domain.StaffAssessContent  
952 -// nowTime := time.Now()  
953 -// for i, v := range evaluationItemList {  
954 -// item := &domain.StaffAssessContent{  
955 -// Id: 0,  
956 -// StaffAssessId: assess.Id,  
957 -// SortBy: i + 1,  
958 -// Category: v.Category,  
959 -// Name: v.Name,  
960 -// PromptTitle: v.PromptTitle,  
961 -// PromptText: v.PromptText,  
962 -// Remark: nil,  
963 -// Value: "",  
964 -// ReteResult: "",  
965 -// CreatedAt: nowTime,  
966 -// Weight: v.Weight,  
967 -// Required: v.Required,  
968 -// UpdatedAt: nowTime,  
969 -// DeletedAt: nil,  
970 -// Rule: v.Rule,  
971 -// }  
972 -// var remarks []domain.AssessContemtRemark  
973 -// for _, vv := range v.EntryItems {  
974 -// ritem := domain.AssessContemtRemark{  
975 -// Title: vv.Title,  
976 -// HintText: vv.HintText,  
977 -// Definition: vv.Definition,  
978 -// RemarkText: "",  
979 -// }  
980 -// remarks = append(remarks, ritem)  
981 -// }  
982 -// item.Remark = remarks  
983 -// contentList = append(contentList, item)  
984 -// }  
985 -// return contentList, nil  
986 -// } 928 +func (srv StaffAssessServeice) getAssessInfoUncompletedV2(transactionContext application.TransactionContext,
  929 + assess *domain.StaffAssess) ([]*domain.StaffAssessContent, error) {
  930 + evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
  931 + "transactionContext": transactionContext,
  932 + })
  933 + var evaluationItemList []*domain.EvaluationItemUsed
  934 + var err error
  935 + _, evaluationItemList, err = evaluationItemRepo.Find(map[string]interface{}{
  936 + "evaluationProjectId": assess.EvaluationProjectId,
  937 + "nodeId": assess.LinkNodeId,
  938 + })
  939 + if err != nil {
  940 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
  941 + }
  942 + if len(evaluationItemList) == 0 {
  943 + //如果当前节点没有评估内容,就去 使用自评节点的评估内容
  944 + _, evaluationItemList, err = evaluationItemRepo.Find(map[string]interface{}{
  945 + "evaluationProjectId": assess.EvaluationProjectId,
  946 + "nodeType": domain.LinkNodeSelfAssessment,
  947 + })
  948 + if err != nil {
  949 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取自评项目填写内容"+err.Error())
  950 + }
  951 + }
  952 + var contentList []*domain.StaffAssessContent
  953 + nowTime := time.Now()
  954 + for i, v := range evaluationItemList {
  955 + item := &domain.StaffAssessContent{
  956 + Id: 0,
  957 + StaffAssessId: assess.Id,
  958 + SortBy: i + 1,
  959 + Category: v.Category,
  960 + Name: v.Name,
  961 + PromptTitle: v.PromptTitle,
  962 + PromptText: v.PromptText,
  963 + Remark: nil,
  964 + Value: "",
  965 + ReteResult: "",
  966 + CreatedAt: nowTime,
  967 + Weight: v.Weight,
  968 + Required: v.Required,
  969 + UpdatedAt: nowTime,
  970 + DeletedAt: nil,
  971 + Rule: v.Rule,
  972 + }
  973 + var remarks []domain.AssessContemtRemark
  974 + for _, vv := range v.EntryItems {
  975 + ritem := domain.AssessContemtRemark{
  976 + Title: vv.Title,
  977 + HintText: vv.HintText,
  978 + Definition: vv.Definition,
  979 + RemarkText: "",
  980 + }
  981 + remarks = append(remarks, ritem)
  982 + }
  983 + item.Remark = remarks
  984 + contentList = append(contentList, item)
  985 + }
  986 + return contentList, nil
  987 +}