瀏覽代碼

数据修复

ziwen 2 年之前
父節點
當前提交
6c378883f3
共有 2 個文件被更改,包括 26 次插入19 次删除
  1. 23 16
      services/commodity_coal_inland.go
  2. 3 3
      services/task.go

+ 23 - 16
services/commodity_coal_inland.go

@@ -21,22 +21,29 @@ func FileCoalInland() () {
 			//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "RefreshDataFromCoalInland ErrMsg:"+err.Error(), utils.EmailSendToUsers)
 		}
 	}()
-	//path := "static/file/内陆17省动力煤终端用户供耗存20220408.xlsx"
-	//path := "/home/code/python/coal_mail/emailFile/内陆17省动力煤终端用户供耗存%s.xlsx"
-	path := "/home/code/python/coal_mail/emailFile/内陆17省动力煤终端用户供耗存20220525.xlsx"
-	//for i := 0;i < 7;i++{
-	//	npath := fmt.Sprintf(path,time.Now().AddDate(0,0,-i).Format(utils.FormatDateUnSpace))
-	//	fmt.Println(npath)
-	//	exist,err := PathExists(npath)
-	//	if err != nil {
-	//		fmt.Println(err)
-	//		return
-	//	}
-	//	if exist{
-	//		path = npath
-	//		break
-	//	}
-	//}
+	path := "/home/code/python/coal_mail/emailFile/内陆17省动力煤终端用户供耗存%s.xlsx"
+	for i := 0;i < 7;i++{
+		npath := fmt.Sprintf(path,time.Now().AddDate(0,0,-i).Format(utils.FormatDateUnSpace))
+		fmt.Println(npath)
+		exist,err := PathExists(npath)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+		if exist{
+			path = npath
+			break
+		}
+	}
+	exist,err := PathExists(path)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	if !exist{
+		path = "/home/code/python/coal_mail/emailFile/内陆17省动力煤终端用户供耗存.xlsx"
+	}
+
 	xlFile, err := xlsx.OpenFile(path)
 	if err != nil {
 		fmt.Println(err)

+ 3 - 3
services/task.go

@@ -15,9 +15,9 @@ func Task() {
 	//task.AddTask("中国煤炭网爬取", refreshCoal)
 	//task.StartTask()
 	//FileCoalJsm()
-	//FileCoalFirm()
-	//FileCoalCoastal()
-	FileCoalInland()
+	FileCoalFirm()
+	FileCoalCoastal()
+	//FileCoalInland()
 	fmt.Println("end crawler")
 }