9. Path 服务
通过 client.path() 访问。可通过一次调用查询资产或标签的层级路径(Site > Area > Line > Equipment)。
9.1 方法一览
| 方法 | 返回类型 | HTTP | 端点 |
|---|---|---|---|
getByAsset(asset_id) | PathResponseV5 或 null | GET | /api/v5/path/asset/{id} |
getByTag(tag_id) | PathResponseV5 或 null | GET | /api/v5/path/tag/{id} |
9.2 PathResponseV5 DTO
| 字段 | 说明 |
|---|---|
site_id / site_name | 所属站点 |
area_id / area_name | 区域 |
line_id / line_name | 产线 |
equipment_id / equipment_name | 设备 |
根据资产类型,部分字段可能为
null(例如仅有 Area 的资产,其line_*、equipment_*均为null)。
9.3 使用示例
设备的完整路径
import plantpulse.api.v5.dto.response.PathResponseV5;
PathResponseV5 path = client.path().getByAsset("ASSET_DJ_M_0001");
if (path != null) {
System.out.printf("%s > %s > %s > %s%n",
path.getSite_name(),
path.getArea_name(),
path.getLine_name(),
path.getEquipment_name());
}
输出示例:
대전 1공장 > 조립구역 > 1라인 > CNC #1
标签的资产路径
PathResponseV5 tagPath = client.path().getByTag("TAG_EDGE_00303_90007");
if (tagPath != null) {
System.out.println("태그가 부착된 설비: " + tagPath.getEquipment_name());
System.out.println("라인: " + tagPath.getLine_name());
}
路径字符串生成工具
static String formatPath(PathResponseV5 p) {
if (p == null) return "(경로 없음)";
StringBuilder sb = new StringBuilder();
if (p.getSite_name() != null) sb.append(p.getSite_name());
if (p.getArea_name() != null) sb.append(" > ").append(p.getArea_name());
if (p.getLine_name() != null) sb.append(" > ").append(p.getLine_name());
if (p.getEquipment_name() != null) sb.append(" > ").append(p.getEquipment_name());
return sb.toString();
}
9.4 应用场景
场景 — 显示报警发生资产的路径
import plantpulse.api.v5.dto.response.AlarmResponseV5;
for (AlarmResponseV5 a : client.alarm().list(20)) {
// AlarmResponseV5 에 tag_location 필드가 이미 있지만
// 더 구조화된 경로가 필요하면 Path 서비스로 재조회
if (a.getTag_id() != null) {
PathResponseV5 path = client.path().getByTag(a.getTag_id());
System.out.printf("[%s] %s @ %s%n",
a.getPriority(),
a.getDescription(),
formatPath(path));
}
}