edb_data_table.go 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. package models
  2. import (
  3. "eta/eta_index_lib/utils"
  4. "strings"
  5. )
  6. var (
  7. EdbDataTableNameMap map[int]string // 指标来源对应数据表名
  8. EdbSourceExtendIdMap map[string]int // 指标来源字符串对应来源ID
  9. EdbSourceNameMap map[int]string // 指标来源名称
  10. )
  11. // InitEdbSource 初始化时加载指标来源对应表名, 避免循环中查库, 注意edb_source表修改table_name的话需要重启服务
  12. func InitEdbSource() {
  13. EdbDataTableNameMap = make(map[int]string)
  14. EdbSourceExtendIdMap = make(map[string]int)
  15. EdbSourceNameMap = make(map[int]string)
  16. sources, e := GetEdbSourceItemsByCondition(``, make([]interface{}, 0), []string{}, "")
  17. if e != nil {
  18. utils.FileLog.Info("init source table err: %s", e.Error())
  19. return
  20. }
  21. for _, v := range sources {
  22. EdbDataTableNameMap[v.EdbSourceId] = v.TableName
  23. EdbSourceNameMap[v.EdbSourceId] = v.SourceName
  24. if v.SourceExtend != "" {
  25. arr := strings.Split(v.SourceExtend, ",")
  26. if len(arr) == 0 {
  27. continue
  28. }
  29. for _, s := range arr {
  30. EdbSourceExtendIdMap[s] = v.EdbSourceId
  31. }
  32. }
  33. }
  34. }
  35. // GetEdbDataTableName 指标数据->存储表
  36. func GetEdbDataTableName(source int) (tableName string) {
  37. switch source {
  38. case utils.DATA_SOURCE_THS:
  39. tableName = "edb_data_ths"
  40. case utils.DATA_SOURCE_WIND:
  41. tableName = "edb_data_wind"
  42. case utils.DATA_SOURCE_PB, utils.DATA_SOURCE_PB_FINANCE:
  43. tableName = "edb_data_pb"
  44. case utils.DATA_SOURCE_CALCULATE:
  45. tableName = "edb_data_calculate"
  46. case utils.DATA_SOURCE_CALCULATE_LJZZY:
  47. tableName = "edb_data_calculate_ljzzy"
  48. case utils.DATA_SOURCE_CALCULATE_TBZ:
  49. tableName = "edb_data_calculate_tbz"
  50. case utils.DATA_SOURCE_CALCULATE_TCZ:
  51. tableName = "edb_data_calculate_tcz"
  52. case utils.DATA_SOURCE_CALCULATE_NSZYDPJJS:
  53. tableName = "edb_data_calculate_nszydpjjs"
  54. case utils.DATA_SOURCE_MANUAL:
  55. tableName = "edb_data_manual"
  56. case utils.DATA_SOURCE_LZ:
  57. tableName = "edb_data_lz"
  58. case utils.DATA_SOURCE_YS:
  59. tableName = "edb_data_ys"
  60. case utils.DATA_SOURCE_CALCULATE_HBZ:
  61. tableName = "edb_data_calculate_hbz"
  62. case utils.DATA_SOURCE_CALCULATE_HCZ:
  63. tableName = "edb_data_calculate_hcz"
  64. case utils.DATA_SOURCE_CALCULATE_BP:
  65. tableName = "edb_data_calculate_bp"
  66. case utils.DATA_SOURCE_GL:
  67. tableName = "edb_data_gl"
  68. case utils.DATA_SOURCE_ZZ:
  69. tableName = "edb_data_zz"
  70. case utils.DATA_SOURCE_DL:
  71. tableName = "edb_data_dl"
  72. case utils.DATA_SOURCE_SH:
  73. tableName = "edb_data_sh"
  74. case utils.DATA_SOURCE_CFFEX:
  75. tableName = "edb_data_cffex"
  76. case utils.DATA_SOURCE_SHFE:
  77. tableName = "edb_data_ine"
  78. case utils.DATA_SOURCE_GIE:
  79. tableName = "edb_data_gie"
  80. case utils.DATA_SOURCE_CALCULATE_ZJPJ:
  81. tableName = "edb_data_calculate_zjpj"
  82. case utils.DATA_SOURCE_CALCULATE_TIME_SHIFT:
  83. tableName = "edb_data_calculate_time_shift"
  84. case utils.DATA_SOURCE_CALCULATE_LJZTBPJ:
  85. tableName = "edb_data_calculate_ljztbpj"
  86. case utils.DATA_SOURCE_LT:
  87. tableName = "edb_data_lt"
  88. case utils.DATA_SOURCE_COAL:
  89. tableName = "edb_data_coal"
  90. case utils.DATA_SOURCE_PYTHON:
  91. tableName = "edb_data_python"
  92. case utils.DATA_SOURCE_GOOGLE_TRAVEL:
  93. tableName = "edb_data_google_travel"
  94. case utils.DATA_SOURCE_PREDICT_CALCULATE:
  95. tableName = "edb_data_predict_calculate"
  96. case utils.DATA_SOURCE_PREDICT_CALCULATE_TBZ:
  97. tableName = "edb_data_predict_calculate_tbz"
  98. case utils.DATA_SOURCE_PREDICT_CALCULATE_TCZ:
  99. tableName = "edb_data_predict_calculate_tcz"
  100. case utils.DATA_SOURCE_MYSTEEL_CHEMICAL:
  101. tableName = "edb_data_mysteel_chemical"
  102. case utils.DATA_SOURCE_CALCULATE_CJJX:
  103. tableName = "edb_data_calculate_cjjx"
  104. case utils.DATA_SOURCE_EIA_STEO:
  105. tableName = "edb_data_eia_steo"
  106. case utils.DATA_SOURCE_CALCULATE_NHCC:
  107. tableName = "edb_data_calculate_nhcc"
  108. case utils.DATA_SOURCE_COM_TRADE:
  109. tableName = "edb_data_com_trade"
  110. case utils.DATA_SOURCE_PREDICT_CALCULATE_NSZYDPJJS:
  111. tableName = "edb_data_predict_calculate_nszydpjjs"
  112. case utils.DATA_SOURCE_CALCULATE_ADJUST:
  113. tableName = "edb_data_calculate_adjust"
  114. case utils.DATA_SOURCE_SCI:
  115. tableName = "edb_data_sci"
  116. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZZY:
  117. tableName = "edb_data_predict_calculate_ljzzy"
  118. case utils.DATA_SOURCE_PREDICT_CALCULATE_TIME_SHIFT:
  119. tableName = "edb_data_predict_calculate_time_shift"
  120. case utils.DATA_SOURCE_PREDICT_CALCULATE_ZJPJ:
  121. tableName = "edb_data_predict_calculate_zjpj"
  122. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZTBPJ:
  123. tableName = "edb_data_predict_calculate_ljztbpj"
  124. case utils.DATA_SOURCE_PREDICT_CALCULATE_NHCC:
  125. tableName = "edb_data_predict_calculate_nhcc"
  126. case utils.DATA_SOURCE_PREDICT_CALCULATE_CJJX:
  127. tableName = "edb_data_predict_calculate_cjjx"
  128. case utils.DATA_SOURCE_PREDICT_CALCULATE_HBZ:
  129. tableName = "edb_data_predict_calculate_hbz"
  130. case utils.DATA_SOURCE_PREDICT_CALCULATE_HCZ:
  131. tableName = "edb_data_predict_calculate_hcz"
  132. case utils.DATA_SOURCE_PREDICT_CALCULATE_BP:
  133. tableName = "edb_data_predict_calculate_bp"
  134. case utils.DATA_SOURCE_CALCULATE_JP:
  135. tableName = "edb_data_calculate_jp"
  136. case utils.DATA_SOURCE_CALCULATE_NH:
  137. tableName = "edb_data_calculate_nh"
  138. case utils.DATA_SOURCE_CALCULATE_KSZS:
  139. tableName = "edb_data_calculate_kszs"
  140. case utils.DATA_SOURCE_PREDICT_CALCULATE_JP:
  141. tableName = "edb_data_predict_calculate_jp"
  142. case utils.DATA_SOURCE_PREDICT_CALCULATE_NH:
  143. tableName = "edb_data_predict_calculate_nh"
  144. case utils.DATA_SOURCE_PREDICT_CALCULATE_KSZS:
  145. tableName = "edb_data_predict_calculate_kszs"
  146. case utils.DATA_SOURCE_BAIINFO:
  147. tableName = "edb_data_baiinfo"
  148. case utils.DATA_SOURCE_STOCK_PLANT:
  149. tableName = "edb_data_stock_plant"
  150. case utils.DATA_SOURCE_CALCULATE_CORRELATION:
  151. tableName = "edb_data_calculate_correlation"
  152. case utils.DATA_SOURCE_NATIONAL_STATISTICS:
  153. tableName = "edb_data_national_statistics"
  154. case utils.DATA_SOURCE_CALCULATE_LJZZJ: //累计值转季 -> 61
  155. tableName = "edb_data_calculate_ljzzj"
  156. case utils.DATA_SOURCE_CALCULATE_LJZ: //累计值 -> 62
  157. tableName = "edb_data_calculate_ljz"
  158. case utils.DATA_SOURCE_CALCULATE_LJZNCZJ: //累计值(年初至今) -> 63
  159. tableName = "edb_data_calculate_ljznczj"
  160. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZZJ: // 预测指标 - 累计值 -> 65
  161. tableName = "edb_data_predict_calculate_ljzzj"
  162. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZ: //预测指标 - 累计值转季->64
  163. tableName = "edb_data_predict_calculate_ljz"
  164. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZNCZJ: //预测指标 - 累计值(年初至今) -> 66
  165. tableName = "edb_data_predict_calculate_ljznczj"
  166. case utils.DATA_SOURCE_CALCULATE_STANDARD_DEVIATION: //标准差->67
  167. tableName = "edb_data_calculate_standard_deviation"
  168. case utils.DATA_SOURCE_CALCULATE_PERCENTILE: //百分位->68
  169. tableName = "edb_data_calculate_percentile"
  170. case utils.DATA_SOURCE_PREDICT_CALCULATE_STANDARD_DEVIATION: //预测标准差->69
  171. tableName = "edb_data_predict_ccalculate_standard_deviation"
  172. case utils.DATA_SOURCE_PREDICT_CALCULATE_PERCENTILE: //预测百分位->70
  173. tableName = "edb_data_predict_ccalculate_percentile"
  174. case utils.DATA_SOURCE_FUBAO: //数宝->71
  175. tableName = "edb_data_fubao"
  176. case utils.DATA_SOURCE_CALCULATE_ZSXY:
  177. tableName = "edb_data_calculate_zsxy" // 指数修匀->72
  178. case utils.DATA_SOURCE_PREDICT_CALCULATE_ZSXY:
  179. tableName = "edb_data_predict_calculate_zsxy" // 预测指数修匀->73
  180. case utils.DATA_SOURCE_CALCULATE_ZDYFX:
  181. tableName = "edb_data_calculate_zdyfx" // 自定义分析->74
  182. case utils.DATA_SOURCE_CALCULATE_RJZ: //日均值75
  183. tableName = "edb_data_calculate_rjz"
  184. default:
  185. tableName = EdbDataTableNameMap[source] // 没有对应的从edb_source中取
  186. }
  187. return
  188. }