predict_edb_rule_data.go 1.3 KB

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