config.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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_TASK_TIME string
  74. RZD_USERNAME string
  75. RZD_PASSWORD string
  76. RZD_EXCEL_PATH string
  77. RZD_OPEN string
  78. RZD_DOWNLOAD_PATH string
  79. RZD_LOGIN_PATH string
  80. )
  81. // CCF化纤信息
  82. var (
  83. CCFOpen string // 是否配置CCF
  84. CCFCookieFile string // CCF登录Cookie
  85. CCFDataRuleFile string // CCF数据爬取规则
  86. CCFDailyTaskTime string // CCF数据日度任务时间
  87. CCFWeeklyTaskTime string // CCF数据周度任务时间
  88. CCFStockTaskTime string // CCF数据装置任务时间
  89. CCFUseName string // CCF登录账号
  90. CCFPassword string // CCF登录密码
  91. CCFDailyFetchNum int // CCF数据日度每次获取报告数量
  92. CCFWeeklyFetchNum int // CCF数据周度每次获取报告数量
  93. CCFStockFetchNum int // CCF数据装置每次获取报告数量
  94. CCFChartRuleFile string // CCF图表爬取规则
  95. CCFChartAdditionRuleFile string // CCF图表爬取附加规则
  96. CCFChartTaskTime string
  97. )
  98. var (
  99. OilchemAccount string
  100. OilchemPassword string
  101. OilchemCookieFile string
  102. OilchemOpen string
  103. OilchemDataInit string
  104. )
  105. var (
  106. HisugarAccount string
  107. HisugarPassword string
  108. HisugarOpen string
  109. )
  110. var TerminalCode string
  111. // 克拉克森
  112. var (
  113. ClarkSonsFilePath string //excel文件地址
  114. ClarkSonsOpen string //是否配置克拉克森数据源,1已配置
  115. )
  116. // minio配置
  117. var (
  118. MinIoAccessKeyId string
  119. MinIoAccessKeySecret string
  120. MinIoEndpoint string
  121. MinIoUseSSL string
  122. MinIoBucketName string
  123. MinIoUploadDir string
  124. MinIoViewHost string
  125. ChromePath string
  126. CommandPython string
  127. OssType string
  128. )
  129. // S3配置
  130. var (
  131. S3Endpoint string
  132. S3BackEndpoint string
  133. S3BucketName string
  134. S3UploadDir string
  135. S3AccessKeyId string
  136. S3AccessKeySecret string
  137. S3Host string
  138. S3Region string
  139. S3ForceStyle string
  140. S3EndpointPort string
  141. S3Protocol string
  142. S3DisableSSL string
  143. S3OpenAcl string
  144. )
  145. // 阿里云配置
  146. var (
  147. Bucketname string
  148. Endpoint string
  149. Imghost string
  150. UploadDir string
  151. Upload_Audio_Dir string
  152. AccessKeyId string
  153. AccessKeySecret string
  154. )
  155. func init() {
  156. tmpRunMode, err := web.AppConfig.String("run_mode")
  157. if err != nil {
  158. panic("配置文件读取run_mode错误 " + err.Error())
  159. }
  160. RunMode = tmpRunMode
  161. fmt.Println("RunMode:", RunMode)
  162. config, err := web.AppConfig.GetSection(RunMode)
  163. if err != nil {
  164. panic("配置文件读取错误 " + err.Error())
  165. }
  166. beeLogger.Log.Info(RunMode + " 模式")
  167. // 公共api内部服务调用
  168. {
  169. // 公共指标库相关
  170. EDB_LIB_URL = config["edb_lib_url"]
  171. APP_EDB_LIB_NAME_EN = config["app_edb_lib_name_en"]
  172. EDB_LIB_Md5_KEY = config["edb_lib_md5_key"]
  173. opUserIdStr := config["op_user_id"]
  174. if opUserIdStr != `` {
  175. OpUserId, err = strconv.Atoi(opUserIdStr)
  176. if err != nil {
  177. panic("配置文件中操作人配置错误 " + err.Error())
  178. }
  179. }
  180. OpUserRealName = config["op_user_real_name"]
  181. }
  182. //日志配置
  183. {
  184. LogPath = config["log_path"]
  185. LogFile = config["log_file"]
  186. BinLogPath = config["binlog_path"]
  187. BinLogFile = config["binlog_file"]
  188. logMaxDaysStr := config["log_max_day"]
  189. LogMaxDays, _ = strconv.Atoi(logMaxDaysStr)
  190. }
  191. //涌益咨询文件夹配置
  192. {
  193. YongyiFilePath = config["yongyi_file_path"]
  194. YongyiReadFilePath = config["yongyi_read_file_path"]
  195. YongyiOpen = config["yongyi_open"]
  196. YongyiDownloadHost = config["yongyi_download_host"]
  197. if YongyiDownloadHost == "" {
  198. YongyiDownloadHost = "http://127.0.0.1:7010/"
  199. }
  200. }
  201. //中国煤炭网文件夹配置
  202. {
  203. CoalMineFilePath = config["coal_mine_file_path"]
  204. CoalMineOpen = config["coal_mine_open"]
  205. CoalMailAttachmentScriptPath = config["coal_mail_attachment_script_path"]
  206. CoalMailAttachmentOpen = config["coal_mail_attachment_open"]
  207. CoalMailAttachmentTime = config["coal_mail_attachment_time"]
  208. CoalMailAttachmentPythonVersion = config["coal_mail_attachment_python_version"]
  209. }
  210. // 汾渭配置
  211. {
  212. FenweiOpen = config["fenwei_open"]
  213. FenweiFileDir = config["fenwei_file_dir"]
  214. FenweiOldFileDir = config["fenwei_old_file_dir"]
  215. FenweiNetOpen = config["fenwei_net_open"]
  216. FenweiNetUseName = config["fenwei_net_username"]
  217. FenweiNetPassword = config["fenwei_net_password"]
  218. FenweiNetJsonPath = config["fenwei_net_json_path"]
  219. }
  220. //煤炭江湖文件夹配置
  221. {
  222. MtjhFilePath = config["mtjh_file_path"]
  223. MtjhOpen = config["mtjh_open"]
  224. }
  225. TerminalCode = config["terminal_code"]
  226. // CCF化纤信息
  227. {
  228. CCFOpen = config["ccf_open"]
  229. CCFCookieFile = config["ccf_cookie_file"]
  230. CCFDataRuleFile = config["ccf_data_rule_file"]
  231. CCFDailyTaskTime = config["ccf_daily_task_time"]
  232. CCFWeeklyTaskTime = config["ccf_weekly_task_time"]
  233. CCFStockTaskTime = config["ccf_stock_task_time"]
  234. CCFUseName = config["ccf_username"]
  235. CCFPassword = config["ccf_password"]
  236. CCFDailyFetchNum, _ = strconv.Atoi(config["ccf_daily_fetch_num"])
  237. if CCFDailyFetchNum <= 0 {
  238. CCFDailyFetchNum = 7
  239. }
  240. CCFWeeklyFetchNum, _ = strconv.Atoi(config["ccf_weekly_fetch_num"])
  241. if CCFWeeklyFetchNum <= 0 {
  242. CCFWeeklyFetchNum = 3
  243. }
  244. CCFStockFetchNum, _ = strconv.Atoi(config["ccf_stock_fetch_num"])
  245. if CCFStockFetchNum <= 0 {
  246. CCFStockFetchNum = 3
  247. }
  248. CCFChartRuleFile = config["ccf_chart_rule_file"]
  249. if CCFChartRuleFile == "" {
  250. CCFChartRuleFile = "static/ccf_chart_rule.json"
  251. }
  252. if CCFChartAdditionRuleFile == "" {
  253. CCFChartAdditionRuleFile = "static/ccf_chart_addition_rule.json"
  254. }
  255. CCFChartTaskTime = config["ccf_chart_task_time"]
  256. }
  257. {
  258. LY_USERNAME = config["ly_username"]
  259. LY_PASSWORD = config["ly_password"]
  260. LY_JSON_PATH = config["ly_json_path"]
  261. LY_OPEN = config["ly_open"]
  262. }
  263. {
  264. RZD_TASK_TIME = config["rzd_task_time"]
  265. RZD_USERNAME = config["rzd_username"]
  266. RZD_PASSWORD = config["rzd_password"]
  267. RZD_EXCEL_PATH = config["rzd_excel_path"]
  268. RZD_OPEN = config["rzd_open"]
  269. RZD_DOWNLOAD_PATH = config["rzd_download_path"]
  270. RZD_LOGIN_PATH = config["rzd_login_path"]
  271. }
  272. // 隆众数据
  273. {
  274. OilchemAccount = config["oilchem_account"]
  275. OilchemPassword = config["oilchem_password"]
  276. OilchemCookieFile = config["oilchem_cookie_file"]
  277. OilchemOpen = config["oilchem_open"]
  278. OilchemDataInit = config["oilchem_data_init"]
  279. }
  280. // 泛糖科技
  281. {
  282. HisugarAccount = config["hisugar_account"]
  283. HisugarPassword = config["hisugar_password"]
  284. HisugarOpen = config["hisugar_open"]
  285. }
  286. //克拉克森文件夹配置
  287. {
  288. ClarkSonsFilePath = config["clarksons_file_path"]
  289. ClarkSonsOpen = config["clarksons_open"]
  290. }
  291. //PDF生成配置
  292. {
  293. MinIoAccessKeyId = config["minio_access_key_id"]
  294. MinIoAccessKeySecret = config["minio_access_key_secret"]
  295. MinIoEndpoint = config["minio_endpoint"]
  296. MinIoUseSSL = config["minio_use_ssl"]
  297. MinIoBucketName = config["minio_bucket_name"]
  298. MinIoUploadDir = config["minio_upload_dir"]
  299. MinIoViewHost = config["minio_view_host"]
  300. ChromePath = config["chrome_path"]
  301. CommandPython = config["command_python"]
  302. if CommandPython == "" {
  303. CommandPython = "python3"
  304. }
  305. OssType = config["oss_type"]
  306. if OssType == "" {
  307. OssType = MINIO
  308. }
  309. // S3-OSS相关
  310. S3Endpoint = config["s3_endpoint"]
  311. S3BackEndpoint = config["s3_back_endpoint"]
  312. S3BucketName = config["s3_bucket_name"]
  313. S3Host = config["s3_host"]
  314. S3AccessKeyId = config["s3_access_key_id"]
  315. S3AccessKeySecret = config["s3_access_key_secret"]
  316. S3UploadDir = config["s3_upload_dir"]
  317. S3Region = config["s3_region"]
  318. S3ForceStyle = config["s3_force_style"]
  319. S3EndpointPort = config["s3_endpoint_port"]
  320. S3Protocol = config["s3_protocol"]
  321. S3DisableSSL = config["s3_disable_ssl"]
  322. S3OpenAcl = config["s3_open_acl"]
  323. //aliyun oss
  324. Endpoint = config["endpoint"]
  325. Bucketname = config["bucket_name"]
  326. Imghost = config["img_host"]
  327. UploadDir = config["upload_dir"]
  328. Upload_Audio_Dir = config["upload_audio_dir"]
  329. AccessKeyId = config["access_key_id"]
  330. AccessKeySecret = config["access_key_secret"]
  331. }
  332. }
  333. //修改接口文档
  334. //http://8.136.199.33:8300/swagger/