base_from_trade_dalian.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package data_manage
  2. import (
  3. "eta_gn/eta_task/global"
  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. err = global.DEFAULT_DmSQL.Create(item).Error
  35. if err != nil {
  36. return
  37. }
  38. lastId = int64(item.BaseFromTradeDalianIndexId)
  39. return
  40. }
  41. type BaseFromTradeDalianData struct {
  42. BaseFromTradeDalianDataId int `orm:"column(base_from_trade_dalian_data_id);pk"`
  43. BaseFromTradeDalianIndexId int
  44. IndexCode string
  45. DataTime time.Time
  46. Value string
  47. AddCutValue string
  48. CreateTime time.Time
  49. ModifyTime time.Time
  50. DataTimestamp string
  51. }
  52. // 刷新大连指标数据
  53. func RefreshEdbDataByDaLian(addSql string) (err error) {
  54. //o := orm.NewOrm()
  55. //_, err = o.Raw(addSql).Exec()
  56. //if err != nil {
  57. // return err
  58. //}
  59. //err = global.DEFAULT_DmSQL.Exec(addSql).Error
  60. return
  61. }
  62. // 获取当天数据信息列表
  63. func GetBaseFromTradeDalianDataList(dateTime string) (items []*BaseFromTradeDalianIndex, err error) {
  64. //o := orm.NewOrm()
  65. sql := `SELECT * FROM base_from_trade_dalian_index WHERE data_time>=?`
  66. //_, err = o.Raw(sql, dateTime).QueryRows(&items)
  67. err = global.DEFAULT_DmSQL.Raw(sql, dateTime).Find(&items).Error
  68. return
  69. }
  70. func UpdateBaseFromTradeDalianIndex(item *BaseFromTradeDalianIndex, dataId int) (err error) {
  71. //o := orm.NewOrm()
  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. err = global.DEFAULT_DmSQL.Exec(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).Error
  75. return
  76. }
  77. type DalianIndexResp struct {
  78. Ret int
  79. Msg string
  80. ErrMsg string
  81. ErrCode string
  82. Data []*BaseFromTradeDalianIndex
  83. }
  84. func GetBaseFromTradeDalianIndexMaxDate() (max_date time.Time, err error) {
  85. //o := orm.NewOrm()
  86. sql := ` SELECT max(a.data_time)as max_date FROM base_from_trade_dalian_index as a `
  87. //err = o.Raw(sql).QueryRow(&max_date)
  88. err = global.DEFAULT_DmSQL.Raw(sql).Scan(&max_date).Error
  89. return
  90. }