package models import ( "eta/eta_task/models/data_manage" "eta/eta_task/models/data_manage/edb_refresh" "eta/eta_task/models/data_manage/future_good" "eta/eta_task/models/report" "eta/eta_task/utils" "time" _ "github.com/go-sql-driver/mysql" "github.com/beego/beego/v2/client/orm" ) func init() { _ = 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) // 注册Edb指标 数据表 initEdbDataTable() // 注册商品期货 相关数据表 initFutureGoodEdbDataTable() //注册持仓分析 数据表 initTradePositionTop() // 研报数据表 initReport() // 智能研报数据表 initSmartReport() // 初始化指标刷新 initEdbRefresh() // 初始化部分数据表变量(直接init会有顺序问题=_=!) data_manage.InitEdbSourceVar() } // initEdbDataTable 注册Edb指标 数据表 func initEdbDataTable() { //注册对象 orm.RegisterModel( new(data_manage.EdbDataWind), new(data_manage.EdbDataThs), new(data_manage.EdbDataPb), new(data_manage.BaseFromSmm), new(data_manage.BaseFromSmmIndex), new(data_manage.BaseFromSmmData), new(data_manage.EdbDataYs), new(data_manage.EdbInfoCalculateMapping), new(data_manage.EdbInfo), //hz_data库的edb_info表 new(data_manage.EdbDataCalculateZjpj), //直接拼接 new(data_manage.EdbDataCalculateLjztbpj), //累计同比值拼接 new(data_manage.BaseFromTradeZhengzhouIndex), new(data_manage.BaseFromTradeDalianIndex), new(data_manage.BaseFromTradeShanghaiIndex), new(data_manage.BaseFromTradeCffexIndex), new(data_manage.BaseFromTradeIneIndex), new(data_manage.BaseFromChangesVisitorsCovid), new(data_manage.BaseFromEiaSteoIndex), new(data_manage.BaseFromEiaSteoClassify), new(data_manage.BaseFromEiaSteoData), new(data_manage.ComTradeIndex), // 联合国指标表 new(data_manage.ComTradeCodeMapping), // 联合国指标关系表 new(data_manage.ComTradeData), // 联合国数据表 new(data_manage.MeetingProbabilities), // 联储加息概率 new(data_manage.BaseFromTradeEicIndexV2), // 欧洲天然气 //广期所 new(data_manage.BaseFromTradeGuangzhouClassify), new(data_manage.BaseFromTradeGuangzhouContract), new(data_manage.BaseFromTradeGuangzhouIndex), new(data_manage.BaseFromTradeGuangzhouData), //ICPI new(data_manage.BaseFromIcpiIndex), new(data_manage.BaseFromIcpiClassify), new(data_manage.BaseFromIcpiData), new(data_manage.BusinessSysInteractionLog), // 商家系统交互记录表 new(data_manage.EdbInfoRelation), //指标引用关联表 new(data_manage.BaseFromThsHfIndex), ) } // initFutureGoodEdbDataTable 注册商品期货Edb指标 数据表 func initFutureGoodEdbDataTable() { //注册对象 orm.RegisterModel( new(future_good.FutureGoodEdbInfo), ) } // initTradePositionTop 注册持仓分析 数据表 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), ) } // initReport 注册研报数据表 func initReport() { orm.RegisterModel( new(Report), new(ReportChapter), new(report.ReportChapterPermissionMapping), // 报告章节的权限关系表 ) } // initSmartReport 注册智能研报数据表 func initSmartReport() { orm.RegisterModel( new(SmartReport), new(ReportStateRecord), ) } // initEdbRefresh 初始化指标刷新 func initEdbRefresh() { orm.RegisterModel( new(edb_refresh.EdbRefreshSource), // 刷新的数据源表 new(edb_refresh.EdbRefreshDefaultConfig), // 指标的默认刷新时间配置表 new(edb_refresh.EdbRefreshConfig), // 指标的刷新时间配置表 new(edb_refresh.EdbRefreshMapping), // 指标刷新时间配置关系表 ) }