predict_edb_rule_data.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package models
  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 string
  13. CreateTime time.Time
  14. ModifyTime time.Time
  15. DataTimestamp int64
  16. }
  17. // PredictEdbRuleDataItem 预测指标,动态规则的计算数据
  18. type PredictEdbRuleDataItem struct {
  19. PredictEdbRuleDataId int `orm:"column(predict_edb_rule_data_id);pk"`
  20. EdbInfoId int
  21. ConfigId int
  22. DataTime string
  23. Value float64
  24. CreateTime time.Time
  25. ModifyTime time.Time
  26. DataTimestamp int64
  27. }
  28. // GetPredictEdbRuleDataItemList 根据基础预测指标id集合 获取 所有的普通指标列表数据
  29. func GetPredictEdbRuleDataItemList(edbInfoId, configId int, startDate, endDate string) (list []*PredictEdbRuleDataItem, err error) {
  30. o := orm.NewOrm()
  31. var pars []interface{}
  32. sql := ` SELECT * FROM predict_edb_rule_data WHERE edb_info_id = ? AND config_id = ? `
  33. if startDate != "" {
  34. sql += ` AND data_time>=? `
  35. pars = append(pars, startDate)
  36. }
  37. if endDate != "" {
  38. sql += ` AND data_time<=? `
  39. pars = append(pars, endDate)
  40. }
  41. sql += ` ORDER BY data_time ASC `
  42. _, err = o.Raw(sql, edbInfoId, configId, pars).QueryRows(&list)
  43. return
  44. }