作者 tangxvhui

根据

... ... @@ -3,32 +3,32 @@ package adapter
import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
type EvaluationInfoAdapter struct {
SummaryEvaluationId int `json:"summaryEvaluationId"` //
CycleId int `json:"cycleId,string"` //周期id
CycleName string `json:"cycleName"` //周期名称
EvaluationProjectId int `json:"evaluationProjectId"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
LinkNodeId int `json:"linkNodeId,string"` //评估环节id
LinkNodeName string `json:"linkNodeName"` //评估环节名称
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
Status string `json:"status"` //完成状态
// Content
SummaryEvaluationId int `json:"summaryEvaluationId"` //
CycleId int `json:"cycleId,string"` //周期id
CycleName string `json:"cycleName"` //周期名称
EvaluationProjectId int `json:"evaluationProjectId"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
LinkNodeId int `json:"linkNodeId,string"` //评估环节id
LinkNodeName string `json:"linkNodeName"` //评估环节名称
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
Status string `json:"status"` //完成状态
EvaluationItems []EvaluationItemAdapter `json:"assessContent"`
}
type EvaluationItemAdapter struct {
SortBy int //排序
Category string //类别
Name string //名称
PromptTitle string //提示项标题
PromptText string //提示项正文
EntryItems []domain.EntryItem //填写的反馈
RuleType int //评估方式(0评级、1评分)
Rule domain.EvaluationRule //评估的选项规则
Weight float64 //"权重"
Required int // 必填项
Value string //评估填写的评分
Score string //评定得分
Types string //评估类型
Remark string //填写的内容反馈
EvaluationItemId int `json:"evaluationItemId,string"` //评估条目的id
SortBy int `json:"sortBy"` //排序
Category string `json:"category"` //类别
Name string `json:"name"` //名称
PromptTitle string `json:"promptTitle"` //提示项标题
PromptText string `json:"promptText"` //提示项正文
EntryItems []domain.EntryItem `json:"entryItems"` //填写的反馈
RuleType int `json:"ruleType"` //评估方式(0评级、1评分)
Rule domain.EvaluationRule `json:"rule"` //评估的选项规则
Weight float64 `json:"weight"` //"权重"
Required int `json:"required"` // 必填项
Value string `json:"value"` //评估填写的评分
Score string `json:"score"` //评定得分
Remark string `json:"remark"` //填写的内容反馈
}
... ...
package command
type QueryEvaluationInfo struct {
CycleId int `json:"cycleId,string"`
CompanyId int `json:"-"`
CycleId int `json:"cycleId,string"` //周期id
ExecutorId int `json:"executorId,string"` //执行人id
CompanyId int `json:"-"` //公司id
}
... ...
... ... @@ -239,8 +239,107 @@ func (srv *SummaryEvaluationServeice) GetMenu(param *command.QueryMenu) (map[str
return result, nil
}
// buildSummaryItemValue 将填写值填充进评估项
func (srv *SummaryEvaluationServeice) buildSummaryItemValue(itemList []*domain.EvaluationItemUsed, valueList []*domain.SummaryEvaluationValue) (
itemValues []adapter.EvaluationItemAdapter) {
itemValues = []adapter.EvaluationItemAdapter{}
valueMap := map[int]*domain.SummaryEvaluationValue{}
for _, v := range valueList {
valueMap[v.EvaluationItemId] = v
}
for _, v := range itemList {
item := adapter.EvaluationItemAdapter{
EvaluationItemId: v.Id,
SortBy: v.SortBy,
Category: v.Category,
Name: v.Name,
PromptTitle: v.PromptTitle,
PromptText: v.PromptText,
EntryItems: v.EntryItems,
RuleType: v.RuleType,
Rule: v.Rule,
Weight: v.Weight,
Required: v.Required,
Value: "",
Score: "",
Remark: "",
}
value, ok := valueMap[v.Id]
if !ok {
continue
}
item.Score = value.Score
item.Value = value.Value
item.Remark = value.Remark
itemValues = append(itemValues, item)
}
return itemValues
}
// 获取综合自评详情
func (srv *SummaryEvaluationServeice) GetEvaluationSelf(param *command.QueryEvaluationInfo) {}
func (srv *SummaryEvaluationServeice) GetEvaluationSelf(param *command.QueryEvaluationInfo) (*adapter.EvaluationInfoAdapter, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
itemValueRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
"limit": 1,
"cycleId": param.CompanyId,
"executorId": param.ExecutorId,
"types": domain.EvaluationSelf,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluationList) == 0 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
evaluationData := evaluationList[0]
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": evaluationData.EvaluationProjectId,
"nodeType": int(domain.LinkNodeSelfAssessment),
})
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())
}
_ = itemList
_ = itemValueRepo
return nil, nil
}
// 编辑综合自评详情
func (srv *SummaryEvaluationServeice) EditEvaluationSelf() {}
func (srv *SummaryEvaluationServeice) EditEvaluationSelf() (map[string][]adapter.EvaluationItemAdapter, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil, nil
}
... ...
... ... @@ -31,10 +31,6 @@ const (
Evaluation360 EvaluationType = 2 //360评估
EvaluationSuper EvaluationType = 3 //上级评估
EvaluationHrbp EvaluationType = 4 //人资评估
// EvaluationSelf EvaluationType = "self"
// Evaluation360 EvaluationType = "360"
// EvaluationSuper EvaluationType = "superior"
// EvaluationHrbp EvaluationType = "hrbp"
)
// 评估的填写状态
... ...
... ... @@ -4,16 +4,16 @@ import "time"
// 周期综合评估填写的内容
type SummaryEvaluationValue struct {
Id int //
EvaluationItemId int //评估条目的id
SummaryEvaluationId int //综合评估任务(SummaryEvaluation)的id
Value string //评估填写的评分
Score string //评定得分
Types EvaluationType //评估类型
Remark string //填写的内容反馈
CreatedAt time.Time //数据创建时间
UpdatedAt time.Time //数据更新时间
DeletedAt *time.Time //数据删除时间
Id int `json:"id"` //
EvaluationItemId int `json:"evaluationItemId"` //评估条目的id
SummaryEvaluationId int `json:"summaryEvaluationId"` //综合评估任务(SummaryEvaluation)的id
Value string `json:"value"` //评估填写的评分
Score string `json:"score"` //评定得分
Types EvaluationType `json:"types"` //评估类型
Remark string `json:"remark"` //填写的内容反馈
CreatedAt time.Time `json:"createdAt"` //数据创建时间
UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
DeletedAt *time.Time `json:"deletedAt"` //数据删除时间
}
type SummaryEvaluationValueRepository interface {
... ...
... ... @@ -78,6 +78,15 @@ func (repo *EvaluationItemUsedRepository) Find(queryOptions map[string]interface
if v, ok := queryOptions["offset"].(int); ok {
query.Offset(v)
}
if v, ok := queryOptions["evaluationProjectId"]; ok {
query.Where("evaluation_project_id=?", v)
}
if v, ok := queryOptions["nodeType"]; ok {
query.Where(" node_type=?", v)
}
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...
... ... @@ -129,6 +129,10 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{
query.Where("types=?", v)
}
if v, ok := queryOptions["cycleId"]; ok {
query.Where("cycle_id=?", v)
}
if v, ok := queryOptions["status"]; ok {
query.Where("status=?", v)
}
... ...