| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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(); |
| | | } |