edb_data_base.go 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. package data_manage
  2. import (
  3. "eta/eta_task/utils"
  4. "time"
  5. )
  6. // GetEdbDataTableName 指标数据->存储表
  7. func GetEdbDataTableName(source, subSource int) (tableName string) {
  8. switch source {
  9. case utils.DATA_SOURCE_THS:
  10. tableName = "edb_data_ths"
  11. if subSource == utils.DATA_SUB_SOURCE_DATE {
  12. tableName = "edb_data_ths_ds"
  13. } else {
  14. tableName = "edb_data_ths"
  15. }
  16. case utils.DATA_SOURCE_WIND:
  17. if subSource == utils.DATA_SUB_SOURCE_DATE {
  18. tableName = "edb_data_wind_wsd"
  19. } else {
  20. tableName = "edb_data_wind"
  21. }
  22. case utils.DATA_SOURCE_PB, utils.DATA_SOURCE_PB_FINANCE:
  23. tableName = "edb_data_pb"
  24. case utils.DATA_SOURCE_CALCULATE:
  25. tableName = "edb_data_calculate"
  26. case utils.DATA_SOURCE_CALCULATE_LJZZY:
  27. tableName = "edb_data_calculate_ljzzy"
  28. case utils.DATA_SOURCE_CALCULATE_TBZ:
  29. tableName = "edb_data_calculate_tbz"
  30. case utils.DATA_SOURCE_CALCULATE_TCZ:
  31. tableName = "edb_data_calculate_tcz"
  32. case utils.DATA_SOURCE_CALCULATE_NSZYDPJJS:
  33. tableName = "edb_data_calculate_nszydpjjs"
  34. case utils.DATA_SOURCE_MANUAL:
  35. tableName = "edb_data_manual"
  36. case utils.DATA_SOURCE_LZ:
  37. tableName = "edb_data_lz"
  38. case utils.DATA_SOURCE_YS:
  39. tableName = "edb_data_ys"
  40. case utils.DATA_SOURCE_CALCULATE_HBZ:
  41. tableName = "edb_data_calculate_hbz"
  42. case utils.DATA_SOURCE_CALCULATE_HCZ:
  43. tableName = "edb_data_calculate_hcz"
  44. case utils.DATA_SOURCE_CALCULATE_BP:
  45. tableName = "edb_data_calculate_bp"
  46. case utils.DATA_SOURCE_GL:
  47. tableName = "edb_data_gl"
  48. case utils.DATA_SOURCE_ZZ:
  49. tableName = "edb_data_zz"
  50. case utils.DATA_SOURCE_DL:
  51. tableName = "edb_data_dl"
  52. case utils.DATA_SOURCE_SH:
  53. tableName = "edb_data_sh"
  54. case utils.DATA_SOURCE_CFFEX:
  55. tableName = "edb_data_cffex"
  56. case utils.DATA_SOURCE_SHFE:
  57. tableName = "edb_data_ine"
  58. case utils.DATA_SOURCE_GIE:
  59. tableName = "edb_data_gie"
  60. case utils.DATA_SOURCE_CALCULATE_ZJPJ:
  61. tableName = "edb_data_calculate_zjpj"
  62. case utils.DATA_SOURCE_CALCULATE_TIME_SHIFT:
  63. tableName = "edb_data_calculate_time_shift"
  64. case utils.DATA_SOURCE_CALCULATE_LJZTBPJ:
  65. tableName = "edb_data_calculate_ljztbpj"
  66. case utils.DATA_SOURCE_LT:
  67. tableName = "edb_data_lt"
  68. case utils.DATA_SOURCE_COAL:
  69. tableName = "edb_data_coal"
  70. case utils.DATA_SOURCE_PYTHON:
  71. tableName = "edb_data_python"
  72. case utils.DATA_SOURCE_GOOGLE_TRAVEL:
  73. tableName = "edb_data_google_travel"
  74. case utils.DATA_SOURCE_PREDICT_CALCULATE:
  75. tableName = "edb_data_predict_calculate"
  76. case utils.DATA_SOURCE_PREDICT_CALCULATE_TBZ:
  77. tableName = "edb_data_predict_calculate_tbz"
  78. case utils.DATA_SOURCE_PREDICT_CALCULATE_TCZ:
  79. tableName = "edb_data_predict_calculate_tcz"
  80. case utils.DATA_SOURCE_MYSTEEL_CHEMICAL:
  81. tableName = "edb_data_mysteel_chemical"
  82. case utils.DATA_SOURCE_CALCULATE_CJJX:
  83. tableName = "edb_data_calculate_cjjx"
  84. case utils.DATA_SOURCE_EIA_STEO:
  85. tableName = "edb_data_eia_steo"
  86. case utils.DATA_SOURCE_CALCULATE_NHCC:
  87. tableName = "edb_data_calculate_nhcc"
  88. case utils.DATA_SOURCE_COM_TRADE:
  89. tableName = "edb_data_com_trade"
  90. case utils.DATA_SOURCE_PREDICT_CALCULATE_NSZYDPJJS:
  91. tableName = "edb_data_predict_calculate_nszydpjjs"
  92. case utils.DATA_SOURCE_CALCULATE_ADJUST:
  93. tableName = "edb_data_calculate_adjust"
  94. case utils.DATA_SOURCE_SCI:
  95. tableName = "edb_data_sci"
  96. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZZY:
  97. tableName = "edb_data_predict_calculate_ljzzy"
  98. case utils.DATA_SOURCE_PREDICT_CALCULATE_TIME_SHIFT:
  99. tableName = "edb_data_predict_calculate_time_shift"
  100. case utils.DATA_SOURCE_PREDICT_CALCULATE_ZJPJ:
  101. tableName = "edb_data_predict_calculate_zjpj"
  102. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZTBPJ:
  103. tableName = "edb_data_predict_calculate_ljztbpj"
  104. case utils.DATA_SOURCE_PREDICT_CALCULATE_NHCC:
  105. tableName = "edb_data_predict_calculate_nhcc"
  106. case utils.DATA_SOURCE_PREDICT_CALCULATE_CJJX:
  107. tableName = "edb_data_predict_calculate_cjjx"
  108. case utils.DATA_SOURCE_PREDICT_CALCULATE_HBZ:
  109. tableName = "edb_data_predict_calculate_hbz"
  110. case utils.DATA_SOURCE_PREDICT_CALCULATE_HCZ:
  111. tableName = "edb_data_predict_calculate_hcz"
  112. case utils.DATA_SOURCE_PREDICT_CALCULATE_BP:
  113. tableName = "edb_data_predict_calculate_bp"
  114. case utils.DATA_SOURCE_CALCULATE_JP:
  115. tableName = "edb_data_calculate_jp"
  116. case utils.DATA_SOURCE_CALCULATE_NH:
  117. tableName = "edb_data_calculate_nh"
  118. case utils.DATA_SOURCE_CALCULATE_KSZS:
  119. tableName = "edb_data_calculate_kszs"
  120. case utils.DATA_SOURCE_PREDICT_CALCULATE_JP:
  121. tableName = "edb_data_predict_calculate_jp"
  122. case utils.DATA_SOURCE_PREDICT_CALCULATE_NH:
  123. tableName = "edb_data_predict_calculate_nh"
  124. case utils.DATA_SOURCE_PREDICT_CALCULATE_KSZS:
  125. tableName = "edb_data_predict_calculate_kszs"
  126. case utils.DATA_SOURCE_BAIINFO:
  127. tableName = "edb_data_baiinfo"
  128. case utils.DATA_SOURCE_STOCK_PLANT:
  129. tableName = "edb_data_stock_plant"
  130. case utils.DATA_SOURCE_CALCULATE_CORRELATION:
  131. tableName = "edb_data_calculate_correlation"
  132. case utils.DATA_SOURCE_NATIONAL_STATISTICS:
  133. tableName = "edb_data_national_statistics"
  134. case utils.DATA_SOURCE_CALCULATE_LJZZJ: //累计值转季 -> 61
  135. tableName = "edb_data_calculate_ljzzj"
  136. case utils.DATA_SOURCE_CALCULATE_LJZ: //累计值 -> 62
  137. tableName = "edb_data_calculate_ljz"
  138. case utils.DATA_SOURCE_CALCULATE_LJZNCZJ: //累计值(年初至今) -> 63
  139. tableName = "edb_data_calculate_ljznczj"
  140. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZZJ: // 预测指标 - 累计值 -> 65
  141. tableName = "edb_data_predict_calculate_ljzzj"
  142. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZ: //预测指标 - 累计值转季->64
  143. tableName = "edb_data_predict_calculate_ljz"
  144. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZNCZJ: //预测指标 - 累计值(年初至今) -> 66
  145. tableName = "edb_data_predict_calculate_ljznczj"
  146. case utils.DATA_SOURCE_CALCULATE_STANDARD_DEVIATION: //标准差->67
  147. tableName = "edb_data_calculate_standard_deviation"
  148. case utils.DATA_SOURCE_CALCULATE_PERCENTILE: //百分位->68
  149. tableName = "edb_data_calculate_percentile"
  150. case utils.DATA_SOURCE_PREDICT_CALCULATE_STANDARD_DEVIATION: //预测标准差->69
  151. tableName = "edb_data_predict_ccalculate_standard_deviation"
  152. case utils.DATA_SOURCE_PREDICT_CALCULATE_PERCENTILE: //预测百分位->70
  153. tableName = "edb_data_predict_ccalculate_percentile"
  154. case utils.DATA_SOURCE_FUBAO:
  155. tableName = "edb_data_fubao"
  156. case utils.DATA_SOURCE_CALCULATE_ZSXY:
  157. tableName = "edb_data_calculate_zsxy" // 指数修匀->72
  158. case utils.DATA_SOURCE_PREDICT_CALCULATE_ZSXY:
  159. tableName = "edb_data_predict_calculate_zsxy" // 预测指数修匀->73
  160. case utils.DATA_SOURCE_CALCULATE_ZDYFX:
  161. tableName = "edb_data_calculate_zdyfx" // 自定义分析->74
  162. case utils.DATA_SOURCE_CALCULATE_RJZ: //日均值75
  163. tableName = "edb_data_calculate_rjz"
  164. default:
  165. edbSource := EdbSourceIdMap[source]
  166. if edbSource != nil {
  167. tableName = edbSource.TableName
  168. }
  169. }
  170. return
  171. }
  172. func GetEdbInfoCalculateTableName(source int) (tableName string) {
  173. switch source {
  174. case utils.DATA_SOURCE_CALCULATE:
  175. tableName = "edb_info_calculate"
  176. case utils.DATA_SOURCE_CALCULATE_LJZZY:
  177. tableName = "edb_info_calculate_ljzzy"
  178. case utils.DATA_SOURCE_CALCULATE_TBZ:
  179. tableName = "edb_info_calculate_tbz"
  180. case utils.DATA_SOURCE_CALCULATE_TCZ:
  181. tableName = "edb_info_calculate_tcz"
  182. case utils.DATA_SOURCE_CALCULATE_NSZYDPJJS:
  183. tableName = "edb_info_calculate_nszydpjjs"
  184. case utils.DATA_SOURCE_CALCULATE_HBZ:
  185. tableName = "edb_info_calculate_hbz"
  186. case utils.DATA_SOURCE_CALCULATE_HCZ:
  187. tableName = "edb_info_calculate_hcz"
  188. case utils.DATA_SOURCE_CALCULATE_BP:
  189. tableName = "edb_info_calculate_bp"
  190. default:
  191. tableName = EdbDataTableNameMap[source] // 没有对应的从edb_source中取
  192. return
  193. }
  194. return
  195. }
  196. func GetAddSql(edbInfoId, edbCode, dataTime, timestampStr, value string) (addSql string) {
  197. nowStr := time.Now().Format(utils.FormatDateTime)
  198. addSql += "("
  199. addSql += edbInfoId + "," + "'" + edbCode + "'" + "," + "'" + dataTime + "'" + "," + value + "," + "'" + nowStr + "'" +
  200. "," + "'" + nowStr + "'" + "," + "1"
  201. addSql += "," + "'" + timestampStr + "'"
  202. addSql += "),"
  203. return
  204. }
  205. type EdbDataBase struct {
  206. EdbDataId int `orm:"column(edb_data_id);pk"`
  207. EdbInfoId int
  208. EdbCode string
  209. DataTime string
  210. Value string
  211. Status int
  212. CreateTime time.Time
  213. ModifyTime time.Time
  214. DataTimestamp int64
  215. }