Commit 8de2508d by 杨树贤

fuck

parent 195b4c82
...@@ -40,11 +40,8 @@ class RefreshHistoryPurchaseUser extends Command ...@@ -40,11 +40,8 @@ class RefreshHistoryPurchaseUser extends Command
$this->info('处理数量: ' . ($num > 0 ? $num : '不限制')); $this->info('处理数量: ' . ($num > 0 ? $num : '不限制'));
$this->info('========================================'); $this->info('========================================');
// 调用服务方法 // 调用服务方法,不使用实时回调输出
$self = $this; $result = SupplierService::refreshHistoryPurchaseUserWithProgress($mode, $num);
$result = SupplierService::refreshHistoryPurchaseUserWithProgress($mode, $num, function ($progress) use ($self) {
$self->outputProgress($progress);
});
// 输出最终结果 // 输出最终结果
$this->info(''); $this->info('');
...@@ -60,7 +57,10 @@ class RefreshHistoryPurchaseUser extends Command ...@@ -60,7 +57,10 @@ class RefreshHistoryPurchaseUser extends Command
if (!empty($result['details'])) { if (!empty($result['details'])) {
$this->info(''); $this->info('');
$this->info('数据变更详情(' . count($result['details']) . '条):'); $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']; $supplierId = $detail['supplier_id'];
$supplierCode = isset($detail['supplier_code']) ? $detail['supplier_code'] : ''; $supplierCode = isset($detail['supplier_code']) ? $detail['supplier_code'] : '';
$supplierName = isset($detail['supplier_name']) ? $detail['supplier_name'] : ''; $supplierName = isset($detail['supplier_name']) ? $detail['supplier_name'] : '';
...@@ -87,28 +87,41 @@ class RefreshHistoryPurchaseUser extends Command ...@@ -87,28 +87,41 @@ class RefreshHistoryPurchaseUser extends Command
$assignInfo $assignInfo
)); ));
} }
if (count($result['details']) > $outputLimit) {
$this->info(' ... 还有 ' . (count($result['details']) - $outputLimit) . ' 条记录未显示');
}
} }
// 打印失败的记录 // 打印失败的记录,限制数量
if (!empty($result['debug_info'])) { if (!empty($result['debug_info'])) {
$this->info(''); $failCount = 0;
$this->warn('失败详情(' . count($result['debug_info']) . '条):');
foreach ($result['debug_info'] as $info) { foreach ($result['debug_info'] as $info) {
$failReason = isset($info['fail_reason']) ? $info['fail_reason'] : ''; if (isset($info['fail_reason']) && $info['fail_reason']) {
$skipReason = isset($info['skip_reason']) ? $info['skip_reason'] : ''; $failCount++;
$supplierName = isset($info['supplier_name']) ? $info['supplier_name'] : ''; }
$supplierCode = isset($info['supplier_code']) ? $info['supplier_code'] : ''; }
$reason = $failReason ? $failReason : $skipReason; if ($failCount > 0) {
$this->info('');
// 只打印失败的,跳过的不再打印 $this->warn('失败详情(' . $failCount . '条):');
if ($failReason) { $failOutputLimit = 20;
$this->warn(sprintf( $outputCount = 0;
' [ID:%d %s] %s - %s', foreach ($result['debug_info'] as $info) {
$info['supplier_id'], $failReason = isset($info['fail_reason']) ? $info['fail_reason'] : '';
$supplierCode, if ($failReason && $outputCount < $failOutputLimit) {
$supplierName, $supplierName = isset($info['supplier_name']) ? $info['supplier_name'] : '';
$reason $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