base_from_trade_dalian.go 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package models
  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 time.Time `description:"插入时间"`
  28. //ModifyTime time.Time `description:"修改时间"`
  29. //DataTime time.Time `description:"数据日期"`
  30. CreateTime string `description:"插入时间"`
  31. ModifyTime string `description:"修改时间"`
  32. DataTime string `description:"数据日期"`
  33. }
  34. func AddBaseFromTradeDalianIndex(item *BaseFromTradeDalianIndex) (lastId int64, err error) {
  35. o := orm.NewOrmUsingDB("data")
  36. lastId, err = o.Insert(item)
  37. return
  38. }
  39. type BaseFromTradeDalianData struct {
  40. BaseFromTradeDalianDataId int `orm:"column(base_from_trade_dalian_data_id);pk"`
  41. BaseFromTradeDalianIndexId int
  42. IndexCode string
  43. DataTime time.Time
  44. Value string
  45. AddCutValue string
  46. CreateTime time.Time
  47. ModifyTime time.Time
  48. DataTimestamp string
  49. }
  50. func GetAddSql(item *BaseFromTradeDalianIndex) (addSql string) {
  51. addSql += "('" + 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.CreateTime + "','" + item.ModifyTime + "','" + item.DataTime + "'),"
  52. return
  53. }
  54. //刷新大连指标数据
  55. func RefreshEdbDataByDaLian(addSql string) (err error) {
  56. o := orm.NewOrmUsingDB("data")
  57. _, err = o.Raw(addSql).Exec()
  58. if err != nil {
  59. return err
  60. }
  61. return
  62. }
  63. //获取当天数据信息列表
  64. func GetBaseFromTradeDalianDataList(dateTime string) (items []*BaseFromTradeDalianIndex, err error) {
  65. o := orm.NewOrmUsingDB("data")
  66. sql := `SELECT * FROM base_from_trade_dalian_index WHERE data_time=?`
  67. _, err = o.Raw(sql, dateTime).QueryRows(&items)
  68. return
  69. }
  70. func UpdateBaseFromTradeDalianIndex(item *BaseFromTradeDalianIndex, dataId int) (err error) {
  71. o := orm.NewOrmUsingDB("data")
  72. 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=? `
  73. _, 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()
  74. return
  75. }
  76. //获取所有指标Id
  77. func GetIndexCodeMapList(exchange string) (items []*BaseFromTradeMapping, err error) {
  78. o := orm.NewOrmUsingDB("data")
  79. sql := `SELECT * FROM base_from_trade_mapping WHERE exchange=?`
  80. _, err = o.Raw(sql, exchange).QueryRows(&items)
  81. return
  82. }