excel_info.go 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. }
  24. // GetNoContentExcelInfoAll 获取不含content的表格列表 用于分类展示
  25. func GetNoContentExcelInfoAll(source, userId int) (items []*ExcelClassifyItems, err error) {
  26. o := orm.NewOrm()
  27. sql := ` SELECT excel_info_id,excel_classify_id,excel_name AS excel_classify_name,
  28. unique_code,sys_user_id,sys_user_real_name
  29. FROM excel_info where is_delete=0 AND source = ? `
  30. pars := []interface{}{source}
  31. if userId > 0 {
  32. sql += ` AND sys_user_id = ? `
  33. pars = append(pars, userId)
  34. }
  35. sql += ` ORDER BY sort asc,create_time desc `
  36. _, err = o.Raw(sql, pars...).QueryRows(&items)
  37. return
  38. }
  39. // UpdateExcelInfoClassifyId 更改表格分类
  40. func UpdateExcelInfoClassifyId(classifyId, excelInfoId int) (err error) {
  41. o := orm.NewOrm()
  42. sql := ` update excel_info set excel_classify_id = ? WHERE excel_info_id=? `
  43. _, err = o.Raw(sql, classifyId, excelInfoId).Exec()
  44. return
  45. }
  46. // GetAllExcelInfoBySource 根据来源获取包含content的表格列表
  47. func GetAllExcelInfoBySource(source int) (items []*ExcelInfo, err error) {
  48. o := orm.NewOrm()
  49. sql := ` SELECT * FROM excel_info where is_delete=0 AND source = ? ORDER BY sort asc,create_time desc `
  50. _, err = o.Raw(sql, source).QueryRows(&items)
  51. return
  52. }
  53. // TableDataReq 自定义表格请求参数
  54. type TableDataReq struct {
  55. EdbInfoIdList []int `description:"指标id列表,从左至右,从上到下的顺序"`
  56. Sort int `description:"日期排序,1:倒序,2:正序"`
  57. Data []EdbInfoData `description:"数据列表"`
  58. TextRowData [][]ManualDataReq `description:"文本列表"`
  59. }
  60. // EdbInfoData 自定义表格的数据
  61. type EdbInfoData struct {
  62. EdbInfoId int `description:"指标ID"`
  63. Tag string `description:"标签"`
  64. EdbName string `description:"指标名称"`
  65. EdbAliasName string `description:"指标别名"`
  66. Frequency string `description:"频度"`
  67. Unit string `description:"单位"`
  68. Data []ManualDataReq `description:"单元格数据列表"`
  69. }
  70. // ManualDataReq 自定义表格的单元格数据
  71. type ManualDataReq struct {
  72. DataType int `description:"数据类型,1:普通的,2:插值法,3:手动输入,4:公式计算,5:预测值"`
  73. DataTime string `description:"所属日期"`
  74. DataTimeType int `description:"日期类型,1:实际日期;2:未来日期"`
  75. ShowValue string `description:"展示值"`
  76. Value string `description:"实际值(计算公式)"`
  77. RelationEdbInfoList []RelationEdbInfo `description:"关联指标(计算公式中关联的指标,用于计算的时候去匹配)"`
  78. }
  79. // RelationEdbInfo 自定义表格中单元格的关联指标
  80. type RelationEdbInfo struct {
  81. Tag string `description:"指标标签"`
  82. Row string `description:"第几行"`
  83. }
  84. // MixedTableReq 混合表格保存请求参数
  85. type MixedTableReq struct {
  86. CellRelation string `description:"单元格关系"`
  87. Data [][]MixedTableCellDataReq `description:"混合表格单元格参数"`
  88. }
  89. // MixedTableCellDataReq 混合表格单元格参数
  90. type MixedTableCellDataReq struct {
  91. Uid string `description:"单元格唯一标识"`
  92. DataType int `description:"数据类型,1:日期,2:指标,3:自定义文本,4:插值"`
  93. DataTime string `description:"所属日期"`
  94. DataTimeType int `description:"日期类型:0:手动输入日期;1:导入系统日期;;3:导入指标日期(指标库的最新日期);"`
  95. EdbInfoId int `description:"指标id"`
  96. ShowValue string `description:"展示值"`
  97. Value string `description:"实际值"`
  98. }