edb_data_coal.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package data_manage
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. type CoalData struct {
  8. InputValue string `orm:"column(DATA_VALUE)" description:"日期"`
  9. DataTime string `orm:"column(DATA_DATE)" description:"值"`
  10. }
  11. type BaseFromCoalDataSimple struct {
  12. Id int `orm:"column(base_from_trade_coal_index_id);pk"`
  13. DealCode string
  14. BuyCode string
  15. SoldCode string
  16. DataTime string
  17. DealValue string
  18. BuyValue string
  19. SoldValue string
  20. }
  21. type BaseInfoFromCoal struct {
  22. IndexName string
  23. Frequency string
  24. Unit string
  25. }
  26. type BaseFromTradeCoalIndex struct {
  27. BaseFromTradeCoalIndexId int `orm:"column(base_from_trade_coal_index_id);pk"`
  28. Rank int
  29. DealShortName string
  30. DealName string
  31. DealCode string
  32. DealValue string
  33. DealChange int
  34. BuyShortName string
  35. BuyName string
  36. BuyCode string
  37. BuyValue string
  38. BuyChange int
  39. SoldShortName string
  40. SoldName string
  41. SoldCode string
  42. SoldValue string
  43. SoldChange int
  44. Frequency string
  45. ClassifyName string
  46. ClassifyType string
  47. CreateTime time.Time
  48. ModifyTime time.Time
  49. DataTime string
  50. }
  51. func GetEdbDataCoalMaxOrMinDate(edbCode string) (minDate, maxDate string, err error) {
  52. o := orm.NewOrmUsingDB("data")
  53. sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_coal WHERE edb_code=? `
  54. err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
  55. return
  56. }
  57. // GetBaseInfoFromCoalByIndexCode 获取指标信息
  58. func GetBaseInfoFromCoalByIndexCode(indexCode, suffix string) (list []*BaseInfoFromCoal, err error) {
  59. o := orm.NewOrmUsingDB("data")
  60. sql := `SELECT * FROM base_from_coalmine_%s WHERE index_code=? `
  61. sql = fmt.Sprintf(sql, suffix)
  62. _, err = o.Raw(sql, indexCode).QueryRows(&list)
  63. return
  64. }