edb_data_gie.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package data_manage
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. type GieData struct {
  8. InputValue string `orm:"column(DATA_VALUE)" description:"日期"`
  9. DataTime string `orm:"column(DATA_DATE)" description:"值"`
  10. }
  11. func GetEdbDataGieMaxOrMinDate(edbCode string) (minDate, maxDate string, err error) {
  12. o := orm.NewOrmUsingDB("data")
  13. sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_gie WHERE edb_code=? `
  14. err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
  15. return
  16. }
  17. type EicIndexV2 struct {
  18. BaseFromEicIndexId int `orm:"column(base_from_eic_index_id);pk"`
  19. Type string
  20. EicCode string
  21. Name string
  22. Status string
  23. GasDayStart string
  24. GasInStorage string
  25. GasInStorageCode string
  26. Consumption string
  27. ConsumptionCode string
  28. ConsumptionFull string
  29. ConsumptionFullCode string
  30. Full string
  31. FullCode string
  32. Trend string
  33. TrendCode string
  34. Injection string
  35. InjectionCode string
  36. Withdrawal string
  37. WithdrawalCode string
  38. WorkingGasVolume string
  39. WorkingGasVolumeCode string
  40. InjectionCapacity string
  41. InjectionCapacityCode string
  42. WithdrawalCapacity string
  43. WithdrawalCapacityCode string
  44. Info string
  45. Parent string
  46. CreateTime time.Time
  47. ModifyTime time.Time
  48. Children []BaseFromTradeEicIndexV2
  49. }
  50. func GetBaseFromEicDataAllByIndexCodeV2(indexCode, suffix string) (list []*BaseFromTradeEicIndexV2, err error) {
  51. o := orm.NewOrmUsingDB("data")
  52. var name string
  53. if suffix == "" {
  54. name = "eic_code"
  55. } else if suffix == "GS" {
  56. name = "gas_in_storage_code"
  57. } else if suffix == "C" {
  58. name = "consumption_code"
  59. } else if suffix == "CF" {
  60. name = "consumption_full_code"
  61. } else if suffix == "F" {
  62. name = "full_code"
  63. } else if suffix == "T" {
  64. name = "trend_code"
  65. } else if suffix == "In" {
  66. name = "injection_code"
  67. } else if suffix == "Out" {
  68. name = "withdrawal_code"
  69. } else if suffix == "WGV" {
  70. name = "working_gas_volume_code"
  71. } else if suffix == "IC" {
  72. name = "injection_capacity_code"
  73. } else if suffix == "WC" {
  74. name = "withdrawal_capacity_code"
  75. }
  76. sql := `SELECT * FROM base_from_trade_eic_index_v2 WHERE %s=? `
  77. sql = fmt.Sprintf(sql, name)
  78. _, err = o.Raw(sql, indexCode).QueryRows(&list)
  79. return
  80. }