Files
zyt/server/app/command/EjPharmacyBootstrapMedicines.php
T
2026-07-22 14:50:34 +08:00

49 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
namespace app\command;
use app\common\service\pharmacy\EjMedicineBootstrapService;
use think\console\Command;
use think\console\Input;
use think\console\input\Option;
use think\console\Output;
class EjPharmacyBootstrapMedicines extends Command
{
protected function configure()
{
$this->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;
}
}
}