diff --git a/inventory-backend/app/services/inbound/buy_service.py b/inventory-backend/app/services/inbound/buy_service.py index b4b3654..11fbe5e 100644 --- a/inventory-backend/app/services/inbound/buy_service.py +++ b/inventory-backend/app/services/inbound/buy_service.py @@ -100,6 +100,12 @@ class BuyInboundService: if not material: raise ValueError("所选物料不存在") if not material.is_enabled: raise ValueError(f"物料【{material.name}】已停用") + # ============================================================ + # 物料类别隔离校验:采购入库禁止"半成品"/"成品" + # ============================================================ + if material.category and ("半成品" in material.category or "成品" in material.category): + raise ValueError(f"物料【{material.name}】类别为【{material.category}】,禁止作为采购件入库!") + # ============================================================ # 强制质检校验:如果物料标记为强制质检,则必须提供到检状态和检测报告 # ============================================================ diff --git a/inventory-backend/app/services/inbound/product_service.py b/inventory-backend/app/services/inbound/product_service.py index ac47faf..a073448 100644 --- a/inventory-backend/app/services/inbound/product_service.py +++ b/inventory-backend/app/services/inbound/product_service.py @@ -115,6 +115,12 @@ class ProductInboundService: if not material.is_enabled: raise ValueError(f"物料【{material.name}】已停用,无法办理新入库。") + # ============================================================ + # 物料类别隔离校验:成品入库必须为"成品"类目 + # ============================================================ + if not material.category or "成品" not in material.category: + raise ValueError(f"物料【{material.name}】类别为【{material.category or '空'}】,非成品,无法办理成品入库!") + ProductInboundService._check_unique( serial_number=data.get('serial_number') ) diff --git a/inventory-backend/app/services/inbound/semi_service.py b/inventory-backend/app/services/inbound/semi_service.py index 1a6dc6b..c4e1b79 100644 --- a/inventory-backend/app/services/inbound/semi_service.py +++ b/inventory-backend/app/services/inbound/semi_service.py @@ -122,6 +122,12 @@ class SemiInboundService: if not material.is_enabled: raise ValueError(f"物料【{material.name}】已停用,无法办理新入库。") + # ============================================================ + # 物料类别隔离校验:半成品入库必须为"半成品"类目 + # ============================================================ + if not material.category or "半成品" not in material.category: + raise ValueError(f"物料【{material.name}】类别为【{material.category or '空'}】,非半成品,无法办理半成品入库!") + SemiInboundService._check_unique( base_id=base_id, serial_number=data.get('serial_number'),