predict_edb_rule_data.go 1.5 KB

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