From 1959bd7304335969851e7b05e88d879ab623d134 Mon Sep 17 00:00:00 2001
From: vince <757871790@qq.com>
Date: 星期五, 31 五月 2024 09:45:17 +0800
Subject: [PATCH] 定时测温

---
 src/main/java/com/fzzy/gateway/controller/GatewayDataApi.java |   70 +++++++++++++++++++---------------
 1 files changed, 39 insertions(+), 31 deletions(-)

diff --git a/src/main/java/com/fzzy/gateway/controller/GatewayDataApi.java b/src/main/java/com/fzzy/gateway/controller/GatewayDataApi.java
index c4f54fc..beec7a3 100644
--- a/src/main/java/com/fzzy/gateway/controller/GatewayDataApi.java
+++ b/src/main/java/com/fzzy/gateway/controller/GatewayDataApi.java
@@ -37,43 +37,51 @@
      * @throws Exception
      */
     @PostMapping("/push-grain")
-    public @ResponseBody BaseResp pushGrain(@RequestBody Fz40Grain grainData) throws Exception {
+    public @ResponseBody
+    BaseResp pushGrain(@RequestBody Fz40Grain grainData) {
 
         BaseResp resp = new BaseResp();
+        try {
 
-        //鏍规嵁绯荤粺浠撳簱缂栫爜鑾峰彇閰嶇疆璁惧淇℃伅
-        GatewayDevice device = GatewayUtils.getCacheByDepotSysId(grainData.getDepotId());
+            log.info("----------涓诲姩鎺ㄩ�佺伯鎯呮帴鍙f墽琛�----{}",grainData);
 
-        if (null == device) {
-            resp.setMsg("缃戝叧涓病鏈夎幏鍙栧埌閰嶇疆鐨勭粓绔澶囦俊鎭�,鏃犳硶鎵ц銆備粨搴撶紪鐮�=" + grainData.getDepotId());
+            //鏍规嵁绯荤粺浠撳簱缂栫爜鑾峰彇閰嶇疆璁惧淇℃伅
+            GatewayDevice device = GatewayUtils.getCacheByDepotSysId(grainData.getDepotId());
+
+            if (null == device) {
+                resp.setMsg("缃戝叧涓病鏈夎幏鍙栧埌閰嶇疆鐨勭粓绔澶囦俊鎭�,鏃犳硶鎵ц銆備粨搴撶紪鐮�=" + grainData.getDepotId());
+                resp.setCode(BaseResp.CODE_500);
+                return resp;
+            }
+
+            //鏁版嵁灏佽杞崲
+            GatewayDeviceReportService reportService = gatewayRemoteManager.getDeviceReportService(device.getPushProtocol());
+            if (null == reportService) {
+                log.error("------------绮儏鎺ㄩ�佸け璐ワ紝绯荤粺涓嶅瓨鍦ㄥ綋鍓嶅崗璁墽琛岀被----{}", device.getDeviceName());
+                resp.setMsg("绮儏鎺ㄩ�佸け璐ワ紝绯荤粺涓嶅瓨鍦ㄥ綋鍓嶅崗璁墽琛岀被锛岀綉鍏宠澶�=" + device.getDeviceName());
+                resp.setCode(BaseResp.CODE_500);
+                return resp;
+            }
+
+            //鏁版嵁灏佽
+            resp = reportService.grainData2GatewayApiInfo(grainData, device);
+
+            BaseReqData reqData = new BaseReqData();
+            reqData.setProductId(device.getProductId());
+            reqData.setDeviceName(device.getDeviceName());
+            reqData.setDeviceId(device.getDeviceId());
+
+            reqData.setDevice(device);
+            reqData.setData(resp.getData());
+
+            //鎵嬪姩鎺ㄩ�佸埌骞冲彴
+            resp = reportService.reportGrainDataByHand(reqData);
+
+        } catch (Exception e) {
+            log.error("-----------鎵嬪姩鎺ㄩ�佺伯鎯呮暟鎹墽琛屽紓甯�---{}", e);
             resp.setCode(BaseResp.CODE_500);
-            return resp;
+            resp.setMsg("鎵ц寮傚父:" + e.getMessage());
         }
-
-        //鏁版嵁灏佽杞崲
-        GatewayDeviceReportService reportService = gatewayRemoteManager.getDeviceReportService(device.getPushProtocol());
-        if (null == reportService) {
-            log.error("------------绮儏鎺ㄩ�佸け璐ワ紝绯荤粺涓嶅瓨鍦ㄥ綋鍓嶅崗璁墽琛岀被----{}", device.getDeviceName());
-            resp.setMsg("绮儏鎺ㄩ�佸け璐ワ紝绯荤粺涓嶅瓨鍦ㄥ綋鍓嶅崗璁墽琛岀被锛岀綉鍏宠澶�=" + device.getDeviceName());
-            resp.setCode(BaseResp.CODE_500);
-            return resp;
-        }
-
-        //鏁版嵁灏佽
-        resp = reportService.grainData2GatewayApiInfo(grainData, device);
-
-        BaseReqData reqData = new BaseReqData();
-        reqData.setProductId(device.getProductId());
-        reqData.setDeviceName(device.getDeviceName());
-        reqData.setDeviceId(device.getDeviceId());
-
-        reqData.setDevice(device);
-
-        //鎵嬪姩鎺ㄩ�佸埌骞冲彴
-        resp = reportService.reportGrainDataByHand(reqData);
-
-
         return resp;
     }
-
 }

--
Gitblit v1.9.3