Commit 8de2508d by 杨树贤

fuck

parent 195b4c82
......@@ -40,11 +40,8 @@ class RefreshHistoryPurchaseUser extends Command
$this->info('处理数量: ' . ($num > 0 ? $num : '不限制'));
$this->info('========================================');
// 调用服务方法
$self = $this;
$result = SupplierService::refreshHistoryPurchaseUserWithProgress($mode, $num, function ($progress) use ($self) {
$self->outputProgress($progress);
});
// 调用服务方法,不使用实时回调输出
$result = SupplierService::refreshHistoryPurchaseUserWithProgress($mode, $num);
// 输出最终结果
$this->info('');
......@@ -60,7 +57,10 @@ class RefreshHistoryPurchaseUser extends Command
if (!empty($result['details'])) {
$this->info('');
$this->info('数据变更详情(' . count($result['details']) . '条):');
foreach ($result['details'] as $detail) {
// 限制输出数量,避免过多输出
$outputLimit = 50;
$details = array_slice($result['details'], 0, $outputLimit);
foreach ($details as $detail) {
$supplierId = $detail['supplier_id'];
$supplierCode = isset($detail['supplier_code']) ? $detail['supplier_code'] : '';
$supplierName = isset($detail['supplier_name']) ? $detail['supplier_name'] : '';
......@@ -87,28 +87,41 @@ class RefreshHistoryPurchaseUser extends Command
$assignInfo
));
}
if (count($result['details']) > $outputLimit) {
$this->info(' ... 还有 ' . (count($result['details']) - $outputLimit) . ' 条记录未显示');
}
}
// 打印失败的记录
// 打印失败的记录,限制数量
if (!empty($result['debug_info'])) {
$this->info('');
$this->warn('失败详情(' . count($result['debug_info']) . '条):');
$failCount = 0;
foreach ($result['debug_info'] as $info) {
$failReason = isset($info['fail_reason']) ? $info['fail_reason'] : '';
$skipReason = isset($info['skip_reason']) ? $info['skip_reason'] : '';
$supplierName = isset($info['supplier_name']) ? $info['supplier_name'] : '';
$supplierCode = isset($info['supplier_code']) ? $info['supplier_code'] : '';
$reason = $failReason ? $failReason : $skipReason;
// 只打印失败的,跳过的不再打印
if ($failReason) {
$this->warn(sprintf(
' [ID:%d %s] %s - %s',
$info['supplier_id'],
$supplierCode,
$supplierName,
$reason
));
if (isset($info['fail_reason']) && $info['fail_reason']) {
$failCount++;
}
}
if ($failCount > 0) {
$this->info('');
$this->warn('失败详情(' . $failCount . '条):');
$failOutputLimit = 20;
$outputCount = 0;
foreach ($result['debug_info'] as $info) {
$failReason = isset($info['fail_reason']) ? $info['fail_reason'] : '';
if ($failReason && $outputCount < $failOutputLimit) {
$supplierName = isset($info['supplier_name']) ? $info['supplier_name'] : '';
$supplierCode = isset($info['supplier_code']) ? $info['supplier_code'] : '';
$this->warn(sprintf(
' [ID:%d %s] %s - %s',
$info['supplier_id'],
$supplierCode,
$supplierName,
$failReason
));
$outputCount++;
}
}
if ($failCount > $failOutputLimit) {
$this->warn(' ... 还有 ' . ($failCount - $failOutputLimit) . ' 条失败记录未显示');
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment