From c301c2c4bc648c2236b090b4ed8cada3b2cc06b9 Mon Sep 17 00:00:00 2001 From: Zhaowenlong Date: Sat, 30 May 2026 17:24:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=BC=BA=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=B8=83=E7=BA=BF=E7=BC=BA=E5=A4=B1=E7=AB=AF=E5=AD=90=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Mod/FreeCADExchange/AutoRouting.py | 21 +++++++++++++++-- .../freecad_exchange_auto_routing_test.py | 23 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/Mod/FreeCADExchange/AutoRouting.py b/src/Mod/FreeCADExchange/AutoRouting.py index 5f15cc1..caab10e 100644 --- a/src/Mod/FreeCADExchange/AutoRouting.py +++ b/src/Mod/FreeCADExchange/AutoRouting.py @@ -1354,6 +1354,23 @@ def route_eplan_connections_from_payload(doc, payload, options=None, prepared_la return report +def _missing_endpoint_label(sample, side): + terminal_uuid = str(sample.get("{0}_terminal_uuid".format(side), "") or "").strip() + element_uuid = str(sample.get("{0}_element_uuid".format(side), "") or "").strip() + terminal_display = str(sample.get("{0}_terminal_display".format(side), "") or "").strip() + if element_uuid and terminal_display: + label = "{0}/{1}".format(element_uuid, terminal_display) + elif terminal_display: + label = terminal_display + elif element_uuid: + label = element_uuid + else: + return terminal_uuid + if terminal_uuid and terminal_uuid != label: + return "{0} ({1})".format(label, terminal_uuid) + return label + + def format_eplan_connection_route_report(report): message = "批量生成布线连接完成:routed={0}, collision_warnings={1}, missing_terminals={2}".format( report.get("routed", 0), @@ -1441,8 +1458,8 @@ def format_eplan_connection_route_report(report): sample = (report.get("missing_endpoint_samples") or [None])[0] if sample: message += "\n缺失示例:{0} -> {1}".format( - sample.get("start_terminal_uuid", ""), - sample.get("end_terminal_uuid", ""), + _missing_endpoint_label(sample, "start"), + _missing_endpoint_label(sample, "end"), ) return message diff --git a/tests/python/freecad_exchange_auto_routing_test.py b/tests/python/freecad_exchange_auto_routing_test.py index c7c6dde..be90d14 100644 --- a/tests/python/freecad_exchange_auto_routing_test.py +++ b/tests/python/freecad_exchange_auto_routing_test.py @@ -1825,6 +1825,29 @@ class AutoRoutingTest(unittest.TestCase): self.assertIn("首个错误:没有可用的线槽/路由路径网络", message) self.assertIn("缺失示例:terminal-a -> terminal-b", message) + def test_route_eplan_connections_report_includes_readable_missing_endpoint_labels(self): + _install_fake_freecad() + _terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules() + report = { + "routed": 0, + "collision_warnings": 0, + "skipped_missing_terminal": 1, + "missing_endpoint_samples": [ + { + "start_terminal_uuid": "terminal-a", + "start_element_uuid": "device-a", + "start_terminal_display": "A1", + "end_terminal_uuid": "terminal-b", + "end_element_uuid": "device-b", + "end_terminal_display": "B1", + } + ], + } + + message = auto_routing.format_eplan_connection_route_report(report) + + self.assertIn("缺失示例:device-a/A1 (terminal-a) -> device-b/B1 (terminal-b)", message) + def test_route_eplan_connections_report_calls_out_clearance_collision_kind(self): _install_fake_freecad() _terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()