edb_info_update_log.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package data_stat
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. // EdbInfoUpdateLog 指标更新/刷新日志列表
  8. type EdbInfoUpdateLog struct {
  9. Id uint64 `orm:"column(id);pk"`
  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. SysUserId int `description:"创建人ID"`
  21. SysUserRealName string `description:"创建人姓名"`
  22. UniqueCode string `description:"指标唯一编码"`
  23. EdbCreateTime time.Time `description:"指标创建时间"`
  24. EdbModifyTime time.Time `description:"指标修改时间"`
  25. CreateTime time.Time `description:"创建时间"`
  26. UpdateSysUserId int `description:"变更人ID"`
  27. UpdateSysUserRealName string `description:"变更人姓名"`
  28. LatestDate string `description:"数据最新日期"`
  29. LatestValue float64 `description:"数据最新值"`
  30. TerminalCode string `description:"终端编码,用于配置在机器上"`
  31. ErDataUpdateDate string `description:"本次更新,数据发生变化的最早日期"`
  32. UpdateResult int `description:"本次刷新操作结果:1成功,2失败"`
  33. UpdateFailedReason string `description:"刷新失败原因"`
  34. DataUpdateResult int `description:"数据更新结果:1成功,2失败"`
  35. DataUpdateFailedReason string `description:"数据未正常更新原因"`
  36. DataUpdateTime string `description:"数据更新时间"`
  37. IsSourceRefresh int `description:"是否为终端刷新到数据源的刷新操作:0否,1是"`
  38. UpdateType int `description:"变更类型,0:数据明细变更,1:基础信息变更, 2:新增指标"`
  39. }
  40. type EdbInfoUpdateLogItem struct {
  41. Id uint64 `orm:"column(id);pk"`
  42. EdbInfoId int `description:"指标ID"`
  43. SourceName string `description:"来源名称"`
  44. Source int `description:"来源id"`
  45. EdbCode string `description:"指标编码"`
  46. EdbName string `description:"指标名称"`
  47. EdbNameSource string `description:"指标名称来源"`
  48. Frequency string `description:"频率"`
  49. Unit string `description:"单位"`
  50. StartDate string `description:"起始日期"`
  51. EndDate string `description:"终止日期"`
  52. SysUserId int `description:"创建人ID"`
  53. SysUserRealName string `description:"创建人姓名"`
  54. UpdateSysUserId int `description:"变更人ID"`
  55. UpdateSysUserRealName string `description:"变更人姓名"`
  56. CreateTime string
  57. UniqueCode string `description:"指标唯一编码"`
  58. LatestDate string `description:"数据最新日期"`
  59. LatestValue float64 `description:"数据最新值"`
  60. TerminalCode string `description:"终端编码,用于配置在机器上"`
  61. DataUpdateTime string `description:"最近一次数据发生变化的时间"`
  62. ErDataUpdateDate string `description:"本次更新,数据发生变化的最早日期"`
  63. UpdateType int `description:"变更类型,0:数据明细变更,1:基础信息变更, 2:新增指标"`
  64. }
  65. func AddEdbUpdateLog(item *EdbInfoUpdateLog) (lastId int64, err error) {
  66. o := orm.NewOrmUsingDB("data")
  67. lastId, err = o.Insert(item)
  68. return
  69. }
  70. type GetEdbUpdateLogResp struct {
  71. List []*EdbInfoUpdateLogItem
  72. Paging *paging.PagingItem
  73. }
  74. func GetEdbUpdateLogByCondition(condition string, pars []interface{}, orderStr string, pageSize, startSize int) (item []*EdbInfoUpdateLog, err error) {
  75. o := orm.NewOrmUsingDB("data")
  76. sql := ` SELECT * FROM edb_info_update_log WHERE 1=1 `
  77. if condition != "" {
  78. sql += condition
  79. }
  80. if orderStr != "" {
  81. sql += orderStr
  82. } else {
  83. sql += ` ORDER BY create_time DESC, id DESC `
  84. }
  85. sql += ` LIMIT ?,? `
  86. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&item)
  87. return
  88. }
  89. // GetEdbUpdateLogCount
  90. func GetEdbUpdateLogCount(condition string, pars []interface{}) (count int, err error) {
  91. o := orm.NewOrmUsingDB("data")
  92. sql := ` SELECT count(*) FROM edb_info_update_log WHERE 1=1 `
  93. if condition != "" {
  94. sql += condition
  95. }
  96. err = o.Raw(sql, pars).QueryRow(&count)
  97. return
  98. }