package addpackage import ( "context" "git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/consts" "git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/batchimport" "git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/model" "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/frame/g" ) type PrepareProcessor struct { inner *Processor config batchimport.ProcessorConfig targetBatchType int } func NewPrepareProcessor(operation Operation, options SubmitOptions) (*PrepareProcessor, error) { inner, err := NewProcessor(operation, options) if err != nil { return nil, err } cfg := inner.Config() cfg.Code = cfg.Code + "_prepare" cfg.BatchType = consts.BatchTypePrepare return &PrepareProcessor{ inner: inner, config: cfg, targetBatchType: inner.config.BatchType, }, nil } func (p *PrepareProcessor) Config() batchimport.ProcessorConfig { return p.config } func (p *PrepareProcessor) ParseRows(ctx context.Context, filePath string) ([]batchimport.Row, error) { return p.inner.ParseRows(ctx, filePath) } func (p *PrepareProcessor) ValidateRows(ctx context.Context, rows []batchimport.Row) error { // Keep submit non-blocking; the worker owns add package prepare validation. return nil } func (p *PrepareProcessor) BuildBatchInfo(ctx context.Context, req batchimport.SubmitRequest, result *batchimport.Result, importOss *model.SysOssSaveContentModel, resultOss *model.SysOssSaveContentModel, downloadId int64) *gjson.Json { info := g.Map{} base := p.inner.BuildBatchInfo(ctx, req, result, importOss, resultOss, downloadId) if base != nil { for key, value := range base.Map() { info[key] = value } } info["operation"] = p.config.Code info["batchType"] = consts.BatchTypePrepare info["targetBatchType"] = p.targetBatchType info["targetBatchName"] = addPackageTargetBatchName(p.targetBatchType) info["targetLabel"] = p.inner.config.TargetLabel return gjson.New(info) } func addPackageTargetBatchName(batchType int) string { switch batchType { case consts.BatchTypePoolAddPackage: return "流量池加油包" default: return "单卡加油包" } }