yinhao 4 роки тому
батько
коміт
375d9eec17

+ 30 - 0
huimv-test-platform/huimv-ctwing/src/main/java/com/huimv/devicedata/controller/DeviceDataController.java

@@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 import java.util.Calendar;
 import java.util.Date;
 
@@ -61,4 +62,33 @@ public class DeviceDataController {
 
         return "200";
     }
+
+    /**
+     * 设备命令响应
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping("/deviceResponse")
+    public String deviceResponse(HttpServletRequest request, HttpServletResponse response) {
+        try {
+            //字符缓冲流接收数据
+            BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream(), StandardCharsets.UTF_8));
+            StringBuilder sb = new StringBuilder();
+            String lineData;
+            while ((lineData = br.readLine()) != null) {
+                sb.append(lineData);
+            }
+            br.close();
+            String result = sb.toString();
+            System.out.println("设备指令响应通知数据-->" + result);
+            JSONObject deviceResponseData = JSONObject.parseObject(result);
+            deviceDataService.saveDeviceResponseData(deviceResponseData);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "200";
+
+    }
 }

+ 9 - 0
huimv-test-platform/huimv-ctwing/src/main/java/com/huimv/devicedata/repo/DeviceUpdataEntityRepository.java

@@ -0,0 +1,9 @@
+package com.huimv.devicedata.repo;
+
+import com.huimv.devicedata.entity.DeviceUpdataEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface DeviceUpdataEntityRepository extends JpaRepository<DeviceUpdataEntity, Integer>, JpaSpecificationExecutor<DeviceUpdataEntity> {
+
+}