Files
syops/docs/features/shipping-notice/order-extraction-workflow-dify-guide.md
T

28 KiB
Raw Blame History

订单抽取服务 Dify Workflow 配置手册

适用范围:HXOPS 货代订单抽取内部 Workflow。本文是当前唯一有效的 Dify 画布契约。

1. 边界与运行模型

HXOPS Worker 每次调用 Workflow 时,只传入一个冻结的抽取单元(Unit):一个 Intake 下的一份邮件正文或一份附件。Dify 只读取该 Unit、按冻结 Schema 提取字段并返回 orders;不负责合并附件、创建 Candidate/Task、判重、库存、RPA、Excel 或重试。

HXOPS Run / Plan
  -> 一个 Unit(一个 Document)
  -> Dify Workflow(无状态)
  -> 当前 Unit 的 orders
  -> HXOPS 校验、跨文档保守合并、Candidate/Task 门禁

不要在 Dify 中增加循环、并行、延迟重试、跨附件拼接、HTTP 建单或数据库读取。HXOPS 已负责 Unit 并发、局部重试、Provider 限流、熔断和跨文档合并。

2. 画布拓扑

Start
  -> Code: parse_and_prepare_input
  -> LLM: extract_orders
  -> Code: validate_and_normalize_orders
  -> If/Else: check_validation
       true  -> End: workflow_end
       false -> Code: raise_validation_error -> Workflow Failed

End 只能输出 orders。失败分支必须抛出异常,不能将校验错误伪装为成功的空订单。

3. Start 节点

仅配置一个必填 String 输入:

变量名 必填 说明
execution_manifest 是 HXOPS Worker 发送的冻结 JSON 字符串

不得添加 documents、unit_id、用户 ID、Provider ID、API Key 或其他顶层输入。

输入示例(仅用于理解,实际由 HXOPS 生成):

{
  "contract_version": "shipping_order_extraction.unit.v2",
  "run": {"run_no": "SNER-..."},
  "unit": {
    "unit_id": 123,
    "unit_type": "document_extraction",
    "intake_id": 456,
    "intake_no": "SNI-...",
    "document_id": 789,
    "document_type": "attachment"
  },
  "integrity": {"input_snapshot_hash": "..."},
  "extraction_contract": {"schema_version_id": 14, "checksum": "...", "fields": []},
  "documents": [
    {
      "intake_id": 456,
      "intake_no": "SNI-...",
      "document": {"document_id": 789, "extracted_text": "..."}
    }
  ],
  "readonly_hints": []
}

documents 必须恰好有一项,实际文档位于 documents[0].document。同次调用不存在其他附件或兄弟 Document。

4. Code 节点:parse_and_prepare_input

输入:execution_manifest = Start.execution_manifest。

输出变量及类型:

变量名 类型
run_no String
unit_id Number
unit_type String
source_intake_no String
primary_document_id Number
schema_contract_json String
document_json String
readonly_context_json String
header_field_ids_json String
line_field_ids_json String

将节点代码整体替换为:

import json


def _parse_json(value, name):
    if isinstance(value, (dict, list)):
        return value
    text = str(value or "").strip()
    if not text:
        raise ValueError(f"{name} is required")
    try:
        return json.loads(text)
    except json.JSONDecodeError as exc:
        raise ValueError(f"{name} must be valid JSON: {exc.msg}") from exc


def _object(value, name):
    if not isinstance(value, dict):
        raise ValueError(f"{name} must be an object")
    return value


def _array(value, name):
    if not isinstance(value, list):
        raise ValueError(f"{name} must be an array")
    return value


def _as_int(value, name):
    try:
        return int(value)
    except (TypeError, ValueError) as exc:
        raise ValueError(f"{name} must be an integer") from exc


def main(execution_manifest: str):
    manifest = _object(_parse_json(execution_manifest, "execution_manifest"), "execution_manifest")
    if manifest.get("contract_version") != "shipping_order_extraction.unit.v2":
        raise ValueError("unsupported execution_manifest.contract_version")

    run = _object(manifest.get("run"), "execution_manifest.run")
    unit = _object(manifest.get("unit"), "execution_manifest.unit")
    integrity = _object(manifest.get("integrity"), "execution_manifest.integrity")
    schema = _object(manifest.get("extraction_contract"), "execution_manifest.extraction_contract")
    wrappers = _array(manifest.get("documents"), "execution_manifest.documents")
    readonly_hints = _array(manifest.get("readonly_hints"), "execution_manifest.readonly_hints")

    if len(wrappers) != 1:
        raise ValueError("unit.v2 requires exactly one document wrapper")
    wrapper = _object(wrappers[0], "execution_manifest.documents[0]")
    document = _object(wrapper.get("document"), "execution_manifest.documents[0].document")

    run_no = str(run.get("run_no") or "").strip()
    unit_id = _as_int(unit.get("unit_id"), "unit.unit_id")
    intake_no = str(unit.get("intake_no") or "").strip().upper()
    document_id = _as_int(unit.get("document_id"), "unit.document_id")
    wrapper_intake_no = str(wrapper.get("intake_no") or "").strip().upper()
    wrapped_document_id = _as_int(document.get("document_id"), "document.document_id")
    checksum = str(schema.get("checksum") or "").strip()
    fields = schema.get("fields")

    if not run_no or not intake_no or not checksum or not isinstance(fields, list):
        raise ValueError("manifest is missing required run, unit, or schema values")
    if wrapper_intake_no != intake_no:
        raise ValueError("documents[0].intake_no must equal unit.intake_no")
    if wrapped_document_id != document_id:
        raise ValueError("documents[0].document.document_id must equal unit.document_id")
    if not str(integrity.get("input_snapshot_hash") or "").strip():
        raise ValueError("integrity.input_snapshot_hash is required")

    header_ids = []
    line_ids = []
    for index, field in enumerate(fields):
        if not isinstance(field, dict):
            raise ValueError(f"schema field {index} must be an object")
        field_id = str(field.get("field_id") or "").strip()
        if not field_id:
            raise ValueError(f"schema field {index} has no field_id")
        if field.get("collection_mode", "llm_extraction") != "llm_extraction":
            continue
        scope = str(field.get("scope") or "").strip().lower()
        if scope == "header":
            header_ids.append(field_id)
        elif scope == "line":
            line_ids.append(field_id)
        else:
            raise ValueError(f"schema field {field_id} has invalid scope")

    model_schema = {
        "schema_version_id": schema.get("schema_version_id"),
        "schema_version": schema.get("schema_version"),
        "checksum": checksum,
        "fields": fields,
        "submission_contract": schema.get("submission_contract", {}),
    }
    model_document = {
        "document_id": document_id,
        "intake_no": intake_no,
        "filename": str(document.get("filename") or ""),
        "document_type": str(document.get("document_type") or unit.get("document_type") or ""),
        "classification": str(document.get("classification") or ""),
        "extracted_text": str(document.get("extracted_text") or ""),
    }
    return {
        "run_no": run_no,
        "unit_id": unit_id,
        "unit_type": str(unit.get("unit_type") or ""),
        "source_intake_no": intake_no,
        "primary_document_id": document_id,
        "schema_contract_json": json.dumps(model_schema, ensure_ascii=False, separators=(",", ":")),
        "document_json": json.dumps(model_document, ensure_ascii=False, separators=(",", ":")),
        "readonly_context_json": json.dumps(readonly_hints, ensure_ascii=False, separators=(",", ":")),
        "header_field_ids_json": json.dumps(sorted(set(header_ids)), ensure_ascii=False, separators=(",", ":")),
        "line_field_ids_json": json.dumps(sorted(set(line_ids)), ensure_ascii=False, separators=(",", ":")),
    }

5. LLM 节点:extract_orders

建议参数:Temperature 0,Top P 0.1,Streaming/Memory/Conversation History 全部关闭;支持时启用 JSON Object 响应格式。Reasoning 不得接入正文或输出。

输入变量:run_no、unit_id、source_intake_no、primary_document_id、schema_contract_json、document_json、readonly_context_json、header_field_ids_json、line_field_ids_json,均来自 parse_and_prepare_input。

System Prompt

你是 HXOPS 货运订单抽取 Workflow 的结构化识别节点。

本次调用只处理一个 Unit 和一个 Document。你的唯一任务是:读取 document_json 中的当前文档,按 schema_contract_json.fields[] 提取可被原文证明的订单字段,并只返回严格 JSON Object。

你只能读取当前 document_json。不得假设存在邮件正文、其他附件、兄弟 Document 或外部数据;不得跨文档合并、补全、判重、建单、调用工具、查询数据库或读取外部文件。

固定来源约束:每一条订单的 source_intake_no 必须逐字等于输入 source_intake_no;primary_document_id 必须逐字等于输入 primary_document_id;每个 Observation.document_id 也必须逐字等于输入 primary_document_id。违反任一约束即为无效输出。

仅可使用 schema_contract_json.fields[] 中 collection_mode=llm_extraction 的 stable field_id。Header 字段仅能使用 header_field_ids_json;明细字段仅能使用 line_field_ids_json。不要用 field_code、显示名称或自然语言字段名代替 field_id。

字段没有可信逐字证据时,直接省略该字段;不要输出空 observations、null、默认值、猜测值或模型解释。每个返回的 Observation 必须有 value、document_id、quote 和 0 到 1 的 confidence;quote 必须是当前 document_json.extracted_text 中能直接证明 value 的原文片段。

必须严格匹配 schema 中每个 field_id 的 value_type:decimal/integer 必须返回 JSON 数字;boolean 必须返回 JSON 布尔值;date 的 value 必须为 `YYYY-MM-DD`。例如原文 `06/22/2026` 的 date value 必须输出 `2026-06-22`,但 quote 仍保留原文 `06/22/2026`。不符合类型或无法规范化时省略字段,不得原样输出非 ISO 日期。

高风险行字段不得按位置或猜测映射:`line_no` 只能是订单行号(如 `00010`);`part_number` 是 HXOPS 内部料号,通常来自明确的 MPN、Supplier Part Number、Vendor Part Number 等供应商/制造商语义;`customer_part_number` 通常来自客户订单中的 `Material`、`Material No`、`Material Number`;`reservation_id` 只能是原文明确标注的 Reservation ID;`inventory_source_hint` 只能是明确库存源/仓库提示,绝不能填行号;`aws_part_number` 只能来自明确标注的 AWS SKU、AWS Part Number、APN 或同等 AWS 语义。若邮件正文或任一附件已有明确 AWS 料号,必须优先使用该证据,不能用 Material 覆盖。不得以料号、行号、描述、金额或数量互相替代。已发布的精确模板 Profile 可以覆盖裸表头的通常语义;例如确认模板中的 `Part Number -> customer_part_number`、`Vendor Item# -> part_number` 是合法契约,Dify 不得重新改写。

Reservation ID、料号、数量、金额、日期等不得根据常识、计算结果、文件名或其他字段反推。readonly_context_json 仅作提示,不得写入 header_fields、lines、conflicts 或输出。

classification 只能是 shipping_request、non_shipping_request 或 uncertain,classification_confidence 必须是 0 到 1 的数字。一个单文档可以有零条、一条或多条独立订单;不得和不存在的 Document 合并。

最终只输出一个 JSON Object,首字符必须是 {,末字符必须是 }。禁止输出 think、analysis、reasoning、XML/HTML、Markdown、代码围栏、自然语言、日志、Provider 信息或内部配置。

输出格式:
{"orders":[{"schema_version_id":123,"schema_checksum":"schema checksum","classification":"shipping_request","classification_confidence":0.98,"source_intake_no":"输入原值","primary_document_id":456,"header_fields":[{"field_id":"...","observations":[{"value":"...","document_id":456,"quote":"原文","confidence":0.98}]}],"lines":[{"fields":[]}],"conflicts":[]}]}

若没有识别出订单,返回 {"orders":[]}。

User Prompt

请只识别当前 Unit 的当前文档,不要读取或推测其他文档。

run_no:
{{#parse_and_prepare_input.run_no#}}

unit_id:
{{#parse_and_prepare_input.unit_id#}}

source_intake_no(所有订单必须原样写回):
{{#parse_and_prepare_input.source_intake_no#}}

primary_document_id(所有订单和 Observation 必须原样写回):
{{#parse_and_prepare_input.primary_document_id#}}

schema_contract_json:
{{#parse_and_prepare_input.schema_contract_json#}}

document_json:
{{#parse_and_prepare_input.document_json#}}

readonly_context_json:
{{#parse_and_prepare_input.readonly_context_json#}}

header_field_ids_json:
{{#parse_and_prepare_input.header_field_ids_json#}}

line_field_ids_json:
{{#parse_and_prepare_input.line_field_ids_json#}}

只返回 {"orders": [...]} 或 {"orders":[]},不要输出任何其他文字。

6. Code 节点:validate_and_normalize_orders

输入:

变量 来源
llm_output extract_orders.text
schema_contract_json parse_and_prepare_input.schema_contract_json
source_intake_no parse_and_prepare_input.source_intake_no
primary_document_id parse_and_prepare_input.primary_document_id

输出:orders(String)、order_count(Number)、validation_ok(Boolean)、validation_error(String)。

extract_orders.text 在不同 Dify 版本或模型连接器中可能是 JSON Object、JSON 字符串,或被额外 JSON 编码一次的字符串。验证节点最多解包两层;最终不是含 orders 数组的 JSON Object 时必须失败。此兼容仅处理序列化包装,不兼容 Markdown、思考文本或任意前后缀。

将节点代码整体替换为:

import json
import re
from datetime import date


def _parse_json(value, name):
    if isinstance(value, (dict, list)):
        return value
    text = str(value or "").strip()
    if not text:
        raise ValueError(f"{name} is empty")
    if text.startswith("```json") and text.endswith("```"):
        text = text[7:-3].strip()
    try:
        return json.loads(text)
    except json.JSONDecodeError as exc:
        raise ValueError(f"{name} is not valid JSON: {exc.msg}") from exc


def _parse_llm_output(value):
    """兼容 Dify 对 LLM JSON 输出最多一次额外字符串化。"""
    raw = value
    for _ in range(2):
        if isinstance(raw, dict):
            return raw
        if not isinstance(raw, str):
            raise ValueError("llm_output must be a JSON object or JSON string")
        text = raw.strip()
        if not text:
            raise ValueError("llm_output is empty")
        try:
            raw = json.loads(text)
        except json.JSONDecodeError as exc:
            raise ValueError(f"llm_output is not valid JSON: {exc.msg}") from exc
    if isinstance(raw, dict):
        return raw
    raise ValueError("llm_output must unwrap to a JSON object")


def _as_int(value, name):
    try:
        return int(value)
    except (TypeError, ValueError) as exc:
        raise ValueError(f"{name} must be an integer") from exc


def _confidence(value, name):
    try:
        result = float(value)
    except (TypeError, ValueError) as exc:
        raise ValueError(f"{name} must be numeric") from exc
    if not 0 <= result <= 1:
        raise ValueError(f"{name} must be between 0 and 1")
    return result


def _orders(raw):
    if isinstance(raw, dict) and isinstance(raw.get("orders"), list):
        return raw["orders"]
    raise ValueError("LLM output must be an object containing orders array")


def _field_map(schema):
    fields = schema.get("fields") if isinstance(schema, dict) else None
    if not isinstance(fields, list):
        raise ValueError("schema_contract_json.fields must be an array")
    result = {}
    for field in fields:
        if isinstance(field, dict) and field.get("collection_mode", "llm_extraction") == "llm_extraction":
            field_id = str(field.get("field_id") or "").strip()
            if field_id:
                result[field_id] = {
                    "scope": str(field.get("scope") or "").strip().lower(),
                    "value_type": str(field.get("value_type") or "string").strip().lower(),
                    "field_code": str(field.get("field_code") or "").strip(),
                    "validator_keys": list(field.get("validator_keys") or []),
                }
    return result


def _typed_value(value, config, field_id):
    """在 Dify 侧拒绝无法落入冻结 Schema 类型的模型值。"""
    value_type = config["value_type"]
    if value_type == "decimal":
        if isinstance(value, bool) or not isinstance(value, (int, float)):
            raise ValueError(f"{field_id} must be a JSON number")
    elif value_type == "integer":
        if isinstance(value, bool) or not isinstance(value, int):
            raise ValueError(f"{field_id} must be a JSON integer")
    elif value_type == "boolean":
        if not isinstance(value, bool):
            raise ValueError(f"{field_id} must be a JSON boolean")
    elif value_type == "date":
        if not isinstance(value, str):
            raise ValueError(f"{field_id} must be an ISO date string")
        try:
            date.fromisoformat(value)
        except ValueError as exc:
            raise ValueError(f"{field_id} must use YYYY-MM-DD") from exc
    elif value_type in {"string", "enum"}:
        if not isinstance(value, str) or not value.strip():
            raise ValueError(f"{field_id} must be a non-empty string")
    return value


def _validate_field_semantics(value, config, field_id):
    """拦截模型常见的列位置错配,避免错误字段作为成功 Unit 进入 HXOPS。"""
    code = config["field_code"]
    validators = set(config["validator_keys"])
    if "positive_decimal" in validators or "positive_integer" in validators:
        if value <= 0:
            raise ValueError(f"{field_id} must be positive")
    if code == "line_no" and re.search(r"[A-Za-z]", value):
        raise ValueError("line_no must not contain a part number")
    if code == "inventory_source_hint" and re.fullmatch(r"\d+", value.strip()):
        raise ValueError("inventory_source_hint must not be a line number")
    if code == "reservation_id" and not re.fullmatch(r"\d{8,20}", value.strip()):
        raise ValueError("reservation_id must be an explicit numeric reservation identifier")
    return value


def _field_group(items, scope, fields, document_id):
    if items is None:
        return []
    if not isinstance(items, list):
        raise ValueError(f"{scope} fields must be an array")
    result = []
    seen = set()
    for item in items:
        if not isinstance(item, dict):
            raise ValueError(f"{scope} field must be an object")
        field_id = str(item.get("field_id") or "").strip()
        config = fields.get(field_id)
        if not field_id or field_id in seen or not config or config["scope"] != scope:
            raise ValueError(f"invalid {scope} field_id")
        seen.add(field_id)
        observations = item.get("observations")
        if not isinstance(observations, list) or not observations:
            raise ValueError(f"{field_id} must have at least one observation")
        normalized = []
        for observation in observations:
            if not isinstance(observation, dict) or "value" not in observation:
                raise ValueError(f"invalid observation for {field_id}")
            if _as_int(observation.get("document_id"), "observation.document_id") != document_id:
                raise ValueError("observation.document_id must equal unit primary_document_id")
            quote = str(observation.get("quote") or "").strip()
            if not quote:
                raise ValueError(f"observation quote is required for {field_id}")
            value = _typed_value(observation.get("value"), config, field_id)
            normalized.append({
                "value": _validate_field_semantics(value, config, field_id),
                "document_id": document_id,
                "quote": quote,
                "confidence": _confidence(observation.get("confidence"), "observation.confidence"),
            })
        result.append({"field_id": field_id, "observations": normalized})
    return result


def main(llm_output, schema_contract_json: str, source_intake_no: str, primary_document_id):
    try:
        schema = _parse_json(schema_contract_json, "schema_contract_json")
        expected_intake = str(source_intake_no or "").strip().upper()
        expected_document = _as_int(primary_document_id, "primary_document_id")
        expected_schema_id = _as_int(schema.get("schema_version_id"), "schema.schema_version_id")
        expected_checksum = str(schema.get("checksum") or "").strip()
        fields = _field_map(schema)
        normalized_orders = []
        for order in _orders(_parse_llm_output(llm_output)):
            if not isinstance(order, dict):
                raise ValueError("each order must be an object")
            if _as_int(order.get("schema_version_id"), "schema_version_id") != expected_schema_id:
                raise ValueError("schema_version_id mismatch")
            if str(order.get("schema_checksum") or "").strip() != expected_checksum:
                raise ValueError("schema_checksum mismatch")
            if str(order.get("source_intake_no") or "").strip().upper() != expected_intake:
                raise ValueError("source_intake_no must equal unit intake_no")
            if _as_int(order.get("primary_document_id"), "primary_document_id") != expected_document:
                raise ValueError("primary_document_id must equal unit document_id")
            classification = str(order.get("classification") or "").strip().lower()
            if classification not in {"shipping_request", "non_shipping_request", "uncertain"}:
                raise ValueError("invalid classification")
            lines = order.get("lines") or []
            if not isinstance(lines, list):
                raise ValueError("lines must be an array")
            normalized_orders.append({
                "schema_version_id": expected_schema_id,
                "schema_checksum": expected_checksum,
                "classification": classification,
                "classification_confidence": _confidence(order.get("classification_confidence"), "classification_confidence"),
                "source_intake_no": expected_intake,
                "primary_document_id": expected_document,
                "header_fields": _field_group(order.get("header_fields"), "header", fields, expected_document),
                "lines": [{"fields": _field_group(line.get("fields"), "line", fields, expected_document)} for line in lines if isinstance(line, dict)],
                "conflicts": order.get("conflicts") if isinstance(order.get("conflicts"), list) else [],
            })
        return {
            "orders": json.dumps(normalized_orders, ensure_ascii=False, separators=(",", ":")),
            "order_count": len(normalized_orders),
            "validation_ok": True,
            "validation_error": "",
        }
    except Exception as exc:
        return {"orders": "[]", "order_count": 0, "validation_ok": False, "validation_error": str(exc)[:500]}

7. If/Else、错误与 End 节点

check_validation 的条件:validate_and_normalize_orders.validation_ok is true。

失败分支的 raise_validation_error:

def main(validation_error: str):
    raise ValueError(str(validation_error or "LLM order extraction output validation failed")[:500])

End 节点只配置:

输出变量 类型 值
orders String validate_and_normalize_orders.orders

不要输出 result、data、answer、日志、思考内容或错误详情。HXOPS 只读取 outputs.orders。

8. 手工配置验收

8.1 HXOPS 发布 Schema 表头别名

在重新发布订单 Schema 前,管理员必须检查确定性表格别名。表头别名是全局精确规则,不是 LLM 提示词;一旦配置,后端会在所有客户模板中按该语义执行。

  • 从 aws_part_number 删除裸 Material、Material No、Material Number,并将这些别名配置到 customer_part_number。aws_part_number 只保留明确含 AWS/APN 业务限定的表头,例如 AWS SKU、AWS Part Number、Allocated APN。
  • Item、Item No 可作为 line_no 的全局别名,但只表示订单行序号;不得同时配置到任何料号字段。
  • part_number 保留明确的内部/供应商料号表头,例如 Supplier Part Number、Vendor Part Number、MPN;不得把客户订单的裸 Material 当作内部料号。
  • 裸 Part Number 存在客户模板歧义,不应作为跨客户强制语义。已确认模板使用精确 Profile 表达 Part Number -> customer_part_number、Vendor Item# -> part_number;这类映射是合法模板规则,不是异常,不应复制为 Dify Prompt 中的全局特例。
  • qty 可增加已经确认仍为独立数量列的完整精确别名,例如 Q TY 数量、Q'TY 数量、Q TY UNIT、ORDER QUANTITY EA。不得配置 Quantity U M Delivery,该文本同时粘连数量、单位和交期,无法证明单一列语义。
  • 不得为含首条数据的污染表头增加别名,例如 Item No 00010、Order Amount 941.76。这类结果必须由版面质量门禁转复核,不能把样本值写入 Schema。
  • reservation_id 每条订单行最终都必须具备,但证据可能位于邮件正文或其他附件。单张 PDF 缺失 Reservation 时应保留其确定性行字段,由邮件/其他附件单元补充;补充失败时停在流程门禁,禁止进入库存匹配和发货 Excel。
  • 保存或发布前检查标准化别名碰撞;同一字段在一张表命中多个列时必须进入复核,不得通过调整 Prompt 让模型选择其中一列。

上述 Schema 修改在 HXOPS 管理端手工完成,不在 Dify Code/LLM 节点复制别名字典。

  • Start 仅有 execution_manifest,且为 String。
  • parse_and_prepare_input 只接受 shipping_order_extraction.unit.v2。
  • 代码要求 documents 长度恰为 1,并且只读取 documents[0].document。
  • LLM 仅收到 document_json,没有 documents_json、附件集合或整封邮件拼接输入。
  • LLM 明确固定 source_intake_no、primary_document_id 和所有 Observation 的 document_id。
  • LLM 不输出没有证据的字段;不输出空 Observation。
  • date 字段的 value 为 YYYY-MM-DD;原文日期只保留在 quote 中。
  • decimal / integer / boolean 分别输出 JSON 数字 / 数字 / 布尔值。
  • line_no、part_number、reservation_id、inventory_source_hint 和 aws_part_number 不发生位置性或互相替代的错误映射。
  • HXOPS published Schema 的 customer_part_number 包含 Material/Material No/Material Number,aws_part_number 不包含这些裸别名。
  • 明确的 AWS SKU/APN 证据优先于 Material,且 Material 不覆盖已有 AWS 料号。
  • Qty 只配置语义单一的完整表头;多语义粘连表头和含首条数据的污染表头未进入 Schema aliases。
  • 单张 PDF 缺少 Reservation 时仍保留其确定性字段;邮件/其他附件负责补充,Dify 不伪造 Reservation,HXOPS 最终流程门禁负责阻断库存匹配。
  • 校验节点对每个订单及每个 Observation 强制当前 Unit 的 Intake/Document 归属。
  • 校验失败进入失败分支,不返回成功空数组。
  • End 只有 String 类型的 orders,API 响应顶层键为 outputs.orders。
  • 没有旧整包输入判断、嵌套附件遍历、跨附件合并、自动建单、Dify 侧重试或循环。

9. 运行后核验

发布 Dify 后,创建一次新的订单抽取 Run。管理员诊断中,每个 Unit 应独立成功或失败;某个 Unit 的 orders、primary_document_id 和所有 Observation document_id 必须一致。跨文档字段合并只会在 HXOPS 后端发生。

Workflow 成功不代表 Task 已创建。HXOPS 仍会执行动态 Schema、Reservation 证据、重复检测、客户影子识别和自动建单开关等门禁。