Commit e29d94c83f62960bb1d6dacac4c978debc85c5ef
1 parent
eefe6f4c
增加推流添加功能,修复级联目录推送
Showing
12 changed files
with
139 additions
and
32 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| ... | ... | @@ -419,7 +419,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 419 | 419 | } |
| 420 | 420 | } |
| 421 | 421 | } else if (gbStream != null) { |
| 422 | - if (streamPushItem.isStatus()) { | |
| 422 | + if (streamPushItem != null && streamPushItem.isStatus()) { | |
| 423 | 423 | // 在线状态 |
| 424 | 424 | pushStream(evt, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, |
| 425 | 425 | mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); |
| ... | ... | @@ -428,9 +428,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 428 | 428 | notifyStreamOnline(evt, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, |
| 429 | 429 | mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); |
| 430 | 430 | } |
| 431 | - | |
| 432 | 431 | } |
| 433 | - | |
| 434 | 432 | } |
| 435 | 433 | |
| 436 | 434 | } catch (SipException | InvalidArgumentException | ParseException e) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
| ... | ... | @@ -22,7 +22,10 @@ import com.github.pagehelper.PageInfo; |
| 22 | 22 | import org.slf4j.Logger; |
| 23 | 23 | import org.slf4j.LoggerFactory; |
| 24 | 24 | import org.springframework.beans.factory.annotation.Autowired; |
| 25 | +import org.springframework.jdbc.datasource.DataSourceTransactionManager; | |
| 25 | 26 | import org.springframework.stereotype.Service; |
| 27 | +import org.springframework.transaction.TransactionDefinition; | |
| 28 | +import org.springframework.transaction.TransactionStatus; | |
| 26 | 29 | import org.springframework.util.StringUtils; |
| 27 | 30 | |
| 28 | 31 | import java.util.*; |
| ... | ... | @@ -69,6 +72,12 @@ public class StreamPushServiceImpl implements IStreamPushService { |
| 69 | 72 | @Autowired |
| 70 | 73 | private IMediaServerService mediaServerService; |
| 71 | 74 | |
| 75 | + @Autowired | |
| 76 | + DataSourceTransactionManager dataSourceTransactionManager; | |
| 77 | + | |
| 78 | + @Autowired | |
| 79 | + TransactionDefinition transactionDefinition; | |
| 80 | + | |
| 72 | 81 | @Override |
| 73 | 82 | public List<StreamPushItem> handleJSON(String jsonData, MediaServerItem mediaServerItem) { |
| 74 | 83 | if (jsonData == null) { |
| ... | ... | @@ -463,4 +472,27 @@ public class StreamPushServiceImpl implements IStreamPushService { |
| 463 | 472 | // 发送通知 |
| 464 | 473 | eventPublisher.catalogEventPublishForStream(null, onlinePushers, CatalogEvent.ON); |
| 465 | 474 | } |
| 475 | + | |
| 476 | + @Override | |
| 477 | + public boolean add(StreamPushItem stream) { | |
| 478 | + stream.setUpdateTime(DateUtil.getNow()); | |
| 479 | + stream.setCreateTime(DateUtil.getNow()); | |
| 480 | + stream.setServerId(userSetting.getServerId()); | |
| 481 | + | |
| 482 | + // 放在事务内执行 | |
| 483 | + boolean result = false; | |
| 484 | + TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); | |
| 485 | + try { | |
| 486 | + int addStreamResult = streamPushMapper.add(stream); | |
| 487 | + if (!StringUtils.isEmpty(stream.getGbId())) { | |
| 488 | + gbStreamMapper.add(stream); | |
| 489 | + } | |
| 490 | + dataSourceTransactionManager.commit(transactionStatus); | |
| 491 | + result = true; | |
| 492 | + }catch (Exception e) { | |
| 493 | + logger.error("批量移除流与平台的关系时错误", e); | |
| 494 | + dataSourceTransactionManager.rollback(transactionStatus); | |
| 495 | + } | |
| 496 | + return result; | |
| 497 | + } | |
| 466 | 498 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java
| ... | ... | @@ -50,7 +50,7 @@ public interface PlatformCatalogMapper { |
| 50 | 50 | @Select("SELECT pc.* FROM platform_catalog pc WHERE pc.id = #{id}") |
| 51 | 51 | PlatformCatalog selectParentCatalog(String id); |
| 52 | 52 | |
| 53 | - @Select("SELECT pc.id as channelId, pc.name, pc.civilCode, pc.businessGroupId,'0' as parental, pc.parentId " + | |
| 53 | + @Select("SELECT pc.id as channelId, pc.name, pc.civilCode, pc.businessGroupId,'1' as parental, pc.parentId " + | |
| 54 | 54 | " FROM platform_catalog pc WHERE pc.platformId=#{platformId}") |
| 55 | 55 | List<DeviceChannel> queryCatalogInPlatform(String platformId); |
| 56 | 56 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
| ... | ... | @@ -741,6 +741,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| 741 | 741 | if (platformCatalog.getPlatformId().equals(platformCatalog.getParentId())) { |
| 742 | 742 | // 第一层节点 |
| 743 | 743 | platformCatalog.setBusinessGroupId(platformCatalog.getId()); |
| 744 | + platformCatalog.setParentId(platform.getDeviceGBId()); | |
| 744 | 745 | }else { |
| 745 | 746 | // 获取顶层的 |
| 746 | 747 | PlatformCatalog topCatalog = getTopCatalog(platformCatalog.getParentId(), platformCatalog.getPlatformId()); |
| ... | ... | @@ -749,6 +750,10 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| 749 | 750 | } |
| 750 | 751 | if (platform.getTreeType().equals(TreeType.CIVIL_CODE)) { |
| 751 | 752 | platformCatalog.setCivilCode(platformCatalog.getId()); |
| 753 | + if (platformCatalog.getPlatformId().equals(platformCatalog.getParentId())) { | |
| 754 | + // 第一层节点 | |
| 755 | + platformCatalog.setParentId(platform.getDeviceGBId()); | |
| 756 | + } | |
| 752 | 757 | } |
| 753 | 758 | |
| 754 | 759 | int result = catalogMapper.add(platformCatalog); | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/bean/WVPResult.java
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
| ... | ... | @@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.conf.UserSetting; |
| 8 | 8 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 9 | 9 | import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; |
| 10 | 10 | import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; |
| 11 | +import com.genersoft.iot.vmp.gb28181.bean.TreeType; | |
| 11 | 12 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| 12 | 13 | import com.genersoft.iot.vmp.service.IPlatformChannelService; |
| 13 | 14 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| ... | ... | @@ -463,13 +464,20 @@ public class PlatformController { |
| 463 | 464 | if (logger.isDebugEnabled()) { |
| 464 | 465 | logger.debug("查询目录,platformId: {}, parentId: {}", platformId, parentId); |
| 465 | 466 | } |
| 467 | + ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); | |
| 468 | + if (platform == null) { | |
| 469 | + return new ResponseEntity<>(new WVPResult<>(400, "平台未找到", null), HttpStatus.OK); | |
| 470 | + } | |
| 471 | + if (platformId.equals(parentId)) { | |
| 472 | + parentId = platform.getDeviceGBId(); | |
| 473 | + } | |
| 466 | 474 | List<PlatformCatalog> platformCatalogList = storager.getChildrenCatalogByPlatform(platformId, parentId); |
| 467 | - // 查询下属的国标通道 | |
| 468 | -// List<PlatformCatalog> catalogsForChannel = storager.queryChannelInParentPlatformAndCatalog(platformId, parentId); | |
| 469 | - // 查询下属的直播流通道 | |
| 470 | -// List<PlatformCatalog> catalogsForStream = storager.queryStreamInParentPlatformAndCatalog(platformId, parentId); | |
| 471 | -// platformCatalogList.addAll(catalogsForChannel); | |
| 472 | -// platformCatalogList.addAll(catalogsForStream); | |
| 475 | +// if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)) { | |
| 476 | +// platformCatalogList = storager.getChildrenCatalogByPlatform(platformId, parentId); | |
| 477 | +// }else { | |
| 478 | +// | |
| 479 | +// } | |
| 480 | + | |
| 473 | 481 | WVPResult<List<PlatformCatalog>> result = new WVPResult<>(); |
| 474 | 482 | result.setCode(0); |
| 475 | 483 | result.setMsg("success"); | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java
| ... | ... | @@ -284,5 +284,35 @@ public class StreamPushController { |
| 284 | 284 | return result; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | + /** | |
| 288 | + * 获取推流播放地址 | |
| 289 | + * @param stream 推流信息 | |
| 290 | + * @return | |
| 291 | + */ | |
| 292 | + @ApiOperation("获取推流播放地址") | |
| 293 | + @ApiImplicitParams({ | |
| 294 | + @ApiImplicitParam(name = "stream", value = "推流信息", dataTypeClass = StreamPushItem.class), | |
| 295 | + }) | |
| 296 | + @PostMapping(value = "/add") | |
| 297 | + @ResponseBody | |
| 298 | + public WVPResult<StreamInfo> add(@RequestBody StreamPushItem stream){ | |
| 299 | + if (StringUtils.isEmpty(stream.getGbId())) { | |
| 300 | + | |
| 301 | + return new WVPResult<>(400, "国标ID不可为空", null); | |
| 302 | + } | |
| 303 | + if (StringUtils.isEmpty(stream.getApp()) && StringUtils.isEmpty(stream.getStream())) { | |
| 304 | + return new WVPResult<>(400, "app或stream不可为空", null); | |
| 305 | + } | |
| 306 | + stream.setStatus(false); | |
| 307 | + stream.setPushIng(false); | |
| 308 | + stream.setAliveSecond(0L); | |
| 309 | + stream.setTotalReaderCount("0"); | |
| 310 | + boolean result = streamPushService.add(stream); | |
| 287 | 311 | |
| 312 | + if (result) { | |
| 313 | + return new WVPResult<>(0, "success", null); | |
| 314 | + }else { | |
| 315 | + return new WVPResult<>(-1, "fail", null); | |
| 316 | + } | |
| 317 | + } | |
| 288 | 318 | } | ... | ... |
web_src/src/components/PushVideoList.vue
| ... | ... | @@ -34,6 +34,8 @@ |
| 34 | 34 | <el-button icon="el-icon-delete" size="mini" style="margin-right: 1rem;" |
| 35 | 35 | :disabled="multipleSelection.length === 0" type="danger" @click="batchDel">批量移除 |
| 36 | 36 | </el-button> |
| 37 | + <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="addStream">添加通道 | |
| 38 | + </el-button> | |
| 37 | 39 | <el-button icon="el-icon-refresh-right" circle size="mini" @click="refresh()"></el-button> |
| 38 | 40 | </div> |
| 39 | 41 | </div> |
| ... | ... | @@ -108,7 +110,7 @@ |
| 108 | 110 | <script> |
| 109 | 111 | import streamProxyEdit from './dialog/StreamProxyEdit.vue' |
| 110 | 112 | import devicePlayer from './dialog/devicePlayer.vue' |
| 111 | -import addStreamTOGB from './dialog/addStreamTOGB.vue' | |
| 113 | +import addStreamTOGB from './dialog/pushStreamEdit.vue' | |
| 112 | 114 | import uiHeader from '../layout/UiHeader.vue' |
| 113 | 115 | import importChannel from './dialog/importChannel.vue' |
| 114 | 116 | import MediaServer from './service/MediaServer' |
| ... | ... | @@ -252,6 +254,9 @@ export default { |
| 252 | 254 | |
| 253 | 255 | }) |
| 254 | 256 | }, |
| 257 | + addStream: function (){ | |
| 258 | + this.$refs.addStreamTOGB.openDialog(null, this.initData); | |
| 259 | + }, | |
| 255 | 260 | batchDel: function () { |
| 256 | 261 | this.$confirm(`确定删除选中的${this.multipleSelection.length}个通道?`, '提示', { |
| 257 | 262 | confirmButtonText: '确定', | ... | ... |
web_src/src/components/channelList.vue
| ... | ... | @@ -124,7 +124,6 @@ |
| 124 | 124 | import devicePlayer from './dialog/devicePlayer.vue' |
| 125 | 125 | import uiHeader from '../layout/UiHeader.vue' |
| 126 | 126 | import moment from "moment"; |
| 127 | -import DviceService from "./service/DeviceService"; | |
| 128 | 127 | import DeviceService from "./service/DeviceService"; |
| 129 | 128 | import DeviceTree from "./common/DeviceTree"; |
| 130 | 129 | |
| ... | ... | @@ -318,7 +317,7 @@ export default { |
| 318 | 317 | changeSubchannel(itemData) { |
| 319 | 318 | this.beforeUrl = this.$router.currentRoute.path; |
| 320 | 319 | |
| 321 | - var url = `/${this.$router.currentRoute.name}/${this.$router.currentRoute.params.deviceId}/${itemData.channelId}/${this.$router.currentRoute.params.count}/1` | |
| 320 | + var url = `/${this.$router.currentRoute.name}/${this.$router.currentRoute.params.deviceId}/${itemData.channelId}` | |
| 322 | 321 | this.$router.push(url).then(() => { |
| 323 | 322 | this.searchSrt = ""; |
| 324 | 323 | this.channelType = ""; | ... | ... |
web_src/src/components/dialog/catalogEdit.vue
web_src/src/components/dialog/addStreamTOGB.vue renamed to web_src/src/components/dialog/pushStreamEdit.vue
| ... | ... | @@ -15,10 +15,10 @@ |
| 15 | 15 | <el-input v-model="proxyParam.name" clearable></el-input> |
| 16 | 16 | </el-form-item> |
| 17 | 17 | <el-form-item label="流应用名" prop="app"> |
| 18 | - <el-input v-model="proxyParam.app" clearable :disabled="true"></el-input> | |
| 18 | + <el-input v-model="proxyParam.app" clearable :disabled="edit"></el-input> | |
| 19 | 19 | </el-form-item> |
| 20 | 20 | <el-form-item label="流ID" prop="stream"> |
| 21 | - <el-input v-model="proxyParam.stream" clearable :disabled="true"></el-input> | |
| 21 | + <el-input v-model="proxyParam.stream" clearable :disabled="edit"></el-input> | |
| 22 | 22 | </el-form-item> |
| 23 | 23 | <el-form-item label="国标编码" prop="gbId"> |
| 24 | 24 | <el-input v-model="proxyParam.gbId" placeholder="设置国标编码可推送到国标" clearable></el-input> |
| ... | ... | @@ -28,7 +28,6 @@ |
| 28 | 28 | <el-button type="primary" @click="onSubmit">保存</el-button> |
| 29 | 29 | <el-button @click="close">取消</el-button> |
| 30 | 30 | </div> |
| 31 | - | |
| 32 | 31 | </el-form-item> |
| 33 | 32 | </el-form> |
| 34 | 33 | </div> |
| ... | ... | @@ -38,7 +37,7 @@ |
| 38 | 37 | |
| 39 | 38 | <script> |
| 40 | 39 | export default { |
| 41 | - name: "streamProxyEdit", | |
| 40 | + name: "pushStreamEdit", | |
| 42 | 41 | props: {}, |
| 43 | 42 | computed: {}, |
| 44 | 43 | created() {}, |
| ... | ... | @@ -63,13 +62,13 @@ export default { |
| 63 | 62 | listChangeCallback: null, |
| 64 | 63 | showDialog: false, |
| 65 | 64 | isLoging: false, |
| 65 | + edit: false, | |
| 66 | 66 | proxyParam: { |
| 67 | 67 | name: null, |
| 68 | 68 | app: null, |
| 69 | 69 | stream: null, |
| 70 | 70 | gbId: null, |
| 71 | 71 | }, |
| 72 | - | |
| 73 | 72 | rules: { |
| 74 | 73 | name: [{ required: true, message: "请输入名称", trigger: "blur" }], |
| 75 | 74 | app: [{ required: true, message: "请输入应用名", trigger: "blur" }], |
| ... | ... | @@ -84,30 +83,53 @@ export default { |
| 84 | 83 | this.listChangeCallback = callback; |
| 85 | 84 | if (proxyParam != null) { |
| 86 | 85 | this.proxyParam = proxyParam; |
| 87 | - } | |
| 86 | + this.edit = true | |
| 87 | + } | |
| 88 | 88 | }, |
| 89 | 89 | onSubmit: function () { |
| 90 | 90 | console.log("onSubmit"); |
| 91 | - var that = this; | |
| 92 | - that.$axios({ | |
| 93 | - method:"post", | |
| 94 | - url:`/api/push/save_to_gb`, | |
| 95 | - data: that.proxyParam | |
| 96 | - }).then(function (res) { | |
| 91 | + if (this.edit) { | |
| 92 | + this.$axios({ | |
| 93 | + method:"post", | |
| 94 | + url:`/api/push/save_to_gb`, | |
| 95 | + data: this.proxyParam | |
| 96 | + }).then( (res) => { | |
| 97 | 97 | if (res.data == "success") { |
| 98 | - that.$message({ | |
| 98 | + this.$message({ | |
| 99 | 99 | showClose: true, |
| 100 | 100 | message: "保存成功", |
| 101 | 101 | type: "success", |
| 102 | 102 | }); |
| 103 | - that.showDialog = false; | |
| 104 | - if (that.listChangeCallback != null) { | |
| 105 | - that.listChangeCallback(); | |
| 103 | + this.showDialog = false; | |
| 104 | + if (this.listChangeCallback != null) { | |
| 105 | + this.listChangeCallback(); | |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | - }).catch(function (error) { | |
| 108 | + }).catch((error)=> { | |
| 109 | 109 | console.log(error); |
| 110 | - }); | |
| 110 | + }); | |
| 111 | + }else { | |
| 112 | + this.$axios({ | |
| 113 | + method:"post", | |
| 114 | + url:`/api/push/add`, | |
| 115 | + data: this.proxyParam | |
| 116 | + }).then( (res) => { | |
| 117 | + if (res.data.code === 0) { | |
| 118 | + this.$message({ | |
| 119 | + showClose: true, | |
| 120 | + message: "保存成功", | |
| 121 | + type: "success", | |
| 122 | + }); | |
| 123 | + this.showDialog = false; | |
| 124 | + if (this.listChangeCallback != null) { | |
| 125 | + this.listChangeCallback(); | |
| 126 | + } | |
| 127 | + } | |
| 128 | + }).catch((error)=> { | |
| 129 | + console.log(error); | |
| 130 | + }); | |
| 131 | + } | |
| 132 | + | |
| 111 | 133 | }, |
| 112 | 134 | close: function () { |
| 113 | 135 | console.log("关闭加入GB"); |
| ... | ... | @@ -131,6 +153,9 @@ export default { |
| 131 | 153 | if (this.platform.enable && this.platform.expires == "0") { |
| 132 | 154 | this.platform.expires = "300"; |
| 133 | 155 | } |
| 156 | + }, | |
| 157 | + handleNodeClick: function (node){ | |
| 158 | + | |
| 134 | 159 | } |
| 135 | 160 | }, |
| 136 | 161 | }; | ... | ... |