修复通道共享的BUG以及增加通道手动推送的功能
parent
dd794d4868
commit
64e9b6674f
|
@ -2,9 +2,12 @@ package com.genersoft.iot.vmp.gb28181.bean;
|
|||
|
||||
import gov.nist.javax.sip.message.SIPRequest;
|
||||
import gov.nist.javax.sip.message.SIPResponse;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.sip.header.*;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class SubscribeInfo {
|
||||
|
||||
|
||||
|
@ -31,9 +34,9 @@ public class SubscribeInfo {
|
|||
|
||||
/**
|
||||
* 以下为可选字段
|
||||
* @return
|
||||
*/
|
||||
private String sn;
|
||||
|
||||
private int gpsInterval;
|
||||
|
||||
/**
|
||||
|
@ -51,91 +54,18 @@ public class SubscribeInfo {
|
|||
*/
|
||||
private String simulatedCallId;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
|
||||
public static SubscribeInfo buildSimulated(String platFormServerId, String platFormServerIp){
|
||||
SubscribeInfo subscribeInfo = new SubscribeInfo();
|
||||
subscribeInfo.setId(platFormServerId);
|
||||
subscribeInfo.setExpires(-1);
|
||||
subscribeInfo.setEventType("Catalog");
|
||||
int random = (int) Math.floor(Math.random() * 10000);
|
||||
subscribeInfo.setEventId(random + "");
|
||||
subscribeInfo.setSimulatedCallId(UUID.randomUUID().toString().replace("-", "") + "@" + platFormServerIp);
|
||||
subscribeInfo.setSimulatedFromTag(UUID.randomUUID().toString().replace("-", ""));
|
||||
subscribeInfo.setSimulatedToTag(UUID.randomUUID().toString().replace("-", ""));
|
||||
return subscribeInfo;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public SIPRequest getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
public void setRequest(SIPRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public int getExpires() {
|
||||
return expires;
|
||||
}
|
||||
|
||||
public void setExpires(int expires) {
|
||||
this.expires = expires;
|
||||
}
|
||||
|
||||
public String getEventId() {
|
||||
return eventId;
|
||||
}
|
||||
|
||||
public void setEventId(String eventId) {
|
||||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
public String getEventType() {
|
||||
return eventType;
|
||||
}
|
||||
|
||||
public void setEventType(String eventType) {
|
||||
this.eventType = eventType;
|
||||
}
|
||||
|
||||
public SIPResponse getResponse() {
|
||||
return response;
|
||||
}
|
||||
|
||||
public void setResponse(SIPResponse response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public int getGpsInterval() {
|
||||
return gpsInterval;
|
||||
}
|
||||
|
||||
public void setGpsInterval(int gpsInterval) {
|
||||
this.gpsInterval = gpsInterval;
|
||||
}
|
||||
|
||||
public String getSimulatedFromTag() {
|
||||
return simulatedFromTag;
|
||||
}
|
||||
|
||||
public void setSimulatedFromTag(String simulatedFromTag) {
|
||||
this.simulatedFromTag = simulatedFromTag;
|
||||
}
|
||||
|
||||
public String getSimulatedCallId() {
|
||||
return simulatedCallId;
|
||||
}
|
||||
|
||||
public void setSimulatedCallId(String simulatedCallId) {
|
||||
this.simulatedCallId = simulatedCallId;
|
||||
}
|
||||
|
||||
public String getSimulatedToTag() {
|
||||
return simulatedToTag;
|
||||
}
|
||||
|
||||
public void setSimulatedToTag(String simulatedToTag) {
|
||||
this.simulatedToTag = simulatedToTag;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -359,4 +359,13 @@ public class PlatformController {
|
|||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "推送通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "id", description = "平台ID", required = true)
|
||||
@GetMapping("/channel/push")
|
||||
@ResponseBody
|
||||
public void pushChannel(Integer id) {
|
||||
Assert.notNull(id, "平台ID不可为空");
|
||||
platformChannelService.pushChannel(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,10 @@ package com.genersoft.iot.vmp.gb28181.dao;
|
|||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -56,17 +53,6 @@ public interface PlatformChannelMapper {
|
|||
@Select("SELECT dc.* from wvp_platform_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.channel_type = 0 and dc.channel_id=#{channelId} and pgc.platform_id=#{platformId}")
|
||||
List<DeviceChannel> queryChannelInParentPlatform(@Param("platformId") String platformId, @Param("channelId") String channelId);
|
||||
|
||||
@Select("<script> "+
|
||||
"SELECT dc.* from wvp_platform_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.channel_type = 0 and pgc.platform_id=#{platformId} " +
|
||||
" <if test='catalogId != null' > and pgc.catalog_id=#{catalogId}</if>" +
|
||||
"</script>")
|
||||
List<CommonGBChannel> queryAllChannelInCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
|
||||
|
||||
@Select(" select dc.channel_id as id, dc.name as name, pgc.platform_id as platform_id, pgc.catalog_id as parent_id, 0 as children_count, 1 as type " +
|
||||
" from wvp_device_channel dc left join wvp_platform_channel pgc on dc.id = pgc.device_channel_id " +
|
||||
" where dc.channel_type = 0 and pgc.platform_id=#{platformId} and pgc.catalog_id=#{catalogId}")
|
||||
List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
|
||||
|
||||
@Select("select d.*\n" +
|
||||
"from wvp_platform_channel pgc\n" +
|
||||
" left join wvp_device_channel dc on dc.id = pgc.device_channel_id\n" +
|
||||
|
@ -74,16 +60,6 @@ public interface PlatformChannelMapper {
|
|||
"where dc.channel_type = 0 and dc.channel_id = #{channelId} and pgc.platform_id=#{platformId}")
|
||||
List<Device> queryVideoDeviceByPlatformIdAndChannelId(@Param("platformId") String platformId, @Param("channelId") String channelId);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE from wvp_platform_channel WHERE platform_id=#{platformId} and catalog_id=#{id}" +
|
||||
"</script>")
|
||||
int delByCatalogId(@Param("platformId") String platformId, @Param("id") String id);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE from wvp_platform_channel WHERE catalog_id=#{parentId} AND platform_id=#{platformId} AND channel_id=#{id}" +
|
||||
"</script>")
|
||||
int delByCatalogIdAndChannelIdAndPlatformId(PlatformCatalog platformCatalog);
|
||||
|
||||
@Select("<script> " +
|
||||
" SELECT " +
|
||||
" pp.* " +
|
||||
|
@ -100,17 +76,6 @@ public interface PlatformChannelMapper {
|
|||
"</script> ")
|
||||
List<Platform> queryPlatFormListForGBWithGBId(@Param("channelId") String channelId, @Param("platforms") List<String> platforms);
|
||||
|
||||
@Delete("<script> " +
|
||||
"DELETE from wvp_platform_channel WHERE platform_id=#{serverGBId}" +
|
||||
"</script>")
|
||||
void delByPlatformId(String serverGBId);
|
||||
|
||||
@Delete("<script> " +
|
||||
"DELETE from wvp_platform_channel WHERE platform_id=#{platformId} " +
|
||||
" <if test=\"catalogId != null\" > and catalog_id=#{catalogId}</if>" +
|
||||
"</script>")
|
||||
int delChannelForGBByCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
|
||||
|
||||
@Select("select dc.channel_id dc.device_id,dc.name,d.manufacturer,d.model,d.firmware\n" +
|
||||
"from wvp_platform_channel pgc\n" +
|
||||
" left join wvp_device_channel dc on dc.id = pgc.device_channel_id\n" +
|
||||
|
@ -428,7 +393,21 @@ public interface PlatformChannelMapper {
|
|||
" dc.id = pgc.device_channel_id " +
|
||||
" WHERE " +
|
||||
" pgc.device_channel_id IN" +
|
||||
"<foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
|
||||
"<foreach collection='ids' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
|
||||
"</script> ")
|
||||
List<Platform> queryPlatFormListByChannelList(List<CommonGBChannel> channelList);
|
||||
List<Platform> queryPlatFormListByChannelList(Collection<Integer> ids);
|
||||
|
||||
@Select("<script> " +
|
||||
" SELECT " +
|
||||
" pp.* " +
|
||||
" FROM " +
|
||||
" wvp_platform pp " +
|
||||
" left join wvp_platform_channel pgc on " +
|
||||
" pp.id = pgc.platform_id " +
|
||||
" left join wvp_device_channel dc on " +
|
||||
" dc.id = pgc.device_channel_id " +
|
||||
" WHERE " +
|
||||
" pgc.device_channel_id = #{channelId}" +
|
||||
"</script> ")
|
||||
List<Platform> queryPlatFormListByChannelId(@Param("channelId") int channelId);
|
||||
}
|
||||
|
|
|
@ -30,8 +30,6 @@ public interface IGbChannelService {
|
|||
|
||||
void updateStatus(List<CommonGBChannel> channelList);
|
||||
|
||||
List<CommonGBChannel> queryByPlatform(Platform platform);
|
||||
|
||||
CommonGBChannel getOne(int id);
|
||||
|
||||
List<IndustryCodeType> getIndustryCodeList();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.genersoft.iot.vmp.gb28181.service;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Platform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
|
@ -22,5 +23,11 @@ public interface IPlatformChannelService {
|
|||
|
||||
int removeChannels(Integer platformId, List<Integer> channelIds);
|
||||
|
||||
void removeChannels(List<CommonGBChannel> channelList);
|
||||
void removeChannels(List<Integer> ids);
|
||||
|
||||
void removeChannel(int gbId);
|
||||
|
||||
List<CommonGBChannel> queryByPlatform(Platform platform);
|
||||
|
||||
void pushChannel(Integer platformId);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.genersoft.iot.vmp.common.InviteInfo;
|
|||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
|
||||
|
@ -538,6 +537,16 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
|||
|
||||
}
|
||||
if (!deleteChannels.isEmpty()) {
|
||||
try {
|
||||
// 这些通道可能关联了,上级平台需要删除同时发送消息
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
deleteChannels.stream().forEach(deviceChannel -> {
|
||||
ids.add(deviceChannel.getId());
|
||||
});
|
||||
platformChannelService.removeChannels(ids);
|
||||
}catch (Exception e) {
|
||||
log.error("[移除通道国标级联共享失败]", e);
|
||||
}
|
||||
if (deleteChannels.size() > limitCount) {
|
||||
for (int i = 0; i < deleteChannels.size(); i += limitCount) {
|
||||
int toIndex = i + limitCount;
|
||||
|
@ -549,17 +558,6 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
|||
}else {
|
||||
channelMapper.batchDel(deleteChannels);
|
||||
}
|
||||
// 这些通道可能关联了,上级平台需要删除同时发送消息
|
||||
|
||||
List<CommonGBChannel> channelList = new ArrayList<>();
|
||||
deleteChannels.stream().forEach(deviceChannel -> {
|
||||
CommonGBChannel commonGBChannel = new CommonGBChannel();
|
||||
commonGBChannel.setGbId(deviceChannel.getId());
|
||||
commonGBChannel.setGbDeviceId(deviceChannel.getDeviceId());
|
||||
commonGBChannel.setGbName(deviceChannel.getName());
|
||||
channelList.add(commonGBChannel);
|
||||
});
|
||||
platformChannelService.removeChannels(channelList);
|
||||
}
|
||||
return true;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.gb28181.dao.RegionMapper;
|
|||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
|
@ -35,6 +36,9 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
|||
@Autowired
|
||||
private PlatformChannelMapper platformChannelMapper;
|
||||
|
||||
@Autowired
|
||||
private IPlatformChannelService platformChannelService;
|
||||
|
||||
@Autowired
|
||||
private RegionMapper regionMapper;
|
||||
|
||||
|
@ -66,7 +70,15 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int delete(int gbId) {
|
||||
// 移除国标级联关联的信息
|
||||
try {
|
||||
platformChannelService.removeChannel(gbId);
|
||||
}catch (Exception e) {
|
||||
log.error("[移除通道国标级联共享失败]", e);
|
||||
}
|
||||
|
||||
CommonGBChannel channel = commonGBChannelMapper.queryById(gbId);
|
||||
if (channel != null) {
|
||||
commonGBChannelMapper.delete(gbId);
|
||||
|
@ -81,18 +93,19 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(Collection<Integer> ids) {
|
||||
// 移除国标级联关联的信息
|
||||
try {
|
||||
platformChannelService.removeChannels(new ArrayList<>(ids));
|
||||
}catch (Exception e) {
|
||||
log.error("[移除通道国标级联共享失败]", e);
|
||||
}
|
||||
List<CommonGBChannel> channelListInDb = commonGBChannelMapper.queryByIds(ids);
|
||||
if (channelListInDb.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
commonGBChannelMapper.batchDelete(channelListInDb);
|
||||
try {
|
||||
// 发送通知
|
||||
eventPublisher.catalogEventPublish(null, channelListInDb, CatalogEvent.DEL);
|
||||
} catch (Exception e) {
|
||||
log.warn("[通道移除通知] 发送失败,{}条", channelListInDb.size(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -309,40 +322,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommonGBChannel> queryByPlatform(Platform platform) {
|
||||
if (platform == null) {
|
||||
return null;
|
||||
}
|
||||
List<CommonGBChannel> commonGBChannelList = commonGBChannelMapper.queryWithPlatform(platform.getId());
|
||||
if (commonGBChannelList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<CommonGBChannel> channelList = new ArrayList<>();
|
||||
// 是否包含平台信息
|
||||
if (platform.getCatalogWithPlatform()) {
|
||||
CommonGBChannel channel = CommonGBChannel.build(platform);
|
||||
channelList.add(channel);
|
||||
}
|
||||
// 关联的行政区划信息
|
||||
if (platform.getCatalogWithRegion()) {
|
||||
// 查询关联平台的行政区划信息
|
||||
List<CommonGBChannel> regionChannelList = regionMapper.queryByPlatform(platform.getId());
|
||||
if (!regionChannelList.isEmpty()) {
|
||||
channelList.addAll(regionChannelList);
|
||||
}
|
||||
}
|
||||
if (platform.getCatalogWithGroup()) {
|
||||
// 关联的分组信息
|
||||
List<CommonGBChannel> groupChannelList = groupMapper.queryForPlatform(platform.getId());
|
||||
if (!groupChannelList.isEmpty()) {
|
||||
channelList.addAll(groupChannelList);
|
||||
}
|
||||
}
|
||||
|
||||
channelList.addAll(commonGBChannelList);
|
||||
return channelList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonGBChannel getOne(int id) {
|
||||
|
|
|
@ -2,13 +2,11 @@ package com.genersoft.iot.vmp.gb28181.service.impl;
|
|||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.GroupMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.RegionMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.*;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -16,7 +14,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.SipException;
|
||||
import java.beans.Transient;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
@ -43,6 +44,12 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||
@Autowired
|
||||
private CommonGBChannelMapper commonGBChannelMapper;
|
||||
|
||||
@Autowired
|
||||
private PlatformMapper platformMapper;
|
||||
|
||||
@Autowired
|
||||
private ISIPCommanderForPlatform sipCommanderFroPlatform;
|
||||
|
||||
|
||||
@Override
|
||||
public PageInfo<PlatformChannel> queryChannelList(int page, int count, String query, Boolean online, Integer platformId, Boolean hasShare) {
|
||||
|
@ -336,44 +343,82 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void removeChannels(List<CommonGBChannel> channelList) {
|
||||
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelList(channelList);
|
||||
@Transient
|
||||
public void removeChannels(List<Integer> ids) {
|
||||
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelList(ids);
|
||||
if (platformList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO 不对呀
|
||||
for (Platform platform : platformList) {
|
||||
int result = platformChannelMapper.removeChannelsWithPlatform(platform.getId(), channelList);
|
||||
if (result > 0) {
|
||||
// 查询通道相关的分组信息
|
||||
Set<Region> regionSet = regionMapper.queryByChannelList(channelList);
|
||||
Set<Region> deleteRegion = deleteEmptyRegion(regionSet, platform.getId());
|
||||
if (!deleteRegion.isEmpty()) {
|
||||
for (Region region : deleteRegion) {
|
||||
channelList.add(0, CommonGBChannel.build(region));
|
||||
}
|
||||
}
|
||||
removeChannels(platform.getId(), ids);
|
||||
}
|
||||
}
|
||||
|
||||
// 查询通道相关的分组信息
|
||||
Set<Group> groupSet = groupMapper.queryByChannelList(channelList);
|
||||
Set<Group> deleteGroup = deleteEmptyGroup(groupSet, platform.getId());
|
||||
if (!deleteGroup.isEmpty()) {
|
||||
for (Group group : deleteGroup) {
|
||||
channelList.add(0, CommonGBChannel.build(group));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void removeChannel(int channelId) {
|
||||
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelId(channelId);
|
||||
if (platformList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Platform platform : platformList) {
|
||||
ArrayList<Integer> ids = new ArrayList<>();
|
||||
ids.add(channelId);
|
||||
removeChannels(platform.getId(), ids);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommonGBChannel> queryByPlatform(Platform platform) {
|
||||
if (platform == null) {
|
||||
return null;
|
||||
}
|
||||
List<CommonGBChannel> commonGBChannelList = commonGBChannelMapper.queryWithPlatform(platform.getId());
|
||||
if (commonGBChannelList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<CommonGBChannel> channelList = new ArrayList<>();
|
||||
// 是否包含平台信息
|
||||
if (platform.getCatalogWithPlatform()) {
|
||||
CommonGBChannel channel = CommonGBChannel.build(platform);
|
||||
channelList.add(channel);
|
||||
}
|
||||
// 关联的行政区划信息
|
||||
if (platform.getCatalogWithRegion()) {
|
||||
// 查询关联平台的行政区划信息
|
||||
List<CommonGBChannel> regionChannelList = regionMapper.queryByPlatform(platform.getId());
|
||||
if (!regionChannelList.isEmpty()) {
|
||||
channelList.addAll(regionChannelList);
|
||||
}
|
||||
// 发送消息
|
||||
try {
|
||||
// 发送catalog
|
||||
eventPublisher.catalogEventPublish(platform.getId(), channelList, CatalogEvent.DEL);
|
||||
} catch (Exception e) {
|
||||
log.warn("[移除关联通道] 发送失败,数量:{}", channelList.size(), e);
|
||||
}
|
||||
if (platform.getCatalogWithGroup()) {
|
||||
// 关联的分组信息
|
||||
List<CommonGBChannel> groupChannelList = groupMapper.queryForPlatform(platform.getId());
|
||||
if (!groupChannelList.isEmpty()) {
|
||||
channelList.addAll(groupChannelList);
|
||||
}
|
||||
}
|
||||
|
||||
channelList.addAll(commonGBChannelList);
|
||||
return channelList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushChannel(Integer platformId) {
|
||||
Platform platform = platformMapper.query(platformId);
|
||||
Assert.notNull(platform, "平台不存在");
|
||||
List<CommonGBChannel> channelList = queryByPlatform(platform);
|
||||
if (channelList.isEmpty()){
|
||||
return;
|
||||
}
|
||||
SubscribeInfo subscribeInfo = SubscribeInfo.buildSimulated(platform.getServerGBId(), platform.getServerIp());
|
||||
|
||||
try {
|
||||
sipCommanderFroPlatform.sendNotifyForCatalogAddOrUpdate(CatalogEvent.UPDATE, platform, channelList, subscribeInfo, null);
|
||||
} catch (InvalidArgumentException | ParseException | NoSuchFieldException |
|
||||
SipException | IllegalAccessException e) {
|
||||
log.error("[命令发送失败] 国标级联 Catalog通知: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ import javax.sip.InvalidArgumentException;
|
|||
import javax.sip.ResponseEvent;
|
||||
import javax.sip.SipException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.Vector;
|
||||
|
@ -329,16 +328,8 @@ public class PlatformServiceImpl implements IPlatformService {
|
|||
@Override
|
||||
public void addSimulatedSubscribeInfo(Platform platform) {
|
||||
// 自动添加一条模拟的订阅信息
|
||||
SubscribeInfo subscribeInfo = new SubscribeInfo();
|
||||
subscribeInfo.setId(platform.getServerGBId());
|
||||
subscribeInfo.setExpires(-1);
|
||||
subscribeInfo.setEventType("Catalog");
|
||||
int random = (int) Math.floor(Math.random() * 10000);
|
||||
subscribeInfo.setEventId(random + "");
|
||||
subscribeInfo.setSimulatedCallId(UUID.randomUUID().toString().replace("-", "") + "@" + platform.getServerIp());
|
||||
subscribeInfo.setSimulatedFromTag(UUID.randomUUID().toString().replace("-", ""));
|
||||
subscribeInfo.setSimulatedToTag(UUID.randomUUID().toString().replace("-", ""));
|
||||
subscribeHolder.putCatalogSubscribe(platform.getServerGBId(), subscribeInfo);
|
||||
subscribeHolder.putCatalogSubscribe(platform.getServerGBId(),
|
||||
SubscribeInfo.buildSimulated(platform.getServerGBId(), platform.getServerIp()));
|
||||
}
|
||||
|
||||
private void registerTask(Platform platform, SipTransactionInfo sipTransactionInfo){
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Platform;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import gov.nist.javax.sip.message.SIPRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dom4j.Element;
|
||||
|
@ -38,6 +36,9 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
|
|||
@Autowired
|
||||
private IGbChannelService channelService;
|
||||
|
||||
@Autowired
|
||||
private IPlatformChannelService platformChannelService;
|
||||
|
||||
@Autowired
|
||||
private SIPCommanderFroPlatform cmderFroPlatform;
|
||||
|
||||
|
@ -67,7 +68,7 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
|
|||
}
|
||||
Element snElement = rootElement.element("SN");
|
||||
String sn = snElement.getText();
|
||||
List<CommonGBChannel> channelList = channelService.queryByPlatform(platform);
|
||||
List<CommonGBChannel> channelList = platformChannelService.queryByPlatform(platform);
|
||||
|
||||
try {
|
||||
if (!channelList.isEmpty()) {
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
<template slot-scope="scope">
|
||||
<el-button size="medium" icon="el-icon-edit" type="text" @click="editPlatform(scope.row)">编辑</el-button>
|
||||
<el-button size="medium" icon="el-icon-share" type="text" @click="chooseChannel(scope.row)">通道共享</el-button>
|
||||
<el-button size="medium" icon="el-icon-top" type="text" :loading="pushChannelLoading" @click="pushChannel(scope.row)">推送通道</el-button>
|
||||
<el-button size="medium" icon="el-icon-delete" type="text" style="color: #f56c6c" @click="deletePlatform(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
@ -94,6 +95,7 @@ export default {
|
|||
deviceIps: [], //设备列表
|
||||
defaultPlatform: null,
|
||||
platform: null,
|
||||
pushChannelLoading: false,
|
||||
winHeight: window.innerHeight - 260,
|
||||
currentPage:1,
|
||||
count:15,
|
||||
|
@ -155,6 +157,36 @@ export default {
|
|||
chooseChannel: function(platform) {
|
||||
this.$refs.shareChannel.openDialog(platform.id, this.initData)
|
||||
},
|
||||
pushChannel: function(row) {
|
||||
this.pushChannelLoading = true;
|
||||
this.$axios({
|
||||
method: 'get',
|
||||
url: `/api/platform/channel/push`,
|
||||
params: {
|
||||
id: row.id,
|
||||
}
|
||||
}).then((res)=> {
|
||||
this.pushChannelLoading = false;
|
||||
if (res.data.code === 0) {
|
||||
this.$message.success({
|
||||
showClose: true,
|
||||
message: '推送成功',
|
||||
});
|
||||
}else {
|
||||
this.$message.error({
|
||||
showClose: true,
|
||||
message: res.data.msg,
|
||||
});
|
||||
}
|
||||
}).catch((error)=> {
|
||||
console.log(error);
|
||||
this.pushChannelLoading = false;
|
||||
this.$message.error({
|
||||
showClose: true,
|
||||
message: error,
|
||||
});
|
||||
});
|
||||
},
|
||||
initData: function() {
|
||||
this.$axios({
|
||||
method: 'get',
|
||||
|
|
Loading…
Reference in New Issue