作者 tangxvhui

更新每日评估的选项

... ... @@ -920,7 +920,7 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
}
} else if assessData.Status == domain.StaffAssessUncompleted {
//未完成
assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData)
assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
... ... @@ -1059,7 +1059,7 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
}
} else if assessData.Status == domain.StaffAssessUncompleted {
//未完成
assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData)
assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
... ... @@ -1077,9 +1077,13 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
if !ok {
continue
}
if v.Required == domain.NodeRequiredYes && len(item.Value) == 0 {
return nil, application.ThrowError(application.BUSINESS_ERROR, v.Category+"-"+v.Name+":必填项")
if assessData.Types == domain.AssessSelf {
//每日自评需要检查必填项
if v.Required == domain.NodeRequiredYes && len(item.Value) == 0 {
return nil, application.ThrowError(application.BUSINESS_ERROR, v.Category+"-"+v.Name+":必填项")
}
}
v.Value = item.Value
if len(item.Value) > 0 {
// 转换填入的评估值
... ...
... ... @@ -4,6 +4,7 @@ import (
"fmt"
"sort"
"strconv"
"time"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
... ... @@ -924,63 +925,63 @@ func (srv StaffAssessServeice) SelectAssessInviteUserV2(param *query.SelectAsses
}
// 获取未完成的员工评估内容
// func (srv StaffAssessServeice) getAssessInfoUncompletedV2(transactionContext application.TransactionContext,
// assess *domain.StaffAssess) ([]*domain.StaffAssessContent, error) {
// evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// var evaluationItemList []*domain.EvaluationItemUsed
// var err error
// _, evaluationItemList, err = evaluationItemRepo.Find(map[string]interface{}{
// "evaluationProjectId": assess.EvaluationProjectId,
// "nodeId": assess.LinkNodeId,
// })
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
// }
// if len(evaluationItemList) == 0 {
// //如果当前节点没有评估内容,就去 使用自评节点的评估内容
// _, evaluationItemList, err = evaluationItemRepo.Find(map[string]interface{}{
// "evaluationProjectId": assess.EvaluationProjectId,
// "nodeType": domain.LinkNodeSelfAssessment,
// })
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取自评项目填写内容"+err.Error())
// }
// }
// var contentList []*domain.StaffAssessContent
// nowTime := time.Now()
// for i, v := range evaluationItemList {
// item := &domain.StaffAssessContent{
// Id: 0,
// StaffAssessId: assess.Id,
// SortBy: i + 1,
// Category: v.Category,
// Name: v.Name,
// PromptTitle: v.PromptTitle,
// PromptText: v.PromptText,
// Remark: nil,
// Value: "",
// ReteResult: "",
// CreatedAt: nowTime,
// Weight: v.Weight,
// Required: v.Required,
// UpdatedAt: nowTime,
// DeletedAt: nil,
// Rule: v.Rule,
// }
// var remarks []domain.AssessContemtRemark
// for _, vv := range v.EntryItems {
// ritem := domain.AssessContemtRemark{
// Title: vv.Title,
// HintText: vv.HintText,
// Definition: vv.Definition,
// RemarkText: "",
// }
// remarks = append(remarks, ritem)
// }
// item.Remark = remarks
// contentList = append(contentList, item)
// }
// return contentList, nil
// }
func (srv StaffAssessServeice) getAssessInfoUncompletedV2(transactionContext application.TransactionContext,
assess *domain.StaffAssess) ([]*domain.StaffAssessContent, error) {
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
var evaluationItemList []*domain.EvaluationItemUsed
var err error
_, evaluationItemList, err = evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": assess.EvaluationProjectId,
"nodeId": assess.LinkNodeId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
if len(evaluationItemList) == 0 {
//如果当前节点没有评估内容,就去 使用自评节点的评估内容
_, evaluationItemList, err = evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": assess.EvaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取自评项目填写内容"+err.Error())
}
}
var contentList []*domain.StaffAssessContent
nowTime := time.Now()
for i, v := range evaluationItemList {
item := &domain.StaffAssessContent{
Id: 0,
StaffAssessId: assess.Id,
SortBy: i + 1,
Category: v.Category,
Name: v.Name,
PromptTitle: v.PromptTitle,
PromptText: v.PromptText,
Remark: nil,
Value: "",
ReteResult: "",
CreatedAt: nowTime,
Weight: v.Weight,
Required: v.Required,
UpdatedAt: nowTime,
DeletedAt: nil,
Rule: v.Rule,
}
var remarks []domain.AssessContemtRemark
for _, vv := range v.EntryItems {
ritem := domain.AssessContemtRemark{
Title: vv.Title,
HintText: vv.HintText,
Definition: vv.Definition,
RemarkText: "",
}
remarks = append(remarks, ritem)
}
item.Remark = remarks
contentList = append(contentList, item)
}
return contentList, nil
}
... ...