edb_data_gie.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package data_manage
  2. import (
  3. "eta_gn/eta_api/global"
  4. "fmt"
  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. sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_gie WHERE edb_code=? `
  13. var tmpDate SmmMaxOrMinDate
  14. err = global.DmSQL["data"].Raw(sql, edbCode).Scan(&tmpDate).Error
  15. if err != nil {
  16. return
  17. }
  18. minDate = tmpDate.MinDate
  19. maxDate = tmpDate.MaxDate
  20. return
  21. }
  22. type EicIndexV2 struct {
  23. BaseFromEicIndexId int `orm:"column(base_from_eic_index_id);pk"`
  24. Type string
  25. EicCode string
  26. Name string
  27. Status string
  28. GasDayStart string
  29. GasInStorage string
  30. GasInStorageCode string
  31. Consumption string
  32. ConsumptionCode string
  33. ConsumptionFull string
  34. ConsumptionFullCode string
  35. Full string
  36. FullCode string
  37. Trend string
  38. TrendCode string
  39. Injection string
  40. InjectionCode string
  41. Withdrawal string
  42. WithdrawalCode string
  43. WorkingGasVolume string
  44. WorkingGasVolumeCode string
  45. InjectionCapacity string
  46. InjectionCapacityCode string
  47. WithdrawalCapacity string
  48. WithdrawalCapacityCode string
  49. Info string
  50. Parent string
  51. CreateTime time.Time
  52. ModifyTime time.Time
  53. Children []BaseFromTradeEicIndexV2
  54. }
  55. func GetBaseFromEicDataAllByIndexCodeV2(indexCode, suffix string) (list []*BaseFromTradeEicIndexV2, err error) {
  56. var name string
  57. if suffix == "" {
  58. name = "eic_code"
  59. } else if suffix == "GS" {
  60. name = "gas_in_storage_code"
  61. } else if suffix == "C" {
  62. name = "consumption_code"
  63. } else if suffix == "CF" {
  64. name = "consumption_full_code"
  65. } else if suffix == "F" {
  66. name = "full_code"
  67. } else if suffix == "T" {
  68. name = "trend_code"
  69. } else if suffix == "In" {
  70. name = "injection_code"
  71. } else if suffix == "Out" {
  72. name = "withdrawal_code"
  73. } else if suffix == "WGV" {
  74. name = "working_gas_volume_code"
  75. } else if suffix == "IC" {
  76. name = "injection_capacity_code"
  77. } else if suffix == "WC" {
  78. name = "withdrawal_capacity_code"
  79. }
  80. sql := `SELECT * FROM base_from_trade_eic_index_v2 WHERE %s=? `
  81. sql = fmt.Sprintf(sql, name)
  82. err = global.DmSQL["data"].Raw(sql, indexCode).Scan(&list).Error
  83. return
  84. }