config.go 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. package utils
  2. import (
  3. "fmt"
  4. "strconv"
  5. beeLogger "github.com/beego/bee/v2/logger"
  6. "github.com/beego/beego/v2/server/web"
  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. // 睿姿得数据
  72. var (
  73. RZD_USERNAME string
  74. RZD_PASSWORD string
  75. RZD_EXCEL_PATH string
  76. RZD_OPEN string
  77. RZD_DOWNLOAD_PATH string
  78. )
  79. // CCF化纤信息
  80. var (
  81. CCFOpen string // 是否配置CCF
  82. CCFCookieFile string // CCF登录Cookie
  83. CCFDataRuleFile string // CCF数据爬取规则
  84. CCFDailyTaskTime string // CCF数据日度任务时间
  85. CCFWeeklyTaskTime string // CCF数据周度任务时间
  86. CCFStockTaskTime string // CCF数据装置任务时间
  87. CCFUseName string // CCF登录账号
  88. CCFPassword string // CCF登录密码
  89. CCFDailyFetchNum int // CCF数据日度每次获取报告数量
  90. CCFWeeklyFetchNum int // CCF数据周度每次获取报告数量
  91. CCFStockFetchNum int // CCF数据装置每次获取报告数量
  92. CCFChartRuleFile string // CCF图表爬取规则
  93. CCFChartAdditionRuleFile string // CCF图表爬取附加规则
  94. CCFChartTaskTime string
  95. )
  96. var (
  97. OilchemAccount string
  98. OilchemPassword string
  99. OilchemCookieFile string
  100. OilchemOpen string
  101. OilchemDataInit string
  102. )
  103. var (
  104. HisugarAccount string
  105. HisugarPassword string
  106. HisugarOpen string
  107. )
  108. var TerminalCode string
  109. // 克拉克森
  110. var (
  111. ClarkSonsFilePath string //excel文件地址
  112. ClarkSonsOpen string //是否配置克拉克森数据源,1已配置
  113. )
  114. func init() {
  115. tmpRunMode, err := web.AppConfig.String("run_mode")
  116. if err != nil {
  117. panic("配置文件读取run_mode错误 " + err.Error())
  118. }
  119. RunMode = tmpRunMode
  120. fmt.Println("RunMode:", RunMode)
  121. config, err := web.AppConfig.GetSection(RunMode)
  122. if err != nil {
  123. panic("配置文件读取错误 " + err.Error())
  124. }
  125. beeLogger.Log.Info(RunMode + " 模式")
  126. // 公共api内部服务调用
  127. {
  128. // 公共指标库相关
  129. EDB_LIB_URL = config["edb_lib_url"]
  130. APP_EDB_LIB_NAME_EN = config["app_edb_lib_name_en"]
  131. EDB_LIB_Md5_KEY = config["edb_lib_md5_key"]
  132. opUserIdStr := config["op_user_id"]
  133. if opUserIdStr != `` {
  134. OpUserId, err = strconv.Atoi(opUserIdStr)
  135. if err != nil {
  136. panic("配置文件中操作人配置错误 " + err.Error())
  137. }
  138. }
  139. OpUserRealName = config["op_user_real_name"]
  140. }
  141. //日志配置
  142. {
  143. LogPath = config["log_path"]
  144. LogFile = config["log_file"]
  145. BinLogPath = config["binlog_path"]
  146. BinLogFile = config["binlog_file"]
  147. logMaxDaysStr := config["log_max_day"]
  148. LogMaxDays, _ = strconv.Atoi(logMaxDaysStr)
  149. }
  150. //涌益咨询文件夹配置
  151. {
  152. YongyiFilePath = config["yongyi_file_path"]
  153. YongyiReadFilePath = config["yongyi_read_file_path"]
  154. YongyiOpen = config["yongyi_open"]
  155. YongyiDownloadHost = config["yongyi_download_host"]
  156. if YongyiDownloadHost == "" {
  157. YongyiDownloadHost = "http://127.0.0.1:7010/"
  158. }
  159. }
  160. //中国煤炭网文件夹配置
  161. {
  162. CoalMineFilePath = config["coal_mine_file_path"]
  163. CoalMineOpen = config["coal_mine_open"]
  164. CoalMailAttachmentScriptPath = config["coal_mail_attachment_script_path"]
  165. CoalMailAttachmentOpen = config["coal_mail_attachment_open"]
  166. CoalMailAttachmentTime = config["coal_mail_attachment_time"]
  167. CoalMailAttachmentPythonVersion = config["coal_mail_attachment_python_version"]
  168. }
  169. // 汾渭配置
  170. {
  171. FenweiOpen = config["fenwei_open"]
  172. FenweiFileDir = config["fenwei_file_dir"]
  173. FenweiOldFileDir = config["fenwei_old_file_dir"]
  174. FenweiNetOpen = config["fenwei_net_open"]
  175. FenweiNetUseName = config["fenwei_net_username"]
  176. FenweiNetPassword = config["fenwei_net_password"]
  177. FenweiNetJsonPath = config["fenwei_net_json_path"]
  178. }
  179. //煤炭江湖文件夹配置
  180. {
  181. MtjhFilePath = config["mtjh_file_path"]
  182. MtjhOpen = config["mtjh_open"]
  183. }
  184. TerminalCode = config["terminal_code"]
  185. // CCF化纤信息
  186. {
  187. CCFOpen = config["ccf_open"]
  188. CCFCookieFile = config["ccf_cookie_file"]
  189. CCFDataRuleFile = config["ccf_data_rule_file"]
  190. CCFDailyTaskTime = config["ccf_daily_task_time"]
  191. CCFWeeklyTaskTime = config["ccf_weekly_task_time"]
  192. CCFStockTaskTime = config["ccf_stock_task_time"]
  193. CCFUseName = config["ccf_username"]
  194. CCFPassword = config["ccf_password"]
  195. CCFDailyFetchNum, _ = strconv.Atoi(config["ccf_daily_fetch_num"])
  196. if CCFDailyFetchNum <= 0 {
  197. CCFDailyFetchNum = 7
  198. }
  199. CCFWeeklyFetchNum, _ = strconv.Atoi(config["ccf_weekly_fetch_num"])
  200. if CCFWeeklyFetchNum <= 0 {
  201. CCFWeeklyFetchNum = 3
  202. }
  203. CCFStockFetchNum, _ = strconv.Atoi(config["ccf_stock_fetch_num"])
  204. if CCFStockFetchNum <= 0 {
  205. CCFStockFetchNum = 3
  206. }
  207. CCFChartRuleFile = config["ccf_chart_rule_file"]
  208. if CCFChartRuleFile == "" {
  209. CCFChartRuleFile = "static/ccf_chart_rule.json"
  210. }
  211. if CCFChartAdditionRuleFile == "" {
  212. CCFChartAdditionRuleFile = "static/ccf_chart_addition_rule.json"
  213. }
  214. CCFChartTaskTime = config["ccf_chart_task_time"]
  215. }
  216. {
  217. LY_USERNAME = config["ly_username"]
  218. LY_PASSWORD = config["ly_password"]
  219. LY_JSON_PATH = config["ly_json_path"]
  220. LY_OPEN = config["ly_open"]
  221. }
  222. {
  223. RZD_USERNAME = config["rzd_username"]
  224. RZD_PASSWORD = config["rzd_password"]
  225. RZD_EXCEL_PATH = config["rzd_excel_path"]
  226. RZD_OPEN = config["rzd_open"]
  227. RZD_DOWNLOAD_PATH = config["rzd_download_path"]
  228. }
  229. // 隆众数据
  230. {
  231. OilchemAccount = config["oilchem_account"]
  232. OilchemPassword = config["oilchem_password"]
  233. OilchemCookieFile = config["oilchem_cookie_file"]
  234. OilchemOpen = config["oilchem_open"]
  235. OilchemDataInit = config["oilchem_data_init"]
  236. }
  237. // 泛糖科技
  238. {
  239. HisugarAccount = config["hisugar_account"]
  240. HisugarPassword = config["hisugar_password"]
  241. HisugarOpen = config["hisugar_open"]
  242. }
  243. //克拉克森文件夹配置
  244. {
  245. ClarkSonsFilePath = config["clarksons_file_path"]
  246. ClarkSonsOpen = config["clarksons_open"]
  247. }
  248. }
  249. //修改接口文档
  250. //http://8.136.199.33:8300/swagger/