From 5d58ac551d0b900b95d9f511fcbf974e2382e347 Mon Sep 17 00:00:00 2001 From: egg Date: Thu, 26 Feb 2026 13:21:31 +0800 Subject: [PATCH] fix(reject-history): WORKORDER bind variable error + move policy filters to in-memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three fixes for the reject history query feature: 1. Fix DPY-4010 bind variable error when querying by WORKORDER — the workflow_lookup CTE had hardcoded :start_date/:end_date which aren't provided in container mode. Replaced with {{ WORKFLOW_FILTER }} template slot that defaults to date-based filter or container-based filter. 2. Move policy toggle filters (material scrap, PB_diode, excluded reasons) from SQL-level to in-memory pandas filtering. Cache now stores unfiltered data so toggling policy filters reuses cached results instantly instead of requiring a ~30s Oracle round-trip per combination. 3. Add per-WORKORDER expansion_info display in FilterPanel for multi-order container resolution diagnostics. Co-Authored-By: Claude Opus 4.6 --- frontend/src/core/reject-history-filters.js | 12 ++ frontend/src/reject-history/App.vue | 10 ++ .../reject-history/components/FilterPanel.vue | 5 + frontend/src/reject-history/style.css | 5 + .../routes/reject_history_routes.py | 14 +++ .../services/reject_dataset_cache.py | 118 ++++++++++++++++-- .../services/reject_history_service.py | 7 ++ .../sql/reject_history/performance_daily.sql | 3 +- .../reject_history/performance_daily_lot.sql | 3 +- 9 files changed, 161 insertions(+), 16 deletions(-) diff --git a/frontend/src/core/reject-history-filters.js b/frontend/src/core/reject-history-filters.js index de7b49f..fcfc45b 100644 --- a/frontend/src/core/reject-history-filters.js +++ b/frontend/src/core/reject-history-filters.js @@ -175,6 +175,7 @@ export function buildViewParams(queryId, { detailReason = '', page = 1, perPage = 50, + policyFilters = {}, } = {}) { const params = { query_id: queryId }; if (supplementaryFilters.packages?.length > 0) { @@ -197,5 +198,16 @@ export function buildViewParams(queryId, { } params.page = page || 1; params.per_page = perPage || 50; + + // Policy filters (applied in-memory on cached data) + if (policyFilters.includeExcludedScrap) { + params.include_excluded_scrap = 'true'; + } + if (policyFilters.excludeMaterialScrap === false) { + params.exclude_material_scrap = 'false'; + } + if (policyFilters.excludePbDiode === false) { + params.exclude_pb_diode = 'false'; + } return params; } diff --git a/frontend/src/reject-history/App.vue b/frontend/src/reject-history/App.vue index f888155..1747479 100644 --- a/frontend/src/reject-history/App.vue +++ b/frontend/src/reject-history/App.vue @@ -242,6 +242,11 @@ async function refreshView() { detailReason: detailReason.value, page: page.value, perPage: DEFAULT_PER_PAGE, + policyFilters: { + includeExcludedScrap: committedPrimary.includeExcludedScrap, + excludeMaterialScrap: committedPrimary.excludeMaterialScrap, + excludePbDiode: committedPrimary.excludePbDiode, + }, }); const resp = await apiGet('/api/reject-history/view', { @@ -468,6 +473,11 @@ async function exportCsv() { for (const date of selectedTrendDates.value) params.append('trend_dates', date); if (detailReason.value) params.set('detail_reason', detailReason.value); + // Policy filters (applied in-memory on cached data) + if (committedPrimary.includeExcludedScrap) params.set('include_excluded_scrap', 'true'); + if (!committedPrimary.excludeMaterialScrap) params.set('exclude_material_scrap', 'false'); + if (!committedPrimary.excludePbDiode) params.set('exclude_pb_diode', 'false'); + const response = await fetch(`/api/reject-history/export-cached?${params.toString()}`); if (response.status === 410) { diff --git a/frontend/src/reject-history/components/FilterPanel.vue b/frontend/src/reject-history/components/FilterPanel.vue index e5b4e6b..7b188c6 100644 --- a/frontend/src/reject-history/components/FilterPanel.vue +++ b/frontend/src/reject-history/components/FilterPanel.vue @@ -173,6 +173,11 @@ function emitSupplementary(patch) { class="card-body resolution-info" > 已解析 {{ resolutionInfo.resolved_count }} 筆容器 +