|
@@ -3,6 +3,7 @@ package data_manage
|
|
|
import (
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
+ "hongze/hz_eta_api/utils"
|
|
|
)
|
|
|
|
|
|
type BaiinfoClassify struct {
|
|
@@ -31,21 +32,21 @@ func GetBaiinfoFrequencyByClassifyId(classifyId int) (items []*GlFrequency, err
|
|
|
|
|
|
type BaiinfoIndex struct {
|
|
|
BaseFromBaiinfoIndexId int `orm:"column(base_from_baiinfo_index_id);pk"`
|
|
|
- Interface string
|
|
|
- Name string
|
|
|
- IndexCode string
|
|
|
- IndexName string
|
|
|
- Type1 string `orm:"column(type_1)"`
|
|
|
- Type2 string `orm:"column(type_2)"`
|
|
|
- Type3 string `orm:"column(type_3)"`
|
|
|
- Frequency string
|
|
|
- Unit string
|
|
|
- ApiStartTime string
|
|
|
- ApiUpdateTime string
|
|
|
- StartTime string
|
|
|
- FinishTime string
|
|
|
- CreateTime string
|
|
|
- ModifyTime string
|
|
|
+ Interface string
|
|
|
+ Name string
|
|
|
+ IndexCode string
|
|
|
+ IndexName string
|
|
|
+ Type1 string `orm:"column(type_1)"`
|
|
|
+ Type2 string `orm:"column(type_2)"`
|
|
|
+ Type3 string `orm:"column(type_3)"`
|
|
|
+ Frequency string
|
|
|
+ Unit string
|
|
|
+ ApiStartTime string
|
|
|
+ ApiUpdateTime string
|
|
|
+ StartTime string
|
|
|
+ FinishTime string
|
|
|
+ CreateTime string
|
|
|
+ ModifyTime string
|
|
|
}
|
|
|
|
|
|
func GetBaiinfoIndex(condition string, pars interface{}) (items []*BaiinfoIndex, err error) {
|
|
@@ -60,26 +61,28 @@ func GetBaiinfoIndex(condition string, pars interface{}) (items []*BaiinfoIndex,
|
|
|
}
|
|
|
|
|
|
type BaiinfoExportIndex struct {
|
|
|
- TypeName string
|
|
|
- IndexCode string
|
|
|
- IndexName string
|
|
|
- Type1 string `orm:"column(type_1)"`
|
|
|
- Type2 string `orm:"column(type_2)"`
|
|
|
- Type3 string `orm:"column(type_3)"`
|
|
|
- Frequency string
|
|
|
- Unit string
|
|
|
- ModifyTime string
|
|
|
-}
|
|
|
-
|
|
|
-func GetExportBaiinfoIndex(typeCodes string) (items []*BaiinfoExportIndex, err error) {
|
|
|
+ TypeName string
|
|
|
+ IndexCode string
|
|
|
+ IndexName string
|
|
|
+ Type1 string `orm:"column(type_1)"`
|
|
|
+ Type2 string `orm:"column(type_2)"`
|
|
|
+ Type3 string `orm:"column(type_3)"`
|
|
|
+ Frequency string
|
|
|
+ Unit string
|
|
|
+ ModifyTime string
|
|
|
+}
|
|
|
+
|
|
|
+func GetExportBaiinfoIndex(typeCodes []string) (items []*BaiinfoExportIndex, err error) {
|
|
|
+ if len(typeCodes) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
- sql := ` SELECT *,CONCAT(type_2, "#", type_3) AS type_name FROM base_from_baiinfo_index WHERE CONCAT(type_2, "#", type_3) IN (` + typeCodes + `) ORDER BY frequency ASC,index_code ASC`
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
-
|
|
|
+ sql := ` SELECT *,CONCAT(type_2, "#", type_3) AS type_name FROM base_from_baiinfo_index WHERE CONCAT(type_2, "#", type_3) IN (` + utils.GetOrmInReplace(len(typeCodes)) + `) ORDER BY frequency ASC,index_code ASC`
|
|
|
+ _, err = o.Raw(sql, typeCodes).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetBaiinfoFrequency(classifyId int ) (items []*string,err error){
|
|
|
+func GetBaiinfoFrequency(classifyId int) (items []*string, err error) {
|
|
|
sql := `SELECT DISTINCT frequency FROM base_from_baiinfo_index WHERE classify_id=? ORDER BY FIELD(frequency,'日度','周度','月度','季度','半年','年度') `
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
_, err = o.Raw(sql, classifyId).QueryRows(&items)
|
|
@@ -95,22 +98,22 @@ func GetBaiinfoFrequencyByCode(code string) (items []*string, err error) {
|
|
|
|
|
|
type BaiinfoIndexList struct {
|
|
|
BaseFromBaiinfoIndexId int `orm:"column(base_from_baiinfo_index_id);pk"`
|
|
|
- Interface string
|
|
|
- Name string
|
|
|
- IndexCode string
|
|
|
- IndexName string
|
|
|
- Type1 string `orm:"column(type_1)"`
|
|
|
- Type2 string `orm:"column(type_2)"`
|
|
|
- Type3 string `orm:"column(type_3)"`
|
|
|
- Frequency string
|
|
|
- Unit string
|
|
|
- ApiStartTime string
|
|
|
- ApiUpdateTime string
|
|
|
- StartTime string
|
|
|
- FinishTime string
|
|
|
- ModifyTime string
|
|
|
- DataList []*BaiinfoIndexData
|
|
|
- Paging *paging.PagingItem `description:"分页数据"`
|
|
|
+ Interface string
|
|
|
+ Name string
|
|
|
+ IndexCode string
|
|
|
+ IndexName string
|
|
|
+ Type1 string `orm:"column(type_1)"`
|
|
|
+ Type2 string `orm:"column(type_2)"`
|
|
|
+ Type3 string `orm:"column(type_3)"`
|
|
|
+ Frequency string
|
|
|
+ Unit string
|
|
|
+ ApiStartTime string
|
|
|
+ ApiUpdateTime string
|
|
|
+ StartTime string
|
|
|
+ FinishTime string
|
|
|
+ ModifyTime string
|
|
|
+ DataList []*BaiinfoIndexData
|
|
|
+ Paging *paging.PagingItem `description:"分页数据"`
|
|
|
}
|
|
|
|
|
|
type BaiinfoIndexData struct {
|
|
@@ -160,11 +163,14 @@ func GetBaiinfoDataMaxCount(classifyId int) (count int, err error) {
|
|
|
}
|
|
|
|
|
|
type ExportBaiinfoDataMaxCount struct {
|
|
|
- TypeName string
|
|
|
- Count int
|
|
|
+ TypeName string
|
|
|
+ Count int
|
|
|
}
|
|
|
|
|
|
-func GetExportBaiinfoDataMaxCount(typeCodes string) (items []*ExportBaiinfoDataMaxCount, err error) {
|
|
|
+func GetExportBaiinfoDataMaxCount(typeCodes []string) (items []*ExportBaiinfoDataMaxCount, err error) {
|
|
|
+ if len(typeCodes) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT
|
|
|
MAX(t.num) AS count,
|
|
@@ -178,26 +184,29 @@ func GetExportBaiinfoDataMaxCount(typeCodes string) (items []*ExportBaiinfoDataM
|
|
|
base_from_baiinfo_index AS a
|
|
|
INNER JOIN base_from_baiinfo_data AS b ON a.index_code = b.index_code
|
|
|
WHERE
|
|
|
- CONCAT(a.type_2, "#", a.type_3) IN (` + typeCodes + `)
|
|
|
+ CONCAT(a.type_2, "#", a.type_3) IN (` + utils.GetOrmInReplace(len(typeCodes)) + `)
|
|
|
GROUP BY
|
|
|
a.base_from_baiinfo_index_id
|
|
|
) AS t
|
|
|
GROUP BY
|
|
|
type_name `
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, typeCodes).QueryRows(&items)
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
type ExportBaiinfoIndexData struct {
|
|
|
- Value string `orm:"column(value)" description:"日期"`
|
|
|
- DataTime string `orm:"column(data_time)" description:"值"`
|
|
|
- IndexCode string `orm:"column(index_code)" description:"指标编码"`
|
|
|
+ Value string `orm:"column(value)" description:"日期"`
|
|
|
+ DataTime string `orm:"column(data_time)" description:"值"`
|
|
|
+ IndexCode string `orm:"column(index_code)" description:"指标编码"`
|
|
|
}
|
|
|
|
|
|
-func GetExportBaiinfoIndexDataByCodes(indexCodes string) (items []*ExportBaiinfoIndexData, err error) {
|
|
|
+func GetExportBaiinfoIndexDataByCodes(indexCodes []string) (items []*ExportBaiinfoIndexData, err error) {
|
|
|
+ if len(indexCodes) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
- sql := ` SELECT index_code,data_time,value FROM base_from_baiinfo_data WHERE index_code IN (` + indexCodes + `) ORDER BY data_time DESC `
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ sql := ` SELECT index_code,data_time,value FROM base_from_baiinfo_data WHERE index_code IN (` + utils.GetOrmInReplace(len(indexCodes)) + `) ORDER BY data_time DESC `
|
|
|
+ _, err = o.Raw(sql, indexCodes).QueryRows(&items)
|
|
|
return
|
|
|
}
|