ziwen 3 年之前
父节点
当前提交
a1d9b2ca2c
共有 2 个文件被更改,包括 16 次插入11 次删除
  1. 13 8
      services/commodity_coal_firm.go
  2. 3 3
      services/commodity_coal_inland.go

+ 13 - 8
services/commodity_coal_firm.go

@@ -21,39 +21,42 @@ func FileCoalFirm() (err error) {
 	}()
 	var xlFile *xlsx.File
 	syear := time.Now().Year()
+	nyear := strconv.Itoa(syear)
 	var smonth string
 	dateMonth := int(time.Now().Month())
 	smonth = strconv.Itoa(dateMonth)
 	//path := "static/file/firm.xlsx"
 	path := "/home/code/python/coal_mail/emailFile/全国分企业煤炭产量旬度数据(%s年%s月).xlsx"
-	path = fmt.Sprintf(path,syear,smonth)
+	path = fmt.Sprintf(path,nyear,smonth)
 	exist,err := PathExists(path)
 	if err != nil {
 		fmt.Println(err)
 		return
 	}
-	if exist == false {
+	if !exist {
 		path = "/home/code/python/coal_mail/emailFile/全国分企业煤炭产量旬度数据(%s年%s月中旬).xlsx"
-		path = fmt.Sprintf(path,syear,smonth)
+		path = fmt.Sprintf(path,nyear,smonth)
 		exist,err = PathExists(path)
 		if err != nil {
 			fmt.Println(err)
 			return
 		}
-	}else if exist == false {
+	}
+	if !exist {
 		path = "/home/code/python/coal_mail/emailFile/全国分企业煤炭产量旬度数据(%s年%s月上旬).xlsx"
-		path = fmt.Sprintf(path,syear,smonth)
+		path = fmt.Sprintf(path,nyear,smonth)
 		exist,err = PathExists(path)
 		if err != nil {
 			fmt.Println(err)
 			return
 		}
-	}else if exist == false {
+	}
+	if !exist {
 		//本月三个文件都没有,去取上一个月的
 		dateMonth = dateMonth - 1
 		smonth = strconv.Itoa(dateMonth)
 		path = "/home/code/python/coal_mail/emailFile/全国分企业煤炭产量旬度数据(%s年%s月).xlsx"
-		path = fmt.Sprintf(path,syear,smonth)
+		path = fmt.Sprintf(path,nyear,smonth)
 		exist,err = PathExists(path)
 		if err != nil {
 			fmt.Println(err)
@@ -62,7 +65,9 @@ func FileCoalFirm() (err error) {
 	}
 
 
-	path = fmt.Sprintf(path,syear,smonth)
+	//path = fmt.Sprintf(path,nyear,smonth)
+	fmt.Println(path)
+	//path = "static/file/全国分企业煤炭产量旬度数据(2022年3月上旬).xlsx"
 	xlFile, err = xlsx.OpenFile(path)
 	if err != nil {
 		fmt.Println(err)

+ 3 - 3
services/commodity_coal_inland.go

@@ -17,9 +17,9 @@ func FileCoalInland() (err error) {
 			go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "RefreshDataFromDalian ErrMsg:"+err.Error(), utils.EmailSendToUsers)
 		}
 	}()
-	path := "static/file/内陆17省动力煤终端用户供耗存20220322.xlsx"
-	//path := "/home/code/python/coal_mail/emailFile/内陆17省动力煤终端用户供耗存%s.xlsx"
-	//path = fmt.Sprintf(path,time.Now().Format(utils.FormatDateUnSpace))
+	//path := "static/file/内陆17省动力煤终端用户供耗存20220322.xlsx"
+	path := "/home/code/python/coal_mail/emailFile/内陆17省动力煤终端用户供耗存%s.xlsx"
+	path = fmt.Sprintf(path,time.Now().Format(utils.FormatDateUnSpace))
 	xlFile, err := xlsx.OpenFile(path)
 	if err != nil {
 		fmt.Println(err)