|
|
|
|
@ -1689,6 +1689,42 @@ def _endpoint_pair_text(sample):
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _route_source_labels(route_track, limit=5):
|
|
|
|
|
labels = []
|
|
|
|
|
seen = set()
|
|
|
|
|
if not isinstance(route_track, dict):
|
|
|
|
|
return labels
|
|
|
|
|
for segment in route_track.get("segments", []) or []:
|
|
|
|
|
carrier = segment.get("carrier", {}) if isinstance(segment, dict) else {}
|
|
|
|
|
if not isinstance(carrier, dict):
|
|
|
|
|
continue
|
|
|
|
|
label = (
|
|
|
|
|
str(carrier.get("source_label", "") or "").strip()
|
|
|
|
|
or str(carrier.get("source_name", "") or "").strip()
|
|
|
|
|
)
|
|
|
|
|
if not label or label in seen:
|
|
|
|
|
continue
|
|
|
|
|
seen.add(label)
|
|
|
|
|
labels.append(label)
|
|
|
|
|
if len(labels) >= int(limit or 0):
|
|
|
|
|
break
|
|
|
|
|
return labels
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _route_source_sample_text(report):
|
|
|
|
|
for route in report.get("routes", []) or []:
|
|
|
|
|
if not isinstance(route, dict):
|
|
|
|
|
continue
|
|
|
|
|
labels = _route_source_labels(route.get("route_track", {}))
|
|
|
|
|
if not labels:
|
|
|
|
|
continue
|
|
|
|
|
return "路径示例:导线 {0} 经过 {1}。".format(
|
|
|
|
|
_wire_sample_text(route),
|
|
|
|
|
"、".join(labels),
|
|
|
|
|
)
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def format_eplan_connection_route_report(report):
|
|
|
|
|
message = "批量生成布线连接完成:routed={0}, collision_warnings={1}, missing_terminals={2}".format(
|
|
|
|
|
report.get("routed", 0),
|
|
|
|
|
@ -1731,6 +1767,9 @@ def format_eplan_connection_route_report(report):
|
|
|
|
|
total_length_mm = float(report.get("total_length_mm", 0.0) or 0.0)
|
|
|
|
|
if total_length_mm > 0.0:
|
|
|
|
|
message += "\n布线连接总长度:{0:.1f} mm。".format(total_length_mm)
|
|
|
|
|
route_source_sample = _route_source_sample_text(report)
|
|
|
|
|
if route_source_sample:
|
|
|
|
|
message += "\n{0}".format(route_source_sample)
|
|
|
|
|
errors = report.get("errors", []) or []
|
|
|
|
|
if errors:
|
|
|
|
|
message += "\n首个错误:{0}".format(str(errors[0]))
|
|
|
|
|
|