option('month'); if (! preg_match('/^20\d{2}-(0[1-9]|1[0-2])$/', $month)) { $this->error('--month 要写成 2026-10 这样'); return self::FAILURE; } $blocks = json_decode((string) @file_get_contents((string) $this->argument('file')), true); if (! is_array($blocks)) { $this->error('读不了 JSON 文件'); return self::FAILURE; } $blocks = array_values(array_filter(array_map(static fn ($b): ?array => is_array($b) && isset($b['title'], $b['labels']) && is_array($b['labels']) ? ['title' => (string) $b['title'], 'labels' => array_map('strval', $b['labels']), 'group' => isset($b['group']) ? (string) $b['group'] : null, 'source' => isset($b['source']) ? (string) $b['source'] : null] : null, $blocks))); $result = $store->saveSummaryTemplates($blocks, $month); $this->info('读到 ' . $result['blocks'] . ' 块,记下 ' . count($result['saved']) . ' 家 ' . $month . ' 的类目:' . implode('、', $result['saved'])); if ($result['unknown'] !== []) { $this->warn('没找到分组:' . implode('、', $result['unknown'])); } return self::SUCCESS; } }