zwxi 7 months ago
parent
commit
ed3b853e9e
2 changed files with 43 additions and 10 deletions
  1. 9 9
      controllers/oilchem_data.go
  2. 34 1
      models/data_manage/base_from_oilchem.go

+ 9 - 9
controllers/oilchem_data.go

@@ -72,25 +72,25 @@ func (this *TradeCommonController) OilchemIndexList() {
 	var pars []interface{}
 
 	if classifyId > 0 {
-		condition += ` AND classify_id=? `
+		condition += ` AND b.classify_id=? `
 		pars = append(pars, classifyId)
 	}
 
-	keyword := this.GetString("KeyWord")
-	if keyword != "" {
-		condition += ` AND (index_code =? OR index_name LIKE ?)  `
-		pars = append(pars, keyword)
-		pars = append(pars, "%"+keyword+"%")
-	}
+	//keyword := this.GetString("KeyWord")
+	//if keyword != "" {
+	//	condition += ` AND (index_code =? OR index_name LIKE ?)  `
+	//	pars = append(pars, keyword)
+	//	pars = append(pars, "%"+keyword+"%")
+	//}
 
-	indexList, e := data_manage.GetOilchemIndexList(condition, pars, startSize, pageSize)
+	indexList, e := data_manage.GetOilchemIndexViewList(condition, pars, startSize, pageSize)
 	if e != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取隆众资讯分类数据分类失败, Err: " + e.Error()
 		return
 	}
 
-	total, err := data_manage.GetOilchemIndexListCount(condition, pars)
+	total, err := data_manage.GetOilchemIndexViewListCount(condition, pars)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取隆众资讯分类数据分类失败, Err: " + err.Error()

+ 34 - 1
models/data_manage/base_from_oilchem.go

@@ -63,7 +63,7 @@ type BaseFromOilchemIndexList struct {
 
 
 type BaseFromOilchemIndexListResp struct {
-	List   []*BaseFromOilchemIndex
+	List   []*BaseFromOilchemIndexView
 	Paging *paging.PagingItem `description:"分页数据"`
 }
 
@@ -242,3 +242,36 @@ func GetOilchemFrequencyByCondition(condition string, pars []interface{}) (items
 	_, err = o.Raw(sql, pars...).QueryRows(&items)
 	return
 }
+
+
+// GetOilchemIndexViewList 根据分类id获取隆众资讯指标列表
+func GetOilchemIndexViewList(condition string, pars []interface{}, startSize, pageSize int) (items []*BaseFromOilchemIndexView, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT b.*, e.edb_info_id,
+	CASE WHEN e.edb_info_id IS NULL THEN 0 ELSE 1 END AS edb_exist
+	FROM base_from_oilchem_index AS b
+	LEFT JOIN edb_info AS e ON b.index_code=e.edb_code AND e.source=89
+	WHERE 1=1   `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY b.modify_time ASC LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+
+// GetOilchemIndexViewListCount 根据分类id获取隆众资讯指标列表
+func GetOilchemIndexViewListCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT COUNT(1) AS count
+	FROM base_from_oilchem_index AS b
+	LEFT JOIN edb_info AS e ON b.index_code=e.edb_code AND e.source=89
+	WHERE 1=1   `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY b.modify_time ASC `
+	err = o.Raw(sql, pars).QueryRow(&count)
+	return
+}