processor_factory.go 835 B

123456789101112131415161718192021222324252627282930
  1. package main
  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. default:
  15. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  16. }
  17. } else if tableName == "RE_Dashboard_Export" {
  18. switch sheetName {
  19. case "Chart1":
  20. return &RoadIndexProcessor{}, nil
  21. default:
  22. return nil, fmt.Errorf("unknown sheetName: %s", sheetName)
  23. }
  24. }
  25. // 可以添加更多的逻辑来处理其他产品和类别
  26. return nil, fmt.Errorf("no processor found for tableName %s and sheetName %s", tableName, sheetName)
  27. }