excel_edb_mapping.go 2.0 KB

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