excel_info.go 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. package excel
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // ExcelInfo excel表格详情表
  7. type ExcelInfo struct {
  8. ExcelInfoId int `orm:"column(excel_info_id);pk"`
  9. Source int `description:"表格来源,1:excel插件的表格,2:自定义表格,3:混合表格,4:自定义分析,默认:1"`
  10. ExcelType int `description:"表格类型,1:指标列,2:日期列,默认:1"`
  11. ExcelName string `description:"表格名称"`
  12. UniqueCode string `description:"表格唯一编码"`
  13. ExcelClassifyId int `description:"表格分类id"`
  14. SysUserId int `description:"操作人id"`
  15. SysUserRealName string `description:"操作人真实姓名"`
  16. Content string `description:"表格内容"`
  17. ExcelImage string `description:"表格图片"`
  18. FileUrl string `description:"表格下载地址"`
  19. Sort int `description:"排序字段,数字越小越排前面"`
  20. IsDelete int `description:"是否删除,0:未删除,1:已删除"`
  21. ModifyTime time.Time `description:"最近修改日期"`
  22. CreateTime time.Time `description:"创建日期"`
  23. IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
  24. ParentId int `description:"表格的父级id"`
  25. BalanceType int `description:"平衡表类型:0 动态表,1静态表"`
  26. UpdateUserId int `description:"更新人id"`
  27. UpdateUserRealName string `description:"更新人真实姓名"`
  28. RelExcelInfoId int `description:"平衡表里静态表关联的动态表excel id"`
  29. VersionName string `description:"静态表版本名称"`
  30. SourcesFrom string `description:"图表来源"`
  31. ExtraConfig string `description:"额外配置:如多空分析、相关性表格参数"`
  32. }
  33. // GetNoContentExcelInfoAll 获取不含content的表格列表 用于分类展示
  34. func GetNoContentExcelInfoAll(source, userId int) (items []*ExcelClassifyItems, err error) {
  35. o := orm.NewOrm()
  36. sql := ` SELECT excel_info_id,excel_classify_id,excel_name AS excel_classify_name,
  37. unique_code,sys_user_id,sys_user_real_name
  38. FROM excel_info where is_delete=0 AND source = ? `
  39. pars := []interface{}{source}
  40. if userId > 0 {
  41. sql += ` AND sys_user_id = ? `
  42. pars = append(pars, userId)
  43. }
  44. sql += ` ORDER BY sort asc,create_time desc `
  45. _, err = o.Raw(sql, pars...).QueryRows(&items)
  46. return
  47. }
  48. // UpdateExcelInfoClassifyId 更改表格分类
  49. func UpdateExcelInfoClassifyId(classifyId, excelInfoId int) (err error) {
  50. o := orm.NewOrm()
  51. sql := ` update excel_info set excel_classify_id = ? WHERE excel_info_id=? `
  52. _, err = o.Raw(sql, classifyId, excelInfoId).Exec()
  53. return
  54. }
  55. // GetAllExcelInfoBySource 根据来源获取包含content的表格列表
  56. func GetAllExcelInfoBySource(source int) (items []*ExcelInfo, err error) {
  57. o := orm.NewOrm()
  58. sql := ` SELECT * FROM excel_info where is_delete=0 AND source = ? ORDER BY sort asc,create_time desc `
  59. _, err = o.Raw(sql, source).QueryRows(&items)
  60. return
  61. }
  62. // TableDataReq 自定义表格请求参数
  63. type TableDataReq struct {
  64. EdbInfoIdList []int `description:"指标id列表,从左至右,从上到下的顺序"`
  65. Sort int `description:"日期排序,1:倒序,2:正序"`
  66. Data []EdbInfoData `description:"数据列表"`
  67. TextRowData [][]ManualDataReq `description:"文本列表"`
  68. }
  69. // EdbInfoData 自定义表格的数据
  70. type EdbInfoData struct {
  71. EdbInfoId int `description:"指标ID"`
  72. Tag string `description:"标签"`
  73. EdbName string `description:"指标名称"`
  74. EdbAliasName string `description:"指标别名"`
  75. Frequency string `description:"频度"`
  76. Unit string `description:"单位"`
  77. Data []ManualDataReq `description:"单元格数据列表"`
  78. }
  79. // ManualDataReq 自定义表格的单元格数据
  80. type ManualDataReq struct {
  81. DataType int `description:"数据类型,1:普通的,2:插值法,3:手动输入,4:公式计算,5:预测值"`
  82. DataTime string `description:"所属日期"`
  83. DataTimeType int `description:"日期类型,1:实际日期;2:未来日期"`
  84. ShowValue string `description:"展示值"`
  85. Value string `description:"实际值(计算公式)"`
  86. RelationEdbInfoList []RelationEdbInfo `description:"关联指标(计算公式中关联的指标,用于计算的时候去匹配)"`
  87. }
  88. // RelationEdbInfo 自定义表格中单元格的关联指标
  89. type RelationEdbInfo struct {
  90. Tag string `description:"指标标签"`
  91. Row string `description:"第几行"`
  92. }
  93. // MixedTableReq 混合表格保存请求参数
  94. type MixedTableReq struct {
  95. CellRelation string `description:"单元格关系"`
  96. Data [][]MixedTableCellDataReq `description:"混合表格单元格参数"`
  97. }
  98. // MixedTableCellDataReq 混合表格单元格参数
  99. type MixedTableCellDataReq struct {
  100. Uid string `description:"单元格唯一标识"`
  101. DataType int `description:"数据类型,1:日期,2:指标,3:自定义文本,4:插值"`
  102. DataTime string `description:"所属日期"`
  103. DataTimeType int `description:"日期类型:0:手动输入日期;1:导入系统日期;;3:导入指标日期(指标库的最新日期);"`
  104. EdbInfoId int `description:"指标id"`
  105. ShowValue string `description:"展示值"`
  106. Value string `description:"实际值"`
  107. }
  108. func (m *ExcelInfo) Update(cols []string) (err error) {
  109. o := orm.NewOrm()
  110. _, err = o.Update(m, cols...)
  111. return
  112. }
  113. func (m *ExcelInfo) GetItemById(id int) (item *ExcelInfo, err error) {
  114. o := orm.NewOrm()
  115. sql := `SELECT * FROM excel_info WHERE excel_info_id = ? LIMIT 1`
  116. err = o.Raw(sql, id).QueryRow(&item)
  117. return
  118. }