kobe6258 1 month ago
parent
commit
bf3553b29b

+ 476 - 476
services/ruizide/processor_business_logic.go

@@ -7,486 +7,486 @@ import (
 	"eta/eta_data_analysis/models"
 	"eta/eta_data_analysis/utils"
 	"fmt"
-	"strconv"
 	"strings"
 	"unicode"
 )
 
-// SupplyRevisionAnalysisChartOneProcessor
-// @Description: SupplyRevisionAnalysisChartOneProcessor处理器
-type SupplyRevisionAnalysisChartOneProcessor struct{}
-
-func (p *SupplyRevisionAnalysisChartOneProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
-	utils.FileLog.Info("Processing SupplyRevisionAnalysisChartOne...")
-	if rowIndex < 1 {
-		return nil, nil
-	}
-
-	frequency := "季度"
-	unit := "千桶每天"
-	indexNameColSuffix := "YearQuarter"
-	indexNameColPrefix := "Country Revision Group"
-
-	// step_1: 分类
-	classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("classifyId: %v", classifyId)
-
-	// step_2: 指标
-	// 指标名称
-	indexName := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-1]
-
-	// 生成指标编码
-	indexCode, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix+" Year Quarter", strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-1]), " ", ""), "")
-
-	indexInfoMap := make(map[string]string)
-	indexInfoMap[indexCode] = indexName
-
-	var indexInfoList []*models.IndexInfo
-	var value float64
-	if rowData[len(rowData)-2] == "" {
-		value = 0
-	} else {
-		value, err = strconv.ParseFloat(rowData[len(rowData)-2], 64)
-		if err != nil {
-			return nil, err
-		}
-	}
-
-	dataTime := rowData[0]
-	format, err := utils.ConvertDateFormatQuarter(dataTime)
-	if err != nil {
-		return nil, err
-	}
-
-	indexInfoList = append(indexInfoList, &models.IndexInfo{
-		IndexName: indexName,
-		IndexCode: indexCode,
-		Value:     value,
-		DataTime:  format,
-	})
-
-	indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("SupplyRevisionAnalysisChartOneProcessor indexInfoList: %v", indexInfoList)
-
-	// step_3: 指标数据
-	dataList, err := dealData(indexInfoList)
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("SupplyRevisionAnalysisChartOneProcessor dataList: %v", dataList)
-
-	return dataList, err
-}
-
-// SupplyRevisionAnalysisChartTwoProcessor
-// @Description: SupplyRevisionAnalysisChartTwoProcessor处理器
-type SupplyRevisionAnalysisChartTwoProcessor struct{}
-
-func (p *SupplyRevisionAnalysisChartTwoProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
-	utils.FileLog.Info("Processing SupplyRevisionAnalysisChartTwoProcessor...")
-	if rowIndex < 1 {
-		return nil, nil
-	}
-
-	frequency := "季度"
-	unit := "千桶每天"
-	indexNameColPrefix := "YearQuarter"
-
-	// step_1: 分类
-	classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("classifyId: %v", classifyId)
-
-	// step_2: 指标
-	// 指标名称
-	indexNameOne := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Current"
-	indexNameTwo := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Previous"
-
-	// 生成指标编码
-	indexCodeOne, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "Current", "")
-	indexCodeTwo, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "Previous", "")
-
-	var indexInfoList []*models.IndexInfo
-	var valueOne float64
-	if rowData[len(rowData)-2] == "" {
-		valueOne = 0
-	} else {
-		valueOne, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
-		if err != nil {
-			return nil, err
-		}
-	}
-
-	dataTimeOne := rowData[sheetC]
-	formatOne, err := utils.ConvertDateFormat2(dataTimeOne)
-	if err != nil {
-		return nil, err
-	}
-
-	indexInfoList = append(indexInfoList, &models.IndexInfo{
-		IndexName: indexNameOne,
-		IndexCode: indexCodeOne,
-		Value:     valueOne,
-		DataTime:  formatOne,
-	})
-	var valueTwo float64
-	if rowData[len(rowData)-1] == "" {
-		valueTwo = 0
-	} else {
-		valueTwo, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-1], ",", ""), 64)
-		if err != nil {
-			return nil, err
-		}
-	}
-
-	indexInfoList = append(indexInfoList, &models.IndexInfo{
-		IndexName: indexNameTwo,
-		IndexCode: indexCodeTwo,
-		Value:     valueTwo,
-		DataTime:  formatOne,
-	})
-
-	indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("SupplyRevisionAnalysisChartTwoProcessor indexInfoList: %v", indexInfoList)
-
-	// step_3: 指标数据
-	dataList, err := dealData(indexInfoList)
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("SupplyRevisionAnalysisChartTwoProcessor dataList: %v", dataList)
-
-	return dataList, err
-}
-
-// SupplyRevisionAnalysisChartThreeProcessor
-// @Description: SupplyRevisionAnalysisChartThreeProcessor
-type SupplyRevisionAnalysisChartThreeProcessor struct{}
-
-func (p *SupplyRevisionAnalysisChartThreeProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
-	utils.FileLog.Info("Processing SupplyRevisionAnalysisChartThreeProcessor...")
-	if rowIndex < 1 {
-		return nil, nil
-	}
-
-	frequency := "年度"
-	unit := "千桶每天"
-	indexNameColSuffix := "Year"
-	indexNameColPrefix := "Country Revision Group"
-
-	// step_1: 分类
-	classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("classifyId: %v", classifyId)
-
-	// step_2: 指标
-	// 指标名称
-	indexName := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-1]
-
-	// 生成指标编码
-	indexCode, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix+" "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-1]), " ", ""), "")
-
-	indexInfoMap := make(map[string]string)
-	indexInfoMap[indexCode] = indexName
-
-	var indexInfoList []*models.IndexInfo
-	var value float64
-	if rowData[len(rowData)-2] == "" {
-		value = 0
-	} else {
-		value, err = strconv.ParseFloat(rowData[len(rowData)-2], 64)
-		if err != nil {
-			return nil, err
-		}
-	}
-
-	dataTime := rowData[0]
-	format, err := utils.ConvertDateFormat4(dataTime)
-	if err != nil {
-		return nil, err
-	}
-
-	indexInfoList = append(indexInfoList, &models.IndexInfo{
-		IndexName: indexName,
-		IndexCode: indexCode,
-		Value:     value,
-		DataTime:  format,
-	})
-
-	indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("SupplyRevisionAnalysisChartThreeProcessor indexInfoList: %v", indexInfoList)
-
-	// step_3: 指标数据
-	dataList, err := dealData(indexInfoList)
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("SupplyRevisionAnalysisChartThreeProcessor dataList: %v", dataList)
-
-	return dataList, err
-}
-
-// SupplyRevisionAnalysisChartFourProcessor
-// @Description: SupplyRevisionAnalysisChartFourProcessor处理器
-type SupplyRevisionAnalysisChartFourProcessor struct{}
-
-func (p *SupplyRevisionAnalysisChartFourProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
-	utils.FileLog.Info("Processing SupplyRevisionAnalysisChartFourProcessor...")
-	if rowIndex < 1 {
-		return nil, nil
-	}
-
-	frequency := "年度"
-	unit := "千桶每天"
-	indexNameColPrefix := "Year"
-
-	// step_1: 分类
-	classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("classifyId: %v", classifyId)
-
-	// step_2: 指标
-	// 指标名称
-	indexNameOne := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Current"
-	indexNameTwo := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Previous"
-
-	// 生成指标编码
-	indexCodeOne, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "current", "")
-	indexCodeTwo, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "previous", "")
-
-	var indexInfoList []*models.IndexInfo
-	var valueOne float64
-	if rowData[len(rowData)-2] == "" {
-		valueOne = 0
-	} else {
-		valueOne, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
-		if err != nil {
-			return nil, err
-		}
-	}
-
-	dataTimeOne := rowData[0]
-	formatOne, err := utils.ConvertDateFormat4(dataTimeOne)
-	if err != nil {
-		return nil, err
-	}
-
-	indexInfoList = append(indexInfoList, &models.IndexInfo{
-		IndexName: indexNameOne,
-		IndexCode: indexCodeOne,
-		Value:     valueOne,
-		DataTime:  formatOne,
-	})
-	var valueTwo float64
-	if rowData[len(rowData)-1] == "" {
-		valueTwo = 0
-	} else {
-		valueTwo, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-1], ",", ""), 64)
-		if err != nil {
-			return nil, err
-		}
-	}
-
-	indexInfoList = append(indexInfoList, &models.IndexInfo{
-		IndexName: indexNameTwo,
-		IndexCode: indexCodeTwo,
-		Value:     valueTwo,
-		DataTime:  formatOne,
-	})
-
-	indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("SupplyRevisionAnalysisChartFourProcessor indexInfoList: %v", indexInfoList)
-
-	// step_3: 指标数据
-	dataList, err := dealData(indexInfoList)
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("SupplyRevisionAnalysisChartFourProcessor dataList: %v", dataList)
-
-	return dataList, err
-}
-
-// SupplyRevisionAnalysisChartFiveProcessor
-// @Description: SupplyRevisionAnalysisChartFiveProcessor处理器
-type SupplyRevisionAnalysisChartFiveProcessor struct{}
-
-func (p *SupplyRevisionAnalysisChartFiveProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
-	utils.FileLog.Info("Processing SupplyRevisionAnalysisChartFiveProcessor...")
-	if rowIndex < 1 {
-		return nil, nil
-	}
-
-	frequency := "月度"
-	unit := "千桶每天"
-	indexNameColPrefix := "YearMonth"
-
-	// step_1: 分类
-	classifyId, err := dealClassify("cube dashboards")
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("classifyId: %v", classifyId)
-
-	// step_2: 指标
-	// 指标名称
-	indexNameOne := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Current/Chat5"
-	indexNameTwo := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Previous/Chat5"
-
-	// 生成指标编码
-	indexCodeOne, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "currentchat5", "")
-	indexCodeTwo, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "previouschat5", "")
-
-	var indexInfoList []*models.IndexInfo
-	var valueOne float64
-	if rowData[len(rowData)-2] == "" {
-		valueOne = 0
-	} else {
-		valueOne, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
-		if err != nil {
-			return nil, err
-		}
-	}
-
-	dataTimeOne := rowData[len(rowData)-1]
-	timeSplit := strings.Split(dataTimeOne, "-")
-	formatOne, err := utils.GetLastDayOfMonth(timeSplit[0] + "-" + timeSplit[1])
-	if err != nil {
-		return nil, err
-	}
-
-	indexInfoList = append(indexInfoList, &models.IndexInfo{
-		IndexName: indexNameOne,
-		IndexCode: indexCodeOne,
-		Value:     valueOne,
-		DataTime:  formatOne,
-	})
-	var valueTwo float64
-	if rowData[len(rowData)-3] == "" {
-		valueTwo = 0
-	} else {
-		valueTwo, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-3], ",", ""), 64)
-		if err != nil {
-			return nil, err
-		}
-	}
-
-	indexInfoList = append(indexInfoList, &models.IndexInfo{
-		IndexName: indexNameTwo,
-		IndexCode: indexCodeTwo,
-		Value:     valueTwo,
-		DataTime:  formatOne,
-	})
-
-	indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("SupplyRevisionAnalysisChartFiveProcessor indexInfoList: %v", indexInfoList)
-
-	// step_3: 指标数据
-	dataList, err := dealData(indexInfoList)
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("SupplyRevisionAnalysisChartFiveProcessor dataList: %v", dataList)
-
-	return dataList, err
-}
-
-// SupplyRevisionAnalysisChartSixProcessor
-// @Description: SupplyRevisionAnalysisChartSixProcessor
-type SupplyRevisionAnalysisChartSixProcessor struct{}
-
-func (p *SupplyRevisionAnalysisChartSixProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
-	utils.FileLog.Info("Processing SupplyRevisionAnalysisChartSixProcessor...")
-	if rowIndex < 1 {
-		return nil, nil
-	}
-
-	frequency := "月度"
-	unit := "千桶每天"
-	indexNameColSuffix := "YearMonth"
-	indexNameColPrefix := "Country Revision Group"
-
-	// step_1: 分类
-	classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("classifyId: %v", classifyId)
-
-	// step_2: 指标
-	// 指标名称
-	indexName := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
-
-	// 生成指标编码
-	indexCode, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix+" "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
-
-	indexInfoMap := make(map[string]string)
-	indexInfoMap[indexCode] = indexName
-
-	var indexInfoList []*models.IndexInfo
-	var value float64
-	if rowData[len(rowData)-1] == "" {
-		value = 0
-	} else {
-		value, err = strconv.ParseFloat(rowData[len(rowData)-1], 64)
-		if err != nil {
-			return nil, err
-		}
-	}
-
-	dataTime := rowData[0]
-	timeSplit := strings.Split(dataTime, "-")
-	format, err := utils.GetLastDayOfMonth(timeSplit[0] + "-" + timeSplit[1])
-	if err != nil {
-		return nil, err
-	}
-
-	indexInfoList = append(indexInfoList, &models.IndexInfo{
-		IndexName: indexName,
-		IndexCode: indexCode,
-		Value:     value,
-		DataTime:  format,
-	})
-
-	indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("SupplyRevisionAnalysisChartSixProcessor indexInfoList: %v", indexInfoList)
-
-	// step_3: 指标数据
-	dataList, err := dealData(indexInfoList)
-	if err != nil {
-		return nil, err
-	}
-	utils.FileLog.Info("SupplyRevisionAnalysisChartSixProcessor dataList: %v", dataList)
-
-	return dataList, err
-}
+//
+//// SupplyRevisionAnalysisChartOneProcessor
+//// @Description: SupplyRevisionAnalysisChartOneProcessor处理器
+//type SupplyRevisionAnalysisChartOneProcessor struct{}
+//
+//func (p *SupplyRevisionAnalysisChartOneProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
+//	utils.FileLog.Info("Processing SupplyRevisionAnalysisChartOne...")
+//	if rowIndex < 1 {
+//		return nil, nil
+//	}
+//
+//	frequency := "季度"
+//	unit := "千桶每天"
+//	indexNameColSuffix := "Year Quarter"
+//	indexNameColPrefix := "Country Revision Group"
+//
+//	// step_1: 分类
+//	classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("classifyId: %v", classifyId)
+//
+//	// step_2: 指标
+//	// 指标名称
+//	indexName := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-1]
+//
+//	// 生成指标编码
+//	indexCode, err := getIndexId("Supply Revision Analysis " + indexNameColPrefix + " Year Quarter")
+//
+//	indexInfoMap := make(map[string]string)
+//	indexInfoMap[indexCode] = indexName
+//
+//	var indexInfoList []*models.IndexInfo
+//	var value float64
+//	if rowData[len(rowData)-2] == "" {
+//		value = 0
+//	} else {
+//		value, err = strconv.ParseFloat(rowData[len(rowData)-2], 64)
+//		if err != nil {
+//			return nil, err
+//		}
+//	}
+//
+//	dataTime := rowData[0]
+//	format, err := utils.ConvertDateFormatQuarter(dataTime)
+//	if err != nil {
+//		return nil, err
+//	}
+//
+//	indexInfoList = append(indexInfoList, &models.IndexInfo{
+//		IndexName: indexName,
+//		IndexCode: indexCode,
+//		Value:     value,
+//		DataTime:  format,
+//	})
+//
+//	indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("SupplyRevisionAnalysisChartOneProcessor indexInfoList: %v", indexInfoList)
+//
+//	// step_3: 指标数据
+//	dataList, err := dealData(indexInfoList)
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("SupplyRevisionAnalysisChartOneProcessor dataList: %v", dataList)
+//
+//	return dataList, err
+//}
+//
+//// SupplyRevisionAnalysisChartTwoProcessor
+//// @Description: SupplyRevisionAnalysisChartTwoProcessor处理器
+//type SupplyRevisionAnalysisChartTwoProcessor struct{}
+//
+//func (p *SupplyRevisionAnalysisChartTwoProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
+//	utils.FileLog.Info("Processing SupplyRevisionAnalysisChartTwoProcessor...")
+//	if rowIndex < 1 {
+//		return nil, nil
+//	}
+//
+//	frequency := "季度"
+//	unit := "千桶每天"
+//	indexNameColPrefix := "YearQuarter"
+//
+//	// step_1: 分类
+//	classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("classifyId: %v", classifyId)
+//
+//	// step_2: 指标
+//	// 指标名称
+//	indexNameOne := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Current"
+//	indexNameTwo := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Previous"
+//
+//	// 生成指标编码
+//	indexCodeOne, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "Current", "")
+//	indexCodeTwo, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "Previous", "")
+//
+//	var indexInfoList []*models.IndexInfo
+//	var valueOne float64
+//	if rowData[len(rowData)-2] == "" {
+//		valueOne = 0
+//	} else {
+//		valueOne, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
+//		if err != nil {
+//			return nil, err
+//		}
+//	}
+//
+//	dataTimeOne := rowData[sheetC]
+//	formatOne, err := utils.ConvertDateFormat2(dataTimeOne)
+//	if err != nil {
+//		return nil, err
+//	}
+//
+//	indexInfoList = append(indexInfoList, &models.IndexInfo{
+//		IndexName: indexNameOne,
+//		IndexCode: indexCodeOne,
+//		Value:     valueOne,
+//		DataTime:  formatOne,
+//	})
+//	var valueTwo float64
+//	if rowData[len(rowData)-1] == "" {
+//		valueTwo = 0
+//	} else {
+//		valueTwo, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-1], ",", ""), 64)
+//		if err != nil {
+//			return nil, err
+//		}
+//	}
+//
+//	indexInfoList = append(indexInfoList, &models.IndexInfo{
+//		IndexName: indexNameTwo,
+//		IndexCode: indexCodeTwo,
+//		Value:     valueTwo,
+//		DataTime:  formatOne,
+//	})
+//
+//	indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("SupplyRevisionAnalysisChartTwoProcessor indexInfoList: %v", indexInfoList)
+//
+//	// step_3: 指标数据
+//	dataList, err := dealData(indexInfoList)
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("SupplyRevisionAnalysisChartTwoProcessor dataList: %v", dataList)
+//
+//	return dataList, err
+//}
+//
+//// SupplyRevisionAnalysisChartThreeProcessor
+//// @Description: SupplyRevisionAnalysisChartThreeProcessor
+//type SupplyRevisionAnalysisChartThreeProcessor struct{}
+//
+//func (p *SupplyRevisionAnalysisChartThreeProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
+//	utils.FileLog.Info("Processing SupplyRevisionAnalysisChartThreeProcessor...")
+//	if rowIndex < 1 {
+//		return nil, nil
+//	}
+//
+//	frequency := "年度"
+//	unit := "千桶每天"
+//	indexNameColSuffix := "Year"
+//	indexNameColPrefix := "Country Revision Group"
+//
+//	// step_1: 分类
+//	classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("classifyId: %v", classifyId)
+//
+//	// step_2: 指标
+//	// 指标名称
+//	indexName := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-1]
+//
+//	// 生成指标编码
+//	indexCode, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix+" "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-1]), " ", ""), "")
+//
+//	indexInfoMap := make(map[string]string)
+//	indexInfoMap[indexCode] = indexName
+//
+//	var indexInfoList []*models.IndexInfo
+//	var value float64
+//	if rowData[len(rowData)-2] == "" {
+//		value = 0
+//	} else {
+//		value, err = strconv.ParseFloat(rowData[len(rowData)-2], 64)
+//		if err != nil {
+//			return nil, err
+//		}
+//	}
+//
+//	dataTime := rowData[0]
+//	format, err := utils.ConvertDateFormat4(dataTime)
+//	if err != nil {
+//		return nil, err
+//	}
+//
+//	indexInfoList = append(indexInfoList, &models.IndexInfo{
+//		IndexName: indexName,
+//		IndexCode: indexCode,
+//		Value:     value,
+//		DataTime:  format,
+//	})
+//
+//	indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("SupplyRevisionAnalysisChartThreeProcessor indexInfoList: %v", indexInfoList)
+//
+//	// step_3: 指标数据
+//	dataList, err := dealData(indexInfoList)
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("SupplyRevisionAnalysisChartThreeProcessor dataList: %v", dataList)
+//
+//	return dataList, err
+//}
+//
+//// SupplyRevisionAnalysisChartFourProcessor
+//// @Description: SupplyRevisionAnalysisChartFourProcessor处理器
+//type SupplyRevisionAnalysisChartFourProcessor struct{}
+//
+//func (p *SupplyRevisionAnalysisChartFourProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
+//	utils.FileLog.Info("Processing SupplyRevisionAnalysisChartFourProcessor...")
+//	if rowIndex < 1 {
+//		return nil, nil
+//	}
+//
+//	frequency := "年度"
+//	unit := "千桶每天"
+//	indexNameColPrefix := "Year"
+//
+//	// step_1: 分类
+//	classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("classifyId: %v", classifyId)
+//
+//	// step_2: 指标
+//	// 指标名称
+//	indexNameOne := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Current"
+//	indexNameTwo := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Previous"
+//
+//	// 生成指标编码
+//	indexCodeOne, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "current", "")
+//	indexCodeTwo, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "previous", "")
+//
+//	var indexInfoList []*models.IndexInfo
+//	var valueOne float64
+//	if rowData[len(rowData)-2] == "" {
+//		valueOne = 0
+//	} else {
+//		valueOne, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
+//		if err != nil {
+//			return nil, err
+//		}
+//	}
+//
+//	dataTimeOne := rowData[0]
+//	formatOne, err := utils.ConvertDateFormat4(dataTimeOne)
+//	if err != nil {
+//		return nil, err
+//	}
+//
+//	indexInfoList = append(indexInfoList, &models.IndexInfo{
+//		IndexName: indexNameOne,
+//		IndexCode: indexCodeOne,
+//		Value:     valueOne,
+//		DataTime:  formatOne,
+//	})
+//	var valueTwo float64
+//	if rowData[len(rowData)-1] == "" {
+//		valueTwo = 0
+//	} else {
+//		valueTwo, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-1], ",", ""), 64)
+//		if err != nil {
+//			return nil, err
+//		}
+//	}
+//
+//	indexInfoList = append(indexInfoList, &models.IndexInfo{
+//		IndexName: indexNameTwo,
+//		IndexCode: indexCodeTwo,
+//		Value:     valueTwo,
+//		DataTime:  formatOne,
+//	})
+//
+//	indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("SupplyRevisionAnalysisChartFourProcessor indexInfoList: %v", indexInfoList)
+//
+//	// step_3: 指标数据
+//	dataList, err := dealData(indexInfoList)
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("SupplyRevisionAnalysisChartFourProcessor dataList: %v", dataList)
+//
+//	return dataList, err
+//}
+//
+//// SupplyRevisionAnalysisChartFiveProcessor
+//// @Description: SupplyRevisionAnalysisChartFiveProcessor处理器
+//type SupplyRevisionAnalysisChartFiveProcessor struct{}
+//
+//func (p *SupplyRevisionAnalysisChartFiveProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
+//	utils.FileLog.Info("Processing SupplyRevisionAnalysisChartFiveProcessor...")
+//	if rowIndex < 1 {
+//		return nil, nil
+//	}
+//
+//	frequency := "月度"
+//	unit := "千桶每天"
+//	indexNameColPrefix := "YearMonth"
+//
+//	// step_1: 分类
+//	classifyId, err := dealClassify("cube dashboards")
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("classifyId: %v", classifyId)
+//
+//	// step_2: 指标
+//	// 指标名称
+//	indexNameOne := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Current/Chat5"
+//	indexNameTwo := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Previous/Chat5"
+//
+//	// 生成指标编码
+//	indexCodeOne, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "currentchat5", "")
+//	indexCodeTwo, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "previouschat5", "")
+//
+//	var indexInfoList []*models.IndexInfo
+//	var valueOne float64
+//	if rowData[len(rowData)-2] == "" {
+//		valueOne = 0
+//	} else {
+//		valueOne, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
+//		if err != nil {
+//			return nil, err
+//		}
+//	}
+//
+//	dataTimeOne := rowData[len(rowData)-1]
+//	timeSplit := strings.Split(dataTimeOne, "-")
+//	formatOne, err := utils.GetLastDayOfMonth(timeSplit[0] + "-" + timeSplit[1])
+//	if err != nil {
+//		return nil, err
+//	}
+//
+//	indexInfoList = append(indexInfoList, &models.IndexInfo{
+//		IndexName: indexNameOne,
+//		IndexCode: indexCodeOne,
+//		Value:     valueOne,
+//		DataTime:  formatOne,
+//	})
+//	var valueTwo float64
+//	if rowData[len(rowData)-3] == "" {
+//		valueTwo = 0
+//	} else {
+//		valueTwo, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-3], ",", ""), 64)
+//		if err != nil {
+//			return nil, err
+//		}
+//	}
+//
+//	indexInfoList = append(indexInfoList, &models.IndexInfo{
+//		IndexName: indexNameTwo,
+//		IndexCode: indexCodeTwo,
+//		Value:     valueTwo,
+//		DataTime:  formatOne,
+//	})
+//
+//	indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("SupplyRevisionAnalysisChartFiveProcessor indexInfoList: %v", indexInfoList)
+//
+//	// step_3: 指标数据
+//	dataList, err := dealData(indexInfoList)
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("SupplyRevisionAnalysisChartFiveProcessor dataList: %v", dataList)
+//
+//	return dataList, err
+//}
+//
+//// SupplyRevisionAnalysisChartSixProcessor
+//// @Description: SupplyRevisionAnalysisChartSixProcessor
+//type SupplyRevisionAnalysisChartSixProcessor struct{}
+//
+//func (p *SupplyRevisionAnalysisChartSixProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
+//	utils.FileLog.Info("Processing SupplyRevisionAnalysisChartSixProcessor...")
+//	if rowIndex < 1 {
+//		return nil, nil
+//	}
+//
+//	frequency := "月度"
+//	unit := "千桶每天"
+//	indexNameColSuffix := "YearMonth"
+//	indexNameColPrefix := "Country Revision Group"
+//
+//	// step_1: 分类
+//	classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("classifyId: %v", classifyId)
+//
+//	// step_2: 指标
+//	// 指标名称
+//	indexName := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
+//
+//	// 生成指标编码
+//	indexCode, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix+" "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
+//
+//	indexInfoMap := make(map[string]string)
+//	indexInfoMap[indexCode] = indexName
+//
+//	var indexInfoList []*models.IndexInfo
+//	var value float64
+//	if rowData[len(rowData)-1] == "" {
+//		value = 0
+//	} else {
+//		value, err = strconv.ParseFloat(rowData[len(rowData)-1], 64)
+//		if err != nil {
+//			return nil, err
+//		}
+//	}
+//
+//	dataTime := rowData[0]
+//	timeSplit := strings.Split(dataTime, "-")
+//	format, err := utils.GetLastDayOfMonth(timeSplit[0] + "-" + timeSplit[1])
+//	if err != nil {
+//		return nil, err
+//	}
+//
+//	indexInfoList = append(indexInfoList, &models.IndexInfo{
+//		IndexName: indexName,
+//		IndexCode: indexCode,
+//		Value:     value,
+//		DataTime:  format,
+//	})
+//
+//	indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("SupplyRevisionAnalysisChartSixProcessor indexInfoList: %v", indexInfoList)
+//
+//	// step_3: 指标数据
+//	dataList, err := dealData(indexInfoList)
+//	if err != nil {
+//		return nil, err
+//	}
+//	utils.FileLog.Info("SupplyRevisionAnalysisChartSixProcessor dataList: %v", dataList)
+//
+//	return dataList, err
+//}
 
 //
 //// OilSupplyAnalysisChartOneProcessor

+ 18 - 18
services/ruizide/processor_factory.go

@@ -64,24 +64,24 @@ type RzdDataProcessor interface {
 }
 
 func GetProcessor(tableName string, sheetName string) (ReportProcessor, error) {
-	if tableName == "Supply_Revision_Analysis" {
-		switch sheetName {
-		case "Chart1":
-			return &SupplyRevisionAnalysisChartOneProcessor{}, nil
-		case "Chart2":
-			return &SupplyRevisionAnalysisChartTwoProcessor{}, nil
-		case "Chart3":
-			return &SupplyRevisionAnalysisChartThreeProcessor{}, nil
-		case "Chart4":
-			return &SupplyRevisionAnalysisChartFourProcessor{}, nil
-		case "Chart5":
-			return &SupplyRevisionAnalysisChartFiveProcessor{}, nil
-		case "Chart6":
-			return &SupplyRevisionAnalysisChartSixProcessor{}, nil
-		default:
-			return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
-		}
-	}
+	//if tableName == "Supply_Revision_Analysis" {
+	//	switch sheetName {
+	//	case "Chart1":
+	//		return &SupplyRevisionAnalysisChartOneProcessor{}, nil
+	//	case "Chart2":
+	//		return &SupplyRevisionAnalysisChartTwoProcessor{}, nil
+	//	case "Chart3":
+	//		return &SupplyRevisionAnalysisChartThreeProcessor{}, nil
+	//	case "Chart4":
+	//		return &SupplyRevisionAnalysisChartFourProcessor{}, nil
+	//	case "Chart5":
+	//		return &SupplyRevisionAnalysisChartFiveProcessor{}, nil
+	//	case "Chart6":
+	//		return &SupplyRevisionAnalysisChartSixProcessor{}, nil
+	//	default:
+	//		return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
+	//	}
+	//}
 	//else if tableName == "Oil_Supply_Analysis" {
 	//	switch sheetName {
 	//	case "Chart1":

+ 65 - 95
services/ruizide/supply_revision_analysis_processor.go

@@ -26,79 +26,76 @@ var (
 		"Chart 1": {
 			Frequency:          "季度",
 			Unit:               "千桶每天",
-			IndexNameColSuffix: "Index",
-			IndexNameColPrefix: "Index 7DMA",
+			IndexNameColSuffix: "Year Quarter",
+			IndexNameColPrefix: "Country Revision Group",
 			chartType:          "one",
 			IndexRow:           2,
-			DateRow:            1,
+			DataRow:            1,
+			DateRow:            0,
 			DateType:           "quarter",
 		},
 		"Chart 2": {
 			Frequency:          "季度",
 			Unit:               "千桶每天",
-			IndexNameColSuffix: "Index",
-			IndexNameColPrefix: "Index 7DMA",
+			IndexNameColPrefix: "Year Quarter",
 			chartType:          "two",
-			NamePrevious:       "",
-			NameCurrent:        "",
-			CodePrevious:       "",
-			CodeCurrent:        "",
-			IndexRow:           2,
-			DataPreviousRow:    4,
-			DataCurrentRow:     5,
-			DateRow:            1,
+			NamePrevious:       "Previous",
+			NameCurrent:        "Current",
+			CodePrevious:       "Previous",
+			CodeCurrent:        "Current",
+			DataPreviousRow:    2,
+			DataCurrentRow:     1,
+			DateRow:            0,
 			DateType:           "quarter",
 		},
 		"Chart 3": {
 			Frequency:          "年度",
 			Unit:               "千桶每天",
-			IndexNameColSuffix: "Index",
-			IndexNameColPrefix: "Index 7DMA",
+			IndexNameColSuffix: "Year",
+			IndexNameColPrefix: "Country Revision Group",
 			chartType:          "one",
 			IndexRow:           2,
-			DateRow:            1,
+			DataRow:            1,
+			DateRow:            0,
 			DateType:           "year",
 		},
 		"Chart 4": {
 			Frequency:          "月度",
 			Unit:               "千桶每天",
-			IndexNameColSuffix: "Index",
-			IndexNameColPrefix: "Index 7DMA",
+			IndexNameColPrefix: "Year",
 			chartType:          "two",
-			NamePrevious:       "",
-			NameCurrent:        "",
-			CodePrevious:       "",
-			CodeCurrent:        "",
-			IndexRow:           2,
-			DataPreviousRow:    4,
-			DataCurrentRow:     5,
-			DateRow:            1,
+			NamePrevious:       "Previous",
+			NameCurrent:        "Current",
+			CodePrevious:       "Previous",
+			CodeCurrent:        "Current",
+			DataPreviousRow:    2,
+			DataCurrentRow:     1,
+			DateRow:            0,
 			DateType:           "year",
 		},
 		"Chart 5": {
 			Frequency:          "月度",
 			Unit:               "千桶每天",
-			IndexNameColSuffix: "Index",
-			IndexNameColPrefix: "Index 7DMA",
+			IndexNameColPrefix: "Year Month",
 			chartType:          "two",
-			NamePrevious:       "",
-			NameCurrent:        "",
-			CodePrevious:       "",
-			CodeCurrent:        "",
-			IndexRow:           3,
-			DataPreviousRow:    4,
-			DataCurrentRow:     5,
-			DateRow:            3,
+			NamePrevious:       "Previous/Chat5",
+			NameCurrent:        "Current/Chat5",
+			CodePrevious:       "previouschat5",
+			CodeCurrent:        "currentchat5",
+			DataPreviousRow:    0,
+			DataCurrentRow:     1,
+			DateRow:            2,
 			DateType:           "month",
 		},
 		"Chart 6": {
 			Frequency:          "日度",
 			Unit:               "千桶每天",
-			IndexNameColSuffix: "Index",
-			IndexNameColPrefix: "Index 7DMA",
+			IndexNameColSuffix: "Year Month",
+			IndexNameColPrefix: "Country Revision Group",
 			chartType:          "one",
-			IndexRow:           3,
-			DateRow:            1,
+			IndexRow:           1,
+			DataRow:            2,
+			DateRow:            0,
 			DateType:           "month",
 		},
 	}
@@ -110,6 +107,7 @@ type SRAPConfig struct {
 	IndexNameColSuffix string
 	IndexNameColPrefix string
 	IndexRow           int
+	DataRow            int
 	DataPreviousRow    int
 	DataCurrentRow     int
 	DateRow            int
@@ -191,27 +189,35 @@ func (p *SupplyRevisionAnalysisProcessor) Process(tableName string) (err error)
 	return
 }
 func OneDataHandler(dataRows [][]string, sheetConfig SRAPConfig, classifyId int) (indexMap map[string]*models.IndexInfo, err error) {
+	re := regexp.MustCompile(`^\d*\.?\d*\s*$`)
 	for _, rowData := range dataRows[BeginRow:] {
 		// step_2: 指标
 		// 指标名称
-		indexNameOne := sheetName + "/" + rowData[sheetConfig.IndexRow] + "/" + sheetConfig.IndexNameColOne
-		indexNameTwo := sheetName + "/" + rowData[sheetConfig.IndexRow] + "/" + sheetConfig.IndexNameColTwo
+		indexName := SupplyRevisionAnalysis + "/" + sheetConfig.IndexNameColPrefix + "/" + sheetConfig.IndexNameColSuffix + "/" + rowData[sheetConfig.IndexRow]
 		// 生成指标编码
-		indexCodeOne := getIndexId(sheetName, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), sheetConfig.IndexNameColOne)
-		indexCodeTwo := getIndexId(sheetName, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), sheetConfig.IndexNameColTwo)
+		indexCode := getIndexId(fmt.Sprintf("%s %s %s", SupplyRevisionAnalysis, sheetConfig.IndexNameColPrefix, sheetConfig.IndexNameColSuffix), strings.ReplaceAll(strings.ToLower(rowData[sheetConfig.IndexRow]), " ", ""), "")
 		dataTime := rowData[sheetConfig.DateRow]
-		date, _, convertErr := utils.ConvertDateFormat(dataTime)
+		var date time.Time
+		var convertErr error
+		switch sheetConfig.DateType {
+		case "quarter":
+			date, _, convertErr = utils.ConvertDateFormatQuarter(dataTime)
+		case "month":
+			date, _, convertErr = utils.ConvertDateFormatYear(dataTime)
+		case "year":
+			date, _, convertErr = utils.ConvertLastDayOfMonth(dataTime)
+		}
 		if convertErr != nil {
-			utils.FileLog.Error(fmt.Sprintf("转换时间数据失败,index_code:%s,time_value:%s err:%v", indexCodeOne, dataTime, convertErr))
+			utils.FileLog.Error(fmt.Sprintf("转换时间数据失败,index_code:%s,time_value:%s err:%v", indexCode, dataTime, convertErr))
 			continue
 		}
-		if rowData[sheetConfig.DataOneRow] != "" && re.MatchString(strings.TrimSpace(rowData[sheetConfig.DataOneRow])) {
-			valueOne, parseErr := decimal.NewFromString(strings.ReplaceAll(rowData[sheetConfig.DataOneRow], ",", ""))
+		if rowData[sheetConfig.DataRow] != "" && re.MatchString(strings.TrimSpace(rowData[sheetConfig.DataRow])) {
+			valueOne, parseErr := decimal.NewFromString(rowData[sheetConfig.DataRow])
 			if parseErr != nil {
-				utils.FileLog.Error(fmt.Sprintf("转换data数据失败,index_code:%s,data_value:%s err:%v", indexCodeOne, rowData[sheetConfig.DataOneRow], err))
+				utils.FileLog.Error(fmt.Sprintf("转换data数据失败,index_code:%s,data_value:%s err:%v", indexCode, rowData[sheetConfig.DataRow], err))
 				continue
 			} else {
-				if index, ok := indexMap[indexCodeOne]; ok {
+				if index, ok := indexMap[indexCode]; ok {
 					if index.StartDate.After(date) {
 						index.StartDate = date
 					}
@@ -224,9 +230,9 @@ func OneDataHandler(dataRows [][]string, sheetConfig SRAPConfig, classifyId int)
 						Value:    valueOne,
 					})
 				} else {
-					indexMap[indexCodeOne] = &models.IndexInfo{
-						IndexName:   indexNameOne,
-						IndexCode:   indexCodeOne,
+					indexMap[indexCode] = &models.IndexInfo{
+						IndexName:   indexName,
+						IndexCode:   indexCode,
 						Frequency:   sheetConfig.Frequency,
 						Unit:        sheetConfig.Unit,
 						StartDate:   date,
@@ -243,50 +249,13 @@ func OneDataHandler(dataRows [][]string, sheetConfig SRAPConfig, classifyId int)
 				}
 			}
 		}
-		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) {
-						index.StartDate = date
-					}
-					if index.EndDate.Before(date) {
-						index.EndDate = date
-						index.LatestValue = valueTwo
-					}
-					index.DataList = append(index.DataList, models.IndexData{
-						DataTime: date,
-						Value:    valueTwo,
-					})
-				} else {
-					indexMap[indexCodeTwo] = &models.IndexInfo{
-						IndexName:   indexNameTwo,
-						IndexCode:   indexCodeTwo,
-						Frequency:   sheetConfig.Frequency,
-						Unit:        sheetConfig.Unit,
-						StartDate:   date,
-						EndDate:     date,
-						LatestValue: valueTwo,
-						ClassifyId:  classifyId,
-						DataList: []models.IndexData{
-							{
-								DataTime: date,
-								Value:    valueTwo,
-							},
-						},
-					}
-				}
-			}
-		}
 	}
+	return
 }
 func TwoDataHandler(dataRows [][]string, sheetConfig SRAPConfig, classifyId int) (indexMap map[string]*models.IndexInfo, err error) {
+	// 匹配非数字字符
+	re := regexp.MustCompile(`^\d*\.?\d*\s*$`)
 	for _, rowData := range dataRows[BeginRow:] {
-		// 匹配非数字字符
-		re := regexp.MustCompile(`^\d*\.?\d*\s*$`)
 		//处理数据不全的情况
 		less := Rows - len(rowData)
 		if less > 0 {
@@ -310,9 +279,9 @@ func TwoDataHandler(dataRows [][]string, sheetConfig SRAPConfig, classifyId int)
 		case "quarter":
 			date, _, convertErr = utils.ConvertDateFormatQuarter(dataTime)
 		case "month":
-			date, _, convertErr = utils.ConvertDateFormat(dataTime)
+			date, _, convertErr = utils.ConvertDateFormatYear(dataTime)
 		case "year":
-			date, _, convertErr = utils.ConvertDateFormat(dataTime)
+			date, _, convertErr = utils.ConvertLastDayOfMonth(dataTime)
 		}
 		if convertErr != nil {
 			utils.FileLog.Error(fmt.Sprintf("转换时间数据失败,index_code:%s,time_value:%s err:%v", indexNameCurrent, dataTime, convertErr))
@@ -396,4 +365,5 @@ func TwoDataHandler(dataRows [][]string, sheetConfig SRAPConfig, classifyId int)
 			}
 		}
 	}
+	return
 }

+ 22 - 6
utils/date_util.go

@@ -362,7 +362,22 @@ func IsSameMonth(dateText1, dateText2 string) (bool, error) {
 }
 
 // GetLastDayOfMonth 获取传入年月的最后一天 dateText 格式为 2024-08 --> 2024-08-31
-func GetLastDayOfMonth(dateText string) (string, error) {
+func ConvertLastDayOfMonth(dateText string) (date time.Time, dateStr string, err error) {
+	// 解析日期
+	date, err = time.Parse("2006-01", strings.TrimSpace(dateText))
+	if err != nil {
+		err = fmt.Errorf("failed to parse date: %v", err)
+		return
+	}
+	// 获取下个月的第一天
+	nextMonth := date.AddDate(0, 1, 0)
+
+	// 获取本月的最后一天
+	date = nextMonth.AddDate(0, 0, -1)
+	dateStr = date.Format("2006-01-02")
+	return
+}
+func GetLastDayOfMonth(dateText string) (dateStr string, err error) {
 	// 解析日期
 	date, err := time.Parse("2006-01", strings.TrimSpace(dateText))
 	if err != nil {
@@ -591,18 +606,19 @@ func ConvertDateFormat3(dataText string) (string, error) {
 }
 
 // ConvertDateFormat4 转换时间格式 2022 --> 2022-12-31
-func ConvertDateFormat4(dataText string) (string, error) {
+func ConvertDateFormatYear(dataText string) (date time.Time, dateStr string, err error) {
 	// 解析输入年份
 	year, err := strconv.Atoi(dataText)
 	if err != nil {
-		return "", fmt.Errorf("无法解析年份: %v", err)
+		err = fmt.Errorf("无法解析年份: %v", err)
+		return
 	}
 
 	// 创建该年最后一天的日期
-	lastDay := time.Date(year, time.December, 31, 0, 0, 0, 0, time.UTC)
-
+	date = time.Date(year, time.December, 31, 0, 0, 0, 0, time.UTC)
 	// 返回格式化后的日期字符串
-	return lastDay.Format("2006-01-02"), nil
+	dateStr = date.Format("2006-01-02")
+	return
 }
 
 // ConvertDateFormat5 转换时间格式 yyyy-MM-dd HH:mm:ss --> yyyy-MM-dd