Browse Source

修改钢炼化工数据获取

tuoling805 1 year ago
parent
commit
25208c867c
2 changed files with 22 additions and 5 deletions
  1. 13 1
      controllers/base_from_mysteel_chemical.go
  2. 9 4
      models/base_from_mysteel_chemical.go

+ 13 - 1
controllers/base_from_mysteel_chemical.go

@@ -671,10 +671,22 @@ func (this *MySteelChemicalController) GetIndexCountByFrequency() {
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
+	var condition string
+	var pars []interface{}
+
+	if req.Frequency != "" {
+		condition += ` AND frequency = ? `
+		pars = append(pars, req.Frequency)
+	}
+
+	if req.EndDate != "" {
+		condition += ` AND end_date < ? `
+		pars = append(pars, req.EndDate)
+	}
 
 	indexObj := new(models.BaseFromMysteelChemicalIndex)
 	// 获取未合并的指标总数量
-	indexTotal, err := indexObj.GetIndexCountByFrequency(req.Frequency)
+	indexTotal, err := indexObj.GetIndexCountByFrequency(condition, pars)
 	if err != nil {
 		return
 	}

+ 9 - 4
models/base_from_mysteel_chemical.go

@@ -272,6 +272,7 @@ func (m *BaseFromMysteelChemicalIndex) GetNoMergeIndexByFrequencyCount(frequency
 // GetMaxFileIndexReq 获取最大文件数请求
 type GetMaxFileIndexReq struct {
 	Frequency string
+	EndDate   string
 }
 
 // GetMaxFileIndex 获取最大文件的
@@ -450,10 +451,14 @@ type GetIndexDetailReq struct {
 }
 
 // GetIndexCountByFrequency 获取未合并的指标总数量
-func (m *BaseFromMysteelChemicalIndex) GetIndexCountByFrequency(frequency string) (total int64, err error) {
+func (m *BaseFromMysteelChemicalIndex) GetIndexCountByFrequency(condition string, pars []interface{}) (total int64, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT count(1) AS total FROM base_from_mysteel_chemical_index WHERE frequency = ? AND index_name NOT LIKE "%停%"  `
-	err = o.Raw(sql, frequency).QueryRow(&total)
+
+	sql := `SELECT count(1) AS total FROM base_from_mysteel_chemical_index WHERE 1=1 AND index_name NOT LIKE "%停%"  `
+	if condition != "" {
+		sql += condition
+	}
+	err = o.Raw(sql, pars).QueryRow(&total)
 
 	return
 }
@@ -476,7 +481,7 @@ type GetIndexPageByFrequencyPageReq struct {
 // GetNoMergeIndexByFrequencyPage 获取未合并的指标列表
 func (m *BaseFromMysteelChemicalIndex) GetIndexPageByFrequency(condition string, pars []interface{}, startSize, pageSize int) (items []*BaseFromMysteelChemicalIndex, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM base_from_mysteel_chemical_index WHERE 1=1 `
+	sql := `SELECT * FROM base_from_mysteel_chemical_index WHERE 1=1 AND index_name NOT LIKE "%停%" `
 	if condition != "" {
 		sql += condition
 	}