From 8e008e24b618b7796cb99409ada23e774b534382 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Wed, 2 Jul 2025 10:01:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8C=87?= =?UTF-8?q?=E6=A0=87=E5=A4=84=E7=90=86=E5=B0=8F=E6=95=B0=E9=83=A8=E5=88=86?= =?UTF-8?q?=EF=BC=8C=E4=BF=9D=E7=95=99=E9=9D=9E=E9=9B=B6=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- features/pm/kpi_c_report/controller.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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 }