From 58e4c87fb61b54c3b84f692c84fef096f8e03a1b Mon Sep 17 00:00:00 2001 From: egg Date: Mon, 23 Feb 2026 07:08:27 +0800 Subject: [PATCH] feat(reject-history): two-phase query architecture with cached views MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace per-interaction Oracle queries with a two-phase model: - POST /query: single Oracle hit, cache full LOT-level DataFrame (L1+L2) - GET /view: read cache, apply supplementary/interactive filters via pandas Add container query mode (LOT/工單/WAFER LOT with wildcard support), supplementary filters (Package/WC GROUP/Reason) from cached data, PB_* series exclusion (was PB_Diode only), and query loading spinner. Co-Authored-By: Claude Opus 4.6 --- environment.yml | 1 + frontend/src/core/reject-history-filters.js | 50 + frontend/src/reject-history/App.vue | 1142 ++++++++--------- .../reject-history/components/FilterPanel.vue | 241 +++- frontend/src/reject-history/style.css | 81 +- requirements.txt | 1 + .../routes/reject_history_routes.py | 141 ++ .../services/reject_dataset_cache.py | 689 ++++++++++ .../services/reject_history_service.py | 12 +- .../sql/reject_history/performance_daily.sql | 3 +- .../reject_history/performance_daily_lot.sql | 3 +- 11 files changed, 1707 insertions(+), 657 deletions(-) create mode 100644 src/mes_dashboard/services/reject_dataset_cache.py diff --git a/environment.yml b/environment.yml index f14bd12..b3ca7b2 100644 --- a/environment.yml +++ b/environment.yml @@ -27,6 +27,7 @@ dependencies: # Data Processing - pandas==2.3.3 # Pin DBAPI2-compatible release for current pd.read_sql flow + - pyarrow>=17.0.0,<20.0.0 # Parquet serialization for Redis DataFrame cache - openpyxl>=3.0.0 # Cache (Redis) diff --git a/frontend/src/core/reject-history-filters.js b/frontend/src/core/reject-history-filters.js index fde98d2..de7b49f 100644 --- a/frontend/src/core/reject-history-filters.js +++ b/frontend/src/core/reject-history-filters.js @@ -149,3 +149,53 @@ export function buildRejectCommonQueryParams(filters = {}, { reason = '' } = {}) } return params; } + +export function parseMultiLineInput(text) { + if (!text) return []; + const tokens = String(text) + .split(/[\n,]+/) + .map((s) => s.trim()) + .filter(Boolean) + .map((s) => s.replace(/\*/g, '%')); + const seen = new Set(); + const result = []; + for (const token of tokens) { + if (!seen.has(token)) { + seen.add(token); + result.push(token); + } + } + return result; +} + +export function buildViewParams(queryId, { + supplementaryFilters = {}, + metricFilter = 'all', + trendDates = [], + detailReason = '', + page = 1, + perPage = 50, +} = {}) { + const params = { query_id: queryId }; + if (supplementaryFilters.packages?.length > 0) { + params.packages = supplementaryFilters.packages; + } + if (supplementaryFilters.workcenterGroups?.length > 0) { + params.workcenter_groups = supplementaryFilters.workcenterGroups; + } + if (supplementaryFilters.reason) { + params.reason = supplementaryFilters.reason; + } + if (metricFilter && metricFilter !== 'all') { + params.metric_filter = metricFilter; + } + if (trendDates?.length > 0) { + params.trend_dates = trendDates; + } + if (detailReason) { + params.detail_reason = detailReason; + } + params.page = page || 1; + params.per_page = perPage || 50; + return params; +} diff --git a/frontend/src/reject-history/App.vue b/frontend/src/reject-history/App.vue index c69b26f..da079e3 100644 --- a/frontend/src/reject-history/App.vue +++ b/frontend/src/reject-history/App.vue @@ -1,11 +1,10 @@ @@ -900,16 +824,28 @@ onBeforeUnmount(() => {
更新時間:{{ lastQueryAt }}
- +
{{ errorMessage }}
-
{{ autoPruneHint }}
{ @export-csv="exportCsv" @remove-chip="removeFilterChip" @pareto-scope-toggle="handleParetoScopeToggle" + @update:query-mode="queryMode = $event" + @update:container-input-type="containerInputType = $event" + @update:container-input="containerInput = $event" + @supplementary-change="onSupplementaryChange" /> - + diff --git a/frontend/src/reject-history/components/FilterPanel.vue b/frontend/src/reject-history/components/FilterPanel.vue index 878f339..e5b4e6b 100644 --- a/frontend/src/reject-history/components/FilterPanel.vue +++ b/frontend/src/reject-history/components/FilterPanel.vue @@ -1,14 +1,39 @@