Эх сурвалжийг харах

处理完事件中枢哪些娃儿乱搞

wukai 2 долоо хоног өмнө
parent
commit
5ee25555c0

+ 8 - 4
jjt-admin/src/main/java/com/jjt/biz/controller/IndexController.java

@@ -4,7 +4,10 @@ import com.jjt.biz.domain.DeviceChannels;
 import com.jjt.biz.domain.FlowsRecord;
 import com.jjt.biz.domain.HouseConfig;
 import com.jjt.biz.domain.SensorConfig;
-import com.jjt.biz.service.*;
+import com.jjt.biz.service.IDeviceChannelsService;
+import com.jjt.biz.service.IFlowsRecordService;
+import com.jjt.biz.service.IHouseConfigService;
+import com.jjt.biz.service.ISensorConfigService;
 import com.jjt.common.core.controller.BaseController;
 import com.jjt.common.core.page.TableDataInfo;
 import com.jjt.common.utils.SecurityUtils;
@@ -58,7 +61,7 @@ public class IndexController extends BaseController {
             xx.put("smoke", true);
             xx.put("exhaust", true);
             SensorConfig sensorConfig = sensorConfigService.findByHouseId(house.getHouseId());
-            if (StringUtils.isNotEmpty(sensorConfig.getRemark())) {
+            if (sensorConfig != null && StringUtils.isNotEmpty(sensorConfig.getRemark())) {
                 String[] tmp = sensorConfig.getRemark().split(",");
                 if (tmp.length == 2) {
                     xx.put("smoke", !"true".equals(tmp[0]));
@@ -181,9 +184,10 @@ public class IndexController extends BaseController {
     @ApiOperation("根据流程ID查询流程列表")
     @GetMapping("/flows/{flowId}")
     public TableDataInfo flowsList(@PathVariable("flowId") String flowId) {
-        startPage();
+        //流程ID映射,因为之前统计的流程ID被修改,所以这里需要重新映射
+              startPage();
         FlowsRecord flowsRecord = new FlowsRecord();
-        flowsRecord.setUpdateBy(flowId + "");
+        flowsRecord.setUpdateBy(flowId);
         flowsRecord.setCreateTime(java.util.Date.from(java.time.LocalDate.now().atStartOfDay(java.time.ZoneId.systemDefault()).toInstant()));
         flowsRecord.getParams().put("deptId", SecurityUtils.getDeptId());
         List<FlowsRecord> list = flowsRecordService.selectFlowsRecordList(flowsRecord);

+ 2 - 2
jjt-admin/src/main/java/com/jjt/biz/service/impl/FlowsRecordServiceImpl.java

@@ -116,7 +116,7 @@ public class FlowsRecordServiceImpl implements IFlowsRecordService {
         Date end = new Date();
         List<FlowsConfig> flowsConfigList = flowsConfigService.selectFlowsConfigList(new FlowsConfig());
         for (FlowsConfig flowsConfig : flowsConfigList) {
-            JSONArray array = FlowsUtils.query(flowsConfig.getFlowsId(), flowsConfig.getUpdateTime(), end, "");
+            JSONArray array = FlowsUtils.query(Long.parseLong(flowsConfig.getCreateBy()), flowsConfig.getUpdateTime(), end, "");
             List<FlowsRecord> insertList = new ArrayList<>();
             for (int i = 0; i < Objects.requireNonNull(array).size(); i++) {
                 JSONObject object = array.getJSONObject(i);
@@ -129,7 +129,7 @@ public class FlowsRecordServiceImpl implements IFlowsRecordService {
                 String house = "";
                 String area = "";
                 if (cache.containsKey(flowsConfig.getHouseId()) && cache.getJSONObject(flowsConfig.getHouseId()) != null) {
-                    if (flowsConfig.getFlowsId() == 191L) {
+                    if ("165".equals(flowsConfig.getCreateBy())) {
                         if (cache.getJSONObject(flowsConfig.getHouseId()).containsKey("value") && cache.getJSONObject(flowsConfig.getHouseId()).getJSONArray("value") != null
                                 && cache.getJSONObject(flowsConfig.getHouseId()).getJSONArray("value").size() > 0) {
                             house = cache.getJSONObject(flowsConfig.getHouseId()).getJSONArray("value").getJSONObject(0).getStr("value");

+ 13 - 12
jjt-admin/src/main/java/com/jjt/biz/utils/FlowsUtils.java

@@ -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();

+ 1 - 1
jjt-admin/src/main/resources/application-prod.yml

@@ -47,7 +47,7 @@ spring:
     # 数据库索引
     database: 0
     # 密码
-    password:
+    password: JJT@2025!yd
     # 连接超时时间
     timeout: 10s
     lettuce:

+ 2 - 2
jjt-admin/src/test/java/com/test/Test.java

@@ -16,8 +16,8 @@ public class Test {
     public static void main(String[] args) {
 
 // 构建 JWT token
-        String appid = "dce1648c820982b7903a5e8efc315020a5a43aca06e43859b0bad0ee2fd58bac";
-        String appsecret = "f5f27ef65cedd8e976f1a8b4685a41a27d6a93162842bf098b1d1563725186f1";
+        String appid = "8078053d8eee5920be02edf274c7b7fdf1af9fb9a30464cffd461c819dbcab62";
+        String appsecret = "058f950e9e5a096494d3792b7e1062e1ea945f51b1fce90e6b808f5a50ffe95f";
         Integer namespaceId = 3;
 
         Map<String, Object> header = new HashMap<>();