Commit d6544c0c711c3a81d675b5891462e07a645ddb3b

Authored by 648540858
1 parent 720231d3

添加媒体服务器节点管理ui-移除接口

src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
... ... @@ -81,6 +81,7 @@ public class ZLMRunner implements CommandLineRunner {
81 81 if (startGetMedia == null) startGetMedia = new HashMap<>();
82 82 startGetMedia.put(mediaServerItem.getId(), true);
83 83 new Thread(() -> {
  84 +
84 85 ZLMServerConfig zlmServerConfig = getMediaServerConfig(mediaServerItem);
85 86 if (zlmServerConfig != null) {
86 87 zlmServerConfig.setIp(mediaServerItem.getIp());
... ... @@ -88,6 +89,7 @@ public class ZLMRunner implements CommandLineRunner {
88 89 startGetMedia.remove(mediaServerItem.getId());
89 90 mediaServerService.handLeZLMServerConfig(zlmServerConfig);
90 91 }
  92 +
91 93 }).start();
92 94 }
93 95 Timer timer = new Timer();
... ... @@ -109,6 +111,9 @@ public class ZLMRunner implements CommandLineRunner {
109 111  
110 112 public ZLMServerConfig getMediaServerConfig(MediaServerItem mediaServerItem) {
111 113 if (startGetMedia == null) { return null;}
  114 + if (mediaServerService.getOne(mediaServerItem.getId()) == null) {
  115 + return null;
  116 + }
112 117 if ( startGetMedia.get(mediaServerItem.getId()) == null || !startGetMedia.get(mediaServerItem.getId())) {
113 118 return null;
114 119 }
... ...
src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java
... ... @@ -57,4 +57,6 @@ public interface IMediaServerService {
57 57 WVPResult<MediaServerItem> checkMediaServer(String ip, int port, String secret);
58 58  
59 59 boolean checkMediaRecordServer(String ip, int port);
  60 +
  61 + void delete(String id);
60 62 }
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
... ... @@ -519,4 +519,12 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR
519 519  
520 520 return result;
521 521 }
  522 +
  523 + @Override
  524 + public void delete(String id) {
  525 + redisUtil.zRemove(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX, id);
  526 + String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + id;
  527 + redisUtil.del(key);
  528 + mediaServerMapper.delOne(id);
  529 + }
522 530 }
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
... ... @@ -129,7 +129,7 @@ public class ServerController {
129 129 })
130 130 @PostMapping(value = "/media_server/save")
131 131 @ResponseBody
132   - public WVPResult<String> checkMediaServer(@RequestBody MediaServerItem mediaServerItem){
  132 + public WVPResult<String> saveMediaServer(@RequestBody MediaServerItem mediaServerItem){
133 133 if (mediaServerService.getOne(mediaServerItem.getId()) != null) {
134 134 mediaServerService.update(mediaServerItem);
135 135 }else {
... ... @@ -141,6 +141,27 @@ public class ServerController {
141 141 return result;
142 142 }
143 143  
  144 + @ApiOperation("移除流媒体服务")
  145 + @ApiImplicitParams({
  146 + @ApiImplicitParam(name="id", value = "流媒体ID", dataTypeClass = String.class)
  147 + })
  148 + @DeleteMapping(value = "/media_server/delete")
  149 + @ResponseBody
  150 + public WVPResult<String> deleteMediaServer(@RequestParam String id){
  151 + if (mediaServerService.getOne(id) != null) {
  152 + mediaServerService.delete(id);
  153 + }else {
  154 + WVPResult<String> result = new WVPResult<>();
  155 + result.setCode(-1);
  156 + result.setMsg("未找到此节点");
  157 + return result;
  158 + }
  159 + WVPResult<String> result = new WVPResult<>();
  160 + result.setCode(0);
  161 + result.setMsg("success");
  162 + return result;
  163 + }
  164 +
144 165  
145 166  
146 167 @ApiOperation("重启服务")
... ...
web_src/src/components/MediaServerManger.vue
... ... @@ -18,9 +18,10 @@
18 18 <div class="card-img-zlm"></div>
19 19 <div style="padding: 14px;text-align: left">
20 20 <span style="font-size: 16px">{{item.id}}</span>
  21 + <el-button icon="el-icon-edit" style="padding: 0;float: right;" type="text" @click="edit(item)">编辑</el-button>
  22 + <el-button icon="el-icon-delete" style="margin-right: 10px;padding: 0;float: right;" type="text" @click="del(item)">移除</el-button>
21 23 <div style="margin-top: 13px; line-height: 12px; ">
22 24 <span style="font-size: 14px; color: #999; margin-top: 5px">创建时间: {{item.createTime}}</span>
23   - <el-button icon="el-icon-edit" style="padding: 0;float: right;" type="text" @click="edit(item)">编辑</el-button>
24 25 </div>
25 26 </div>
26 27 <i v-if="item.status" class="iconfont icon-online server-card-status-online" title="在线"></i>
... ... @@ -88,6 +89,25 @@
88 89 edit: function (row){
89 90 this.$refs.mediaServerEdit.openDialog(row, this.initData)
90 91 },
  92 + del: function (row){
  93 + this.$confirm('确认删除此节点?', '提示', {
  94 + confirmButtonText: '确定',
  95 + cancelButtonText: '取消',
  96 + type: 'warning'
  97 + }).then(() => {
  98 + this.mediaServerObj.delete(row.id, (data)=>{
  99 + if (data.code === 0) {
  100 + this.$message({
  101 + type: 'success',
  102 + message: '删除成功!'
  103 + });
  104 + }
  105 + })
  106 +
  107 + }).catch(() => {
  108 + });
  109 +
  110 + },
91 111 getNumberByWidth(){
92 112 let candidateNums = [1, 2, 3, 4, 6, 8, 12, 24]
93 113 let clientWidth = window.innerWidth - 30;
... ...
web_src/src/components/service/MediaServer.js
... ... @@ -80,6 +80,20 @@ class MediaServer{
80 80 console.log(error);
81 81 });
82 82 }
  83 +
  84 + delete(id, callback) {
  85 + this.$axios({
  86 + method: 'delete',
  87 + url:`/api/server/media_server/delete`,
  88 + params: {
  89 + id: id
  90 + }
  91 + }).then(function (res) {
  92 + if (typeof (callback) == "function") callback(res.data)
  93 + }).catch(function (error) {
  94 + console.log(error);
  95 + });
  96 + }
83 97 }
84 98  
85 99 export default MediaServer;
... ...