fix: 自定义指标数据查询值float64保留3为小数
This commit is contained in:
@@ -3,6 +3,7 @@ package kpi_c_report
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
@@ -157,7 +158,12 @@ func (k *KpiCReport) GetReport2FE(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, k := range r.KpiValues {
|
for _, k := range r.KpiValues {
|
||||||
report[k.KPIID] = k.Value
|
formatted := fmt.Sprintf("%.3f", k.Value)
|
||||||
|
formattedFloat, err := strconv.ParseFloat(formatted, 64)
|
||||||
|
if err != nil {
|
||||||
|
formattedFloat = 0
|
||||||
|
}
|
||||||
|
report[k.KPIID] = formattedFloat
|
||||||
}
|
}
|
||||||
reports = append(reports, report)
|
reports = append(reports, report)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user