package services import ( "context" "encoding/json" "eta/eta_data_analysis/models" "eta/eta_data_analysis/services/base_from_yongyi_v2" "eta/eta_data_analysis/utils" "fmt" "io/fs" "os" "path" "path/filepath" "strings" "sync" "time" "github.com/xuri/excelize/v2" ) /* 日度-商品猪出栏价 日度-商品猪标肥价差 日度-商品猪全国均价和宰量 日度-屠宰企业屠宰量 周度-商品猪出栏价 周度-体重 周度-屠宰厂宰前活猪重 周度-各体重段价差 周度-50公斤二元母猪价格 周度-规模场15公斤仔猪出栏价 周度-宰后结算价 周度-冻品库存 周度-冻品库存多样本 周度-猪肉价(前三等级白条均价) 月度出栏完成率 月度计划出栏量 月度-能繁母猪存栏(2020年2月新增) 月度-小猪存栏(2020年5月新增) 月度-中猪存栏(2020年5月新增) 月度-大猪存栏(2020年5月新增) 月度-商品猪出栏量 */ func HandleYongyiExcelDaily(filePath string) (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", filePath, err)) return } terminalCode := utils.TerminalCode for _, sheet := range xlFile.Sheets { var indexList []*models.YongyiExcelIndex switch sheet.Name { case "出栏价": indexList, err = base_from_yongyi.HandleYongyiExcelDaily1(sheet) case "标肥价差": indexList, err = base_from_yongyi.HandleYongyiExcelDaily2(sheet) case "价格+宰量": indexList, err = base_from_yongyi.HandleYongyiExcelDaily3(sheet) case "屠宰企业日度屠宰量": indexList, err = base_from_yongyi.HandleYongyiExcelDaily4(sheet) default: continue } if err != nil { utils.FileLog.Info(fmt.Sprintf("解析sheet:%s 失败, Err: %s", sheet.Name, err)) continue } if len(indexList) > 0 { params := make(map[string]interface{}) params["List"] = indexList params["TerminalCode"] = terminalCode result, e := PostEdbLib(params, utils.LIB_ROUTE_YONGYI_HANDLE) if e != nil { b, _ := json.Marshal(params) utils.FileLog.Info(fmt.Sprintf("sheet :%s PostEdbLib err: %s, params: %s", sheet.Name, e.Error(), string(b))) return } resp := new(models.BaseEdbLibResponse) if e := json.Unmarshal(result, &resp); e != nil { utils.FileLog.Info(fmt.Sprintf("sheet :%s json.Unmarshal err: %s", sheet.Name, e)) continue } if resp.Ret != 200 { utils.FileLog.Info(fmt.Sprintf("sheet :%s Msg: %s, ErrMsg: %s", sheet.Name, resp.Msg, resp.ErrMsg)) continue } } }*/ return } func HandleYongyiExcelWeekly(filePath string) (err error) { // 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", filePath, err)) return } terminalCode := utils.TerminalCode for _, sheet := range xlFile.Sheets { var indexList []*models.YongyiExcelIndex switch sheet.Name { case "周度-商品猪出栏价": indexList, err = base_from_yongyi.HandleYongyiExcelWeekly1(sheet) case "周度-体重": indexList, err = base_from_yongyi.HandleYongyiExcelWeekly2(sheet) case "周度-屠宰厂宰前活猪重": indexList, err = base_from_yongyi.HandleYongyiExcelWeekly3(sheet) case "周度-各体重段价差": indexList, err = base_from_yongyi.HandleYongyiExcelWeekly4(sheet) case "周度-50公斤二元母猪价格", "周度-规模场15公斤仔猪出栏价", "周度-宰后结算价", "周度-冻品库存", "周度-猪肉价(前三等级白条均价)": indexList, err = base_from_yongyi.HandleYongyiExcelWeekly5(sheet) case "周度-冻品库存多样本", "月度出栏完成率": indexList, err = base_from_yongyi.HandleYongyiExcelWeekly6(sheet) case "月度计划出栏量": indexList, err = base_from_yongyi.HandleYongyiExcelWeekly7(sheet) case "月度-能繁母猪存栏(2020年2月新增)": indexList, err = base_from_yongyi.HandleYongyiExcelWeekly8(sheet) case "月度-小猪存栏(2020年5月新增)", "月度-中猪存栏(2020年5月新增)", "月度-大猪存栏(2020年5月新增)": indexList, err = base_from_yongyi.HandleYongyiExcelWeekly9(sheet) case "月度-商品猪出栏量": indexList, err = base_from_yongyi.HandleYongyiExcelWeekly10(sheet) default: continue } if err != nil { utils.FileLog.Info(fmt.Sprintf("解析sheet:%s 失败, Err: %s", sheet.Name, err)) continue } if len(indexList) > 0 { params := make(map[string]interface{}) params["List"] = indexList params["TerminalCode"] = terminalCode result, e := PostEdbLib(params, utils.LIB_ROUTE_YONGYI_HANDLE) if e != nil { b, _ := json.Marshal(params) utils.FileLog.Info(fmt.Sprintf("sheet :%s PostEdbLib err: %s, params: %s", sheet.Name, e.Error(), string(b))) return } resp := new(models.BaseEdbLibResponse) if e := json.Unmarshal(result, &resp); e != nil { utils.FileLog.Info(fmt.Sprintf("sheet :%s json.Unmarshal err: %s", sheet.Name, e)) continue } if resp.Ret != 200 { utils.FileLog.Info(fmt.Sprintf("sheet :%s Msg: %s, ErrMsg: %s", sheet.Name, resp.Msg, resp.ErrMsg)) continue } } }*/ return } var ( YongyiDownloadUrl = fmt.Sprintf("%syongyi/download", utils.YongyiDownloadHost) ) // YongyiDownloadDaily // @Description: 调用python服务去涌益咨询官网下载日度excel文件 // @datetime 2023-12-19 09:39:05 func YongyiDownloadDaily(cont context.Context) (err error) { // 2023年12月19日涌益咨询日度数据 now := time.Now() weekday := int(now.Weekday()) if weekday == 0 { weekday = 7 } // 计算与周一的天数差 // 如果当天是周五,差值为0;周六为1,以此类推,直到下个周四为6 offset := (weekday - 5) % 7 // 加7是为了处理weekday为0(周日)的情况 if offset == 1 || offset == 2 { // 获取周一的日期 now = now.AddDate(0, 0, -offset) } filePath := fmt.Sprintf("%s%s", now.Format("2006年1月2日"), "涌益咨询日度数据.xlsx") filePath = filepath.Join(utils.YongyiReadFilePath, filePath) fmt.Println("YongyiDownloadDaily: " + filePath) _, e := os.Stat(filePath) if e == nil { //文件或者目录存在 return } url := fmt.Sprintf("%s?dayFlag=1&weekFlag=0", YongyiDownloadUrl) fmt.Println("YongyiDownload URL:" + url) body, err := HttpGet(url) if err != nil { utils.FileLog.Info("YongyiDownload Err:" + err.Error()) return } utils.FileLog.Debug("YongyiDownload Result:" + string(body)) return } // YongyiDownloadWeekyly // @Description: 调用python服务去涌益咨询官网下载周度excel文件 // @datetime 2023-12-19 09:39:05 func YongyiDownloadWeekyly(cont context.Context) (err error) { // 2023.11.10-2023.11.16涌益咨询 周度数据.xlsx // 获取本周的时间范围, 即当前时间 now := time.Now() weekday := int(now.Weekday()) if weekday == 0 { weekday = 7 } // 计算与周一的天数差 // 如果当天是周五,差值为0;周六为1,以此类推,直到下个周四为6 offset := (weekday - 5) % 7 // 加7是为了处理weekday为0(周日)的情况 // 获取周一的日期 startDateT := now.AddDate(0, 0, -offset) startDate := startDateT.Format("2006.1.2") fmt.Printf("startDate: %s\n", startDate) endDate := startDateT.AddDate(0, 0, 6).Format("2006.1.2") fmt.Printf("endDate: %s\n", endDate) dataFileExsit := false chartFileExist := false fileName := fmt.Sprintf("%s-%s%s", startDate, endDate, "涌益咨询 周度数据.xlsx") filePath := filepath.Join(utils.YongyiReadFilePath, fileName) fmt.Println("YongyiDownloadWeekyly: " + filePath) // 从已处理的表格中查询是否已存在,如果已存在,也无需下载 _, e := os.Stat(filePath) if e == nil { //文件或者目录存在 dataFileExsit = true } else if os.IsNotExist(e) { //文件或者目录不存在 filePath = filepath.Join(utils.YongyiFilePath, fileName) fmt.Println("YongyiDownloadWeekyly: " + filePath) // 从已处理的表格中查询是否已存在,如果已存在,也无需下载 _, e = os.Stat(filePath) if e == nil { //文件或者目录存在 dataFileExsit = true } } filePath = fmt.Sprintf("%s-%s%s", startDate, endDate, "周度图表版图.xlsx") filePath = filepath.Join(utils.YongyiReadFilePath, filePath) fmt.Println("YongyiDownloadWeekyly: " + filePath) _, e = os.Stat(filePath) if e == nil { //文件或者目录存在 chartFileExist = true } else if os.IsNotExist(e) { //文件或者目录不存在 filePath = filepath.Join(utils.YongyiFilePath, fileName) fmt.Println("YongyiDownloadWeekyly: " + filePath) // 从已处理的表格中查询是否已存在,如果已存在,也无需下载 _, e = os.Stat(filePath) if e == nil { //文件或者目录存在 chartFileExist = true } } if dataFileExsit && chartFileExist { return } url := fmt.Sprintf("%s?dayFlag=0&weekFlag=1", YongyiDownloadUrl) fmt.Println("YongyiDownload URL:" + url) body, err := HttpGet(url) if err != nil { utils.FileLog.Info("YongyiDownload Err:" + err.Error()) return } utils.FileLog.Debug("YongyiDownload Result:" + string(body)) return } var HandlezYongyiFilePathMutex sync.Mutex // 监听涌溢咨询文件夹是否有新增的excel文件 func ReadWatchYongyiFile(cont context.Context) (err error) { fmt.Println("ReadWatchYongyiFile start") defer func() { if err != nil { fmt.Println("ReadWatchYongyiFile Err:" + err.Error()) } }() if utils.YongyiFilePath == "" { utils.FileLog.Info("文件目录未配置") return } // 上一个监听未结束时不执行 HandlezYongyiFilePathMutex.Lock() defer HandlezYongyiFilePathMutex.Unlock() err = filepath.Walk(utils.YongyiFilePath, func(path string, info fs.FileInfo, err error) error { if err != nil { err = fmt.Errorf("ReadWatchYongyiFile walk err: %s", err.Error()) return err } if info.IsDir() { return nil } if path == "" { return nil } moveFlag := false //fmt.Println("path", path) if strings.Contains(path, "日度数据") { err = HandleYongyiExcelDailyV2(path) if err == nil { moveFlag = true } // todo 移动文件到新目录下 } else if strings.Contains(path, "周度图表版图") { err = HandleYongyiExcelWeeklyChart(path) if err == nil { moveFlag = true } } else if strings.Contains(path, "周度数据") { err = HandleYongyiExcelWeeklyV2(path) if err == nil { moveFlag = true } } if err != nil { err = fmt.Errorf("file name: %s, handlerYongyi err: %s", path, err.Error()) return err } if moveFlag { // 移动文件至已处理目录 err = utils.CreateDirIfNotExists(utils.YongyiReadFilePath) if err != nil { err = fmt.Errorf("CreateDirIfNotExists err: %s", err.Error()) fmt.Printf("ReadWatchYongyiFile CreateDirIfNotExists err: %s\n", err.Error()) return err } destPath := filepath.Join(utils.YongyiReadFilePath, info.Name()) err = os.Rename(path, destPath) if err != nil { err = fmt.Errorf("file move err: %s", err.Error()) fmt.Printf("ReadWatchYongyiFile file move err: %s\n", err.Error()) return err } } return nil }) return } var YongyiDailyHandlers = map[string]func(f *excelize.File, sheetName string) ([]*models.YongyiExcelIndex, error){ "出栏价": base_from_yongyi_v2.HandleYongyiExcelDaily1, "标肥价差": base_from_yongyi_v2.HandleYongyiExcelDaily2, "价格+宰量": base_from_yongyi_v2.HandleYongyiExcelDaily3, "屠宰企业日度屠宰量": base_from_yongyi_v2.HandleYongyiExcelDaily4, } var YongyiWeeklyHandlers = map[string]func(f *excelize.File, sheetName string) ([]*models.YongyiExcelIndex, error){ "周度-商品猪出栏价": base_from_yongyi_v2.HandleYongyiExcelWeekly1, "周度-体重": base_from_yongyi_v2.HandleYongyiExcelWeekly2, "周度-屠宰厂宰前活猪重": base_from_yongyi_v2.HandleYongyiExcelWeekly3, "周度-各体重段价差": base_from_yongyi_v2.HandleYongyiExcelWeekly4, "周度-50公斤二元母猪价格": base_from_yongyi_v2.HandleYongyiExcelWeekly5, "周度-规模场15公斤仔猪出栏价": base_from_yongyi_v2.HandleYongyiExcelWeekly5, "周度-宰后结算价": base_from_yongyi_v2.HandleYongyiExcelWeekly5, "周度-冻品库存": base_from_yongyi_v2.HandleYongyiExcelWeekly5, "周度-猪肉价(前三等级白条均价)": base_from_yongyi_v2.HandleYongyiExcelWeekly5, "周度-冻品库存多样本": base_from_yongyi_v2.HandleYongyiExcelWeekly6, "月度出栏完成率": base_from_yongyi_v2.HandleYongyiExcelWeekly6, "月度计划出栏量": base_from_yongyi_v2.HandleYongyiExcelWeekly7, "月度-能繁母猪存栏(2020年2月新增)": base_from_yongyi_v2.HandleYongyiExcelWeekly8, "月度-小猪存栏(2020年5月新增)": base_from_yongyi_v2.HandleYongyiExcelWeekly9, "月度-中猪存栏(2020年5月新增)": base_from_yongyi_v2.HandleYongyiExcelWeekly9, "月度-大猪存栏(2020年5月新增)": base_from_yongyi_v2.HandleYongyiExcelWeekly9, "月度-商品猪出栏量": base_from_yongyi_v2.HandleYongyiExcelWeekly10, "历史猪价": base_from_yongyi_v2.HandleYongyiExcelWeekly12, "二育成本": base_from_yongyi_v2.HandleYongyiExcelWeekly13, "二育销量": base_from_yongyi_v2.HandleYongyiExcelWeekly14, "育肥栏舍利用率": base_from_yongyi_v2.HandleYongyiExcelWeekly15, "周度-养殖利润最新": base_from_yongyi_v2.HandleYongyiExcelWeekly16, "周度-当期、预期成本": base_from_yongyi_v2.HandleYongyiExcelWeekly17, "育肥全价料出厂价": base_from_yongyi_v2.HandleYongyiExcelWeekly18, "周度-成本计算附件": base_from_yongyi_v2.HandleYongyiExcelWeekly19, "周度-毛白价差": base_from_yongyi_v2.HandleYongyiExcelWeekly20, "仔猪、母猪": base_from_yongyi_v2.HandleYongyiExcelWeekly21, "周度-河南屠宰白条成本": base_from_yongyi_v2.HandleYongyiExcelWeekly22, "周度-淘汰母猪价格": base_from_yongyi_v2.HandleYongyiExcelWeekly23, //todo 少两个指标,云南和贵州,数据都不符合规范 "鲜销率": base_from_yongyi_v2.HandleYongyiExcelWeekly24, //todo 等待解析(正月初六-二月初四)2022.2.6-3.6 "周度-猪肉产品价格": base_from_yongyi_v2.HandleYongyiExcelWeekly25, "周度-屠宰企业日度屠宰量": base_from_yongyi_v2.HandleYongyiExcelWeekly26, "周度-屠宰新2022.10.28": base_from_yongyi_v2.HandleYongyiExcelWeekly27, "月度-淘汰母猪屠宰厂宰杀量": base_from_yongyi_v2.HandleYongyiExcelWeekly28, "月度-猪料销量": base_from_yongyi_v2.HandleYongyiExcelWeekly29, "月度-屠宰企业开工率": base_from_yongyi_v2.HandleYongyiExcelWeekly30, "月度-屠宰厂公母比例": base_from_yongyi_v2.HandleYongyiExcelWeekly31, "月度-生产指标(2021.5.7新增)": base_from_yongyi_v2.HandleYongyiExcelWeekly32, "月度-生产指标2": base_from_yongyi_v2.HandleYongyiExcelWeekly33, "月度-二元三元能繁比例": base_from_yongyi_v2.HandleYongyiExcelWeekly34, //todo 2019年1-6月 "月度-能繁母猪存栏量": base_from_yongyi_v2.HandleYongyiExcelWeekly35, "月度-原种场二元后备母猪销量及出栏日龄": base_from_yongyi_v2.HandleYongyiExcelWeekly11, "周度-养殖利润": base_from_yongyi_v2.HandleYongyiExcelWeekly37, "华东冻品价格": base_from_yongyi_v2.HandleYongyiExcelWeekly38, "运费": base_from_yongyi_v2.HandleYongyiExcelWeekly39, "国产冻品2-4号肉价格": base_from_yongyi_v2.HandleYongyiExcelWeekly40, "月度-小猪(50公斤以下)存栏": base_from_yongyi_v2.HandleYongyiExcelWeekly41, "月度-中猪(50-80公斤)存栏": base_from_yongyi_v2.HandleYongyiExcelWeekly41, "月度-大猪(80公斤以上)月度存栏": base_from_yongyi_v2.HandleYongyiExcelWeekly41, "月度猪肉供应占比": base_from_yongyi_v2.HandleYongyiExcelWeekly42, "历史出栏体重": base_from_yongyi_v2.HandleYongyiExcelWeekly43, "重要部位冻品进口": base_from_yongyi_v2.HandleYongyiExcelWeekly44, "各存栏规模": base_from_yongyi_v2.HandleYongyiExcelWeekly45, "进口肉": base_from_yongyi_v2.HandleYongyiExcelWeekly46, "猪料原料占比": base_from_yongyi_v2.HandleYongyiExcelWeekly47, "MSY": base_from_yongyi_v2.HandleYongyiExcelWeekly48, } var YongyiWeeklyChartHandlers = map[string]func(f *excelize.File, sheetName string) ([]*models.YongyiExcelIndex, error){ "涌益样本测算": base_from_yongyi_v2.HandleYongyiExcelWeekly36, } func HandleYongyiExcelDailyV2(filePath string) (err error) { //filePath = fmt.Sprintf("/Users/xiexiaoyuan/Downloads/2024年2月2日涌益咨询日度数据.xlsx") defer func() { if err != nil { fmt.Printf("HandleYongyiExcelDailyV2 ErrMsg: %s\n", err.Error()) utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelDailyV2 ErrMsg: %s", err.Error())) } }() _ = path.Base(filePath) f, e := excelize.OpenFile(filePath) if e != nil { err = fmt.Errorf("open file err: %s", e.Error()) return } defer func() { if e = f.Close(); e != nil { err = fmt.Errorf("f close err: %s", e.Error()) } }() terminalCode := utils.TerminalCode for _, sheetName := range f.GetSheetMap() { // 检查是否有对应的处理函数 handler, ok := YongyiDailyHandlers[sheetName] if !ok { continue // 如果没有,则跳过当前sheet } utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelDailyV2 %s start", sheetName)) // 调用处理函数,并处理可能发生的错误 indexList, e := handler(f, sheetName) utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelDailyV2 %s end", sheetName)) if e != nil { utils.FileLog.Info(fmt.Sprintf("解析sheet:%s 失败, Err: %s", sheetName, err)) continue } if len(indexList) > 0 { params := make(map[string]interface{}) params["List"] = indexList params["TerminalCode"] = terminalCode result, e := PostEdbLib(params, utils.LIB_ROUTE_YONGYI_HANDLE) if e != nil { b, _ := json.Marshal(params) utils.FileLog.Info(fmt.Sprintf("sheet :%s PostEdbLib err: %s, params: %s", sheetName, e.Error(), string(b))) continue } resp := new(models.BaseEdbLibResponse) if e := json.Unmarshal(result, &resp); e != nil { utils.FileLog.Info(fmt.Sprintf("sheet :%s json.Unmarshal err: %s", sheetName, e)) continue } if resp.Ret != 200 { utils.FileLog.Info(fmt.Sprintf("sheet :%s Msg: %s, ErrMsg: %s", sheetName, resp.Msg, resp.ErrMsg)) continue } } } return } func HandleYongyiExcelWeeklyV2(filePath string) (err error) { //filePath = fmt.Sprintf("/Users/xiexiaoyuan/Downloads/涌益生猪项目数据库-3/2024.1.26-2024.2.1涌益咨询周度数据.xlsx") defer func() { if err != nil { fmt.Printf("HandleYongyiExcelWeeklyV2 ErrMsg: %s\n", err.Error()) utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeeklyV2 ErrMsg: %s", err.Error())) } }() _ = path.Base(filePath) f, e := excelize.OpenFile(filePath) if e != nil { err = fmt.Errorf("open file err: %s", e.Error()) return } defer func() { if e = f.Close(); e != nil { err = fmt.Errorf("f close err: %s", e.Error()) } }() terminalCode := utils.TerminalCode for _, sheetName := range f.GetSheetMap() { // 检查是否有对应的处理函数 handler, ok := YongyiWeeklyHandlers[sheetName] if !ok { continue // 如果没有,则跳过当前sheet } // 调用处理函数,并处理可能发生的错误 utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeeklyV2 %s start", sheetName)) indexList, e := handler(f, sheetName) utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeeklyV2 %s end", sheetName)) if e != nil { utils.FileLog.Info(fmt.Sprintf("解析sheet:%s 失败, Err: %s", sheetName, err)) continue } if len(indexList) > 0 { params := make(map[string]interface{}) params["List"] = indexList params["TerminalCode"] = terminalCode result, e := PostEdbLib(params, utils.LIB_ROUTE_YONGYI_HANDLE) if e != nil { b, _ := json.Marshal(params) utils.FileLog.Info(fmt.Sprintf("sheet :%s PostEdbLib err: %s, params: %s", sheetName, e.Error(), string(b))) continue } resp := new(models.BaseEdbLibResponse) if e := json.Unmarshal(result, &resp); e != nil { utils.FileLog.Info(fmt.Sprintf("sheet :%s json.Unmarshal err: %s", sheetName, e)) continue } if resp.Ret != 200 { utils.FileLog.Info(fmt.Sprintf("sheet :%s Msg: %s, ErrMsg: %s", sheetName, resp.Msg, resp.ErrMsg)) continue } } } return } func HandleYongyiExcelWeeklyChart(filePath string) (err error) { //filePath = fmt.Sprintf("/Users/xiexiaoyuan/Downloads/涌益生猪项目数据库-3/2024.1.26-2024.2.1周度图表版图.xlsx") defer func() { if err != nil { fmt.Printf("HandleYongyiExcelWeeklyChart ErrMsg: %s\n", err.Error()) utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeeklyChart ErrMsg: %s", err.Error())) } }() _ = path.Base(filePath) f, e := excelize.OpenFile(filePath) if e != nil { err = fmt.Errorf("open file err: %s", e.Error()) return } defer func() { if e = f.Close(); e != nil { err = fmt.Errorf("f close err: %s", e.Error()) } }() terminalCode := utils.TerminalCode for _, sheetName := range f.GetSheetMap() { // 检查是否有对应的处理函数 handler, ok := YongyiWeeklyChartHandlers[sheetName] if !ok { continue // 如果没有,则跳过当前sheet } utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeeklyChart %s start", sheetName)) // 调用处理函数,并处理可能发生的错误 indexList, e := handler(f, sheetName) utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeeklyChart %s end", sheetName)) if e != nil { utils.FileLog.Info(fmt.Sprintf("解析sheet:%s 失败, Err: %s", sheetName, err)) continue } if len(indexList) > 0 { params := make(map[string]interface{}) params["List"] = indexList params["TerminalCode"] = terminalCode result, e := PostEdbLib(params, utils.LIB_ROUTE_YONGYI_HANDLE) if e != nil { b, _ := json.Marshal(params) utils.FileLog.Info(fmt.Sprintf("sheet :%s PostEdbLib err: %s, params: %s", sheetName, e.Error(), string(b))) continue } resp := new(models.BaseEdbLibResponse) if e := json.Unmarshal(result, &resp); e != nil { utils.FileLog.Info(fmt.Sprintf("sheet :%s json.Unmarshal err: %s", sheetName, e)) continue } if resp.Ret != 200 { utils.FileLog.Info(fmt.Sprintf("sheet :%s Msg: %s, ErrMsg: %s", sheetName, resp.Msg, resp.ErrMsg)) continue } } } return }