Эх сурвалжийг харах

fix:修改ccf新增指标

zqbao 3 сар өмнө
parent
commit
03d69e68bb

+ 10 - 3
services/base_from_ccf/chart.go

@@ -48,6 +48,7 @@ type CCFChartAdditionRule struct {
 	Frequency  string `json:"Frequency"`
 	ProdNames  string `json:"prodNames"`
 	LastNYear  int    `json:"LastNYear"`
+	IndexType  string `json:"IndexType"`
 }
 
 func LoadCCFChartAdditionRule() (rules []*CCFChartAdditionRule, err error) {
@@ -353,9 +354,15 @@ func AnalysisAdditionChartInventoryWeeklyEdb(htm []byte, rule *CCFChartAdditionR
 			date := row.Find("td:nth-child(2)").Text()
 			date = strings.TrimSpace(date)
 
-			// 提取周均值
-			dailyAvg := row.Find("td:nth-child(4)").Text()
-			dailyAvg = strings.TrimSpace(dailyAvg)
+			// 提取周(日)均值
+			var dailyAvg string
+			if rule.IndexType == "周均" {
+				dailyAvg = row.Find("td:nth-child(4)").Text()
+				dailyAvg = strings.TrimSpace(dailyAvg)
+			} else {
+				dailyAvg = row.Find("td:nth-child(3)").Text()
+				dailyAvg = strings.TrimSpace(dailyAvg)
+			}
 
 			// 打印提取的信息
 			fmt.Printf("单位: %s\n产品名称: %s\n日期: %s\n日均值: %s\n\n", unit, indexName, date, dailyAvg)

+ 6 - 4
static/ccf_chart_addition_rule.json

@@ -1,16 +1,18 @@
 [
     {
-        "Name": "CCF/MEG港口库存指数",
+        "Name": "CCFMEG港口库存指数",
         "ClassifyId": 21,
         "Frequency": "周度",
         "prodNames": "kc-221000",
-        "LastNYear": 3
+        "LastNYear": 3,
+        "IndexType": "周均"
     },
     {
-        "Name": "CCF/PTA FOB中国",
+        "Name": "CCFPTA FOB中国",
         "ClassifyId": 22,
         "Frequency": "日度",
         "prodNames": "zs-235",
-        "LastNYear": 3
+        "LastNYear": 3,
+        "IndexType": "日均"
     }
 ]