123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- 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)
- // 注册Edb指标 数据表
- initEdbDataTable()
- // 注册商品期货 相关数据表
- initFutureGoodEdbDataTable()
- //注册持仓分析 数据表
- initTradePositionTop()
- // 研报数据表
- initReport()
- // 智能研报数据表
- initSmartReport()
- // 初始化指标刷新
- initEdbRefresh()
- // 初始化部分数据表变量(直接init会有顺序问题=_=!)
- data_manage.InitEdbSourceVar()
- }
- // initEdbDataTable 注册Edb指标 数据表
- func initEdbDataTable() {
- //注册对象
- orm.RegisterModel(
- new(data_manage.EdbInfoCalculateMapping),
- new(data_manage.EdbInfo), //hz_data库的edb_info表
- new(data_manage.BusinessSysInteractionLog), // 商家系统交互记录表
- new(data_manage.EdbInfoRelation), //指标引用关联表
- )
- }
- // 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), // 指标刷新时间配置关系表
- )
- }
- // AfterInitTable
- // @Description: 系统初始化后的数据操作
- func AfterInitTable() {
- // 初始化部分数据表变量(直接init会有顺序问题=_=!)
- data_manage.InitEdbSourceVar()
- }
|