edb_info_update_log.go 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package data_stat
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // EdbInfoUpdateLog 指标更新/刷新日志列表
  7. type EdbInfoUpdateLog struct {
  8. Id uint64 `orm:"column(id);pk"`
  9. EdbInfoId int `description:"指标ID"`
  10. SourceName string `description:"来源名称"`
  11. Source int `description:"来源id"`
  12. EdbCode string `description:"指标编码"`
  13. EdbName string `description:"指标名称"`
  14. EdbNameSource string `description:"指标名称来源"`
  15. Frequency string `description:"频率"`
  16. Unit string `description:"单位"`
  17. StartDate string `description:"起始日期"`
  18. EndDate string `description:"终止日期"`
  19. SysUserId int `description:"创建人ID"`
  20. SysUserRealName string `description:"创建人姓名"`
  21. UniqueCode string `description:"指标唯一编码"`
  22. EdbCreateTime time.Time `description:"指标创建时间"`
  23. EdbModifyTime time.Time `description:"指标修改时间"`
  24. CreateTime time.Time `description:"创建时间"`
  25. UpdateSysUserId int `description:"变更人ID"`
  26. UpdateSysUserRealName string `description:"变更人姓名"`
  27. LatestDate string `description:"数据最新日期"`
  28. LatestValue float64 `description:"数据最新值"`
  29. TerminalCode string `description:"终端编码,用于配置在机器上"`
  30. ErDataUpdateDate string `description:"本次更新,数据发生变化的最早日期"`
  31. UpdateResult int `description:"本次刷新操作结果:1成功,2失败"`
  32. UpdateFailedReason string `description:"刷新失败原因"`
  33. DataUpdateResult int `description:"数据更新结果:1成功,2失败"`
  34. DataUpdateFailedReason string `description:"数据未正常更新原因"`
  35. DataUpdateTime string `description:"数据更新时间"`
  36. IsSourceRefresh int `description:"是否为终端刷新到数据源的刷新操作:0否,1是"`
  37. UpdateType int `description:"变更类型,0:数据明细变更,1:基础信息变更, 2:新增指标"`
  38. }
  39. func AddEdbUpdateLog(item *EdbInfoUpdateLog) (lastId int64, err error) {
  40. o := orm.NewOrm()
  41. lastId, err = o.Insert(item)
  42. return
  43. }
  44. // GetEdbUpdateLogByCondition 获取指标更新记录
  45. func GetEdbUpdateLogByCondition(condition string, pars []interface{}) (item []*EdbInfoUpdateLog, err error) {
  46. o := orm.NewOrm()
  47. sql := ` SELECT * FROM edb_info_update_log WHERE 1=1 `
  48. if condition != "" {
  49. sql += condition
  50. }
  51. _, err = o.Raw(sql, pars).QueryRows(&item)
  52. return
  53. }
  54. // GetEdbUpdateSourceLogByCreateDate 获取指标终端更新记录
  55. func GetEdbUpdateSourceLogByCreateDate(source int, startDate, endDate string) (item []*EdbInfoUpdateLog, err error) {
  56. o := orm.NewOrm()
  57. sql := ` SELECT * FROM edb_info_update_log WHERE source = ? and create_time >= ? and create_time < ? and is_source_refresh =1 order by data_update_result asc, id desc`
  58. _, err = o.Raw(sql, source, startDate, endDate).QueryRows(&item)
  59. return
  60. }