|
@@ -11,7 +11,7 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-func FileCoalCoastal() () {
|
|
|
+func FileCoalCoastal() {
|
|
|
var err error
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
@@ -20,35 +20,34 @@ func FileCoalCoastal() () {
|
|
|
}
|
|
|
}()
|
|
|
//path := "static/file/沿海八省动力煤终端用户供耗存数据更新03.07.xlsx"
|
|
|
- var month string
|
|
|
+ var month, day string
|
|
|
dateMonth := int(time.Now().Month())
|
|
|
if dateMonth < 10 {
|
|
|
month = strconv.Itoa(dateMonth)
|
|
|
- month = "0"+month
|
|
|
+ month = "0" + month
|
|
|
}
|
|
|
|
|
|
- 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
|
|
|
- // }
|
|
|
- //}
|
|
|
+ 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 {
|
|
@@ -136,7 +135,7 @@ func FileCoalCoastal() () {
|
|
|
mappingItems = append(mappingItems, &item)
|
|
|
}
|
|
|
if k == 10 {
|
|
|
- unit = strings.Replace(cell.String(),"单位:","",-1)
|
|
|
+ unit = strings.Replace(cell.String(), "单位:", "", -1)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -175,7 +174,7 @@ func FileCoalCoastal() () {
|
|
|
codeMap[v.IndexName] = v.IndexCode
|
|
|
newId, err := models.AddBaseFromCoalmineMapping(v)
|
|
|
if err != nil {
|
|
|
- for i := 0; i<10; i++ {
|
|
|
+ for i := 0; i < 10; i++ {
|
|
|
v.IndexCode = v.IndexCode + strconv.Itoa(i)
|
|
|
codeMap[v.IndexName] = v.IndexCode
|
|
|
newId, err := models.AddBaseFromCoalmineMapping(v)
|