processor_factory.go 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. package ruizide
  2. import (
  3. "eta/eta_data_analysis/models"
  4. "fmt"
  5. )
  6. type ReportProcessor interface {
  7. Process(string, string, int, []string) ([]models.BaseFromRzdData, error)
  8. }
  9. func GetProcessor(tableName string, sheetName string) (ReportProcessor, error) {
  10. if tableName == "Oil_Demand_Signals_Weekly_Report" {
  11. switch sheetName {
  12. case "Road Index":
  13. return &RoadIndexProcessor{}, nil
  14. case "Road Active Fleet":
  15. return &RoadActiveFleetProcessor{}, nil
  16. case "Aviation Index":
  17. return &AviationIndexProcessor{}, nil
  18. case "Aviation Active Fleet":
  19. return &AviationActiveFleetProcessor{}, nil
  20. case "Demand - Gasoline":
  21. return &DemandGasolineProcessor{}, nil
  22. case "Demand - Diesel":
  23. return &DemandDieselProcessor{}, nil
  24. case "Demand - Jet Fuel":
  25. return &DemandJetFuelProcessor{}, nil
  26. case "Demand - Maritime Bunker":
  27. return &DemandMaritimeBunkerProcessor{}, nil
  28. default:
  29. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  30. }
  31. } else if tableName == "Supply_Revision_Analysis" {
  32. switch sheetName {
  33. case "Chart1":
  34. return &SupplyRevisionAnalysisChartOneProcessor{}, nil
  35. case "Chart2":
  36. return &SupplyRevisionAnalysisChartTwoProcessor{}, nil
  37. case "Chart3":
  38. return &SupplyRevisionAnalysisChartThreeProcessor{}, nil
  39. case "Chart4":
  40. return &SupplyRevisionAnalysisChartFourProcessor{}, nil
  41. case "Chart5":
  42. return &SupplyRevisionAnalysisChartFiveProcessor{}, nil
  43. case "Chart6":
  44. return &SupplyRevisionAnalysisChartSixProcessor{}, nil
  45. default:
  46. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  47. }
  48. } else if tableName == "Oil_Supply_Analysis" {
  49. switch sheetName {
  50. case "Chart1":
  51. return &OilSupplyAnalysisChartOneProcessor{}, nil
  52. case "Chart2":
  53. return &OilSupplyAnalysisChartTwoProcessor{}, nil
  54. case "Chart3":
  55. return &OilSupplyAnalysisChartThreeProcessor{}, nil
  56. case "Chart4":
  57. return &OilSupplyAnalysisChartFourProcessor{}, nil
  58. default:
  59. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  60. }
  61. } else if tableName == "Oil_Demand_Analysis_Continent" {
  62. switch sheetName {
  63. case "Chart1":
  64. return &OilDemandAnalysisContinentProcessor{}, nil
  65. default:
  66. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  67. }
  68. } else if tableName == "Oil_Demand_Analysis_Region" {
  69. switch sheetName {
  70. case "Chart1":
  71. return &OilDemandAnalysisRegionProcessor{}, nil
  72. default:
  73. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  74. }
  75. } else if tableName == "Oil_Demand_Analysis_Country" {
  76. switch sheetName {
  77. case "Chart1":
  78. return &OilDemandAnalysisCountryProcessor{}, nil
  79. default:
  80. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  81. }
  82. } else if tableName == "Oil_Demand_Analysis_Product_Category" {
  83. switch sheetName {
  84. case "Chart1":
  85. return &OilDemandAnalysisProductCategoryProcessor{}, nil
  86. default:
  87. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  88. }
  89. } else if tableName == "Oil_Demand_Analysis_Product_Detail" {
  90. switch sheetName {
  91. case "Chart1":
  92. return &OilDemandAnalysisProductDetailProcessor{}, nil
  93. default:
  94. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  95. }
  96. } else if tableName == "Oil_Demand_Analysis_Sector_Category" {
  97. switch sheetName {
  98. case "Chart1":
  99. return &OilDemandAnalysisSectorCategoryProcessor{}, nil
  100. default:
  101. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  102. }
  103. } else if tableName == "Oil_Demand_Analysis_Sector_Detail" {
  104. switch sheetName {
  105. case "Chart1":
  106. return &OilDemandAnalysisSectorDetailProcessor{}, nil
  107. default:
  108. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  109. }
  110. } else if tableName == "Oil_Demand_Analysis_Scenario" {
  111. switch sheetName {
  112. case "Chart1":
  113. return &OilDemandAnalysisScenarioProcessor{}, nil
  114. default:
  115. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  116. }
  117. } else if tableName == "Oil_Market_Cube_Upstream_Supply_Oil_Quality_Api" {
  118. switch sheetName {
  119. case "ExportCubeBrowser 1":
  120. return &UpstreamSupplyOilQualityApiProcessor{}, nil
  121. default:
  122. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  123. }
  124. } else if tableName == "Oil_Market_Cube_Upstream_Supply_Oil_Quality_Sulphur" {
  125. switch sheetName {
  126. case "ExportCubeBrowser 1":
  127. return &OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor{}, nil
  128. default:
  129. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  130. }
  131. } else if tableName == "Oil_Market_Cube_Upstream_Supply_Capacity_Capacity" {
  132. switch sheetName {
  133. case "ExportCubeBrowser 1":
  134. return &OilMarketCubeUpstreamSupplyCapacityCapacityProcessor{}, nil
  135. default:
  136. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  137. }
  138. } else if tableName == "Oil_Market_Cube_Upstream_Supply_Production" {
  139. switch sheetName {
  140. case "ExportCubeBrowser 1":
  141. return &OilMarketCubeUpstreamSupplyProductionProcessor{}, nil
  142. default:
  143. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  144. }
  145. } else if tableName == "Oil_Market_Cube_Upstream_Supply_Production_Wo_Seasonality" {
  146. switch sheetName {
  147. case "ExportCubeBrowser 1":
  148. return &UpstreamSupplyProductionWoSeasonalityProcessor{}, nil
  149. default:
  150. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  151. }
  152. } else if tableName == "Oil_Market_Cube_Upstream_Supply_OPEC_Policy_Reference_Production" {
  153. switch sheetName {
  154. case "ExportCubeBrowser 1":
  155. return &UpstreamSupplyOPECPolicyReferenceProductionProcessor{}, nil
  156. default:
  157. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  158. }
  159. } else if tableName == "Oil_Market_Cube_Upstream_Supply_OPEC_Policy_Target_Production" {
  160. switch sheetName {
  161. case "ExportCubeBrowser 1":
  162. return &UpstreamSupplyOPECPolicyTargetProductionProcessor{}, nil
  163. default:
  164. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  165. }
  166. } else if tableName == "Oil_Market_Cube_Upstream_Supply_OPEC_Policy_Target_Cut" {
  167. switch sheetName {
  168. case "ExportCubeBrowser 1":
  169. return &UpstreamSupplyOPECPolicyTargetCutProcessor{}, nil
  170. default:
  171. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  172. }
  173. } else if tableName == "Oil_Market_Cube_Upstream_Supply_OPEC_Policy_Actual_Cut" {
  174. switch sheetName {
  175. case "ExportCubeBrowser 1":
  176. return &UpstreamSupplyOPECPolicyActualCutProcessor{}, nil
  177. default:
  178. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  179. }
  180. } else if tableName == "Oil_Market_Cube_Upstream_Supply_OPEC_Policy_Compliance" {
  181. switch sheetName {
  182. case "ExportCubeBrowser 1":
  183. return &UpstreamSupplyOPECPolicyComplianceProcessor{}, nil
  184. default:
  185. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  186. }
  187. } else if tableName == "Oil_Market_Cube_Upstream_Supply_OPEC_Policy_Production_Subject_To_Cut" {
  188. switch sheetName {
  189. case "ExportCubeBrowser 1":
  190. return &UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor{}, nil
  191. default:
  192. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  193. }
  194. } else if tableName == "Oil_Market_Cube_Products_Demand_Products_Demand_Mean" {
  195. switch sheetName {
  196. case "ExportCubeBrowser 1":
  197. return &ProductsDemandProductsDemandMeanProcessor{}, nil
  198. default:
  199. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  200. }
  201. } else if tableName == "Oil_Market_Cube_Products_Demand_Products_Demand+Sigma" {
  202. switch sheetName {
  203. case "ExportCubeBrowser 1":
  204. return &ProductsDemandProductsDemandAddSigmaProcessor{}, nil
  205. default:
  206. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  207. }
  208. } else if tableName == "Oil_Market_Cube_Products_Demand_Products_Demand-Sigma" {
  209. switch sheetName {
  210. case "ExportCubeBrowser 1":
  211. return &ProductsDemandProductsDemandSubSigmaProcessor{}, nil
  212. default:
  213. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  214. }
  215. } else if tableName == "Oil_Market_Cube_Balances_Total_Liquids_Balances" {
  216. switch sheetName {
  217. case "ExportCubeBrowser 1":
  218. return &BalancesTotalLiquidsBalancesProcessor{}, nil
  219. default:
  220. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  221. }
  222. } else if tableName == "Oil_Market_Cube_Geography_Latitude" {
  223. switch sheetName {
  224. case "ExportCubeBrowser 1":
  225. return &GeographyLatitudeProcessor{}, nil
  226. default:
  227. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  228. }
  229. } else if tableName == "Oil_Market_Cube_Geography_Longitude" {
  230. switch sheetName {
  231. case "ExportCubeBrowser 1":
  232. return &GeographyLongitudeProcessor{}, nil
  233. default:
  234. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  235. }
  236. }
  237. // 可以添加更多的逻辑来处理其他产品和类别
  238. return nil, fmt.Errorf("no processor found for tableName %s and sheetName %s", tableName, sheetName)
  239. }