Pārlūkot izejas kodu

Merge branch 'feature/shanghai_smm' of eta_server/eta_crawler into master

baoziqiang 2 nedēļas atpakaļ
vecāks
revīzija
a770adf158
2 mainītis faili ar 26 papildinājumiem un 2 dzēšanām
  1. 2 1
      .gitignore
  2. 24 1
      services/smm_shanghai.go

+ 2 - 1
.gitignore

@@ -9,4 +9,5 @@
 /eta_crawler.exe
 /binlog/*.log
 /static/file/*
-.DS_Store
+.DS_Store
+/test/

+ 24 - 1
services/smm_shanghai.go

@@ -202,6 +202,18 @@ var copperReqs = []SmmRequest{
 		Unit:      "元/吨",
 		Frequency: "日度",
 	},
+	{
+		Name:      "电力行业用杆加工费(华东)-平均价",
+		Url:       "https://hq.smm.cn/ajax/spot/history/201811010001",
+		Unit:      "元/吨",
+		Frequency: "日度",
+	},
+	{
+		Name:      "电力行业用杆加工费(华南)-平均价",
+		Url:       "https://hq.smm.cn/ajax/spot/history/202004080001",
+		Unit:      "元/吨",
+		Frequency: "日度",
+	},
 }
 
 var zincReqs = []SmmRequest{
@@ -380,6 +392,12 @@ type EdbInfoData struct {
 }
 
 func SyncShangHaiSmm(cont context.Context) (err error) {
+	utils.FileLog.Info("上海有色爬虫开始更新")
+	defer func() {
+		if err := recover(); err != nil {
+			utils.FileLog.Error("上海有色爬虫更新失败:%+v", err)
+		}
+	}()
 	upMonth := time.Now().AddDate(0, -1, 0).Format(utils.FormatDate)
 	curDate := time.Now().Format(utils.FormatDate)
 	reqList := make([]SmmRequest, 0)
@@ -424,6 +442,7 @@ func SyncShangHaiSmm(cont context.Context) (err error) {
 			Value:     v.Value,
 			SmmData:   *data[len(data)-1],
 		})
+		utils.FileLog.Info("上海有色爬虫请求成功, 指标名称:%s, 指标数据:%+v", v.Name, data[len(data)-1])
 	}
 
 	urlStr := `shanghai_smm/refresh/list`
@@ -449,6 +468,7 @@ func SyncShangHaiSmm(cont context.Context) (err error) {
 		fmt.Println("上海有色爬虫更新失败")
 		return
 	}
+	utils.FileLog.Info("上海有色爬虫完成更新")
 	return
 }
 
@@ -538,7 +558,7 @@ func OldExcel() (err error) {
 		fmt.Print(err)
 		return
 	}
-	var edbClassify = []string{`镍`, `铜`, `锌`, `锌(日度)`}
+	var edbClassify = []string{`镍`, `铜`, `锌`, `锌(日度)`, `二期`}
 	for _, v := range edbClassify {
 		edbInfoList := ExcelToSmm(f, v)
 		_, err = json.Marshal(edbInfoList)
@@ -547,6 +567,9 @@ func OldExcel() (err error) {
 			return
 		}
 		fmt.Println("成功:", v)
+		if len(edbInfoList) == 0 {
+			continue
+		}
 		urlStr := `shanghai_smm/refresh/excel`
 		postUrl := utils.EDB_LIB_URL + urlStr
 		postData, er := json.Marshal(edbInfoList)