// Package fenwei // @Author gmy 2024/8/20 14:47:00 package fenwei import ( "encoding/json" "eta/eta_data_analysis/models" "eta/eta_data_analysis/utils" "fmt" "strings" ) // ThermalCoalSupplyProcessor 动力煤供应量 type ThermalCoalSupplyProcessor struct { BaseProcessor } func (p *ThermalCoalSupplyProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: nil, CheckedDims: map[string][]string{ "province": {"20", "16", "21", "6", "19", "23", "8", "1", "7", "17", "9", "15", "11", "22", "24", "4", "25", "12", "14", "13", "18", "3", "10", "5", "2", "37"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW4002D", QuotaName: "monthly_value,monthly_accumulation", SplitTypeKey: "province", IsTotal: 0, DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *ThermalCoalSupplyProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseData := fillFenWeiNetResponseData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "动力煤供应量" for _, data := range responseData { var frequency string if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") { frequency = "月度" } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") { frequency = "周度" } else { frequency = "日度" } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + data.ProvinceName + "/汾渭", Unit: data.MonthlyValueChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.MonthlyValue, }) } return indexInfoList, nil } // CokingCleanCoalSupplyProcessor 炼焦精煤供应量 type CokingCleanCoalSupplyProcessor struct { BaseProcessor } func (p *CokingCleanCoalSupplyProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: nil, CheckedDims: map[string][]string{ "province": {"20", "16", "21", "6", "19", "23", "8", "1", "7", "17", "9", "15", "11", "22", "24", "4", "25", "12", "14", "13", "18", "3", "10", "5", "2", "37"}, "coal_type": {"13", "10", "9", "8", "7", "5", "3"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW4001D", QuotaName: "monthly_value,monthly_accumulation", SplitTypeKey: "coal_type", IsTotal: 0, DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *CokingCleanCoalSupplyProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseData := fillFenWeiNetResponseData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "炼焦精煤供应量" for _, data := range responseData { var frequency string if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") { frequency = "月度" } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") { frequency = "周度" } else { frequency = data.MonthlyValueChnName } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + data.CoalTypeName + "/汾渭", Unit: data.MonthlyValueChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.MonthlyValue, }) } return indexInfoList, nil } // RawCoalProvinceProductionProcessor 原煤分省分煤种产量 type RawCoalProvinceProductionProcessor struct { BaseProcessor } func (p *RawCoalProvinceProductionProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: nil, CheckedDims: map[string][]string{ "province": {"20", "16", "21", "6", "19", "23", "8", "1", "7", "17", "9", "15", "11", "22", "24", "4", "25", "12", "14", "13", "18", "3", "10", "5", "2", "37"}, "coal_type": {"14", "6", "40", "21"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW3050D", QuotaName: "monthly_value,monthly_accumulation", SplitTypeKey: "coal_type", IsTotal: 0, DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *RawCoalProvinceProductionProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseData := fillFenWeiNetResponseData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "原煤分省分煤种产量" for _, data := range responseData { var frequency string if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") { frequency = "月度" } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") { frequency = "周度" } else { frequency = data.MonthlyValueChnName } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + data.CoalTypeName + "/汾渭", Unit: data.MonthlyValueChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.MonthlyValue, }) } return indexInfoList, nil } // StateOwnedKeyCoalMineRawCoalProductionProcessor 国有重点煤矿原煤产量 type StateOwnedKeyCoalMineRawCoalProductionProcessor struct { BaseProcessor } func (p *StateOwnedKeyCoalMineRawCoalProductionProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: nil, CheckedDims: map[string][]string{ "province": {"20", "16", "21", "6", "19", "23", "8", "1", "7", "17", "9", "15", "11", "22", "24", "4", "25", "12", "14", "13", "2", "27", "28"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW3007D", QuotaName: "monthly_value,monthly_accumulation", SplitTypeKey: "province", IsTotal: 0, DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *StateOwnedKeyCoalMineRawCoalProductionProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseData := fillFenWeiNetResponseData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "国有重点煤矿原煤产量" for _, data := range responseData { var frequency string if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") { frequency = "月度" } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") { frequency = "周度" } else { frequency = data.MonthlyValueChnName } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + data.ProvinceName + "/汾渭", Unit: data.MonthlyValueChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.MonthlyValue, }) } return indexInfoList, nil } // CokingBituminousCoalProductionProcessor 炼焦烟煤分煤种产量 type CokingBituminousCoalProductionProcessor struct { BaseProcessor } func (p *CokingBituminousCoalProductionProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: nil, CheckedDims: map[string][]string{ "province": {"20", "16", "21", "6", "19", "23", "8", "1", "7", "17", "9", "15", "11", "22", "24", "4", "25", "12", "14", "13", "18", "3", "10", "5", "2", "37"}, "coal_type": {"13", "10", "9", "8", "7", "5", "3"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW3001D", QuotaName: "monthly_value,monthly_accumulation", SplitTypeKey: "coal_type", IsTotal: 0, DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *CokingBituminousCoalProductionProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseData := fillFenWeiNetResponseData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "炼焦烟煤分煤种产量" for _, data := range responseData { var frequency string if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") { frequency = "月度" } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") { frequency = "周度" } else { frequency = data.MonthlyValueChnName } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + data.CoalTypeName + "/汾渭", Unit: data.MonthlyValueChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.MonthlyValue, }) } return indexInfoList, nil } // ThermalCoalInventorySocietyProcessor 动力煤库存-全社会 type ThermalCoalInventorySocietyProcessor struct { BaseProcessor } func (p *ThermalCoalInventorySocietyProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: "79", CheckedDims: map[string][]string{ "product_item_code": {"FW8004D-1"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW8004D", QuotaName: "stock,avaliable_days,daily_consumption,monthly_value,inventory_index,week_value", SplitTypeKey: "", DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *ThermalCoalInventorySocietyProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseDataMap := fillFenWeiNetResponseMapData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "动力煤库存-全社会" for productCategoryName, responseDataList := range responseDataMap { if productCategoryName != productName { continue } for _, data := range responseDataList { var frequency string if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") { frequency = "月度" } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") { frequency = "周度" } else { frequency = data.MonthlyValueChnName } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + "/汾渭", Unit: data.MonthlyValueChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.MonthlyValue, }) } } return indexInfoList, nil } // ThermalCoalInventoryProductionProcessor 动力煤库存-生产企业 type ThermalCoalInventoryProductionProcessor struct { BaseProcessor } func (p *ThermalCoalInventoryProductionProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: "116", CheckedDims: map[string][]string{ "product_item_code": {"FW8004D-2"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW8004D", QuotaName: "stock,avaliable_days,daily_consumption,monthly_value,inventory_index,week_value", SplitTypeKey: "", DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *ThermalCoalInventoryProductionProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseDataMap := fillFenWeiNetResponseMapData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "动力煤库存-生产企业" for productCategoryName, responseDataList := range responseDataMap { if productCategoryName != productName { continue } for _, data := range responseDataList { var frequency string if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") { frequency = "月度" } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") { frequency = "周度" } else { frequency = data.MonthlyValueChnName } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + "/汾渭", Unit: data.WeekValueChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.MonthlyValue, }) } } return indexInfoList, nil } // ThermalCoalInventorySixPowerPlantProcessor 动力煤库存-六大电厂 type ThermalCoalInventorySixPowerPlantProcessor struct { BaseProcessor } func (p *ThermalCoalInventorySixPowerPlantProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: "118", CheckedDims: map[string][]string{ "product_item_code": {"FW8004D-125500", "FW8004D-112534", "FW8004D-112548", "FW8004D-112549", "FW8004D-1129", "FW8004D-125", "FW8004D-125382", "FW8004D-125383"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW8004D", QuotaName: "stock,avaliable_days,daily_consumption,monthly_value,inventory_index,week_value", SplitTypeKey: "", DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *ThermalCoalInventorySixPowerPlantProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseDataMap := fillFenWeiNetResponseMapData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "动力煤库存" for productCategoryName, responseDataList := range responseDataMap { for _, data := range responseDataList { var frequency string if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") { frequency = "月度" } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") { frequency = "周度" } else { frequency = "日度" } classifyName := "动力煤库存-六大电厂" // 库存 indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + productCategoryName + data.StockChnName + "/汾渭", Unit: data.StockChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: classifyName, DataTime: data.DataDate, Value: data.Stock, }) // 可用天数 indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + productCategoryName + data.AvaliableDaysChnName + "/汾渭", Unit: data.AvaliableDaysChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: classifyName, DataTime: data.DataDate, Value: data.AvaliableDays, }) // 日耗 indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + productCategoryName + data.DailyConsumptionChnName + "/汾渭", Unit: data.DailyConsumptionChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: classifyName, DataTime: data.DataDate, Value: data.DailyConsumption, }) } } return indexInfoList, nil } // CokingCoalInventorySocietyProcessor 炼焦煤库存-全社会 type CokingCoalInventorySocietyProcessor struct { BaseProcessor } func (p *CokingCoalInventorySocietyProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: "79", CheckedDims: map[string][]string{ "product_item_code": {"FW8005D-1"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW8005D", QuotaName: "stock,monthly_value,inventory_index,week_value", SplitTypeKey: "", DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *CokingCoalInventorySocietyProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseDataMap := fillFenWeiNetResponseMapData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "炼焦煤库存-全社会" for productCategoryName, responseDataList := range responseDataMap { if productCategoryName == "合计" { continue } for _, data := range responseDataList { var frequency string if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") { frequency = "月度" } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") { frequency = "周度" } else { frequency = data.MonthlyValueChnName } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productCategoryName + "/汾渭", Unit: data.MonthlyValueChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.MonthlyValue, }) } } return indexInfoList, nil } // CokingCoalInventoryProductionProcessor 炼焦煤库存-生产企业 type CokingCoalInventoryProductionProcessor struct { BaseProcessor } func (p *CokingCoalInventoryProductionProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: "116", CheckedDims: map[string][]string{ "product_item_code": {"FW8005D-2"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW8005D", QuotaName: "stock,monthly_value,inventory_index,week_value", SplitTypeKey: "", DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *CokingCoalInventoryProductionProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseDataMap := fillFenWeiNetResponseMapData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "炼焦煤库存-生产企业" for productCategoryName, responseDataList := range responseDataMap { if productCategoryName == "合计" { continue } for _, data := range responseDataList { var frequency string if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") { frequency = "月度" } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") { frequency = "周度" } else { frequency = data.MonthlyValueChnName } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productCategoryName + "/汾渭", Unit: data.WeekValueChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.WeekValue, }) } } return indexInfoList, nil } // CokingCoalInventoryDownstreamProcessor 炼焦煤库存-下游企业 type CokingCoalInventoryDownstreamProcessor struct { BaseProcessor } func (p *CokingCoalInventoryDownstreamProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: "117", CheckedDims: map[string][]string{ "product_item_code": {"FW8005D-3", "FW8005D-5"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW8005D", QuotaName: "stock,monthly_value,inventory_index,week_value", SplitTypeKey: "", DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *CokingCoalInventoryDownstreamProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseDataMap := fillFenWeiNetResponseMapData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "炼焦煤库存-下游企业" for productCategoryName, responseDataList := range responseDataMap { if productCategoryName == "合计" { continue } for _, data := range responseDataList { frequency := "周度" indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productCategoryName + "/汾渭", Unit: data.StockChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.Stock, }) } } return indexInfoList, nil } // NationalCoalMineInventoryProcessor 全国煤矿库存 type NationalCoalMineInventoryProcessor struct { BaseProcessor } func (p *NationalCoalMineInventoryProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: nil, CheckedDims: map[string][]string{}, DateRange: "20190820-" + currentTime, ProductCode: "FW8001D", QuotaName: "monthly_value", SplitTypeKey: "", DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *NationalCoalMineInventoryProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseData := fillFenWeiNetResponseData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "全国煤矿库存" for _, data := range responseData { var frequency string if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") { frequency = "月度" } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") { frequency = "周度" } else { frequency = "日度" } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + "/汾渭", Unit: data.MonthlyValueChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.MonthlyValue, }) } return indexInfoList, nil } // StateOwnedKeyCoalMineInventoryProcessor 国有重点煤矿库存 type StateOwnedKeyCoalMineInventoryProcessor struct { BaseProcessor } func (p *StateOwnedKeyCoalMineInventoryProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: nil, CheckedDims: map[string][]string{ "province": {"20", "16", "21", "6", "19", "23", "8", "1", "7", "17", "9", "15", "11", "22", "24", "4", "25", "12", "14", "13", "2", "27", "28"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW8003D", QuotaName: "monthly_value", SplitTypeKey: "province", IsTotal: "", DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *StateOwnedKeyCoalMineInventoryProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseData := fillFenWeiNetResponseData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "国有重点煤矿库存" for _, data := range responseData { var frequency string if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") { frequency = "月度" } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") { frequency = "周度" } else { frequency = "日度" } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + data.ProvinceName + "/汾渭", Unit: data.MonthlyValueChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.MonthlyValue, }) } return indexInfoList, nil } // CokeInventoryProcessor 焦炭库存 type CokeInventoryProcessor struct { BaseProcessor } func (p *CokeInventoryProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: nil, CheckedDims: map[string][]string{ "product_item_code": {"FW1405D-1", "FW1405D-2", "FW1405D-3", "FW1405D-4", "FW1405D-5", "FW1405D-6", "FW1405D-7"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW1405D", QuotaName: "stock,inventory_index", SplitTypeKey: "", DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *CokeInventoryProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseDataMap := fillFenWeiNetResponseMapData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "焦炭库存" for productCategoryName, responseDataList := range responseDataMap { utils.FileLog.Info(fmt.Sprintf("productName: %s, responseDataList:size: %v", productName, len(responseDataList))) for _, data := range responseDataList { var frequency string productCodeMap := map[string]struct{}{ "FW1405D-1": {}, "FW1405D-2": {}, "FW1405D-3": {}, "FW1405D-6": {}, "FW1405D-7": {}, } if _, ok := productCodeMap[data.ProductItemCode]; ok { frequency = "周度" } else { frequency = "日度" } var unit string if data.InventoryIndexChnUnit != "" { unit = data.InventoryIndexChnUnit } else { unit = data.StockChnUnit } var value float64 if data.InventoryIndex != 0 { value = data.InventoryIndex } else { value = data.Stock } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + productCategoryName + "/汾渭", Unit: unit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: value, }) } } return indexInfoList, nil } // PortDataInventoryNorthernPortProcessor 港口数据-库存-北方港口 type PortDataInventoryNorthernPortProcessor struct { BaseProcessor } func (p *PortDataInventoryNorthernPortProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: "79", CheckedDims: map[string][]string{ "code": {"2332", "2333", "2335", "2334", "2337", "2339", "2340", "2341", "2342"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW1203D", QuotaName: "stock", SplitTypeKey: "product_item_code", IsTotal: 0, DataType: nil, Type: 2, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *PortDataInventoryNorthernPortProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseData := fillFenWeiNetResponseData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "港口数据-库存-北方港口" for _, data := range responseData { var frequency string if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") { frequency = "月度" } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") { frequency = "周度" } else { frequency = "日度" } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + data.ProductItemName + "/汾渭", Unit: data.StockChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.Stock, }) } return indexInfoList, nil } // PortDataInventoryInlandPortProcessor 港口数据-库存-江内港口 type PortDataInventoryInlandPortProcessor struct { BaseProcessor } func (p *PortDataInventoryInlandPortProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: "79", CheckedDims: map[string][]string{ "code": {"2321", "2320", "2324", "2323", "2322", "2325"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW1203D", QuotaName: "stock", SplitTypeKey: "product_item_code", IsTotal: 0, DataType: nil, Type: 2, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *PortDataInventoryInlandPortProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseData := fillFenWeiNetResponseData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "港口数据-库存-江内港口" for _, data := range responseData { var frequency = "周度" indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + data.ProductItemName + "/汾渭", Unit: data.StockChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.Stock, }) } return indexInfoList, nil } // PortDataDispatchNorthernPortProcessor 港口数据-调度-北方港口 type PortDataDispatchNorthernPortProcessor struct { BaseProcessor } func (p *PortDataDispatchNorthernPortProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: "120", CheckedDims: map[string][]string{ "code": {"2364", "2365", "2366", "2363", "2367", "2368"}, "port": {"2", "4", "7", "9", "11", "326", "327", "329", "330"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW1203D", QuotaName: "vehicle,ship,tons", SplitTypeKey: "product_item_code,port", IsTotal: 1, DataType: nil, Type: 2, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *PortDataDispatchNorthernPortProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseData := fillFenWeiNetResponseData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "港口数据-调度-北方港口" for _, data := range responseData { var frequency = "日度" var unit string if data.VehicleChnUnit != "" { unit = data.VehicleChnUnit } else if data.TonsChnUnit != "" { unit = data.TonsChnUnit } else { unit = data.ShipChnUnit } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + "-" + data.PortName + data.ProductItemName + "/汾渭", Unit: unit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.Tons, }) } return indexInfoList, nil } // PortDataThroughputProcessor 港口数据-运量 type PortDataThroughputProcessor struct { BaseProcessor } func (p *PortDataThroughputProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: "30", CheckedDims: map[string][]string{ "code": {"2362"}, "port_son": {"44", "43", "42", "41", "40", "39"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW1203D", QuotaName: "transport_volume", SplitTypeKey: "port_son", IsTotal: 0, DataType: nil, Type: 2, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *PortDataThroughputProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseData := fillFenWeiNetResponseData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "港口数据-运量" for _, data := range responseData { var frequency = "日度" indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + data.PortSonName + "/汾渭", Unit: data.TransportVolumeChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.TransportVolume, }) } return indexInfoList, nil } // DaqinLineDailyThroughputProcessor 大秦线日运量 type DaqinLineDailyThroughputProcessor struct { BaseProcessor } func (p *DaqinLineDailyThroughputProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: nil, CheckedDims: map[string][]string{}, DateRange: "20190820-" + currentTime, ProductCode: "FW1107D", QuotaName: "stock", SplitTypeKey: "", DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *DaqinLineDailyThroughputProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseData := fillFenWeiNetResponseData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "大秦线日运量" for _, data := range responseData { var frequency = "日度" indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + data.StockChnName + "/汾渭", Unit: data.StockChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.Stock, }) } return indexInfoList, nil } // ThermalCoalPortPriceProcessor 动力煤港口价格 type ThermalCoalPortPriceProcessor struct { BaseProcessor } func (p *ThermalCoalPortPriceProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: nil, CheckedDims: map[string][]string{ "product_item_code": {"FW2001P-1001", "FW2001P-1002", "FW2001P-1004", "FW2001P-1005", "FW2001P-1003", "FW2001P-1171"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW2310R", QuotaName: "price_rmb,price_index_mom", SplitTypeKey: "", DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *ThermalCoalPortPriceProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseDataMap := fillFenWeiNetResponseAStratumMapData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "动力煤港口价格" for productCategoryName, responseDataList := range responseDataMap { utils.FileLog.Info(fmt.Sprintf("productName: %s, responseDataList:size: %v", productName, len(responseDataList))) for _, data := range responseDataList { var frequency = "日度" indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + productCategoryName + "-" + data.PriceRmbChnName + "/汾渭", Unit: data.PriceRmbChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.PriceRmb, }) indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + productCategoryName + "-" + data.PriceIndexMomChnName + "/汾渭", Unit: data.PriceIndexMomChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.PriceIndexMom, }) } } return indexInfoList, nil } // ThermalCoalConsumptionProcessor 动力煤消费量 type ThermalCoalConsumptionProcessor struct { BaseProcessor } func (p *ThermalCoalConsumptionProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: nil, CheckedDims: map[string][]string{ "product_item_code": {"FW5002D-1", "FW5002D-2", "FW5002D-3", "FW5002D-4", "FW5002D-5", "FW5002D-6", "FW5002D-7"}, }, DateRange: "20190820-" + currentTime, ProductCode: "FW5002D", QuotaName: "monthly_value,monthly_accumulation", SplitTypeKey: "", DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *ThermalCoalConsumptionProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseDataMap := fillFenWeiNetResponseMapData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "动力煤消费量" for productCategoryName, responseDataList := range responseDataMap { utils.FileLog.Info(fmt.Sprintf("productName: %s, responseDataList:size: %v", productName, len(responseDataList))) for _, data := range responseDataList { var frequency string if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") { frequency = "月度" } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") { frequency = "周度" } else { frequency = "日度" } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + productCategoryName + "/汾渭", Unit: data.MonthlyValueChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.MonthlyValue, }) } } return indexInfoList, nil } // CokingCleanCoalConsumptionProcessor 炼焦精煤消费量 type CokingCleanCoalConsumptionProcessor struct { BaseProcessor } func (p *CokingCleanCoalConsumptionProcessor) GenerateRequestParams(currentTime string) map[string]string { params := models.RequestParams{ Category: nil, CheckedDims: map[string][]string{}, DateRange: "20190820-" + currentTime, ProductCode: "FW5001D", QuotaName: "monthly_value,monthly_accumulation", SplitTypeKey: "", DataType: nil, IsSeason: 1, } // 将结构体转换为 JSON 字符串 paramsJSON, _ := json.Marshal(params) // 返回为 map[string]string 类型 return map[string]string{ "params": string(paramsJSON), } } func (p *CokingCleanCoalConsumptionProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) { responseData := fillFenWeiNetResponseData(data) var indexInfoList []models.FenWeiNetIndexInfo productName := "炼焦精煤消费量" for _, data := range responseData { var frequency string if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") { frequency = "月度" } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") { frequency = "周度" } else { frequency = "日度" } indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{ IndexName: productName + "/汾渭", Unit: data.MonthlyValueChnUnit, Frequency: frequency, TerminalCode: utils.TerminalCode, ClassifyName: productName, DataTime: data.DataDate, Value: data.MonthlyValue, }) } return indexInfoList, nil } func fillFenWeiNetResponseData(data string) []models.FenWeiNetResponse { var result models.FenWeiNetResponseWrapper err := json.Unmarshal([]byte(data), &result) if err != nil { return nil } responseData := result.Data.Data return responseData } func fillFenWeiNetResponseMapData(data string) map[string][]models.FenWeiNetResponse { var result models.FenWeiNetResponseMapWrapper err := json.Unmarshal([]byte(data), &result) if err != nil { return nil } responseData := result.Data.Data return responseData } func fillFenWeiNetResponseAStratumMapData(data string) map[string][]models.FenWeiNetResponse { var result models.FenWeiNetResponseAStratumMapWrapper err := json.Unmarshal([]byte(data), &result) if err != nil { return nil } responseData := result.Data return responseData }