作者 tangxvhui

Merge branch 'fix' into test

... ... @@ -2,11 +2,12 @@ package service
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis"
"strconv"
"strings"
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/adapter"
... ...
... ... @@ -1944,10 +1944,18 @@ func (srv *SummaryEvaluationService) editEvaluationValue(
}
}
}
//填充评估填写值
err := newItemValue.FillValue(evaluationItem, v.Value, v.Remark)
if err != nil {
return err
if evaluationData.Types == domain.EvaluationSelf {
// 填充评估填写值
err := newItemValue.EvaluationSelfFillValue(evaluationItem, v.Value, v.Remark)
if err != nil {
return err
}
} else {
//填充评估填写值
err := newItemValue.FillValue(evaluationItem, v.Value, v.Remark)
if err != nil {
return err
}
}
}
// 填入固定的默认值
... ...
... ... @@ -114,3 +114,39 @@ func (itemValue *SummaryEvaluationValue) valueTypeScore(item *EvaluationItemUsed
}
return nil
}
// 填写综合自评
func (itemValue *SummaryEvaluationValue) EvaluationSelfFillValue(item *EvaluationItemUsed, value string, remark string) error {
itemValue.Remark = remark
if item.Weight == 0 {
//使用评级的形式
err := itemValue.valueTypeRating(item, value)
return err
}
//综合自评 评分的形式,特殊处理
err := itemValue.valueTypeScoreEvaluationSelf(item, value)
return err
}
func (itemValue *SummaryEvaluationValue) valueTypeScoreEvaluationSelf(item *EvaluationItemUsed, value string) error {
if item.Weight <= 0 {
return errors.New("评分方式错误")
}
value = strings.TrimSpace(value)
itemValue.Value = value
//处理空值
if len(value) == 0 {
itemValue.Score = "0"
return nil
}
valueNumber, err := strconv.ParseFloat(value, 64)
if err != nil {
return fmt.Errorf("条目%d:%s-%s评分值异常", item.Id, item.Category, item.Name)
}
// 分数保留2位小数
score := valueNumber * item.Weight
itemValue.Score = fmt.Sprintf("%.2f", score)
return nil
}
... ...