Browse Source

Merge branch 'bzq/fix_excel_history_data' of eta_server/eta_chart_lib into debug

baoziqiang 6 months ago
parent
commit
63a414b168
3 changed files with 2 additions and 17 deletions
  1. 0 1
      models/request/mixed_table.go
  2. 1 14
      services/excel/lucky_sheet.go
  3. 1 2
      utils/common.go

+ 0 - 1
models/request/mixed_table.go

@@ -167,7 +167,6 @@ type MixCellShowStyle struct {
 	Last            string      `description:"起始操作:nt|decimal" json:"last"`
 	Color           string      `description:"颜色值,#RRG" json:"color"`
 	BackgroundColor string      `description:"背景颜色值,#RRG" json:"background-color"`
-	Align           string      `description:"对齐方式:left|center|right" json:"align"`
 }
 
 type DateDataBeforeAfterReq struct {

+ 1 - 14
services/excel/lucky_sheet.go

@@ -1280,7 +1280,7 @@ func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq, hide
 						}
 
 						if styleConfig.Decimal != nil {
-							tmp.Monitor = roundNumber(cell.ShowValue, *styleConfig.Decimal, hasPercent)
+							tmp.Monitor = utils.RoundNumber(cell.ShowValue, *styleConfig.Decimal, hasPercent)
 						} else {
 							if hasPercent {
 								numDecimal, _ := decimal.NewFromString(cell.ShowValue)
@@ -1339,16 +1339,3 @@ func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq, hide
 
 	return
 }
-
-func roundNumber(num string, decimalPlaces int, hasPercent bool) string {
-	numDecimal, _ := decimal.NewFromString(num)
-	if hasPercent {
-		numDecimal = numDecimal.Mul(decimal.NewFromInt(100))
-	}
-	numFloat, _ := numDecimal.Round(int32(decimalPlaces)).Float64()
-	numStr := strconv.FormatFloat(numFloat, 'f', decimalPlaces, 64)
-	if hasPercent {
-		numStr += "%"
-	}
-	return numStr
-}

+ 1 - 2
utils/common.go

@@ -1403,8 +1403,7 @@ func RoundNumber(num string, decimalPlaces int, hasPercent bool) string {
 	if hasPercent {
 		numDecimal = numDecimal.Mul(decimal.NewFromInt(100))
 	}
-	numFloat, _ := numDecimal.Round(int32(decimalPlaces)).Float64()
-	numStr := strconv.FormatFloat(numFloat, 'f', decimalPlaces, 64)
+	numStr := numDecimal.Round(int32(decimalPlaces)).StringFixed(int32(decimalPlaces))
 	if hasPercent {
 		numStr += "%"
 	}