edb_info_updates.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. )
  6. type UpdatesStatisticalItem struct {
  7. Total int
  8. Source int
  9. EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
  10. }
  11. func GetUpdatesStatistical(condition string, pars []interface{}) (list []*UpdatesStatisticalItem, err error) {
  12. o := orm.NewOrmUsingDB("data")
  13. sql := ` SELECT COUNT(1) AS total,source,edb_type FROM edb_info
  14. WHERE 1=1 `
  15. sql += condition
  16. sql += ` GROUP BY source `
  17. _, err = o.Raw(sql, pars).QueryRows(&list)
  18. return
  19. }
  20. type UpdatesStatisticalResp struct {
  21. ThsUpdate int `description:"同花顺已更新"`
  22. ThsNotUpdate int `description:"同花顺未更新"`
  23. WindUpdate int `description:"wind已更新"`
  24. WindNotUpdate int `description:"wind未更新"`
  25. PbUpdate int `description:"彭博已更新"`
  26. PbNotUpdate int `description:"彭博未更新"`
  27. PbFinanceUpdate int `description:"彭博财务已更新"`
  28. PbFinanceNotUpdate int `description:"彭博财务未更新"`
  29. LzUpdate int `description:"隆众已更新"`
  30. LzNotUpdate int `description:"隆众未更新"`
  31. SmmUpdate int `description:"Smm已更新"`
  32. SmmNotUpdate int `description:"Smm未更新"`
  33. MysteelUpdate int `description:"钢联已更新"`
  34. MysteelNotUpdate int `description:"钢联未更新"`
  35. ZzUpdate int `description:"郑商所已更新"`
  36. ZzNotUpdate int `description:"郑商所未更新"`
  37. DlUpdate int `description:"大商所已更新"`
  38. DlNotUpdate int `description:"大商所未更新"`
  39. ShUpdate int `description:"上期所已更新"`
  40. ShNotUpdate int `description:"上期所未更新"`
  41. CffexUpdate int `description:"中金所已更新"`
  42. CffexNotUpdate int `description:"中金所未更新"`
  43. ShfeUpdate int `description:"上期能源已更新"`
  44. ShfeNotUpdate int `description:"上期能源未更新"`
  45. GieUpdate int `description:"欧洲天然气已更新"`
  46. GieNotUpdate int `description:"欧洲天然气未更新"`
  47. CalculateUpdate int `description:"计算指标已更新"`
  48. CalculateNotUpdate int `description:"计算指标未更新"`
  49. ManualUpdate int `description:"手工指标已更新"`
  50. ManualNotUpdate int `description:"手工指标未更新"`
  51. LtUpdate int `description:"路透已更新"`
  52. LtNotUpdate int `description:"路透未更新"`
  53. CoalUpdate int `description:"煤炭网已更新"`
  54. CoalNotUpdate int `description:"煤炭网未更新"`
  55. GoogleTravelUpdate int `description:"谷歌出行已更新"`
  56. GoogleTravelNotUpdate int `description:"谷歌出行未更新"`
  57. EiaSteoUpdate int `description:"eia steo报告已更新"`
  58. EiaSteoNotUpdate int `description:"eia steo报告未更新"`
  59. UNUpdate int `description:"UN报告已更新"`
  60. UNNotUpdate int `description:"UN报告未更新"`
  61. SciUpdate int `description:"卓创数据已更新"`
  62. SciNotUpdate int `description:"卓创数据未更新"`
  63. BaiinfoUpdate int `description:"百川盈孚数据已更新"`
  64. BaiinfoNotUpdate int `description:"百川盈孚数据未更新"`
  65. NationalStatisticsUpdate int `description:"国家统计局数据已更新"`
  66. NationalStatisticsNotUpdate int `description:"国家统计局数据未更新"`
  67. FubaoUpdate int `description:"富宝已更新"`
  68. FubaoNotUpdate int `description:"富宝未更新"`
  69. }
  70. /*
  71. DATA_SOURCE_THS = iota + 1 //同花顺
  72. DATA_SOURCE_WIND //wind
  73. DATA_SOURCE_PB //彭博
  74. DATA_SOURCE_CALCULATE //指标运算
  75. DATA_SOURCE_CALCULATE_LJZZY //累计值转月
  76. DATA_SOURCE_CALCULATE_TBZ //同比值
  77. DATA_SOURCE_CALCULATE_TCZ //同差值
  78. DATA_SOURCE_CALCULATE_NSZYDPJJS //N数值移动平均计算
  79. DATA_SOURCE_MANUAL //手工指标
  80. DATA_SOURCE_LZ //隆众
  81. DATA_SOURCE_YS //有色
  82. DATA_SOURCE_CALCULATE_HBZ //环比值->12
  83. DATA_SOURCE_CALCULATE_HCZ //环差值->13
  84. DATA_SOURCE_CALCULATE_BP //变频->14
  85. DATA_SOURCE_GL //钢联->15
  86. */
  87. func GetUpdatesList(condition string, pars []interface{}, startSize, pageSize int) (list []*EdbInfoView, err error) {
  88. o := orm.NewOrmUsingDB("data")
  89. sql := ` SELECT * FROM edb_info
  90. WHERE 1=1 `
  91. sql += condition
  92. sql += ` LIMIT ?,? `
  93. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  94. return
  95. }
  96. // GetAllUpdatesList 获取所有待更新的指标
  97. func GetAllUpdatesList() (list []*EdbInfoView, err error) {
  98. o := orm.NewOrmUsingDB("data")
  99. sql := ` SELECT * FROM edb_info
  100. WHERE 1=1 AND is_update=? AND no_update=? AND edb_info_type = ? ORDER BY edb_type ASC `
  101. _, err = o.Raw(sql, 1, 0, 0).QueryRows(&list)
  102. return
  103. }
  104. func GetUpdatesListTotal(condition string, pars []interface{}) (count int, err error) {
  105. o := orm.NewOrmUsingDB("data")
  106. sql := ` SELECT COUNT(1) AS count FROM edb_info
  107. WHERE 1=1 `
  108. sql += condition
  109. err = o.Raw(sql, pars).QueryRow(&count)
  110. return
  111. }
  112. type UpdatesListResp struct {
  113. List []*EdbInfoView
  114. Total int
  115. Paging *paging.PagingItem
  116. }