setName('ej-pharmacy:bootstrap-medicines') ->setDescription('一次性导入并原子替换恩济药房药材目录投影') ->addOption('replace', null, Option::VALUE_NONE, '确认替换本地 EJ 药材投影') ->addOption('confirm', null, Option::VALUE_OPTIONAL, '破坏性操作确认令牌:RESET_TEST_CATALOG', '') ->addOption('batch-size', null, Option::VALUE_OPTIONAL, '远端导入批次大小(1-500)', 100); } protected function execute(Input $input, Output $output) { try { $batchSize = (int) $input->getOption('batch-size'); EjMedicineBootstrapService::assertCommandGate( (bool) $input->getOption('replace'), (string) $input->getOption('confirm'), $batchSize ); $result = EjMedicineBootstrapService::execute($batchSize); $output->writeln(sprintf( 'bootstrap 完成 source=%d batches=%d catalog=%d active_mappings=%d unmapped=%d', $result['source_count'], $result['batch_count'], $result['catalog'], $result['active_mappings'], $result['unmapped'] )); return 0; } catch (\Throwable $exception) { $output->error($exception->getMessage()); return 1; } } }