base_from_trade_dalian.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type BaseFromTradeDalianIndex struct {
  7. BaseFromTradeDalianIndexId int `orm:"column(base_from_trade_dalian_index_id);pk"`
  8. Rank string `description:"排名"`
  9. DealShortName string `description:"成交量公司简称"`
  10. DealName string `description:"成交量指标名称"`
  11. DealCode string `description:"成交量指标编码"`
  12. DealValue string `description:"成交量"`
  13. DealChange string `description:"成交变化量"`
  14. BuyShortName string `description:"成交量公司简称"`
  15. BuyName string `description:"持买单量指标名称"`
  16. BuyCode string `description:"持买单量指标编码"`
  17. BuyValue string `description:"持买单量"`
  18. BuyChange string `description:"持买单量变化量"`
  19. SoldShortName string `description:"成交量公司简称"`
  20. SoldName string `description:"持买单量指标名称"`
  21. SoldCode string `description:"持买单量指标编码"`
  22. SoldValue string `description:"持买单量"`
  23. SoldChange string `description:"持买单量变化量"`
  24. Frequency string `description:"频度"`
  25. ClassifyName string `description:"分类名称"`
  26. ClassifyType string `description:"分类名称下的类型"`
  27. CreateTime string `description:"插入时间"`
  28. ModifyTime string `description:"修改时间"`
  29. DataTime string `description:"数据日期"`
  30. }
  31. func AddBaseFromTradeDalianIndex(item *BaseFromTradeDalianIndex) (lastId int64, err error) {
  32. o := orm.NewOrm()
  33. lastId, err = o.Insert(item)
  34. return
  35. }
  36. type BaseFromTradeDalianData struct {
  37. BaseFromTradeDalianDataId int `orm:"column(base_from_trade_dalian_data_id);pk"`
  38. BaseFromTradeDalianIndexId int
  39. IndexCode string
  40. DataTime time.Time
  41. Value string
  42. AddCutValue string
  43. CreateTime time.Time
  44. ModifyTime time.Time
  45. DataTimestamp string
  46. }
  47. // 刷新大连指标数据
  48. func RefreshEdbDataByDaLian(addSql string) (err error) {
  49. o := orm.NewOrm()
  50. _, err = o.Raw(addSql).Exec()
  51. if err != nil {
  52. return err
  53. }
  54. return
  55. }
  56. // 获取当天数据信息列表
  57. func GetBaseFromTradeDalianDataList(dateTime string) (items []*BaseFromTradeDalianIndex, err error) {
  58. o := orm.NewOrm()
  59. sql := `SELECT * FROM base_from_trade_dalian_index WHERE data_time>=?`
  60. _, err = o.Raw(sql, dateTime).QueryRows(&items)
  61. return
  62. }
  63. func UpdateBaseFromTradeDalianIndex(item *BaseFromTradeDalianIndex, dataId int) (err error) {
  64. o := orm.NewOrm()
  65. sql := "UPDATE base_from_trade_dalian_index SET `rank`=?,deal_short_name=?,deal_name=?,deal_code=?,deal_value=?,buy_short_name=?,deal_change=?,buy_name=?,buy_code=?,buy_value=?,buy_change=?,sold_short_name=?,sold_name=?,sold_code=?,sold_value=?,sold_change=?,frequency=?,classify_name=?,classify_type=?,modify_time=?,data_time=? WHERE base_from_trade_dalian_index_id=? "
  66. _, err = o.Raw(sql, item.Rank, item.DealShortName, item.DealName, item.DealCode, item.DealValue, item.BuyShortName, item.DealChange, item.BuyName, item.BuyCode, item.BuyValue, item.BuyChange, item.SoldShortName, item.SoldName, item.SoldCode, item.SoldValue, item.SoldChange, item.Frequency, item.ClassifyName, item.ClassifyType, item.ModifyTime, item.DataTime, dataId).Exec()
  67. return
  68. }
  69. type DalianIndexResp struct {
  70. Ret int
  71. Msg string
  72. ErrMsg string
  73. ErrCode string
  74. Data []*BaseFromTradeDalianIndex
  75. }
  76. func GetBaseFromTradeDalianIndexMaxDate() (max_date time.Time, err error) {
  77. o := orm.NewOrm()
  78. sql := ` SELECT max(a.data_time)as max_date FROM base_from_trade_dalian_index as a `
  79. err = o.Raw(sql).QueryRow(&max_date)
  80. return
  81. }