店铺违规预警:已超时口径限定需提醒范围,字典导入命令兼容大维度文件 #334
@ -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)
|
||||
|
||||
@ -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())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user