config.go 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. package utils
  2. import (
  3. "fmt"
  4. beeLogger "github.com/beego/bee/v2/logger"
  5. "github.com/beego/beego/v2/server/web"
  6. "strconv"
  7. )
  8. var (
  9. RunMode string //运行模式
  10. )
  11. // 公共api内部服务调用
  12. var (
  13. // EDB_LIB_URL 公共指标库
  14. EDB_LIB_URL string
  15. APP_EDB_LIB_NAME_EN string
  16. EDB_LIB_Md5_KEY string
  17. OpUserId int // 操作人id
  18. OpUserRealName string // 操作人真实名称
  19. )
  20. // 弘则
  21. const (
  22. APPID = "SJCrpOPvagscPxEv"
  23. SECRET = "gLLjT72uFHQZEFtaFCuoZegD1z2ezfyX"
  24. )
  25. // 日志配置
  26. var (
  27. LogPath string //调用过程中的日志存放地址
  28. LogFile string
  29. BinLogPath string //数据库相关的日志存放地址
  30. BinLogFile string
  31. LogMaxDays int //日志最大保留天数
  32. )
  33. // 涌益生猪
  34. var (
  35. YongyiFilePath string //excel文件地址
  36. YongyiReadFilePath string //已读的excel文件地址
  37. YongyiOpen string //是否配置涌益生猪数据源,1已配置
  38. YongyiDownloadHost string
  39. )
  40. // 中国煤炭网
  41. var (
  42. CoalMineFilePath string //excel文件地址
  43. CoalMineOpen string //是否配置中国煤炭网数据源,1已配置
  44. CoalMailAttachmentScriptPath string // 获取邮件附件的脚本目录
  45. CoalMailAttachmentOpen string // 获取邮件附件功能,1已配置
  46. CoalMailAttachmentTime string // 获取邮件附件功能时间
  47. CoalMailAttachmentPythonVersion string // 获取邮件附件功能python版本
  48. )
  49. // 汾渭煤炭
  50. var (
  51. FenweiFileDir string // excel文件目录
  52. FenweiOldFileDir string // 已读取过的excel文件目录
  53. FenweiOpen string // 是否配置汾渭数据源
  54. FenweiNetOpen string // 是否配置汾渭网页数据源
  55. FenweiNetUseName string // 汾渭登录账号
  56. FenweiNetPassword string // 汾渭登录密码
  57. FenweiNetJsonPath string // 汾渭json文件地址
  58. )
  59. // 煤炭江湖
  60. var (
  61. MtjhFilePath string //excel文件地址
  62. MtjhOpen string //是否配置煤炭江湖数据源,1已配置
  63. )
  64. // 粮油商务网
  65. var (
  66. LY_USERNAME string
  67. LY_PASSWORD string
  68. LY_JSON_PATH string
  69. LY_OPEN string
  70. )
  71. // CCF化纤信息
  72. var (
  73. CCFOpen string // 是否配置CCF
  74. CCFCookieFile string // CCF登录Cookie
  75. CCFDataRuleFile string // CCF数据爬取规则
  76. CCFDailyTaskTime string // CCF数据日度任务时间
  77. CCFWeeklyTaskTime string // CCF数据周度任务时间
  78. CCFStockTaskTime string // CCF数据装置任务时间
  79. CCFUseName string // CCF登录账号
  80. CCFPassword string // CCF登录密码
  81. CCFDailyFetchNum int // CCF数据日度每次获取报告数量
  82. CCFWeeklyFetchNum int // CCF数据周度每次获取报告数量
  83. CCFStockFetchNum int // CCF数据装置每次获取报告数量
  84. )
  85. var (
  86. OilchemAccount string
  87. OilchemPassword string
  88. OilchemCookieFile string
  89. OilchemOpen string
  90. OilchemDataInit string
  91. )
  92. var TerminalCode string
  93. func init() {
  94. tmpRunMode, err := web.AppConfig.String("run_mode")
  95. if err != nil {
  96. panic("配置文件读取run_mode错误 " + err.Error())
  97. }
  98. RunMode = tmpRunMode
  99. fmt.Println("RunMode:", RunMode)
  100. config, err := web.AppConfig.GetSection(RunMode)
  101. if err != nil {
  102. panic("配置文件读取错误 " + err.Error())
  103. }
  104. beeLogger.Log.Info(RunMode + " 模式")
  105. // 公共api内部服务调用
  106. {
  107. // 公共指标库相关
  108. EDB_LIB_URL = config["edb_lib_url"]
  109. APP_EDB_LIB_NAME_EN = config["app_edb_lib_name_en"]
  110. EDB_LIB_Md5_KEY = config["edb_lib_md5_key"]
  111. opUserIdStr := config["op_user_id"]
  112. if opUserIdStr != `` {
  113. OpUserId, err = strconv.Atoi(opUserIdStr)
  114. if err != nil {
  115. panic("配置文件中操作人配置错误 " + err.Error())
  116. }
  117. }
  118. OpUserRealName = config["op_user_real_name"]
  119. }
  120. //日志配置
  121. {
  122. LogPath = config["log_path"]
  123. LogFile = config["log_file"]
  124. BinLogPath = config["binlog_path"]
  125. BinLogFile = config["binlog_file"]
  126. logMaxDaysStr := config["log_max_day"]
  127. LogMaxDays, _ = strconv.Atoi(logMaxDaysStr)
  128. }
  129. //涌益咨询文件夹配置
  130. {
  131. YongyiFilePath = config["yongyi_file_path"]
  132. YongyiReadFilePath = config["yongyi_read_file_path"]
  133. YongyiOpen = config["yongyi_open"]
  134. YongyiDownloadHost = config["yongyi_download_host"]
  135. if YongyiDownloadHost == "" {
  136. YongyiDownloadHost = "http://127.0.0.1:7010/"
  137. }
  138. }
  139. //中国煤炭网文件夹配置
  140. {
  141. CoalMineFilePath = config["coal_mine_file_path"]
  142. CoalMineOpen = config["coal_mine_open"]
  143. CoalMailAttachmentScriptPath = config["coal_mail_attachment_script_path"]
  144. CoalMailAttachmentOpen = config["coal_mail_attachment_open"]
  145. CoalMailAttachmentTime = config["coal_mail_attachment_time"]
  146. CoalMailAttachmentPythonVersion = config["coal_mail_attachment_python_version"]
  147. }
  148. // 汾渭配置
  149. {
  150. FenweiOpen = config["fenwei_open"]
  151. FenweiFileDir = config["fenwei_file_dir"]
  152. FenweiOldFileDir = config["fenwei_old_file_dir"]
  153. FenweiNetOpen = config["fenwei_net_open"]
  154. FenweiNetUseName = config["fenwei_net_username"]
  155. FenweiNetPassword = config["fenwei_net_password"]
  156. FenweiNetJsonPath = config["fenwei_net_json_path"]
  157. }
  158. //煤炭江湖文件夹配置
  159. {
  160. MtjhFilePath = config["mtjh_file_path"]
  161. MtjhOpen = config["mtjh_open"]
  162. }
  163. TerminalCode = config["terminal_code"]
  164. // CCF化纤信息
  165. {
  166. CCFOpen = config["ccf_open"]
  167. CCFCookieFile = config["ccf_cookie_file"]
  168. CCFDataRuleFile = config["ccf_data_rule_file"]
  169. CCFDailyTaskTime = config["ccf_daily_task_time"]
  170. CCFWeeklyTaskTime = config["ccf_weekly_task_time"]
  171. CCFStockTaskTime = config["ccf_stock_task_time"]
  172. CCFUseName = config["ccf_username"]
  173. CCFPassword = config["ccf_password"]
  174. CCFDailyFetchNum, _ = strconv.Atoi(config["ccf_daily_fetch_num"])
  175. if CCFDailyFetchNum <= 0 {
  176. CCFDailyFetchNum = 7
  177. }
  178. CCFWeeklyFetchNum, _ = strconv.Atoi(config["ccf_weekly_fetch_num"])
  179. if CCFWeeklyFetchNum <= 0 {
  180. CCFWeeklyFetchNum = 3
  181. }
  182. CCFStockFetchNum, _ = strconv.Atoi(config["ccf_stock_fetch_num"])
  183. if CCFStockFetchNum <= 0 {
  184. CCFStockFetchNum = 3
  185. }
  186. }
  187. {
  188. LY_USERNAME = config["ly_username"]
  189. LY_PASSWORD = config["ly_password"]
  190. LY_JSON_PATH = config["ly_json_path"]
  191. LY_OPEN = config["ly_open"]
  192. }
  193. // 隆众数据
  194. {
  195. OilchemAccount = config["oilchem_account"]
  196. OilchemPassword = config["oilchem_password"]
  197. OilchemCookieFile = config["oilchem_cookie_file"]
  198. OilchemOpen = config["oilchem_open"]
  199. OilchemDataInit = config["oilchem_data_init"]
  200. }
  201. }
  202. //修改接口文档
  203. //http://8.136.199.33:8300/swagger/