123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- package models
- import (
- "eta_gn/eta_task/models/data_manage"
- "eta_gn/eta_task/models/data_manage/edb_refresh"
- "eta_gn/eta_task/models/data_manage/future_good"
- "eta_gn/eta_task/models/report"
- "eta_gn/eta_task/utils"
- "time"
- _ "github.com/go-sql-driver/mysql"
- "github.com/beego/beego/v2/client/orm"
- )
- func initback() {
- _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL)
- orm.SetMaxIdleConns("default", 50)
- orm.SetMaxOpenConns("default", 100)
- db, _ := orm.GetDB("default")
- db.SetConnMaxLifetime(10 * time.Minute)
- if utils.MYSQL_URL_RDDP != "" {
- _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
- orm.SetMaxIdleConns("rddp", 50)
- orm.SetMaxOpenConns("rddp", 100)
- report_db, _ := orm.GetDB("rddp")
- report_db.SetConnMaxLifetime(10 * time.Minute)
- }
- if utils.MYSQL_URL_EDB != "" {
- _ = orm.RegisterDataBase("edb", "mysql", utils.MYSQL_URL_EDB)
- orm.SetMaxIdleConns("edb", 50)
- orm.SetMaxOpenConns("edb", 100)
- edb_db, _ := orm.GetDB("edb")
- edb_db.SetConnMaxLifetime(10 * time.Minute)
- }
- if utils.MYSQL_URL_DATA != "" {
- _ = orm.RegisterDataBase("data", "mysql", utils.MYSQL_URL_DATA)
- orm.SetMaxIdleConns("data", 50)
- orm.SetMaxOpenConns("data", 100)
- data_db, _ := orm.GetDB("data")
- data_db.SetConnMaxLifetime(10 * time.Minute)
- }
- if utils.MYSQL_URL_GL != "" {
- _ = orm.RegisterDataBase("gl", "mysql", utils.MYSQL_URL_GL)
- orm.SetMaxIdleConns("gl", 50)
- orm.SetMaxOpenConns("gl", 100)
- gl, _ := orm.GetDB("gl")
- gl.SetConnMaxLifetime(10 * time.Minute)
- }
- if utils.MYSQL_URL_ETA != "" {
- _ = orm.RegisterDataBase("eta", "mysql", utils.MYSQL_URL_ETA)
- orm.SetMaxIdleConns("eta", 50)
- orm.SetMaxOpenConns("eta", 100)
- etaDb, _ := orm.GetDB("eta")
- etaDb.SetConnMaxLifetime(10 * time.Minute)
- }
- orm.Debug = true
- orm.DebugLog = orm.NewLog(utils.Binlog)
- initEdbDataTable()
- initFutureGoodEdbDataTable()
- initTradePositionTop()
- initReport()
- initSmartReport()
- initEdbRefresh()
- data_manage.InitEdbSourceVar()
- }
- func initEdbDataTable() {
- orm.RegisterModel(
- new(data_manage.EdbInfoCalculateMapping),
- new(data_manage.EdbInfo), //hz_data库的edb_info表
- new(data_manage.BusinessSysInteractionLog), // 商家系统交互记录表
- new(data_manage.EdbInfoRelation), //指标引用关联表
- )
- }
- func initFutureGoodEdbDataTable() {
- orm.RegisterModel(
- new(future_good.FutureGoodEdbInfo),
- )
- }
- func initTradePositionTop() {
- orm.RegisterModel(
- new(data_manage.TradePositionDalianTop),
- new(data_manage.TradePositionZhengzhouTop),
- new(data_manage.TradePositionShanghaiTop),
- new(data_manage.TradePositionIneTop),
- new(data_manage.TradePositionCffexTop),
- new(data_manage.BaseFromTradeClassify), // 交易所分类
- new(data_manage.TradePositionGuangzhouTop),
- )
- }
- func initReport() {
- orm.RegisterModel(
- new(Report),
- new(ReportChapter),
- new(report.ReportChapterPermissionMapping), // 报告章节的权限关系表
- )
- }
- func initSmartReport() {
- orm.RegisterModel(
- new(SmartReport),
- new(ReportStateRecord),
- )
- }
- func initEdbRefresh() {
- orm.RegisterModel(
- new(edb_refresh.EdbRefreshSource), // 刷新的数据源表
- new(edb_refresh.EdbRefreshDefaultConfig), // 指标的默认刷新时间配置表
- new(edb_refresh.EdbRefreshConfig), // 指标的刷新时间配置表
- new(edb_refresh.EdbRefreshMapping), // 指标刷新时间配置关系表
- )
- }
- func AfterInitTable() {
- data_manage.InitEdbSourceVar()
- }
|