From 4df471add2b0d64bc853b577450a3f77585b3885 Mon Sep 17 00:00:00 2001 From: DXC Date: Wed, 8 Apr 2026 17:45:29 +0800 Subject: [PATCH] fix(inbound): correct date attributes for StockProduct and StockSemi in history location query --- inventory-backend/app/services/inbound/buy_service.py | 8 ++++---- inventory-backend/app/services/inbound/product_service.py | 8 ++++---- inventory-backend/app/services/inbound/semi_service.py | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/inventory-backend/app/services/inbound/buy_service.py b/inventory-backend/app/services/inbound/buy_service.py index 4d89de5..052db7e 100644 --- a/inventory-backend/app/services/inbound/buy_service.py +++ b/inventory-backend/app/services/inbound/buy_service.py @@ -543,21 +543,21 @@ class BuyInboundService: # 2. 查询成品入库最新记录 last_product = StockProduct.query.filter( StockProduct.base_id == base_id - ).order_by(StockProduct.in_date.desc()).first() + ).order_by(StockProduct.production_date.desc()).first() # 3. 查询半成品入库最新记录 last_semi = StockSemi.query.filter( StockSemi.base_id == base_id - ).order_by(StockSemi.in_date.desc()).first() + ).order_by(StockSemi.production_date.desc()).first() # 比较三个表中的最新入库时间,返回最新的库位 candidates = [] if last_buy and last_buy.warehouse_location: candidates.append((last_buy.in_date, last_buy.warehouse_location)) if last_product and last_product.warehouse_location: - candidates.append((last_product.in_date, last_product.warehouse_location)) + candidates.append((last_product.production_date, last_product.warehouse_location)) if last_semi and last_semi.warehouse_location: - candidates.append((last_semi.in_date, last_semi.warehouse_location)) + candidates.append((last_semi.production_date, last_semi.warehouse_location)) if not candidates: return "" diff --git a/inventory-backend/app/services/inbound/product_service.py b/inventory-backend/app/services/inbound/product_service.py index 0dce41f..0e5b615 100644 --- a/inventory-backend/app/services/inbound/product_service.py +++ b/inventory-backend/app/services/inbound/product_service.py @@ -590,7 +590,7 @@ class ProductInboundService: # 1. 查询成品入库最新记录 last_product = StockProduct.query.filter( StockProduct.base_id == base_id - ).order_by(StockProduct.in_date.desc()).first() + ).order_by(StockProduct.production_date.desc()).first() # 2. 查询采购入库最新记录 last_buy = StockBuy.query.filter( @@ -600,16 +600,16 @@ class ProductInboundService: # 3. 查询半成品入库最新记录 last_semi = StockSemi.query.filter( StockSemi.base_id == base_id - ).order_by(StockSemi.in_date.desc()).first() + ).order_by(StockSemi.production_date.desc()).first() # 比较三个表中的最新入库时间,返回最新的库位 candidates = [] if last_product and last_product.warehouse_location: - candidates.append((last_product.in_date, last_product.warehouse_location)) + candidates.append((last_product.production_date, last_product.warehouse_location)) if last_buy and last_buy.warehouse_location: candidates.append((last_buy.in_date, last_buy.warehouse_location)) if last_semi and last_semi.warehouse_location: - candidates.append((last_semi.in_date, last_semi.warehouse_location)) + candidates.append((last_semi.production_date, last_semi.warehouse_location)) if not candidates: return "" diff --git a/inventory-backend/app/services/inbound/semi_service.py b/inventory-backend/app/services/inbound/semi_service.py index fd81c79..0b4c887 100644 --- a/inventory-backend/app/services/inbound/semi_service.py +++ b/inventory-backend/app/services/inbound/semi_service.py @@ -667,7 +667,7 @@ class SemiInboundService: # 1. 查询半成品入库最新记录 last_semi = StockSemi.query.filter( StockSemi.base_id == base_id - ).order_by(StockSemi.in_date.desc()).first() + ).order_by(StockSemi.production_date.desc()).first() # 2. 查询采购入库最新记录 last_buy = StockBuy.query.filter( @@ -677,16 +677,16 @@ class SemiInboundService: # 3. 查询成品入库最新记录 last_product = StockProduct.query.filter( StockProduct.base_id == base_id - ).order_by(StockProduct.in_date.desc()).first() + ).order_by(StockProduct.production_date.desc()).first() # 比较三个表中的最新入库时间,返回最新的库位 candidates = [] if last_semi and last_semi.warehouse_location: - candidates.append((last_semi.in_date, last_semi.warehouse_location)) + candidates.append((last_semi.production_date, last_semi.warehouse_location)) if last_buy and last_buy.warehouse_location: candidates.append((last_buy.in_date, last_buy.warehouse_location)) if last_product and last_product.warehouse_location: - candidates.append((last_product.in_date, last_product.warehouse_location)) + candidates.append((last_product.production_date, last_product.warehouse_location)) if not candidates: return ""