excel_style.go 5.2 KB

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