37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
||
|
||
namespace App\Console\Commands;
|
||
|
||
use Illuminate\Console\Command;
|
||
use Modules\EcommerceFinance\Services\InventoryReportAuthoritativeImporter;
|
||
use Throwable;
|
||
|
||
class ImportInventoryReportAuthoritativeMonth extends Command
|
||
{
|
||
protected $signature = 'business-mirror:import-inventory-report-month
|
||
{path : 聚水潭按商品、按仓库、按月多维分析完整 XLSX 导出文件}';
|
||
|
||
protected $description = '导入进销存报表权威月明细,保留仓储方和子仓维度';
|
||
|
||
public function handle(InventoryReportAuthoritativeImporter $importer): int
|
||
{
|
||
try {
|
||
$result = $importer->import((string) $this->argument('path'));
|
||
} catch (Throwable $exception) {
|
||
report($exception);
|
||
$this->error('进销存权威月报导入失败:' . $exception->getMessage());
|
||
$this->warn('已保留上一版有效数据。');
|
||
|
||
return self::FAILURE;
|
||
}
|
||
|
||
$this->info(sprintf(
|
||
'进销存权威月报导入完成:月份 %s,明细 %d 行。',
|
||
$result['source_month'],
|
||
$result['source_rows'],
|
||
));
|
||
|
||
return self::SUCCESS;
|
||
}
|
||
}
|