123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703 |
- package data_manage
- import (
- "fmt"
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "time"
- )
- type BaseFromTradeShanghaiIndex struct {
- BaseFromTradeShangHaiIndexId int `orm:"column(base_from_trade_shanghai_index_id);pk"`
- Rank int
- DealShortName string
- DealName string
- DealCode string
- DealValue string
- DealChange string
- BuyShortName string
- BuyName string
- BuyCode string
- BuyValue string
- BuyChange string
- SoldShortName string
- SoldName string
- SoldCode string
- SoldValue string
- SoldChange string
- Frequency string
- ClassifyName string
- ClassifyType string
- CreateTime time.Time
- ModifyTime time.Time
- DataTime string
- }
- type BaseFromTradeCffexIndex struct {
- BaseFromTradeCffexIndexId int `orm:"column(base_from_trade_cffex_index_id);pk"`
- Rank int
- DealShortName string
- DealName string
- DealCode string
- DealValue string
- DealChange string
- BuyShortName string
- BuyName string
- BuyCode string
- BuyValue string
- BuyChange string
- SoldShortName string
- SoldName string
- SoldCode string
- SoldValue string
- SoldChange string
- Frequency string
- ClassifyName string
- ClassifyType string
- CreateTime time.Time
- ModifyTime time.Time
- DataTime string
- }
- type BaseFromTradeIneIndex struct {
- BaseFromTradeIneIndexId int `orm:"column(base_from_trade_ine_index_id);pk"`
- Rank int
- DealShortName string
- DealName string
- DealCode string
- DealValue string
- DealChange string
- BuyShortName string
- BuyName string
- BuyCode string
- BuyValue string
- BuyChange string
- SoldShortName string
- SoldName string
- SoldCode string
- SoldValue string
- SoldChange string
- Frequency string
- ClassifyName string
- ClassifyType string
- CreateTime time.Time
- ModifyTime time.Time
- DataTime string
- }
- type BaseFromTradeEicIndex struct {
- BaseFromEicIndexId int `orm:"column(base_from_eic_index_id);pk"`
- Country string
- Type string
- EicCode string
- ShortName string
- Name string
- Status string
- GasDayStartedOn string
- GasInStorage string
- GasInStorageCode string
- Full string
- FullCode string
- Trend string
- TrendCode string
- Injection string
- InjectionCode string
- Withdrawal string
- WithdrawalCode string
- WorkingGasVolume string
- WorkingGasVolumeCode string
- InjectionCapacity string
- InjectionCapacityCode string
- WithdrawalCapacity string
- WithdrawalCapacityCode string
- Info string
- CreateTime time.Time
- ModifyTime time.Time
- }
- func GetBaseFromTradeIndexByParam(exchange, date, classifyName, classifyType string) (list []*BaseFromTradeShanghaiIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- if classifyName == "" {
- sql := "SELECT * FROM base_from_trade_" + exchange + "_index where data_time=?"
- _, err = o.Raw(sql, date).QueryRows(&list)
- return
- } else if classifyType == "" {
- sql := "SELECT * FROM base_from_trade_" + exchange + "_index where data_time=? and classify_name=? ORDER BY classify_type,`rank`"
- _, err = o.Raw(sql, date, classifyName).QueryRows(&list)
- return
- } else {
- sql := "SELECT * FROM base_from_trade_" + exchange + "_index where data_time=? and classify_name=? and classify_type=?"
- _, err = o.Raw(sql, date, classifyName, classifyType).QueryRows(&list)
- return
- }
- }
- func GetExchangeClassify(exchange, dataTime string) (classifyName []string, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT DISTINCT classify_name FROM base_from_trade_" + exchange + "_index where data_time=? ORDER BY CONVERT(classify_name using gbk) DESC"
- _, err = o.Raw(sql, dataTime).QueryRows(&classifyName)
- return
- }
- func GetLatestDate(exchange string) (dataTime string, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT data_time FROM base_from_trade_" + exchange + "_index ORDER BY data_time desc limit 1"
- err = o.Raw(sql).QueryRow(&dataTime)
- return
- }
- func GetExchangeClassifyContract(exchange, Classify, dataTime string) (classifyName []*string, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT DISTINCT classify_type FROM base_from_trade_" + exchange + "_index where classify_name=? and data_time=?"
- _, err = o.Raw(sql, Classify, dataTime).QueryRows(&classifyName)
- return
- }
- func GetContinentEicDate(date string) (data []*BaseFromTradeEicIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_trade_eic_index where gas_day_started_on=? and type='continent' "
- _, err = o.Raw(sql, date).QueryRows(&data)
- return
- }
- func GetCountryEicDate(date string) (data []*BaseFromTradeEicIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_trade_eic_index where gas_day_started_on=? and type='country' "
- _, err = o.Raw(sql, date).QueryRows(&data)
- return
- }
- func GetSSOEicDate(date, country string) (data []*BaseFromTradeEicIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_trade_eic_index where gas_day_started_on=? and country=? and type='SSO' "
- _, err = o.Raw(sql, date, country).QueryRows(&data)
- return
- }
- func GetStorageEicDate(date, country string) (data []*BaseFromTradeEicIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_trade_eic_index where gas_day_started_on=? and country=? " +
- " and (type='Storage Facility' or type='Storage Group') "
- _, err = o.Raw(sql, date, country).QueryRows(&data)
- return
- }
- func GetEicDate() (date []*BaseFromTradeEicIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_trade_eic_index ORDER BY gas_day_started_on desc limit 1"
- _, err = o.Raw(sql).QueryRows(&date)
- return
- }
- func GetEicHistoryDate(code string) (date []*BaseFromTradeEicIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_trade_eic_index WHERE eic_code=? ORDER BY gas_day_started_on desc limit 30"
- _, err = o.Raw(sql, code).QueryRows(&date)
- return
- }
- func GetEicHistoryDateByDate(code, startDate, endDate string) (date []*BaseFromTradeEicIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_trade_eic_index WHERE eic_code=? and gas_day_started_on between ? and ? ORDER BY gas_day_started_on desc"
- _, err = o.Raw(sql, code, startDate, endDate).QueryRows(&date)
- return
- }
- type BaseFromCoalmineJsmIndex struct {
- BaseFromCoalmineJsmIndexId int `orm:"column(base_from_coalmine_jsm_index_id);pk"`
- IndexName string `description:"持买单量指标名称"`
- IndexCode string `description:"持买单量指标编码"`
- Exchange string `description:"样本统计类别"`
- DealValue string `description:"成交量"`
- DataTime string `description:"数据日期"`
- Source string `description:"来源"`
- Province string `description:"省份"`
- Description string `description:"描述"`
- Unit string `description:"单位"`
- Frequency string `description:"频率"`
- CreateTime string `description:"插入时间"`
- ModifyTime string `description:"修改时间"`
- }
- // GetBaseFromCoalmineIndex 查询数据
- func GetBaseFromCoalmineIndex(startDate, endDate string) (items []*BaseFromCoalmineJsmIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_jsm_index WHERE data_time between ? and ? `
- _, err = o.Raw(sql, startDate, endDate).QueryRows(&items)
- return
- }
- type BaseFromCoalmineCompanyIndex struct {
- BaseFromCoalmineCompanyIndexId int `orm:"column(base_from_coalmine_company_index_id);pk"`
- IndexName string `description:"持买单量指标名称"`
- IndexCode string `description:"持买单量指标编码"`
- DealValue string `description:"成交量"`
- DataTime string `description:"数据日期"`
- Source string `description:"来源"`
- Province string `description:"省份"`
- City string `description:"城市"`
- GroupName string `description:"集团名称"`
- Unit string `description:"单位"`
- Frequency string `description:"频率"`
- CreateTime string `description:"插入时间"`
- ModifyTime string `description:"修改时间"`
- }
- // GetBaseFromCoalmineCompanyIndex 查询公司指标
- func GetBaseFromCoalmineCompanyIndex(startDate, endDate string) (items []*BaseFromCoalmineCompanyIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_company_index WHERE data_time between ? and ? `
- _, err = o.Raw(sql, startDate, endDate).QueryRows(&items)
- return
- }
- // BaseFromCoalmineFirmIndex 煤矿产量周度公司数据表
- type BaseFromCoalmineFirmIndex struct {
- BaseFromCoalmineFirmIndexID int `orm:"column(base_from_coalmine_firm_index_id);pk"`
- IndexName string // 省份/企业名称
- IndexCode string // 持买单量指标编码
- DataTime string // 指标时间
- DealValue string // 数据量
- GroupName string // 集团名
- Source string // 来源
- Unit string // 来源
- Frequency string `description:"频率"`
- CreateTime string `description:"插入时间"`
- ModifyTime string `description:"修改时间"`
- }
- // 查询指标
- func GetBaseFromCoalmineFirmIndex(dataTime string) (items []*BaseFromCoalmineFirmIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_firm_index WHERE data_time LIKE `
- sql = sql + "'" + dataTime + "%" + "'"
- _, err = o.Raw(sql).QueryRows(&items)
- fmt.Println(sql)
- return
- }
- // BaseFromCoalmineCoastalIndex 沿海八省动力煤用户供耗存数据指标表
- type BaseFromCoalmineCoastalIndex struct {
- BaseFromCoalmineCoastalIndexID int `orm:"column(base_from_coalmine_coastal_index_id);pk"`
- IndexName string // 省份/企业名称
- IndexCode string // 持买单量指标编码
- DataTime string // 指标时间
- DealValue string // 数据量
- GroupName string // 地区
- Source string // 来源
- Unit string //单位
- Frequency string `description:"频率"`
- CreateTime string `description:"插入时间"`
- ModifyTime string `description:"修改时间"`
- }
- // 查询指标
- func GetBaseFromCoalmineCoastalIndex(startDate, endDate string) (items []*BaseFromCoalmineCoastalIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_coastal_index WHERE data_time between ? and ? `
- _, err = o.Raw(sql, startDate, endDate).QueryRows(&items)
- return
- }
- // BaseFromCoalmineInlandIndex 内陆动力煤用户供耗存数据指标表
- type BaseFromCoalmineInlandIndex struct {
- BaseFromCoalmineInlandIndexID int `orm:"column(base_from_coalmine_inland_index_id);pk"`
- IndexName string // 省份/企业名称
- IndexCode string // 持买单量指标编码
- DataTime string // 指标时间
- DealValue string // 数据量
- GroupName string // 地区
- Source string // 来源
- Unit string // 来源
- Frequency string `description:"频率"`
- CreateTime string `description:"插入时间"`
- ModifyTime string `description:"修改时间"`
- }
- // 查询指标
- func GetBaseFromCoalmineInlandIndex(startDate, endDate string) (items []*BaseFromCoalmineInlandIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_inland_index WHERE data_time between ? and ? `
- _, err = o.Raw(sql, startDate, endDate).QueryRows(&items)
- return
- }
- type BaseFromCoalmineClassifyItem struct {
- ClassifyId int
- ClassifyName string
- Child []CoalChild
- }
- type CoalChild struct {
- ClassifyId int
- ClassifyName string
- }
- type CoalmineDataResp struct {
- IndexName string
- IndexCode string // 持买单量指标编码
- Unit string // 来源
- Frequency string
- ModifyTime string
- DataList []DataList
- }
- type CoalmineDataPageResp struct {
- IndexName string
- IndexCode string // 持买单量指标编码
- Unit string // 来源
- Frequency string
- ModifyTime string
- Paging *paging.PagingItem `description:"分页数据"`
- DataList []DataList
- }
- type CoalmineSingalDataResp struct {
- IndexName string
- IndexCode string // 持买单量指标编码
- Unit string // 来源
- GroupId int // 二级id
- GroupName string // 二级名称
- Frequency string
- ModifyTime string
- ClassifyId int
- DataList []DataList
- }
- type DataList struct {
- Value string
- DataTime string
- }
- type FrequencyResp struct {
- Frequency int
- }
- // GetFrequencyFromCoal 获取指标信息
- func GetFrequencyFromCoal(suffix string) (list *string, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT DISTINCT frequency FROM base_from_coalmine_%s `
- sql = fmt.Sprintf(sql, suffix)
- err = o.Raw(sql).QueryRow(&list)
- return
- }
- // 查询数据
- func GetBaseFromCoalmineIndexByFrequency(frequency, groupName string) (items []*BaseFromCoalmineJsmIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_jsm_index WHERE frequency=? AND province=?`
- _, err = o.Raw(sql, frequency, groupName).QueryRows(&items)
- return
- }
- // 查询数据
- func GetGroupNameFromCoalmineIndex(suffix string) (items []*string, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT DISTINCT group_name FROM base_from_coalmine_%s `
- sql = fmt.Sprintf(sql, suffix)
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- // 查询数据
- func GetProvinceFromCoalmineIndex(suffix string) (items []*string, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT DISTINCT province FROM base_from_coalmine_%s `
- sql = fmt.Sprintf(sql, suffix)
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- // 查询数据
- func GetClassifyCoalmineIndexByGroupName(groupName string) (items []*string, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT DISTINCT index_code FROM base_from_coalmine_jsm_index WHERE province=? `
- _, err = o.Raw(sql, groupName).QueryRows(&items)
- return
- }
- // 查询数据
- func GetPageFromCoalmineIndexByFrequency(frequency, classify string, startSize, pageSize int) (items []*BaseFromCoalmineJsmIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_jsm_index WHERE frequency=? AND index_code=? ORDER BY data_time DESC LIMIT ?,? `
- _, err = o.Raw(sql, frequency, classify, startSize, pageSize).QueryRows(&items)
- return
- }
- // 查询数据
- func GetCountFromJsm(indexCode string) (item int, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT COUNT(1) FROM base_from_coalmine_jsm_index WHERE index_code=? `
- err = o.Raw(sql, indexCode).QueryRow(&item)
- return
- }
- func GetClassifyCompanyByGroupName(groupName string) (items []*string, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT DISTINCT index_code FROM base_from_coalmine_company_index WHERE group_name=? `
- _, err = o.Raw(sql, groupName).QueryRows(&items)
- return
- }
- func GetClassifyJsmByGroupName(groupName string) (items []*string, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT DISTINCT index_code FROM base_from_coalmine_jsm_index WHERE province=? `
- _, err = o.Raw(sql, groupName).QueryRows(&items)
- return
- }
- // 查询公司指标
- func GetPageFromCoalmineCompanyIndexByFrequency(frequency, classify string, startSize, pageSize int) (items []*BaseFromCoalmineCompanyIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_company_index WHERE frequency=? AND index_code=? ORDER BY data_time DESC LIMIT ?,? `
- _, err = o.Raw(sql, frequency, classify, startSize, pageSize).QueryRows(&items)
- return
- }
- func GetCountFromCompany(indexCode string) (item int, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT COUNT(1) FROM base_from_coalmine_company_index WHERE index_code=? `
- err = o.Raw(sql, indexCode).QueryRow(&item)
- return
- }
- func GetCountFromFirm(indexCode string) (item int, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT COUNT(1) FROM base_from_coalmine_firm_index WHERE index_code=? `
- err = o.Raw(sql, indexCode).QueryRow(&item)
- return
- }
- func GetClassifyFirmByGroupName(groupName string) (items []*string, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT DISTINCT index_code FROM base_from_coalmine_firm_index WHERE group_name=? `
- _, err = o.Raw(sql, groupName).QueryRows(&items)
- return
- }
- // 查询指标
- func GetPageFromCoalmineFirmIndexByFrequency(frequency, classify string, startSize, pageSize int) (items []*BaseFromCoalmineFirmIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_firm_index WHERE frequency=? AND index_code=? ORDER BY data_time DESC LIMIT ?,? `
- _, err = o.Raw(sql, frequency, classify, startSize, pageSize).QueryRows(&items)
- return
- }
- func GetCountFromCoastal(indexCode string) (item int, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT COUNT(1) FROM base_from_coalmine_coastal_index WHERE index_code=? `
- err = o.Raw(sql, indexCode).QueryRow(&item)
- return
- }
- func GetClassifyCoastalByGroupName(groupName string) (items []*string, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT DISTINCT index_code FROM base_from_coalmine_coastal_index WHERE group_name=? `
- _, err = o.Raw(sql, groupName).QueryRows(&items)
- return
- }
- // 查询指标
- func GetPageFromCoalmineCoastalIndexByFrequency(frequency, classify string, startSize, pageSize int) (items []*BaseFromCoalmineCoastalIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_coastal_index WHERE frequency=? AND index_code=? ORDER BY data_time DESC LIMIT ?,? `
- _, err = o.Raw(sql, frequency, classify, startSize, pageSize).QueryRows(&items)
- return
- }
- func GetCountFromInland(indexCode string) (item int, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT COUNT(1) FROM base_from_coalmine_inland_index WHERE index_code=? `
- err = o.Raw(sql, indexCode).QueryRow(&item)
- return
- }
- func GetClassifyInlandByGroupName(groupName string) (items []*string, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT DISTINCT index_code FROM base_from_coalmine_inland_index WHERE group_name=? `
- _, err = o.Raw(sql, groupName).QueryRows(&items)
- return
- }
- // 查询指标
- func GetPageFromCoalmineInlandIndexByFrequency(frequency, classify string, startSize, pageSize int) (items []*BaseFromCoalmineInlandIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_inland_index WHERE frequency=? AND index_code=? ORDER BY data_time DESC LIMIT ?,? `
- _, err = o.Raw(sql, frequency, classify, startSize, pageSize).QueryRows(&items)
- return
- }
- // 查询公司指标
- func GetBaseFromCoalmineCompanyIndexByFrequency(frequency, groupName string) (items []*BaseFromCoalmineCompanyIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_company_index WHERE frequency=? AND group_name=? `
- _, err = o.Raw(sql, frequency, groupName).QueryRows(&items)
- return
- }
- // 查询指标
- func GetBaseFromCoalmineFirmIndexByFrequency(frequency, groupName string) (items []*BaseFromCoalmineFirmIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_firm_index WHERE frequency=? AND group_name=? `
- _, err = o.Raw(sql, frequency, groupName).QueryRows(&items)
- return
- }
- // 查询指标
- func GetBaseFromCoalmineCoastalIndexByFrequency(frequency, groupName string) (items []*BaseFromCoalmineCoastalIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_coastal_index WHERE frequency=? AND group_name=? `
- _, err = o.Raw(sql, frequency, groupName).QueryRows(&items)
- return
- }
- // 查询指标
- func GetBaseFromCoalmineInlandIndexByFrequency(frequency, groupName string) (items []*BaseFromCoalmineInlandIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_inland_index WHERE frequency=? AND group_name=? `
- _, err = o.Raw(sql, frequency, groupName).QueryRows(&items)
- return
- }
- // 查询数据
- func GetBaseFromCoalmineIndexByCode(indexCode string) (items []*BaseFromCoalmineJsmIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_jsm_index WHERE index_code=?`
- _, err = o.Raw(sql, indexCode).QueryRows(&items)
- return
- }
- // 查询公司指标
- func GetBaseFromCoalmineCompanyIndexByCode(indexCode string) (items []*BaseFromCoalmineCompanyIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_company_index WHERE index_code=? `
- _, err = o.Raw(sql, indexCode).QueryRows(&items)
- return
- }
- // 查询指标
- func GetBaseFromCoalmineFirmIndexByCode(indexCode string) (items []*BaseFromCoalmineFirmIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_firm_index WHERE index_code=? `
- _, err = o.Raw(sql, indexCode).QueryRows(&items)
- return
- }
- // 查询指标
- func GetBaseFromCoalmineCoastalIndexByCode(indexCode string) (items []*BaseFromCoalmineCoastalIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_coastal_index WHERE index_code=? `
- _, err = o.Raw(sql, indexCode).QueryRows(&items)
- return
- }
- // 查询指标
- func GetBaseFromCoalmineInlandIndexByCode(indexCode string) (items []*BaseFromCoalmineInlandIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM base_from_coalmine_inland_index WHERE index_code=? `
- _, err = o.Raw(sql, indexCode).QueryRows(&items)
- return
- }
- type BaseFromTradeEicIndexV2 struct {
- BaseFromEicIndexId int `orm:"column(base_from_eic_index_id);pk"`
- Type string
- EicCode string
- Name string
- Status string
- GasDayStart string
- GasInStorage float64
- GasInStorageCode string
- Consumption string
- ConsumptionCode string
- ConsumptionFull string
- ConsumptionFullCode string
- Full float64
- FullCode string
- Trend float64
- TrendCode string
- Injection float64
- InjectionCode string
- Withdrawal float64
- WithdrawalCode string
- WorkingGasVolume float64
- WorkingGasVolumeCode string
- InjectionCapacity float64
- InjectionCapacityCode string
- WithdrawalCapacity float64
- WithdrawalCapacityCode string
- Info string
- Parent string
- CreateTime time.Time
- ModifyTime time.Time
- Children []BaseFromTradeEicIndexV2
- }
- func GetEicDateV2() (date []*BaseFromTradeEicIndexV2, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_trade_eic_index_v2 ORDER BY gas_day_start desc limit 1"
- _, err = o.Raw(sql).QueryRows(&date)
- return
- }
- func GetEicDataV2(date string) (data []*BaseFromTradeEicIndexV2, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start=? "
- _, err = o.Raw(sql, date).QueryRows(&data)
- return
- }
- func GetEicHistoryDateByDateV2(code, startDate, endDate string) (date []*BaseFromTradeEicIndexV2, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_trade_eic_index_v2 WHERE eic_code=? and gas_day_start between ? and ? ORDER BY gas_day_start desc"
- _, err = o.Raw(sql, code, startDate, endDate).QueryRows(&date)
- return
- }
- func GetEicHistoryDateV2(code string) (date []*BaseFromTradeEicIndexV2, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_trade_eic_index_v2 WHERE eic_code=? ORDER BY gas_day_start desc limit 30"
- _, err = o.Raw(sql, code).QueryRows(&date)
- return
- }
- func GetContinentAndCountryEicDateV2(date string) (data []*BaseFromTradeEicIndexV2, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start=? and (type='continent' OR type='country') "
- _, err = o.Raw(sql, date).QueryRows(&data)
- return
- }
- func GetSSOAndFacEicDateV2(date, name string) (data []*BaseFromTradeEicIndexV2, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start=? and (type='sso' OR type='fac') "
- _, err = o.Raw(sql, date).QueryRows(&data)
- return
- }
- func GetBaseFromTradeIndexByDate(exchange, startDate, endDate string) (list []*BaseFromTradeShanghaiIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_trade_" + exchange + "_index where `rank` < 50 and data_time between ? and ? order by data_time asc"
- _, err = o.Raw(sql, startDate, endDate).QueryRows(&list)
- return
- }
- func GetFirstBaseFromTradeIndexByDate(exchange string) (item *BaseFromTradeShanghaiIndex, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_trade_" + exchange + "_index where `rank` < 50 order by data_time asc"
- err = o.Raw(sql).QueryRow(&item)
- return
- }
- type BaseFromCoalmineClassify struct {
- BaseFromCoalmineClassifyId int `orm:"column(base_from_coalmine_classify_id);pk"`
- ClassifyName string // 分类名称
- Suffix string // 表名后缀
- CreateTime time.Time
- }
- func GetCoalmineClassifyList() (list []*BaseFromCoalmineClassify, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := "SELECT * FROM base_from_coalmine_classify"
- _,err = o.Raw(sql).QueryRows(&list)
- return
- }
|