Browse Source

Merge branch 'ETA_2.0.6' into debug

zwxi 7 months ago
parent
commit
da81ee902c
2 changed files with 58 additions and 30 deletions
  1. 19 0
      controllers/oilchem_data.go
  2. 39 30
      models/data_manage/base_from_oilchem.go

+ 19 - 0
controllers/oilchem_data.go

@@ -89,6 +89,24 @@ func (this *TradeCommonController) OilchemIndexList() {
 		br.ErrMsg = "获取隆众资讯分类数据分类失败, Err: " + e.Error()
 		return
 	}
+	indexIdList := make([]int, 0)
+	for _, v := range indexList {
+		indexIdList = append(indexIdList, v.BaseFromOilchemIndexId)
+	}
+	dataList, err := data_manage.GetOilchemDataViewList(indexIdList)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取隆众资讯分类数据分类失败, Err: " + err.Error()
+		return
+	}
+	for i, v := range indexList {
+		for _, v1 := range dataList {
+			if v.BaseFromOilchemIndexId == v1.BaseFromOilchemIndexId {
+				indexList[i].DataTime = v1.DataTime
+				indexList[i].Value = v1.Value
+			}
+		}
+	}
 
 	total, err := data_manage.GetOilchemIndexViewListCount(condition, pars)
 	if err != nil {
@@ -175,6 +193,7 @@ func (this *TradeCommonController) OilchemData() {
 	resp.IndexName = index.IndexName
 	resp.Frequency = index.Frequency
 	resp.Unit = index.Unit
+	resp.EdbExist = index.EdbExist
 
 	total, err := data_manage.GetOilchemDataListCount(condition, pars)
 	page := paging.GetPaging(currentIndex, pageSize, total)

+ 39 - 30
models/data_manage/base_from_oilchem.go

@@ -7,13 +7,13 @@ import (
 )
 
 type BaseFromOilchemClassify struct {
-	BaseFromOilchemClassifyId int       // 分类ID
-	ClassifyName          string    // 分类名称
-	ParentID              int       // 上级ID
-	Level                 int       // 层级
-	Sort                  int       // 排序
-	CreateTime            string // 创建时间
-	ModifyTime            string // 修改时间
+	BaseFromOilchemClassifyId int    // 分类ID
+	ClassifyName              string // 分类名称
+	ParentID                  int    // 上级ID
+	Level                     int    // 层级
+	Sort                      int    // 排序
+	CreateTime                string // 创建时间
+	ModifyTime                string // 修改时间
 }
 
 type BaseFromOilchemIndex struct {
@@ -50,18 +50,18 @@ type BaseFromOilchemIndexList struct {
 	BaseFromOilchemIndexId int    // 主键ID
 	IndexCode              string // 指标编码
 	IndexName              string // 指标名称
-	ClassifyId             uint   // 分类ID
+	ClassifyId             int   // 分类ID
 	Unit                   string // 单位
 	Frequency              string // 频度
 	Describe               string // 指标描述
 	Sort                   int    // 排序
 	CreateTime             string // 创建时间
 	ModifyTime             string // 修改时间
+	EdbExist               int    `description:"edb是否存在"`
 	DataList               []*BaseFromOilchemData
 	Paging                 *paging.PagingItem `description:"分页数据"`
 }
 
-
 type BaseFromOilchemIndexListResp struct {
 	List   []*BaseFromOilchemIndexView
 	Paging *paging.PagingItem `description:"分页数据"`
@@ -74,10 +74,13 @@ func GetOilchemIndexById(indexId int) (item *BaseFromOilchemIndex, err error) {
 	err = o.Raw(sql, indexId).QueryRow(&item)
 	return
 }
-func GetOilchemIndexByCode(indexCode string) (item *BaseFromOilchemIndex, err error) {
+func GetOilchemIndexByCode(indexCode string) (item *BaseFromOilchemIndexView, err error) {
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT * FROM base_from_oilchem_index WHERE 1=1 and index_code = ? `
-	sql += `ORDER BY base_from_oilchem_index_id ASC `
+	sql := ` SELECT a.*,CASE WHEN e.edb_info_id IS NULL THEN 0 ELSE 1 END AS edb_exist
+	FROM base_from_oilchem_index as a 
+LEFT JOIN edb_info AS e ON a.index_code=e.edb_code AND e.source=89 
+	WHERE 1=1 and a.index_code = ? `
+	sql += `ORDER BY a.base_from_oilchem_index_id ASC `
 	err = o.Raw(sql, indexCode).QueryRow(&item)
 	return
 }
@@ -142,7 +145,6 @@ type OilchemDataBatchListReq struct {
 	IsSelectAll bool   `description:"是否查询全部, 默认false, true:全选, false:查询已选"`
 }
 
-
 // GetOilchemIndexByCondition 根据条件获取隆众资讯指标列表
 func GetOilchemIndexByCondition(condition string, pars []interface{}) (items []*BaseFromOilchemIndex, err error) {
 	o := orm.NewOrmUsingDB("data")
@@ -176,22 +178,23 @@ func GetOilchemIndexAndEdbInfoByCondition(condition string, pars []interface{})
 
 type BaseFromOilchemIndexView struct {
 	BaseFromOilchemIndexId int    `orm:"pk"`
-	EdbInfoId            int    `description:"指标库id"`
-	ClassifyId           int    `description:"指标分类id"`
-	IndexCode            string `description:"指标编码"`
-	IndexName            string `description:"指标名称"`
-	UniqueCode           string `description:"唯一code"`
-	Frequency            string `description:"频度"`
-	Unit                 string `description:"单位"`
-	StartDate            string `description:"开始日期"`
-	EndDate              string `description:"结束日期"`
-	Sort                 int    `description:"排序"`
-	EdbExist             int    `description:"edb是否存在"`
-	EdbClassifyId        int    `description:"edb分类id"`
-	ModifyTime           string
+	EdbInfoId              int    `description:"指标库id"`
+	ClassifyId             int    `description:"指标分类id"`
+	IndexCode              string `description:"指标编码"`
+	IndexName              string `description:"指标名称"`
+	UniqueCode             string `description:"唯一code"`
+	Frequency              string `description:"频度"`
+	Unit                   string `description:"单位"`
+	StartDate              string `description:"开始日期"`
+	EndDate                string `description:"结束日期"`
+	Sort                   int    `description:"排序"`
+	EdbExist               int    `description:"edb是否存在"`
+	EdbClassifyId          int    `description:"edb分类id"`
+	ModifyTime             string
+	DataTime               string `description:"数据时间"`
+	Value                  string `description:"值"`
 }
 
-
 // ExportOilchemExcelReq 导出隆众资讯excel指标
 type ExportOilchemExcelReq struct {
 	KeyWord       string   `description:"关键字, 指标编码或指标ID"`
@@ -244,7 +247,6 @@ func GetOilchemFrequencyByCondition(condition string, pars []interface{}) (items
 	return
 }
 
-
 // GetOilchemIndexViewList 根据分类id获取隆众资讯指标列表
 func GetOilchemIndexViewList(condition string, pars []interface{}, startSize, pageSize int) (items []*BaseFromOilchemIndexView, err error) {
 	o := orm.NewOrmUsingDB("data")
@@ -261,7 +263,6 @@ func GetOilchemIndexViewList(condition string, pars []interface{}, startSize, pa
 	return
 }
 
-
 // GetOilchemIndexViewListCount 根据分类id获取隆众资讯指标列表
 func GetOilchemIndexViewListCount(condition string, pars []interface{}) (count int, err error) {
 	o := orm.NewOrmUsingDB("data")
@@ -275,4 +276,12 @@ func GetOilchemIndexViewListCount(condition string, pars []interface{}) (count i
 	sql += ` ORDER BY b.modify_time ASC `
 	err = o.Raw(sql, pars).QueryRow(&count)
 	return
-}
+}
+
+// GetOilchemDataViewList 根据指标id获取隆众资讯指标列表
+func GetOilchemDataViewList(indexIds []int) (items []*BaseFromOilchemData, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT * FROM base_from_oilchem_data WHERE base_from_oilchem_index_id IN (` + utils.GetOrmInReplace(len(indexIds)) + `)ORDER BY data_time desc  `
+	_, err = o.Raw(sql, indexIds).QueryRows(&items)
+	return
+}