puzhibing
2024-10-29 32291a03e69e7c3bdb627c893d52eebde0b140fe
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java
@@ -170,19 +170,19 @@
         return AjaxResult.error("设备编号已存在");
      }
      //调用华为Iot创建设备
      AddDevice addDevice = new AddDevice();
      addDevice.setProductId("66da68d21837002b28b34ec0");
      addDevice.setNodeId(chargingPile.getCode());
      addDevice.setDeviceName(chargingPile.getName());
      addDevice.setDescription(chargingPile.getNumber().toString());
      AddDeviceResp deviceResp = iotInterfaceClient.addDevice(addDevice).getData();
      if(null != deviceResp){
         int httpStatusCode = deviceResp.getHttpStatusCode();
         if(httpStatusCode == 201){
            chargingPile.setIotdDeviceId(deviceResp.getDeviceId());
            this.save(chargingPile);
         }
      }
//      AddDevice addDevice = new AddDevice();
//      addDevice.setProductId("66da68d21837002b28b34ec0");
//      addDevice.setNodeId(chargingPile.getCode());
//      addDevice.setDeviceName(chargingPile.getName());
//      addDevice.setDescription(chargingPile.getNumber().toString());
//      AddDeviceResp deviceResp = iotInterfaceClient.addDevice(addDevice).getData();
//      if(null != deviceResp){
//         int httpStatusCode = deviceResp.getHttpStatusCode();
//         if(httpStatusCode == 201){
//            chargingPile.setIotdDeviceId(deviceResp.getDeviceId());
//         }
//      }
      this.save(chargingPile);
      return AjaxResult.success();
   }
   
@@ -266,12 +266,12 @@
      for (Integer id : ids) {
         TChargingPile chargingPile = this.getById(id);
         //调用华为Iot删除设备
         if(StringUtils.isNotEmpty(chargingPile.getIotdDeviceId())){
            DeleteDeviceResp deviceResp = iotInterfaceClient.deleteDevice(chargingPile.getIotdDeviceId()).getData();
            if(null != deviceResp && deviceResp.getHttpStatusCode() == 0){
               this.removeById(chargingPile);
            }
         }
//         if(StringUtils.isNotEmpty(chargingPile.getIotdDeviceId())){
//            DeleteDeviceResp deviceResp = iotInterfaceClient.deleteDevice(chargingPile.getIotdDeviceId()).getData();
//            if(null != deviceResp && deviceResp.getHttpStatusCode() == 0){
//            }
//         }
         this.removeById(chargingPile);
      }
      return AjaxResult.success();
   }