44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
||
|
||
namespace App\Console\Commands;
|
||
|
||
use Illuminate\Console\Command;
|
||
use Modules\EcommerceFinance\Services\DingProcessDetailMirrorImporter;
|
||
use Throwable;
|
||
|
||
class ImportDingProcessDetails extends Command
|
||
{
|
||
protected $signature = 'ding:import-process-details
|
||
{file : 15 列流程明细 CSV 文件路径}
|
||
{--scope=personal_permission : 数据权限范围标识}
|
||
{--replace : 导入前清空同一范围的数据}';
|
||
|
||
protected $description = '兼容导入旧版铺平 CSV;生产请使用 business-mirror:sync-ding-process-details';
|
||
|
||
public function handle(DingProcessDetailMirrorImporter $importer): int
|
||
{
|
||
try {
|
||
$result = $importer->import(
|
||
(string) $this->argument('file'),
|
||
(string) $this->option('scope'),
|
||
(bool) $this->option('replace'),
|
||
);
|
||
} catch (Throwable $exception) {
|
||
$this->error('导入失败:' . $exception->getMessage());
|
||
|
||
return self::FAILURE;
|
||
}
|
||
|
||
$this->info(sprintf(
|
||
'导入完成:%d 行,跳过占位 %d 行,跳过无效 %d 行,重复 %d 行,范围 %s。',
|
||
$result['rows'],
|
||
$result['placeholders'],
|
||
$result['invalid'],
|
||
$result['duplicates'],
|
||
$result['scope'],
|
||
));
|
||
|
||
return self::SUCCESS;
|
||
}
|
||
}
|