Commit 9c5b1060af4e6c468b2cf95fbb9ec6d0a05fad5c
1 parent
0cd86a79
支持删除在线设备
Showing
2 changed files
with
38 additions
and
27 deletions
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
| ... | ... | @@ -204,10 +204,7 @@ public class DeviceQuery { |
| 204 | 204 | if (logger.isDebugEnabled()) { |
| 205 | 205 | logger.debug("设备信息删除API调用,deviceId:" + deviceId); |
| 206 | 206 | } |
| 207 | - | |
| 208 | - if (offLineDetector.isOnline(deviceId)) { | |
| 209 | - return new ResponseEntity<String>("不允许删除在线设备!", HttpStatus.NOT_ACCEPTABLE); | |
| 210 | - } | |
| 207 | + | |
| 211 | 208 | // 清除redis记录 |
| 212 | 209 | boolean isSuccess = storager.delete(deviceId); |
| 213 | 210 | if (isSuccess) { |
| ... | ... | @@ -319,20 +316,20 @@ public class DeviceQuery { |
| 319 | 316 | if (!StringUtils.isEmpty(device.getCharset())) deviceInStore.setCharset(device.getCharset()); |
| 320 | 317 | if (!StringUtils.isEmpty(device.getMediaServerId())) deviceInStore.setMediaServerId(device.getMediaServerId()); |
| 321 | 318 | |
| 322 | - if ((deviceInStore.getSubscribeCycleForCatalog() <=0 && device.getSubscribeCycleForCatalog() > 0) | |
| 323 | - || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) { | |
| 324 | - deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog()); | |
| 325 | - // 开启订阅 | |
| 326 | - deviceService.addCatalogSubscribe(deviceInStore); | |
| 327 | - } | |
| 328 | - if (deviceInStore.getSubscribeCycleForCatalog() > 0 && device.getSubscribeCycleForCatalog() <= 0) { | |
| 329 | - deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog()); | |
| 330 | - // 取消订阅 | |
| 331 | - deviceService.removeCatalogSubscribe(deviceInStore); | |
| 319 | + if (device.getSubscribeCycleForCatalog() > 0) { | |
| 320 | + if (deviceInStore.getSubscribeCycleForCatalog() == 0 || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) { | |
| 321 | + // 开启订阅 | |
| 322 | + deviceService.addCatalogSubscribe(deviceInStore); | |
| 323 | + } | |
| 324 | + }else if (device.getSubscribeCycleForCatalog() == 0) { | |
| 325 | + if (deviceInStore.getSubscribeCycleForCatalog() != 0) { | |
| 326 | + // 取消订阅 | |
| 327 | + deviceService.removeCatalogSubscribe(deviceInStore); | |
| 328 | + } | |
| 332 | 329 | } |
| 333 | 330 | |
| 334 | - storager.updateDevice(deviceInStore); | |
| 335 | - cmder.deviceInfoQuery(deviceInStore); | |
| 331 | + storager.updateDevice(device); | |
| 332 | + cmder.deviceInfoQuery(device); | |
| 336 | 333 | } |
| 337 | 334 | WVPResult<String> result = new WVPResult<>(); |
| 338 | 335 | result.setCode(0); | ... | ... |
web_src/src/components/DeviceList.vue
| ... | ... | @@ -55,14 +55,14 @@ |
| 55 | 55 | <el-table-column prop="createTime" label="创建时间" align="center" width="140"> |
| 56 | 56 | </el-table-column> |
| 57 | 57 | |
| 58 | - <el-table-column label="操作" width="360" align="center" fixed="right"> | |
| 58 | + <el-table-column label="操作" width="450" align="center" fixed="right"> | |
| 59 | 59 | <template slot-scope="scope"> |
| 60 | 60 | <el-button size="mini" :ref="scope.row.deviceId + 'refbtn' " v-if="scope.row.online!=0" icon="el-icon-refresh" @click="refDevice(scope.row)">刷新</el-button> |
| 61 | 61 | <el-button-group> |
| 62 | 62 | <el-button size="mini" icon="el-icon-video-camera-solid" v-bind:disabled="scope.row.online==0" type="primary" @click="showChannelList(scope.row)">通道</el-button> |
| 63 | 63 | <el-button size="mini" icon="el-icon-location" v-bind:disabled="scope.row.online==0" type="primary" @click="showDevicePosition(scope.row)">定位</el-button> |
| 64 | 64 | <el-button size="mini" icon="el-icon-edit" type="primary" @click="edit(scope.row)">编辑</el-button> |
| 65 | - <el-button size="mini" icon="el-icon-delete" type="danger" v-if="scope.row.online==0" @click="deleteDevice(scope.row)">删除</el-button> | |
| 65 | + <el-button size="mini" icon="el-icon-delete" type="danger" @click="deleteDevice(scope.row)">删除</el-button> | |
| 66 | 66 | </el-button-group> |
| 67 | 67 | </template> |
| 68 | 68 | </el-table-column> |
| ... | ... | @@ -165,15 +165,29 @@ |
| 165 | 165 | |
| 166 | 166 | }, |
| 167 | 167 | deleteDevice: function(row) { |
| 168 | - let that = this; | |
| 169 | - this.$axios({ | |
| 170 | - method: 'delete', | |
| 171 | - url:`/api/device/query/devices/${row.deviceId}/delete` | |
| 172 | - }).then((res)=>{ | |
| 173 | - this.getDeviceList(); | |
| 174 | - }).catch((error) =>{ | |
| 175 | - console.log(error); | |
| 176 | - }); | |
| 168 | + let msg = "确定删除此设备?" | |
| 169 | + if (row.online !== 0) { | |
| 170 | + msg = "在线设备删除后仍可通过注册再次上线。<br/>如需彻底删除请先将设备离线。<br/><strong>确定删除此设备?</strong>" | |
| 171 | + } | |
| 172 | + this.$confirm(msg, '提示', { | |
| 173 | + dangerouslyUseHTMLString : true, | |
| 174 | + confirmButtonText: '确定', | |
| 175 | + cancelButtonText: '取消', | |
| 176 | + center: true, | |
| 177 | + type: 'warning' | |
| 178 | + }).then(() => { | |
| 179 | + this.$axios({ | |
| 180 | + method: 'delete', | |
| 181 | + url:`/api/device/query/devices/${row.deviceId}/delete` | |
| 182 | + }).then((res)=>{ | |
| 183 | + this.getDeviceList(); | |
| 184 | + }).catch((error) =>{ | |
| 185 | + console.log(error); | |
| 186 | + }); | |
| 187 | + }).catch(() => { | |
| 188 | + | |
| 189 | + }); | |
| 190 | + | |
| 177 | 191 | |
| 178 | 192 | }, |
| 179 | 193 | showChannelList: function(row) { | ... | ... |