CaiWuXiTong/app/Console/Commands/ImportDingProcessDetails.php

44 lines
1.3 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
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;
}
}