edb_data_wind.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type EdbDataWind struct {
  7. EdbDataId int `orm:"column(edb_data_id);pk"`
  8. EdbInfoId int
  9. EdbCode string
  10. DataTime string
  11. Value float64
  12. Status int
  13. CreateTime time.Time
  14. ModifyTime time.Time
  15. DataTimestamp int64
  16. }
  17. func AddEdbDataWind(items []*EdbDataWind) (err error) {
  18. o := orm.NewOrm()
  19. _, err = o.InsertMulti(1, items)
  20. return
  21. }
  22. func ModifyEdbDataWind(edbInfoId int64, edbCode, dataTime string, value float64) (err error) {
  23. o := orm.NewOrm()
  24. sql := ` UPDATE edb_data_wind SET edb_info_id=?,value=?,status=1,modify_time=NOW() WHERE edb_code=? AND data_time=? `
  25. _, err = o.Raw(sql, edbInfoId, value, edbCode, dataTime).Exec()
  26. return
  27. }
  28. func ModifyEdbDataWindStatus(edbInfoId int64, edbCode string) (err error) {
  29. o := orm.NewOrm()
  30. sql := ` UPDATE edb_data_wind SET edb_info_id=?, status=1,modify_time=NOW() WHERE edb_code=? `
  31. _, err = o.Raw(sql, edbInfoId, edbCode).Exec()
  32. return
  33. }
  34. func GetEdbDataWindCount(edbCode, dataTime string) (count int, err error) {
  35. o := orm.NewOrm()
  36. sql := ` SELECT COUNT(1) AS count FROM edb_data_wind WHERE edb_code=? AND data_time=? `
  37. err = o.Raw(sql, edbCode, dataTime).QueryRow(&count)
  38. return
  39. }
  40. func GetEdbDataWindMaxOrMinDate(edbInfoId int) (min_date, max_date string, err error) {
  41. o := orm.NewOrm()
  42. sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM edb_data_wind WHERE edb_info_id=? `
  43. err = o.Raw(sql, edbInfoId).QueryRow(&min_date, &max_date)
  44. return
  45. }