edb_info_update_log.go 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package data_manage
  2. import (
  3. "eta/eta_task/global"
  4. "eta/eta_task/utils"
  5. "gorm.io/gorm"
  6. "time"
  7. )
  8. type EdbInfoUpdateLog struct {
  9. Id int `gorm:"primaryKey"`
  10. EdbInfoId int `description:"指标id"`
  11. SourceName string `description:"来源名称"`
  12. Source int `description:"来源id"`
  13. EdbCode string `description:"指标编码"`
  14. EdbName string `description:"指标名称"`
  15. EdbNameSource string `description:"指标名称来源"`
  16. Frequency string `description:"频率"`
  17. Unit string `description:"单位"`
  18. StartDate string `description:"起始日期"`
  19. EndDate string `description:"终止日期"`
  20. ClassifyId int `description:"分类id"`
  21. SysUserId int `description:"创建人"`
  22. SysUserRealName string `description:"创建人名称"`
  23. UpdateSysUserId int `description:"变更人"`
  24. UpdateSysUserRealName string `description:"变更人名称"`
  25. EdbModifyTime string `description:"指标修改时间"`
  26. UniqueCode string `description:"唯一编码"`
  27. LatestDate string `description:"数据最新日期"`
  28. LatestValue float64 `description:"数据最新值"`
  29. TerminalCode string `gorm:"column:terminal_code;default:'';comment:'终端编码,用于配置在机器上'"`
  30. CreateTime time.Time `gorm:"column:create_time;default:null;comment:'创建时间,即指标刷新/更新操作时间点'"`
  31. DataUpdateTime time.Time `gorm:"column:data_update_time;default:null;comment:'最近一次数据发生变化的时间'"`
  32. ErDataUpdateDate time.Time `gorm:"column:er_data_update_date;default:null;comment:'本次更新,数据发生变化的最早日期'"`
  33. UpdateResult int32 `gorm:"column:update_result;default:null;comment:'本次刷新操作结果:1成功,2失败'"`
  34. UpdateFailedReason string `gorm:"column:update_failed_reason;default:null;comment:'刷新失败原因'"`
  35. DataUpdateResult int32 `gorm:"column:data_update_result;not null;default:0;comment:'数据更新结果:1成功,2失败'"`
  36. DataUpdateFailedReason string `description:"数据未正常更新原因"`
  37. IsSourceRefresh int `description:"终端刷新到数据源的刷新操作:0否,1是"`
  38. UpdateType int `description:"变更类型,0:数据明细变更,1:基础信息变更, 2:新增指标"`
  39. }
  40. func (m *EdbInfoUpdateLog) AfterFind(db *gorm.DB) (err error) {
  41. m.StartDate = utils.GormDateStrToDateStr(m.StartDate)
  42. m.EndDate = utils.GormDateStrToDateStr(m.EndDate)
  43. m.LatestDate = utils.GormDateStrToDateStr(m.LatestDate)
  44. return
  45. }
  46. func GetEdbInfoUpdateLogByCondition(condition string, pars []interface{}) (item []*EdbInfoUpdateLog, err error) {
  47. o := global.DbMap[utils.DbNameIndex]
  48. sql := ` SELECT * FROM edb_info_update_log WHERE 1=1 `
  49. if condition != "" {
  50. sql += condition
  51. }
  52. sql += `ORDER BY id ASC limit 0,10 `
  53. err = o.Raw(sql, pars...).Find(&item).Error
  54. return
  55. }