fix(inbound): correct date attributes for StockProduct and StockSemi in history location query
This commit is contained in:
@ -543,21 +543,21 @@ class BuyInboundService:
|
|||||||
# 2. 查询成品入库最新记录
|
# 2. 查询成品入库最新记录
|
||||||
last_product = StockProduct.query.filter(
|
last_product = StockProduct.query.filter(
|
||||||
StockProduct.base_id == base_id
|
StockProduct.base_id == base_id
|
||||||
).order_by(StockProduct.in_date.desc()).first()
|
).order_by(StockProduct.production_date.desc()).first()
|
||||||
|
|
||||||
# 3. 查询半成品入库最新记录
|
# 3. 查询半成品入库最新记录
|
||||||
last_semi = StockSemi.query.filter(
|
last_semi = StockSemi.query.filter(
|
||||||
StockSemi.base_id == base_id
|
StockSemi.base_id == base_id
|
||||||
).order_by(StockSemi.in_date.desc()).first()
|
).order_by(StockSemi.production_date.desc()).first()
|
||||||
|
|
||||||
# 比较三个表中的最新入库时间,返回最新的库位
|
# 比较三个表中的最新入库时间,返回最新的库位
|
||||||
candidates = []
|
candidates = []
|
||||||
if last_buy and last_buy.warehouse_location:
|
if last_buy and last_buy.warehouse_location:
|
||||||
candidates.append((last_buy.in_date, last_buy.warehouse_location))
|
candidates.append((last_buy.in_date, last_buy.warehouse_location))
|
||||||
if last_product and last_product.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:
|
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:
|
if not candidates:
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
@ -590,7 +590,7 @@ class ProductInboundService:
|
|||||||
# 1. 查询成品入库最新记录
|
# 1. 查询成品入库最新记录
|
||||||
last_product = StockProduct.query.filter(
|
last_product = StockProduct.query.filter(
|
||||||
StockProduct.base_id == base_id
|
StockProduct.base_id == base_id
|
||||||
).order_by(StockProduct.in_date.desc()).first()
|
).order_by(StockProduct.production_date.desc()).first()
|
||||||
|
|
||||||
# 2. 查询采购入库最新记录
|
# 2. 查询采购入库最新记录
|
||||||
last_buy = StockBuy.query.filter(
|
last_buy = StockBuy.query.filter(
|
||||||
@ -600,16 +600,16 @@ class ProductInboundService:
|
|||||||
# 3. 查询半成品入库最新记录
|
# 3. 查询半成品入库最新记录
|
||||||
last_semi = StockSemi.query.filter(
|
last_semi = StockSemi.query.filter(
|
||||||
StockSemi.base_id == base_id
|
StockSemi.base_id == base_id
|
||||||
).order_by(StockSemi.in_date.desc()).first()
|
).order_by(StockSemi.production_date.desc()).first()
|
||||||
|
|
||||||
# 比较三个表中的最新入库时间,返回最新的库位
|
# 比较三个表中的最新入库时间,返回最新的库位
|
||||||
candidates = []
|
candidates = []
|
||||||
if last_product and last_product.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_buy and last_buy.warehouse_location:
|
if last_buy and last_buy.warehouse_location:
|
||||||
candidates.append((last_buy.in_date, last_buy.warehouse_location))
|
candidates.append((last_buy.in_date, last_buy.warehouse_location))
|
||||||
if last_semi and last_semi.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:
|
if not candidates:
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
@ -667,7 +667,7 @@ class SemiInboundService:
|
|||||||
# 1. 查询半成品入库最新记录
|
# 1. 查询半成品入库最新记录
|
||||||
last_semi = StockSemi.query.filter(
|
last_semi = StockSemi.query.filter(
|
||||||
StockSemi.base_id == base_id
|
StockSemi.base_id == base_id
|
||||||
).order_by(StockSemi.in_date.desc()).first()
|
).order_by(StockSemi.production_date.desc()).first()
|
||||||
|
|
||||||
# 2. 查询采购入库最新记录
|
# 2. 查询采购入库最新记录
|
||||||
last_buy = StockBuy.query.filter(
|
last_buy = StockBuy.query.filter(
|
||||||
@ -677,16 +677,16 @@ class SemiInboundService:
|
|||||||
# 3. 查询成品入库最新记录
|
# 3. 查询成品入库最新记录
|
||||||
last_product = StockProduct.query.filter(
|
last_product = StockProduct.query.filter(
|
||||||
StockProduct.base_id == base_id
|
StockProduct.base_id == base_id
|
||||||
).order_by(StockProduct.in_date.desc()).first()
|
).order_by(StockProduct.production_date.desc()).first()
|
||||||
|
|
||||||
# 比较三个表中的最新入库时间,返回最新的库位
|
# 比较三个表中的最新入库时间,返回最新的库位
|
||||||
candidates = []
|
candidates = []
|
||||||
if last_semi and last_semi.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 last_buy and last_buy.warehouse_location:
|
if last_buy and last_buy.warehouse_location:
|
||||||
candidates.append((last_buy.in_date, last_buy.warehouse_location))
|
candidates.append((last_buy.in_date, last_buy.warehouse_location))
|
||||||
if last_product and last_product.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:
|
if not candidates:
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
Reference in New Issue
Block a user