123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- package models
- import (
- "eta_gn/eta_index_lib/models/data_stat"
- "eta_gn/eta_index_lib/models/edb_refresh"
- "eta_gn/eta_index_lib/models/excel"
- "eta_gn/eta_index_lib/models/future_good"
- "eta_gn/eta_index_lib/models/supply_analysis"
- "eta_gn/eta_index_lib/utils"
- "time"
- "github.com/beego/beego/v2/client/orm"
- _ "github.com/go-sql-driver/mysql"
- )
- 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)
- _ = 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)
- _ = 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)
- // master库
- {
- _ = orm.RegisterDataBase("master", "mysql", utils.MYSQL_URL_MASTER)
- orm.SetMaxIdleConns("master", 50)
- orm.SetMaxOpenConns("master", 100)
- master, _ := orm.GetDB("master")
- master.SetConnMaxLifetime(10 * time.Minute)
- }
- orm.Debug = true
- orm.DebugLog = orm.NewLog(utils.Binlog)
- //注册对象
- orm.RegisterModel(
- new(EdbDataCalculateZjpj),
- new(EdbDataCalculateLjztbpj),
- new(EdbInfo),
- new(EdbInfoRecord),
- new(BaseFromSmmRecord),
- new(BaseFromMysteelChemicalRecord),
- new(EdbInfoCalculateMapping),
- new(EdbPythonCode),
- new(EdbDataPython),
- new(ChartEdbMapping),
- new(PredictEdbConf),
- new(EdbClassify),
- new(PredictEdbConfCalculateMapping),
- new(PredictEdbRuleData),
- new(EdbDataCalculateNhcc),
- new(EdbDataPredictCalculateLjztbpj),
- new(EdbDataPredictCalculateNhcc),
- new(EdbDataPredictCalculateZjpj),
- new(EdbDataInsertConfig),
- new(EdbAdjustConf), // 数据调整的配置
- new(BaseFromMysteelChemicalClassify),
- new(EdbInfoRelation), //指标引用记录
- )
- // 注册期货数据 数据表
- initFutureGood()
- // 供应分析 数据表
- initSupplyAnalysis()
- // 基础指标表
- initBaseIndex()
- // initDataStat 数据源统计管理相关表
- initDataStat()
- // Eta表格相关
- initExcel()
- // 初始化指标刷新
- initEdbRefresh()
- // 自有数据指标
- initBusinessEdb()
- // 初始化因子指标系列
- initFactorEdbSeries()
- // 初始化部分数据表变量(直接init会有顺序问题=_=!)
- afterInitTable()
- }
- // initFutureGood 注册期货数据 数据表
- func initFutureGood() {
- //注册对象
- orm.RegisterModel(
- new(future_good.FutureGoodEdbInfo), //期货指标表
- new(future_good.FutureGoodEdbData), //期货指标数据表
- new(future_good.ChartInfoFutureGoodProfit), //商品期货利润图表相关的信息
- )
- }
- // initSupplyAnalysis 供应分析
- func initSupplyAnalysis() {
- orm.RegisterModel(
- new(supply_analysis.Variety),
- new(supply_analysis.VarietyAdminPermission),
- new(supply_analysis.VarietyEdbInfo),
- new(supply_analysis.VarietyPlant),
- new(supply_analysis.BaseFromStockPlantData),
- )
- }
- // initBaseIndex 基础指标表
- func initBaseIndex() {
- orm.RegisterModel(
- new(BaseFromSciIndex),
- new(BaseFromSciData),
- new(BaseFromBaiinfoIndex),
- new(BaseFromBaiinfoData),
- new(BaseFromSmmIndex),
- new(BaseFromSmmData),
- new(BaseFromMysteelChemicalIndex),
- new(BaseFromMysteelChemicalData),
- new(BaseFromTradeShanghaiIndex),
- new(BaseFromTradeIneIndex),
- new(BaseFromSmmClassify),
- new(BaseFromYongyiIndex),
- new(BaseFromYongyiData),
- new(BaseFromYongyiClassify),
- new(BaseFromCoalmineMapping),
- new(BaseFromCoalmineJsmIndex),
- new(BaseFromCoalmineCoastalIndex),
- new(BaseFromCoalmineInlandIndex),
- new(BaseFromCoalmineCompanyIndex),
- new(BaseFromCoalmineFirmIndex),
- new(BaseFromMtjhMapping),
- new(BaseFromMtjhIndex),
- new(BaseFromFenweiIndex),
- new(BaseFromFenweiData),
- new(BaseFromBloombergIndex),
- new(BaseFromBloombergData),
- new(BaseFromSci99Data),
- new(BaseFromSci99Index),
- new(BaseFromSci99Classify),
- new(BaseFromCCFIndex),
- new(BaseFromCCFData),
- new(CCFStockExcel),
- new(BaseFromSciHqData),
- new(BaseFromSciHqIndex),
- new(BaseFromThsHfIndex),
- new(BaseFromThsHfData),
- new(BaseFromEdbMapping),
- new(EdbDataThsHf),
- new(BaseFromBusinessData), // 数据源中自有数据的明细数据表
- new(BaseFromOilchemIndex),
- new(BaseFromOilchemData),
- new(BaseFromFenweiClassify),
- new(EdbDataTradeAnalysis),
- )
- }
- // initDataStat 数据源统计管理相关表
- func initDataStat() {
- orm.RegisterModel(
- new(data_stat.EdbInfoUpdateLog), // 指标更新/刷新日志列表
- new(data_stat.EdbInfoUpdateStat), // 数据源明细表
- new(data_stat.EdbSourceStat), // 数据源统计表
- )
- }
- // initExcel Excel
- func initExcel() {
- orm.RegisterModel(
- new(excel.ExcelInfo),
- new(excel.ExcelClassify),
- new(excel.ExcelEdbMapping), //excel与指标的关系表
- )
- }
- // initEdbRefresh 初始化指标刷新
- func initEdbRefresh() {
- orm.RegisterModel(
- new(edb_refresh.EdbRefreshSource), // 刷新的数据源表
- new(edb_refresh.EdbRefreshDefaultConfig), // 指标的默认刷新时间配置表
- new(edb_refresh.EdbRefreshConfig), // 指标的刷新时间配置表
- new(edb_refresh.EdbRefreshMapping), // 指标刷新时间配置关系表
- )
- }
- // initBusinessEdb 初始化指标刷新
- func initBusinessEdb() {
- orm.RegisterModel(
- new(BaseFromBusinessIndex), // 外部指标(商家系统)表
- new(EdbBusinessSource), // 自有数据(商家)指标来源
- )
- }
- // initFactorEdbSeries 因子指标系列数据表
- func initFactorEdbSeries() {
- orm.RegisterModel(
- new(FactorEdbSeries), // 因子指标系列
- new(FactorEdbSeriesChartMapping), // 因子指标系列-图表关联
- new(FactorEdbSeriesMapping), // 因子指标系列-指标计算数据
- new(FactorEdbSeriesCalculateData), // 因子指标系列-指标关联
- new(FactorEdbSeriesCalculateDataQjjs), // 因子指标系列-区间计算
- )
- }
- // afterInitTable
- // @Description: 初始化表结构的的后置操作
- // @author: Roc
- // @datetime 2024-07-01 13:31:09
- func afterInitTable() {
- // 初始化指标来源配置
- InitEdbSource()
- // 初始化是否启用mongo配置
- InitUseMongoConf()
- // 初始化Smm有色指标数据获取方式
- InitSmmDataMethodConf()
- }
|