base_from_coalmine.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. package models
  2. import (
  3. "time"
  4. "github.com/beego/beego/v2/client/orm"
  5. )
  6. type CoalSheetData struct {
  7. Name string
  8. Rows []Row
  9. Cols []*Col
  10. MaxRow int
  11. MaxCol int
  12. Hidden bool
  13. Selected bool
  14. }
  15. type Row struct {
  16. Cells []Cell
  17. Hidden bool
  18. Height float64
  19. OutlineLevel uint8
  20. isCustom bool
  21. }
  22. type Col struct {
  23. Min int
  24. Max int
  25. Hidden bool
  26. Width float64
  27. Collapsed bool
  28. OutlineLevel uint8
  29. numFmt string
  30. }
  31. type Cell struct {
  32. Value string
  33. }
  34. type BaseFromCoalmineMapping struct {
  35. BaseFromCoalmineMappingId int `orm:"column(base_from_coalmine_mapping_id);pk"`
  36. IndexName string `description:"持买单量指标名称"`
  37. IndexCode string `description:"持买单量指标编码"`
  38. CreateTime time.Time `description:"时间"`
  39. }
  40. type BaseFromCoalmineJsmIndex struct {
  41. BaseFromCoalmineJsmIndexId int `orm:"column(base_from_coalmine_jsm_index_id);pk"`
  42. IndexName string `description:"持买单量指标名称"`
  43. IndexCode string `description:"持买单量指标编码"`
  44. Exchange string `description:"样本统计类别"`
  45. DealValue string `description:"成交量"`
  46. DataTime string `description:"数据日期"`
  47. Source string `description:"来源"`
  48. Province string `description:"省份"`
  49. Description string `description:"描述"`
  50. Unit string `description:"单位"`
  51. Frequency string `description:"频率"`
  52. CreateTime time.Time `description:"插入时间"`
  53. ModifyTime time.Time `description:"修改时间"`
  54. }
  55. type BaseFromCoalmineCompanyIndex struct {
  56. BaseFromCoalmineCompanyIndexId int `orm:"column(base_from_coalmine_company_index_id);pk"`
  57. IndexName string `description:"持买单量指标名称"`
  58. IndexCode string `description:"持买单量指标编码"`
  59. DealValue string `description:"成交量"`
  60. DataTime string `description:"数据日期"`
  61. Source string `description:"来源"`
  62. Province string `description:"省份"`
  63. City string `description:"城市"`
  64. GroupName string `description:"集团名称"`
  65. Unit string `description:"单位"`
  66. Frequency string `description:"频率"`
  67. CreateTime time.Time `description:"插入时间"`
  68. ModifyTime time.Time `description:"修改时间"`
  69. }
  70. // 添加指标
  71. func AddBaseFromCoalmineMapping(item *BaseFromCoalmineMapping) (lastId int64, err error) {
  72. o := orm.NewOrmUsingDB("data")
  73. lastId, err = o.Insert(item)
  74. return
  75. }
  76. // 查询指标
  77. func GetBaseFromCoalmineMapping() (items []*BaseFromCoalmineMapping, err error) {
  78. o := orm.NewOrmUsingDB("data")
  79. sql := `SELECT * FROM base_from_coalmine_mapping`
  80. _, err = o.Raw(sql).QueryRows(&items)
  81. return
  82. }
  83. // 查询数据
  84. func GetBaseFromCoalmineIndex() (items []*BaseFromCoalmineJsmIndex, err error) {
  85. o := orm.NewOrmUsingDB("data")
  86. sql := `SELECT * FROM base_from_coalmine_jsm_index`
  87. _, err = o.Raw(sql).QueryRows(&items)
  88. return
  89. }
  90. func UpdateBaseFromCoalmineIndex(item *BaseFromCoalmineJsmIndex) (err error) {
  91. o := orm.NewOrmUsingDB("data")
  92. sql := `UPDATE base_from_coalmine_jsm_index SET deal_value=? WHERE index_name=? AND data_time = ?`
  93. _, err = o.Raw(sql, item.DealValue, item.IndexName, item.DataTime).Exec()
  94. return
  95. }
  96. // 添加数据
  97. func AddBaseFromCoalmineIndex(item *BaseFromCoalmineJsmIndex) (lastId int64, err error) {
  98. o := orm.NewOrmUsingDB("data")
  99. lastId, err = o.Insert(item)
  100. return
  101. }
  102. // 添加公司指标
  103. func AddBaseFromCoalmineCompanyIndex(item *BaseFromCoalmineCompanyIndex) (lastId int64, err error) {
  104. o := orm.NewOrmUsingDB("data")
  105. lastId, err = o.Insert(item)
  106. return
  107. }
  108. // 查询公司指标
  109. func GetBaseFromCoalmineCompanyIndex() (items []*BaseFromCoalmineCompanyIndex, err error) {
  110. o := orm.NewOrmUsingDB("data")
  111. sql := `SELECT * FROM base_from_coalmine_company_index`
  112. _, err = o.Raw(sql).QueryRows(&items)
  113. return
  114. }
  115. func UpdateBaseFromCoalmineCompanyIndex(item *BaseFromCoalmineCompanyIndex) (err error) {
  116. o := orm.NewOrmUsingDB("data")
  117. sql := `UPDATE base_from_coalmine_company_index SET deal_value=? WHERE index_name=? AND data_time = ?`
  118. _, err = o.Raw(sql, item.DealValue, item.IndexName, item.DataTime).Exec()
  119. return
  120. }