作者 tangxvhui

Merge branch 'fix' into test

@@ -2,11 +2,12 @@ package service @@ -2,11 +2,12 @@ package service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis"  
6 "strconv" 5 "strconv"
7 "strings" 6 "strings"
8 "time" 7 "time"
9 8
  9 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis"
  10 +
10 "github.com/linmadan/egglib-go/core/application" 11 "github.com/linmadan/egglib-go/core/application"
11 "github.com/linmadan/egglib-go/utils/tool_funs" 12 "github.com/linmadan/egglib-go/utils/tool_funs"
12 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/adapter" 13 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/adapter"
@@ -1944,10 +1944,18 @@ func (srv *SummaryEvaluationService) editEvaluationValue( @@ -1944,10 +1944,18 @@ func (srv *SummaryEvaluationService) editEvaluationValue(
1944 } 1944 }
1945 } 1945 }
1946 } 1946 }
1947 - //填充评估填写值  
1948 - err := newItemValue.FillValue(evaluationItem, v.Value, v.Remark)  
1949 - if err != nil {  
1950 - return err 1947 + if evaluationData.Types == domain.EvaluationSelf {
  1948 + // 填充评估填写值
  1949 + err := newItemValue.EvaluationSelfFillValue(evaluationItem, v.Value, v.Remark)
  1950 + if err != nil {
  1951 + return err
  1952 + }
  1953 + } else {
  1954 + //填充评估填写值
  1955 + err := newItemValue.FillValue(evaluationItem, v.Value, v.Remark)
  1956 + if err != nil {
  1957 + return err
  1958 + }
1951 } 1959 }
1952 } 1960 }
1953 // 填入固定的默认值 1961 // 填入固定的默认值
@@ -114,3 +114,39 @@ func (itemValue *SummaryEvaluationValue) valueTypeScore(item *EvaluationItemUsed @@ -114,3 +114,39 @@ func (itemValue *SummaryEvaluationValue) valueTypeScore(item *EvaluationItemUsed
114 } 114 }
115 return nil 115 return nil
116 } 116 }
  117 +
  118 +// 填写综合自评
  119 +func (itemValue *SummaryEvaluationValue) EvaluationSelfFillValue(item *EvaluationItemUsed, value string, remark string) error {
  120 + itemValue.Remark = remark
  121 + if item.Weight == 0 {
  122 + //使用评级的形式
  123 + err := itemValue.valueTypeRating(item, value)
  124 + return err
  125 + }
  126 + //综合自评 评分的形式,特殊处理
  127 + err := itemValue.valueTypeScoreEvaluationSelf(item, value)
  128 + return err
  129 +}
  130 +
  131 +func (itemValue *SummaryEvaluationValue) valueTypeScoreEvaluationSelf(item *EvaluationItemUsed, value string) error {
  132 + if item.Weight <= 0 {
  133 + return errors.New("评分方式错误")
  134 + }
  135 + value = strings.TrimSpace(value)
  136 + itemValue.Value = value
  137 + //处理空值
  138 + if len(value) == 0 {
  139 + itemValue.Score = "0"
  140 + return nil
  141 + }
  142 + valueNumber, err := strconv.ParseFloat(value, 64)
  143 + if err != nil {
  144 + return fmt.Errorf("条目%d:%s-%s评分值异常", item.Id, item.Category, item.Name)
  145 + }
  146 +
  147 + // 分数保留2位小数
  148 + score := valueNumber * item.Weight
  149 + itemValue.Score = fmt.Sprintf("%.2f", score)
  150 +
  151 + return nil
  152 +}