|
|
@@ -8,7 +8,6 @@ import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.jjt.common.utils.DateUtils;
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
-import java.time.OffsetDateTime;
|
|
|
import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
@@ -19,10 +18,12 @@ import java.util.Date;
|
|
|
*/
|
|
|
public class FlowsUtils {
|
|
|
private static final String FLOWS_URL = "https://smp.quanmate.com.cn";
|
|
|
- private static final String FLOWS_TOKEN = "dce1648c820982b7903a5e8efc315020a5a43aca06e43859b0bad0ee2fd58bac:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuYW1lc3BhY2VfaWQiOjN9.AJaMbpfZxoJ1hoLKR1hE6juBmUQT8N7HP6ROgcHKTcg";
|
|
|
+ private static final String FLOWS_USER = "43";
|
|
|
+ private static final String FLOWS_ID = "165";
|
|
|
+ private static final String FLOWS_TOKEN = "8078053d8eee5920be02edf274c7b7fdf1af9fb9a30464cffd461c819dbcab62:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuYW1lc3BhY2VfaWQiOjN9.oIuSZM4OVq0CoFsinS8ajzWj-U7-vrDWlGfI0uygnnM";
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
- create(618L, "烟雾状态:正常,温度:28.1℃,湿度:50.4%");
|
|
|
+ create(391L, "烟雾状态:正常,温度:28.1℃,湿度:55.4%");
|
|
|
// 将 ISO 8601 格式字符串转换为 Date 对象
|
|
|
// String isoDateString = "2025-09-17T18:50:56.722+08:00";
|
|
|
//// / 使用 OffsetDateTime 解析
|
|
|
@@ -88,13 +89,13 @@ public class FlowsUtils {
|
|
|
*/
|
|
|
|
|
|
public static void create(Long house, String value) {
|
|
|
- String uri = FLOWS_URL + "/api/v4/yaw/flows/191/journeys";
|
|
|
+ String uri = FLOWS_URL + "/api/v4/yaw/flows/165/journeys";
|
|
|
HttpRequest request = HttpRequest.post(uri);
|
|
|
request.header("Authorization", FLOWS_TOKEN);
|
|
|
String success = "SUCCESS";
|
|
|
// 设置请求体 - 使用更明确的方式
|
|
|
String body = body(house, value);
|
|
|
- System.err.println(body);
|
|
|
+// System.err.println(body);
|
|
|
request.body(body);
|
|
|
try (HttpResponse res = request.execute()) {
|
|
|
System.err.println("响应状态码: " + res.getStatus());
|
|
|
@@ -121,7 +122,7 @@ public class FlowsUtils {
|
|
|
* 发布任务
|
|
|
*/
|
|
|
public static void publish(Long nextId) {
|
|
|
- String uri = FLOWS_URL + "/api/v4/yaw/flows/191/journeys";
|
|
|
+ String uri = FLOWS_URL + "/api/v4/yaw/flows/"+FLOWS_ID+"/journeys";
|
|
|
HttpRequest request = HttpRequest.post(uri);
|
|
|
request.header("Authorization", FLOWS_TOKEN);
|
|
|
request.body("{" +
|
|
|
@@ -129,7 +130,7 @@ public class FlowsUtils {
|
|
|
" \"operation\": \"propose\"," +
|
|
|
" \"next_vertex_id\": " + nextId +
|
|
|
" }," +
|
|
|
- " \"user_id\": 66" +
|
|
|
+ " \"user_id\": " + FLOWS_USER +
|
|
|
"}");
|
|
|
try (HttpResponse res = request.execute()) {
|
|
|
System.err.println("响应状态码: " + res.getStatus());
|
|
|
@@ -167,22 +168,22 @@ public class FlowsUtils {
|
|
|
|
|
|
// 添加entries_attributes数组元素
|
|
|
JSONObject entry1 = new JSONObject();
|
|
|
- entry1.put("field_id", 868);
|
|
|
+ entry1.put("field_id", 575);
|
|
|
entry1.put("option_id", house);
|
|
|
entriesAttributes.add(entry1);
|
|
|
|
|
|
JSONObject entry2 = new JSONObject();
|
|
|
- entry2.put("field_id", 846);
|
|
|
+ entry2.put("field_id", 576);
|
|
|
entry2.put("value", "传感器网关");
|
|
|
entriesAttributes.add(entry2);
|
|
|
|
|
|
JSONObject entry3 = new JSONObject();
|
|
|
- entry3.put("field_id", 644);
|
|
|
+ entry3.put("field_id", 577);
|
|
|
entry3.put("value", value);
|
|
|
entriesAttributes.add(entry3);
|
|
|
|
|
|
JSONObject entry4 = new JSONObject();
|
|
|
- entry4.put("field_id", 645);
|
|
|
+ entry4.put("field_id", 578);
|
|
|
entry4.put("value", DateUtils.getTime());
|
|
|
entriesAttributes.add(entry4);
|
|
|
|
|
|
@@ -191,7 +192,7 @@ public class FlowsUtils {
|
|
|
requestBody.put("assignment", assignment);
|
|
|
|
|
|
// 添加user_id
|
|
|
- requestBody.put("user_id", 66);
|
|
|
+ requestBody.put("user_id", FLOWS_USER);
|
|
|
|
|
|
// 构建webhook对象
|
|
|
JSONObject webhook = new JSONObject();
|