|
@@ -93,11 +93,25 @@ func GetEdbDataList(source, endInfoId int, startDate, endDate string) (list []*E
|
|
|
list = make([]*EdbDataList, 0)
|
|
|
return list, err
|
|
|
}
|
|
|
- sql := `SELECT edb_data_id,edb_info_id,data_time,TRUNCATE(value,2) AS value,data_timestamp FROM %s WHERE edb_info_id=? AND data_time>=? AND data_time<=? ORDER BY data_time ASC `
|
|
|
+ var pars []interface{}
|
|
|
+ var condition string
|
|
|
+ if startDate != "" {
|
|
|
+ condition += ` AND data_time>=? `
|
|
|
+ pars = append(pars, startDate)
|
|
|
+ }
|
|
|
+ if endDate != "" {
|
|
|
+ condition += ` AND data_time<=? `
|
|
|
+ pars = append(pars, endDate)
|
|
|
+ }
|
|
|
+ sql := `SELECT edb_data_id,edb_info_id,data_time,TRUNCATE(value,2) AS value,data_timestamp FROM %s WHERE edb_info_id=? `
|
|
|
+ if condition != "" {
|
|
|
+ sql += condition
|
|
|
+ }
|
|
|
+ sql += ` ORDER BY data_time ASC `
|
|
|
sql = fmt.Sprintf(sql, tableName)
|
|
|
o := orm.NewOrm()
|
|
|
o.Using("data")
|
|
|
- _, err = o.Raw(sql, endInfoId, startDate, endDate).QueryRows(&list)
|
|
|
+ _, err = o.Raw(sql, endInfoId, pars).QueryRows(&list)
|
|
|
return
|
|
|
}
|
|
|
|