修复:按发货状态读取当前余量
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
from datetime import datetime, time, timedelta
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy import ColumnElement, Select, delete, false, or_, select, update
|
||||
from sqlalchemy import ColumnElement, Select, and_, delete, false, or_, select, update
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy.orm.attributes import InstrumentedAttribute
|
||||
|
||||
from common.vo import PageModel
|
||||
from module_business.domain.enums import DocumentStatus, PalletFlowState
|
||||
from module_business.entity.do.master_do import BizPallet
|
||||
from module_business.entity.do.operation_do import (
|
||||
BizFillingRecord,
|
||||
@@ -656,19 +657,37 @@ class OperationDao:
|
||||
if shipment is None:
|
||||
return None
|
||||
|
||||
item_result = await db.execute(
|
||||
select(BizShipmentItem, BizPalletInventory.remaining_packages)
|
||||
.outerjoin(
|
||||
BizPalletInventory,
|
||||
BizPalletInventory.pallet_id == BizShipmentItem.pallet_id,
|
||||
if shipment.status == DocumentStatus.DRAFT.value:
|
||||
item_result = await db.execute(
|
||||
select(BizShipmentItem, BizPalletInventory.remaining_packages)
|
||||
.outerjoin(
|
||||
BizPalletInventory,
|
||||
and_(
|
||||
BizPalletInventory.pallet_id == BizShipmentItem.pallet_id,
|
||||
BizPalletInventory.warehouse_id == shipment.source_warehouse_id,
|
||||
BizPalletInventory.flow_state == PalletFlowState.FILLED_IN_WAREHOUSE.value,
|
||||
BizPalletInventory.site_id.is_(None),
|
||||
BizPalletInventory.current_line_id.is_(None),
|
||||
BizPalletInventory.active_filling_id.is_not(None),
|
||||
BizPalletInventory.remaining_packages > 0,
|
||||
),
|
||||
)
|
||||
.where(BizShipmentItem.shipment_id == shipment_id)
|
||||
.order_by(BizShipmentItem.shipment_item_id)
|
||||
)
|
||||
.where(BizShipmentItem.shipment_id == shipment_id)
|
||||
.order_by(BizShipmentItem.shipment_item_id)
|
||||
)
|
||||
items = []
|
||||
for item, remaining_packages in item_result.all():
|
||||
item.remaining_packages = remaining_packages
|
||||
items.append(item)
|
||||
items = []
|
||||
for item, remaining_packages in item_result.all():
|
||||
item.remaining_packages = remaining_packages
|
||||
items.append(item)
|
||||
else:
|
||||
item_result = await db.execute(
|
||||
select(BizShipmentItem)
|
||||
.where(BizShipmentItem.shipment_id == shipment_id)
|
||||
.order_by(BizShipmentItem.shipment_item_id)
|
||||
)
|
||||
items = list(item_result.scalars().all())
|
||||
for item in items:
|
||||
item.remaining_packages = None
|
||||
shipment.items = items
|
||||
return shipment
|
||||
|
||||
|
||||
Reference in New Issue
Block a user