Browse Source

fix:修复持仓分析库连接的问题

Roc 1 year ago
parent
commit
a995b9e320

+ 1 - 1
models/data_manage/base_from_trade_index.go

@@ -5,7 +5,7 @@ import (
 )
 
 func GetFirstBaseFromTradeIndexByDate(exchange string) (item *BaseFromTradeShanghaiIndex, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	sql := "SELECT * FROM base_from_trade_" + exchange + "_index where rank < 50 order by data_time asc"
 	err = o.Raw(sql).QueryRow(&item)
 	return

+ 12 - 12
models/data_manage/trade_position_analysis.go

@@ -45,7 +45,7 @@ type TradePositionIneTop struct {
 }
 
 func InsertMultiTradePositionTop(exchange string, items []*TradePositionTop) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	if exchange == "dalian" {
 		list := make([]*TradePositionDalianTop, 0)
 		for _, v := range items {
@@ -92,21 +92,21 @@ func InsertMultiTradePositionTop(exchange string, items []*TradePositionTop) (er
 }
 
 func GetTradePositionTopByExchangeDataTime(exchange string, startDate, endDate string) (list []*TradePositionTop, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	sql := "SELECT * FROM trade_position_" + exchange + "_top where data_time >= ? and data_time <= ? and deal_type in (1,2) ORDER BY classify_name, classify_type, deal_type, data_time, deal_value desc"
 	_, err = o.Raw(sql, startDate, endDate).QueryRows(&list)
 	return
 }
 
 func GetTradePositionTopCountByExchangeDataTime(exchange string, startDate, endDate string) (count int64, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	sql := "SELECT count(*) FROM trade_position_" + exchange + "_top where data_time >= ? and data_time <= ? and deal_type in (1,2) ORDER BY classify_name, classify_type, deal_type, data_time, deal_value desc"
 	err = o.Raw(sql, startDate, endDate).QueryRow(&count)
 	return
 }
 
 func GetTradePositionTopByExchangeSourceType(exchange string, dataTime string, sourceType int) (list []*TradePositionTop, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	sql := "SELECT * FROM trade_position_" + exchange + "_top where data_time= ? and source_type = ? ORDER BY classify_name, classify_type, deal_type, deal_value desc"
 	_, err = o.Raw(sql, dataTime, sourceType).QueryRows(&list)
 	return
@@ -149,7 +149,7 @@ type UpdateDealValueChange struct {
 }
 
 func MultiUpdatePositionTop(exchange string, updates []UpdateDealValueChange) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	p, err := o.Raw("UPDATE trade_position_" + exchange + "_top SET deal_value=?, deal_change=?, source_type=?, modify_time=? WHERE id = ?").Prepare()
 	if err != nil {
 		return
@@ -167,21 +167,21 @@ func MultiUpdatePositionTop(exchange string, updates []UpdateDealValueChange) (e
 }
 
 func DeletePositionTopByDataTime(exchange string, dataTime string, dealType int) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	sql := "delete from trade_position_" + exchange + "_Top WHERE data_time=? and deal_type=?"
 	_, err = o.Raw(sql, dataTime, dealType).Exec()
 	return
 }
 
 func GetTradePositionTopByExchangeDataTimeType(exchange string, dataTime string, dealType int) (list []TradePositionTop, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	sql := "select * from trade_position_" + exchange + "_Top WHERE data_time=? and deal_type=?"
 	_, err = o.Raw(sql, dataTime, dealType).QueryRows(&list)
 	return
 }
 
 func MultiInsertTradeBaseDataToTop(exchange string, startDate, endDate string) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	now := time.Now().Format(utils.FormatDateTime)
 	sql1 := `INSERT INTO trade_position_` + exchange + `_top(classify_name,classify_type,deal_short_name,deal_value,deal_change,data_time,deal_type,source_type,rank,create_time,modify_time)
 	SELECT classify_name,classify_type,buy_short_name,buy_value,buy_change,data_time,1,0,rank,?,? FROM base_from_trade_` + exchange + `_index where rank <50 and buy_short_name !="" and data_time between ? and ?`
@@ -197,7 +197,7 @@ SELECT classify_name,classify_type,sold_short_name,sold_value,sold_change,data_t
 
 // GetTradePositionTopOriginDataTimes 获取榜单原始数据日期-正序
 func GetTradePositionTopOriginDataTimes(exchange string) (dates []string, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	sql := `SELECT DISTINCT data_time FROM base_from_trade_%s_index ORDER BY data_time ASC`
 	sql = fmt.Sprintf(sql, exchange)
 	_, err = o.Raw(sql).QueryRows(&dates)
@@ -218,7 +218,7 @@ type BaseFromTradeClassify struct {
 func GetAllBaseFromTradeClassify() (list []BaseFromTradeClassify, err error) {
 	sql := `SELECT * FROM base_from_trade_classify   `
 
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	_, err = o.Raw(sql).QueryRows(&list)
 
 	return
@@ -229,7 +229,7 @@ func MultiAddBaseFromTradeClassify(items []*BaseFromTradeClassify) (err error) {
 	if len(items) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	_, err = o.InsertMulti(len(items), items)
 	return
 }
@@ -249,7 +249,7 @@ func GetExchangeClassify(exchange string) (list []TradeClassifyName, err error)
 	sql := `SELECT classify_name, classify_type FROM ` + tableName + ` WHERE rank <=20 and rank > 0 GROUP BY classify_name, classify_type  `
 	sql += ` ORDER BY ` + orderStr
 
-	o := orm.NewOrmUsingDB("data")
+	o := orm.NewOrm()
 	_, err = o.Raw(sql).QueryRows(&list)
 
 	return