From b32168ba771431b9b0c725effdd05379a7e9521d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E6=9C=A8?= <594326199@qq.com> Date: Tue, 13 Oct 2026 20:13:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=97=E9=93=BA=E8=BF=9D=E8=A7=84=E9=A2=84?= =?UTF-8?q?=E8=AD=A6=EF=BC=9A=E5=B7=B2=E8=B6=85=E6=97=B6=E5=8F=A3=E5=BE=84?= =?UTF-8?q?=E9=99=90=E5=AE=9A=E9=9C=80=E6=8F=90=E9=86=92=E8=8C=83=E5=9B=B4?= =?UTF-8?q?=EF=BC=8C=E5=AD=97=E5=85=B8=E5=AF=BC=E5=85=A5=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=A4=A7=E7=BB=B4=E5=BA=A6=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 统一表查询与预览统计:已超时(筛选与 KPI)仅统计「需提醒」的记录,避免非预警历史记录拉高口径 - store-violations:import-rules:限制读取前 5000 行并启用 readDataOnly,兼容带巨大空白维度的导出文件;--dry-run 输出预计新增/更新数 --- .../Commands/ImportStoreViolationRules.php | 28 +++++++++++++------ .../StoreViolationRecordRepository.php | 2 ++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/app/Console/Commands/ImportStoreViolationRules.php b/app/Console/Commands/ImportStoreViolationRules.php index 18fb67d2..bd5d234d 100644 --- a/app/Console/Commands/ImportStoreViolationRules.php +++ b/app/Console/Commands/ImportStoreViolationRules.php @@ -54,8 +54,20 @@ class ImportStoreViolationRules extends Command } try { - $sheet = IOFactory::load($file)->getActiveSheet(); - $matrix = $sheet->toArray(null, true, true, false); + $reader = IOFactory::createReaderForFile($file); + if (method_exists($reader, 'setReadDataOnly')) { + $reader->setReadDataOnly(true); + } + if (method_exists($reader, 'setReadFilter')) { + // 字典文件通常只有几十行;部分导出文件带巨大空白维度,限制读取范围。 + $reader->setReadFilter(new class implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter { + public function readCell($columnAddress, $row, $worksheetName = ''): bool + { + return $row <= 5000; + } + }); + } + $matrix = $reader->load($file)->getActiveSheet()->toArray(null, true, true, false); } catch (Throwable $exception) { $this->error('无法读取文件:' . $exception->getMessage()); @@ -137,18 +149,16 @@ class ImportStoreViolationRules extends Command 'updated_at' => now(), ]; - if ($this->option('dry-run')) { - $skipped += 0; - $updated += 0; - $created += 0; - continue; - } - $exists = $connection->table(StoreViolationRuleRepository::TABLE) ->where('platform', $platform) ->where('violation_type', $payload['violation_type']) ->exists(); + if ($this->option('dry-run')) { + $exists ? $updated++ : $created++; + continue; + } + if ($exists) { $connection->table(StoreViolationRuleRepository::TABLE) ->where('platform', $platform) diff --git a/modules/EcommerceFinance/Repositories/StoreViolationRecordRepository.php b/modules/EcommerceFinance/Repositories/StoreViolationRecordRepository.php index 458d4f5e..c11c7dd0 100644 --- a/modules/EcommerceFinance/Repositories/StoreViolationRecordRepository.php +++ b/modules/EcommerceFinance/Repositories/StoreViolationRecordRepository.php @@ -202,6 +202,7 @@ class StoreViolationRecordRepository if (! empty($filters['overdue'])) { $query->whereNotIn('handling_status', self::FINAL_HANDLING_STATUSES) + ->where('needs_alert', true) ->whereNotNull('handling_deadline') ->where('handling_deadline', '<', now()); } @@ -311,6 +312,7 @@ class StoreViolationRecordRepository $grouped = $this->connection->table(self::TABLE) ->selectRaw('platform, COUNT(*) AS aggregate') + ->where('needs_alert', true) ->whereNotIn('handling_status', self::FINAL_HANDLING_STATUSES) ->whereNotNull('handling_deadline') ->where('handling_deadline', '<', now()) -- 2.47.2