From d454e51e06dbf7beb50551588fc58a5810295d7c Mon Sep 17 00:00:00 2001
From: jiazx0107@163.com <jiazx0107@163.com>
Date: 星期一, 01 一月 2024 19:28:22 +0800
Subject: [PATCH] 调整KFKA数据推送测试。

---
 src/main/java/com/fzzy/gateway/controller/GatewayDeviceController.java |  160 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 157 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/fzzy/gateway/controller/GatewayDeviceController.java b/src/main/java/com/fzzy/gateway/controller/GatewayDeviceController.java
index 0d6b52a..a533499 100644
--- a/src/main/java/com/fzzy/gateway/controller/GatewayDeviceController.java
+++ b/src/main/java/com/fzzy/gateway/controller/GatewayDeviceController.java
@@ -1,8 +1,10 @@
 package com.fzzy.gateway.controller;
 
+import com.fzzy.api.data.GatewayDeviceProtocol;
 import com.fzzy.api.data.GatewayDeviceType;
 import com.fzzy.gateway.GatewayUtils;
 import com.fzzy.gateway.api.GatewayRemoteManager;
+import com.fzzy.gateway.api.GatewaySyncLprService;
 import com.fzzy.gateway.data.BaseResp;
 import com.fzzy.gateway.data.BaseReqData;
 import com.fzzy.gateway.entity.GateWayParam;
@@ -69,6 +71,143 @@
         return "SUCCESS";
     }
 
+
+    /**
+     * 涓嬭鍒嗘満娴嬭瘯鍏ュ彛
+     *
+     * @param param
+     * @return
+     */
+    @PostMapping("/test/IDE")
+    public @ResponseBody
+    String testIDE(@RequestBody GateWayParam param) throws Exception {
+
+        if (StringUtils.isEmpty(param.getBizType())) {
+            return "ERROR:娌℃湁鑾峰彇鍒颁笟鍔$被鍨嬶紝鎵ц澶辫触";
+        }
+
+        //鑾峰彇鍒嗘満閰嶇疆
+        if ("syncConf".equals(param.getBizType())) {
+            return syncConf(param);
+        }
+
+        if ("writeConf".equals(param.getBizType())) {
+            return writeConf(param);
+        }
+
+        if ("initParam".equals(param.getBizType())) {
+            return initCable(param);
+        }
+
+        if ("disconnect".equals(param.getBizType())) {
+            return disconnect(param);
+        }
+
+        if ("transparent".equals(param.getBizType())) {
+            return transparent(param);
+        }
+
+        return "SUCCESS";
+    }
+
+
+    private String transparent(GateWayParam param) {
+
+        String deviceId = param.getDeviceId();
+
+        GatewayDevice device = GatewayUtils.getCacheByDeviceId(deviceId);
+
+        BaseReqData reqData = new BaseReqData();
+        reqData.setDeviceId(device.getDeviceId());
+        reqData.setProductId(device.getProductId());
+        reqData.setDeviceName(device.getDeviceName());
+        reqData.setDevice(device);
+        reqData.setAutoReplay(false);
+
+        BaseResp resp = gatewayRemoteManager.getSyncGrainService(device.getSyncProtocol()).transparent(reqData);
+        if (BaseResp.CODE_200 != resp.getCode()) {
+            return "ERROR锛�" + resp.getMsg();
+        }
+        return "SUCCESS";
+    }
+
+    private String disconnect(GateWayParam param) {
+        String deviceId = param.getDeviceId();
+
+        GatewayDevice device = GatewayUtils.getCacheByDeviceId(deviceId);
+
+        BaseReqData reqData = new BaseReqData();
+        reqData.setDeviceId(device.getDeviceId());
+        reqData.setProductId(device.getProductId());
+        reqData.setDeviceName(device.getDeviceName());
+        reqData.setDevice(device);
+        reqData.setAutoReplay(false);
+
+        BaseResp resp = gatewayRemoteManager.getSyncGrainService(device.getSyncProtocol()).disconnect(reqData);
+        if (BaseResp.CODE_200 != resp.getCode()) {
+            return "ERROR锛�" + resp.getMsg();
+        }
+        return "SUCCESS";
+    }
+
+    private String initCable(GateWayParam param) {
+        String deviceId = param.getDeviceId();
+
+        GatewayDevice device = GatewayUtils.getCacheByDeviceId(deviceId);
+
+        BaseReqData reqData = new BaseReqData();
+        reqData.setDeviceId(device.getDeviceId());
+        reqData.setProductId(device.getProductId());
+        reqData.setDeviceName(device.getDeviceName());
+        reqData.setDevice(device);
+        reqData.setAutoReplay(false);
+
+        BaseResp resp = gatewayRemoteManager.getSyncGrainService(device.getSyncProtocol()).initCable(reqData);
+        if (BaseResp.CODE_200 != resp.getCode()) {
+            return "ERROR锛�" + resp.getMsg();
+        }
+        return "SUCCESS";
+    }
+
+    private String syncConf(GateWayParam param) {
+
+        String deviceId = param.getDeviceId();
+
+        GatewayDevice device = GatewayUtils.getCacheByDeviceId(deviceId);
+
+        BaseReqData reqData = new BaseReqData();
+        reqData.setDeviceId(device.getDeviceId());
+        reqData.setProductId(device.getProductId());
+        reqData.setDeviceName(device.getDeviceName());
+        reqData.setDevice(device);
+        reqData.setAutoReplay(false);
+
+        BaseResp resp = gatewayRemoteManager.getSyncGrainService(device.getSyncProtocol()).syncConf(reqData);
+        if (BaseResp.CODE_200 != resp.getCode()) {
+            return "ERROR锛�" + resp.getMsg();
+        }
+        return "SUCCESS";
+    }
+
+    private String writeConf(GateWayParam param) {
+        String deviceId = param.getDeviceId();
+
+        GatewayDevice device = GatewayUtils.getCacheByDeviceId(deviceId);
+
+        BaseReqData reqData = new BaseReqData();
+        reqData.setDeviceId(device.getDeviceId());
+        reqData.setProductId(device.getProductId());
+        reqData.setDeviceName(device.getDeviceName());
+        reqData.setDevice(device);
+        reqData.setAutoReplay(false);
+
+        BaseResp resp = gatewayRemoteManager.getSyncGrainService(device.getSyncProtocol()).writeConf(reqData);
+        if (BaseResp.CODE_200 != resp.getCode()) {
+            return "ERROR锛�" + resp.getMsg();
+        }
+        return "SUCCESS";
+    }
+
     /**
      * 鍒濆鍖栬溅鐗岃瘑鍒�
      *
@@ -86,7 +225,8 @@
         }
 
         BaseReqData reqData;
-        int i = 1;
+        int i = 0;
+        GatewaySyncLprService syncLprService;
         for (GatewayDevice device : list) {
 
             if (!GatewayDeviceType.TYPE_02.getCode().equals(device.getType())) {
@@ -94,7 +234,9 @@
             }
             reqData = new BaseReqData(device);
             reqData.setIndex(i);
-            gatewayRemoteManager.getSyncLprService(device.getSyncProtocol()).initLpr(reqData);
+            syncLprService = gatewayRemoteManager.getSyncLprService(device.getSyncProtocol());
+            if (null == syncLprService) continue;
+            syncLprService.initLpr(reqData);
             i++;
         }
 
@@ -121,7 +263,14 @@
             return "ERROR锛氬綋鍓嶈澶囨病鏈夐厤缃竷绾胯鍒欙紝鏃犳硶鎵ц";
         }
 
-        BaseResp resp = gatewayRemoteManager.getGatewayTestService(device.getPushProtocol()).testGrain(reqData);
+        BaseResp resp;
+        if (GatewayDeviceProtocol.DEVICE_TEST.getCode().equals(device.getSyncProtocol())) {
+            resp = gatewayRemoteManager.getGatewayTestService(device.getPushProtocol()).testGrain(reqData);
+        } else {
+            reqData.setAutoReplay(false);
+            resp = gatewayRemoteManager.getSyncGrainService(device.getSyncProtocol()).syncGrain(reqData);
+        }
+
         //鑷姩鎺ㄩ��
         if (BaseResp.CODE_200 == resp.getCode() && reqData.isAutoReplay()) {
             reqData.setData(resp.getData());
@@ -147,6 +296,11 @@
         BaseReqData reqData;
         BaseResp resp;
         for (GatewayDevice device : list) {
+
+            //濡傛灉涓嶆槸绮儏鍒嗘満璺宠繃
+            if (!GatewayDeviceType.TYPE_07.getCode().equals(device.getType())) {
+                continue;
+            }
             reqData = new BaseReqData();
             reqData.setDeviceId(param.getDeviceId());
             reqData.setDayTime(param.getDayTime());

--
Gitblit v1.9.3