predict_edb_rule_data.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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. 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 = global.DmSQL["data"].Raw(sql, utils.ForwardPars(pars, edbInfoId, configId)...).Find(&list).Error
  32. return
  33. }