|
@@ -1,17 +1,18 @@
|
|
|
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"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
+
|
|
|
+ "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
)
|
|
|
|
|
|
type ChartEdbMapping struct {
|
|
|
- ChartEdbMappingId int `orm:"column(chart_edb_mapping_id);pk"`
|
|
|
+ ChartEdbMappingId int `gorm:"column(chart_edb_mapping_id);primaryKey"`
|
|
|
ChartInfoId int `description:"图表id"`
|
|
|
EdbInfoId int `description:"指标id"`
|
|
|
CreateTime time.Time `description:"创建时间"`
|
|
@@ -37,86 +38,99 @@ type ChartEdbMapping struct {
|
|
|
ConvertEnUnit string `description:"数据转换单位"`
|
|
|
}
|
|
|
|
|
|
+func (m *ChartEdbMapping) TableName() string {
|
|
|
+ return "chart_edb_mapping"
|
|
|
+}
|
|
|
+
|
|
|
func AddChartEdbMapping(items []*ChartEdbMapping) (err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
- _, err = o.InsertMulti(1, items)
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
+ err = o.CreateInBatches(items, utils.MultiAddNum).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetChartEdbMappingList(chartInfoId int) (list []*ChartEdbInfoMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
- sql := ` SELECT a.*,b.source_name,b.source,b.sub_source,b.classify_id,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,
|
|
|
-b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type,b.edb_type,b.is_join_permission,
|
|
|
-a.is_convert, a.convert_type, a.convert_value, a.convert_unit, a.convert_en_unit
|
|
|
- FROM chart_edb_mapping AS a
|
|
|
- INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
|
|
|
- WHERE chart_info_id=?
|
|
|
- ORDER BY chart_edb_mapping_id ASC `
|
|
|
- _, err = o.Raw(sql, chartInfoId).QueryRows(&list)
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
+ sql := `SELECT a.*, b.source_name, b.source, b.sub_source, b.classify_id, b.edb_code, b.edb_name, b.edb_name_en,
|
|
|
+ b.frequency, b.unit, b.unit_en, b.start_date, b.end_date, b.modify_time, b.latest_date,
|
|
|
+ b.latest_value, b.unique_code, b.edb_info_type AS edb_info_category_type,
|
|
|
+ b.edb_type, b.is_join_permission, a.is_convert, a.convert_type,
|
|
|
+ a.convert_value, a.convert_unit, a.convert_en_unit
|
|
|
+ FROM chart_edb_mapping AS a
|
|
|
+ INNER JOIN edb_info AS b ON a.edb_info_id = b.edb_info_id
|
|
|
+ WHERE chart_info_id = ?
|
|
|
+ ORDER BY chart_edb_mapping_id ASC`
|
|
|
+ err = o.Raw(sql, chartInfoId).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetChartMappingList(chartInfoId int) (list []*ChartEdbMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
- sql := ` SELECT a.*
|
|
|
- FROM chart_edb_mapping AS a
|
|
|
- WHERE chart_info_id=?
|
|
|
- ORDER BY chart_edb_mapping_id ASC `
|
|
|
- _, err = o.Raw(sql, chartInfoId).QueryRows(&list)
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
+ sql := `SELECT * FROM chart_edb_mapping WHERE chart_info_id = ? ORDER BY chart_edb_mapping_id ASC`
|
|
|
+ err = o.Raw(sql, chartInfoId).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetChartEdbMappingListByChartInfoIds(chartInfoIds string) (list []*ChartEdbInfoMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
- sql := ` SELECT a.*,b.source_name,b.source,b.sub_source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type,b.edb_type,b.classify_id,b.is_join_permission
|
|
|
- FROM chart_edb_mapping AS a
|
|
|
- INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
|
|
|
- WHERE chart_info_id in (` + chartInfoIds + `)
|
|
|
- ORDER BY chart_edb_mapping_id ASC `
|
|
|
- _, err = o.Raw(sql).QueryRows(&list)
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
+ sql := `SELECT a.*, b.source_name, b.source, b.sub_source, b.classify_id, b.edb_code, b.edb_name, b.edb_name_en,
|
|
|
+ b.frequency, b.unit, b.unit_en, b.start_date, b.end_date, b.modify_time, b.latest_date,
|
|
|
+ b.latest_value, b.unique_code, b.edb_info_type AS edb_info_category_type,
|
|
|
+ b.edb_type, b.is_join_permission
|
|
|
+ FROM chart_edb_mapping AS a
|
|
|
+ INNER JOIN edb_info AS b ON a.edb_info_id = b.edb_info_id
|
|
|
+ WHERE chart_info_id IN (` + chartInfoIds + `)
|
|
|
+ ORDER BY chart_edb_mapping_id ASC`
|
|
|
+ err = o.Raw(sql).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetChartEdbMappingListByEdbInfoId(edbInfoStr string) (list []*ChartEdbInfoMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
- sql := ` SELECT edb_info_id,source_name,source,sub_source,edb_code,edb_name,edb_name_en,frequency,unit,unit_en,start_date,end_date,modify_time,latest_date,latest_value,unique_code,edb_info_type AS edb_info_category_type,max_value,min_value,edb_type,classify_id,is_join_permission
|
|
|
- FROM edb_info
|
|
|
- WHERE edb_info_id IN(` + edbInfoStr + `)
|
|
|
- ORDER BY FIELD(edb_info_id,` + edbInfoStr + `)
|
|
|
- `
|
|
|
- _, err = o.Raw(sql).QueryRows(&list)
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
+ sql := `SELECT edb_info_id, source_name, source, sub_source, edb_code, edb_name, edb_name_en,
|
|
|
+ frequency, unit, unit_en, start_date, end_date, modify_time, latest_date, latest_value,
|
|
|
+ unique_code, edb_info_type AS edb_info_category_type, max_value, min_value, edb_type, classify_id,
|
|
|
+ is_join_permission
|
|
|
+ FROM edb_info
|
|
|
+ WHERE edb_info_id IN (` + edbInfoStr + `)
|
|
|
+ ORDER BY FIELD(edb_info_id, ` + edbInfoStr + `)`
|
|
|
+ err = o.Raw(sql).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// GetChartEdbMappingListByEdbInfoIdList 根据指标id列表获取关联关系
|
|
|
+// GetChartEdbMappingListByEdbInfoIdList 根据指标ID列表获取映射
|
|
|
func GetChartEdbMappingListByEdbInfoIdList(edbIdList []int) (list []*ChartEdbInfoMapping, err error) {
|
|
|
num := len(edbIdList)
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
- sql := ` SELECT edb_info_id,source_name,source,sub_source,edb_code,edb_name,edb_name_en,frequency,unit,unit_en,start_date,end_date,modify_time,latest_date,latest_value,unique_code,edb_info_type AS edb_info_category_type,max_value,min_value,edb_type,classify_id,is_join_permission
|
|
|
- FROM edb_info
|
|
|
- WHERE edb_info_id IN(` + utils.GetOrmInReplace(num) + `)
|
|
|
- ORDER BY FIELD(edb_info_id,` + utils.GetOrmInReplace(num) + `)
|
|
|
- `
|
|
|
- _, err = o.Raw(sql, edbIdList, edbIdList).QueryRows(&list)
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
+ sql := `SELECT edb_info_id, source_name, source, sub_source, edb_code, edb_name, edb_name_en,
|
|
|
+ frequency, unit, unit_en, start_date, end_date, modify_time, latest_date, latest_value,
|
|
|
+ unique_code, edb_info_type AS edb_info_category_type, max_value, min_value, edb_type, classify_id,
|
|
|
+ is_join_permission
|
|
|
+ FROM edb_info
|
|
|
+ WHERE edb_info_id IN (` + utils.GetOrmInReplace(num) + `)
|
|
|
+ ORDER BY FIELD(edb_info_id, ` + utils.GetOrmInReplace(num) + `)`
|
|
|
+ err = o.Raw(sql, edbIdList).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// GetChartEdbMappingListByIdList 通过图表id列表获取
|
|
|
+// GetChartEdbMappingListByIdList 通过图表ID列表获取映射
|
|
|
func GetChartEdbMappingListByIdList(chartInfoIdList []int) (list []*ChartEdbInfoMapping, err error) {
|
|
|
num := len(chartInfoIdList)
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
- sql := ` SELECT a.*,b.source_name,b.source,b.sub_source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type,b.edb_type AS edb_info_category_type,b.classify_id,b.is_join_permission
|
|
|
- FROM chart_edb_mapping AS a
|
|
|
- INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
|
|
|
- WHERE chart_info_id in (` + utils.GetOrmInReplace(num) + `)
|
|
|
- ORDER BY chart_edb_mapping_id ASC `
|
|
|
- _, err = o.Raw(sql, chartInfoIdList).QueryRows(&list)
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
+ sql := `SELECT a.*, b.source_name, b.source, b.sub_source, b.edb_code, b.edb_name, b.edb_name_en,
|
|
|
+ b.frequency, b.unit, b.unit_en, b.start_date, b.end_date, b.modify_time, b.latest_date,
|
|
|
+ b.latest_value, b.unique_code, b.edb_info_type AS edb_info_category_type,
|
|
|
+ b.edb_type, b.is_join_permission
|
|
|
+ FROM chart_edb_mapping AS a
|
|
|
+ INNER JOIN edb_info AS b ON a.edb_info_id = b.edb_info_id
|
|
|
+ WHERE chart_info_id IN (` + utils.GetOrmInReplace(num) + `)
|
|
|
+ ORDER BY chart_edb_mapping_id ASC`
|
|
|
+ err = o.Raw(sql, chartInfoIdList).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -127,32 +141,31 @@ type RelationEdbInfoListResp struct {
|
|
|
}
|
|
|
|
|
|
func GetRelationEdbInfoListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*ChartEdbInfoMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := ` SELECT a.* FROM edb_info AS a
|
|
|
JOIN edb_info_calculate_mapping AS b on a.edb_info_id = b.edb_info_id WHERE 1=1 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
- //sql += " ORDER BY sort ASC,chart_info_id DESC LIMIT ?,? "
|
|
|
- sql += " ORDER BY a.create_time DESC LIMIT ?,? "
|
|
|
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&item)
|
|
|
+ pars = append(pars, startSize, pageSize)
|
|
|
+ err = o.Raw(sql, pars...).Find(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetRelationEdbInfoListCountByCondition(condition string, pars []interface{}) (count int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := ` SELECT COUNT(1) AS count FROM edb_info AS a
|
|
|
JOIN edb_info_calculate_mapping AS b on a.edb_info_id = b.edb_info_id WHERE 1=1 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
- err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
+ err = o.Raw(sql, pars...).Scan(&count).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetEtaEdbChartEdbMapping 商品曲线图查询对应的普通指标
|
|
|
func GetEtaEdbChartEdbMapping(chartInfoId int) (item *ChartEdbInfoMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source`
|
|
|
|
|
|
sql := ` SELECT ` + aField + `,b.source_name,b.source,b.sub_source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type,b.classify_id,b.is_join_permission
|
|
@@ -160,13 +173,13 @@ func GetEtaEdbChartEdbMapping(chartInfoId int) (item *ChartEdbInfoMapping, err e
|
|
|
INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
|
|
|
WHERE a.chart_info_id=? AND a.source = ?
|
|
|
ORDER BY chart_edb_mapping_id ASC `
|
|
|
- err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_DEFAULT).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_DEFAULT).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetEtaEdbChartEdbMappingList 商品曲线图查询对应的普通指标
|
|
|
func GetEtaEdbChartEdbMappingList(chartInfoId int) (items []*ChartEdbInfoMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source`
|
|
|
|
|
|
sql := ` SELECT ` + aField + `,b.source_name,b.source,b.sub_source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type,b.classify_id,b.is_join_permission
|
|
@@ -174,72 +187,72 @@ func GetEtaEdbChartEdbMappingList(chartInfoId int) (items []*ChartEdbInfoMapping
|
|
|
INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
|
|
|
WHERE a.chart_info_id=? AND a.source = ?
|
|
|
ORDER BY chart_edb_mapping_id ASC `
|
|
|
- _, err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_DEFAULT).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_DEFAULT).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetFutureGoodEdbChartEdbMapping 商品曲线图查询对应的商品指标
|
|
|
func GetFutureGoodEdbChartEdbMapping(chartInfoId int) (item *ChartEdbInfoMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source`
|
|
|
sql := ` SELECT ` + aField + `,b.future_good_edb_info_id,b.future_good_edb_code as edb_code,b.future_good_edb_name as edb_name,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value
|
|
|
FROM chart_edb_mapping AS a
|
|
|
INNER JOIN future_good_edb_info AS b ON a.edb_info_id=b.future_good_edb_info_id
|
|
|
WHERE a.chart_info_id=? AND a.source = ?
|
|
|
ORDER BY chart_edb_mapping_id ASC `
|
|
|
- err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_FUTURE_GOOD).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_FUTURE_GOOD).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetFutureGoodEdbChartEdbMappingList 商品曲线图查询对应的商品指标
|
|
|
func GetFutureGoodEdbChartEdbMappingList(chartInfoId int) (items []*ChartEdbInfoMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source`
|
|
|
sql := ` SELECT ` + aField + `,b.future_good_edb_info_id,b.future_good_edb_code as edb_code,b.future_good_edb_name as edb_name,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value
|
|
|
FROM chart_edb_mapping AS a
|
|
|
INNER JOIN future_good_edb_info AS b ON a.edb_info_id=b.future_good_edb_info_id
|
|
|
WHERE a.chart_info_id=? AND a.source = ?
|
|
|
ORDER BY chart_edb_mapping_id ASC `
|
|
|
- _, err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_FUTURE_GOOD).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_FUTURE_GOOD).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetChartEdbMappingListV2 根据图表id获取指标信息,不连表查询指标表
|
|
|
func GetChartEdbMappingListV2(chartInfoId int) (list []*ChartEdbInfoMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := ` SELECT a.* FROM chart_edb_mapping AS a
|
|
|
WHERE chart_info_id=?
|
|
|
ORDER BY chart_edb_mapping_id ASC `
|
|
|
- _, err = o.Raw(sql, chartInfoId).QueryRows(&list)
|
|
|
+ err = o.Raw(sql, chartInfoId).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetChartEdbMappingByEdbInfoId 根据指标id获取edb_mapping
|
|
|
func GetChartEdbMappingByEdbInfoId(edbInfoId int) (item *ChartEdbInfoMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := ` SELECT edb_info_id,source_name,classify_id,source,sub_source,edb_code,edb_name,edb_name_en,frequency,unit,unit_en,start_date,end_date,modify_time,latest_date,latest_value,unique_code,edb_info_type AS edb_info_category_type,edb_type,max_value,min_value,is_join_permission
|
|
|
FROM edb_info
|
|
|
WHERE edb_info_id = ? limit 1`
|
|
|
- err = o.Raw(sql, edbInfoId).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, edbInfoId).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetEdbMappingListByEdbInfoId 根据指标id获取edb_mapping
|
|
|
func GetEdbMappingListByEdbInfoId(edbInfoId int) (item []*ChartEdbInfoMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := ` SELECT * FROM chart_edb_mapping
|
|
|
WHERE edb_info_id = ? `
|
|
|
- _, err = o.Raw(sql, edbInfoId).QueryRows(&item)
|
|
|
+ err = o.Raw(sql, edbInfoId).Find(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetChartEdbMappingByFutureGoodEdbInfoId 根据指标id获取edb_mapping
|
|
|
func GetChartEdbMappingByFutureGoodEdbInfoId(edbInfoId int) (item *ChartEdbInfoMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := ` SELECT future_good_edb_info_id as edb_info_id,future_good_edb_code as edb_code,b.future_good_edb_name as edb_name,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.region_type
|
|
|
FROM future_good_edb_info b
|
|
|
WHERE future_good_edb_info_id = ? limit 1 `
|
|
|
- err = o.Raw(sql, edbInfoId).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, edbInfoId).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -251,7 +264,7 @@ func GetChartEdbMappingByFutureGoodEdbInfoId(edbInfoId int) (item *ChartEdbInfoM
|
|
|
// @param edbInfoList []*EdbInfo
|
|
|
// @return err error
|
|
|
func ModifyChartEdbMapping(chartInfoId int, edbInfoList []*EdbInfo) (err error) {
|
|
|
- o, err := orm.NewOrmUsingDB("data").Begin()
|
|
|
+ o := global.DbMap[utils.DbNameIndex].Begin()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -268,7 +281,7 @@ func ModifyChartEdbMapping(chartInfoId int, edbInfoList []*EdbInfo) (err error)
|
|
|
FROM chart_edb_mapping AS a
|
|
|
WHERE chart_info_id=?
|
|
|
ORDER BY chart_edb_mapping_id ASC `
|
|
|
- _, err = o.Raw(sql, chartInfoId).QueryRows(&list)
|
|
|
+ err = o.Raw(sql, chartInfoId).Find(&list).Error
|
|
|
|
|
|
if err != nil {
|
|
|
return
|
|
@@ -314,7 +327,7 @@ func ModifyChartEdbMapping(chartInfoId int, edbInfoList []*EdbInfo) (err error)
|
|
|
|
|
|
// 需要添加的话,那就添加吧
|
|
|
if len(addList) > 0 {
|
|
|
- _, err = o.InsertMulti(len(addList), addList)
|
|
|
+ err = o.CreateInBatches(addList, utils.MultiAddNum).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -331,7 +344,7 @@ func ModifyChartEdbMapping(chartInfoId int, edbInfoList []*EdbInfo) (err error)
|
|
|
//如果拼接指标变更了,那么需要删除所有的指标数据
|
|
|
sql := fmt.Sprintf(` DELETE FROM chart_edb_mapping WHERE chart_edb_mapping_id in (%s) `, removeIdStr)
|
|
|
|
|
|
- _, err = o.Raw(sql).Exec()
|
|
|
+ err = o.Exec(sql).Error
|
|
|
if err != nil {
|
|
|
err = fmt.Errorf("移除不必要的mapping失败,Err:" + err.Error())
|
|
|
return
|
|
@@ -342,12 +355,12 @@ func ModifyChartEdbMapping(chartInfoId int, edbInfoList []*EdbInfo) (err error)
|
|
|
}
|
|
|
|
|
|
func GetRelationEdbInfoListMappingByCondition(condition string, pars []interface{}) (item []*ChartEdbInfoMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
sql := ` SELECT a.* FROM edb_info AS a
|
|
|
JOIN edb_info_calculate_mapping AS b on a.edb_info_id = b.edb_info_id WHERE 1=1 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&item)
|
|
|
+ err = o.Raw(sql, pars).Find(&item).Error
|
|
|
return
|
|
|
}
|