excel_style.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. package data_manage
  2. import (
  3. "time"
  4. "github.com/beego/beego/v2/client/orm"
  5. )
  6. type ExcelStyle struct {
  7. ExcelId int `orm:"column(excel_id);pk"`
  8. Name string
  9. Color string
  10. Row int
  11. Colum int
  12. DefaultRowHeight int
  13. DefaultColWidth int
  14. CellData string
  15. Config string
  16. Data string
  17. CreateTime time.Time
  18. }
  19. type ExcelStyleReq struct {
  20. ExcelId int
  21. Name string
  22. Color string
  23. Row int
  24. Colum int
  25. DefaultRowHeight int
  26. DefaultColWidth int
  27. CellData []interface{}
  28. Config interface{}
  29. Data [][]interface{}
  30. TradeCode string `description:"指标编码"`
  31. Frequence string `description:"频度"`
  32. ClassifyId int `description:"分类id"`
  33. OldClassifyId int `description:"历史分类id"`
  34. OldFrequence string `description:"历史频度"`
  35. }
  36. type CellData struct {
  37. R int
  38. C int
  39. V struct {
  40. Bg interface{} `json:"bg"`
  41. Bl int `json:"bl"`
  42. It int `json:"it"`
  43. Ff int `json:"ff"`
  44. Fs int `json:"fs"`
  45. Fc string `json:"fc"`
  46. Ht int `json:"ht"`
  47. Vt int `json:"vt"`
  48. V int `json:"-"`
  49. Ct struct {
  50. Fa string `json:"fa"`
  51. T string `json:"t"`
  52. } `json:"ct"`
  53. M string `json:"m"`
  54. } `json:"v"`
  55. }
  56. type Data struct {
  57. Bg interface{} `json:"bg"`
  58. Bl int `json:"bl"`
  59. It int `json:"it"`
  60. Ff int `json:"ff"`
  61. Fs int `json:"fs"`
  62. Fc string `json:"fc"`
  63. Ht int `json:"ht"`
  64. Vt int `json:"vt"`
  65. V int `json:"-"`
  66. Ct struct {
  67. Fa string `json:"fa"`
  68. T string `json:"t"`
  69. } `json:"ct"`
  70. M string `json:"m"`
  71. }
  72. type config struct {
  73. Merge Merge
  74. BorderInfo BorderInfo
  75. Rowlen Rowlen
  76. }
  77. type Merge struct {
  78. One35 struct {
  79. R int `json:"r"`
  80. C int `json:"c"`
  81. Rs int `json:"rs"`
  82. Cs int `json:"cs"`
  83. } `json:"13_5"`
  84. One37 struct {
  85. R int `json:"r"`
  86. C int `json:"c"`
  87. Rs int `json:"rs"`
  88. Cs int `json:"cs"`
  89. } `json:"13_7"`
  90. One42 struct {
  91. R int `json:"r"`
  92. C int `json:"c"`
  93. Rs int `json:"rs"`
  94. Cs int `json:"cs"`
  95. } `json:"14_2"`
  96. One510 struct {
  97. R int `json:"r"`
  98. C int `json:"c"`
  99. Rs int `json:"rs"`
  100. Cs int `json:"cs"`
  101. } `json:"15_10"`
  102. }
  103. type BorderInfo struct {
  104. RangeType string `json:"rangeType"`
  105. Value struct {
  106. RowIndex int `json:"row_index"`
  107. ColIndex int `json:"col_index"`
  108. L struct {
  109. Style int `json:"style"`
  110. Color string `json:"color"`
  111. } `json:"l"`
  112. R struct {
  113. Style int `json:"style"`
  114. Color string `json:"color"`
  115. } `json:"r"`
  116. T struct {
  117. Style int `json:"style"`
  118. Color string `json:"color"`
  119. } `json:"t"`
  120. B struct {
  121. Style int `json:"style"`
  122. Color string `json:"color"`
  123. } `json:"b"`
  124. } `json:"value"`
  125. }
  126. type Rowlen struct {
  127. Num0 int `json:"0"`
  128. Num1 int `json:"1"`
  129. Num2 int `json:"2"`
  130. Num3 int `json:"3"`
  131. Num4 int `json:"4"`
  132. Num5 int `json:"5"`
  133. Num6 int `json:"6"`
  134. Num7 int `json:"7"`
  135. Num8 int `json:"8"`
  136. Num9 int `json:"9"`
  137. Num10 int `json:"10"`
  138. Num11 int `json:"11"`
  139. Num12 int `json:"12"`
  140. Num13 int `json:"13"`
  141. Num14 int `json:"14"`
  142. Num15 int `json:"15"`
  143. Num16 int `json:"16"`
  144. Num17 int `json:"17"`
  145. Num18 int `json:"18"`
  146. Num19 int `json:"19"`
  147. Num20 int `json:"20"`
  148. Num21 int `json:"21"`
  149. Num22 int `json:"22"`
  150. Num23 int `json:"23"`
  151. Num24 int `json:"24"`
  152. Num25 int `json:"25"`
  153. Num26 int `json:"26"`
  154. Num27 int `json:"27"`
  155. Num28 int `json:"28"`
  156. Num29 int `json:"29"`
  157. }
  158. type ExcelEdbdataMapping struct {
  159. MappingId int `orm:"column(mapping_id);pk"`
  160. ExcelId int64
  161. ClassifyId int
  162. Frequency string
  163. TradeCode string
  164. CreateTime time.Time
  165. }
  166. func AddExcelEdbdataMapping(item *ExcelEdbdataMapping) (err error) {
  167. o := orm.NewOrmUsingDB("edb")
  168. _, err = o.Insert(item)
  169. return
  170. }
  171. func GetExcelEdbdataMappingByTradeCode(classifyId int, frequency string) (excelId *int, err error) {
  172. o := orm.NewOrmUsingDB("edb")
  173. sql := `SELECT excel_id FROM excel_edbdata_mapping WHERE classify_id = ? AND frequency=?`
  174. err = o.Raw(sql, classifyId, frequency).QueryRow(&excelId)
  175. return
  176. }
  177. func GetExcelStyleById(excelId int) (item *ExcelStyle, err error) {
  178. o := orm.NewOrmUsingDB("edb")
  179. sql := `SELECT * FROM excel_style WHERE excel_id = ? `
  180. err = o.Raw(sql, excelId).QueryRow(&item)
  181. return
  182. }
  183. func GetExcelEdbdataMappingCount(classifyId int, tradeCode, frequency string) (count int, err error) {
  184. sql := `SELECT COUNT(1) AS count FROM excel_edbdata_mapping WHERE classify_id=? AND trade_code=? AND frequency=? `
  185. o := orm.NewOrmUsingDB("edb")
  186. err = o.Raw(sql, classifyId, tradeCode, frequency).QueryRow(&count)
  187. return
  188. }
  189. //func ModifyExcelEdbdataMapping(classifyId int, tradeCode, frequency string) (err error) {
  190. // sql := `UPDATE excel_edbdata_mapping SET CLOSE=?,modify_time=NOW() WHERE TRADE_CODE=? AND DT=? `
  191. // o := orm.NewOrmUsingDB("edb")
  192. // _, err = o.Raw(sql, close, tradeCode, dt).Exec()
  193. // return
  194. //}
  195. type Ct struct {
  196. Fa string `json:"fa"`
  197. T string `json:"t"`
  198. }
  199. // ManualEdbExcelStyleEditReq
  200. // @Description: 手工数据录入编辑(Excel样式)
  201. type ManualEdbExcelStyleEditReq struct {
  202. EdbName string
  203. Data []struct {
  204. Date string
  205. Value float64
  206. }
  207. TradeCode string `description:"指标编码"`
  208. Unit string `description:"单位"`
  209. Frequency string `description:"频度"`
  210. ClassifyId int `description:"分类id"`
  211. }