123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- package utils
- import (
- "fmt"
- beeLogger "github.com/beego/bee/v2/logger"
- "github.com/beego/beego/v2/server/web"
- "strconv"
- )
- var (
- RunMode string //运行模式
- )
- // 公共api内部服务调用
- var (
- // EDB_LIB_URL 公共指标库
- EDB_LIB_URL string
- APP_EDB_LIB_NAME_EN string
- EDB_LIB_Md5_KEY string
- OpUserId int // 操作人id
- OpUserRealName string // 操作人真实名称
- )
- // 弘则
- const (
- APPID = "SJCrpOPvagscPxEv"
- SECRET = "gLLjT72uFHQZEFtaFCuoZegD1z2ezfyX"
- )
- // 日志配置
- var (
- LogPath string //调用过程中的日志存放地址
- LogFile string
- BinLogPath string //数据库相关的日志存放地址
- BinLogFile string
- LogMaxDays int //日志最大保留天数
- )
- // 涌益生猪
- var (
- YongyiFilePath string //excel文件地址
- YongyiReadFilePath string //已读的excel文件地址
- YongyiOpen string //是否配置涌益生猪数据源,1已配置
- YongyiDownloadHost string
- )
- // 中国煤炭网
- var (
- CoalMineFilePath string //excel文件地址
- CoalMineOpen string //是否配置中国煤炭网数据源,1已配置
- CoalMailAttachmentScriptPath string // 获取邮件附件的脚本目录
- CoalMailAttachmentOpen string // 获取邮件附件功能,1已配置
- CoalMailAttachmentTime string // 获取邮件附件功能时间
- CoalMailAttachmentPythonVersion string // 获取邮件附件功能python版本
- )
- // 汾渭煤炭
- var (
- FenweiFileDir string // excel文件目录
- FenweiOldFileDir string // 已读取过的excel文件目录
- FenweiOpen string // 是否配置汾渭数据源
- FenweiNetOpen string // 是否配置汾渭网页数据源
- FenweiNetUseName string // 汾渭登录账号
- FenweiNetPassword string // 汾渭登录密码
- FenweiNetJsonPath string // 汾渭json文件地址
- )
- // 煤炭江湖
- var (
- MtjhFilePath string //excel文件地址
- MtjhOpen string //是否配置煤炭江湖数据源,1已配置
- )
- // 粮油商务网
- var (
- LY_USERNAME string
- LY_PASSWORD string
- LY_JSON_PATH string
- LY_OPEN string
- )
- // CCF化纤信息
- var (
- CCFOpen string // 是否配置CCF
- CCFCookieFile string // CCF登录Cookie
- CCFDataRuleFile string // CCF数据爬取规则
- CCFDailyTaskTime string // CCF数据日度任务时间
- CCFWeeklyTaskTime string // CCF数据周度任务时间
- CCFStockTaskTime string // CCF数据装置任务时间
- CCFUseName string // CCF登录账号
- CCFPassword string // CCF登录密码
- CCFDailyFetchNum int // CCF数据日度每次获取报告数量
- CCFWeeklyFetchNum int // CCF数据周度每次获取报告数量
- CCFStockFetchNum int // CCF数据装置每次获取报告数量
- )
- var (
- OilchemAccount string
- OilchemPassword string
- OilchemCookieFile string
- OilchemOpen string
- OilchemDataInit string
- )
- var TerminalCode string
- func init() {
- tmpRunMode, err := web.AppConfig.String("run_mode")
- if err != nil {
- panic("配置文件读取run_mode错误 " + err.Error())
- }
- RunMode = tmpRunMode
- fmt.Println("RunMode:", RunMode)
- config, err := web.AppConfig.GetSection(RunMode)
- if err != nil {
- panic("配置文件读取错误 " + err.Error())
- }
- beeLogger.Log.Info(RunMode + " 模式")
- // 公共api内部服务调用
- {
- // 公共指标库相关
- EDB_LIB_URL = config["edb_lib_url"]
- APP_EDB_LIB_NAME_EN = config["app_edb_lib_name_en"]
- EDB_LIB_Md5_KEY = config["edb_lib_md5_key"]
- opUserIdStr := config["op_user_id"]
- if opUserIdStr != `` {
- OpUserId, err = strconv.Atoi(opUserIdStr)
- if err != nil {
- panic("配置文件中操作人配置错误 " + err.Error())
- }
- }
- OpUserRealName = config["op_user_real_name"]
- }
- //日志配置
- {
- LogPath = config["log_path"]
- LogFile = config["log_file"]
- BinLogPath = config["binlog_path"]
- BinLogFile = config["binlog_file"]
- logMaxDaysStr := config["log_max_day"]
- LogMaxDays, _ = strconv.Atoi(logMaxDaysStr)
- }
- //涌益咨询文件夹配置
- {
- YongyiFilePath = config["yongyi_file_path"]
- YongyiReadFilePath = config["yongyi_read_file_path"]
- YongyiOpen = config["yongyi_open"]
- YongyiDownloadHost = config["yongyi_download_host"]
- if YongyiDownloadHost == "" {
- YongyiDownloadHost = "http://127.0.0.1:7010/"
- }
- }
- //中国煤炭网文件夹配置
- {
- CoalMineFilePath = config["coal_mine_file_path"]
- CoalMineOpen = config["coal_mine_open"]
- CoalMailAttachmentScriptPath = config["coal_mail_attachment_script_path"]
- CoalMailAttachmentOpen = config["coal_mail_attachment_open"]
- CoalMailAttachmentTime = config["coal_mail_attachment_time"]
- CoalMailAttachmentPythonVersion = config["coal_mail_attachment_python_version"]
- }
- // 汾渭配置
- {
- FenweiOpen = config["fenwei_open"]
- FenweiFileDir = config["fenwei_file_dir"]
- FenweiOldFileDir = config["fenwei_old_file_dir"]
- FenweiNetOpen = config["fenwei_net_open"]
- FenweiNetUseName = config["fenwei_net_username"]
- FenweiNetPassword = config["fenwei_net_password"]
- FenweiNetJsonPath = config["fenwei_net_json_path"]
- }
- //煤炭江湖文件夹配置
- {
- MtjhFilePath = config["mtjh_file_path"]
- MtjhOpen = config["mtjh_open"]
- }
- TerminalCode = config["terminal_code"]
- // CCF化纤信息
- {
- CCFOpen = config["ccf_open"]
- CCFCookieFile = config["ccf_cookie_file"]
- CCFDataRuleFile = config["ccf_data_rule_file"]
- CCFDailyTaskTime = config["ccf_daily_task_time"]
- CCFWeeklyTaskTime = config["ccf_weekly_task_time"]
- CCFStockTaskTime = config["ccf_stock_task_time"]
- CCFUseName = config["ccf_username"]
- CCFPassword = config["ccf_password"]
- CCFDailyFetchNum, _ = strconv.Atoi(config["ccf_daily_fetch_num"])
- if CCFDailyFetchNum <= 0 {
- CCFDailyFetchNum = 7
- }
- CCFWeeklyFetchNum, _ = strconv.Atoi(config["ccf_weekly_fetch_num"])
- if CCFWeeklyFetchNum <= 0 {
- CCFWeeklyFetchNum = 3
- }
- CCFStockFetchNum, _ = strconv.Atoi(config["ccf_stock_fetch_num"])
- if CCFStockFetchNum <= 0 {
- CCFStockFetchNum = 3
- }
- }
- {
- LY_USERNAME = config["ly_username"]
- LY_PASSWORD = config["ly_password"]
- LY_JSON_PATH = config["ly_json_path"]
- LY_OPEN = config["ly_open"]
- }
- // 隆众数据
- {
- OilchemAccount = config["oilchem_account"]
- OilchemPassword = config["oilchem_password"]
- OilchemCookieFile = config["oilchem_cookie_file"]
- OilchemOpen = config["oilchem_open"]
- OilchemDataInit = config["oilchem_data_init"]
- }
- }
- //修改接口文档
- //http://8.136.199.33:8300/swagger/
|