Files
zkxw/backend/app/services/qc_work_order_conclusion.py
T
zlwuandCursor a3af039e74 feat: 质检工单结论、库位批量/筛选与协议样本接收质检摘要
落库并展示质检工单级结论(可编辑/任务派生),库位树支持批量新增子节点与货架格子检索,协议/捐赠列表补充接收与门禁质检摘要,并同步生产物料与工单卡片展示优化。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-28 18:46:24 +08:00

37 lines
1.1 KiB
Python

"""质检工单级结论:由下属任务 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),
}