|
@@ -1,12 +1,14 @@
|
|
|
package services
|
|
|
|
|
|
import (
|
|
|
+ "context"
|
|
|
"encoding/json"
|
|
|
"eta/eta_data_analysis/models"
|
|
|
"eta/eta_data_analysis/services/base_from_yongyi"
|
|
|
"eta/eta_data_analysis/utils"
|
|
|
"fmt"
|
|
|
"github.com/tealeg/xlsx"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
/*
|
|
@@ -32,11 +34,12 @@ import (
|
|
|
月度-大猪存栏(2020年5月新增)
|
|
|
月度-商品猪出栏量
|
|
|
*/
|
|
|
-func HandleYongyiExcelDaily(uploadPath string) (err error) {
|
|
|
- xlFile, err := xlsx.OpenFile(uploadPath)
|
|
|
+func HandleYongyiExcelDaily(cont context.Context) (err error) {
|
|
|
+ filePath := fmt.Sprintf("%s/%s_day.xlsx", utils.YongyiFilePath, time.Now().Format(utils.FormatDate))
|
|
|
+ xlFile, err := xlsx.OpenFile(filePath)
|
|
|
if err != nil {
|
|
|
err = fmt.Errorf("打开文件失败, Err: %s", err)
|
|
|
- utils.FileLog.Info(fmt.Sprintf("打开文件:%s 失败, Err: %s", uploadPath, err))
|
|
|
+ utils.FileLog.Info(fmt.Sprintf("打开文件:%s 失败, Err: %s", filePath, err))
|
|
|
return
|
|
|
}
|
|
|
terminalCode := ""
|
|
@@ -83,11 +86,16 @@ func HandleYongyiExcelDaily(uploadPath string) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func HandleYongyiExcelWeekly(uploadPath string) (err error) {
|
|
|
- xlFile, err := xlsx.OpenFile(uploadPath)
|
|
|
+func HandleYongyiExcelWeekly(cont context.Context) (err error) {
|
|
|
+ week := time.Now().Weekday()
|
|
|
+ if week != time.Thursday { //每周四,处理
|
|
|
+ return
|
|
|
+ }
|
|
|
+ filePath := fmt.Sprintf("%s/%s_week.xlsx", utils.YongyiFilePath, time.Now().Format(utils.FormatDate))
|
|
|
+ xlFile, err := xlsx.OpenFile(filePath)
|
|
|
if err != nil {
|
|
|
err = fmt.Errorf("打开文件失败, Err: %s", err)
|
|
|
- utils.FileLog.Info(fmt.Sprintf("打开文件:%s 失败, Err: %s", uploadPath, err))
|
|
|
+ utils.FileLog.Info(fmt.Sprintf("打开文件:%s 失败, Err: %s", filePath, err))
|
|
|
return
|
|
|
}
|
|
|
terminalCode := ""
|