processor_factory.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // @Author gmy 2024/8/6 10:48:00
  2. package main
  3. import (
  4. "context"
  5. "eta/eta_data_analysis/models"
  6. "fmt"
  7. )
  8. type ReportProcessor interface {
  9. Process(ctx context.Context, product string, reportContent string, keywords []string, classifyId int) ([]models.BaseFromLyData, error)
  10. }
  11. func GetProcessor(product string, category string) (ReportProcessor, error) {
  12. if product == "大豆" {
  13. switch category {
  14. case "进口成本":
  15. return &ImportCostProcessor{}, nil
  16. case "加工利润":
  17. return &ProcessingProfitProcessor{}, nil
  18. case "船运费用":
  19. return &ShippingCostProcessor{}, nil
  20. case "供需平衡":
  21. return &SupplyDemandBalanceProcessor{}, nil
  22. case "采购装船":
  23. return &PurchaseShippingProcessor{}, nil
  24. case "库存分析":
  25. return &InventoryAnalysisProcessor{}, nil
  26. case "加工报告":
  27. return &ProcessingReportProcessor{}, nil
  28. default:
  29. return nil, fmt.Errorf("unknown category: %s", category)
  30. }
  31. } else if product == "豆粕" {
  32. switch category {
  33. case "库存分析":
  34. return &InventoryAnalysisProcessor{}, nil
  35. default:
  36. return nil, fmt.Errorf("unknown category: %s", category)
  37. }
  38. } else if product == "大豆油" {
  39. switch category {
  40. case "库存分析":
  41. return &InventoryAnalysisProcessor{}, nil
  42. case "价差套利":
  43. return &PriceSpreadArbitrageProcessor{}, nil
  44. case "每日成交":
  45. return &DailyTransactionProcessor{}, nil
  46. default:
  47. return nil, fmt.Errorf("unknown category: %s", category)
  48. }
  49. } else if product == "棕榈油" {
  50. switch category {
  51. case "国际价格":
  52. return &InternationalPriceProcessor{}, nil
  53. case "进口成本":
  54. return &PalmOilImportCostProcessor{}, nil
  55. case "库存分析":
  56. return &InventoryAnalysisProcessor{}, nil
  57. case "每日成交":
  58. return &DailyTransactionProcessor{}, nil
  59. default:
  60. return nil, fmt.Errorf("unknown category: %s", category)
  61. }
  62. } else if product == "油菜籽" {
  63. switch category {
  64. case "进口成本":
  65. return &ImportCostProcessor{}, nil
  66. case "库存分析":
  67. return &InventoryAnalysisProcessor{}, nil
  68. case "进口预估":
  69. return &ImportEstimateProcessor{}, nil
  70. case "加拿大统计局":
  71. return &CanadaStatisticsBureauProcessor{}, nil
  72. case "进出口分析":
  73. return &ImportExportAnalysisProcessor{}, nil
  74. default:
  75. return nil, fmt.Errorf("unknown category: %s", category)
  76. }
  77. } else if product == "菜粕" {
  78. switch category {
  79. case "库存分析":
  80. return &InventoryAnalysisProcessor{}, nil
  81. case "进出口分析":
  82. return &ImportExportAnalysisProcessor{}, nil
  83. default:
  84. return nil, fmt.Errorf("unknown category: %s", category)
  85. }
  86. } else if product == "菜籽油" {
  87. switch category {
  88. case "库存分析":
  89. return &InventoryAnalysisProcessor{}, nil
  90. case "进口预估":
  91. return &ImportEstimateProcessor{}, nil
  92. case "每日成交":
  93. return &DailyTransactionProcessor{}, nil
  94. default:
  95. return nil, fmt.Errorf("unknown category: %s", category)
  96. }
  97. } else if product == "葵花粕" {
  98. switch category {
  99. case "进口预估":
  100. return &ImportEstimateProcessor{}, nil
  101. default:
  102. return nil, fmt.Errorf("unknown category: %s", category)
  103. }
  104. }
  105. // 可以添加更多的逻辑来处理其他产品和类别
  106. return nil, fmt.Errorf("no processor found for product %s and category %s", product, category)
  107. }