12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120 |
- package data_source
- import (
- "eta/eta_api/global"
- "eta/eta_api/utils"
- "fmt"
- "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 string `description:"最新值(部分数据源如中国煤炭网存在97%这种数据...)"`
- 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 `gorm:"column:base_from_rzd_index_id;primaryKey"`
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromHisugarIndex 泛糖科技
- type BaseFromHisugarIndex struct {
- BaseFromHisugarIndexId int `gorm:"column:base_from_hisugar_index_id;primaryKey"`
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromLyIndex 粮油商务网
- type BaseFromLyIndex struct {
- BaseFromLyIndexId int `gorm:"column:base_from_ly_index_id;primaryKey"`
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromSciHqIndex 卓创红期
- type BaseFromSciHqIndex struct {
- BaseFromSciHqIndexId int `gorm:"column:base_from_sci_hq_index_id;primaryKey"`
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromOilchemIndex 隆众资讯
- type BaseFromOilchemIndex struct {
- BaseFromOilchemIndexId int `gorm:"column:base_from_oilchem_index_id;primaryKey"`
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromThsHfIndex 同花顺高频数据
- type BaseFromThsHfIndex struct {
- BaseFromThsHfIndexId int `gorm:"column:base_from_ths_hf_index_id;primaryKey"`
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromCcfIndex CCF化纤信息
- type BaseFromCcfIndex struct {
- BaseFromCcfIndexId int `gorm:"column:base_from_ccf_index_id;primaryKey"`
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromUsdaFasIndex 美国农业部
- type BaseFromUsdaFasIndex struct {
- BaseFromUsdaFasIndexId int `gorm:"column:base_from_usda_fas_index_id;primaryKey"`
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromMysteelChemicalIndex 上海钢联
- type BaseFromMysteelChemicalIndex struct {
- BaseFromMysteelChemicalIndexId int `gorm:"column:base_from_mysteel_chemical_index_id;primaryKey"`
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromSmmIndex 有色原始数据库
- type BaseFromSmmIndex struct {
- BaseFromSmmIndexId int `gorm:"column:base_from_smm_index_id;primaryKey"`
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromBaiinfoIndex 百川盈孚
- type BaseFromBaiinfoIndex struct {
- BaseFromBaiinfoIndexId int `gorm:"column:base_from_baiinfo_index_id;primaryKey"`
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromSciIndex 卓创数据(红桃3)
- type BaseFromSciIndex struct {
- BaseFromSciIndexId int `gorm:"column:base_from_sci_index_id;primaryKey"`
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromCoalmineMapping 中国煤炭市场网
- type BaseFromCoalmineMapping struct {
- BaseFromCoalmineMappingId int `gorm:"column:base_from_coalmine_mapping_id;primaryKey"`
- 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 string `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: "unit",
- Frequency: "frequency",
- StartDate: "start_date",
- EndDate: "end_date",
- LatestValue: "latest_value",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- }
- 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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromEiaSteoIndex EIA STEO报告
- type BaseFromEiaSteoIndex struct {
- BaseFromEiaSteoIndexId int `gorm:"column:base_from_eia_steo_index_id;primaryKey"`
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromIcpiIndex ICPI消费价格指数
- //type BaseFromIcpiIndex struct {
- // BaseFromIcpiIndexId int `gorm:"column:base_from_icpi_index_id;primaryKey"`
- // 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromYongyiIndex 涌益咨询
- type BaseFromYongyiIndex struct {
- YongyiIndexId int `gorm:"column:yongyi_index_id;primaryKey"`
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromFenweiIndex 汾渭数据
- type BaseFromFenweiIndex struct {
- FenweiIndexId int `gorm:"column:fenwei_index_id;primaryKey"`
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromSci99Index 卓创资讯
- //type BaseFromSci99Index struct {
- // BaseFromSciIndexId int `gorm:"column:base_from_sci_index_id;primaryKey"`
- // 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromGlIndex 钢联原始指标库
- type BaseFromGlIndex struct {
- PrimaryId int `gorm:"column:ID;primaryKey"`
- IndexCode string `gorm:"column:INDEX_CODE" description:"指标编码"`
- IndexName string `gorm:"column:INDEX_NAME" description:"指标名称"`
- Unit string `gorm:"column:UNIT_NAME" description:"单位"`
- Frequency string `gorm:"column:FREQUENCY_NAME" description:"频度"`
- StartDate string `gorm:"column:BEGIN_DATE" description:"开始日期"`
- EndDate string `gorm:"column:END_DATE" description:"结束日期"`
- LatestValue float64 `gorm:"column:DATA_VALUE" description:"最新值"`
- CreateTime time.Time `gorm:"column:CREATE_TIME" description:"创建时间"`
- ModifyTime time.Time `gorm:"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 = origin.StartDate
- item.EndDate = origin.EndDate
- item.LatestValue = fmt.Sprint(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 := global.DbMap[utils.DbNameGL]
- 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...).Find(&items).Error
- return
- }
- // BaseFromManualEdb 手工数据录入
- type BaseFromManualEdb struct {
- //PrimaryId int `gorm:"column:TRADE_CODE)"` // 注手工指标没自增ID...
- IndexCode string `gorm:"column:TRADE_CODE" description:"指标编码"`
- IndexName string `gorm:"column:SEC_NAME" description:"指标名称"`
- ClassifyId int `gorm:"column:classify_id" description:"分类ID"`
- Unit string `gorm:"column:UNIT" description:"单位"`
- Frequency string `gorm:"column:frequency" description:"频度"`
- StartDate time.Time `gorm:"column:start_date" description:"开始日期"`
- EndDate time.Time `gorm:"column:end_date" description:"结束日期"`
- LatestValue float64 `gorm:"column:latest_value" description:"最新值"`
- CreateTime time.Time `gorm:"column:create_date" description:"创建时间"`
- ModifyTime time.Time `gorm:"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 = fmt.Sprint(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 := global.DbMap[utils.DbNameManualIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromBusinessIndex 自有数据
- type BaseFromBusinessIndex struct {
- BaseFromBusinessIndexId int `gorm:"column:base_from_business_index_id;primaryKey"`
- //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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromBloombergIndex Bloomberg
- type BaseFromBloombergIndex struct {
- BaseFromBloombergIndexId int `gorm:"column:base_from_bloomberg_index_id;primaryKey"`
- //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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseFromMtjhMapping 煤炭江湖
- type BaseFromMtjhMapping struct {
- BaseFromMtjhMappingId int `gorm:"column:base_from_mtjh_mapping_id;primaryKey"`
- //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: "modify_time",
- }
- }
- 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 = fmt.Sprint(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 := global.DbMap[utils.DbNameIndex]
- 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...).Find(&items).Error
- return
- }
- // BaseIndexDataMinMax 数据源极值信息
- type BaseIndexDataMinMax struct {
- MinDate string `description:"最小日期"`
- MaxDate string `description:"最大日期"`
- LatestValue string `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_sci99_index"
- dataTable = "base_from_sci99_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 := global.DbMap[utils.DbNameIndex]
- var sql string
- var latestVal string
- // 煤炭江湖
- 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 err = o.Raw(sql, indexCode).First(&item).Error; err != nil {
- return
- }
- sql = `SELECT deal_value AS latest_value FROM base_from_mtjh_index WHERE index_code = ? ORDER BY data_time DESC LIMIT 1`
- if err = o.Raw(sql, indexCode).Scan(&latestVal).Error; err != nil {
- 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 err = o.Raw(sql, indexCode).First(&item).Error; err != nil {
- 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 err = o.Raw(sql, indexCode).Scan(&latestVal).Error; err != nil {
- 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 err = o.Raw(sql, indexCode).First(&item).Error; err != nil {
- return
- }
- sql = `SELECT value AS latest_value FROM %s WHERE index_code = ? ORDER BY data_time DESC LIMIT 1`
- sql = fmt.Sprintf(sql, dataTable)
- sql = utils.ReplaceDriverKeywords("", sql)
- if err = o.Raw(sql, indexCode).Scan(&latestVal).Error; err != nil {
- return
- }
- item.LatestValue = latestVal
- return
- }
- // BaseFromMtjhIndex 煤炭江湖数据表
- type BaseFromMtjhIndex struct {
- BaseFromMtjhIndexId int `gorm:"column:base_from_mtjh_index_id;primaryKey"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- DealValue string `description:"成交量"`
- DataTime time.Time `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:"更新时间"`
- }
- // GetMtjhBaseInfoFromDataTable 煤炭江湖-从数据表获取基础信息
- func GetMtjhBaseInfoFromDataTable(codes []string) (items []*BaseFromMtjhIndex, err error) {
- codeLens := len(codes)
- if codeLens == 0 {
- return
- }
- sql := fmt.Sprintf(`SELECT * FROM base_from_mtjh_index WHERE index_code IN (%s) GROUP BY index_code`, utils.GetOrmInReplace(codeLens))
- err = global.DbMap[utils.DbNameIndex].Raw(sql, codes).Find(&items).Error
- return
- }
- // BaseFromCoalmineIndexBase 中国煤炭市场网数据表基础信息
- type BaseFromCoalmineIndexBase struct {
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频度"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- // GetCoalmineBaseInfoFromDataTable 中国煤炭市场网-从数据表获取基础信息
- func GetCoalmineBaseInfoFromDataTable(codes []string) (items []*BaseFromCoalmineIndexBase, err error) {
- codeLens := len(codes)
- if codeLens == 0 {
- return
- }
- o := global.DbMap[utils.DbNameIndex]
- items = make([]*BaseFromCoalmineIndexBase, 0)
- var jsmCodes, companyCodes, firmCodes, coastalCodes, inlandCodes []string
- for _, code := range codes {
- if strings.Contains(code, "jsm") {
- jsmCodes = append(jsmCodes, code)
- }
- if strings.Contains(code, "company") {
- companyCodes = append(companyCodes, code)
- }
- if strings.Contains(code, "firm") {
- firmCodes = append(firmCodes, code)
- }
- if strings.Contains(code, "coastal") {
- coastalCodes = append(coastalCodes, code)
- }
- if strings.Contains(code, "inland") {
- inlandCodes = append(inlandCodes, code)
- }
- }
- var sql string
- itemsOnce := make([]*BaseFromCoalmineIndexBase, 0)
- if len(jsmCodes) > 0 {
- sql = fmt.Sprintf(`SELECT * FROM base_from_coalmine_jsm_index WHERE index_code IN (%s) GROUP BY index_code`, utils.GetOrmInReplace(len(jsmCodes)))
- err = o.Raw(sql, jsmCodes).Find(&itemsOnce).Error
- if err != nil {
- return
- }
- items = append(items, itemsOnce...)
- }
- if len(companyCodes) > 0 {
- sql = fmt.Sprintf(`SELECT * FROM base_from_coalmine_company_index WHERE index_code IN (%s) GROUP BY index_code`, utils.GetOrmInReplace(len(companyCodes)))
- err = o.Raw(sql, companyCodes).Find(&itemsOnce).Error
- if err != nil {
- return
- }
- items = append(items, itemsOnce...)
- }
- if len(firmCodes) > 0 {
- sql = fmt.Sprintf(`SELECT * FROM base_from_coalmine_firm_index WHERE index_code IN (%s) GROUP BY index_code`, utils.GetOrmInReplace(len(firmCodes)))
- err = o.Raw(sql, firmCodes).Find(&itemsOnce).Error
- if err != nil {
- return
- }
- items = append(items, itemsOnce...)
- }
- if len(coastalCodes) > 0 {
- sql = fmt.Sprintf(`SELECT * FROM base_from_coalmine_coastal_index WHERE index_code IN (%s) GROUP BY index_code`, utils.GetOrmInReplace(len(coastalCodes)))
- err = o.Raw(sql, coastalCodes).Find(&itemsOnce).Error
- if err != nil {
- return
- }
- items = append(items, itemsOnce...)
- }
- if len(inlandCodes) > 0 {
- sql = fmt.Sprintf(`SELECT * FROM base_from_coalmine_inland_index WHERE index_code IN (%s) GROUP BY index_code`, utils.GetOrmInReplace(len(inlandCodes)))
- err = o.Raw(sql, inlandCodes).Find(&itemsOnce).Error
- if err != nil {
- return
- }
- items = append(items, itemsOnce...)
- }
- return
- }
|