|
@@ -5,11 +5,11 @@ import (
|
|
|
"eta/eta_data_analysis/models"
|
|
|
"eta/eta_data_analysis/utils"
|
|
|
"fmt"
|
|
|
+ "github.com/shopspring/decimal"
|
|
|
"github.com/xuri/excelize/v2"
|
|
|
"os"
|
|
|
"path/filepath"
|
|
|
"regexp"
|
|
|
- "strconv"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
@@ -185,10 +185,7 @@ func (p *OilDemandSignalsWeeklyReportProcessor) Process(tableName string) (err e
|
|
|
}
|
|
|
// 匹配非数字字符
|
|
|
re := regexp.MustCompile(`^\d*\.?\d*\s*$`)
|
|
|
- if !re.MatchString(strings.TrimSpace(rowData[sheetConfig.DataOneRow])) || !re.MatchString(strings.TrimSpace(rowData[sheetConfig.DataTwoRow])) {
|
|
|
- utils.FileLog.Error("数据格式错误:", fmt.Sprintf("%v", rowData))
|
|
|
- continue
|
|
|
- }
|
|
|
+
|
|
|
classifyId := classifyIds[sheetName]
|
|
|
// step_2: 指标
|
|
|
// 指标名称
|
|
@@ -203,10 +200,11 @@ func (p *OilDemandSignalsWeeklyReportProcessor) Process(tableName string) (err e
|
|
|
utils.FileLog.Error(fmt.Sprintf("转换时间数据失败,index_code:%s,time_value:%s err:%v", indexCodeOne, dataTime, convertErr))
|
|
|
continue
|
|
|
}
|
|
|
- if rowData[sheetConfig.DataOneRow] != "" {
|
|
|
- valueOne, parseErr := strconv.ParseFloat(strings.ReplaceAll(rowData[sheetConfig.DataOneRow], ",", ""), 64)
|
|
|
+ if rowData[sheetConfig.DataOneRow] != "" && re.MatchString(strings.TrimSpace(rowData[sheetConfig.DataOneRow])) {
|
|
|
+ valueOne, parseErr := decimal.NewFromString(strings.ReplaceAll(rowData[sheetConfig.DataOneRow], ",", ""))
|
|
|
if parseErr != nil {
|
|
|
utils.FileLog.Error(fmt.Sprintf("转换data数据失败,index_code:%s,data_value:%s err:%v", indexCodeOne, rowData[sheetConfig.DataOneRow], err))
|
|
|
+ continue
|
|
|
} else {
|
|
|
if index, ok := indexMap[indexCodeOne]; ok {
|
|
|
if index.StartDate.After(date) {
|
|
@@ -240,10 +238,11 @@ func (p *OilDemandSignalsWeeklyReportProcessor) Process(tableName string) (err e
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if rowData[sheetConfig.DataTwoRow] != "" {
|
|
|
- valueTwo, parseErr := strconv.ParseFloat(strings.ReplaceAll(rowData[sheetConfig.DataTwoRow], ",", ""), 64)
|
|
|
+ if rowData[sheetConfig.DataTwoRow] != "" && re.MatchString(strings.TrimSpace(rowData[sheetConfig.DataTwoRow])) {
|
|
|
+ valueTwo, parseErr := decimal.NewFromString(strings.ReplaceAll(rowData[sheetConfig.DataTwoRow], ",", ""))
|
|
|
if parseErr != nil {
|
|
|
utils.FileLog.Error(fmt.Sprintf("转换data数据失败,index_code:%s,data_value:%s err:%v", indexCodeTwo, rowData[sheetConfig.DataTwoRow], err))
|
|
|
+ continue
|
|
|
} else {
|
|
|
if index, ok := indexMap[indexCodeTwo]; ok {
|
|
|
if index.StartDate.After(date) {
|
|
@@ -302,7 +301,11 @@ func (p *OilDemandSignalsWeeklyReportProcessor) Process(tableName string) (err e
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+func isValidNumber(s string) bool {
|
|
|
+ // 匹配整数或浮点数(支持正负号)
|
|
|
+ re := regexp.MustCompile(`^[-+]?\d*\.?\d+$`)
|
|
|
+ return re.MatchString(s)
|
|
|
+}
|
|
|
func chunkIndexData(index *models.IndexInfo, rzdBatchSize int) (pars []models.IndexInfo) {
|
|
|
var chunks int
|
|
|
total := len(index.DataList)
|