| 123456789101112131415161718192021222324252627282930313233343536 |
- """质检工单级结论:由下属任务 conclusion 派生(合格/不合格)。"""
- from __future__ import annotations
- from typing import Any, Dict, Iterable, List, Optional
- _WORK_ORDER_QC_CONCLUSION_LABELS = {
- "tg": "合格",
- "btg": "不合格",
- }
- def derive_work_order_qc_conclusion(task_conclusions: Iterable[Optional[str]]) -> str:
- """与短信模块规则一致:任一 btg → btg;全部 tg → tg;否则空。"""
- conclusions = [(c or "").strip() for c in task_conclusions]
- if not conclusions:
- return ""
- if any(c == "btg" for c in conclusions):
- return "btg"
- if all(c == "tg" for c in conclusions):
- return "tg"
- return ""
- def work_order_qc_conclusion_label(code: Optional[str]) -> str:
- return _WORK_ORDER_QC_CONCLUSION_LABELS.get((code or "").strip(), "")
- def build_qc_conclusion_fields(
- task_conclusions: Iterable[Optional[str]],
- ) -> Dict[str, str]:
- code = derive_work_order_qc_conclusion(task_conclusions)
- return {
- "qcConclusion": code,
- "qcConclusionLabel": work_order_qc_conclusion_label(code),
- }
|