excel_style.go 4.8 KB

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