|
@@ -1,14 +1,16 @@
|
|
|
package data_manage
|
|
|
|
|
|
import (
|
|
|
+ "eta/eta_api/global"
|
|
|
+ "eta/eta_api/utils"
|
|
|
"fmt"
|
|
|
- "github.com/beego/beego/v2/client/orm"
|
|
|
- "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"time"
|
|
|
+
|
|
|
+ "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
)
|
|
|
|
|
|
type BaseFromTradeShanghaiIndex struct {
|
|
|
- BaseFromTradeShangHaiIndexId int `orm:"column(base_from_trade_shanghai_index_id);pk"`
|
|
|
+ BaseFromTradeShangHaiIndexId int `orm:"column(base_from_trade_shanghai_index_id);pk" gorm:"primaryKey"`
|
|
|
Rank int
|
|
|
DealShortName string
|
|
|
DealName string
|
|
@@ -33,7 +35,7 @@ type BaseFromTradeShanghaiIndex struct {
|
|
|
DataTime string
|
|
|
}
|
|
|
type BaseFromTradeCffexIndex struct {
|
|
|
- BaseFromTradeCffexIndexId int `orm:"column(base_from_trade_cffex_index_id);pk"`
|
|
|
+ BaseFromTradeCffexIndexId int `orm:"column(base_from_trade_cffex_index_id);pk" gorm:"primaryKey"`
|
|
|
Rank int
|
|
|
DealShortName string
|
|
|
DealName string
|
|
@@ -59,7 +61,7 @@ type BaseFromTradeCffexIndex struct {
|
|
|
}
|
|
|
|
|
|
type BaseFromTradeIneIndex struct {
|
|
|
- BaseFromTradeIneIndexId int `orm:"column(base_from_trade_ine_index_id);pk"`
|
|
|
+ BaseFromTradeIneIndexId int `orm:"column(base_from_trade_ine_index_id);pk" gorm:"primaryKey"`
|
|
|
Rank int
|
|
|
DealShortName string
|
|
|
DealName string
|
|
@@ -85,7 +87,7 @@ type BaseFromTradeIneIndex struct {
|
|
|
}
|
|
|
|
|
|
type BaseFromTradeEicIndex struct {
|
|
|
- BaseFromEicIndexId int `orm:"column(base_from_eic_index_id);pk"`
|
|
|
+ BaseFromEicIndexId int `orm:"column(base_from_eic_index_id);pk" gorm:"primaryKey"`
|
|
|
Country string
|
|
|
Type string
|
|
|
EicCode string
|
|
@@ -115,95 +117,95 @@ type BaseFromTradeEicIndex struct {
|
|
|
}
|
|
|
|
|
|
func GetBaseFromTradeIndexByParam(exchange, date, classifyName, classifyType string) (list []*BaseFromTradeShanghaiIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
if classifyName == "" {
|
|
|
sql := "SELECT * FROM base_from_trade_" + exchange + "_index where data_time=?"
|
|
|
- _, err = o.Raw(sql, date).QueryRows(&list)
|
|
|
+ err = o.Raw(sql, date).Find(&list).Error
|
|
|
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)
|
|
|
+ err = o.Raw(sql, date, classifyName).Find(&list).Error
|
|
|
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)
|
|
|
+ err = o.Raw(sql, date, classifyName, classifyType).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func GetExchangeClassify(exchange, dataTime string) (classifyName []string, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, dataTime).Scan(&classifyName).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetLatestDate(exchange string) (dataTime string, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := "SELECT data_time FROM base_from_trade_" + exchange + "_index ORDER BY data_time desc limit 1"
|
|
|
- err = o.Raw(sql).QueryRow(&dataTime)
|
|
|
+ err = o.Raw(sql).Scan(&dataTime).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetExchangeClassifyContract(exchange, Classify, dataTime string) (classifyName []*string, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, Classify, dataTime).Scan(&classifyName).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetContinentEicDate(date string) (data []*BaseFromTradeEicIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := "SELECT * FROM base_from_trade_eic_index where gas_day_started_on=? and type='continent' "
|
|
|
- _, err = o.Raw(sql, date).QueryRows(&data)
|
|
|
+ err = o.Raw(sql, date).Find(&data).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetCountryEicDate(date string) (data []*BaseFromTradeEicIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := "SELECT * FROM base_from_trade_eic_index where gas_day_started_on=? and type='country' "
|
|
|
- _, err = o.Raw(sql, date).QueryRows(&data)
|
|
|
+ err = o.Raw(sql, date).Find(&data).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetSSOEicDate(date, country string) (data []*BaseFromTradeEicIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, date, country).Find(&data).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetStorageEicDate(date, country string) (data []*BaseFromTradeEicIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, date, country).Find(&data).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetEicDate() (date []*BaseFromTradeEicIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := "SELECT * FROM base_from_trade_eic_index ORDER BY gas_day_started_on desc limit 1"
|
|
|
- _, err = o.Raw(sql).QueryRows(&date)
|
|
|
+ err = o.Raw(sql).Find(&date).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetEicHistoryDate(code string) (date []*BaseFromTradeEicIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, code).Find(&date).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetEicHistoryDateByDate(code, startDate, endDate string) (date []*BaseFromTradeEicIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, code, startDate, endDate).Find(&date).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
type BaseFromCoalmineJsmIndex struct {
|
|
|
- BaseFromCoalmineJsmIndexId int `orm:"column(base_from_coalmine_jsm_index_id);pk"`
|
|
|
+ BaseFromCoalmineJsmIndexId int `orm:"column(base_from_coalmine_jsm_index_id);pk" gorm:"primaryKey"`
|
|
|
IndexName string `description:"持买单量指标名称"`
|
|
|
IndexCode string `description:"持买单量指标编码"`
|
|
|
Exchange string `description:"样本统计类别"`
|
|
@@ -220,14 +222,14 @@ type BaseFromCoalmineJsmIndex struct {
|
|
|
|
|
|
// GetBaseFromCoalmineIndex 查询数据
|
|
|
func GetBaseFromCoalmineIndex(startDate, endDate string) (items []*BaseFromCoalmineJsmIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT * FROM base_from_coalmine_jsm_index WHERE data_time between ? and ? `
|
|
|
- _, err = o.Raw(sql, startDate, endDate).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, startDate, endDate).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
type BaseFromCoalmineCompanyIndex struct {
|
|
|
- BaseFromCoalmineCompanyIndexId int `orm:"column(base_from_coalmine_company_index_id);pk"`
|
|
|
+ BaseFromCoalmineCompanyIndexId int `orm:"column(base_from_coalmine_company_index_id);pk" gorm:"primaryKey"`
|
|
|
IndexName string `description:"持买单量指标名称"`
|
|
|
IndexCode string `description:"持买单量指标编码"`
|
|
|
DealValue string `description:"成交量"`
|
|
@@ -244,15 +246,15 @@ type BaseFromCoalmineCompanyIndex struct {
|
|
|
|
|
|
// GetBaseFromCoalmineCompanyIndex 查询公司指标
|
|
|
func GetBaseFromCoalmineCompanyIndex(startDate, endDate string) (items []*BaseFromCoalmineCompanyIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT * FROM base_from_coalmine_company_index WHERE data_time between ? and ? `
|
|
|
- _, err = o.Raw(sql, startDate, endDate).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, startDate, endDate).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromCoalmineFirmIndex 煤矿产量周度公司数据表
|
|
|
type BaseFromCoalmineFirmIndex struct {
|
|
|
- BaseFromCoalmineFirmIndexID int `orm:"column(base_from_coalmine_firm_index_id);pk"`
|
|
|
+ BaseFromCoalmineFirmIndexID int `orm:"column(base_from_coalmine_firm_index_id);pk" gorm:"primaryKey"`
|
|
|
IndexName string // 省份/企业名称
|
|
|
IndexCode string // 持买单量指标编码
|
|
|
DataTime string // 指标时间
|
|
@@ -267,17 +269,17 @@ type BaseFromCoalmineFirmIndex struct {
|
|
|
|
|
|
// 查询指标
|
|
|
func GetBaseFromCoalmineFirmIndex(dataTime string) (items []*BaseFromCoalmineFirmIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT * FROM base_from_coalmine_firm_index WHERE data_time LIKE `
|
|
|
sql = sql + "'" + dataTime + "%" + "'"
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ err = o.Raw(sql).Find(&items).Error
|
|
|
fmt.Println(sql)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromCoalmineCoastalIndex 沿海八省动力煤用户供耗存数据指标表
|
|
|
type BaseFromCoalmineCoastalIndex struct {
|
|
|
- BaseFromCoalmineCoastalIndexID int `orm:"column(base_from_coalmine_coastal_index_id);pk"`
|
|
|
+ BaseFromCoalmineCoastalIndexID int `orm:"column(base_from_coalmine_coastal_index_id);pk" gorm:"primaryKey"`
|
|
|
IndexName string // 省份/企业名称
|
|
|
IndexCode string // 持买单量指标编码
|
|
|
DataTime string // 指标时间
|
|
@@ -292,15 +294,15 @@ type BaseFromCoalmineCoastalIndex struct {
|
|
|
|
|
|
// 查询指标
|
|
|
func GetBaseFromCoalmineCoastalIndex(startDate, endDate string) (items []*BaseFromCoalmineCoastalIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT * FROM base_from_coalmine_coastal_index WHERE data_time between ? and ? `
|
|
|
- _, err = o.Raw(sql, startDate, endDate).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, startDate, endDate).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromCoalmineInlandIndex 内陆动力煤用户供耗存数据指标表
|
|
|
type BaseFromCoalmineInlandIndex struct {
|
|
|
- BaseFromCoalmineInlandIndexID int `orm:"column(base_from_coalmine_inland_index_id);pk"`
|
|
|
+ BaseFromCoalmineInlandIndexID int `orm:"column(base_from_coalmine_inland_index_id);pk" gorm:"primaryKey"`
|
|
|
IndexName string // 省份/企业名称
|
|
|
IndexCode string // 持买单量指标编码
|
|
|
DataTime string // 指标时间
|
|
@@ -315,9 +317,9 @@ type BaseFromCoalmineInlandIndex struct {
|
|
|
|
|
|
// 查询指标
|
|
|
func GetBaseFromCoalmineInlandIndex(startDate, endDate string) (items []*BaseFromCoalmineInlandIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT * FROM base_from_coalmine_inland_index WHERE data_time between ? and ? `
|
|
|
- _, err = o.Raw(sql, startDate, endDate).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, startDate, endDate).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -374,232 +376,232 @@ type FrequencyResp struct {
|
|
|
|
|
|
// GetFrequencyFromCoal 获取指标信息
|
|
|
func GetFrequencyFromCoal(suffix string) (list *string, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT DISTINCT frequency FROM base_from_coalmine_%s `
|
|
|
sql = fmt.Sprintf(sql, suffix)
|
|
|
- err = o.Raw(sql).QueryRow(&list)
|
|
|
+ err = o.Raw(sql).Scan(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询数据
|
|
|
func GetBaseFromCoalmineIndexByFrequency(frequency, groupName string) (items []*BaseFromCoalmineJsmIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT * FROM base_from_coalmine_jsm_index WHERE frequency=? AND province=?`
|
|
|
- _, err = o.Raw(sql, frequency, groupName).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, frequency, groupName).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询数据
|
|
|
func GetGroupNameFromCoalmineIndex(suffix string) (items []*string, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT DISTINCT group_name FROM base_from_coalmine_%s `
|
|
|
sql = fmt.Sprintf(sql, suffix)
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ err = o.Raw(sql).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询数据
|
|
|
func GetProvinceFromCoalmineIndex(suffix string) (items []*string, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT DISTINCT province FROM base_from_coalmine_%s `
|
|
|
sql = fmt.Sprintf(sql, suffix)
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ err = o.Raw(sql).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询数据
|
|
|
func GetClassifyCoalmineIndexByGroupName(groupName string) (items []*string, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT DISTINCT index_code FROM base_from_coalmine_jsm_index WHERE province=? `
|
|
|
- _, err = o.Raw(sql, groupName).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, groupName).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询数据
|
|
|
func GetPageFromCoalmineIndexByFrequency(frequency, classify string, startSize, pageSize int) (items []*BaseFromCoalmineJsmIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, frequency, classify, startSize, pageSize).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询数据
|
|
|
func GetCountFromJsm(indexCode string) (item int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT COUNT(1) FROM base_from_coalmine_jsm_index WHERE index_code=? `
|
|
|
- err = o.Raw(sql, indexCode).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, indexCode).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetClassifyCompanyByGroupName(groupName string) (items []*string, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT DISTINCT index_code FROM base_from_coalmine_company_index WHERE group_name=? `
|
|
|
- _, err = o.Raw(sql, groupName).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, groupName).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetClassifyJsmByGroupName(groupName string) (items []*string, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT DISTINCT index_code FROM base_from_coalmine_jsm_index WHERE province=? `
|
|
|
- _, err = o.Raw(sql, groupName).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, groupName).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询公司指标
|
|
|
func GetPageFromCoalmineCompanyIndexByFrequency(frequency, classify string, startSize, pageSize int) (items []*BaseFromCoalmineCompanyIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, frequency, classify, startSize, pageSize).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetCountFromCompany(indexCode string) (item int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT COUNT(1) FROM base_from_coalmine_company_index WHERE index_code=? `
|
|
|
- err = o.Raw(sql, indexCode).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, indexCode).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetCountFromFirm(indexCode string) (item int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT COUNT(1) FROM base_from_coalmine_firm_index WHERE index_code=? `
|
|
|
- err = o.Raw(sql, indexCode).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, indexCode).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetClassifyFirmByGroupName(groupName string) (items []*string, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT DISTINCT index_code FROM base_from_coalmine_firm_index WHERE group_name=? `
|
|
|
- _, err = o.Raw(sql, groupName).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, groupName).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询指标
|
|
|
func GetPageFromCoalmineFirmIndexByFrequency(frequency, classify string, startSize, pageSize int) (items []*BaseFromCoalmineFirmIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, frequency, classify, startSize, pageSize).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetCountFromCoastal(indexCode string) (item int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT COUNT(1) FROM base_from_coalmine_coastal_index WHERE index_code=? `
|
|
|
- err = o.Raw(sql, indexCode).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, indexCode).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetClassifyCoastalByGroupName(groupName string) (items []*string, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT DISTINCT index_code FROM base_from_coalmine_coastal_index WHERE group_name=? `
|
|
|
- _, err = o.Raw(sql, groupName).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, groupName).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询指标
|
|
|
func GetPageFromCoalmineCoastalIndexByFrequency(frequency, classify string, startSize, pageSize int) (items []*BaseFromCoalmineCoastalIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, frequency, classify, startSize, pageSize).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetCountFromInland(indexCode string) (item int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT COUNT(1) FROM base_from_coalmine_inland_index WHERE index_code=? `
|
|
|
- err = o.Raw(sql, indexCode).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, indexCode).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetClassifyInlandByGroupName(groupName string) (items []*string, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT DISTINCT index_code FROM base_from_coalmine_inland_index WHERE group_name=? `
|
|
|
- _, err = o.Raw(sql, groupName).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, groupName).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询指标
|
|
|
func GetPageFromCoalmineInlandIndexByFrequency(frequency, classify string, startSize, pageSize int) (items []*BaseFromCoalmineInlandIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, frequency, classify, startSize, pageSize).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询公司指标
|
|
|
func GetBaseFromCoalmineCompanyIndexByFrequency(frequency, groupName string) (items []*BaseFromCoalmineCompanyIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT * FROM base_from_coalmine_company_index WHERE frequency=? AND group_name=? `
|
|
|
- _, err = o.Raw(sql, frequency, groupName).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, frequency, groupName).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询指标
|
|
|
func GetBaseFromCoalmineFirmIndexByFrequency(frequency, groupName string) (items []*BaseFromCoalmineFirmIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT * FROM base_from_coalmine_firm_index WHERE frequency=? AND group_name=? `
|
|
|
- _, err = o.Raw(sql, frequency, groupName).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, frequency, groupName).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询指标
|
|
|
func GetBaseFromCoalmineCoastalIndexByFrequency(frequency, groupName string) (items []*BaseFromCoalmineCoastalIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT * FROM base_from_coalmine_coastal_index WHERE frequency=? AND group_name=? `
|
|
|
- _, err = o.Raw(sql, frequency, groupName).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, frequency, groupName).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询指标
|
|
|
func GetBaseFromCoalmineInlandIndexByFrequency(frequency, groupName string) (items []*BaseFromCoalmineInlandIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT * FROM base_from_coalmine_inland_index WHERE frequency=? AND group_name=? `
|
|
|
- _, err = o.Raw(sql, frequency, groupName).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, frequency, groupName).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询数据
|
|
|
func GetBaseFromCoalmineIndexByCode(indexCode string) (items []*BaseFromCoalmineJsmIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT * FROM base_from_coalmine_jsm_index WHERE index_code=?`
|
|
|
- _, err = o.Raw(sql, indexCode).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, indexCode).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询公司指标
|
|
|
func GetBaseFromCoalmineCompanyIndexByCode(indexCode string) (items []*BaseFromCoalmineCompanyIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT * FROM base_from_coalmine_company_index WHERE index_code=? `
|
|
|
- _, err = o.Raw(sql, indexCode).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, indexCode).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询指标
|
|
|
func GetBaseFromCoalmineFirmIndexByCode(indexCode string) (items []*BaseFromCoalmineFirmIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT * FROM base_from_coalmine_firm_index WHERE index_code=? `
|
|
|
- _, err = o.Raw(sql, indexCode).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, indexCode).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询指标
|
|
|
func GetBaseFromCoalmineCoastalIndexByCode(indexCode string) (items []*BaseFromCoalmineCoastalIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT * FROM base_from_coalmine_coastal_index WHERE index_code=? `
|
|
|
- _, err = o.Raw(sql, indexCode).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, indexCode).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 查询指标
|
|
|
func GetBaseFromCoalmineInlandIndexByCode(indexCode string) (items []*BaseFromCoalmineInlandIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := `SELECT * FROM base_from_coalmine_inland_index WHERE index_code=? `
|
|
|
- _, err = o.Raw(sql, indexCode).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, indexCode).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
type BaseFromTradeEicIndexV2 struct {
|
|
|
- BaseFromEicIndexId int `orm:"column(base_from_eic_index_id);pk"`
|
|
|
+ BaseFromEicIndexId int `orm:"column(base_from_eic_index_id);pk" gorm:"primaryKey"`
|
|
|
Type string
|
|
|
EicCode string
|
|
|
Name string
|
|
@@ -633,71 +635,71 @@ type BaseFromTradeEicIndexV2 struct {
|
|
|
}
|
|
|
|
|
|
func GetEicDateV2() (date []*BaseFromTradeEicIndexV2, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := "SELECT * FROM base_from_trade_eic_index_v2 ORDER BY gas_day_start desc limit 1"
|
|
|
- _, err = o.Raw(sql).QueryRows(&date)
|
|
|
+ err = o.Raw(sql).Find(&date).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetEicDataV2(date string) (data []*BaseFromTradeEicIndexV2, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := "SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start=? "
|
|
|
- _, err = o.Raw(sql, date).QueryRows(&data)
|
|
|
+ err = o.Raw(sql, date).Find(&data).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetEicHistoryDateByDateV2(code, startDate, endDate string) (date []*BaseFromTradeEicIndexV2, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, code, startDate, endDate).Find(&date).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetEicHistoryDateV2(code string) (date []*BaseFromTradeEicIndexV2, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, code).Find(&date).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetContinentAndCountryEicDateV2(date string) (data []*BaseFromTradeEicIndexV2, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, date).Find(&data).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetSSOAndFacEicDateV2(date, name string) (data []*BaseFromTradeEicIndexV2, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, date).Find(&data).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetBaseFromTradeIndexByDate(exchange, startDate, endDate string) (list []*BaseFromTradeShanghaiIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
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)
|
|
|
+ err = o.Raw(sql, startDate, endDate).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetFirstBaseFromTradeIndexByDate(exchange string) (item *BaseFromTradeShanghaiIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := "SELECT * FROM base_from_trade_" + exchange + "_index where `rank` < 50 order by data_time asc"
|
|
|
- err = o.Raw(sql).QueryRow(&item)
|
|
|
+ err = o.Raw(sql).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
type BaseFromCoalmineClassify struct {
|
|
|
- BaseFromCoalmineClassifyId int `orm:"column(base_from_coalmine_classify_id);pk"`
|
|
|
+ BaseFromCoalmineClassifyId int `orm:"column(base_from_coalmine_classify_id);pk" gorm:"primaryKey"`
|
|
|
ClassifyName string // 分类名称
|
|
|
Suffix string // 表名后缀
|
|
|
CreateTime time.Time
|
|
|
}
|
|
|
|
|
|
func GetCoalmineClassifyList() (list []*BaseFromCoalmineClassify, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := "SELECT * FROM base_from_coalmine_classify"
|
|
|
- _,err = o.Raw(sql).QueryRows(&list)
|
|
|
+ err = o.Raw(sql).Find(&list).Error
|
|
|
return
|
|
|
}
|