db.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. _ "github.com/go-sql-driver/mysql"
  5. "hongze/hongze_edb_lib/models/future_good"
  6. "hongze/hongze_edb_lib/models/supply_analysis"
  7. "hongze/hongze_edb_lib/utils"
  8. "time"
  9. )
  10. func init() {
  11. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL)
  12. orm.SetMaxIdleConns("default", 50)
  13. orm.SetMaxOpenConns("default", 100)
  14. db, _ := orm.GetDB("default")
  15. db.SetConnMaxLifetime(10 * time.Minute)
  16. _ = orm.RegisterDataBase("edb", "mysql", utils.MYSQL_URL_EDB)
  17. orm.SetMaxIdleConns("edb", 50)
  18. orm.SetMaxOpenConns("edb", 100)
  19. edb_db, _ := orm.GetDB("edb")
  20. edb_db.SetConnMaxLifetime(10 * time.Minute)
  21. _ = orm.RegisterDataBase("gl", "mysql", utils.MYSQL_URL_GL)
  22. orm.SetMaxIdleConns("gl", 50)
  23. orm.SetMaxOpenConns("gl", 100)
  24. gl, _ := orm.GetDB("gl")
  25. gl.SetConnMaxLifetime(10 * time.Minute)
  26. orm.Debug = true
  27. orm.DebugLog = orm.NewLog(utils.Binlog)
  28. //注册对象
  29. orm.RegisterModel(
  30. new(EdbDataCalculateZjpj),
  31. new(EdbDataCalculateLjztbpj),
  32. new(EdbInfo),
  33. new(EdbInfoCalculateMapping),
  34. new(EdbPythonCode),
  35. new(EdbDataPython),
  36. new(ChartEdbMapping),
  37. new(PredictEdbConf),
  38. new(EdbClassify),
  39. new(PredictEdbConfCalculateMapping),
  40. new(PredictEdbRuleData),
  41. new(EdbDataCalculateNhcc),
  42. new(EdbDataPredictCalculateLjztbpj),
  43. new(EdbDataPredictCalculateNhcc),
  44. new(EdbDataPredictCalculateZjpj),
  45. new(EdbDataInsertConfig),
  46. new(EdbAdjustConf), // 数据调整的配置
  47. )
  48. // 注册期货数据 数据表
  49. initFutureGood()
  50. // 供应分析 数据表
  51. initSupplyAnalysis()
  52. // 基础指标表
  53. initBaseIndex()
  54. }
  55. // initFutureGood 注册期货数据 数据表
  56. func initFutureGood() {
  57. //注册对象
  58. orm.RegisterModel(
  59. new(future_good.FutureGoodEdbInfo), //期货指标表
  60. new(future_good.FutureGoodEdbData), //期货指标数据表
  61. new(future_good.ChartInfoFutureGoodProfit), //商品期货利润图表相关的信息
  62. )
  63. }
  64. // initSupplyAnalysis 供应分析
  65. func initSupplyAnalysis() {
  66. orm.RegisterModel(
  67. new(supply_analysis.Variety),
  68. new(supply_analysis.VarietyAdminPermission),
  69. new(supply_analysis.VarietyEdbInfo),
  70. new(supply_analysis.VarietyPlant),
  71. new(supply_analysis.BaseFromStockPlantData),
  72. )
  73. }
  74. // initBaseIndex 基础指标表
  75. func initBaseIndex() {
  76. orm.RegisterModel(
  77. new(BaseFromSciIndex),
  78. new(BaseFromSciData),
  79. new(BaseFromBaiinfoIndex),
  80. new(BaseFromBaiinfoData),
  81. new(BaseFromSmmIndex),
  82. new(BaseFromSmmData),
  83. new(BaseFromMysteelChemicalIndex),
  84. new(BaseFromMysteelChemicalData),
  85. )
  86. }