config.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. )
  55. // 煤炭江湖
  56. var (
  57. MtjhFilePath string //excel文件地址
  58. MtjhOpen string //是否配置煤炭江湖数据源,1已配置
  59. )
  60. // CCF化纤信息
  61. var (
  62. CCFOpen string // 是否配置CCF
  63. CCFCookieFile string // CCF登录Cookie
  64. CCFDataRuleFile string // CCF数据爬取规则
  65. CCFDailyTaskTime string // CCF数据日度任务时间
  66. CCFWeeklyTaskTime string // CCF数据周度任务时间
  67. CCFStockTaskTime string // CCF数据装置任务时间
  68. CCFUseName string // CCF登录账号
  69. CCFPassword string // CCF登录密码
  70. )
  71. var (
  72. OilchemAccount string
  73. OilchemPassword string
  74. OilchemCookieFile string
  75. OilchemOpen string
  76. OilchemDataInit string
  77. )
  78. var TerminalCode string
  79. func init() {
  80. tmpRunMode, err := web.AppConfig.String("run_mode")
  81. if err != nil {
  82. panic("配置文件读取run_mode错误 " + err.Error())
  83. }
  84. RunMode = tmpRunMode
  85. fmt.Println("RunMode:", RunMode)
  86. config, err := web.AppConfig.GetSection(RunMode)
  87. if err != nil {
  88. panic("配置文件读取错误 " + err.Error())
  89. }
  90. beeLogger.Log.Info(RunMode + " 模式")
  91. // 公共api内部服务调用
  92. {
  93. // 公共指标库相关
  94. EDB_LIB_URL = config["edb_lib_url"]
  95. APP_EDB_LIB_NAME_EN = config["app_edb_lib_name_en"]
  96. EDB_LIB_Md5_KEY = config["edb_lib_md5_key"]
  97. opUserIdStr := config["op_user_id"]
  98. if opUserIdStr != `` {
  99. OpUserId, err = strconv.Atoi(opUserIdStr)
  100. if err != nil {
  101. panic("配置文件中操作人配置错误 " + err.Error())
  102. }
  103. }
  104. OpUserRealName = config["op_user_real_name"]
  105. }
  106. //日志配置
  107. {
  108. LogPath = config["log_path"]
  109. LogFile = config["log_file"]
  110. BinLogPath = config["binlog_path"]
  111. BinLogFile = config["binlog_file"]
  112. logMaxDaysStr := config["log_max_day"]
  113. LogMaxDays, _ = strconv.Atoi(logMaxDaysStr)
  114. }
  115. //涌益咨询文件夹配置
  116. {
  117. YongyiFilePath = config["yongyi_file_path"]
  118. YongyiReadFilePath = config["yongyi_read_file_path"]
  119. YongyiOpen = config["yongyi_open"]
  120. YongyiDownloadHost = config["yongyi_download_host"]
  121. if YongyiDownloadHost == "" {
  122. YongyiDownloadHost = "http://127.0.0.1:7010/"
  123. }
  124. }
  125. //中国煤炭网文件夹配置
  126. {
  127. CoalMineFilePath = config["coal_mine_file_path"]
  128. CoalMineOpen = config["coal_mine_open"]
  129. CoalMailAttachmentScriptPath = config["coal_mail_attachment_script_path"]
  130. CoalMailAttachmentOpen = config["coal_mail_attachment_open"]
  131. CoalMailAttachmentTime = config["coal_mail_attachment_time"]
  132. CoalMailAttachmentPythonVersion = config["coal_mail_attachment_python_version"]
  133. }
  134. // 汾渭配置
  135. {
  136. FenweiOpen = config["fenwei_open"]
  137. FenweiFileDir = config["fenwei_file_dir"]
  138. FenweiOldFileDir = config["fenwei_old_file_dir"]
  139. }
  140. //煤炭江湖文件夹配置
  141. {
  142. MtjhFilePath = config["mtjh_file_path"]
  143. MtjhOpen = config["mtjh_open"]
  144. }
  145. TerminalCode = config["terminal_code"]
  146. // CCF化纤信息
  147. {
  148. CCFOpen = config["ccf_open"]
  149. CCFCookieFile = config["ccf_cookie_file"]
  150. CCFDataRuleFile = config["ccf_data_rule_file"]
  151. CCFDailyTaskTime = config["ccf_daily_task_time"]
  152. CCFWeeklyTaskTime = config["ccf_weekly_task_time"]
  153. CCFStockTaskTime = config["ccf_stock_task_time"]
  154. CCFUseName = config["ccf_username"]
  155. CCFPassword = config["ccf_password"]
  156. }
  157. // 隆众数据
  158. {
  159. OilchemAccount = config["oilchem_account"]
  160. OilchemPassword = config["oilchem_password"]
  161. OilchemCookieFile = config["oilchem_cookie_file"]
  162. OilchemOpen = config["oilchem_open"]
  163. OilchemDataInit = config["oilchem_data_init"]
  164. }
  165. }
  166. //修改接口文档
  167. //http://8.136.199.33:8300/swagger/