predict_edb_rule_data.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // PredictEdbRuleData 预测指标,动态规则的计算数据
  7. type PredictEdbRuleData struct {
  8. PredictEdbRuleDataId int `orm:"column(predict_edb_rule_data_id);pk"`
  9. EdbInfoId int
  10. ConfigId int
  11. DataTime string
  12. Value float64
  13. CreateTime time.Time
  14. ModifyTime time.Time
  15. DataTimestamp int64
  16. }
  17. // GetPredictEdbRuleDataList 根据基础预测指标id集合 获取 所有的普通指标列表数据
  18. func GetPredictEdbRuleDataList(edbInfoId, configId int, startDate, endDate string) (list []*PredictEdbRuleData, err error) {
  19. o := orm.NewOrmUsingDB("data")
  20. var pars []interface{}
  21. sql := ` SELECT * FROM predict_edb_rule_data WHERE edb_info_id = ? AND config_id = ? `
  22. if startDate != "" {
  23. sql += ` AND data_time>=? `
  24. pars = append(pars, startDate)
  25. }
  26. if endDate != "" {
  27. sql += ` AND data_time<=? `
  28. pars = append(pars, endDate)
  29. }
  30. sql += ` ORDER BY data_time ASC `
  31. _, err = o.Raw(sql, edbInfoId, configId, pars).QueryRows(&list)
  32. return
  33. }