processor_factory.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package area_graph
  2. import (
  3. "eta/eta_api/models/data_manage"
  4. "fmt"
  5. )
  6. type NullDealStrategy interface {
  7. Deal(tmpConfig data_manage.AreaExtraConf, edbDataList []*data_manage.ChartEdbInfoMapping, standardIndexMap map[string]*data_manage.EdbDataList, startDate string, endDate string) (err error)
  8. }
  9. func CreateStrategy(dealWay int) (NullDealStrategy, error) {
  10. switch dealWay {
  11. case 1:
  12. return &InterpolateStrategy{}, nil
  13. case 2:
  14. return &FillWithPreviousStrategy{}, nil
  15. case 3:
  16. return &FillWithNextStrategy{}, nil
  17. case 4:
  18. return &SetToZeroStrategy{}, nil
  19. case 5:
  20. return &DeleteDateStrategy{}, nil
  21. default:
  22. return nil, fmt.Errorf("未知的空值处理类型: %d", dealWay)
  23. }
  24. }
  25. type NullDealContext struct {
  26. strategy NullDealStrategy
  27. }
  28. func (c *NullDealContext) SetStrategy(strategy NullDealStrategy) {
  29. c.strategy = strategy
  30. }
  31. func (c *NullDealContext) ExecuteStrategy(tmpConfig data_manage.AreaExtraConf, edbDataList []*data_manage.ChartEdbInfoMapping, standardIndexMap map[string]*data_manage.EdbDataList) error {
  32. return c.strategy.Deal(tmpConfig, edbDataList, standardIndexMap, "", "")
  33. }