Browse Source

煤炭数据源fix

ziwen 3 years ago
parent
commit
9249dcd0fb
2 changed files with 23 additions and 18 deletions
  1. 22 16
      services/commodity_coal_coastal.go
  2. 1 2
      services/commodity_coal_inland.go

+ 22 - 16
services/commodity_coal_coastal.go

@@ -26,23 +26,29 @@ func FileCoalCoastal() () {
 		month = strconv.Itoa(dateMonth)
 		month = "0"+month
 	}
-	path := "/home/code/python/coal_mail/emailFile/沿海八省动力煤终端用户供耗存数据更新%s.%s.xlsx"
-	for i := 0;i < 7;i++{
-		sday := time.Now().AddDate(0,0,-i).Day()
-		day := strconv.Itoa(sday)
-		npath := fmt.Sprintf(path, month, day)
-		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/沿海八省动力煤终端用户供耗存数据更新04.04.xlsx"
+	//path := "/home/code/python/coal_mail/emailFile/沿海八省动力煤终端用户供耗存数据更新%s.%s.xlsx"
+	//for i := 0;i < 7;i++{
+	//	dateDay := time.Now().AddDate(0,0,-i).Day()
+	//	if dateDay < 10 {
+	//		day = strconv.Itoa(dateDay)
+	//		day = "0"+day
+	//	}else {
+	//		day = strconv.Itoa(dateDay)
+	//	}
+	//	npath := fmt.Sprintf(path, month, day)
+	//	fmt.Println(npath)
+	//	exist,err := PathExists(npath)
+	//	if err != nil {
+	//		fmt.Println(err)
+	//		return
+	//	}
+	//	if exist{
+	//		path = npath
+	//		break
+	//	}
+	//}
 
 	xlFile, err := xlsx.OpenFile(path)
 	if err != nil {

+ 1 - 2
services/commodity_coal_inland.go

@@ -19,7 +19,7 @@ func FileCoalInland() () {
 		}
 	}()
 	//path := "static/file/内陆17省动力煤终端用户供耗存20220322.xlsx"
-	path := "/home/code/python/coal_mail/emailFile/内陆17省动力煤终端用户供耗存-%s.xlsx"
+	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)
@@ -33,7 +33,6 @@ func FileCoalInland() () {
 			break
 		}
 	}
-
 	xlFile, err := xlsx.OpenFile(path)
 	if err != nil {
 		fmt.Println(err)