From 70149fc7c02a9502985d4a42d32f2f8ae1901df7 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 27 Oct 2026 21:33:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=85=A5=E5=BA=93=E5=88=97=E8=A1=A8):=20?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E9=9C=80=E5=8A=A0=E5=B7=A5=E6=A0=87=E8=AE=B0?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 前端徽标/筛选已存在;后端补订单行加工方式/归属与未完工加工需求单判定,返回 needs_processing/processing_method。只读展示,不改入库门槛。 --- server/src/services/inspectionQueryService.ts | 19 +++++++++++++- .../inspectionListNeedsProcessing.test.ts | 25 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 server/tests/inspectionListNeedsProcessing.test.ts diff --git a/server/src/services/inspectionQueryService.ts b/server/src/services/inspectionQueryService.ts index 78ca41b..b6bd0c6 100644 --- a/server/src/services/inspectionQueryService.ts +++ b/server/src/services/inspectionQueryService.ts @@ -194,7 +194,9 @@ export async function listInspectionsForManagement( LEFT JOIN skus sk ON sk.sku_code = i.sku_code LEFT JOIN suppliers sup ON sup.supplier_code = i.supplier_code LEFT JOIN LATERAL ( - SELECT oi2.item_name, oi2.category_code, oi2.unit, oi2.category_name + SELECT oi2.item_name, oi2.category_code, oi2.unit, oi2.category_name, + oi2.processing_method AS line_processing_method, + oi2.processing_owner AS line_processing_owner FROM order_items oi2 WHERE oi2.order_code = i.order_code AND (oi2.sku_code = i.sku_code OR i.sku_code IS NULL) @@ -308,6 +310,19 @@ export async function listInspectionsForManagement( demand_sheet.demand_material_qty, demand_sheet.demand_net_weight, demand_sheet.demand_loss_qty, + -- 入库列表「需加工」:订单行是仓内加工,或该订单+商品存在未完工加工需求单。 + -- 前端 InspectionManagement 已有徽标/筛选,缺的只是后端这个只读字段。 + (CASE + WHEN LOWER(TRIM(COALESCE(oi.line_processing_owner, ''))) IN + ('warehouse', 'warehouse_processing', '仓内加工') + AND COALESCE(NULLIF(TRIM(oi.line_processing_method), ''), '原材料') <> '原材料' + THEN TRUE + WHEN demand_sheet.demand_material_qty IS NOT NULL + OR demand_sheet.demand_net_weight IS NOT NULL + THEN TRUE + ELSE FALSE + END) AS needs_processing, + oi.line_processing_method AS processing_method, ${LAST_INBOUND_ZONE_SELECT}, ${inboundPriceSql} AS inbound_unit_price ${listFromSql} @@ -330,6 +345,8 @@ export async function listInspectionsForManagement( demand_material_qty: row.demand_material_qty == null ? null : Number(row.demand_material_qty), demand_net_weight: row.demand_net_weight == null ? null : Number(row.demand_net_weight), demand_loss_qty: row.demand_loss_qty == null ? null : Number(row.demand_loss_qty), + needs_processing: row.needs_processing === true, + processing_method: row.processing_method || null, })); return { diff --git a/server/tests/inspectionListNeedsProcessing.test.ts b/server/tests/inspectionListNeedsProcessing.test.ts new file mode 100644 index 0000000..13d1f8b --- /dev/null +++ b/server/tests/inspectionListNeedsProcessing.test.ts @@ -0,0 +1,25 @@ +import { readFileSync } from 'node:fs'; +import { describe, expect, it } from 'vitest'; + +const service = readFileSync(new URL('../src/services/inspectionQueryService.ts', import.meta.url), 'utf8'); +const page = readFileSync(new URL('../../src/pages/inspection/InspectionManagement.tsx', import.meta.url), 'utf8'); + +describe('入库列表「需加工」徽标字段', () => { + it('后端 LATERAL 取订单行加工字段并返回 needs_processing', () => { + expect(service).toContain('oi2.processing_method AS line_processing_method'); + expect(service).toContain('oi2.processing_owner AS line_processing_owner'); + expect(service).toContain('AS needs_processing'); + expect(service).toContain('AS processing_method'); + expect(service).toContain("LOWER(TRIM(COALESCE(oi.line_processing_owner, ''))) IN"); + expect(service).toContain('demand_sheet.demand_material_qty IS NOT NULL'); + expect(service).toContain('demand_sheet.demand_net_weight IS NOT NULL'); + expect(service).toContain('needs_processing: row.needs_processing === true'); + }); + + it('前端徽标、筛选与三语文案已存在', () => { + expect(page).toContain('needs_processing: Boolean(item.needs_processing)'); + expect(page).toContain('task.needs_processing'); + expect(page).toContain("t('inspection.needProcess')"); + expect(page).toContain("processingFilter === 'needs'"); + }); +});