xingzai 1 mēnesi atpakaļ
vecāks
revīzija
c71df3069d

+ 23 - 13
models/data_manage/com_trade_data.go

@@ -1,7 +1,8 @@
 package data_manage
 
 import (
-	"github.com/beego/beego/v2/client/orm"
+	"eta_gn/eta_task/global"
+	"eta_gn/eta_task/utils"
 	"time"
 )
 
@@ -29,36 +30,45 @@ type ComTradeData struct {
 
 // GetAllComTradeDataList 获取联合国商品贸易数据列表
 func GetAllComTradeDataList(startDate string) (list []*ComTradeData, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := `SELECT * FROM com_trade_data WHERE create_time>=?  ORDER BY com_trade_data_id ASC `
-	_, err = o.Raw(sql, startDate).QueryRows(&list)
+	//_, err = o.Raw(sql, startDate).QueryRows(&list)
+	err = global.DEFAULT_DmSQL.Raw(sql, startDate).Find(&list).Error
 
 	return
 }
 
 // AddBaseFromComTradeData 添加数据
 func AddBaseFromComTradeData(item *ComTradeData) (lastId int64, err error) {
-	o := orm.NewOrm()
-	lastId, err = o.Insert(item)
+	//o := orm.NewOrm()
+	//lastId, err = o.Insert(item)
+
+	err = global.DEFAULT_DmSQL.Create(item).Error
+	if err != nil {
+		return
+	}
+	lastId = int64(item.ComTradeDataId)
 	return
 }
 
 // MultiAddBaseFromComTradeData 批量添加数据
 func MultiAddBaseFromComTradeData(items []*ComTradeData) (lastId int64, err error) {
-	num := len(items)
-	if num <= 0 {
-		return
-	}
-	o := orm.NewOrm()
-	lastId, err = o.InsertMulti(num, items)
+	//num := len(items)
+	//if num <= 0 {
+	//	return
+	//}
+	//o := orm.NewOrm()
+	//lastId, err = o.InsertMulti(num, items)
 
+	err = global.DEFAULT_DmSQL.CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 // GetBaseFromComTradeMaxDate 获取un数据中的最大日期数据
 func GetBaseFromComTradeMaxDate() (max_date time.Time, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT max(a.create_time)as max_date FROM com_trade_data as a `
-	err = o.Raw(sql).QueryRow(&max_date)
+	//err = o.Raw(sql).QueryRow(&max_date)
+	err = global.DEFAULT_DmSQL.Raw(sql).Scan(&max_date).Error
 	return
 }

+ 27 - 12
models/data_manage/com_trade_index.go

@@ -1,7 +1,7 @@
 package data_manage
 
 import (
-	"github.com/beego/beego/v2/client/orm"
+	"eta_gn/eta_task/global"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"time"
 )
@@ -18,24 +18,32 @@ type ComTradeIndex struct {
 
 // GetAllComTradeIndexList 获取指标数据列表
 func GetAllComTradeIndexList(startDate string) (list []*ComTradeIndex, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := `SELECT * FROM com_trade_index WHERE create_time>=?  ORDER BY com_trade_id DESC `
-	_, err = o.Raw(sql, startDate).QueryRows(&list)
-
+	//_, err = o.Raw(sql, startDate).QueryRows(&list)
+	err = global.DEFAULT_DmSQL.Raw(sql, startDate).Find(&list).Error
 	return
 }
 
 func GetBaseFromComTradeCodeMappingAll(dateStr string) (list []*BaseFromEiaSteoIndex, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := `SELECT * FROM com_trade_index WHERE create_time>=?`
-	_, err = o.Raw(sql, dateStr).QueryRows(&list)
+	//_, err = o.Raw(sql, dateStr).QueryRows(&list)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, dateStr).Find(&list).Error
 	return
 }
 
 // AddBaseFromComTradeIndex 添加新的指标
 func AddBaseFromComTradeIndex(item *ComTradeIndex) (lastId int64, err error) {
-	o := orm.NewOrm()
-	lastId, err = o.Insert(item)
+	//o := orm.NewOrm()
+	//lastId, err = o.Insert(item)
+
+	err = global.DEFAULT_DmSQL.Create(item).Error
+	if err != nil {
+		return
+	}
+	lastId = int64(item.ComTradeId)
 	return
 }
 
@@ -50,17 +58,24 @@ type ComTradeCodeMapping struct {
 
 // GetAllComTradeCodeMappingList 获取联合国商品贸易数据指标编码与分类编码的关系列表
 func GetAllComTradeCodeMappingList(startDate string) (list []*ComTradeCodeMapping, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := `SELECT * FROM com_trade_code_mapping WHERE create_time>=?  ORDER BY create_time ASC `
-	_, err = o.Raw(sql, startDate).QueryRows(&list)
+	//_, err = o.Raw(sql, startDate).QueryRows(&list)
 
+	err = global.DEFAULT_DmSQL.Raw(sql, startDate).Find(&list).Error
 	return
 }
 
 // AddBaseFromComTradeCodeMapping 添加联合国商品贸易数据指标编码与分类编码的关系
 func AddBaseFromComTradeCodeMapping(item *ComTradeCodeMapping) (lastId int64, err error) {
-	o := orm.NewOrm()
-	lastId, err = o.Insert(item)
+	//o := orm.NewOrm()
+	//lastId, err = o.Insert(item)
+
+	err = global.DEFAULT_DmSQL.Create(item).Error
+	if err != nil {
+		return
+	}
+	//lastId = int64(item.Code)
 	return
 }
 

+ 4 - 4
models/data_manage/edb_classify.go

@@ -1,7 +1,7 @@
 package data_manage
 
 import (
-	"github.com/beego/beego/v2/client/orm"
+	"eta_gn/eta_task/global"
 	"time"
 )
 
@@ -32,13 +32,13 @@ type EdbClassify struct {
 // @return item []*EdbInfoUpdateLog
 // @return err error
 func GetAllEdbClassifyListByCondition(condition string, pars []interface{}) (item []*EdbClassify, err error) {
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT * FROM edb_classify WHERE 1=1 `
 	if condition != "" {
 		sql += condition
 	}
 	sql += `ORDER BY classify_id ASC `
-	_, err = o.Raw(sql, pars).QueryRows(&item)
-
+	//_, err = o.Raw(sql, pars).QueryRows(&item)
+	err = global.DmSQL["data"].Raw(sql, pars).Find(&item).Error
 	return
 }

+ 23 - 13
models/data_manage/edb_data_calculate.go

@@ -1,35 +1,43 @@
 package data_manage
 
 import (
+	"eta_gn/eta_task/global"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
 func GetEdbDataCalculateByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_calculate WHERE edb_code=? AND data_time=? `
-	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+	//err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode, startDate).Scan(&count).Error
 	return
 }
 
 func ModifyEdbDataCalculate(edbInfoId int64, dataTime string, value float64) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_data_calculate SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
-	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+	//_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, value, edbInfoId, dataTime).Error
 	return
 }
 
 func AddEdbDataCalculateBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Raw(sqlStr).Exec()
+	//o := orm.NewOrm()
+	//_, err = o.Raw(sqlStr).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sqlStr).Error
 	return
 }
 
 // DeleteEdbDataCalculateBySql 根据删除sql删除指标数据
 func DeleteEdbDataCalculateBySql(deleteStr string, edbInfoId int) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Raw(deleteStr, edbInfoId).Exec()
+	//o := orm.NewOrm()
+	//_, err = o.Raw(deleteStr, edbInfoId).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(deleteStr, edbInfoId).Error
 	return
 }
 
@@ -51,22 +59,24 @@ type EdbInfoCalculateDetail struct {
 }
 
 func GetEdbInfoCalculateDetail(edbInfoId int) (list []*EdbInfoCalculateDetail, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT a.*,b.start_date,b.end_date FROM edb_info_calculate_mapping AS a
 			INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
 			WHERE a.edb_info_id=? ORDER BY sort ASC `
-	_, err = o.Raw(sql, edbInfoId).QueryRows(&list)
+	//_, err = o.Raw(sql, edbInfoId).QueryRows(&list)
+	err = global.DEFAULT_DmSQL.Raw(sql, edbInfoId).Find(&list).Error
 	return
 }
 
 func GetEdbInfoCalculateMap(edbInfoId, source int) (list []*EdbInfoCalculateDetail, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 
 	calculateTableName := GetEdbInfoCalculateTableName(source)
 	sql := ` SELECT a.*,b.start_date,b.end_date,b.edb_type FROM %s AS a
 			INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
 			WHERE a.edb_info_id=? ORDER BY sort ASC `
 	sql = fmt.Sprintf(sql, calculateTableName)
-	_, err = o.Raw(sql, edbInfoId).QueryRows(&list)
+	//_, err = o.Raw(sql, edbInfoId).QueryRows(&list)
+	err = global.DEFAULT_DmSQL.Raw(sql, edbInfoId).Find(&list).Error
 	return
 }

+ 4 - 3
models/data_manage/edb_data_calculate_ljztbpj.go

@@ -1,7 +1,7 @@
 package data_manage
 
 import (
-	"github.com/beego/beego/v2/client/orm"
+	"eta_gn/eta_task/global"
 	"time"
 )
 
@@ -20,8 +20,9 @@ type EdbDataCalculateLjztbpj struct {
 
 // GetAllEdbDataCalculateLjztbpjByEdbInfoId 根据指标id获取全部的数据
 func GetAllEdbDataCalculateLjztbpjByEdbInfoId(edbInfoId int) (items []*EdbDataCalculateLjztbpj, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT * FROM edb_data_calculate_ljztbpj WHERE edb_info_id=? ORDER BY data_time DESC `
-	_, err = o.Raw(sql, edbInfoId).QueryRows(&items)
+	//_, err = o.Raw(sql, edbInfoId).QueryRows(&items)
+	err = global.DEFAULT_DmSQL.Raw(sql, edbInfoId).Find(&items).Error
 	return
 }

+ 5 - 3
models/data_manage/edb_data_calculate_zjpj.go

@@ -1,7 +1,7 @@
 package data_manage
 
 import (
-	"github.com/beego/beego/v2/client/orm"
+	"eta_gn/eta_task/global"
 	"time"
 )
 
@@ -20,8 +20,10 @@ type EdbDataCalculateZjpj struct {
 
 // GetAllEdbDataCalculateZjpjByEdbInfoId 根据指标id获取全部的数据
 func GetAllEdbDataCalculateZjpjByEdbInfoId(edbInfoId int) (items []*EdbDataCalculateZjpj, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT * FROM edb_data_calculate_zjpj WHERE edb_info_id=? ORDER BY data_time DESC `
-	_, err = o.Raw(sql, edbInfoId).QueryRows(&items)
+	//_, err = o.Raw(sql, edbInfoId).QueryRows(&items)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbInfoId).Find(&items).Error
 	return
 }

+ 34 - 20
models/data_manage/edb_data_cffex.go

@@ -1,9 +1,9 @@
 package data_manage
 
 import (
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -58,16 +58,16 @@ type BaseFromTradeCFFEXIndex struct {
 }
 
 func GetEdbDataCffexMaxOrMinDate(edbCode string) (minDate, maxDate string, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_cffex WHERE edb_code=? `
-	err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
+	//err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode).First(&minDate, &maxDate).Error
 	return
 }
 
 // RefreshEdbDataByCffex 刷新中金所指标数据
 func RefreshEdbDataByCffex(edbInfoId int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	tx, err := o.Begin()
+	tx := global.DEFAULT_DmSQL.Begin()
 	if err != nil {
 		return err
 	}
@@ -160,9 +160,13 @@ func RefreshEdbDataByCffex(edbInfoId int, edbCode, startDate, endDate string) (e
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = tx.Raw(addSql).Exec()
-		if err != nil {
-			return err
+		//_, err = tx.Raw(addSql).Exec()
+		//if err != nil {
+		//	return err
+		//}
+
+		if err = tx.Exec(addSql).Error; err != nil {
+			return
 		}
 	}
 	return
@@ -170,48 +174,58 @@ func RefreshEdbDataByCffex(edbInfoId int, edbCode, startDate, endDate string) (e
 
 // GetBaseInfoFromCffexByIndexCode 获取指标信息
 func GetBaseInfoFromCffexByIndexCode(indexCode, suffix string) (list []*BaseInfoFromCffex, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := `SELECT * FROM base_from_trade_cffex_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
-	_, err = o.Raw(sql, indexCode).QueryRows(&list)
+	//_, err = o.Raw(sql, indexCode).QueryRows(&list)
+	err = global.DEFAULT_DmSQL.Raw(sql, indexCode).Find(&list).Error
 	return
 }
 
 func GetCffexDataByTradeCode(condition string, pars []interface{}) (item []*BaseFromCffexDataSimple, err error) {
 	sql := ` SELECT * FROM base_from_trade_cffex_index WHERE 1=1 `
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	if condition != "" {
 		sql += condition
 	}
 	sql += ` ORDER BY data_time DESC `
-	_, err = o.Raw(sql, pars).QueryRows(&item)
+	//_, err = o.Raw(sql, pars).QueryRows(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).Find(&item).Error
 	return
 }
 
 func AddEdbDataCffexBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Raw(sqlStr).Exec()
+	//o := orm.NewOrm()
+	//_, err = o.Raw(sqlStr).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sqlStr).Error
 	return
 }
 
 func GetBaseFromCffexDataAllByIndexCode(indexCode, suffix string) (list []*BaseFromTradeCFFEXIndex, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := `SELECT * FROM base_from_trade_cffex_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
-	_, err = o.Raw(sql, indexCode).QueryRows(&list)
+	//_, err = o.Raw(sql, indexCode).QueryRows(&list)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, indexCode).Find(&list).Error
 	return
 }
 
 func GetEdbDataCffexByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_cffex WHERE edb_code=? AND data_time=? `
-	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+	//err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode, startDate).Scan(&count).Error
 	return
 }
 
 func ModifyEdbDataCffex(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_data_cffex SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
-	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+	//_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+	err = global.DEFAULT_DmSQL.Exec(sql, value, edbInfoId, dataTime).Error
 	return
 }

+ 36 - 20
models/data_manage/edb_data_dl.go

@@ -1,9 +1,9 @@
 package data_manage
 
 import (
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -32,16 +32,18 @@ type BaseInfoFromDl struct {
 }
 
 func GetEdbDataDlMaxOrMinDate(edbCode string) (minDate, maxDate string, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_dl WHERE edb_code=? `
-	err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
+	//err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode).First(&minDate, &maxDate).Error
 	return
 }
 
 // RefreshEdbDataByDl 刷新大商所指标数据
 func RefreshEdbDataByDl(edbInfoId int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	tx, err := o.Begin()
+	//o := orm.NewOrm()
+	//tx, err := o.Begin()
+	tx := global.DEFAULT_DmSQL.Begin()
 	if err != nil {
 		return err
 	}
@@ -134,58 +136,72 @@ func RefreshEdbDataByDl(edbInfoId int, edbCode, startDate, endDate string) (err
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = tx.Raw(addSql).Exec()
-		if err != nil {
-			return err
+		//_, err = tx.Raw(addSql).Exec()
+		//if err != nil {
+		//	return err
+		//}
+
+		if err = tx.Exec(addSql).Error; err != nil {
+			return
 		}
+
 	}
 	return
 }
 
 // GetBaseInfoFromDalianByIndexCode 获取指标信息
 func GetBaseInfoFromDalianByIndexCode(indexCode, suffix string) (list []*BaseInfoFromDl, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := `SELECT * FROM base_from_trade_dalian_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
-	_, err = o.Raw(sql, indexCode).QueryRows(&list)
+	//_, err = o.Raw(sql, indexCode).QueryRows(&list)
+	err = global.DEFAULT_DmSQL.Raw(sql, indexCode).Find(&list).Error
 	return
 }
 
 func GetDlDataByTradeCode(condition string, pars []interface{}) (item []*BaseFromDlDataSimple, err error) {
 	sql := ` SELECT * FROM base_from_trade_dalian_index WHERE 1=1 `
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	if condition != "" {
 		sql += condition
 	}
 	sql += ` ORDER BY data_time DESC `
-	_, err = o.Raw(sql, pars).QueryRows(&item)
+	//_, err = o.Raw(sql, pars).QueryRows(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).Find(&item).Error
 	return
 }
 
 func AddEdbDataDlBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Raw(sqlStr).Exec()
+	//o := orm.NewOrm()
+	//_, err = o.Raw(sqlStr).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sqlStr).Error
 	return
 }
 
 func GetBaseFromDalianDataAllByIndexCode(indexCode, suffix string) (list []*BaseFromTradeDalianIndex, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := `SELECT * FROM base_from_trade_dalian_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
-	_, err = o.Raw(sql, indexCode).QueryRows(&list)
+	//_, err = o.Raw(sql, indexCode).QueryRows(&list)
+	err = global.DEFAULT_DmSQL.Raw(sql, indexCode).Find(&list).Error
 	return
 }
 
 func GetEdbDataDlByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_dl WHERE edb_code=? AND data_time=? `
-	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+	//err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode, startDate).Scan(&count).Error
 	return
 }
 
 func ModifyEdbDataDl(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_data_dl SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
-	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+	//_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+	err = global.DEFAULT_DmSQL.Exec(sql, value, edbInfoId, dataTime).Error
 	return
 }

+ 30 - 17
models/data_manage/edb_data_gl.go

@@ -1,17 +1,19 @@
 package data_manage
 
 import (
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
 )
 
 func AddEdbDataGlBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Raw(sqlStr).Exec()
+	//o := orm.NewOrm()
+	//_, err = o.Raw(sqlStr).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sqlStr).Error
 	return
 }
 
@@ -29,37 +31,44 @@ func GetGlDataByTradeCode(condition string, pars []interface{}) (item []*GlData,
 	//sql += ` ORDER BY PUBLISH_TIME DESC `
 	condition += " AND IS_DELETE=0 "
 	sql1 := ` SELECT * FROM mb_index_main_data WHERE 1=1 AND DATA_VALUE is not null `
-	o := orm.NewOrmUsingDB("gl")
+	//o := orm.NewOrmUsingDB("gl")
 	if condition != "" {
 		sql1 += condition
 	}
 	sql := `select * from (` + sql1 + ` having 1 order by PUBLISH_TIME DESC ) tmp group by DATA_DATE ORDER BY PUBLISH_TIME DESC `
 
-	_, err = o.Raw(sql, pars).QueryRows(&item)
+	//_, err = o.Raw(sql, pars).QueryRows(&item)
+
+	err = global.DmSQL["gl"].Raw(sql, pars).Find(&item).Error
 	return
 }
 
 func GetEdbDataGlByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_gl WHERE edb_code=? AND data_time=? `
-	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+	//err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode, startDate).Scan(&count).Error
 	return
 }
 
 func ModifyEdbDataGl(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_data_gl SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
-	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+	//_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, value, edbInfoId, dataTime).Error
+
 	return
 }
 
 // 刷新钢联指标数据
 func RefreshEdbDataByGl(edbInfoId int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	tx, err := o.Begin()
-	if err != nil {
-		return err
-	}
+	//o := orm.NewOrm()
+	//tx, err := o.Begin()
+	tx := global.DEFAULT_DmSQL.Begin()
+	//if err != nil {
+	//	return err
+	//}
 	defer func() {
 		if err != nil {
 			tx.Rollback()
@@ -98,7 +107,9 @@ func RefreshEdbDataByGl(edbInfoId int, edbCode, startDate, endDate string) (err
 	dataTableName := GetEdbDataTableName(utils.DATA_SOURCE_GL, utils.DATA_SUB_SOURCE_EDB)
 	sql := `SELECT * FROM %s WHERE edb_info_id=? `
 	sql = fmt.Sprintf(sql, dataTableName)
-	_, err = o.Raw(sql, edbInfoId).QueryRows(&existDataList)
+	//_, err = o.Raw(sql, edbInfoId).QueryRows(&existDataList)
+	err = tx.Raw(sql, edbInfoId).Find(&existDataList).Error
+
 	if err != nil {
 		return err
 	}
@@ -132,7 +143,8 @@ func RefreshEdbDataByGl(edbInfoId int, edbCode, startDate, endDate string) (err
 				if existVal != item.InputValue {
 					sql := ` UPDATE %s SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
 					sql = fmt.Sprintf(sql, dataTableName)
-					_, err = tx.Raw(sql, item.InputValue, edbInfoId, v.DataTime).Exec()
+					//_, err = tx.Raw(sql, item.InputValue, edbInfoId, v.DataTime).Exec()
+					err = tx.Exec(sql, item.InputValue, edbInfoId, v.DataTime).Error
 					if err != nil {
 						return err
 					}
@@ -143,7 +155,8 @@ func RefreshEdbDataByGl(edbInfoId int, edbCode, startDate, endDate string) (err
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = tx.Raw(addSql).Exec()
+		//_, err = tx.Raw(addSql).Exec()
+		err = tx.Exec(addSql).Error
 		if err != nil {
 			return err
 		}

+ 19 - 11
models/data_manage/edb_data_lt.go

@@ -2,9 +2,9 @@ package data_manage
 
 import (
 	"encoding/json"
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/http"
 	"time"
 )
@@ -23,37 +23,45 @@ type EdbDataLt struct {
 
 // AddEdbDataLtBySql 执行添加数据的sql
 func AddEdbDataLtBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Raw(sqlStr).Exec()
+	//o := orm.NewOrm()
+	//_, err = o.Raw(sqlStr).Exec()
+	err = global.DEFAULT_DmSQL.Exec(sqlStr).Error
 	return
 }
 
 // ModifyEdbDataLt 修改路透社数据
 func ModifyEdbDataLt(edbInfoId int64, dataTime string, value float64) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_data_lt SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
-	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+	//_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, value, edbInfoId, dataTime).Error
 	return
 }
 
 func GetEdbDataLtMaxOrMinDate(edbCode string) (min_date, max_date string, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM edb_data_lt WHERE edb_code=? `
-	err = o.Raw(sql, edbCode).QueryRow(&min_date, &max_date)
+	//err = o.Raw(sql, edbCode).QueryRow(&min_date, &max_date)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode).First(&min_date, &max_date).Error
 	return
 }
 
 func GetEdbDataLtByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_lt WHERE edb_code=? AND data_time=? `
-	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+	//err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode, startDate).Scan(&count).Error
 	return
 }
 
 func GetEdbDataLtByCode(edbCode string, size int) (items []*EdbInfoSearchData, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT * FROM edb_data_lt WHERE edb_code=? ORDER BY data_time DESC LIMIT ? `
-	_, err = o.Raw(sql, edbCode, size).QueryRows(&items)
+	//_, err = o.Raw(sql, edbCode, size).QueryRows(&items)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode, size).Find(&items).Error
 	return
 }
 

+ 17 - 9
models/data_manage/edb_data_lz.go

@@ -1,7 +1,7 @@
 package data_manage
 
 import (
-	"github.com/beego/beego/v2/client/orm"
+	"eta_gn/eta_task/global"
 )
 
 type lzSurveyData struct {
@@ -47,32 +47,40 @@ func GetLzSurveyDataByTradeCode(condition string, pars []interface{}) (item []*l
 	sql := ` SELECT  a.* FROM longzhong_survey_data AS a
 				INNER JOIN longzhong_survey_product AS b ON a.survey_product_id=b.survey_product_id
 				WHERE 1=1 `
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	if condition != "" {
 		sql += condition
 	}
 	sql += ` ORDER BY a.data_time DESC `
-	_, err = o.Raw(sql, pars).QueryRows(&item)
+	//_, err = o.Raw(sql, pars).QueryRows(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).Find(&item).Error
 	return
 }
 
 func GetLzSurveyDataExistByTradeCode(surveyProductId int) (items []*LongzhongSurveyData, err error) {
 	sql := ` SELECT  * FROM longzhong_survey_data WHERE 1=1 AND survey_product_id=? `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, surveyProductId).QueryRows(&items)
+	//o := orm.NewOrm()
+	//_, err = o.Raw(sql, surveyProductId).QueryRows(&items)
+	err = global.DEFAULT_DmSQL.Raw(sql, surveyProductId).Find(&items).Error
+
 	return
 }
 
 func GetEdbDataLzByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_lz WHERE edb_code=? AND data_time=? `
-	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+	//err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode, startDate).Scan(&count).Error
 	return
 }
 
 func ModifyEdbDataLz(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_data_lz SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
-	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+	//_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, value, edbInfoId, dataTime).Error
 	return
 }

+ 26 - 14
models/data_manage/edb_data_manual.go

@@ -1,24 +1,27 @@
 package data_manage
 
 import (
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
 )
 
 func AddEdbDataManualBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Raw(sqlStr).Exec()
+	//o := orm.NewOrm()
+	//_, err = o.Raw(sqlStr).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sqlStr).Error
 	return
 }
 
 func GetEdbDataManualMaxOrMinDate(edbCode string) (min_date, max_date string, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM edb_data_manual WHERE edb_code=? `
-	err = o.Raw(sql, edbCode).QueryRow(&min_date, &max_date)
+	//err = o.Raw(sql, edbCode).QueryRow(&min_date, &max_date)
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode).First(&min_date, &max_date).Error
 	return
 }
 
@@ -31,34 +34,42 @@ type ManualEdbdata struct {
 
 func GetEdbdataManualByTradeCode(condition string, pars []interface{}) (item []*ManualEdbdata, err error) {
 	sql := ` SELECT  * FROM edbdata WHERE 1=1 `
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	if condition != "" {
 		sql += condition
 	}
 	sql += ` ORDER BY DT DESC `
-	_, err = o.Raw(sql, pars).QueryRows(&item)
+	//_, err = o.Raw(sql, pars).QueryRows(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).Find(&item).Error
 	return
 }
 
 func GetEdbDataManualByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_manual WHERE edb_code=? AND data_time=? `
-	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+	//err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode, startDate).Scan(&count).Error
+
 	return
 }
 
 func ModifyEdbDataManual(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
+	//	o := orm.NewOrm()
 	sql := ` UPDATE edb_data_manual SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
-	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+	//_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, value, edbInfoId, dataTime).Error
 	return
 }
 
 // 刷新手工指标数据
 func RefreshManual(item *EdbInfoList) (err error) {
 	//edbInfoId int, edbCode, startDate, endDate string
-	o := orm.NewOrm()
-	tx, err := o.Begin()
+	//o := orm.NewOrm()
+	//tx, err := o.Begin()
+
+	tx := global.DEFAULT_DmSQL.Begin()
 	if err != nil {
 		return err
 	}
@@ -144,7 +155,8 @@ func RefreshManual(item *EdbInfoList) (err error) {
 
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = tx.Raw(addSql).Exec()
+		//_, err = tx.Raw(addSql).Exec()
+		err = tx.Exec(addSql).Error
 		if err != nil {
 			return err
 		}

+ 22 - 11
models/data_manage/edb_data_pb.go

@@ -1,7 +1,8 @@
 package data_manage
 
 import (
-	"github.com/beego/beego/v2/client/orm"
+	"eta_gn/eta_task/global"
+	"eta_gn/eta_task/utils"
 	"time"
 )
 
@@ -20,35 +21,45 @@ type EdbDataPb struct {
 }
 
 func AddEdbDataPb(items []*EdbDataPb) (err error) {
-	o := orm.NewOrm()
-	_, err = o.InsertMulti(1, items)
+	//o := orm.NewOrm()
+	//_, err = o.InsertMulti(1, items)
+
+	err = global.DEFAULT_DmSQL.CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 func ModifyEdbDataPb(edbInfoId int64, edbCode, dataTime string, value float64) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_data_pb SET edb_info_id=?,value=?,status=1,modify_time=NOW() WHERE edb_code=? AND data_time=? `
-	_, err = o.Raw(sql, edbInfoId, value, edbCode, dataTime).Exec()
+	//_, err = o.Raw(sql, edbInfoId, value, edbCode, dataTime).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, edbInfoId, value, edbCode, dataTime).Error
 	return
 }
 
 func ModifyEdbDataPbStatus(edbInfoId int64, edbCode string) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_data_pb SET edb_info_id=?, status=1,modify_time=NOW() WHERE edb_code=? `
-	_, err = o.Raw(sql, edbInfoId, edbCode).Exec()
+	//_, err = o.Raw(sql, edbInfoId, edbCode).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, edbInfoId, edbCode).Error
 	return
 }
 
 func GetEdbDataPbCount(edbCode, dataTime string) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_pb WHERE edb_code=? AND data_time=? `
-	err = o.Raw(sql, edbCode, dataTime).QueryRow(&count)
+	//err = o.Raw(sql, edbCode, dataTime).QueryRow(&count)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode, dataTime).Scan(&count).Error
 	return
 }
 
 func GetEdbDataPbMaxOrMinDate(edbInfoId int) (min_date, max_date string, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM edb_data_pb WHERE edb_info_id=? `
-	err = o.Raw(sql, edbInfoId).QueryRow(&min_date, &max_date)
+	//err = o.Raw(sql, edbInfoId).QueryRow(&min_date, &max_date)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbInfoId).First(&min_date, &max_date).Error
 	return
 }

+ 5 - 3
models/data_manage/edb_data_quarter.go

@@ -1,12 +1,14 @@
 package data_manage
 
 import (
-	"github.com/beego/beego/v2/client/orm"
+	"eta_gn/eta_task/global"
 )
 
 func GetEdbDataQuarterCount(edbInfoId int) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	hsql := `SELECT COUNT(1) AS count FROM edb_data_quarter WHERE edb_info_id=? `
-	err = o.Raw(hsql, edbInfoId).QueryRow(&count)
+	//err = o.Raw(hsql, edbInfoId).QueryRow(&count)
+
+	err = global.DEFAULT_DmSQL.Raw(hsql, edbInfoId).Scan(&count).Error
 	return
 }

+ 33 - 18
models/data_manage/edb_data_sh.go

@@ -1,9 +1,9 @@
 package data_manage
 
 import (
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -58,16 +58,19 @@ type BaseFromTradeShIndex struct {
 }
 
 func GetEdbDataShMaxOrMinDate(edbCode string) (minDate, maxDate string, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_sh WHERE edb_code=? `
-	err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
+	//err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode).First(&minDate, &maxDate).Error
 	return
 }
 
 // RefreshEdbDataBySh 刷新上期所指标数据
 func RefreshEdbDataBySh(edbInfoId int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	tx, err := o.Begin()
+	//o := orm.NewOrm()
+	//tx, err := o.Begin()
+	tx := global.DEFAULT_DmSQL.Begin()
 	if err != nil {
 		return err
 	}
@@ -160,7 +163,8 @@ func RefreshEdbDataBySh(edbInfoId int, edbCode, startDate, endDate string) (err
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = tx.Raw(addSql).Exec()
+		//_, err = tx.Raw(addSql).Exec()
+		err = tx.Exec(addSql).Error
 		if err != nil {
 			return err
 		}
@@ -170,48 +174,59 @@ func RefreshEdbDataBySh(edbInfoId int, edbCode, startDate, endDate string) (err
 
 // GetBaseInfoFromShByIndexCode 获取指标信息
 func GetBaseInfoFromShByIndexCode(indexCode, suffix string) (list []*BaseInfoFromSh, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := `SELECT * FROM base_from_trade_shanghai_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
-	_, err = o.Raw(sql, indexCode).QueryRows(&list)
+	//_, err = o.Raw(sql, indexCode).QueryRows(&list)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, indexCode).Find(&list).Error
 	return
 }
 
 func GetShDataByTradeCode(condition string, pars []interface{}) (item []*BaseFromShDataSimple, err error) {
 	sql := ` SELECT * FROM base_from_trade_shanghai_index WHERE 1=1 `
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	if condition != "" {
 		sql += condition
 	}
 	sql += ` ORDER BY data_time DESC `
-	_, err = o.Raw(sql, pars).QueryRows(&item)
+	//_, err = o.Raw(sql, pars).QueryRows(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).Find(&item).Error
 	return
 }
 
 func AddEdbDataShBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Raw(sqlStr).Exec()
+	//o := orm.NewOrm()
+	//_, err = o.Raw(sqlStr).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sqlStr).Error
 	return
 }
 
 func GetBaseFromShDataAllByIndexCode(indexCode, suffix string) (list []*BaseFromTradeShIndex, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := `SELECT * FROM base_from_trade_shanghai_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
-	_, err = o.Raw(sql, indexCode).QueryRows(&list)
+	//	_, err = o.Raw(sql, indexCode).QueryRows(&list)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, indexCode).Find(&list).Error
 	return
 }
 
 func GetEdbDataShByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_sh WHERE edb_code=? AND data_time=? `
-	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+	//err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode, startDate).Scan(&count).Error
 	return
 }
 
 func ModifyEdbDataSh(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_data_sh SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
-	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+	//_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, value, edbInfoId, dataTime).Error
 	return
 }

+ 32 - 18
models/data_manage/edb_data_shfe.go

@@ -1,9 +1,9 @@
 package data_manage
 
 import (
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -58,16 +58,19 @@ type BaseFromTradeShfeIndex struct {
 }
 
 func GetEdbDataShfeMaxOrMinDate(edbCode string) (minDate, maxDate string, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_ine WHERE edb_code=? `
-	err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
+	//err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode).First(&minDate, &maxDate).Error
 	return
 }
 
 // RefreshEdbDataByShfe 刷新上期能源指标数据
 func RefreshEdbDataByShfe(edbInfoId int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	tx, err := o.Begin()
+	//o := orm.NewOrm()
+	//tx, err := o.Begin()
+	tx := global.DEFAULT_DmSQL.Begin()
 	if err != nil {
 		return err
 	}
@@ -160,7 +163,8 @@ func RefreshEdbDataByShfe(edbInfoId int, edbCode, startDate, endDate string) (er
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = tx.Raw(addSql).Exec()
+		//_, err = tx.Raw(addSql).Exec()
+		err = tx.Exec(addSql).Error
 		if err != nil {
 			return err
 		}
@@ -170,48 +174,58 @@ func RefreshEdbDataByShfe(edbInfoId int, edbCode, startDate, endDate string) (er
 
 // GetBaseInfoFromShfeByIndexCode 获取指标信息
 func GetBaseInfoFromShfeByIndexCode(indexCode, suffix string) (list []*BaseInfoFromShfe, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := `SELECT * FROM base_from_trade_ine_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
-	_, err = o.Raw(sql, indexCode).QueryRows(&list)
+	//_, err = o.Raw(sql, indexCode).QueryRows(&list)
+	err = global.DEFAULT_DmSQL.Raw(sql, indexCode).Find(&list).Error
 	return
 }
 
 func GetShfeDataByTradeCode(condition string, pars []interface{}) (item []*BaseFromShfeDataSimple, err error) {
 	sql := ` SELECT * FROM base_from_trade_ine_index WHERE 1=1 `
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	if condition != "" {
 		sql += condition
 	}
 	sql += ` ORDER BY data_time DESC `
-	_, err = o.Raw(sql, pars).QueryRows(&item)
+	//_, err = o.Raw(sql, pars).QueryRows(&item)
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).Find(&item).Error
 	return
 }
 
 func AddEdbDataShfeBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Raw(sqlStr).Exec()
+	//o := orm.NewOrm()
+	//_, err = o.Raw(sqlStr).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sqlStr).Error
 	return
 }
 
 func GetBaseFromShfeDataAllByIndexCode(indexCode, suffix string) (list []*BaseFromTradeShfeIndex, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := `SELECT * FROM base_from_trade_ine_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
-	_, err = o.Raw(sql, indexCode).QueryRows(&list)
+	//_, err = o.Raw(sql, indexCode).QueryRows(&list)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, indexCode).Find(&list).Error
 	return
 }
 
 func GetEdbDataShfeByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_ine WHERE edb_code=? AND data_time=? `
-	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+	//err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode, startDate).Scan(&count).Error
 	return
 }
 
 func ModifyEdbDataShfe(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_data_ine SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
-	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+	//_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, value, edbInfoId, dataTime).Error
 	return
 }

+ 18 - 9
models/data_manage/edb_data_ths.go

@@ -1,7 +1,8 @@
 package data_manage
 
 import (
-	"github.com/beego/beego/v2/client/orm"
+	"eta_gn/eta_task/global"
+	"eta_gn/eta_task/utils"
 	"time"
 )
 
@@ -18,28 +19,36 @@ type EdbDataThs struct {
 }
 
 func AddEdbDataThs(items []*EdbDataThs) (err error) {
-	o := orm.NewOrm()
-	_, err = o.InsertMulti(1, items)
+	//o := orm.NewOrm()
+	//_, err = o.InsertMulti(1, items)
+
+	err = global.DEFAULT_DmSQL.CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 func ModifyEdbDataThs(edbInfoId int64, edbCode, dataTime string, value float64) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_data_ths SET edb_info_id=?,value=?,status=1,modify_time=NOW() WHERE edb_code=? AND data_time=? `
-	_, err = o.Raw(sql, edbInfoId, value, edbCode, dataTime).Exec()
+	//_, err = o.Raw(sql, edbInfoId, value, edbCode, dataTime).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, edbInfoId, value, edbCode, dataTime).Error
 	return
 }
 
 func GetEdbDataThsCount(ebdCode, dataTime string) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_ths WHERE edb_code=? AND data_time=? `
-	err = o.Raw(sql, ebdCode, dataTime).QueryRow(&count)
+	//err = o.Raw(sql, ebdCode, dataTime).QueryRow(&count)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, ebdCode, dataTime).Scan(&count).Error
 	return
 }
 
 func GetEdbDataThsMaxOrMinDate(edbInfoId int) (min_date, max_date string, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM edb_data_ths WHERE edb_info_id=? `
-	err = o.Raw(sql, edbInfoId).QueryRow(&min_date, &max_date)
+	//err = o.Raw(sql, edbInfoId).QueryRow(&min_date, &max_date)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbInfoId).First(&min_date, &max_date).Error
 	return
 }

+ 22 - 11
models/data_manage/edb_data_wind.go

@@ -1,7 +1,8 @@
 package data_manage
 
 import (
-	"github.com/beego/beego/v2/client/orm"
+	"eta_gn/eta_task/global"
+	"eta_gn/eta_task/utils"
 	"time"
 )
 
@@ -18,35 +19,45 @@ type EdbDataWind struct {
 }
 
 func AddEdbDataWind(items []*EdbDataWind) (err error) {
-	o := orm.NewOrm()
-	_, err = o.InsertMulti(1, items)
+	//o := orm.NewOrm()
+	//_, err = o.InsertMulti(1, items)
+
+	err = global.DEFAULT_DmSQL.CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 func ModifyEdbDataWind(edbInfoId int64, edbCode, dataTime string, value float64) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_data_wind SET edb_info_id=?,value=?,status=1,modify_time=NOW() WHERE edb_code=? AND data_time=? `
-	_, err = o.Raw(sql, edbInfoId, value, edbCode, dataTime).Exec()
+	//_, err = o.Raw(sql, edbInfoId, value, edbCode, dataTime).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, edbInfoId, value, edbCode, dataTime).Error
 	return
 }
 
 func ModifyEdbDataWindStatus(edbInfoId int64, edbCode string) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_data_wind SET edb_info_id=?, status=1,modify_time=NOW() WHERE edb_code=? `
-	_, err = o.Raw(sql, edbInfoId, edbCode).Exec()
+	//_, err = o.Raw(sql, edbInfoId, edbCode).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, edbInfoId, edbCode).Error
 	return
 }
 
 func GetEdbDataWindCount(edbCode, dataTime string) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_wind WHERE edb_code=? AND data_time=? `
-	err = o.Raw(sql, edbCode, dataTime).QueryRow(&count)
+	//err = o.Raw(sql, edbCode, dataTime).QueryRow(&count)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode, dataTime).Scan(&count).Error
 	return
 }
 
 func GetEdbDataWindMaxOrMinDate(edbInfoId int) (min_date, max_date string, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM edb_data_wind WHERE edb_info_id=? `
-	err = o.Raw(sql, edbInfoId).QueryRow(&min_date, &max_date)
+	//err = o.Raw(sql, edbInfoId).QueryRow(&min_date, &max_date)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbInfoId).First(&min_date, &max_date).Error
 	return
 }

+ 9 - 5
models/data_manage/edb_data_ys.go

@@ -10,9 +10,9 @@ import (
 	"encoding/hex"
 	"encoding/json"
 	"errors"
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"io/ioutil"
 	"net/http"
 	"net/url"
@@ -33,15 +33,19 @@ type EdbDataYs struct {
 }
 
 func AddEdbDataSmm(items []*EdbDataYs) (err error) {
-	o := orm.NewOrm()
-	_, err = o.InsertMulti(1, items)
+	//o := orm.NewOrm()
+	//_, err = o.InsertMulti(1, items)
+
+	err = global.DEFAULT_DmSQL.CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 func ModifyEdbDataSmm(edbCode, dataTime string, value float64) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_data_ys SET value=?,status=1,modify_time=NOW() WHERE edb_code=? AND data_time=? `
-	_, err = o.Raw(sql, value, edbCode, dataTime).Exec()
+	//_, err = o.Raw(sql, value, edbCode, dataTime).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, value, edbCode, dataTime).Error
 	return
 }
 

+ 34 - 18
models/data_manage/edb_data_zz.go

@@ -1,9 +1,9 @@
 package data_manage
 
 import (
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"strings"
 	"time"
@@ -32,16 +32,19 @@ type BaseInfoFromZz struct {
 }
 
 func GetEdbDataZzMaxOrMinDate(edbCode string) (minDate, maxDate string, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_zz WHERE edb_code=? `
-	err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
+	//err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode).First(&minDate, &maxDate).Error
 	return
 }
 
 // RefreshEdbDataByZz 刷新郑商所指标数据
 func RefreshEdbDataByZz(edbInfoId int, edbCode, startDate, endDate string) (err error) {
-	o := orm.NewOrm()
-	tx, err := o.Begin()
+	//o := orm.NewOrm()
+	//tx, err := o.Begin()
+	tx := global.DEFAULT_DmSQL.Begin()
 	if err != nil {
 		return err
 	}
@@ -134,7 +137,8 @@ func RefreshEdbDataByZz(edbInfoId int, edbCode, startDate, endDate string) (err
 	}
 	if isAdd {
 		addSql = strings.TrimRight(addSql, ",")
-		_, err = tx.Raw(addSql).Exec()
+		//_, err = tx.Raw(addSql).Exec()
+		err = tx.Exec(addSql).Error
 		if err != nil {
 			return err
 		}
@@ -144,48 +148,60 @@ func RefreshEdbDataByZz(edbInfoId int, edbCode, startDate, endDate string) (err
 
 // GetBaseInfoFromZhengzhouByIndexCode 获取指标信息
 func GetBaseInfoFromZhengzhouByIndexCode(indexCode, suffix string) (list []*BaseInfoFromZz, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := `SELECT * FROM base_from_trade_zhengzhou_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
-	_, err = o.Raw(sql, indexCode).QueryRows(&list)
+	//_, err = o.Raw(sql, indexCode).QueryRows(&list)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, indexCode).Find(&list).Error
 	return
 }
 
 func GetZzDataByTradeCode(condition string, pars []interface{}) (item []*BaseFromZzDataSimple, err error) {
 	sql := ` SELECT * FROM base_from_trade_zhengzhou_index WHERE 1=1 `
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	if condition != "" {
 		sql += condition
 	}
 	sql += ` ORDER BY data_time DESC `
-	_, err = o.Raw(sql, pars).QueryRows(&item)
+	//_, err = o.Raw(sql, pars).QueryRows(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).Find(&item).Error
 	return
 }
 
 func AddEdbDataZzBySql(sqlStr string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Raw(sqlStr).Exec()
+	//o := orm.NewOrm()
+	//_, err = o.Raw(sqlStr).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sqlStr).Error
 	return
 }
 
 func GetBaseFromZhengzhouDataAllByIndexCode(indexCode, suffix string) (list []*BaseFromTradeZhengzhouIndex, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := `SELECT * FROM base_from_trade_zhengzhou_index WHERE %s_code=? `
 	sql = fmt.Sprintf(sql, suffix)
-	_, err = o.Raw(sql, indexCode).QueryRows(&list)
+	//_, err = o.Raw(sql, indexCode).QueryRows(&list)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, indexCode).Find(&list).Error
 	return
 }
 
 func GetEdbDataZzByCodeAndDate(edbCode string, startDate string) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT COUNT(1) AS count FROM edb_data_zz WHERE edb_code=? AND data_time=? `
-	err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+	//err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode, startDate).Scan(&count).Error
 	return
 }
 
 func ModifyEdbDataZz(edbInfoId int64, dataTime, value string) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_data_zz SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
-	_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+	//_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, value, edbInfoId, dataTime).Error
 	return
 }

+ 75 - 40
models/data_manage/edb_info.go

@@ -2,9 +2,9 @@ package data_manage
 
 import (
 	"errors"
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strconv"
 	"time"
 )
@@ -65,7 +65,7 @@ type EdbInfoSearchDataV1 struct {
 }
 
 func GetEdbInfoByCondition(condition string, pars []interface{}, order int) (item []*EdbInfoList, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT * FROM edb_info WHERE 1=1 `
 	if condition != "" {
 		sql += condition
@@ -75,14 +75,18 @@ func GetEdbInfoByCondition(condition string, pars []interface{}, order int) (ite
 	} else {
 		sql += ` ORDER BY edb_info_id ASC `
 	}
-	_, err = o.Raw(sql, pars).QueryRows(&item)
+	//_, err = o.Raw(sql, pars).QueryRows(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).Find(&item).Error
 	return
 }
 
 func ModifyEdbDataInfoDate(edbInfoId int, maxDate string) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_info SET end_date=?,modify_time=NOW() WHERE edb_info_id=? `
-	_, err = o.Raw(sql, maxDate, edbInfoId).Exec()
+	//_, err = o.Raw(sql, maxDate, edbInfoId).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, maxDate, edbInfoId).Error
 	return
 }
 
@@ -95,7 +99,7 @@ type EdbInfoMaxAndMinInfo struct {
 }
 
 func GetEdbInfoMaxAndMinInfo(source, subSource int, edbCode string) (item *EdbInfoMaxAndMinInfo, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ``
 	tableName := GetEdbDataTableName(source, subSource)
 	if tableName == "" {
@@ -104,26 +108,30 @@ func GetEdbInfoMaxAndMinInfo(source, subSource int, edbCode string) (item *EdbIn
 	}
 	sql = ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date,MIN(value) AS min_value,MAX(value) AS max_value FROM %s WHERE edb_code=? `
 	sql = fmt.Sprintf(sql, tableName)
-	err = o.Raw(sql, edbCode).QueryRow(&item)
+	//err = o.Raw(sql, edbCode).QueryRow(&item)
 
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode).First(&item).Error
 	var latest_value float64
 	sql = ` SELECT value AS latest_value FROM %s WHERE edb_code=? ORDER BY data_time DESC LIMIT 1 `
 	sql = fmt.Sprintf(sql, tableName)
-	err = o.Raw(sql, edbCode).QueryRow(&latest_value)
+	//err = o.Raw(sql, edbCode).QueryRow(&latest_value)
+	err = global.DEFAULT_DmSQL.Raw(sql, edbCode).First(&latest_value).Error
 	item.LatestValue = latest_value
 	return
 }
 
 func ModifyEdbInfoMaxAndMinInfo(edbInfoId int, item *EdbInfoMaxAndMinInfo) (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_info SET start_date=?,end_date=?,min_value=?,max_value=?,is_update=2,latest_date=?,latest_value=?,modify_time=NOW() WHERE edb_info_id=? `
-	_, err = o.Raw(sql, item.MinDate, item.MaxDate, item.MinValue, item.MaxValue, item.MaxDate, item.LatestValue, edbInfoId).Exec()
+	//_, err = o.Raw(sql, item.MinDate, item.MaxDate, item.MinValue, item.MaxValue, item.MaxDate, item.LatestValue, edbInfoId).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, item.MinDate, item.MaxDate, item.MinValue, item.MaxValue, item.MaxDate, item.LatestValue, edbInfoId).Error
 	return
 }
 
 //order:1升序,其余值为降序
 func GetEdbDataListAll(condition string, pars []interface{}, source, subSource, order int) (item []*EdbInfoSearchData, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ``
 	tableName := GetEdbDataTableName(source, subSource)
 	sql = ` SELECT * FROM %s WHERE 1=1 `
@@ -137,12 +145,14 @@ func GetEdbDataListAll(condition string, pars []interface{}, source, subSource,
 	} else {
 		sql += ` ORDER BY data_time DESC `
 	}
-	_, err = o.Raw(sql, pars).QueryRows(&item)
+	//_, err = o.Raw(sql, pars).QueryRows(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).Find(&item).Error
 	return
 }
 
 func GetEdbDataListAllV1(condition string, pars []interface{}, source, subSource, order int) (item []*EdbInfoSearchDataV1, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ``
 	tableName := GetEdbDataTableName(source, subSource)
 	sql = ` SELECT * FROM %s WHERE 1=1 `
@@ -156,39 +166,47 @@ func GetEdbDataListAllV1(condition string, pars []interface{}, source, subSource
 	} else {
 		sql += ` ORDER BY data_time DESC `
 	}
-	_, err = o.Raw(sql, pars).QueryRows(&item)
+	//_, err = o.Raw(sql, pars).QueryRows(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).Find(&item).Error
 	return
 }
 
 func GetEdbInfoById(edbInfoId int) (item *EdbInfo, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT * FROM edb_info WHERE edb_info_id=? `
-	err = o.Raw(sql, edbInfoId).QueryRow(&item)
+	//err = o.Raw(sql, edbInfoId).QueryRow(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbInfoId).First(&item).Error
 	return
 }
 
 func GetQuarterEdbInfo() (item []*EdbInfo, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT c.* FROM chart_info AS a
 			INNER JOIN chart_edb_mapping AS b ON a.chart_info_id=b.chart_info_id
 			INNER JOIN edb_info AS c ON b.edb_info_id=c.edb_info_id
 			WHERE a.chart_type=2
 			GROUP BY b.edb_info_id
 			ORDER BY b.edb_info_id ASC  `
-	_, err = o.Raw(sql).QueryRows(&item)
+	//_, err = o.Raw(sql).QueryRows(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql).Find(&item).Error
 	return
 }
 
 func ResetEdbInfoIsUpdate() (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` UPDATE edb_info SET is_update=1  `
-	_, err = o.Raw(sql).Exec()
+	//_, err = o.Raw(sql).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql).Error
 	return
 }
 
 // GetEdbInfoCalculateListByCondition 获取指标关系列表
 func GetEdbInfoCalculateListByCondition(condition string, pars []interface{}) (items []*EdbInfoCalculateMapping, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	//calculateTableName := GetEdbInfoCalculateTableName(source)
 	//if calculateTableName == "" {
 	//	err = errors.New("无效的表名")
@@ -200,7 +218,9 @@ func GetEdbInfoCalculateListByCondition(condition string, pars []interface{}) (i
 	if condition != "" {
 		sql += condition
 	}
-	_, err = o.Raw(sql, pars).QueryRows(&items)
+	//_, err = o.Raw(sql, pars).QueryRows(&items)
+
+	err = global.DEFAULT_DmSQL.Raw(sql).Find(&items).Error
 	return
 }
 
@@ -209,8 +229,9 @@ func DeleteEdbDataByIdAndSource(edbDataId, source, subSource int) (err error) {
 	tableName := GetEdbDataTableName(source, subSource)
 	sql = fmt.Sprintf(sql, tableName)
 
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, edbDataId).Exec()
+	//o := orm.NewOrm()
+	//_, err = o.Raw(sql, edbDataId).Exec()
+	err = global.DEFAULT_DmSQL.Exec(sql, edbDataId).Error
 	return
 }
 
@@ -236,14 +257,15 @@ type EdbInfoClassify struct {
 // @return item []*EdbInfoUpdateLog
 // @return err error
 func GetAllEdbInfoClassifyListByCondition(condition string, pars []interface{}) (item []*EdbInfoClassify, err error) {
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT * FROM edb_info WHERE 1=1 `
 	if condition != "" {
 		sql += condition
 	}
 	sql += `ORDER BY edb_info_id ASC `
-	_, err = o.Raw(sql, pars).QueryRows(&item)
+	//_, err = o.Raw(sql, pars).QueryRows(&item)
 
+	err = global.DmSQL["data"].Raw(sql, pars).Find(&item).Error
 	return
 }
 
@@ -256,10 +278,11 @@ func GetAllEdbInfoClassifyListByCondition(condition string, pars []interface{})
 // @return item *EdbInfo
 // @return err error
 func GetEdbInfoItemByCodeAndSource(source int, edbCode string) (item *EdbInfoItem, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT * FROM edb_info WHERE edb_code=? AND source = ?`
-	err = o.Raw(sql, source, edbCode).QueryRow(&item)
+	//err = o.Raw(sql, source, edbCode).QueryRow(&item)
 
+	err = global.DEFAULT_DmSQL.Raw(sql, source, edbCode).First(&item).Error
 	return
 }
 
@@ -272,7 +295,7 @@ func GetEdbInfoItemByCodeAndSource(source int, edbCode string) (item *EdbInfoIte
 // @return modifyTime string
 // @return err error
 func GetEdbInfoMaxModifyTime(source, subSource int, edbCode string) (modifyTime string, err error) {
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	tableName := GetEdbDataTableName(source, subSource)
 	if tableName == "" {
 		err = errors.New("无效的表名称:source:" + strconv.Itoa(source))
@@ -281,29 +304,35 @@ func GetEdbInfoMaxModifyTime(source, subSource int, edbCode string) (modifyTime
 
 	sql := ` SELECT MAX(modify_time) AS modify_time FROM %s WHERE edb_code=? `
 	sql = fmt.Sprintf(sql, tableName)
-	err = o.Raw(sql, edbCode).QueryRow(&modifyTime)
+	//err = o.Raw(sql, edbCode).QueryRow(&modifyTime)
+
+	err = global.DmSQL["data"].Raw(sql, edbCode).Scan(&modifyTime).Error
 
 	return
 }
 
 func GetEdbInfoPageByCondition(condition string, pars []interface{}, startPage, pageSize int) (item []*EdbInfo, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT * FROM edb_info WHERE 1=1 `
 	if condition != "" {
 		sql += condition
 	}
 	sql += ` LIMIT ?,? `
-	_, err = o.Raw(sql, pars, startPage, pageSize).QueryRows(&item)
+	//_, err = o.Raw(sql, pars, startPage, pageSize).QueryRows(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars, startPage, pageSize).Find(&item).Error
 	return
 }
 
 func GetEdbInfoCountByCondition(condition string, pars []interface{}) (total int64, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT count(*) FROM edb_info WHERE 1=1 `
 	if condition != "" {
 		sql += condition
 	}
-	err = o.Raw(sql, pars).QueryRow(&total)
+	//err = o.Raw(sql, pars).QueryRow(&total)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).Scan(&total).Error
 	return
 }
 
@@ -312,7 +341,9 @@ func ModifyEdbUpdateStatus(edbIdList []int, indexCodeList []string, calculateEdb
 	if idNum <= 0 {
 		return
 	}
-	o, err := orm.NewOrmUsingDB("data").Begin()
+	//o, err := orm.NewOrmUsingDB("data").Begin()
+
+	o := global.DmSQL["data"].Begin()
 	if err != nil {
 		return
 	}
@@ -326,7 +357,8 @@ func ModifyEdbUpdateStatus(edbIdList []int, indexCodeList []string, calculateEdb
 
 	// 更改指标的更新状态
 	sql := ` UPDATE edb_info SET no_update = 1 WHERE source in (?, ?) AND edb_info_id IN (` + utils.GetOrmInReplace(idNum) + `) AND  no_update = 0`
-	_, err = o.Raw(sql, utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_WIND, edbIdList).Exec()
+	//_, err = o.Raw(sql, utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_WIND, edbIdList).Exec()
+	err = o.Exec(sql, utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_WIND, edbIdList).Error
 	if err != nil {
 		return
 	}
@@ -335,7 +367,8 @@ func ModifyEdbUpdateStatus(edbIdList []int, indexCodeList []string, calculateEdb
 	if len(indexCodeList) > 0 {
 		// 更改数据源的更新状态
 		sql = ` UPDATE base_from_mysteel_chemical_index SET is_stop = 1 WHERE index_code IN (` + utils.GetOrmInReplace(len(indexCodeList)) + `) and is_stop=0`
-		_, err = o.Raw(sql, indexCodeList).Exec()
+		//_, err = o.Raw(sql, indexCodeList).Exec()
+		err = o.Exec(sql, indexCodeList).Error
 		if err != nil {
 			return
 		}
@@ -345,7 +378,8 @@ func ModifyEdbUpdateStatus(edbIdList []int, indexCodeList []string, calculateEdb
 	if len(calculateEdbInfoIds) > 0 {
 		// 批量更新相关联的指标ID
 		sql = ` UPDATE edb_info SET no_update = 1 WHERE edb_info_id IN (` + utils.GetOrmInReplace(len(calculateEdbInfoIds)) + `) AND  no_update = 0`
-		_, err = o.Raw(sql, calculateEdbInfoIds).Exec()
+		//_, err = o.Raw(sql, calculateEdbInfoIds).Exec()
+		err = o.Exec(sql, calculateEdbInfoIds).Error
 		if err != nil {
 			return
 		}
@@ -359,8 +393,9 @@ func GetEdbInfoByIdList(edbInfoIdList []int) (items []*EdbInfo, err error) {
 	if num <= 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT * FROM edb_info WHERE edb_info_id in (` + utils.GetOrmInReplace(num) + `) `
-	_, err = o.Raw(sql, edbInfoIdList).QueryRows(&items)
+	//_, err = o.Raw(sql, edbInfoIdList).QueryRows(&items)
+	err = global.DmSQL["data"].Raw(sql, edbInfoIdList).Find(&items).Error
 	return
 }

+ 35 - 19
models/data_manage/edb_info_calculate_mapping.go

@@ -1,9 +1,9 @@
 package data_manage
 
 import (
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -25,17 +25,21 @@ type EdbInfoCalculateMapping struct {
 }
 
 func AddEdbInfoCalculateMappingMulti(items []*EdbInfoCalculateMapping) (err error) {
-	o := orm.NewOrm()
-	_, err = o.InsertMulti(1, items)
+	//o := orm.NewOrm()
+	//_, err = o.InsertMulti(1, items)
+
+	err = global.DEFAULT_DmSQL.CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 func FixEdbInfoCalculateMapping() {
-	o := orm.NewOrm()
-	tx, err := o.Begin()
-	if err != nil {
-		return
-	}
+	//o := orm.NewOrm()
+	//tx, err := o.Begin()
+	var err error
+	tx := global.DEFAULT_DmSQL.Begin()
+	//if err != nil {
+	//	return
+	//}
 	defer func() {
 		if err != nil {
 			tx.Rollback()
@@ -45,7 +49,9 @@ func FixEdbInfoCalculateMapping() {
 	}()
 	edbInfoList := make([]*EdbInfoList, 0)
 	sql := `SELECT * FROM edb_info WHERE edb_type=2 `
-	_, err = o.Raw(sql).QueryRows(&edbInfoList)
+	//_, err = o.Raw(sql).QueryRows(&edbInfoList)
+	err = tx.Raw(sql).Find(&edbInfoList).Error
+
 	if err != nil {
 		return
 	}
@@ -56,7 +62,9 @@ func FixEdbInfoCalculateMapping() {
 		sql := ` SELECT * FROM %s
 			WHERE edb_info_id=? ORDER BY sort ASC `
 		sql = fmt.Sprintf(sql, calculateTableName)
-		_, err = tx.Raw(sql, v.EdbInfoId).QueryRows(&calculateList)
+		//_, err = tx.Raw(sql, v.EdbInfoId).QueryRows(&calculateList)
+		err = tx.Raw(sql, v.EdbInfoId).Find(&calculateList).Error
+
 		if err != nil {
 			fmt.Println("query calculate err:" + err.Error())
 			return
@@ -77,7 +85,8 @@ func FixEdbInfoCalculateMapping() {
 			calculateMappingItem.FromTag = cv.FromTag
 			calculateMappingItem.Source = v.Source
 			calculateMappingItem.SourceName = v.SourceName
-			tx.Insert(calculateMappingItem)
+			//tx.Insert(calculateMappingItem)
+			tx.Create(calculateMappingItem)
 		}
 	}
 }
@@ -105,19 +114,22 @@ type EdbInfoCalculateMappingView struct {
 }
 
 func GetEdbInfoCalculateMappingDetail(edbInfoId int) (item *EdbInfoCalculateMappingView, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := ` SELECT a.*,b.start_date,b.end_date,b.calculate_formula,b.move_type,b.move_frequency FROM edb_info_calculate_mapping AS a
 			INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
 			WHERE a.edb_info_id=? `
-	err = o.Raw(sql, edbInfoId).QueryRow(&item)
+	//err = o.Raw(sql, edbInfoId).QueryRow(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, edbInfoId).First(&item).Error
 	return
 }
 
 // GetAllCalculateEdbIdsByEdbInfoIds 所依赖计算指标
 func GetAllCalculateEdbIdsByEdbInfoIds(edbInfoIds []int) (edbIds []int, err error) {
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	msql := ` SELECT edb_info_id FROM edb_info_calculate_mapping WHERE from_edb_info_id in (` + utils.GetOrmInReplace(len(edbInfoIds)) + `)  GROUP BY edb_info_id `
-	_, err = o.Raw(msql, edbInfoIds).QueryRows(&edbIds)
+	//_, err = o.Raw(msql, edbInfoIds).QueryRows(&edbIds)
+	err = global.DmSQL["data"].Raw(msql, edbInfoIds).Find(&edbIds).Error
 	if err != nil {
 		return
 	}
@@ -151,20 +163,24 @@ type EdbInfoCalculateMappingInfo struct {
 
 // GetEdbInfoCalculateMappingListByEdbInfoId 根据生成的指标id获取来源的指标id列表
 func GetEdbInfoCalculateMappingListByEdbInfoId(edbInfoId int) (items []*EdbInfoCalculateMappingInfo, err error) {
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT a.*,b.edb_type as from_edb_type,b.edb_info_type as from_edb_info_type, b.unique_code AS from_unique_code, b.classify_id AS from_classify_id,b.no_update FROM edb_info_calculate_mapping AS a
 			INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
 			WHERE a.edb_info_id=? `
-	_, err = o.Raw(sql, edbInfoId).QueryRows(&items)
+	//_, err = o.Raw(sql, edbInfoId).QueryRows(&items)
+
+	err = global.DmSQL["data"].Raw(sql, edbInfoId).Find(&items).Error
 	return
 }
 
 // GetEdbInfoCalculateMappingListByEdbInfoIds 根据生成的指标id获取来源的指标id列表
 func GetEdbInfoCalculateMappingListByEdbInfoIds(edbInfoIds []int) (items []*EdbInfoCalculateMappingInfo, err error) {
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT a.*,b.edb_type as from_edb_type,b.edb_info_type as from_edb_info_type, b.unique_code AS from_unique_code, b.classify_id AS from_classify_id,b.no_update FROM edb_info_calculate_mapping AS a
 			INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
 			WHERE a.edb_info_id in (` + utils.GetOrmInReplace(len(edbInfoIds)) + `) `
-	_, err = o.Raw(sql, edbInfoIds).QueryRows(&items)
+	//_, err = o.Raw(sql, edbInfoIds).QueryRows(&items)
+
+	err = global.DmSQL["data"].Raw(sql, edbInfoIds).Find(&items).Error
 	return
 }

+ 16 - 8
models/data_manage/edb_info_relation.go

@@ -1,8 +1,8 @@
 package data_manage
 
 import (
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
-	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -30,7 +30,8 @@ func (e *EdbInfoRelation) TableName() string {
 }
 
 func AddEdbInfoRelationMulti(relationList []*EdbInfoRelation) (err error) {
-	o, err := orm.NewOrmUsingDB("data").Begin()
+	//o, err := orm.NewOrmUsingDB("data").Begin()
+	o := global.DmSQL["data"].Begin()
 	if err != nil {
 		return
 	}
@@ -49,7 +50,9 @@ func AddEdbInfoRelationMulti(relationList []*EdbInfoRelation) (err error) {
 				relationCodesMap[relation.RelationCode] = struct{}{}
 			}
 		}
-		_, err = o.InsertMulti(len(relationList), relationList)
+		//_, err = o.InsertMulti(len(relationList), relationList)
+
+		err = o.CreateInBatches(relationList, utils.MultiAddNum).Error
 		if err != nil {
 			return
 		}
@@ -67,7 +70,8 @@ SET e1.parent_relation_id = e2.edb_info_relation_id
 WHERE  
     e1.relation_type = 1   
     AND e2.relation_type = 0 AND e1.parent_relation_id !=e2.edb_info_relation_id AND e1.relation_code in (` + utils.GetOrmInReplace(len(relationCodes)) + `)`
-			_, err = o.Raw(sql, relationCodes).Exec()
+			//_, err = o.Raw(sql, relationCodes).Exec()
+			err = o.Exec(sql, relationCodes).Error
 			if err != nil {
 				return
 			}
@@ -78,9 +82,11 @@ WHERE
 
 // GetEdbInfoRelationByEdbInfoIds 查询引用的指标ID
 func GetEdbInfoRelationByEdbInfoIds(edbInfoIds []int) (edbIds []int, err error) {
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	msql := ` SELECT edb_info_id FROM edb_info_relation WHERE edb_info_id in (` + utils.GetOrmInReplace(len(edbInfoIds)) + `)  GROUP BY edb_info_id `
-	_, err = o.Raw(msql, edbInfoIds).QueryRows(&edbIds)
+	//_, err = o.Raw(msql, edbInfoIds).QueryRows(&edbIds)
+
+	err = global.DmSQL["data"].Raw(msql, edbInfoIds).Find(&edbIds).Error
 	if err != nil {
 		return
 	}
@@ -89,8 +95,10 @@ func GetEdbInfoRelationByEdbInfoIds(edbInfoIds []int) (edbIds []int, err error)
 
 // GetEdbInfoRelationByReferObjectIds 查询引用的指标ID
 func GetEdbInfoRelationByReferObjectIds(referObjectIds []int, referObjectType int) (items []*EdbInfoRelation, err error) {
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	msql := ` SELECT * FROM edb_info_relation WHERE refer_object_id in (` + utils.GetOrmInReplace(len(referObjectIds)) + `) AND refer_object_type=? AND relation_type=0`
-	_, err = o.Raw(msql, referObjectIds, referObjectType).QueryRows(&items)
+	//_, err = o.Raw(msql, referObjectIds, referObjectType).QueryRows(&items)
+
+	err = global.DmSQL["data"].Raw(msql, referObjectIds, referObjectType).Find(&items).Error
 	return
 }

+ 4 - 4
models/data_manage/edb_info_update_log.go

@@ -1,7 +1,7 @@
 package data_manage
 
 import (
-	"github.com/beego/beego/v2/client/orm"
+	"eta_gn/eta_task/global"
 	"time"
 )
 
@@ -39,13 +39,13 @@ type EdbInfoUpdateLog struct {
 }
 
 func GetEdbInfoUpdateLogByCondition(condition string, pars []interface{}) (item []*EdbInfoUpdateLog, err error) {
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT * FROM edb_info_update_log WHERE 1=1 `
 	if condition != "" {
 		sql += condition
 	}
 	sql += `ORDER BY id ASC limit 0,10  `
-	_, err = o.Raw(sql, pars).QueryRows(&item)
-
+	//_, err = o.Raw(sql, pars).QueryRows(&item)
+	err = global.DmSQL["data"].Raw(sql, pars).Find(&item).Error
 	return
 }

+ 9 - 5
models/data_manage/edb_source.go

@@ -1,9 +1,9 @@
 package data_manage
 
 import (
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strings"
 )
 
@@ -30,7 +30,7 @@ type EdbSource struct {
 
 // GetEdbSourceItemsByCondition 获取指标来源列表
 func GetEdbSourceItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*EdbSource, err error) {
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -40,15 +40,19 @@ func GetEdbSourceItemsByCondition(condition string, pars []interface{}, fieldArr
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM edb_source WHERE 1=1 %s %s`, fields, condition, order)
-	_, err = o.Raw(sql, pars).QueryRows(&items)
+
+	//_, err = o.Raw(sql, pars).QueryRows(&items)
+	err = global.DmSQL["data"].Raw(sql, pars).Find(&items).Error
 	return
 }
 
 // GetEdbSourceItemByCondition 获取指标来源
 func GetEdbSourceItemByCondition(condition string, pars []interface{}) (item *EdbSource, err error) {
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	sql := fmt.Sprintf(`SELECT * FROM edb_source WHERE 1=1 %s`, condition)
-	err = o.Raw(sql, pars).QueryRow(&item)
+	//err = o.Raw(sql, pars).QueryRow(&item)
+
+	err = global.DmSQL["data"].Raw(sql, pars).First(&item).Error
 	return
 }
 

+ 13 - 13
models/data_manage/edb_update_log.go

@@ -1,8 +1,8 @@
 package data_manage
 
 import (
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
-	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
@@ -27,10 +27,10 @@ type EdbUpdateLog struct {
 // @return maxId int
 // @return err error
 func GetEdbUpdateLogMaxId() (maxId int64, err error) {
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT id FROM edb_update_log WHERE 1=1 ORDER BY id desc limit 1 `
-	err = o.Raw(sql).QueryRow(&maxId)
-
+	//err = o.Raw(sql).QueryRow(&maxId)
+	err = global.DmSQL["data"].Raw(sql).Scan(&maxId).Error
 	return
 }
 
@@ -41,10 +41,10 @@ func GetEdbUpdateLogMaxId() (maxId int64, err error) {
 // @return maxId int64
 // @return err error
 func GetEdbUpdateLogMaxHandleId() (maxId int64, err error) {
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT id FROM edb_update_log WHERE 1=1 AND is_handle = 1 ORDER BY id desc limit 1 `
-	err = o.Raw(sql).QueryRow(&maxId)
-
+	//err = o.Raw(sql).QueryRow(&maxId)
+	err = global.DmSQL["data"].Raw(sql).Scan(&maxId).Error
 	return
 }
 
@@ -57,14 +57,14 @@ func GetEdbUpdateLogMaxHandleId() (maxId int64, err error) {
 // @return item []*EdbUpdateLog
 // @return err error
 func GetEdbUpdateLogByCondition(condition string, pars []interface{}) (item []*EdbUpdateLog, err error) {
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	sql := ` SELECT * FROM edb_update_log WHERE 1=1 `
 	if condition != "" {
 		sql += condition
 	}
 	sql += ` ORDER BY id ASC limit 500 `
-	_, err = o.Raw(sql, pars).QueryRows(&item)
-
+	//_, err = o.Raw(sql, pars).QueryRows(&item)
+	err = global.DmSQL["data"].Raw(sql, pars).Find(&item).Error
 	return
 }
 
@@ -79,10 +79,10 @@ func HandleUpdateLogByIds(idList []int64, modifyTime string) (err error) {
 	if num <= 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	//o := orm.NewOrmUsingDB("data")
 	sql := ` UPDATE edb_update_log set is_handle=1 ,modify_time = ?  WHERE id in (` + utils.GetOrmInReplace(num) + `) `
-	_, err = o.Raw(sql, modifyTime, idList).Exec()
-
+	//_, err = o.Raw(sql, modifyTime, idList).Exec()
+	err = global.DmSQL["data"].Exec(sql, modifyTime, idList).Error
 	return
 }
 

+ 52 - 30
models/data_manage/factor_edb_series_chart_mapping.go

@@ -1,9 +1,9 @@
 package data_manage
 
 import (
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strings"
 	"time"
 )
@@ -62,34 +62,42 @@ func (m *FactorEdbSeriesChartMapping) Cols() MultipleFactorSeriesChartMappingCol
 }
 
 func (m *FactorEdbSeriesChartMapping) Create() (err error) {
-	o := orm.NewOrm()
-	id, err := o.Insert(m)
-	if err != nil {
-		return
-	}
-	m.FactorEdbSeriesChartMappingId = int(id)
+	//o := orm.NewOrm()
+	//id, err := o.Insert(m)
+	//if err != nil {
+	//	return
+	//}
+	//m.FactorEdbSeriesChartMappingId = int(id)
+
+	err = global.DEFAULT_DmSQL.Create(m).Error
 	return
 }
 
 func (m *FactorEdbSeriesChartMapping) CreateMulti(items []*FactorEdbSeriesChartMapping) (err error) {
-	if len(items) == 0 {
-		return
-	}
-	o := orm.NewOrm()
-	_, err = o.InsertMulti(len(items), items)
+	//if len(items) == 0 {
+	//	return
+	//}
+	//o := orm.NewOrm()
+	//_, err = o.InsertMulti(len(items), items)
+
+	err = global.DEFAULT_DmSQL.CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 func (m *FactorEdbSeriesChartMapping) Update(cols []string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Update(m, cols...)
+	//o := orm.NewOrm()
+	//_, err = o.Update(m, cols...)
+
+	err = global.DEFAULT_DmSQL.Select(cols).Updates(m).Error
 	return
 }
 
 func (m *FactorEdbSeriesChartMapping) Remove() (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	_, err = o.Raw(sql, m.FactorEdbSeriesChartMappingId).Exec()
+	//_, err = o.Raw(sql, m.FactorEdbSeriesChartMappingId).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, m.FactorEdbSeriesChartMappingId).Error
 	return
 }
 
@@ -97,39 +105,47 @@ func (m *FactorEdbSeriesChartMapping) MultiRemove(ids []int) (err error) {
 	if len(ids) == 0 {
 		return
 	}
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s IN (%s)`, m.TableName(), m.Cols().PrimaryId, utils.GetOrmInReplace(len(ids)))
-	_, err = o.Raw(sql, ids).Exec()
+	//_, err = o.Raw(sql, ids).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, ids).Error
 	return
 }
 
 func (m *FactorEdbSeriesChartMapping) GetItemById(id int) (item *FactorEdbSeriesChartMapping, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	err = o.Raw(sql, id).QueryRow(&item)
+	//err = o.Raw(sql, id).QueryRow(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, id).First(&item).Error
 	return
 }
 
 func (m *FactorEdbSeriesChartMapping) GetItemByCondition(condition string, pars []interface{}, orderRule string) (item *FactorEdbSeriesChartMapping, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	order := ``
 	if orderRule != "" {
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s %s LIMIT 1`, m.TableName(), condition, order)
-	err = o.Raw(sql, pars).QueryRow(&item)
+	//err = o.Raw(sql, pars).QueryRow(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).First(&item).Error
 	return
 }
 
 func (m *FactorEdbSeriesChartMapping) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = o.Raw(sql, pars).QueryRow(&count)
+	//err = o.Raw(sql, pars).QueryRow(&count)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).Scan(&count).Error
 	return
 }
 
 func (m *FactorEdbSeriesChartMapping) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*FactorEdbSeriesChartMapping, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -139,12 +155,14 @@ func (m *FactorEdbSeriesChartMapping) GetItemsByCondition(condition string, pars
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars).QueryRows(&items)
+	//_, err = o.Raw(sql, pars).QueryRows(&items)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).Find(&items).Error
 	return
 }
 
 func (m *FactorEdbSeriesChartMapping) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*FactorEdbSeriesChartMapping, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -154,15 +172,19 @@ func (m *FactorEdbSeriesChartMapping) GetPageItemsByCondition(condition string,
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	//_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars, startSize, pageSize).Find(&items).Error
 	return
 }
 
 // GetDistinctSeriesIdByChartId 获取图表关联的系列ID
 func (m *FactorEdbSeriesChartMapping) GetDistinctSeriesIdByChartId(chartId int) (seriesIds []int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := fmt.Sprintf(`SELECT DISTINCT %s FROM %s WHERE %s = ?`, m.Cols().FactorEdbSeriesId, m.TableName(), m.Cols().ChartInfoId)
-	_, err = o.Raw(sql, chartId).QueryRows(&seriesIds)
+	//_, err = o.Raw(sql, chartId).QueryRows(&seriesIds)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, chartId).Find(&seriesIds).Error
 	return
 }
 

+ 48 - 27
models/data_manage/factor_edb_series_mapping.go

@@ -1,9 +1,9 @@
 package data_manage
 
 import (
+	"eta_gn/eta_task/global"
 	"eta_gn/eta_task/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strings"
 	"time"
 )
@@ -43,12 +43,14 @@ func (m *FactorEdbSeriesMapping) Cols() FactorEdbSeriesMappingCols {
 }
 
 func (m *FactorEdbSeriesMapping) Create() (err error) {
-	o := orm.NewOrm()
-	id, err := o.Insert(m)
-	if err != nil {
-		return
-	}
-	m.FactorEdbSeriesMappingId = int(id)
+	//o := orm.NewOrm()
+	//id, err := o.Insert(m)
+	//if err != nil {
+	//	return
+	//}
+	//m.FactorEdbSeriesMappingId = int(id)
+
+	err = global.DEFAULT_DmSQL.Create(m).Error
 	return
 }
 
@@ -56,21 +58,27 @@ func (m *FactorEdbSeriesMapping) CreateMulti(items []*FactorEdbSeriesMapping) (e
 	if len(items) == 0 {
 		return
 	}
-	o := orm.NewOrm()
-	_, err = o.InsertMulti(len(items), items)
+	//o := orm.NewOrm()
+	//_, err = o.InsertMulti(len(items), items)
+
+	err = global.DEFAULT_DmSQL.CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 func (m *FactorEdbSeriesMapping) Update(cols []string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Update(m, cols...)
+	//o := orm.NewOrm()
+	//_, err = o.Update(m, cols...)
+
+	err = global.DEFAULT_DmSQL.Select(cols).Updates(m).Error
 	return
 }
 
 func (m *FactorEdbSeriesMapping) Remove() (err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	_, err = o.Raw(sql, m.FactorEdbSeriesMappingId).Exec()
+	//_, err = o.Raw(sql, m.FactorEdbSeriesMappingId).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, m.FactorEdbSeriesMappingId).Error
 	return
 }
 
@@ -78,9 +86,11 @@ func (m *FactorEdbSeriesMapping) MultiRemove(ids []int) (err error) {
 	if len(ids) == 0 {
 		return
 	}
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s IN (%s)`, m.TableName(), m.Cols().PrimaryId, utils.GetOrmInReplace(len(ids)))
-	_, err = o.Raw(sql, ids).Exec()
+	//_, err = o.Raw(sql, ids).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, ids).Error
 	return
 }
 
@@ -88,39 +98,47 @@ func (m *FactorEdbSeriesMapping) RemoveByCondition(condition string, pars []inte
 	if condition == "" {
 		return
 	}
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s`, m.TableName(), condition)
-	_, err = o.Raw(sql, pars).Exec()
+	//_, err = o.Raw(sql, pars).Exec()
+
+	err = global.DEFAULT_DmSQL.Exec(sql, pars).Error
 	return
 }
 
 func (m *FactorEdbSeriesMapping) GetItemById(id int) (item *FactorEdbSeriesMapping, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	err = o.Raw(sql, id).QueryRow(&item)
+	//err = o.Raw(sql, id).QueryRow(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, id).First(&item).Error
 	return
 }
 
 func (m *FactorEdbSeriesMapping) GetItemByCondition(condition string, pars []interface{}, orderRule string) (item *FactorEdbSeriesMapping, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	order := ``
 	if orderRule != "" {
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s %s LIMIT 1`, m.TableName(), condition, order)
-	err = o.Raw(sql, pars).QueryRow(&item)
+	//err = o.Raw(sql, pars).QueryRow(&item)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).First(&item).Error
 	return
 }
 
 func (m *FactorEdbSeriesMapping) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = o.Raw(sql, pars).QueryRow(&count)
+	//err = o.Raw(sql, pars).QueryRow(&count)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).Scan(&count).Error
 	return
 }
 
 func (m *FactorEdbSeriesMapping) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*FactorEdbSeriesMapping, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -130,12 +148,13 @@ func (m *FactorEdbSeriesMapping) GetItemsByCondition(condition string, pars []in
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars).QueryRows(&items)
+	//_, err = o.Raw(sql, pars).QueryRows(&items)
+	err = global.DEFAULT_DmSQL.Raw(sql, pars).Find(&items).Error
 	return
 }
 
 func (m *FactorEdbSeriesMapping) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*FactorEdbSeriesMapping, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -145,7 +164,9 @@ func (m *FactorEdbSeriesMapping) GetPageItemsByCondition(condition string, pars
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	//_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+
+	err = global.DEFAULT_DmSQL.Raw(sql, pars, startSize, pageSize).Find(&items).Error
 	return
 }