predict_edb_rule_data.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package data_manage
  2. import (
  3. "eta_gn/eta_api/global"
  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. var pars []interface{}
  33. sql := ` SELECT * FROM predict_edb_rule_data WHERE edb_info_id = ? AND config_id = ? `
  34. if startDate != "" {
  35. sql += ` AND data_time>=? `
  36. pars = append(pars, startDate)
  37. }
  38. if endDate != "" {
  39. sql += ` AND data_time<=? `
  40. pars = append(pars, endDate)
  41. }
  42. sql += ` ORDER BY data_time ASC `
  43. err = global.DmSQL["data"].Raw(sql, edbInfoId, configId, pars).Find(&list).Error
  44. return
  45. }