|
@@ -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)
|