Browse Source

汾渭数据源-接口数据爬取

gmy 7 months ago
parent
commit
f12974ebde
2 changed files with 63 additions and 62 deletions
  1. 46 45
      models/base_from_fenwei.go
  2. 17 17
      services/fenwei/processor_business_logic.go

+ 46 - 45
models/base_from_fenwei.go

@@ -84,45 +84,46 @@ type JsonConfig struct {
 }
 
 type FenWeiNetResponse struct {
-	MonthlyAccumulation        float64 `json:"monthly_accumulation"`
-	ProductItemCode            string  `json:"product_item_code"`
-	MonthlyValueChnName        string  `json:"monthly_value_chn_name"`
-	MonthlyAccumulationChnName string  `json:"monthly_accumulation_chn_name"`
-	ProductItemName            string  `json:"product_item_name"`
-	DataDate                   string  `json:"data_date"`
-	MonthlyValue               float64 `json:"monthly_value"`
-	MonthlyValueChnUnit        string  `json:"monthly_value_chn_unit"`
-	ProductCode                string  `json:"product_code"`
-	ProvinceName               string  `json:"province_name"`
-	MonthlyAccumulationChnUnit string  `json:"monthly_accumulation_chn_unit"`
-	PortName                   string  `json:"port_name"`
-	PortSonName                string  `json:"port_son_name"`
-	Stock                      float64 `json:"stock"`
-	StockChnName               string  `json:"stock_chn_name"`
-	StockChnUnit               string  `json:"stock_chn_unit"`
-	CoalTypeName               string  `json:"coal_type_name"`
-	WeekValueChnName           string  `json:"week_value_chn_name"`
-	WeekValue                  float64 `json:"week_value"`
-	AvaliableDaysChnName       string  `json:"avaliable_days_chn_name"`
-	AvaliableDaysChnUnit       string  `json:"avaliable_days_chn_unit"`
-	AvaliableDays              float64 `json:"avaliable_days"`
-	DailyConsumptionChnName    string  `json:"daily_consumption_chn_name"`
-	DailyConsumptionChnUnit    string  `json:"daily_consumption_chn_unit"`
-	DailyConsumption           float64 `json:"daily_consumption"`
-	InventoryIndexChnUnit      string  `json:"inventory_index_chn_unit"`
-	InventoryIndex             float64 `json:"inventory_index"`
-	TonsChnUnit                string  `json:"tons_chn_unit"`
-	Tons                       float64 `json:"tons"`
-	TransportVolumeChnUnit     string  `json:"transport_volume_chn_unit"`
-	TransportVolume            float64 `json:"transport_volume"`
-	PriceRmbChnName            string  `json:"price_rmb_chn_name"`
-	PriceIndexMomChnName       string  `json:"price_index_mom_chn_name"`
-	PriceRmbChnUnit            string  `json:"price_rmb_chn_unit"`
-	PriceIndexMomChnUnit       string  `json:"price_index_mom_chn_unit"`
-	PriceRmb                   float64 `json:"price_rmb"`
-	PriceIndexMom              float64 `json:"price_index_mom"`
-	VehicleChnUnit             string  `json:"vehicle_chn_unit"`
-	ShipChnUnit                string  `json:"ship_chn_unit"`
+	MonthlyAccumulation        float64     `json:"monthly_accumulation"`
+	ProductItemCode            string      `json:"product_item_code"`
+	MonthlyValueChnName        string      `json:"monthly_value_chn_name"`
+	MonthlyAccumulationChnName string      `json:"monthly_accumulation_chn_name"`
+	ProductItemName            string      `json:"product_item_name"`
+	DataDate                   string      `json:"data_date"`
+	MonthlyValue               float64     `json:"monthly_value"`
+	MonthlyValueChnUnit        string      `json:"monthly_value_chn_unit"`
+	ProductCode                string      `json:"product_code"`
+	ProvinceName               string      `json:"province_name"`
+	MonthlyAccumulationChnUnit string      `json:"monthly_accumulation_chn_unit"`
+	PortName                   string      `json:"port_name"`
+	PortSonName                string      `json:"port_son_name"`
+	Stock                      float64     `json:"stock"`
+	StockChnName               string      `json:"stock_chn_name"`
+	StockChnUnit               string      `json:"stock_chn_unit"`
+	CoalTypeName               string      `json:"coal_type_name"`
+	WeekValueChnName           string      `json:"week_value_chn_name"`
+	WeekValue                  float64     `json:"week_value"`
+	AvaliableDaysChnName       string      `json:"avaliable_days_chn_name"`
+	AvaliableDaysChnUnit       string      `json:"avaliable_days_chn_unit"`
+	AvaliableDays              float64     `json:"avaliable_days"`
+	DailyConsumptionChnName    string      `json:"daily_consumption_chn_name"`
+	DailyConsumptionChnUnit    string      `json:"daily_consumption_chn_unit"`
+	DailyConsumption           float64     `json:"daily_consumption"`
+	InventoryIndexChnUnit      string      `json:"inventory_index_chn_unit"`
+	InventoryIndex             float64     `json:"inventory_index"`
+	TonsChnUnit                string      `json:"tons_chn_unit"`
+	Tons                       float64     `json:"tons"`
+	TransportVolumeChnUnit     string      `json:"transport_volume_chn_unit"`
+	TransportVolume            float64     `json:"transport_volume"`
+	PriceRmbChnName            string      `json:"price_rmb_chn_name"`
+	PriceIndexMomChnName       string      `json:"price_index_mom_chn_name"`
+	PriceRmbChnUnit            string      `json:"price_rmb_chn_unit"`
+	PriceIndexMomChnUnit       string      `json:"price_index_mom_chn_unit"`
+	PriceRmb                   interface{} `json:"price_rmb"`
+	PriceIndexMom              interface{} `json:"price_index_mom"`
+	VehicleChnUnit             string      `json:"vehicle_chn_unit"`
+	ShipChnUnit                string      `json:"ship_chn_unit"`
+	WeekValueChnUnit           string      `json:"week_value_chn_unit"`
 }
 
 type FenWeiNetResponseWrapper struct {
@@ -149,10 +150,10 @@ type FenWeiNetResponseResult struct {
 type FenWeiNetIndexInfo struct {
 	IndexName string `description:"指标名称"`
 	//IndexCode    string  `description:"指标编码"`
-	Unit         string  `description:"单位"`
-	Frequency    string  `description:"频度"`
-	TerminalCode string  `description:"编码"`
-	ClassifyName string  `description:"分类名称"`
-	DataTime     string  `description:"数据时间"`
-	Value        float64 `description:"数据值"`
+	Unit         string      `description:"单位"`
+	Frequency    string      `description:"频度"`
+	TerminalCode string      `description:"编码"`
+	ClassifyName string      `description:"分类名称"`
+	DataTime     string      `description:"数据时间"`
+	Value        interface{} `description:"数据值"`
 }

+ 17 - 17
services/fenwei/processor_business_logic.go

@@ -48,7 +48,7 @@ func (p *ThermalCoalSupplyProcessor) ProcessResponse(data string) ([]models.FenW
 		var frequency string
 		if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
 			frequency = "月度"
-		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
+		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
 			frequency = "周度"
 		} else {
 			frequency = "日度"
@@ -107,7 +107,7 @@ func (p *CokingCleanCoalSupplyProcessor) ProcessResponse(data string) ([]models.
 		var frequency string
 		if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
 			frequency = "月度"
-		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
+		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
 			frequency = "周度"
 		} else {
 			frequency = data.MonthlyValueChnName
@@ -166,7 +166,7 @@ func (p *RawCoalProvinceProductionProcessor) ProcessResponse(data string) ([]mod
 		var frequency string
 		if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
 			frequency = "月度"
-		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
+		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
 			frequency = "周度"
 		} else {
 			frequency = data.MonthlyValueChnName
@@ -224,7 +224,7 @@ func (p *StateOwnedKeyCoalMineRawCoalProductionProcessor) ProcessResponse(data s
 		var frequency string
 		if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
 			frequency = "月度"
-		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
+		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
 			frequency = "周度"
 		} else {
 			frequency = data.MonthlyValueChnName
@@ -283,7 +283,7 @@ func (p *CokingBituminousCoalProductionProcessor) ProcessResponse(data string) (
 		var frequency string
 		if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
 			frequency = "月度"
-		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
+		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
 			frequency = "周度"
 		} else {
 			frequency = data.MonthlyValueChnName
@@ -346,7 +346,7 @@ func (p *ThermalCoalInventorySocietyProcessor) ProcessResponse(data string) ([]m
 			var frequency string
 			if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
 				frequency = "月度"
-			} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
+			} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
 				frequency = "周度"
 			} else {
 				frequency = data.MonthlyValueChnName
@@ -410,7 +410,7 @@ func (p *ThermalCoalInventoryProductionProcessor) ProcessResponse(data string) (
 			var frequency string
 			if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
 				frequency = "月度"
-			} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
+			} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
 				frequency = "周度"
 			} else {
 				frequency = data.MonthlyValueChnName
@@ -418,7 +418,7 @@ func (p *ThermalCoalInventoryProductionProcessor) ProcessResponse(data string) (
 
 			indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
 				IndexName:    productName + "/汾渭",
-				Unit:         data.MonthlyValueChnUnit,
+				Unit:         data.WeekValueChnUnit,
 				Frequency:    frequency,
 				TerminalCode: utils.TerminalCode,
 				ClassifyName: productName,
@@ -471,7 +471,7 @@ func (p *ThermalCoalInventorySixPowerPlantProcessor) ProcessResponse(data string
 			var frequency string
 			if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
 				frequency = "月度"
-			} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
+			} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
 				frequency = "周度"
 			} else {
 				frequency = "日度"
@@ -557,7 +557,7 @@ func (p *CokingCoalInventorySocietyProcessor) ProcessResponse(data string) ([]mo
 			var frequency string
 			if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
 				frequency = "月度"
-			} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
+			} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
 				frequency = "周度"
 			} else {
 				frequency = data.MonthlyValueChnName
@@ -620,7 +620,7 @@ func (p *CokingCoalInventoryProductionProcessor) ProcessResponse(data string) ([
 			var frequency string
 			if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
 				frequency = "月度"
-			} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
+			} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
 				frequency = "周度"
 			} else {
 				frequency = data.MonthlyValueChnName
@@ -628,7 +628,7 @@ func (p *CokingCoalInventoryProductionProcessor) ProcessResponse(data string) ([
 
 			indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
 				IndexName:    productCategoryName + "/汾渭",
-				Unit:         data.MonthlyValueChnUnit,
+				Unit:         data.WeekValueChnUnit,
 				Frequency:    frequency,
 				TerminalCode: utils.TerminalCode,
 				ClassifyName: productName,
@@ -733,7 +733,7 @@ func (p *NationalCoalMineInventoryProcessor) ProcessResponse(data string) ([]mod
 		var frequency string
 		if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
 			frequency = "月度"
-		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
+		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
 			frequency = "周度"
 		} else {
 			frequency = "日度"
@@ -792,7 +792,7 @@ func (p *StateOwnedKeyCoalMineInventoryProcessor) ProcessResponse(data string) (
 		var frequency string
 		if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
 			frequency = "月度"
-		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
+		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
 			frequency = "周度"
 		} else {
 			frequency = "日度"
@@ -931,7 +931,7 @@ func (p *PortDataInventoryNorthernPortProcessor) ProcessResponse(data string) ([
 		var frequency string
 		if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
 			frequency = "月度"
-		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
+		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
 			frequency = "周度"
 		} else {
 			frequency = "日度"
@@ -1270,7 +1270,7 @@ func (p *ThermalCoalConsumptionProcessor) ProcessResponse(data string) ([]models
 			var frequency string
 			if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
 				frequency = "月度"
-			} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
+			} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
 				frequency = "周度"
 			} else {
 				frequency = "日度"
@@ -1327,7 +1327,7 @@ func (p *CokingCleanCoalConsumptionProcessor) ProcessResponse(data string) ([]mo
 		var frequency string
 		if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
 			frequency = "月度"
-		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
+		} else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "度") {
 			frequency = "周度"
 		} else {
 			frequency = "日度"