|
@@ -2,9 +2,10 @@ package data_manage
|
|
|
|
|
|
import (
|
|
|
"eta/eta_api/utils"
|
|
|
+ "time"
|
|
|
+
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
- "time"
|
|
|
)
|
|
|
|
|
|
type BaseFromYongyiIndex struct {
|
|
@@ -23,6 +24,9 @@ type BaseFromYongyiIndexList struct {
|
|
|
YongyiIndexId int `orm:"column(yongyi_index_id);pk"`
|
|
|
ClassifyId int
|
|
|
Interface string
|
|
|
+ EdbInfoId int
|
|
|
+ EdbUniqueCode string `description:"指标库唯一编码"`
|
|
|
+ EdbClassifyId int `description:"指标库分类ID"`
|
|
|
IndexCode string
|
|
|
IndexName string
|
|
|
Frequency string
|
|
@@ -30,6 +34,7 @@ type BaseFromYongyiIndexList struct {
|
|
|
Sort int
|
|
|
CreateTime string
|
|
|
ModifyTime string
|
|
|
+ EdbExist int `description:"指标库是否已添加:0-否;1-是"`
|
|
|
DataList []*BaseFromYongyiData
|
|
|
Paging *paging.PagingItem `description:"分页数据"`
|
|
|
}
|
|
@@ -37,6 +42,7 @@ type BaseFromYongyiIndexList struct {
|
|
|
type YongyiSingleDataResp struct {
|
|
|
YongyiIndexId int
|
|
|
ClassifyId int
|
|
|
+ EdbInfoId int
|
|
|
IndexCode string
|
|
|
IndexName string
|
|
|
Frequency string
|
|
@@ -44,6 +50,7 @@ type YongyiSingleDataResp struct {
|
|
|
StartTime string
|
|
|
CreateTime string
|
|
|
ModifyTime string
|
|
|
+ EdbExist int `description:"指标库是否已添加:0-否;1-是"`
|
|
|
Data []*YongyiSingleData
|
|
|
}
|
|
|
|
|
@@ -52,6 +59,13 @@ type YongyiSingleData struct {
|
|
|
DataTime string `orm:"column(data_time)" description:"值"`
|
|
|
}
|
|
|
|
|
|
+func GetYongyiIndexByClassifyId(classifyId int) (items []*BaseFromYongyiIndex, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := ` SELECT yongyi_index_id, classify_id, index_code, index_name FROM base_from_yongyi_index WHERE classify_id=? ORDER BY sort ASC, yongyi_index_id ASC `
|
|
|
+ _, err = o.Raw(sql, classifyId).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
func GetYongyiIndex(condition string, pars interface{}) (items []*BaseFromYongyiIndexList, err error) {
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM base_from_yongyi_index WHERE 1=1 `
|
|
@@ -78,12 +92,51 @@ func GetYongyiIndexData(indexCode string, startSize, pageSize int) (items []*Bas
|
|
|
}
|
|
|
|
|
|
func GetYongyiIndexDataByCodes(indexCode []string) (items []*BaseFromYongyiData, err error) {
|
|
|
+ if len(indexCode) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM base_from_yongyi_data WHERE index_code in (` + utils.GetOrmInReplace(len(indexCode)) + `) ORDER BY data_time DESC `
|
|
|
_, err = o.Raw(sql, indexCode).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// GetYongyiByConditionAndFrequency 根据条件获取涌益咨询指标列表
|
|
|
+func GetYongyiByConditionAndFrequency(condition, frequency string, pars []interface{}) (items []*BaseFromYongyiIndex, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := ` SELECT * FROM base_from_yongyi_index WHERE 1=1 `
|
|
|
+
|
|
|
+ if condition != "" {
|
|
|
+ sql += condition
|
|
|
+ }
|
|
|
+ sql += ` AND frequency=?`
|
|
|
+ sql += ` ORDER BY sort ASC, yongyi_index_id ASC`
|
|
|
+ _, err = o.Raw(sql, pars, frequency).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func GetYongyiFrequencyByCondition(condition string, pars []interface{}) (items []string, err error) {
|
|
|
+ sql := `SELECT DISTINCT frequency FROM base_from_yongyi_index WHERE 1=1 `
|
|
|
+ if condition != "" {
|
|
|
+ sql += condition
|
|
|
+ }
|
|
|
+ sql += ` ORDER BY FIELD(frequency,'日度','周度','旬度','月度','季度','半年度','年度') `
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ _, err = o.Raw(sql, pars...).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// GetYongyiDataDataTimeByIndexId 根据指标id获取指标数据的日期列表
|
|
|
+func GetYongyiDataDataTimeByIndexId(indexIdList []int) (items []string, err error) {
|
|
|
+ if len(indexIdList) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := ` SELECT DISTINCT data_time FROM base_from_yongyi_data WHERE yongyi_index_id IN (` + utils.GetOrmInReplace(len(indexIdList)) + `) ORDER BY data_time DESC`
|
|
|
+ _, err = o.Raw(sql, indexIdList).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
type BaseFromYongyiData struct {
|
|
|
YongyiDataId int `orm:"column(yongyi_data_id);pk"`
|
|
|
YongyiIndexId int
|
|
@@ -96,10 +149,11 @@ type BaseFromYongyiData struct {
|
|
|
}
|
|
|
|
|
|
type BaseFromYongyiIndexSearchItem struct {
|
|
|
- YongyiIndexId int `orm:"column(yongyi_index_id);pk"`
|
|
|
- ClassifyId int
|
|
|
- IndexCode string
|
|
|
- IndexName string
|
|
|
+ YongyiIndexId int `orm:"column(yongyi_index_id);pk"`
|
|
|
+ ClassifyId int
|
|
|
+ ParentClassifyId int
|
|
|
+ IndexCode string
|
|
|
+ IndexName string
|
|
|
}
|
|
|
|
|
|
// GetYongyiItemList 模糊查询Yongyi数据库指标列表
|