base_from_trade_eic_v2.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type BaseFromTradeEicIndexV2 struct {
  7. BaseFromEicIndexId int `orm:"column(base_from_eic_index_id);pk"`
  8. Type string
  9. EicCode string
  10. Name string
  11. Status string
  12. GasDayStart string
  13. GasInStorage float64
  14. GasInStorageCode string
  15. Consumption string
  16. ConsumptionCode string
  17. ConsumptionFull string
  18. ConsumptionFullCode string
  19. Full float64
  20. FullCode string
  21. Trend float64
  22. TrendCode string
  23. Injection float64
  24. InjectionCode string
  25. Withdrawal float64
  26. WithdrawalCode string
  27. WorkingGasVolume float64
  28. WorkingGasVolumeCode string
  29. InjectionCapacity float64
  30. InjectionCapacityCode string
  31. WithdrawalCapacity float64
  32. WithdrawalCapacityCode string
  33. Info string
  34. Parent string
  35. CreateTime time.Time
  36. ModifyTime time.Time
  37. }
  38. func AddBaseFromEicIndexV2(item *BaseFromTradeEicIndexV2) (lastId int64, err error) {
  39. o := orm.NewOrmUsingDB("data")
  40. lastId, err = o.Insert(item)
  41. return
  42. }
  43. func GetSSOFromEicIndexAllV2(date string) (list []*BaseFromTradeEicIndexV2, err error) {
  44. o := orm.NewOrmUsingDB("data")
  45. sql := `SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start=? and type='sso'`
  46. _, err = o.Raw(sql, date).QueryRows(&list)
  47. return
  48. }
  49. func GetFacFromEicIndexAllV2(date string) (list []*BaseFromTradeEicIndexV2, err error) {
  50. o := orm.NewOrmUsingDB("data")
  51. sql := `SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start=? and type='fac'`
  52. _, err = o.Raw(sql, date).QueryRows(&list)
  53. return
  54. }
  55. func ModifyBaseFromEicIndexV2(gasInStorage, full, trend, injection, withdrawal float64, dataId int) (err error) {
  56. o := orm.NewOrmUsingDB("data")
  57. sql := `UPDATE base_from_trade_eic_index_v2 SET gas_in_storage=?,full=?,trend=?,injection=?,withdrawal=?,modify_time=NOW() WHERE base_from_eic_index_id=? `
  58. _, err = o.Raw(sql, gasInStorage, full, trend, injection, withdrawal, dataId).Exec()
  59. return
  60. }
  61. func GetCountryFromEicIndexAllV2(date string) (list []*BaseFromTradeEicIndexV2, err error) {
  62. o := orm.NewOrmUsingDB("data")
  63. sql := `SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start=? and type='country' `
  64. _, err = o.Raw(sql, date).QueryRows(&list)
  65. return
  66. }
  67. func GetContinentFromEicIndexAllV2(date string) (list []*BaseFromTradeEicIndexV2, err error) {
  68. o := orm.NewOrmUsingDB("data")
  69. sql := `SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start=? and type='continent' `
  70. _, err = o.Raw(sql, date).QueryRows(&list)
  71. return
  72. }
  73. func AddEicDataMultiV2(items []*BaseFromTradeEicIndexV2) (successNums int64, err error) {
  74. o := orm.NewOrmUsingDB("data")
  75. successNums, err = o.InsertMulti(1, items)
  76. return
  77. }