123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- // Package liangyou
- // @Author gmy 2024/8/6 10:48:00
- package liangyou
- import (
- "context"
- "eta/eta_crawler/models"
- "fmt"
- )
- type ReportProcessor interface {
- Process(ctx context.Context, product string, reportContent string, keywords []string, classifyId int) ([]models.BaseFromLyData, error)
- }
- func GetProcessor(product string, category string) (ReportProcessor, error) {
- if product == "大豆" {
- switch category {
- case "进口成本":
- return &ImportCostProcessor{}, nil
- case "加工利润":
- return &ProcessingProfitProcessor{}, nil
- case "船运费用":
- return &ShippingCostProcessor{}, nil
- case "供需平衡":
- return &SupplyDemandBalanceProcessor{}, nil
- case "采购装船":
- return &PurchaseShippingProcessor{}, nil
- case "库存分析":
- return &InventoryAnalysisProcessor{}, nil
- case "加工报告":
- return &ProcessingReportProcessor{}, nil
- default:
- return nil, fmt.Errorf("unknown category: %s", category)
- }
- } else if product == "豆粕" {
- switch category {
- case "库存分析":
- return &InventoryAnalysisProcessor{}, nil
- default:
- return nil, fmt.Errorf("unknown category: %s", category)
- }
- } else if product == "大豆油" {
- switch category {
- case "库存分析":
- return &InventoryAnalysisProcessor{}, nil
- case "价差套利":
- return &PriceSpreadArbitrageProcessor{}, nil
- case "每日成交":
- return &DailyTransactionProcessor{}, nil
- default:
- return nil, fmt.Errorf("unknown category: %s", category)
- }
- } else if product == "棕榈油" {
- switch category {
- case "国际价格":
- return &InternationalPriceProcessor{}, nil
- case "进口成本":
- return &PalmOilImportCostProcessor{}, nil
- case "库存分析":
- return &InventoryAnalysisProcessor{}, nil
- case "每日成交":
- return &DailyTransactionProcessor{}, nil
- default:
- return nil, fmt.Errorf("unknown category: %s", category)
- }
- } else if product == "油菜籽" {
- switch category {
- case "进口成本":
- return &ImportCostProcessor{}, nil
- case "库存分析":
- return &InventoryAnalysisProcessor{}, nil
- case "进口预估":
- return &ImportEstimateProcessor{}, nil
- case "加拿大统计局":
- return &CanadaStatisticsBureauProcessor{}, nil
- case "进出口分析":
- return &ImportExportAnalysisProcessor{}, nil
- default:
- return nil, fmt.Errorf("unknown category: %s", category)
- }
- } else if product == "菜粕" {
- switch category {
- case "库存分析":
- return &InventoryAnalysisProcessor{}, nil
- case "进出口分析":
- return &ImportExportAnalysisProcessor{}, nil
- default:
- return nil, fmt.Errorf("unknown category: %s", category)
- }
- } else if product == "菜籽油" {
- switch category {
- case "库存分析":
- return &InventoryAnalysisProcessor{}, nil
- case "进口预估":
- return &ImportEstimateProcessor{}, nil
- case "每日成交":
- return &DailyTransactionProcessor{}, nil
- default:
- return nil, fmt.Errorf("unknown category: %s", category)
- }
- } else if product == "葵花粕" {
- switch category {
- case "进口预估":
- return &ImportEstimateProcessor{}, nil
- default:
- return nil, fmt.Errorf("unknown category: %s", category)
- }
- }
- // 可以添加更多的逻辑来处理其他产品和类别
- return nil, fmt.Errorf("no processor found for product %s and category %s", product, category)
- }
|