根据异常清单和完整物料表定向修正发货明细物料编号与描述;只允许修正标记行使用存储物料,其他行逻辑不变。 验证:定向修正器 4 个测试、39 条断言;页面 9 个测试、109 条断言;生产只读审计 221 行精确匹配。
67 lines
2.6 KiB
PHP
67 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Business\KukaPostingBase\KukaPostingMaterialRepairImporter;
|
|
use Illuminate\Console\Command;
|
|
use Throwable;
|
|
|
|
class ImportKukaPostingMaterialRepair extends Command
|
|
{
|
|
protected $signature = 'business-mirror:import-kuka-posting-material-repair
|
|
{abnormalPath : 表一,缺少物料信息的异常数据 XLSX 文件}
|
|
{mappingPath : 表二,包含完整物料信息的发货明细 XLSX 文件}
|
|
{--month= : 账期 YYYY-MM}
|
|
{--sheet=Sheet1 : 两个工作表共用的工作表名称}
|
|
{--company=1 : 公司 ID}
|
|
{--dry-run : 只校验异常清单、表二和生产镜像,不写入}';
|
|
|
|
protected $description = '仅修正顾家过账异常发货明细行的物料编号和物料描述';
|
|
|
|
public function handle(KukaPostingMaterialRepairImporter $importer): int
|
|
{
|
|
$period = trim((string) $this->option('month'));
|
|
if ($period === '') {
|
|
$this->error('必须指定 --month=YYYY-MM。');
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
try {
|
|
$result = $importer->import(
|
|
(string) $this->argument('abnormalPath'),
|
|
(string) $this->argument('mappingPath'),
|
|
$period,
|
|
(string) ($this->option('sheet') ?: 'Sheet1'),
|
|
max(1, (int) $this->option('company')),
|
|
(bool) $this->option('dry-run'),
|
|
);
|
|
} catch (Throwable $exception) {
|
|
$this->error('顾家过账物料修正未导入,原有数据未改变。' . $exception->getMessage());
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
$storeRows = [];
|
|
foreach ($result['stores'] as $store => $count) {
|
|
$storeRows[] = [$store, number_format($count)];
|
|
}
|
|
|
|
$this->table(['项目', '值'], [
|
|
['模式', $result['dry_run'] ? '仅校验' : '正式导入'],
|
|
['账期', $result['period']],
|
|
['异常数据行数', number_format($result['rows'])],
|
|
['业务记录数', number_format($result['identities'])],
|
|
['物料组合数', number_format($result['material_pairs'])],
|
|
['需要更新', number_format($result['updated'])],
|
|
['已一致', number_format($result['unchanged'])],
|
|
['表一 SHA-256', $result['abnormal_file_sha256']],
|
|
['表二 SHA-256', $result['mapping_file_sha256']],
|
|
]);
|
|
$this->table(['店铺', '异常行数'], $storeRows);
|
|
$this->info($result['dry_run'] ? '顾家过账异常物料校验完成。' : '顾家过账异常物料已修正。');
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|