CaiWuXiTong/app/Console/Commands/ImportSystemizationTodos.php
yueyang 3cff23c595 新增财务系统化待办与完成截图
新增财务系统化待办与完成截图
2026-10-25 16:23:08 +08:00

42 lines
1.1 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 App\Business\SystemizationTodoWorkbookImporter;
use Illuminate\Console\Command;
use Throwable;
class ImportSystemizationTodos extends Command
{
protected $signature = 'systemization-todos:import
{file : 待办 Excel 文件路径}
{--company=1 : 写入的 company_id}
{--user= : 操作人用户 ID}';
protected $description = '导入财务系统化待办清单';
public function handle(SystemizationTodoWorkbookImporter $importer): int
{
try {
$result = $importer->import(
(string) $this->argument('file'),
max((int) $this->option('company'), 1),
$this->option('user') !== null ? (int) $this->option('user') : null,
);
} catch (Throwable $exception) {
$this->error($exception->getMessage());
return self::FAILURE;
}
$this->info(sprintf(
'工作表 %s:新增 %d 条,跳过已存在 %d 条。',
$result['sheet'],
$result['created'],
$result['skipped'],
));
return self::SUCCESS;
}
}