excel_edb_mapping.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package excel
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // ExcelEdbMapping excel与指标的关系表
  7. type ExcelEdbMapping struct {
  8. ExcelEdbMappingId int `orm:"column(excel_edb_mapping_id);pk"`
  9. ExcelInfoId int `description:"excel的id"`
  10. Source int `description:"表格来源,1:excel插件的表格,2:自定义表格,3:混合表格,4:自定义分析,默认:1"`
  11. EdbInfoId int `description:"计算指标id"`
  12. CreateTime time.Time `description:"创建时间"`
  13. ModifyTime time.Time `description:"修改时间"`
  14. }
  15. // AddExcelEdbMappingMulti 批量添加excel与指标的关系
  16. func AddExcelEdbMappingMulti(items []*ExcelEdbMapping) (err error) {
  17. o := orm.NewOrm()
  18. _, err = o.InsertMulti(len(items), items)
  19. return
  20. }
  21. // Add 添加excel与指标的关系
  22. func (e *ExcelEdbMapping) Add() (err error) {
  23. o := orm.NewOrm()
  24. _, err = o.Insert(e)
  25. return
  26. }
  27. type ExcelEdbMappingItem struct {
  28. EdbInfoId int `description:"指标id"`
  29. UniqueCode string `description:"唯一编码"`
  30. EdbName string `description:"指标名称"`
  31. ClassifyId int `description:"分类id"`
  32. Frequency string `description:"频度"`
  33. Unit string `description:"单位"`
  34. CalculateFormula string `json:"-"`
  35. DateSequenceStr string `description:"日期序列公式"`
  36. DataSequenceStr string `description:"数据序列公式"`
  37. }
  38. // CalculateFormula 计算公式
  39. type CalculateFormula struct {
  40. DateSequenceStr string `json:"DateSequenceStr"`
  41. DataSequenceStr string `json:"DataSequenceStr"`
  42. }
  43. // GetExcelEdbMappingByEdbInfoId 根据指标id获取配置关系
  44. func GetExcelEdbMappingByEdbInfoId(edbInfoId int) (item *ExcelEdbMapping, err error) {
  45. o := orm.NewOrm()
  46. sql := ` SELECT * FROM excel_edb_mapping WHERE 1=1 AND edb_info_id = ? `
  47. err = o.Raw(sql, edbInfoId).QueryRow(&item)
  48. return
  49. }