作者 tangxvhui

修改评估值的填充

... ... @@ -461,12 +461,13 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
evaluationItemMap := map[int]*domain.EvaluationItemUsed{}
evaluationValueMap := map[int]*domain.SummaryEvaluationValue{}
for _, v := range itemList {
newValue := &domain.SummaryEvaluationValue{}
newValue.SetBlankValue(evaluationData, v)
evaluationValueMap[v.Id] = newValue
evaluationItemMap[v.Id] = v
}
for _, v := range itemValueList {
if mValue, ok := evaluationValueMap[v.EvaluationItemId]; ok {
... ... @@ -479,11 +480,13 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
if !ok {
continue
}
evaluationItem, ok := evaluationItemMap[v.EvaluationItemId]
if !ok {
continue
}
updatedData.UpdatedAt = nowTime
updatedData.Value = v.Value
updatedData.Remark = v.Remark
//计算得分
err = updatedData.SummaryEvaluationScore()
//填充评估填写值
err = updatedData.FillValue(evaluationItem, v.Value, v.Remark)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
... ... @@ -845,11 +848,14 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval
if err != nil {
return nil, err
}
evaluationItemMap := map[int]*domain.EvaluationItemUsed{}
evaluationValueMap := map[int]*domain.SummaryEvaluationValue{}
for _, v := range itemList {
newValue := &domain.SummaryEvaluationValue{}
//初始一个空白的value
newValue.SetBlankValue(evaluationData, v)
evaluationValueMap[v.Id] = newValue
evaluationItemMap[v.Id] = v
}
for _, v := range itemValueList {
if mValue, ok := evaluationValueMap[v.EvaluationItemId]; ok {
... ... @@ -862,18 +868,23 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval
if !ok {
continue
}
evaluationItem, ok := evaluationItemMap[v.EvaluationItemId]
if !ok {
continue
}
if defaultValue, ok := hrbpOr360ItemValue[v.EvaluationItemId]; ok {
updatedData.Value = defaultValue.Value
//填充值
err = updatedData.FillValue(evaluationItem, defaultValue.Value, v.Remark)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
} else {
updatedData.Value = v.Value
err = updatedData.FillValue(evaluationItem, v.Value, v.Remark)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
}
updatedData.UpdatedAt = nowTime
updatedData.Remark = v.Remark
//计算得分
err = updatedData.SummaryEvaluationScore()
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
}
evaluationValueList := []*domain.SummaryEvaluationValue{}
for _, v := range evaluationValueMap {
... ...
... ... @@ -16,6 +16,7 @@ type SummaryEvaluationValue struct {
Types EvaluationType `json:"types"` //评估类型
Remark string `json:"remark"` //填写的内容反馈
Weight float64 `json:"weight"` //"权重"
Rating RatingLevel `json:"rating" ` //评级时的填写值
CreatedAt time.Time `json:"createdAt"` //数据创建时间
UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
DeletedAt *time.Time `json:"deletedAt"` //数据删除时间
... ... @@ -45,35 +46,62 @@ func (itemValue *SummaryEvaluationValue) SumScore() (float64, error) {
if len(itemValue.Value) == 0 {
return 0, nil
}
if itemValue.Weight == 0 {
//使用评级
return 0, nil
}
if itemValue.Types == EvaluationHrbp {
//hrbp 填写值就是得分
valueFloat, err := strconv.ParseFloat(itemValue.Value, 64)
if err != nil {
return 0, fmt.Errorf("条目%d系数值异常,%s", itemValue.Id, itemValue.Value)
}
return valueFloat, nil
}
if itemValue.Weight == 0 {
return 0, nil
}
valueFloat, err := strconv.ParseFloat(itemValue.Value, 64)
if err != nil {
return 0, fmt.Errorf("条目%d系数值异常,%s", itemValue.Id, itemValue.Value)
}
//计算方式
//得分计算方式
score := itemValue.Weight * valueFloat
return score, nil
}
// 初始化一个空的value
func (itemValue *SummaryEvaluationValue) SetBlankValue(evaluation *SummaryEvaluation, item *EvaluationItemUsed) {
itemValue.Types = evaluation.Types
itemValue.EvaluationItemId = item.Id
itemValue.SummaryEvaluationId = evaluation.Id
itemValue.Value = ""
itemValue.Score = ""
itemValue.Remark = ""
itemValue.Types = evaluation.Types
itemValue.Weight = item.Weight
itemValue.CreatedAt = time.Now()
itemValue.UpdatedAt = time.Now()
}
// 填充评估的内容
func (itemValue *SummaryEvaluationValue) FillValue(item *EvaluationItemUsed, value string, remark string) error {
itemValue.Remark = remark
itemValue.Value = value
if item.Weight == 0 {
//使用评级
if len(value) == 0 {
return nil
}
var ratingValue *RatingLevel
for _, v := range item.Rule.Rating.Levels {
if v.Code == value {
ratingValue = v
}
}
if (ratingValue == nil) && len(value) > 0 {
return fmt.Errorf("条目%d系评级值异常", itemValue.EvaluationItemId)
}
itemValue.Rating = *ratingValue
return nil
}
//使用评分的形式
err := itemValue.SummaryEvaluationScore()
return err
}
... ...
... ... @@ -1210,7 +1210,7 @@ from staff_assess_content
join staff_assess on staff_assess_content.staff_assess_id = staff_assess.id
where 1=1 and staff_assess.deleted_at isnull
and target_user ->>'userId'='?'
and staff_assess."types" = '?'
and staff_assess."types" = ?
and staff_assess_content.level_value notnull
and staff_assess.cycle_id =?
group by level_value,category,"name" `
... ...
package models
import "time"
import (
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 周期综合评估填写的内容
type SummaryEvaluationValue struct {
tableName struct{} `comment:"周期综合评估填写的内容" pg:"summary_evaluation_value"`
Id int //
EvaluationItemId int //评估条目的id
SummaryEvaluationId int //综合评估任务(SummaryEvaluation)的id
Value string //评估填写的评分
Score string //评定得分
Types int //评估类型
Remark string //填写的内容反馈
CreatedAt time.Time //数据创建时间
UpdatedAt time.Time //数据更新时间
DeletedAt *time.Time //数据删除时间
tableName struct{} `comment:"周期综合评估填写的内容" pg:"summary_evaluation_value"`
Id int //
EvaluationItemId int //评估条目的id
SummaryEvaluationId int //综合评估任务(SummaryEvaluation)的id
Value string //评估填写的评分
Score string //评定得分
Types int //评估类型
Weight float64 //权重
Rating domain.RatingLevel //评级填写值
Remark string //填写的内容反馈
CreatedAt time.Time //数据创建时间
UpdatedAt time.Time //数据更新时间
DeletedAt *time.Time //数据删除时间
}
... ...
... ... @@ -30,6 +30,8 @@ func (repo *SummaryEvaluationValueRepository) TransformToDomain(d *models.Summar
Score: d.Score,
Types: domain.EvaluationType(d.Types),
Remark: d.Remark,
Weight: d.Weight,
Rating: d.Rating,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: d.DeletedAt,
... ... @@ -44,6 +46,8 @@ func (repo *SummaryEvaluationValueRepository) Save(param *domain.SummaryEvaluati
Value: param.Value,
Score: param.Score,
Types: int(param.Types),
Weight: param.Weight,
Rating: param.Rating,
Remark: param.Remark,
CreatedAt: param.CreatedAt,
UpdatedAt: param.UpdatedAt,
... ...