diff --git a/features/pm/kpi_c_report/controller.go b/features/pm/kpi_c_report/controller.go index 7dc6dcf6..7ae1334f 100644 --- a/features/pm/kpi_c_report/controller.go +++ b/features/pm/kpi_c_report/controller.go @@ -158,8 +158,20 @@ func (k *KpiCReport) GetReport2FE(c *gin.Context) { } for _, k := range r.KpiValues { - formatted := fmt.Sprintf("%.3f", k.Value) - formattedFloat, err := strconv.ParseFloat(formatted, 64) + vStr := fmt.Sprintf("%v", k.Value) + // 分割整数和小数部分 + parts := strings.Split(vStr, ".") + if len(parts) == 2 { + // 处理小数部分,保留非零数字 + decimalPart := strings.TrimRight(parts[1], "0") + if decimalPart != "" { + vStr = parts[0] + "." + decimalPart + } else { + vStr = parts[0] + } + } + + formattedFloat, err := strconv.ParseFloat(vStr, 64) if err != nil { formattedFloat = 0 }