option('company'); if ($companyId <= 0) { throw new InvalidArgumentException('公司 ID 必须为正整数。'); } $period = trim((string) $this->option('period')); if ($period !== '' && preg_match('/^\d{4}-(0[1-9]|1[0-2])$/', $period) !== 1) { throw new InvalidArgumentException('账期格式必须为 YYYY-MM。'); } $result = $synchronizer->sync( $companyId, $period === '' ? null : $period, (bool) $this->option('dry-run'), ); if ((bool) $this->option('json')) { $this->line(json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); } else { $this->info(sprintf( '物料映射%s完成:货号 %d,唯一匹配 %d,未匹配 %d,冲突 %d;直接物料编号 %d,档案条码 %d。', $result['dry_run'] ? '校验' : '同步', $result['items'], $result['matched'], $result['unmatched'], $result['ambiguous'], $result['direct'], $result['archive'], )); } return self::SUCCESS; } }