1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017 |
- package data_source
- import (
- "eta/eta_task/utils"
- "fmt"
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "strings"
- "time"
- )
- // SearchDataSource 数据源ES搜索
- type SearchDataSource struct {
- PrimaryId int `description:"主键ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- ClassifyId int `description:"分类ID"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate string `description:"开始日期"`
- EndDate string `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- Source int `description:"来源"`
- SourceName string `description:"数据源名称"`
- SubSource int `description:"子来源"`
- IsDeleted int `description:"是否已删除:0-正常;1-已删除"`
- CreateTime string `description:"创建时间"`
- ModifyTime string `description:"修改时间"`
- }
- // SearchDataSourceItem 数据源ES搜索
- type SearchDataSourceItem struct {
- SearchDataSource
- SearchText string `description:"搜索结果(含高亮)"`
- }
- // ToMap 为了方便前端那边的修改,这里兼容一下部分Key的变动,不然改动量很大
- func (s *SearchDataSourceItem) ToMap(primaryIdKey, indexNameKey, classifyIdKey string) map[string]interface{} {
- data := make(map[string]interface{})
- if primaryIdKey != "" {
- data[primaryIdKey] = s.PrimaryId
- } else {
- data["PrimaryId"] = s.PrimaryId
- }
- if indexNameKey != "" {
- data[indexNameKey] = s.IndexName
- } else {
- data["IndexName"] = s.IndexName
- }
- if classifyIdKey != "" {
- data[classifyIdKey] = s.ClassifyId
- } else {
- data["ClassifyId"] = s.ClassifyId
- }
- data["IndexCode"] = s.IndexCode
- data["Unit"] = s.Unit
- data["Frequency"] = s.Frequency
- data["StartDate"] = s.StartDate
- data["EndDate"] = s.EndDate
- data["LatestValue"] = s.LatestValue
- data["Source"] = s.Source
- data["SourceName"] = s.SourceName
- data["IsDeleted"] = s.IsDeleted
- data["CreateTime"] = s.CreateTime
- data["ModifyTime"] = s.ModifyTime
- data["SearchText"] = s.SearchText
- return data
- }
- // SearchDataSourceResp 数据源ES-分页搜索响应
- type SearchDataSourceResp struct {
- Paging *paging.PagingItem
- List []map[string]interface{}
- }
- // SearchEsCols 数据源ES搜索字段
- type SearchEsCols struct {
- PrimaryId string
- IndexCode string
- IndexName string
- ClassifyId string
- Unit string
- Frequency string
- StartDate string
- EndDate string
- LatestValue string
- CreateTime string
- ModifyTime string
- }
- // EsBaseFromIndex 数据源ES统一实现的接口
- type EsBaseFromIndex interface {
- EsCols() SearchEsCols
- SourceInfo() (int, int, string)
- }
- // GetEsBaseFromIndexByTableName 根据表名获取对应数据源
- func GetEsBaseFromIndexByTableName(tableName string) EsBaseFromIndex {
- switch tableName {
- case "base_from_rzd_index":
- return &BaseFromRzdIndex{}
- case "base_from_hisugar_index":
- return &BaseFromHisugarIndex{}
- case "base_from_ly_index":
- return &BaseFromLyIndex{}
- case "base_from_sci_hq_index":
- return &BaseFromSciHqIndex{}
- case "base_from_oilchem_index":
- return &BaseFromOilchemIndex{}
- case "base_from_ths_hf_index":
- return &BaseFromThsHfIndex{}
- case "base_from_ccf_index":
- return &BaseFromCcfIndex{}
- case "base_from_usda_fas_index":
- return &BaseFromUsdaFasIndex{}
- case "base_from_mysteel_chemical_index":
- return &BaseFromMysteelChemicalIndex{}
- case "base_from_smm_index":
- return &BaseFromSmmIndex{}
- case "base_from_baiinfo_index":
- return &BaseFromBaiinfoIndex{}
- case "base_from_sci_index":
- return &BaseFromSciIndex{}
- case "base_from_coalmine_mapping":
- return &BaseFromCoalmineMapping{}
- case "base_from_eia_steo_index":
- return &BaseFromEiaSteoIndex{}
- case "base_from_icpi_index":
- return &BaseFromIcpiIndex{}
- case "base_from_yongyi_index":
- return &BaseFromYongyiIndex{}
- case "base_from_fenwei_index":
- return &BaseFromFenweiIndex{}
- case "base_from_sci99_index":
- return &BaseFromSci99Index{}
- case "mb_index_main_info":
- return &BaseFromGlIndex{}
- case "edbinfo":
- return &BaseFromManualEdb{}
- case "base_from_business_index":
- return &BaseFromBusinessIndex{}
- case "base_from_bloomberg_index":
- return &BaseFromBloombergIndex{}
- case "base_from_mtjh_mapping":
- return &BaseFromMtjhMapping{}
- }
- return nil
- }
- // BaseFromRzdIndex 睿咨得
- type BaseFromRzdIndex struct {
- BaseFromRzdIndexId int `orm:"column(base_from_rzd_index_id);pk"`
- BaseFromRzdClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromRzdIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_RZD, 0, "睿咨得"
- }
- func (m *BaseFromRzdIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_rzd_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "base_from_rzd_classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromRzdIndex) Format2SearchDataSource(origin *BaseFromRzdIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromRzdIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.BaseFromRzdClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromRzdIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromRzdIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_rzd_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromHisugarIndex 泛糖科技
- type BaseFromHisugarIndex struct {
- BaseFromHisugarIndexId int `orm:"column(base_from_hisugar_index_id);pk"`
- ClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- Source string `description:"数据来源"`
- Describe string `description:"指标描述"`
- Sort int `description:"排序"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromHisugarIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_HISUGAR, 0, "泛糖科技"
- }
- func (m *BaseFromHisugarIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_hisugar_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromHisugarIndex) Format2SearchDataSource(origin *BaseFromHisugarIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromHisugarIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromHisugarIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromHisugarIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_hisugar_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromLyIndex 粮油商务网
- type BaseFromLyIndex struct {
- BaseFromLyIndexId int `orm:"column(base_from_ly_index_id);pk"`
- BaseFromLyClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- EdbExist int `description:"指标库是否已添加:0-否;1-是"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromLyIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_LY, 0, "粮油商务网"
- }
- func (m *BaseFromLyIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_ly_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "base_from_ly_classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromLyIndex) Format2SearchDataSource(origin *BaseFromLyIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromLyIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.BaseFromLyClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromLyIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromLyIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_ly_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromSciHqIndex 卓创红期
- type BaseFromSciHqIndex struct {
- BaseFromSciHqIndexId int `orm:"column(base_from_sci_hq_index_id);pk"`
- ClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- Sort int `description:"排序"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- LatestDate time.Time `description:"最新更新时间"`
- TerminalCode string `description:"指标描述"`
- FilePath string `description:"文件路径"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromSciHqIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_SCI_HQ, 0, "卓创红期"
- }
- func (m *BaseFromSciHqIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_sci_hq_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromSciHqIndex) Format2SearchDataSource(origin *BaseFromSciHqIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromSciHqIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromSciHqIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromSciHqIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_sci_hq_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromOilchemIndex 隆众资讯
- type BaseFromOilchemIndex struct {
- BaseFromOilchemIndexId int `orm:"column(base_from_oilchem_index_id);pk"`
- ClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromOilchemIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_OILCHEM, 0, "隆众资讯"
- }
- func (m *BaseFromOilchemIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_oilchem_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromOilchemIndex) Format2SearchDataSource(origin *BaseFromOilchemIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromOilchemIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromOilchemIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromOilchemIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_oilchem_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromThsHfIndex 同花顺高频数据
- type BaseFromThsHfIndex struct {
- BaseFromThsHfIndexId int `orm:"column(base_from_ths_hf_index_id);pk"`
- BaseFromThsHfClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Source string `description:"数据来源"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期(至时分秒)"`
- EndDate time.Time `description:"结束日期(至时分秒)"`
- Describe string `description:"指标描述"`
- Sort int `description:"排序"`
- IsStop int `description:"是否停更:0-否;1-停更"`
- TerminalCode string `description:"所属终端编码"`
- StockCode string `description:"证券代码"`
- Indicator string `description:"同花顺指标代码"`
- ApiPars string `description:"API请求参数"`
- LatestValue float64 `description:"最新值"`
- SysUserId int `description:"创建人ID"`
- SysUserRealName string `description:"创建人姓名"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- }
- func (m *BaseFromThsHfIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_THS, utils.DATA_SUB_SOURCE_HIGH_FREQUENCY, "同花顺高频"
- }
- func (m *BaseFromThsHfIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_ths_hf_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "base_from_ths_hf_classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromThsHfIndex) Format2SearchDataSource(origin *BaseFromThsHfIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromThsHfIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.BaseFromThsHfClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDateTime, origin.StartDate) // 高频这里是到时分秒
- item.EndDate = utils.TimeTransferString(utils.FormatDateTime, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromThsHfIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromThsHfIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_ths_hf_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromCcfIndex CCF化纤信息
- type BaseFromCcfIndex struct {
- BaseFromCcfIndexId int `orm:"column(base_from_ccf_index_id);pk"`
- ClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromCcfIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_CCF, 0, "CCF化纤信息"
- }
- func (m *BaseFromCcfIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_ccf_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromCcfIndex) Format2SearchDataSource(origin *BaseFromCcfIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromCcfIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromCcfIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromCcfIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_ccf_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromUsdaFasIndex 美国农业部
- type BaseFromUsdaFasIndex struct {
- BaseFromUsdaFasIndexId int `orm:"column(base_from_usda_fas_index_id);pk"`
- ClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromUsdaFasIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_USDA_FAS, 0, "美国农业部"
- }
- func (m *BaseFromUsdaFasIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_usda_fas_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "end_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromUsdaFasIndex) Format2SearchDataSource(origin *BaseFromUsdaFasIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromUsdaFasIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromUsdaFasIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromUsdaFasIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s, end_value AS latest_value FROM base_from_usda_fas_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromMysteelChemicalIndex 上海钢联
- type BaseFromMysteelChemicalIndex struct {
- BaseFromMysteelChemicalIndexId int `orm:"column(base_from_mysteel_chemical_index_id);pk"`
- BaseFromMysteelChemicalClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromMysteelChemicalIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_MYSTEEL_CHEMICAL, 0, "上海钢联"
- }
- func (m *BaseFromMysteelChemicalIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_mysteel_chemical_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "base_from_mysteel_chemical_classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "end_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromMysteelChemicalIndex) Format2SearchDataSource(origin *BaseFromMysteelChemicalIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromMysteelChemicalIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.BaseFromMysteelChemicalClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromMysteelChemicalIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromMysteelChemicalIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s, end_value AS latest_value FROM base_from_mysteel_chemical_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromSmmIndex 有色原始数据库
- type BaseFromSmmIndex struct {
- BaseFromSmmIndexId int `orm:"column(base_from_smm_index_id);pk"`
- ClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromSmmIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_YS, 0, "SMM原始数据库"
- }
- func (m *BaseFromSmmIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_smm_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "end_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromSmmIndex) Format2SearchDataSource(origin *BaseFromSmmIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromSmmIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromSmmIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromSmmIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s, end_value AS latest_value FROM base_from_smm_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromBaiinfoIndex 百川盈孚
- type BaseFromBaiinfoIndex struct {
- BaseFromBaiinfoIndexId int `orm:"column(base_from_baiinfo_index_id);pk"`
- ClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromBaiinfoIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_BAIINFO, 0, "百川盈孚"
- }
- func (m *BaseFromBaiinfoIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_baiinfo_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromBaiinfoIndex) Format2SearchDataSource(origin *BaseFromBaiinfoIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromBaiinfoIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromBaiinfoIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromBaiinfoIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_baiinfo_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromSciIndex 卓创数据(红桃3)
- type BaseFromSciIndex struct {
- BaseFromSciIndexId int `orm:"column(base_from_sci_index_id);pk"`
- ClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromSciIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_SCI, 0, "卓创数据(红桃3)"
- }
- func (m *BaseFromSciIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_sci_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromSciIndex) Format2SearchDataSource(origin *BaseFromSciIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromSciIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromSciIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromSciIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_sci_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromCoalmineMapping 中国煤炭市场网
- type BaseFromCoalmineMapping struct {
- BaseFromCoalmineMappingId int `orm:"column(base_from_coalmine_mapping_id);pk"`
- ClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromCoalmineMapping) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_COAL, 0, "中国煤炭市场网"
- }
- func (m *BaseFromCoalmineMapping) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_coalmine_mapping_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "",
- Unit: "",
- Frequency: "",
- StartDate: "",
- EndDate: "",
- LatestValue: "",
- CreateTime: "create_time",
- ModifyTime: "",
- }
- }
- func (m *BaseFromCoalmineMapping) Format2SearchDataSource(origin *BaseFromCoalmineMapping) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromCoalmineMappingId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromCoalmineMapping) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromCoalmineMapping, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_coalmine_mapping WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromEiaSteoIndex EIA STEO报告
- type BaseFromEiaSteoIndex struct {
- BaseFromEiaSteoIndexId int `orm:"column(base_from_eia_steo_index_id);pk"`
- BaseFromEiaSteoClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromEiaSteoIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_EIA_STEO, 0, "EIA STEO报告"
- }
- func (m *BaseFromEiaSteoIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_eia_steo_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "base_from_eia_steo_classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromEiaSteoIndex) Format2SearchDataSource(origin *BaseFromEiaSteoIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromEiaSteoIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.BaseFromEiaSteoClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromEiaSteoIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromEiaSteoIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_eia_steo_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromIcpiIndex ICPI消费价格指数
- type BaseFromIcpiIndex struct {
- BaseFromIcpiIndexId int `orm:"column(base_from_icpi_index_id);pk"`
- BaseFromIcpiClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromIcpiIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_ICPI, 0, "ICPI消费价格指数"
- }
- func (m *BaseFromIcpiIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_icpi_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "base_from_icpi_classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromIcpiIndex) Format2SearchDataSource(origin *BaseFromIcpiIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromIcpiIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.BaseFromIcpiClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromIcpiIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromIcpiIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_icpi_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromYongyiIndex 涌益咨询
- type BaseFromYongyiIndex struct {
- YongyiIndexId int `orm:"column(yongyi_index_id);pk"`
- ClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromYongyiIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_YONYI, 0, "涌益咨询"
- }
- func (m *BaseFromYongyiIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "yongyi_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromYongyiIndex) Format2SearchDataSource(origin *BaseFromYongyiIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.YongyiIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromYongyiIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromYongyiIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_yongyi_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromFenweiIndex 汾渭数据
- type BaseFromFenweiIndex struct {
- FenweiIndexId int `orm:"column(fenwei_index_id);pk"`
- ClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromFenweiIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_FENWEI, 0, "汾渭数据"
- }
- func (m *BaseFromFenweiIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "fenwei_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromFenweiIndex) Format2SearchDataSource(origin *BaseFromFenweiIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.FenweiIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromFenweiIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromFenweiIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_fenwei_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromSci99Index 卓创资讯
- type BaseFromSci99Index struct {
- BaseFromSciIndexId int `orm:"column(base_from_sci_index_id);pk"`
- ClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromSci99Index) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_SCI99, 0, "卓创资讯"
- }
- func (m *BaseFromSci99Index) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_sci_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "classify_id",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromSci99Index) Format2SearchDataSource(origin *BaseFromSci99Index) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromSciIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromSci99Index) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromSci99Index, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_sci99_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromGlIndex 钢联原始指标库
- type BaseFromGlIndex struct {
- PrimaryId int `orm:"column(ID);pk"`
- IndexCode string `orm:"column(INDEX_CODE)" description:"指标编码"`
- IndexName string `orm:"column(INDEX_NAME)" description:"指标名称"`
- Unit string `orm:"column(UNIT_NAME)" description:"单位"`
- Frequency string `orm:"column(FREQUENCY_NAME)" description:"频度"`
- StartDate time.Time `orm:"column(BEGIN_DATE)" description:"开始日期"`
- EndDate time.Time `orm:"column(END_DATE)" description:"结束日期"`
- LatestValue float64 `orm:"column(DATA_VALUE)" description:"最新值"`
- CreateTime time.Time `orm:"column(CREATE_TIME)" description:"创建时间"`
- ModifyTime time.Time `orm:"column(UPDATE_TIME)" description:"更新时间"`
- }
- func (m *BaseFromGlIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_GL, 0, "钢联原始数据库"
- }
- func (m *BaseFromGlIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "ID",
- IndexCode: "INDEX_CODE",
- IndexName: "INDEX_NAME",
- ClassifyId: "",
- Unit: "UNIT_NAME",
- Frequency: "FREQUENCY_NAME",
- StartDate: "BEGIN_DATE",
- EndDate: "END_DATE",
- LatestValue: "DATA_VALUE",
- CreateTime: "CREATE_TIME",
- ModifyTime: "UPDATE_TIME",
- }
- }
- func (m *BaseFromGlIndex) Format2SearchDataSource(origin *BaseFromGlIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.PrimaryId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- //item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromGlIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromGlIndex, err error) {
- o := orm.NewOrmUsingDB("gl")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY CREATE_TIME DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM mb_index_main_info WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromManualEdb 手工数据录入
- type BaseFromManualEdb struct {
- //PrimaryId int `orm:"column(TRADE_CODE)"` // 注手工指标没自增ID...
- IndexCode string `orm:"column(TRADE_CODE)" description:"指标编码"`
- IndexName string `orm:"column(SEC_NAME)" description:"指标名称"`
- ClassifyId int `orm:"column(classify_id)" description:"分类ID"`
- Unit string `orm:"column(UNIT)" description:"单位"`
- Frequency string `orm:"column(frequency)" description:"频度"`
- StartDate time.Time `orm:"column(start_date)" description:"开始日期"`
- EndDate time.Time `orm:"column(end_date)" description:"结束日期"`
- LatestValue float64 `orm:"column(latest_value)" description:"最新值"`
- CreateTime time.Time `orm:"column(create_date)" description:"创建时间"`
- ModifyTime time.Time `orm:"column(modify_time)" description:"更新时间"`
- }
- func (m *BaseFromManualEdb) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_MANUAL, 0, "手工指标录入"
- }
- func (m *BaseFromManualEdb) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "",
- IndexCode: "TRADE_CODE",
- IndexName: "SEC_NAME",
- ClassifyId: "classify_id",
- Unit: "UNIT",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_date",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromManualEdb) Format2SearchDataSource(origin *BaseFromManualEdb) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- //item.PrimaryId = origin.PrimaryId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromManualEdb) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromManualEdb, err error) {
- o := orm.NewOrmUsingDB("edb")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_date DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM edbinfo WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromBusinessIndex 自有数据
- type BaseFromBusinessIndex struct {
- BaseFromBusinessIndexId int `orm:"column(base_from_business_index_id);pk"`
- //ClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromBusinessIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_BUSINESS, 0, "自有数据"
- }
- func (m *BaseFromBusinessIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_business_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromBusinessIndex) Format2SearchDataSource(origin *BaseFromBusinessIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromBusinessIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- //item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromBusinessIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromBusinessIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_business_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromBloombergIndex Bloomberg
- type BaseFromBloombergIndex struct {
- BaseFromBloombergIndexId int `orm:"column(base_from_bloomberg_index_id);pk"`
- //ClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromBloombergIndex) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_BLOOMBERG, 0, "Bloomberg"
- }
- func (m *BaseFromBloombergIndex) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_bloomberg_index_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- func (m *BaseFromBloombergIndex) Format2SearchDataSource(origin *BaseFromBloombergIndex) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromBloombergIndexId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- //item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromBloombergIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromBloombergIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_bloomberg_index WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseFromMtjhMapping 煤炭江湖
- type BaseFromMtjhMapping struct {
- BaseFromMtjhMappingId int `orm:"column(base_from_mtjh_mapping_id);pk"`
- //ClassifyId int `description:"分类ID"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- LatestValue float64 `description:"最新值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (m *BaseFromMtjhMapping) SourceInfo() (int, int, string) {
- return utils.DATA_SOURCE_MTJH, 0, "煤炭江湖"
- }
- func (m *BaseFromMtjhMapping) EsCols() SearchEsCols {
- return SearchEsCols{
- PrimaryId: "base_from_mtjh_mapping_id",
- IndexCode: "index_code",
- IndexName: "index_name",
- ClassifyId: "",
- Unit: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "",
- }
- }
- func (m *BaseFromMtjhMapping) Format2SearchDataSource(origin *BaseFromMtjhMapping) (item *SearchDataSource) {
- if origin == nil {
- return
- }
- source, subSource, sourceName := m.SourceInfo()
- item = new(SearchDataSource)
- item.PrimaryId = origin.BaseFromMtjhMappingId
- item.IndexCode = origin.IndexCode
- item.IndexName = origin.IndexName
- //item.ClassifyId = origin.ClassifyId
- item.Unit = origin.Unit
- item.Frequency = origin.Frequency
- item.StartDate = utils.TimeTransferString(utils.FormatDate, origin.StartDate)
- item.EndDate = utils.TimeTransferString(utils.FormatDate, origin.EndDate)
- item.LatestValue = origin.LatestValue
- item.Source = source
- item.SubSource = subSource
- item.SourceName = sourceName
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- func (m *BaseFromMtjhMapping) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromMtjhMapping, err error) {
- o := orm.NewOrmUsingDB("data")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM base_from_mtjh_mapping WHERE 1=1 %s %s`, fields, condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // BaseIndexDataMinMax 数据源极值信息
- type BaseIndexDataMinMax struct {
- MinDate string `description:"最小日期"`
- MaxDate string `description:"最大日期"`
- LatestValue float64 `description:"最新值"`
- //MinValue float64 `description:"最小值"`
- //MaxValue float64 `description:"最大值"`
- }
- // GetBaseIndexDataTableName 根据来源获取原始指标表和数据表名(很大一部分来源不存在原始指标)
- func GetBaseIndexDataTableName(source, subSource int) (indexTable, dataTable string) {
- switch source {
- case utils.DATA_SOURCE_THS:
- if subSource == utils.DATA_SUB_SOURCE_HIGH_FREQUENCY {
- indexTable = "base_from_ths_hf_index"
- dataTable = "base_from_ths_hf_data"
- }
- case utils.DATA_SOURCE_RZD:
- indexTable = "base_from_rzd_index"
- dataTable = "base_from_rzd_data"
- case utils.DATA_SOURCE_HISUGAR:
- indexTable = "base_from_hisugar_index"
- dataTable = "base_from_hisugar_data"
- case utils.DATA_SOURCE_LY:
- indexTable = "base_from_ly_index"
- dataTable = "base_from_ly_data"
- case utils.DATA_SOURCE_SCI_HQ:
- indexTable = "base_from_sci_hq_index"
- dataTable = "base_from_sci_hq_data"
- case utils.DATA_SOURCE_OILCHEM:
- indexTable = "base_from_oilchem_index"
- dataTable = "base_from_oilchem_data"
- case utils.DATA_SOURCE_CCF:
- indexTable = "base_from_ccf_index"
- dataTable = "base_from_ccf_data"
- case utils.DATA_SOURCE_USDA_FAS:
- indexTable = "base_from_usda_fas_index"
- dataTable = "base_from_usda_fas_data"
- case utils.DATA_SOURCE_MYSTEEL_CHEMICAL:
- indexTable = "base_from_mysteel_chemical_index"
- dataTable = "base_from_mysteel_chemical_data"
- case utils.DATA_SOURCE_YS:
- indexTable = "base_from_smm_index"
- dataTable = "base_from_smm_data"
- case utils.DATA_SOURCE_BAIINFO:
- indexTable = "base_from_baiinfo_index"
- dataTable = "base_from_baiinfo_data"
- case utils.DATA_SOURCE_SCI:
- indexTable = "base_from_sci_index"
- dataTable = "base_from_sci_data"
- case utils.DATA_SOURCE_EIA_STEO:
- indexTable = "base_from_eia_steo_index"
- dataTable = "base_from_eia_steo_data"
- case utils.DATA_SOURCE_ICPI:
- indexTable = "base_from_icpi_index"
- dataTable = "base_from_icpi_data"
- case utils.DATA_SOURCE_YONYI:
- indexTable = "base_from_yongyi_index"
- dataTable = "base_from_yongyi_data"
- case utils.DATA_SOURCE_FENWEI:
- indexTable = "base_from_fenwei_index"
- dataTable = "base_from_fenwei_data"
- case utils.DATA_SOURCE_SCI99:
- indexTable = "base_from_icpi_index"
- dataTable = "base_from_icpi_data"
- case utils.DATA_SOURCE_BUSINESS:
- indexTable = "base_from_business_index"
- dataTable = "base_from_business_data"
- case utils.DATA_SOURCE_BLOOMBERG:
- indexTable = "base_from_bloomberg_index"
- dataTable = "base_from_bloomberg_data"
- default:
- utils.FileLog.Info(fmt.Sprintf("数据源无对应表名, source: %d, sub: %d", source, subSource))
- }
- return
- }
- // getCoalmineDataTableName 获取中国煤炭市场网数据表名
- func getCoalmineDataTableName(indexCode string) string {
- if strings.Contains(indexCode, "jsm") {
- return "base_from_coalmine_jsm_index"
- }
- if strings.Contains(indexCode, "company") {
- return "base_from_coalmine_company_index"
- }
- if strings.Contains(indexCode, "firm") {
- return "base_from_coalmine_firm_index"
- }
- if strings.Contains(indexCode, "coastal") {
- return "base_from_coalmine_coastal_index"
- }
- if strings.Contains(indexCode, "inland") {
- return "base_from_coalmine_inland_index"
- }
- return ""
- }
- // GetBaseIndexDataMinMax 获取数据源极值
- func GetBaseIndexDataMinMax(source, subSource int, indexCode string) (item *BaseIndexDataMinMax, err error) {
- o := orm.NewOrmUsingDB("data")
- var sql string
- var latestVal float64
- // 煤炭江湖
- if source == utils.DATA_SOURCE_MTJH {
- sql = `SELECT MIN(data_time) AS min_date, MAX(data_time) AS max_date FROM base_from_mtjh_index WHERE index_code = ?`
- if e := o.Raw(sql, indexCode).QueryRow(&item); e != nil {
- err = fmt.Errorf("获取数据源开始结束时间失败, %v", e)
- return
- }
- sql = `SELECT deal_value AS latest_value FROM base_from_mtjh_index WHERE index_code = ? ORDER BY data_time DESC LIMIT 1`
- if e := o.Raw(sql, indexCode).QueryRow(&latestVal); e != nil {
- err = fmt.Errorf("获取数据源最新值失败, %v", e)
- return
- }
- item.LatestValue = latestVal
- return
- }
- // 中国煤炭市场网
- if source == utils.DATA_SOURCE_COAL {
- dataTable := getCoalmineDataTableName(indexCode)
- if dataTable == "" {
- err = fmt.Errorf("中国煤炭市场网-指标无对应表名: %s", indexCode)
- return
- }
- fieldDataTime := "data_time"
- if dataTable == "base_from_coalmine_firm_index" {
- fieldDataTime = "data_time_date"
- }
- sql = `SELECT MIN(%s) AS min_date, MAX(%s) AS max_date FROM %s WHERE index_code = ?`
- sql = fmt.Sprintf(sql, fieldDataTime, fieldDataTime, dataTable)
- if e := o.Raw(sql, indexCode).QueryRow(&item); e != nil {
- err = fmt.Errorf("获取数据源开始结束时间失败, %v", e)
- return
- }
- sql = `SELECT deal_value AS latest_value FROM %s WHERE index_code = ? ORDER BY %s DESC LIMIT 1`
- sql = fmt.Sprintf(sql, dataTable, fieldDataTime)
- if e := o.Raw(sql, indexCode).QueryRow(&latestVal); e != nil {
- err = fmt.Errorf("获取数据源最新值失败, %v", e)
- return
- }
- item.LatestValue = latestVal
- return
- }
- // 其他数据源
- _, dataTable := GetBaseIndexDataTableName(source, subSource)
- if dataTable == "" {
- err = fmt.Errorf("数据源无对应数据表, source: %d, sub: %d, code: %s", source, subSource, indexCode)
- return
- }
- sql = `SELECT MIN(data_time) AS min_date, MAX(data_time) AS max_date FROM %s WHERE index_code = ?`
- sql = fmt.Sprintf(sql, dataTable)
- if e := o.Raw(sql, indexCode).QueryRow(&item); e != nil {
- err = fmt.Errorf("获取数据源开始结束时间失败, %v", e)
- return
- }
- sql = `SELECT value AS latest_value FROM %s WHERE index_code = ? ORDER BY data_time DESC LIMIT 1`
- sql = fmt.Sprintf(sql, dataTable)
- if e := o.Raw(sql, indexCode).QueryRow(&latestVal); e != nil {
- err = fmt.Errorf("获取数据源最新值失败, %v", e)
- return
- }
- item.LatestValue = latestVal
- return
- }
|