This commit is contained in:
zlwu committed 2026-06-21 12:41:39 +08:00
1 parent 299609706c
commit e46c0480d4
87 files changed
+11975 -15543

No files matched your search

+1 -10
View File
@@ -7,9 +7,8 @@ from app.core.utils import format_datetime
# 三方预生成出入库单「日期未填」占位(原系统 date="",DDL 为 NOT NULL DATE)
EMPTY_INVENTORY_DATE = date(1970, 1, 1)
from app.models.db_models import DbInboundOutbound, DbPurchasePlan, DbVehicle, DbWeighingSlip
from app.models.db_models import DbInboundOutbound, DbPurchasePlan, DbWeighingSlip
from app.schemas.db.inventory import InboundOutboundRead
from app.schemas.db.master_data import VehicleRead
from app.schemas.db.plans import PurchasePlanRead, PurchasePlanWithFillLink
from app.schemas.db.weighing import WeighingSlipRead
@@ -32,14 +31,6 @@ def fmt_datetime(value: datetime | str | None) -> str | None:
return str(value)
def vehicle_to_read(row: DbVehicle) -> VehicleRead:
return VehicleRead(
id=row.id,
vehicleNo=row.vehicle_no,
remarks=row.remark,
)
def plan_to_read(row: DbPurchasePlan, *, executed_quantity: float | None = None) -> PurchasePlanRead:
return PurchasePlanRead(
id=row.id,
@@ -11,7 +11,7 @@ from typing import Optional
from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.models.db_models import DbInboundOutbound, DbPurchasePlan, DbVehicle, DbWeighingSlip
from app.models.db_models import DbInboundOutbound, DbPurchasePlan, DbWeighingSlip
from app.models.pl_models import PlPlan, PlPlanProduct, PlTransport, PlTransportDbLink
from app.services.db.inventory_id import next_inbound_outbound_id
from app.services.db.mappers import parse_date_str
@@ -83,32 +83,6 @@ def _generate_batch_no(db: Session, tenant_no: str) -> str:
return f"CRKDH{max_seq + 1:07d}"
def _ensure_vehicle_exists(db: Session, tenant_no: str, vehicle_no: str) -> None:
vehicle_no = (vehicle_no or "").strip()
if not vehicle_no:
return
exists = (
db.query(DbVehicle.id)
.filter(
DbVehicle.tenant_no == tenant_no,
DbVehicle.del_flag == 0,
DbVehicle.vehicle_no == vehicle_no,
)
.first()
)
if exists:
return
db.add(
DbVehicle(
id=generate_uuid(),
tenant_no=tenant_no,
vehicle_no=vehicle_no,
remark="",
)
)
db.flush()
def find_monthly_db_plan(
db: Session,
tenant_no: str,
@@ -191,9 +165,6 @@ def _create_db_inventory(
user_id: Optional[str],
dept_id: str,
) -> DbInboundOutbound:
if license_plate:
_ensure_vehicle_exists(db, tenant_no, license_plate)
snapshot = resolve_crm_product(db, tenant_no, product.product_id)
status_value = "待入库" if business_type == "入库" else "待出库"
inventory = DbInboundOutbound(