edb_update_log.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package data_manage
  2. import (
  3. "eta_gn/eta_task/global"
  4. "eta_gn/eta_task/utils"
  5. "time"
  6. )
  7. type EdbUpdateLog struct {
  8. Id int64 `gorm:"column:id;primaryKey" json:"id"` // `json:"id" orm:"column(id);pk"`
  9. OpDbName string `json:"op_db_name"` // 库名
  10. OpTableName string `json:"op_table_name"` // 表名
  11. OpType string `json:"op_type"` // 变更类型
  12. OldData string `json:"old_data"` // 历史数据
  13. NewData string `json:"new_data"` // 新数据
  14. IsHandle int `json:"is_handle"` // 是否处理,0:未处理,1:已处理;默认:0
  15. ModifyTime time.Time `json:"modify_time"`
  16. CreateTime time.Time `json:"create_time"`
  17. }
  18. func GetEdbUpdateLogMaxId() (maxId int64, err error) {
  19. sql := ` SELECT id FROM edb_update_log WHERE 1=1 ORDER BY id desc limit 1 `
  20. err = global.DmSQL["data"].Raw(sql).Scan(&maxId).Error
  21. return
  22. }
  23. func GetEdbUpdateLogMaxHandleId() (maxId int64, err error) {
  24. sql := ` SELECT id FROM edb_update_log WHERE 1=1 AND is_handle = 1 ORDER BY id desc limit 1 `
  25. err = global.DmSQL["data"].Raw(sql).Scan(&maxId).Error
  26. return
  27. }
  28. func GetEdbUpdateLogByCondition(condition string, pars []interface{}) (item []*EdbUpdateLog, err error) {
  29. sql := ` SELECT * FROM edb_update_log WHERE 1=1 `
  30. if condition != "" {
  31. sql += condition
  32. }
  33. sql += ` ORDER BY id ASC limit 500 `
  34. err = global.DmSQL["data"].Raw(sql, pars...).Find(&item).Error
  35. return
  36. }
  37. func HandleUpdateLogByIds(idList []int64, modifyTime string) (err error) {
  38. num := len(idList)
  39. if num <= 0 {
  40. return
  41. }
  42. sql := ` UPDATE edb_update_log set is_handle=1 ,modify_time = ? WHERE id in (` + utils.GetOrmInReplace(num) + `) `
  43. err = global.DmSQL["data"].Exec(sql, modifyTime, idList).Error
  44. return
  45. }
  46. type EdbInfoItem struct {
  47. CalculateFormula string `json:"calculate_formula"`
  48. Calendar string `json:"calendar"`
  49. ChartImage string `json:"chart_image"`
  50. ClassifyId int `json:"classify_id"`
  51. CreateTime string `json:"create_time"`
  52. DataDateType string `json:"data_date_type"`
  53. DataUpdateTime string `json:"data_update_time"`
  54. EdbCode string `json:"edb_code"`
  55. EdbInfoId int `json:"edb_info_id"`
  56. EdbInfoType int `json:"edb_info_type"`
  57. EdbName string `json:"edb_name"`
  58. EdbNameEn string `json:"edb_name_en"`
  59. EdbNameSource string `json:"edb_name_source"`
  60. EdbType int `json:"edb_type"`
  61. EmptyType int `json:"empty_type"`
  62. EndDate string `json:"end_date"`
  63. EndValue float64 `json:"end_value"`
  64. ErDataUpdateDate string `json:"er_data_update_date"`
  65. Extra string `json:"extra"`
  66. Frequency string `json:"frequency"`
  67. IndicatorCode string `json:"indicator_code"`
  68. IsUpdate int `json:"is_update"`
  69. LatestDate string `json:"latest_date"`
  70. LatestValue float64 `json:"latest_value"`
  71. ManualSave int `json:"manual_save"`
  72. MaxEmptyType int `json:"max_empty_type"`
  73. MaxValue float64 `json:"max_value"`
  74. MinValue float64 `json:"min_value"`
  75. ModifyTime string `json:"modify_time"`
  76. MoveFrequency string `json:"move_frequency"`
  77. MoveType int `json:"move_type"`
  78. NoUpdate int `json:"no_update"`
  79. ServerUrl string `json:"server_url"`
  80. Sort int `json:"sort"`
  81. Source int `json:"source"`
  82. SourceIndexName string `json:"source_index_name"`
  83. SourceName string `json:"source_name"`
  84. StartDate string `json:"start_date"`
  85. StockCode string `json:"stock_code"`
  86. SubSource int `json:"sub_source"`
  87. SubSourceName string `json:"sub_source_name"`
  88. SysUserId int `json:"sys_user_id"`
  89. SysUserRealName string `json:"sys_user_real_name"`
  90. TerminalCode string `json:"terminal_code"`
  91. UniqueCode string `json:"unique_code"`
  92. Unit string `json:"unit"`
  93. UnitEn string `json:"unit_en"`
  94. }
  95. type EdbData struct {
  96. EdbDataId int32 `gorm:"column:edb_data_id;primaryKey" json:"edb_data_id"` // `orm:"column(edb_data_id);pk" json:"edb_data_id"`
  97. EdbInfoId int32 `json:"edb_info_id"` // 指标id
  98. EdbCode string `json:"edb_code"` // 指标编码
  99. DataTime string `json:"data_time"` // 数据日期
  100. Value float64 `json:"value"` // 数据值
  101. CreateTime string `json:"create_time"` // 创建时间
  102. ModifyTime string `json:"modify_time"` // 修改时间
  103. DataTimestamp int64 `json:"data_timestamp"` // 数据日期时间戳
  104. }