predict_edb_rule_data.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package models
  2. import (
  3. "eta_gn/eta_index_lib/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 string
  13. CreateTime time.Time
  14. ModifyTime time.Time
  15. DataTimestamp int64
  16. }
  17. // PredictEdbRuleDataItem 预测指标,动态规则的计算数据
  18. type PredictEdbRuleDataItem struct {
  19. PredictEdbRuleDataId int `gorm:"primaryKey;autoIncrement;column:predict_edb_rule_data_id"`
  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. var pars []interface{}
  31. sql := ` SELECT * FROM predict_edb_rule_data WHERE edb_info_id = ? AND config_id = ? `
  32. if startDate != "" {
  33. sql += ` AND data_time>=? `
  34. pars = append(pars, startDate)
  35. }
  36. if endDate != "" {
  37. sql += ` AND data_time<=? `
  38. pars = append(pars, endDate)
  39. }
  40. sql += ` ORDER BY data_time ASC `
  41. err = global.DEFAULT_DmSQL.Raw(sql, edbInfoId, configId, pars).Scan(&list).Error
  42. return
  43. }