temp_qc_target.py 845 B

12345678910111213141516171819202122
  1. """临时质检对象:系统产品 / 外部编号互斥归一化。"""
  2. from typing import Optional, Tuple
  3. def resolve_temp_qc_target(
  4. *,
  5. cell_product_id: Optional[str] = None,
  6. external_target_code: Optional[str] = None,
  7. ) -> Tuple[Optional[str], Optional[str]]:
  8. """临时质检对象互斥归一化。返回 (cell_product_id|None, external_target_code|None)。"""
  9. cp = (cell_product_id or "").strip() or None
  10. ext = (external_target_code or "").strip() or None
  11. if cp and ext:
  12. raise ValueError("质检对象不能同时选择系统产品并填写外部编号")
  13. if not cp and not ext:
  14. raise ValueError("请选择质检对象或填写外部编号")
  15. if ext and len(ext) > 64:
  16. raise ValueError("外部编号最长 64 个字符")
  17. if ext:
  18. return None, ext
  19. return cp, None