Browse Source

Merge remote-tracking branch 'origin/master'

zwxi 11 months ago
parent
commit
e9bf0e6a5a

+ 4 - 2
controllers/business_conf.go

@@ -6,6 +6,7 @@ import (
 	"eta/eta_api/services"
 	"eta/eta_api/utils"
 	"fmt"
+	"github.com/shopspring/decimal"
 	"html"
 	"strconv"
 	"strings"
@@ -103,10 +104,11 @@ func (this *BusinessConfController) Save() {
 				approveType = str
 			}
 		case 2: // 数值
-			num, ok := v.(float64)
-			if !ok {
+			vDeci, err := decimal.NewFromString(fmt.Sprint(v))
+			if err != nil {
 				continue
 			}
+			num, _ := vDeci.Float64()
 			if conf.Necessary == 1 && num <= 0 {
 				br.Msg = conf.Remark + "不可为空"
 				return

+ 20 - 0
controllers/data_manage/excel/excel_info.go

@@ -16,6 +16,7 @@ import (
 	"eta/eta_api/utils"
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
+	"github.com/shopspring/decimal"
 	"github.com/yidane/formula"
 	"io"
 	"os"
@@ -1181,6 +1182,7 @@ func (c *ExcelInfoController) AddDraft() {
 // @Title 获取excel表格的table数据
 // @Description 获取excel表格的table数据接口
 // @Param   UniqueCode   query   string  true       "表格code"
+// @Param   FromScene   query   int  true       "场景来源,1:智能研报,2:研报列表;3:英文研报;4:中文PPT;5:英文PPT"
 // @Success 200 {object} response.ExcelTableDetailResp
 // @router /excel_info/table_data [get]
 func (c *ExcelInfoController) GetExcelTableData() {
@@ -1197,6 +1199,7 @@ func (c *ExcelInfoController) GetExcelTableData() {
 		return
 	}
 	uniqueCode := c.GetString("UniqueCode")
+	fromScene, _ := c.GetInt("FromScene", 0)
 
 	var err error
 	if uniqueCode == `` {
@@ -1281,11 +1284,28 @@ func (c *ExcelInfoController) GetExcelTableData() {
 
 	tableData = excel.HandleTableCell(tableData)
 
+	config := response.ExcelTableDetailConfigResp{
+		FontSize: 9,
+	}
+
+	// 获取配置的字体大小
+	confName := models.FromSceneMap[fromScene]
+	if confName != `` {
+		busConf, err := models.GetBusinessConfByKey(confName)
+		if err == nil {
+			sizeDeci, err := decimal.NewFromString(busConf.ConfVal)
+			if err == nil {
+				config.FontSize = int(sizeDeci.IntPart())
+			}
+		}
+	}
+
 	resp := response.ExcelTableDetailResp{
 		UniqueCode: excelInfo.UniqueCode,
 		ExcelImage: excelInfo.ExcelImage,
 		ExcelName:  excelInfo.ExcelName,
 		TableInfo:  tableData,
+		Config:     config,
 	}
 	br.Ret = 200
 	br.Success = true

+ 9 - 0
models/business_conf.go

@@ -52,6 +52,15 @@ const (
 	BusinessConfEmailClientSmtp        = "smtp" // 普通邮箱标记
 )
 
+// FromSceneMap 数据源名称与数据源ID的对应关系
+var FromSceneMap = map[int]string{
+	1: "SmartReportSheetSize",
+	2: "ReportSheetSize",
+	3: "EnReportSheetSize",
+	4: "CnPptSheetSize",
+	5: "EnPptSheetSize",
+}
+
 // BusinessConf 商户配置表
 type BusinessConf struct {
 	Id         int    `orm:"column(id);pk"`

+ 7 - 0
models/data_manage/excel/response/excel_info.go

@@ -26,6 +26,13 @@ type ExcelTableDetailResp struct {
 	ExcelImage string `description:"表格截图"`
 	ExcelName  string `description:"表格名称"`
 	TableInfo  excel.TableData
+	Config     ExcelTableDetailConfigResp
+}
+
+// ExcelTableDetailConfigResp
+// @Description: Excel表格的配置信息
+type ExcelTableDetailConfigResp struct {
+	FontSize int
 }
 
 // TableCellResp 单元格

+ 16 - 6
services/excel/lucky_sheet.go

@@ -1543,10 +1543,15 @@ func GetTableDataByCustomData(excelType int, data request.TableDataReq) (selfTab
 
 				// 数据值
 				for _, v := range data.Data {
+					background := ``
+					if v.Data[i].DataType == 5 {
+						background = "#ffefdd"
+					}
 					dataCol = append(dataCol, LuckySheetDataValue{
-						Value:     v.Data[i].Value,
-						Monitor:   v.Data[i].ShowValue,
-						MergeCell: LuckySheetDataConfigMerge{},
+						Value:      v.Data[i].Value,
+						Monitor:    v.Data[i].ShowValue,
+						MergeCell:  LuckySheetDataConfigMerge{},
+						Background: background,
 					})
 				}
 
@@ -1647,10 +1652,15 @@ func GetTableDataByCustomData(excelType int, data request.TableDataReq) (selfTab
 
 			// 指标数据列
 			for _, tmpData := range tmpEdbInfo.Data {
+				background := ``
+				if tmpData.DataType == 5 {
+					background = "#ffefdd"
+				}
 				dataCol = append(dataCol, LuckySheetDataValue{
-					Value:     tmpData.Value,
-					Monitor:   tmpData.ShowValue,
-					MergeCell: LuckySheetDataConfigMerge{},
+					Value:      tmpData.Value,
+					Monitor:    tmpData.ShowValue,
+					MergeCell:  LuckySheetDataConfigMerge{},
+					Background: background,
 				})
 			}