临时提交
This commit is contained in:
@@ -422,12 +422,14 @@ public class CommonGBChannel {
|
||||
// 业务分组
|
||||
channel.setGbName(group.getName());
|
||||
channel.setGbDeviceId(group.getDeviceId());
|
||||
channel.setGbCivilCode(group.getCivilCode());
|
||||
} else {
|
||||
// 虚拟组织
|
||||
channel.setGbName(group.getName());
|
||||
channel.setGbDeviceId(group.getDeviceId());
|
||||
channel.setGbParentId(group.getParentDeviceId());
|
||||
channel.setGbBusinessGroupId(group.getBusinessGroup());
|
||||
channel.setGbCivilCode(group.getCivilCode());
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,11 @@ public class Group implements Comparable<Group>{
|
||||
*/
|
||||
@Schema(description = "更新时间")
|
||||
private String updateTime;
|
||||
/**
|
||||
* 行政区划
|
||||
*/
|
||||
@Schema(description = "行政区划")
|
||||
private String civilCode;
|
||||
|
||||
public static Group getInstance(DeviceChannel channel) {
|
||||
GbCode gbCode = GbCode.decode(channel.getDeviceId());
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.gb28181.dao;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Group;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GroupTree;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Platform;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -11,13 +12,13 @@ import java.util.Set;
|
||||
@Mapper
|
||||
public interface GroupMapper {
|
||||
|
||||
@Insert("INSERT INTO wvp_common_group (device_id, name, parent_id, parent_device_id, business_group, create_time, update_time) " +
|
||||
"VALUES (#{deviceId}, #{name}, #{parentId}, #{parentDeviceId}, #{businessGroup}, #{createTime}, #{updateTime})")
|
||||
@Insert("INSERT INTO wvp_common_group (device_id, name, parent_id, parent_device_id, business_group, create_time, update_time, civil_code) " +
|
||||
"VALUES (#{deviceId}, #{name}, #{parentId}, #{parentDeviceId}, #{businessGroup}, #{createTime}, #{updateTime}, #{civilCode})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int add(Group group);
|
||||
|
||||
@Insert("INSERT INTO wvp_common_group (device_id, name, business_group, create_time, update_time) " +
|
||||
"VALUES (#{deviceId}, #{name}, #{businessGroup}, #{createTime}, #{updateTime})")
|
||||
@Insert("INSERT INTO wvp_common_group (device_id, name, business_group, create_time, update_time, civil_code) " +
|
||||
"VALUES (#{deviceId}, #{name}, #{businessGroup}, #{createTime}, #{updateTime}, #{civilCode})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int addBusinessGroup(Group group);
|
||||
|
||||
@@ -25,7 +26,8 @@ public interface GroupMapper {
|
||||
int delete(@Param("id") int id);
|
||||
|
||||
@Update(" UPDATE wvp_common_group " +
|
||||
" SET update_time=#{updateTime}, device_id=#{deviceId}, name=#{name}, parent_id=#{parentId}, parent_device_id=#{parentDeviceId}, business_group=#{businessGroup}" +
|
||||
" SET update_time=#{updateTime}, device_id=#{deviceId}, name=#{name}, parent_id=#{parentId}, " +
|
||||
" parent_device_id=#{parentDeviceId}, business_group=#{businessGroup}, civil_code=#{civilCode}" +
|
||||
" WHERE id = #{id}")
|
||||
int update(Group group);
|
||||
|
||||
@@ -52,10 +54,11 @@ public interface GroupMapper {
|
||||
" parent_id," +
|
||||
" business_group," +
|
||||
" create_time," +
|
||||
" civil_code," +
|
||||
" update_time) " +
|
||||
" VALUES " +
|
||||
" <foreach collection='groupList' index='index' item='item' separator=','> " +
|
||||
" (#{item.deviceId}, #{item.name}, #{item.parentDeviceId}, #{item.parentId}, #{item.businessGroup},#{item.createTime},#{item.updateTime})" +
|
||||
" (#{item.deviceId}, #{item.name}, #{item.parentDeviceId}, #{item.parentId}, #{item.businessGroup},#{item.createTime},#{item.civilCode},#{item.updateTime})" +
|
||||
" </foreach> " +
|
||||
" </script>")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
@@ -210,4 +213,15 @@ public interface GroupMapper {
|
||||
" </script>")
|
||||
void updateParentIdWithBusinessGroup(List<Group> groupListForAdd);
|
||||
|
||||
@Select(" <script>" +
|
||||
" SELECT " +
|
||||
" wp.* " +
|
||||
" from wvp_platform_group wpg " +
|
||||
" left join wvp_platform wp on wp.id = wpg.platform_id " +
|
||||
" where wpg.group_id = #{groupId} " +
|
||||
"</script>")
|
||||
List<Platform> queryForPlatformByGroupId(@Param("groupId") int groupId);
|
||||
|
||||
@Delete("DELETE FROM wvp_platform_group WHERE group_id = #{groupId}")
|
||||
void deletePlatformGroup(@Param("groupId") int groupId);
|
||||
}
|
||||
|
||||
@@ -339,7 +339,17 @@ public interface PlatformChannelMapper {
|
||||
" </foreach> " +
|
||||
"</if>" +
|
||||
"</script>")
|
||||
int removeChannels(@Param("platformId") Integer platformId, List<CommonGBChannel> channelList);
|
||||
int removeChannelsWithPlatform(@Param("platformId") Integer platformId, List<CommonGBChannel> channelList);
|
||||
|
||||
@Delete("<script> " +
|
||||
"DELETE from wvp_platform_channel WHERE " +
|
||||
"<if test='channelList != null'> AND device_channel_id in " +
|
||||
" <foreach item='item' index='index' collection='channelList' open='(' separator=',' close=')'>" +
|
||||
" #{item.gbId} " +
|
||||
" </foreach> " +
|
||||
"</if>" +
|
||||
"</script>")
|
||||
int removeChannels(List<CommonGBChannel> channelList);
|
||||
|
||||
@Insert("<script> "+
|
||||
"INSERT INTO wvp_platform_group (platform_id, group_id) VALUES " +
|
||||
@@ -406,4 +416,19 @@ public interface PlatformChannelMapper {
|
||||
"<foreach collection='regionSet' item='item' open='(' separator=',' close=')' > #{item.parentId}</foreach>" +
|
||||
" </script>")
|
||||
Set<Region> queryShareParentRegionByRegionSet(Set<Region> regionSet, @Param("platformId") Integer platformId);
|
||||
|
||||
@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 IN" +
|
||||
"<foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
|
||||
"</script> ")
|
||||
List<Platform> queryPlatFormListByChannelList(List<CommonGBChannel> channelList);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.genersoft.iot.vmp.gb28181.service;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
@@ -20,4 +21,6 @@ public interface IPlatformChannelService {
|
||||
int addChannels(Integer platformId, List<Integer> channelIds);
|
||||
|
||||
int removeChannels(Integer platformId, List<Integer> channelIds);
|
||||
|
||||
void removeChannels(List<CommonGBChannel> channelList);
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@ 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;
|
||||
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.DeviceMobilePositionMapper;
|
||||
@@ -17,11 +19,11 @@ 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.IDeviceChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce;
|
||||
import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
@@ -68,6 +70,10 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@Autowired
|
||||
private IPlatformChannelService platformChannelService;
|
||||
|
||||
|
||||
@Override
|
||||
public void updateChannel(String deviceId, DeviceChannel channel) {
|
||||
String channelId = channel.getDeviceId();
|
||||
@@ -503,7 +509,6 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
||||
return false;
|
||||
}
|
||||
int limitCount = 50;
|
||||
boolean result = false;
|
||||
if (!addChannels.isEmpty()) {
|
||||
if (addChannels.size() > limitCount) {
|
||||
for (int i = 0; i < addChannels.size(); i += limitCount) {
|
||||
@@ -511,39 +516,52 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
||||
if (i + limitCount > addChannels.size()) {
|
||||
toIndex = addChannels.size();
|
||||
}
|
||||
result = result || channelMapper.batchAdd(addChannels.subList(i, toIndex)) > 0;
|
||||
channelMapper.batchAdd(addChannels.subList(i, toIndex));
|
||||
}
|
||||
}else {
|
||||
result = channelMapper.batchAdd(addChannels) > 0;
|
||||
channelMapper.batchAdd(addChannels);
|
||||
}
|
||||
}
|
||||
if (!result && !updateChannels.isEmpty()) {
|
||||
if (!updateChannels.isEmpty()) {
|
||||
if (updateChannels.size() > limitCount) {
|
||||
for (int i = 0; i < updateChannels.size(); i += limitCount) {
|
||||
int toIndex = i + limitCount;
|
||||
if (i + limitCount > updateChannels.size()) {
|
||||
toIndex = updateChannels.size();
|
||||
}
|
||||
result = result || channelMapper.batchUpdate(updateChannels.subList(i, toIndex)) > 0;
|
||||
channelMapper.batchUpdate(updateChannels.subList(i, toIndex));
|
||||
}
|
||||
}else {
|
||||
result = channelMapper.batchUpdate(updateChannels) > 0;
|
||||
channelMapper.batchUpdate(updateChannels);
|
||||
}
|
||||
// 不对收到的通道做比较,已确定是否真的发生变化,所以不发送更新通知
|
||||
|
||||
}
|
||||
if (!result && !deleteChannels.isEmpty()) {
|
||||
if (!deleteChannels.isEmpty()) {
|
||||
if (deleteChannels.size() > limitCount) {
|
||||
for (int i = 0; i < deleteChannels.size(); i += limitCount) {
|
||||
int toIndex = i + limitCount;
|
||||
if (i + limitCount > deleteChannels.size()) {
|
||||
toIndex = deleteChannels.size();
|
||||
}
|
||||
result = result || channelMapper.batchDel(deleteChannels.subList(i, toIndex)) < 0;
|
||||
channelMapper.batchDel(deleteChannels.subList(i, toIndex));
|
||||
}
|
||||
}else {
|
||||
result = channelMapper.batchDel(deleteChannels) < 0;
|
||||
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 result;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -536,6 +536,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
return;
|
||||
}
|
||||
commonGBChannelMapper.removeParentIdByChannels(channelList);
|
||||
// TODO 可能需要发送通道更新通知
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.genersoft.iot.vmp.gb28181.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GbCode;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Group;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GroupTree;
|
||||
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.event.EventPublisher;
|
||||
@@ -202,14 +199,22 @@ public class GroupServiceImpl implements IGroupService {
|
||||
gbChannelService.removeParentIdByGroupList(groupListForDelete);
|
||||
}
|
||||
groupManager.batchDelete(groupListForDelete);
|
||||
|
||||
for (Group groupForDelete : groupListForDelete) {
|
||||
// 将变化信息发送通知
|
||||
CommonGBChannel channel = CommonGBChannel.build(groupForDelete);
|
||||
try {
|
||||
// 发送catalog
|
||||
eventPublisher.catalogEventPublish(null, channel, CatalogEvent.DEL);
|
||||
}catch (Exception e) {
|
||||
log.warn("[业务分组/虚拟组织删除] 发送失败,{}", groupForDelete.getDeviceId(), e);
|
||||
// 删除平台关联的分组信息。同时发送通知
|
||||
List<Platform> platformList = groupManager.queryForPlatformByGroupId(groupForDelete.getId());
|
||||
if ( !platformList.isEmpty()) {
|
||||
groupManager.deletePlatformGroup(groupForDelete.getId());
|
||||
// 将变化信息发送通知
|
||||
CommonGBChannel channel = CommonGBChannel.build(groupForDelete);
|
||||
for (Platform platform : platformList) {
|
||||
try {
|
||||
// 发送catalog
|
||||
eventPublisher.catalogEventPublish(platform.getId(), channel, CatalogEvent.DEL);
|
||||
}catch (Exception e) {
|
||||
log.warn("[业务分组/虚拟组织删除] 发送失败,{}", groupForDelete.getDeviceId(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.genersoft.iot.vmp.gb28181.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Group;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Region;
|
||||
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;
|
||||
@@ -273,7 +270,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
public int removeAllChannel(Integer platformId) {
|
||||
List<CommonGBChannel> channelListShare = platformChannelMapper.queryShare(platformId, null);
|
||||
Assert.notEmpty(channelListShare, "未共享任何通道");
|
||||
int result = platformChannelMapper.removeChannels(platformId, channelListShare);
|
||||
int result = platformChannelMapper.removeChannelsWithPlatform(platformId, channelListShare);
|
||||
if (result > 0) {
|
||||
// 查询通道相关的分组信息
|
||||
Set<Region> regionSet = regionMapper.queryByChannelList(channelListShare);
|
||||
@@ -308,7 +305,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
public int removeChannels(Integer platformId, List<Integer> channelIds) {
|
||||
List<CommonGBChannel> channelList = platformChannelMapper.queryShare(platformId, channelIds);
|
||||
Assert.notEmpty(channelList, "所选通道未共享");
|
||||
int result = platformChannelMapper.removeChannels(platformId, channelList);
|
||||
int result = platformChannelMapper.removeChannelsWithPlatform(platformId, channelList);
|
||||
if (result > 0) {
|
||||
// 查询通道相关的分组信息
|
||||
Set<Region> regionSet = regionMapper.queryByChannelList(channelList);
|
||||
@@ -337,4 +334,46 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeChannels(List<CommonGBChannel> channelList) {
|
||||
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelList(channelList);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
// 查询通道相关的分组信息
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
// 发送消息
|
||||
try {
|
||||
// 发送catalog
|
||||
eventPublisher.catalogEventPublish(platform.getId(), channelList, CatalogEvent.DEL);
|
||||
} catch (Exception e) {
|
||||
log.warn("[移除关联通道] 发送失败,数量:{}", channelList.size(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
|
||||
return;
|
||||
}
|
||||
SIPRequest request = (SIPRequest) evt.getRequest();
|
||||
log.info("[收到心跳] device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId());
|
||||
log.debug("[收到心跳] device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId());
|
||||
if (userSetting.getGbDeviceOnline() == 0 && !device.isOnLine()) {
|
||||
log.warn("[收到心跳] 设备离线,心跳不进行回复, device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId());
|
||||
return;
|
||||
|
||||
@@ -105,7 +105,7 @@ public class ZLMMediaServerStatusManger {
|
||||
if (serverItem == null) {
|
||||
return;
|
||||
}
|
||||
log.info("[ZLM-HOOK事件-心跳] ID:" + event.getMediaServerItem().getId());
|
||||
log.debug("[ZLM-HOOK事件-心跳] ID:" + event.getMediaServerItem().getId());
|
||||
online(serverItem, null);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user