瀏覽代碼

Merge branch 'ETA_2.0.6'

zwxi 6 月之前
父節點
當前提交
9f081251f3
共有 2 個文件被更改,包括 44 次插入38 次删除
  1. 40 34
      services/base_from_oilchem/jiachun_edb.go
  2. 4 4
      services/base_from_oilchem/oilchem.go

+ 40 - 34
services/base_from_oilchem/jiachun_edb.go

@@ -6,14 +6,13 @@ import (
 	"eta/eta_data_analysis/utils"
 	"fmt"
 	"github.com/PuerkitoBio/goquery"
-	"strconv"
 	"strings"
 	"time"
 )
 
 // OilchemTaskAnalysisHandlers 解析表格的函数
 var OilchemTaskAnalysisHandlers = map[string]func(htm []byte) (err error){
-	"[产量/产能利用率]:中国甲醇产量及产能利用率": AnalysisOilchemJiaChun1,
+	"[产量/产能利用率]:中国甲醇产量及产能利用率周数据统计": AnalysisOilchemJiaChun1,
 	"库存周数据分析":  AnalysisOilchemJiaChun2,
 	"中国甲醇样本生产企业库存及订单待发周数据统计":  AnalysisOilchemJiaChun3,
 	"中国甲醇样本利润周数据统计":   AnalysisOilchemJiaChun4,
@@ -54,7 +53,7 @@ var OilchemTaskAnalysisHandlers = map[string]func(htm []byte) (err error){
 }
 
 var JiaChunListMap = map[string]string {
-	"[产量/产能利用率]:中国甲醇产量及产能利用率" : "https://list.oilchem.net/140/38266/",
+	"[产量/产能利用率]:中国甲醇产量及产能利用率周数据统计" : "https://list.oilchem.net/140/38266/",
 	"库存周数据分析" : "https://list.oilchem.net/140/38271/",
 	"中国甲醇样本生产企业库存及订单待发周数据统计" : "https://list.oilchem.net/140/1086/",
 	"中国甲醇样本利润周数据统计" : "https://list.oilchem.net/140/1088/",
@@ -119,6 +118,7 @@ func AnalysisOilchemJiaChun1(htm []byte) (err error) {
 				text3 := table3.Text()
 				text3 = strings.Replace(text3,"\n","",-1)
 				text3 = strings.Replace(text3," ","",-1)
+				text3 = strings.Replace(text3,"\u00a0","",-1)
 				if text3 == "上周" || text3 == "环比" || text3 == "地区" {
 					return
 				}
@@ -247,6 +247,7 @@ func AnalysisOilchemJiaChun2(htm []byte) (err error) {
 				text3 := table3.Text()
 				text3 = strings.Replace(text3,"\n","",-1)
 				text3 = strings.Replace(text3," ","",-1)
+				text3 = strings.Replace(text3,"\u00a0","",-1)
 				if text3 == "上周" || text3 == "环比" || text3 == "地区" {
 					return
 				}
@@ -378,6 +379,7 @@ func AnalysisOilchemJiaChun3(htm []byte) (err error) {
 				text3 := table3.Text()
 				text3 = strings.Replace(text3,"\n","",-1)
 				text3 = strings.Replace(text3," ","",-1)
+				text3 = strings.Replace(text3,"\u00a0","",-1)
 				if text3 == "上周" || text3 == "环比" || text3 == "地区" {
 					return
 				}
@@ -399,19 +401,19 @@ func AnalysisOilchemJiaChun3(htm []byte) (err error) {
 				}
 				value := text3
 				value = strings.TrimRight(value, "%")
-				valueF, e := strconv.ParseFloat(value, 64)
-				if e != nil {
-					err = e
-					utils.FileLog.Error(fmt.Sprintf("strconv.ParseFloat err:%v",e))
-					return
-				}
+				//valueF, e := strconv.ParseFloat(value, 64)
+				//if e != nil {
+				//	err = e
+				//	utils.FileLog.Error(fmt.Sprintf("strconv.ParseFloat err:%v",e))
+				//	return
+				//}
 
 
 
 				indexName := titleList[tableIndex] + "(" + area +")"
 				unit := "万吨"
 				fmt.Println("indexName:",indexName)
-				fmt.Println("valueF:",valueF)
+				//fmt.Println("valueF:",valueF)
 				fmt.Println("unit:",unit)
 				item := &models.BaseFromOilchemIndex{
 					IndexName:              indexName,
@@ -500,6 +502,7 @@ func AnalysisOilchemJiaChun4(htm []byte) (err error) {
 				text3 := table3.Text()
 				text3 = strings.Replace(text3,"\n","",-1)
 				text3 = strings.Replace(text3," ","",-1)
+				text3 = strings.Replace(text3,"\u00a0","",-1)
 				if text3 == "上周" || text3 == "环比" || text3 == "地区" {
 					return
 				}
@@ -521,7 +524,7 @@ func AnalysisOilchemJiaChun4(htm []byte) (err error) {
 				}
 				value := text3
 				value = strings.TrimRight(value, "%")
-				valueF, e := strconv.ParseFloat(value, 64)
+				//valueF, e := strconv.ParseFloat(value, 64)
 				if e != nil {
 					err = e
 					utils.FileLog.Error(fmt.Sprintf("strconv.ParseFloat err:%v",e))
@@ -532,7 +535,7 @@ func AnalysisOilchemJiaChun4(htm []byte) (err error) {
 				indexName := area
 				unit := "元/吨"
 				fmt.Println("indexName:",indexName)
-				fmt.Println("valueF:",valueF)
+				//fmt.Println("valueF:",valueF)
 				fmt.Println("unit:",unit)
 				item := &models.BaseFromOilchemIndex{
 					IndexName:              indexName,
@@ -620,6 +623,7 @@ func AnalysisOilchemJiaChun5(htm []byte) (err error) {
 				text3 := table3.Text()
 				text3 = strings.Replace(text3,"\n","",-1)
 				text3 = strings.Replace(text3," ","",-1)
+				text3 = strings.Replace(text3,"\u00a0","",-1)
 				if text3 == "上周" || text3 == "环比" || text3 == "地区" {
 					return
 				}
@@ -641,12 +645,12 @@ func AnalysisOilchemJiaChun5(htm []byte) (err error) {
 				}
 				value := text3
 				value = strings.TrimRight(value, "%")
-				valueF, e := strconv.ParseFloat(value, 64)
-				if e != nil {
-					err = e
-					utils.FileLog.Error(fmt.Sprintf("strconv.ParseFloat err:%v",e))
-					return
-				}
+				//valueF, e := strconv.ParseFloat(value, 64)
+				//if e != nil {
+				//	err = e
+				//	utils.FileLog.Error(fmt.Sprintf("strconv.ParseFloat err:%v",e))
+				//	return
+				//}
 
 
 				indexName := "中国甲醇" + area
@@ -657,7 +661,7 @@ func AnalysisOilchemJiaChun5(htm []byte) (err error) {
 					unit = "%"
 				}
 				fmt.Println("indexName:",indexName)
-				fmt.Println("valueF:",valueF)
+				//fmt.Println("valueF:",valueF)
 				fmt.Println("unit:",unit)
 				item := &models.BaseFromOilchemIndex{
 					IndexName:              indexName,
@@ -744,6 +748,7 @@ func AnalysisOilchemJiaChun6(htm []byte) (err error) {
 				text3 := table3.Text()
 				text3 = strings.Replace(text3,"\n","",-1)
 				text3 = strings.Replace(text3," ","",-1)
+				text3 = strings.Replace(text3,"\u00a0","",-1)
 				if text3 == "上周" || text3 == "环比" || text3 == "地区" {
 					return
 				}
@@ -765,19 +770,19 @@ func AnalysisOilchemJiaChun6(htm []byte) (err error) {
 				}
 				value := text3
 				value = strings.TrimRight(value, "%")
-				valueF, e := strconv.ParseFloat(value, 64)
-				if e != nil {
-					err = e
-					utils.FileLog.Error(fmt.Sprintf("strconv.ParseFloat err:%v",e))
-					return
-				}
+				//valueF, e := strconv.ParseFloat(value, 64)
+				//if e != nil {
+				//	err = e
+				//	utils.FileLog.Error(fmt.Sprintf("strconv.ParseFloat err:%v",e))
+				//	return
+				//}
 				area = strings.Replace(area," ","",-1)
 				area = strings.Replace(area," ","",-1)
 
 				indexName := "中国甲醇部分下游品种产能利用率" +"("+ area +")"
 				unit := "%"
 				fmt.Println("indexName:",indexName)
-				fmt.Println("valueF:",valueF)
+				//fmt.Println("valueF:",valueF)
 				fmt.Println("unit:",unit)
 				item := &models.BaseFromOilchemIndex{
 					BaseFromOilchemIndexId: 0,
@@ -866,6 +871,7 @@ func AnalysisOilchemJiaChun7(htm []byte) (err error) {
 				text3 := table3.Text()
 				text3 = strings.Replace(text3,"\n","",-1)
 				text3 = strings.Replace(text3," ","",-1)
+				text3 = strings.Replace(text3,"\u00a0","",-1)
 				if text3 == "上周" || text3 == "环比" || text3 == "地区" {
 					return
 				}
@@ -887,18 +893,18 @@ func AnalysisOilchemJiaChun7(htm []byte) (err error) {
 				}
 				value := text3
 				value = strings.TrimRight(value, "%")
-				valueF, e := strconv.ParseFloat(value, 64)
-				if e != nil {
-					err = e
-					utils.FileLog.Error(fmt.Sprintf("strconv.ParseFloat err:%v",e))
-					return
-				}
+				//valueF, e := strconv.ParseFloat(value, 64)
+				//if e != nil {
+				//	err = e
+				//	utils.FileLog.Error(fmt.Sprintf("strconv.ParseFloat err:%v",e))
+				//	return
+				//}
 
 
 				indexName := area
 				unit := "万吨"
 				fmt.Println("indexName:",indexName)
-				fmt.Println("valueF:",valueF)
+				//fmt.Println("valueF:",valueF)
 				fmt.Println("unit:",unit)
 				item := &models.BaseFromOilchemIndex{
 					BaseFromOilchemIndexId: 0,
@@ -975,7 +981,7 @@ func JiaChunList(num int) (err error) {
 				fmt.Println("AnalysisOilchemJiaChunList err",err)
 				return
 			}
-			time.Sleep(2*time.Second)
+			//time.Sleep(2*time.Second)
 		}
 	}
 	return

+ 4 - 4
services/base_from_oilchem/oilchem.go

@@ -70,19 +70,19 @@ func OilchemList(context.Context) (err error)  {
 	}
 	err = NiaoSuList(num)
 	if err != nil {
-		utils.FileLog.Info("JiaChunList Err:", err)
+		utils.FileLog.Info("NiaoSuList Err:", err)
 	}
 	err = FuHeFeiList(num)
 	if err != nil {
-		utils.FileLog.Info("JiaChunList Err:", err)
+		utils.FileLog.Info("FuHeFeiList Err:", err)
 	}
 	err = ZhiJiangList(num)
 	if err != nil {
-		utils.FileLog.Info("JiaChunList Err:", err)
+		utils.FileLog.Info("ZhiJiangList Err:", err)
 	}
 	err = YuanYouList(num)
 	if err != nil {
-		utils.FileLog.Info("JiaChunList Err:", err)
+		utils.FileLog.Info("YuanYouList Err:", err)
 	}
 	return
 }