Ver código fonte

Merge branch 'master' of http://8.136.199.33:3000/eta_server/eta_chart_lib into bzq/mix_table_style

zqbao 4 meses atrás
pai
commit
22fb5846a3

+ 10 - 0
controllers/excel_info.go

@@ -187,6 +187,16 @@ func (this *ExcelInfoController) GetTableDetail() {
 	config := response.ExcelTableDetailConfigResp{
 		FontSize: 9,
 	}
+	waterMarkConf, err := models.GetBusinessConfByKeys([]string{"WatermarkTable", "CompanyWatermark"})
+	if err != nil {
+		br.Msg = "获取水印失败"
+		br.ErrMsg = "获取水印失败,Err:" + err.Error()
+		return
+	}
+	if waterMarkConf["WatermarkTable"] == "true" && waterMarkConf["CompanyWatermark"] != "" {
+		config.Watermark = waterMarkConf["CompanyWatermark"]
+
+	}
 
 	// 获取配置的字体大小
 	confName := models.FromSceneMap[fromScene]

+ 22 - 1
models/business_conf.go

@@ -3,9 +3,10 @@ package models
 import (
 	"eta/eta_chart_lib/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"html"
 	"time"
+
+	"github.com/beego/beego/v2/client/orm"
 )
 
 const (
@@ -63,6 +64,26 @@ func GetBusinessConfByKey(key string) (item *BusinessConf, err error) {
 	return
 }
 
+func GetBusinessConfByKeys(key []string) (list map[string]string, err error) {
+	list = make(map[string]string)
+	if len(key) == 0 {
+		return
+	}
+	var items []*BusinessConf
+	o := orm.NewOrm()
+	sql := fmt.Sprintf(`SELECT * FROM business_conf WHERE conf_key IN (%s) `, utils.GetOrmInReplace(len(key)))
+	_, err = o.Raw(sql, key).QueryRows(&items)
+
+	for _, v := range items {
+		if v.ValType == 4 {
+			list[v.ConfKey] = html.UnescapeString(v.ConfVal)
+			continue
+		}
+		list[v.ConfKey] = v.ConfVal
+	}
+	return
+}
+
 // InitUseMongoConf
 // @Description:
 // @author: Roc

+ 2 - 0
models/edb_data_base.go

@@ -170,6 +170,8 @@ func GetEdbDataTableName(source, subSource int) (tableName string) {
 		tableName = "edb_data_icpi"
 	case utils.DATA_SOURCE_SCI99: //卓创资讯->85
 		tableName = "edb_data_sci99"
+	case utils.DATA_SOURCE_PREDICT: // 基础预测指标->30
+		tableName = "edb_data_predict_base"
 	default:
 		edbSource := data_manage.EdbSourceIdMap[source]
 		if edbSource != nil {

+ 9 - 8
models/request/mixed_table.go

@@ -160,14 +160,15 @@ type MixDateCalculateTagReq struct {
 
 // MixCellShowStyle 混合表格 单元格样式展示计算
 type MixCellShowStyle struct {
-	Pn              int     `description:"小数点位数增加或减少,正数表述增加,负数表示减少" json:"pn"`
-	Nt              string  `description:"变换类型:number 小数点位数改变,percent百分比," json:"nt"`
-	Decimal         *int    `description:"小数点位数"`
-	Last            string  `description:"起始操作:nt|decimal"`
-	Color           string  `description:"颜色值,#RRG" json:"color"`
-	BackgroundColor string  `description:"背景颜色值,#RRG" json:"background-color"`
-	Width           float64 `description:"单元格宽度" json:"width"`
-	Align           string  `description:"对齐方式:left|center|right" json:"align"`
+	Pn              int         `description:"小数点位数增加或减少,正数表述增加,负数表示减少" json:"pn"`
+	Nt              string      `description:"变换类型:number 小数点位数改变,percent百分比," json:"nt"`
+	GlObj           interface{} `description:"公式对象:1:数值,2:百分比,3:文本" json:"glObj"`
+	Decimal         *int        `description:"小数点位数" json:"decimal"`
+	Last            string      `description:"起始操作:nt|decimal" json:"last"`
+	Color           string      `description:"颜色值,#RRG" json:"color"`
+	BackgroundColor string      `description:"背景颜色值,#RRG" json:"background-color"`
+	Width           float64     `description:"单元格宽度" json:"width"`
+	Align           string      `description:"对齐方式:left|center|right" json:"align"`
 }
 
 type DateDataBeforeAfterReq struct {

+ 2 - 1
models/response/excel_info.go

@@ -25,7 +25,8 @@ type ExcelTableDetailResp struct {
 // ExcelTableDetailConfigResp
 // @Description: Excel表格的配置信息
 type ExcelTableDetailConfigResp struct {
-	FontSize int
+	FontSize  int
+	Watermark string
 }
 
 // TableCellResp 单元格

+ 39 - 2
services/data/chart_info.go

@@ -535,9 +535,14 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
 		if chartType == 2 && item.IsAxis == 1 {
 			latestDate, tmpErr := time.Parse(utils.FormatDate, v.LatestDate)
 			if tmpErr != nil {
+				//item.DataList = dataList
+				item.IsNullData = true
+				edbList = append(edbList, item)
+				continue
 				err = errors.New(fmt.Sprint("获取最后实际数据的日期失败,Err:" + tmpErr.Error() + ";LatestDate:" + v.LatestDate))
 				return
 			}
+
 			if calendar == "农历" {
 				if len(dataList) <= 0 {
 					result := new(models.EdbDataResult)
@@ -564,8 +569,29 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
 				}
 				item.DataList = quarterDataList
 			}
+
 		} else if chartType == 2 && item.IsAxis == 0 {
-			// 右轴数据处理,只要最新一年
+			// 右轴数据处理
+			xStartDate := "01-01"
+
+			jumpYear := 0
+			var seasonExtra models.SeasonExtraItem
+			if seasonExtraConfig != "" {
+				err = json.Unmarshal([]byte(seasonExtraConfig), &seasonExtra)
+				if err != nil {
+					return
+				}
+			}
+
+			if seasonExtra.XStartDate != "" {
+				xStartDate = seasonExtra.XStartDate
+				jumpYear = seasonExtra.JumpYear
+			}
+
+			length := len(dataList)
+			if length == 0 {
+				return
+			}
 			latestDate, tmpErr := time.Parse(utils.FormatDate, v.LatestDate)
 			if tmpErr != nil {
 				//item.DataList = dataList
@@ -575,6 +601,17 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
 				err = errors.New(fmt.Sprint("获取最后实际数据的日期失败,Err:" + tmpErr.Error() + ";LatestDate:" + v.LatestDate))
 				return
 			}
+
+			var rightAxisDate time.Time
+			if jumpYear == 1 {
+				latestDate = latestDate.AddDate(-1, 0, 0)
+			}
+			latestDateStr := fmt.Sprintf("%d-%s", latestDate.Year(), xStartDate)
+			rightAxisDate, err = time.Parse(utils.FormatDate, latestDateStr)
+			if err != nil {
+				return
+			}
+
 			newDataList := make([]*models.EdbDataList, 0)
 			for _, v := range dataList {
 				dataTime, e := time.Parse(utils.FormatDate, v.DataTime)
@@ -582,7 +619,7 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
 					err = errors.New("季节性图处理右轴指标数据转换日期失败,Err:" + e.Error())
 					return
 				}
-				if dataTime.Year() == latestDate.Year() {
+				if dataTime.Equal(rightAxisDate) || dataTime.After(rightAxisDate) {
 					newDataList = append(newDataList, v)
 				}
 			}

+ 52 - 8
services/data/excel/mixed_table.go

@@ -9,12 +9,13 @@ import (
 	"eta/eta_chart_lib/services/data"
 	"eta/eta_chart_lib/utils"
 	"fmt"
-	"github.com/shopspring/decimal"
-	"github.com/yidane/formula"
 	"sort"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/shopspring/decimal"
+	"github.com/yidane/formula"
 )
 
 // BaseCalculate
@@ -1185,10 +1186,19 @@ func handleMixCellShowStyle(showStyleList []string, calculateCellMap map[string]
 
 			cell := config[cellPosition.Column][cellPosition.Row]
 			val := cell.ShowValue
-			isPercent := false
-			if strings.Contains(val, "%") {
-				isPercent = true
-				val = strings.Trim(val, "%")
+			// 不支持手动输入的%数
+			// isPercent := false
+			// if strings.Contains(val, "%") {
+			// 	isPercent = true
+			// 	val = strings.Trim(val, "%")
+			// }
+			// 如果没有showValue, 则使用value
+			if cell.ShowValue == "" {
+				_, err := strconv.ParseFloat(cell.Value, 64)
+				if err == nil {
+					val = cell.Value
+					cell.ShowValue = cell.Value
+				}
 			}
 			_, e := strconv.ParseFloat(val, 64) // 将字符串转换成float类型
 			if e != nil {                       // 如果没有错误发生则返回true,说明该字符串是一个合法的数字
@@ -1200,13 +1210,47 @@ func handleMixCellShowStyle(showStyleList []string, calculateCellMap map[string]
 				err = fmt.Errorf("日期计算配置json解析失败失败: %s, Err:%s", config, err.Error())
 				return
 			}
+			hasPercent := false
+			if styleConf.Nt == "percent" {
+				hasPercent = true
+			}
 
 			if styleConf.Pn != 0 || styleConf.Nt != "" {
-				val = changePointDecimalPlaces(val, styleConf.Pn, styleConf.Nt, isPercent)
-				cell.ShowFormatValue = val
+				// val = changePointDecimalPlaces(val, styleConf.Pn, styleConf.Nt, isPercent)
+				// cell.ShowFormatValue = val
+				// 修复历史数据,没有保存小数位数,重置小数位数
+				if styleConf.Pn != 0 {
+					if styleConf.Decimal == nil {
+						styleConf.Decimal = new(int)
+					}
+					*styleConf.Decimal += styleConf.Pn
+					if *styleConf.Decimal < 0 {
+						*styleConf.Decimal = 0
+					}
+					cell.ShowFormatValue = utils.RoundNumber(cell.ShowValue, *styleConf.Decimal, hasPercent)
+					styleConf.Pn = 0
+				} else if styleConf.Decimal != nil {
+					cell.ShowFormatValue = utils.RoundNumber(cell.ShowValue, *styleConf.Decimal, hasPercent)
+				} else {
+					if hasPercent {
+						numDecimal, _ := decimal.NewFromString(cell.ShowValue)
+						tmpStr := numDecimal.Mul(decimal.NewFromInt(100)).String()
+						cell.ShowFormatValue = tmpStr + "%"
+					} else {
+						cell.ShowFormatValue = cell.ShowValue
+					}
+				}
+			} else if styleConf.Decimal != nil {
+				cell.ShowFormatValue = utils.RoundNumber(cell.ShowValue, *styleConf.Decimal, hasPercent)
 			} else {
 				cell.ShowFormatValue = cell.ShowValue
 			}
+			// 前端传过来的json中有可能有glObj,需要去掉
+			styleConf.GlObj = nil
+			tmpStyleConf, err := json.Marshal(styleConf)
+			if err == nil {
+				cell.ShowStyle = string(tmpStyleConf)
+			}
 			config[cellPosition.Column][cellPosition.Row] = cell
 		}
 	}

+ 3 - 83
services/data/predict_edb_info.go

@@ -96,90 +96,10 @@ func GetPredictDataListByPredictEdbInfoId(edbInfoId int, startDate, endDate stri
 // GetPredictDataListByPredictEdbInfo 根据预测指标信息获取预测指标的数据
 func GetPredictDataListByPredictEdbInfo(edbInfo *data_manage.EdbInfo, startDate, endDate string, isTimeBetween bool) (dataList []*models.EdbDataList, sourceEdbInfoItem *data_manage.EdbInfo, predictEdbConf *data_manage.PredictEdbConf, err error, errMsg string) {
 	// 非计算指标,直接从表里获取数据
-	if edbInfo.EdbType != 1 {
-		if !isTimeBetween {
-			endDate = ``
-		}
-		return GetPredictCalculateDataListByPredictEdbInfo(edbInfo, startDate, endDate)
-	}
-	// 查找该预测指标配置
-	predictEdbConfList, err := data_manage.GetPredictEdbConfListById(edbInfo.EdbInfoId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		errMsg = "获取预测指标配置信息失败"
-		return
-	}
-	if len(predictEdbConfList) == 0 {
-		errMsg = "获取预测指标配置信息失败"
-		err = errors.New(errMsg)
-		return
+	if !isTimeBetween {
+		endDate = ``
 	}
-	predictEdbConf = predictEdbConfList[0]
-	if predictEdbConf == nil {
-		errMsg = "获取预测指标配置信息失败"
-		err = errors.New(errMsg)
-		return
-	}
-
-	// 来源指标
-	sourceEdbInfoItem, err = data_manage.GetEdbInfoById(predictEdbConf.SourceEdbInfoId)
-	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
-			errMsg = "找不到来源指标信息"
-			err = errors.New(errMsg)
-		}
-		return
-	}
-
-	// 所有数据
-	allDataList := make([]*models.EdbDataList, 0)
-	//获取指标数据(实际已生成)
-	dataList, err = models.GetEdbDataList(sourceEdbInfoItem.Source, sourceEdbInfoItem.SubSource, sourceEdbInfoItem.EdbInfoId, startDate, endDate)
-	if err != nil {
-		return
-	}
-	// 如果选择了日期,那么需要筛选所有的数据,用于未来指标的生成
-	if startDate != `` {
-		allDataList, err = models.GetEdbDataList(sourceEdbInfoItem.Source, sourceEdbInfoItem.SubSource, sourceEdbInfoItem.EdbInfoId, "", "")
-		if err != nil {
-			return
-		}
-	} else {
-		allDataList = dataList
-	}
-
-	// 获取预测指标未来的数据
-	predictDataList := make([]*models.EdbDataList, 0)
-
-	endDateStr := edbInfo.EndDate //预测指标的结束日期
-
-	if isTimeBetween && endDate != `` { //如果是时间区间,同时截止日期不为空的情况,那么
-		reqEndDateTime, _ := time.ParseInLocation(utils.FormatDate, endDate, time.Local)
-		endDateTime, _ := time.ParseInLocation(utils.FormatDate, edbInfo.EndDate, time.Local)
-		// 如果选择的时间区间结束日期 晚于 当天,那么预测数据截止到当天
-		if reqEndDateTime.Before(endDateTime) {
-			endDateStr = endDate
-		}
-	}
-	//predictDataList, err = GetChartPredictEdbInfoDataList(*predictEdbConf, startDate, sourceEdbInfoItem.LatestDate, sourceEdbInfoItem.LatestValue, endDateStr, edbInfo.Frequency)
-	var predictMinValue, predictMaxValue float64
-	predictDataList, predictMinValue, predictMaxValue, err = GetChartPredictEdbInfoDataListByConfList(predictEdbConfList, startDate, sourceEdbInfoItem.LatestDate, endDateStr, edbInfo.Frequency, edbInfo.DataDateType, allDataList)
-
-	if err != nil {
-		return
-	}
-	dataList = append(dataList, predictDataList...)
-	if len(predictDataList) > 0 {
-		// 如果最小值 大于 预测值,那么将预测值作为最小值数据返回
-		if edbInfo.MinValue > predictMinValue {
-			edbInfo.MinValue = predictMinValue
-		}
-
-		// 如果最大值 小于 预测值,那么将预测值作为最大值数据返回
-		if edbInfo.MaxValue < predictMaxValue {
-			edbInfo.MaxValue = predictMaxValue
-		}
-	}
-	return
+	return GetPredictCalculateDataListByPredictEdbInfo(edbInfo, startDate, endDate)
 }
 
 // GetPredictCalculateDataListByPredictEdbInfo 根据预测运算指标信息获取预测指标的数据

+ 13 - 0
services/data/range_analysis/chart_info.go

@@ -421,6 +421,12 @@ func GetChartDataByEdbInfoList(chartInfoId int, dateType, startYear int, startDa
 			edbInfoMapping.ConvertUnit = req.DataConvertConf.Unit
 			edbInfoMapping.ConvertEnUnit = req.DataConvertConf.Unit
 		}
+		if edbInfoMapping.ConvertUnit == "无" {
+			edbInfoMapping.ConvertUnit = ""
+		}
+		if edbInfoMapping.ConvertEnUnit == "无" {
+			edbInfoMapping.ConvertEnUnit = ""
+		}
 		dataList := edbInfoMapping.DataList.([]*models.EdbDataList)
 		// 处理上下限
 		var maxData, minData float64
@@ -548,6 +554,12 @@ func GetChartDataByEdbInfoListBySeries(chartInfoId int, dateType, startYear int,
 			edbInfoMapping.ConvertUnit = req.DataConvertConf.Unit
 			edbInfoMapping.ConvertEnUnit = req.DataConvertConf.Unit
 		}
+		if edbInfoMapping.ConvertUnit == "无" {
+			edbInfoMapping.ConvertUnit = ""
+		}
+		if edbInfoMapping.ConvertEnUnit == "无" {
+			edbInfoMapping.ConvertEnUnit = ""
+		}
 		edbInfoMapping.DataList = dataList
 		// 处理上下限
 		var maxData, minData float64
@@ -761,6 +773,7 @@ func getChartDataByEdbInfo(edbInfoMapping *models.ChartEdbInfoMapping, req *mode
 					dealDataList = append(dealDataList, v)
 				}
 			}
+			newDataList = dealDataList
 		case 2:
 			for i, v := range newDataList {
 				if utils.CompareFloatByOpStrings(req.UnNormalDataConf.Formula, v.Value, req.UnNormalDataConf.Value) {

+ 101 - 38
services/excel/lucky_sheet.go

@@ -5,10 +5,11 @@ import (
 	"eta/eta_chart_lib/models/request"
 	"eta/eta_chart_lib/utils"
 	"fmt"
-	"math"
 	"reflect"
 	"sort"
 	"strconv"
+
+	"github.com/shopspring/decimal"
 )
 
 type LuckySheetDataBak struct {
@@ -1033,12 +1034,16 @@ func GetTableDataByCustomData(excelType int, data request.TableDataReq, lang str
 					if v.Data[i].DataType == 5 {
 						background = "#ffefdd"
 					}
-					dataCol = append(dataCol, LuckySheetDataValue{
+					tmpCol := LuckySheetDataValue{
 						Value:      v.Data[i].Value,
 						Monitor:    v.Data[i].ShowValue,
 						MergeCell:  LuckySheetDataConfigMerge{},
 						Background: background,
-					})
+					}
+					if tmpCol.Monitor == `` {
+						tmpCol.Monitor = "-"
+					}
+					dataCol = append(dataCol, tmpCol)
 				}
 
 				tableDataList = append(tableDataList, dataCol)
@@ -1050,11 +1055,16 @@ func GetTableDataByCustomData(excelType int, data request.TableDataReq, lang str
 			for _, textColList := range data.TextRowData {
 				dataCol := make([]LuckySheetDataValue, 0)
 				for _, v := range textColList {
-					dataCol = append(dataCol, LuckySheetDataValue{
+					tmpCol := LuckySheetDataValue{
 						Value:     v.Value,
 						Monitor:   v.ShowValue,
 						MergeCell: LuckySheetDataConfigMerge{},
-					})
+					}
+					tmpCol.Value = v.Value
+					if tmpCol.Monitor == "" {
+						tmpCol.Monitor = "-"
+					}
+					dataCol = append(dataCol, tmpCol)
 				}
 				tableDataList = append(tableDataList, dataCol)
 			}
@@ -1100,11 +1110,15 @@ func GetTableDataByCustomData(excelType int, data request.TableDataReq, lang str
 
 			// 文本列
 			for _, textColList := range data.TextRowData {
-				firstCol = append(firstCol, LuckySheetDataValue{
+				tmpCol := LuckySheetDataValue{
 					Value:     textColList[0].Value,
 					Monitor:   textColList[0].ShowValue,
 					MergeCell: LuckySheetDataConfigMerge{},
-				})
+				}
+				if tmpCol.Monitor == `` {
+					tmpCol.Monitor = "-"
+				}
+				firstCol = append(firstCol, tmpCol)
 			}
 
 			tableDataList = append(tableDataList, firstCol)
@@ -1158,23 +1172,30 @@ func GetTableDataByCustomData(excelType int, data request.TableDataReq, lang str
 				if tmpData.DataType == 5 {
 					background = "#ffefdd"
 				}
-				dataCol = append(dataCol, LuckySheetDataValue{
+				tmpCol := LuckySheetDataValue{
 					Value:      tmpData.Value,
 					Monitor:    tmpData.ShowValue,
 					MergeCell:  LuckySheetDataConfigMerge{},
 					Background: background,
-				})
+				}
+				if tmpCol.Monitor == `` {
+					tmpCol.Monitor = "-"
+				}
+				dataCol = append(dataCol, tmpCol)
 			}
 
 			// 文本列
 			for _, textColList := range data.TextRowData {
-				dataCol = append(dataCol, LuckySheetDataValue{
+				tmpCol := LuckySheetDataValue{
 					Value:     textColList[i+1].Value,
 					Monitor:   textColList[i+1].ShowValue,
 					MergeCell: LuckySheetDataConfigMerge{},
-				})
+				}
+				if tmpCol.Monitor == `` {
+					tmpCol.Monitor = "-"
+				}
+				dataCol = append(dataCol, tmpCol)
 			}
-
 			tableDataList = append(tableDataList, dataCol)
 		}
 
@@ -1201,6 +1222,10 @@ func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq, hide
 					Monitor:   cell.ShowValue,
 					MergeCell: LuckySheetDataConfigMerge{},
 				}
+				if cell.DataType != request.CustomTextDT && tmp.Monitor == `` {
+					tmp.Monitor = "-"
+					cell.ShowFormatValue = "-"
+				}
 				// 前端需要隐藏被合并的单元格, 混合表格/平衡表通过这个字段判断, 不通过HandleTableCell方法隐藏
 				if cell.MerData != nil {
 					if hideMerged && cell.MerData.Type == "merged" {
@@ -1234,39 +1259,77 @@ func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq, hide
 						tmp.Ht = 2
 					}
 					tmp.Monitor = cell.ShowFormatValue
-					tmpShowValue, err := strconv.ParseFloat(cell.Value, 64)
+					// 如果没有showValue, 则使用value
+					if cell.ShowValue == "" {
+						_, err := strconv.ParseFloat(cell.Value, 64)
+						if err == nil {
+							cell.ShowValue = cell.Value
+						}
+					}
+					_, err := strconv.ParseFloat(cell.ShowValue, 64)
 					if err == nil {
-						switch styleConfig.Last {
-						case "nt":
-							// 先进行数字的百分比计算,然后保留小数点位数
-							percent := tmpShowValue * 100
+						hasPercent := false
+						if styleConfig.Nt == "percent" {
+							hasPercent = true
+						}
+						// 修复历史数据
+						if styleConfig.Pn != 0 {
 							if styleConfig.Decimal == nil {
-								continue
+								styleConfig.Decimal = new(int)
 							}
-							factor := math.Pow(10, float64(*styleConfig.Decimal))
-							rounded := math.Round(percent*factor) / factor
-							tmp.Monitor = fmt.Sprintf("%g%%", rounded)
-						case "decimal":
-							// 先保留小数点位数,再进行百分比计算
-							if styleConfig.Decimal == nil {
-								continue
+							*styleConfig.Decimal += styleConfig.Pn
+							if *styleConfig.Decimal < 0 {
+								*styleConfig.Decimal = 0
 							}
-							factor := math.Pow(10, float64(*styleConfig.Decimal))
-							rounded := math.Round(tmpShowValue*factor) / factor
-							if styleConfig.Nt == "percent" {
-								percent := rounded * 100
-								var precisionStr string
-								if *styleConfig.Decimal > 2 {
-									precision := *styleConfig.Decimal - 2
-									precisionStr = strconv.FormatFloat(rounded, 'f', precision, 64)
-								} else {
-									precisionStr = strconv.FormatFloat(math.Round(percent), 'f', -1, 64)
-								}
-								tmp.Monitor = fmt.Sprintf("%s%%", precisionStr)
+						}
+
+						if styleConfig.Decimal != nil {
+							tmp.Monitor = utils.RoundNumber(cell.ShowValue, *styleConfig.Decimal, hasPercent)
+						} else {
+							if hasPercent {
+								numDecimal, _ := decimal.NewFromString(cell.ShowValue)
+								tmpStr := numDecimal.Mul(decimal.NewFromInt(100)).String()
+								tmp.Monitor = tmpStr + "%"
 							} else {
-								tmp.Monitor = fmt.Sprintf("%g", rounded)
+								tmp.Monitor = cell.ShowValue
 							}
 						}
+						// switch styleConfig.Last {
+						// case "nt":
+						// 	// 先进行数字的百分比计算,然后保留小数点位数
+						// 	percent := tmpShowValue * 100
+						// 	if styleConfig.Decimal == nil {
+						// 		continue
+						// 	}
+						// 	factor := math.Pow(10, float64(*styleConfig.Decimal))
+						// 	rounded := math.Round(percent*factor) / factor
+						// 	tmp.Monitor = fmt.Sprintf("%g%%", rounded)
+						// case "decimal":
+						// 	// 先保留小数点位数,再进行百分比计算
+						// 	if styleConfig.Decimal == nil {
+						// 		continue
+						// 	}
+						// 	factor := math.Pow(10, float64(*styleConfig.Decimal))
+						// 	rounded := math.Round(tmpShowValue*factor) / factor
+						// 	if styleConfig.Nt == "percent" {
+						// 		percent := rounded * 100
+						// 		var precisionStr string
+						// 		if *styleConfig.Decimal > 2 {
+						// 			precision := *styleConfig.Decimal - 2
+						// 			precisionStr = strconv.FormatFloat(rounded, 'f', precision, 64)
+						// 		} else {
+						// 			precisionStr = strconv.FormatFloat(math.Round(percent), 'f', -1, 64)
+						// 		}
+						// 		tmp.Monitor = fmt.Sprintf("%s%%", precisionStr)
+						// 	} else {
+						// 		tmp.Monitor = fmt.Sprintf("%g", rounded)
+						// 	}
+						// }
+					} else {
+						if cell.DataType == request.CustomTextDT {
+							tmp.Monitor = cell.Value
+						}
+
 					}
 				}
 				dataCol = append(dataCol, tmp)

+ 13 - 0
utils/common.go

@@ -1359,3 +1359,16 @@ func CompareFloatByOpStrings(op string, a, b float64) bool {
 	}
 	return false
 }
+
+// RoundNumber 保留小数位数
+func RoundNumber(num string, decimalPlaces int, hasPercent bool) string {
+	numDecimal, _ := decimal.NewFromString(num)
+	if hasPercent {
+		numDecimal = numDecimal.Mul(decimal.NewFromInt(100))
+	}
+	numStr := numDecimal.Round(int32(decimalPlaces)).StringFixed(int32(decimalPlaces))
+	if hasPercent {
+		numStr += "%"
+	}
+	return numStr
+}