瀏覽代碼

wifi禁用设备,以及兼容G100、G300、G600型号的云盒

zhj 2 年之前
父節點
當前提交
ab19cac747

+ 1 - 0
src/main/java/com/welampiot/common/InterfaceResultEnum.java

@@ -96,6 +96,7 @@ public enum InterfaceResultEnum {
     LACK_WIFI_TYPE_ERROR("0289","WiFi安全选项不能为空","The WiFi security option cannot be empty","Опция безопасности WiFi не может быть пустой"),
     WIFI_NAME_LENGTH_ERROR("0290","WiFi名字长度不能超过30位","The length of the WiFi name cannot exceed 30 characters","Длина имени WiFi не может превышать 30 бит"),
     WIFI_PWD_LENGTH_ERROR("0291","WiFi密码长度要在8~30之间","The length of the WiFi password must be between 8 and 30","Длина пароля от 8 до 30"),
+    LACK_WIFI_MAC_ADDRESS_ERROR("0292","mac地址不能为空","The mac address cannot be empty","Мак-адрес не может быть пустым"),
     ;
     private String code;
     private String msgCn;

+ 74 - 12
src/main/java/com/welampiot/controller/MapController.java

@@ -1919,8 +1919,17 @@ public class MapController{
         if (lampPoleId == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
         WifiDTO wifiDTO = wifiService.getWifiInfoByLampPoleId(lampPoleId);
         if (wifiDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
-        String sendTopic = "/WEGW2/ReadIn/" + wifiDTO.getNum();
-        String resTopic = "/WEGW2/ReadOut/" + wifiDTO.getNum();
+        String sendTopic = "", resTopic = "";
+        if (wifiDTO.getModel() == 1 || wifiDTO.getModel() == 5) {
+            sendTopic = "/WEGW2/ReadIn/" + wifiDTO.getNum();
+            resTopic = "/WEGW2/ReadOut/" + wifiDTO.getNum();
+        } else if (wifiDTO.getModel() == 3 || wifiDTO.getModel() == 6) {
+            sendTopic = "/WEGW3/ReadIn/" + wifiDTO.getNum();
+            resTopic = "/WEGW3/ReadOut/" + wifiDTO.getNum();
+        } else if (wifiDTO.getModel() == 0) {
+            sendTopic = "/WEGW/ReadIn/" + wifiDTO.getNum();
+            resTopic = "/WEGW/ReadOut/" + wifiDTO.getNum();
+        }
         String cmd = "0001B10B";
         String cmd1 = "0001AA01";
         byte[] bytes = toolUtils.hexString2Bytes(cmd);
@@ -1973,22 +1982,22 @@ public class MapController{
             wifiInfoVO.setWifiNet("4G");
         }
         switch (wifiDTO.getModel()) {
-            case "6":
+            case 6:
                 wifiInfoVO.setWifiModel("WE-GW-G600");
                 break;
-            case "5":
+            case 5:
                 wifiInfoVO.setWifiModel("WE-GW-G260");
                 break;
-            case "4":
+            case 4:
                 wifiInfoVO.setWifiModel("WE-XA-G20");
                 break;
-            case "3":
+            case 3:
                 wifiInfoVO.setWifiModel("WE-GW-G300");
                 break;
-            case "2":
+            case 2:
                 wifiInfoVO.setWifiModel("WE-GW-G40");
                 break;
-            case "1":
+            case 1:
                 wifiInfoVO.setWifiModel("WE-GW-G200");
                 break;
             default:
@@ -2023,8 +2032,19 @@ public class MapController{
             return toolUtils.response(InterfaceResultEnum.WIFI_NAME_LENGTH_ERROR,version);
         if (wifiPwd.length() < 8 || wifiPwd.length() > 30)
             return toolUtils.response(InterfaceResultEnum.WIFI_PWD_LENGTH_ERROR,version);
-        String sendTopic = "/WEGW2/WriteIn/" + wifiDTO.getNum();
-        String resTopic = "/WEGW2/WriteOut/" + wifiDTO.getNum();
+        String sendTopic = "", resTopic = "";
+        if (wifiDTO.getModel() == 1 || wifiDTO.getModel() == 5) {
+            sendTopic = "/WEGW2/WriteIn/" + wifiDTO.getNum();
+            resTopic = "/WEGW2/WriteOut/" + wifiDTO.getNum();
+        } else if (wifiDTO.getModel() == 3 || wifiDTO.getModel() == 6) {
+            sendTopic = "/WEGW3/WriteIn/" + wifiDTO.getNum();
+            resTopic = "/WEGW3/WriteOut/" + wifiDTO.getNum();
+        } else if (wifiDTO.getModel() == 0) {
+            sendTopic = "/WEGW/WriteIn/" + wifiDTO.getNum();
+            resTopic = "/WEGW/WriteOut/" + wifiDTO.getNum();
+        }
+        System.out.println("sendTopic:" + sendTopic);
+        System.out.println("resTopic:" + resTopic);
         String cmd = "01" + "{\"B1\":\"" + wifiName + "\",\"B2\":" + wifiType +  ",\"B3\":\"" + wifiPwd + "\"}";
         System.out.println("cmd:" + cmd);
         String resCmd = toolUtils.sendMqttCmd(sendTopic, cmd, resTopic);
@@ -2045,8 +2065,17 @@ public class MapController{
         WifiDTO wifiDTO = wifiService.getWifiInfoByLampPoleId(lampPoleId);
         if (wifiDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
         Integer status = (Integer) toolUtils.getRequestContent(request,"status",1);
-        String sendTopic = "/WEGW2/WriteIn/" + wifiDTO.getNum();
-        String resTopic = "/WEGW2/WriteOut/" + wifiDTO.getNum();
+        String sendTopic = "", resTopic = "";
+        if (wifiDTO.getModel() == 1 || wifiDTO.getModel() == 5) {
+            sendTopic = "/WEGW2/WriteIn/" + wifiDTO.getNum();
+            resTopic = "/WEGW2/WriteOut/" + wifiDTO.getNum();
+        } else if (wifiDTO.getModel() == 3 || wifiDTO.getModel() == 6) {
+            sendTopic = "/WEGW3/WriteIn/" + wifiDTO.getNum();
+            resTopic = "/WEGW3/WriteOut/" + wifiDTO.getNum();
+        } else if (wifiDTO.getModel() == 0) {
+            sendTopic = "/WEGW/WriteIn/" + wifiDTO.getNum();
+            resTopic = "/WEGW/WriteOut/" + wifiDTO.getNum();
+        }
         String cmd = "01" + "{\"B4\":" + status + "}";
         System.out.println("cmd:" + cmd);
         String resCmd = toolUtils.sendMqttCmd(sendTopic, cmd, resTopic);
@@ -2057,4 +2086,37 @@ public class MapController{
         wifiService.updateWifiStatus(dto);
         return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
     }
+
+    /**
+     * WiFi禁用设备
+     * @param request lampPoleId
+     * @return wifi禁用或解禁设备
+     */
+    @RequestMapping(value = "/wifiDisable", method = RequestMethod.POST)
+    public BaseResult<?> wifiDisable(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        Integer lampPoleId = (Integer) toolUtils.getRequestContent(request,"lampPoleId",1);
+        if (lampPoleId == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        WifiDTO wifiDTO = wifiService.getWifiInfoByLampPoleId(lampPoleId);
+        if (wifiDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
+        Integer status = (Integer) toolUtils.getRequestContent(request,"status",1);
+        String macAddress = (String) toolUtils.getRequestContent(request,"macAddress",2);
+        if (macAddress.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_WIFI_MAC_ADDRESS_ERROR,version);
+        String sendTopic = "", resTopic = "";
+        if (wifiDTO.getModel() == 1 || wifiDTO.getModel() == 5) {
+            sendTopic = "/WEGW2/WriteIn/" + wifiDTO.getNum();
+            resTopic = "/WEGW2/WriteOut/" + wifiDTO.getNum();
+        } else if (wifiDTO.getModel() == 3 || wifiDTO.getModel() == 6) {
+            sendTopic = "/WEGW3/WriteIn/" + wifiDTO.getNum();
+            resTopic = "/WEGW3/WriteOut/" + wifiDTO.getNum();
+        } else if (wifiDTO.getModel() == 0) {
+            sendTopic = "/WEGW/WriteIn/" + wifiDTO.getNum();
+            resTopic = "/WEGW/WriteOut/" + wifiDTO.getNum();
+        }
+        String cmd = "01" + "{\"BC\":\"" + macAddress + "|" + status + "\"}";
+        System.out.println("cmd:" + cmd);
+        String resCmd = toolUtils.sendMqttCmd(sendTopic, cmd, resTopic);
+        System.out.println("resCmd:" + resCmd);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
+    }
 }

+ 1 - 1
src/main/java/com/welampiot/dto/WifiDTO.java

@@ -23,7 +23,7 @@ public class WifiDTO implements Serializable {
      * 3 WE-GW-G300,4 WE-XA-G20(云盒加4G双控设备),
      * 5 WE-GW-G260,6 WE-GW-G600)
      **/
-    private String model;
+    private Integer model;
 
     /** 序列号IMEI **/
     private String num;

+ 2 - 2
src/main/java/com/welampiot/service/impl/LampPoleServiceImpl.java

@@ -152,7 +152,7 @@ public class LampPoleServiceImpl implements LampPoleService {
         wifiDTO.setVersion2(lampPoleVO.getVersion());
         if (cloudBox.containsKey("sn")) wifiDTO.setSn((String) cloudBox.get("sn"));
         if (cloudBox.containsKey("ipAddr")) wifiDTO.setIpAddr((String) cloudBox.get("ipAddr"));
-        if (cloudBox.containsKey("model")) wifiDTO.setModel((String) cloudBox.get("model"));
+        if (cloudBox.containsKey("model")) wifiDTO.setModel((Integer) cloudBox.get("model"));
         if (cloudBox.containsKey("remark1")) wifiDTO.setRemark1((String) cloudBox.get("remark1"));
         if (cloudBox.containsKey("remark2")) wifiDTO.setRemark2((String) cloudBox.get("remark2"));
         if (cloudBox.containsKey("remark3")) wifiDTO.setRemark3((String) cloudBox.get("remark3"));
@@ -243,7 +243,7 @@ public class LampPoleServiceImpl implements LampPoleService {
         wifiDTO.setVersion2(lampPoleVO.getVersion());
         if (cloudBox.containsKey("sn")) wifiDTO.setSn((String) cloudBox.get("sn"));
         if (cloudBox.containsKey("ipAddr")) wifiDTO.setIpAddr((String) cloudBox.get("ipAddr"));
-        if (cloudBox.containsKey("model")) wifiDTO.setModel((String) cloudBox.get("model"));
+        if (cloudBox.containsKey("model")) wifiDTO.setModel((Integer) cloudBox.get("model"));
         if (cloudBox.containsKey("remark1")) wifiDTO.setRemark1((String) cloudBox.get("remark1"));
         if (cloudBox.containsKey("remark2")) wifiDTO.setRemark2((String) cloudBox.get("remark2"));
         if (cloudBox.containsKey("remark3")) wifiDTO.setRemark3((String) cloudBox.get("remark3"));