16. Flow-Service
Der Zugriff erfolgt über client.flow(). Der Service liest die visuellen Workflows (Flow) von PlantPulse sowie die darin enthaltenen Knoten (Flow Node) aus. Es handelt sich um einen in V5 neu hinzugefügten Service.
Hinweis: Der Flow-Service in V5 ist schreibgeschützt. Das Anlegen, Ändern und Ausführen von Flows erfolgt über die UI oder die dedizierte API der Flow-Engine. Einzelheiten zur Funktionsweise der Flow-Engine finden Sie in der Dokumentation zur Flow-Engine.
16.1 Methodenübersicht
| Methode | Rückgabetyp | HTTP | Endpunkt |
|---|---|---|---|
get(flow_id) | FlowResponseV5 oder null | GET | /api/v5/flow/{id} |
list() | List<FlowResponseV5> (inkl. Statistik) | GET | /api/v5/flow |
listNodes(flow_id) | List<FlowNodeResponseV5> | GET | /api/v5/flow/{id}/node |
16.2 FlowResponseV5 DTO
| Feld | Typ | Beschreibung |
|---|---|---|
flow_id | String | Flow-ID (PK) |
flow_name | String | Flow-Name |
description | String | Beschreibung |
enabled | boolean | Aktiviert ja/nein |
is_root | boolean | Root-Flow ja/nein |
debug_mode | boolean | Debug-Modus |
insert_user / insert_date | String | Ersteller/Zeitpunkt |
update_user / update_date | String | Bearbeiter/Zeitpunkt |
node_count | int | Anzahl Knoten (Statistik) |
trigger_count | int | Anzahl Trigger (Statistik) |
error_count | long | Kumulierte Fehleranzahl (Statistik) |
16.3 FlowNodeResponseV5 DTO
| Feld | Typ | Beschreibung |
|---|---|---|
flow_node_id | String | Knoten-ID (PK) |
flow_id | String | Zugehöriger Flow |
type | String | Knotentyp (trigger, function, action usw.) |
name | String | Knotenname |
configuration_json | String | JSON-String der Knotenkonfiguration |
position_x / position_y | int | Position auf der Zeichenfläche |
debug_mode | boolean | Debug je Knoten |
16.4 Anwendungsbeispiele
Flow-Liste (inkl. Statistik)
import java.util.List;
import plantpulse.api.v5.dto.response.FlowResponseV5;
List<FlowResponseV5> flows = client.flow().list();
for (FlowResponseV5 f : flows) {
System.out.printf("[%s] %s — 노드 %d개, 트리거 %d개, 에러 %d건%n",
f.isEnabled() ? "ON" : "OFF",
f.getFlow_name(),
f.getNode_count(),
f.getTrigger_count(),
f.getError_count());
}
Beispielausgabe:
[ON] 생산 카운트 집계 — 노드 8개, 트리거 1개, 에러 0건
[ON] 알람 알림 라우팅 — 노드 12개, 트리거 3개, 에러 2건
[OFF] (실험) ML 예측 — 노드 5개, 트리거 0개, 에러 0건
Einzelnen Flow abfragen
FlowResponseV5 flow = client.flow().get("flow_001");
if (flow != null && !flow.isEnabled()) {
System.err.println("Flow가 비활성 상태: " + flow.getFlow_name());
}
Knotenliste eines Flows
import plantpulse.api.v5.dto.response.FlowNodeResponseV5;
String flowId = "flow_001";
List<FlowNodeResponseV5> nodes = client.flow().listNodes(flowId);
for (FlowNodeResponseV5 n : nodes) {
System.out.printf(" [%s] %s (%s)%n",
n.getType(), n.getName(), n.getFlow_node_id());
}
Flows mit Fehlern identifizieren
import java.util.stream.Collectors;
List<FlowResponseV5> errored = client.flow().list().stream()
.filter(f -> f.getError_count() > 0)
.collect(Collectors.toList());
System.out.println("에러 발생 Flow: " + errored.size() + "개");
for (FlowResponseV5 f : errored) {
System.out.printf(" %s: %d건%n", f.getFlow_name(), f.getError_count());
}
16.5 Einsatzszenarien
Szenario — Flow-Health-Dashboard
while (running) {
List<FlowResponseV5> all = client.flow().list();
long total = all.size();
long enabled = all.stream().filter(FlowResponseV5::isEnabled).count();
long errored = all.stream().filter(f -> f.getError_count() > 0).count();
long triggers = all.stream().mapToInt(FlowResponseV5::getTrigger_count).sum();
updateUI(total, enabled, errored, triggers);
Thread.sleep(5_000);
}
Nächste Schritte
- Leitfaden zur Flow-Engine — Funktionsweise von Flow (separates Dokument)
- Integrationsbeispiele — Beispiele zur Anbindung von Flow und API