通道编辑修复分组路径显示异常,支持行政区划路径显示

This commit is contained in:
lin
2025-11-19 17:03:45 +08:00
parent c1c9c7957b
commit 033db1925c
21 changed files with 279 additions and 158 deletions

View File

@@ -396,4 +396,56 @@ public class CommonGBChannel {
return commonGBChannel;
}
@Override
public String toString() {
return "CommonGBChannel{" +
"gbId=" + gbId +
", gbDeviceId='" + gbDeviceId + '\'' +
", gbName='" + gbName + '\'' +
", gbManufacturer='" + gbManufacturer + '\'' +
", gbModel='" + gbModel + '\'' +
", gbOwner='" + gbOwner + '\'' +
", gbCivilCode='" + gbCivilCode + '\'' +
", gbBlock='" + gbBlock + '\'' +
", gbAddress='" + gbAddress + '\'' +
", gbParental=" + gbParental +
", gbParentId='" + gbParentId + '\'' +
", gbSafetyWay=" + gbSafetyWay +
", gbRegisterWay=" + gbRegisterWay +
", gbCertNum='" + gbCertNum + '\'' +
", gbCertifiable=" + gbCertifiable +
", gbErrCode=" + gbErrCode +
", gbEndTime='" + gbEndTime + '\'' +
", gbSecrecy=" + gbSecrecy +
", gbIpAddress='" + gbIpAddress + '\'' +
", gbPort=" + gbPort +
", gbPassword='" + gbPassword + '\'' +
", gbStatus='" + gbStatus + '\'' +
", gbLongitude=" + gbLongitude +
", gbLatitude=" + gbLatitude +
", gpsAltitude=" + gpsAltitude +
", gpsSpeed=" + gpsSpeed +
", gpsDirection=" + gpsDirection +
", gpsTime='" + gpsTime + '\'' +
", gbBusinessGroupId='" + gbBusinessGroupId + '\'' +
", gbPtzType=" + gbPtzType +
", gbPositionType=" + gbPositionType +
", gbRoomType=" + gbRoomType +
", gbUseType=" + gbUseType +
", gbSupplyLightType=" + gbSupplyLightType +
", gbDirectionType=" + gbDirectionType +
", gbResolution='" + gbResolution + '\'' +
", gbDownloadSpeed='" + gbDownloadSpeed + '\'' +
", gbSvcSpaceSupportMod=" + gbSvcSpaceSupportMod +
", gbSvcTimeSupportMode=" + gbSvcTimeSupportMode +
", recordPLan=" + recordPLan +
", dataType=" + dataType +
", dataDeviceId=" + dataDeviceId +
", createTime='" + createTime + '\'' +
", updateTime='" + updateTime + '\'' +
", streamId='" + streamId + '\'' +
", enableBroadcast=" + enableBroadcast +
", mapLevel=" + mapLevel +
'}';
}
}

View File

@@ -32,7 +32,8 @@ public class SubscribeHolder {
public void putCatalogSubscribe(String platformId, SubscribeInfo subscribeInfo) {
log.info("[国标级联] 添加目录订阅,平台: {} 有效期: {}", platformId, subscribeInfo.getExpires());
String key = String.format("%s_%s_%s_%s", prefix, userSetting.getServerId(), "catalog", platformId);
subscribeInfo.setServerId(userSetting.getServerId());
String key = String.format("%s:%s:%s", prefix, "catalog", platformId);
if (subscribeInfo.getExpires() > 0) {
Duration duration = Duration.ofSeconds(subscribeInfo.getExpires());
redisTemplate.opsForValue().set(key, subscribeInfo, duration);
@@ -42,18 +43,19 @@ public class SubscribeHolder {
}
public SubscribeInfo getCatalogSubscribe(String platformId) {
String key = String.format("%s_%s_%s_%s", prefix, userSetting.getServerId(), "catalog", platformId);
String key = String.format("%s:%s:%s", prefix, "catalog", platformId);
return (SubscribeInfo)redisTemplate.opsForValue().get(key);
}
public void removeCatalogSubscribe(String platformId) {
String key = String.format("%s_%s_%s_%s", prefix, userSetting.getServerId(), "catalog", platformId);
String key = String.format("%s:%s:%s", prefix, "catalog", platformId);
redisTemplate.delete(key);
}
public void putMobilePositionSubscribe(String platformId, SubscribeInfo subscribeInfo, Runnable gpsTask) {
log.info("[国标级联] 添加移动位置订阅,平台: {} 有效期: {}s", platformId, subscribeInfo.getExpires());
String key = String.format("%s_%s_%s_%s", prefix, userSetting.getServerId(), "mobilePosition", platformId);
subscribeInfo.setServerId(userSetting.getServerId());
String key = String.format("%s:%s:%s", prefix, "mobilePosition", platformId);
if (subscribeInfo.getExpires() > 0) {
Duration duration = Duration.ofSeconds(subscribeInfo.getExpires());
redisTemplate.opsForValue().set(key, subscribeInfo, duration);
@@ -81,12 +83,12 @@ public class SubscribeHolder {
}
public SubscribeInfo getMobilePositionSubscribe(String platformId) {
String key = String.format("%s_%s_%s_%s", prefix, userSetting.getServerId(), "mobilePosition", platformId);
String key = String.format("%s:%s:%s", prefix, "mobilePosition", platformId);
return (SubscribeInfo)redisTemplate.opsForValue().get(key);
}
public void removeMobilePositionSubscribe(String platformId) {
String key = String.format("%s_%s_%s_%s", prefix, userSetting.getServerId(), "mobilePosition", platformId);
String key = String.format("%s:%s:%s", prefix, "mobilePosition", platformId);
redisTemplate.delete(key);
}
@@ -96,7 +98,7 @@ public class SubscribeHolder {
}
List<String> result = new ArrayList<>();
for (Platform platform : platformList) {
String key = String.format("%s_%s_%s_%s", prefix, userSetting.getServerId(), "catalog", platform.getServerGBId());
String key = String.format("%s:%s:%s", prefix, "catalog", platform.getServerGBId());
if (redisTemplate.hasKey(key)) {
result.add(platform.getServerGBId());
}
@@ -110,7 +112,7 @@ public class SubscribeHolder {
}
List<String> result = new ArrayList<>();
for (Platform platform : platformList) {
String key = String.format("%s_%s_%s_%s", prefix, userSetting.getServerId(), "mobilePosition", platform.getServerGBId());
String key = String.format("%s:%s:%s", prefix, "mobilePosition", platform.getServerGBId());
if (redisTemplate.hasKey(key)) {
result.add(platform.getServerGBId());
}

View File

@@ -37,6 +37,11 @@ public class SubscribeInfo {
*/
private String simulatedCallId;
/**
* 来源serverId
*/
private String serverId;
public static SubscribeInfo getInstance(SIPResponse response, String id, int expires, EventHeader eventHeader){
SubscribeInfo subscribeInfo = new SubscribeInfo();

View File

@@ -22,13 +22,13 @@ public interface DeviceChannelMapper {
"insert into wvp_device_channel " +
"(device_id, data_type, data_device_id, name, manufacturer, model, owner, civil_code, block, " +
"address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, end_time, secrecy, " +
"ip_address, port, password, status, longitude, latitude, gb_longitude, gb_latitude, ptz_type, position_type, room_type, use_type, " +
"ip_address, port, password, status, longitude, latitude, ptz_type, position_type, room_type, use_type, " +
"supply_light_type, direction_type, resolution, business_group_id, download_speed, svc_space_support_mod, " +
"svc_time_support_mode, create_time, update_time, sub_count, stream_id, has_audio, gps_time, stream_identification, channel_type) " +
"values " +
"(#{deviceId}, #{dataType}, #{dataDeviceId}, #{name}, #{manufacturer}, #{model}, #{owner}, #{civilCode}, #{block}, " +
"#{address}, #{parental}, #{parentId}, #{safetyWay}, #{registerWay}, #{certNum}, #{certifiable}, #{errCode}, #{endTime}, #{secrecy}, " +
"#{ipAddress}, #{port}, #{password}, #{status}, #{longitude}, #{latitude}, #{gbLongitude}, #{gbLatitude}, #{ptzType}, #{positionType}, #{roomType}, #{useType}, " +
"#{ipAddress}, #{port}, #{password}, #{status}, #{longitude}, #{latitude}, #{ptzType}, #{positionType}, #{roomType}, #{useType}, " +
"#{supplyLightType}, #{directionType}, #{resolution}, #{businessGroupId}, #{downloadSpeed}, #{svcSpaceSupportMod}," +
" #{svcTimeSupportMode}, #{createTime}, #{updateTime}, #{subCount}, #{streamId}, #{hasAudio}, #{gpsTime}, #{streamIdentification}, #{channelType}) " +
"</script>")
@@ -63,8 +63,6 @@ public interface DeviceChannelMapper {
", status=#{status}" +
", longitude=#{longitude}" +
", latitude=#{latitude}" +
", gb_longitude=#{gbLongitude}" +
", gb_latitude=#{gbLatitude}" +
", ptz_type=#{ptzType}" +
", position_type=#{positionType}" +
", room_type=#{roomType}" +
@@ -200,14 +198,14 @@ public interface DeviceChannelMapper {
"insert into wvp_device_channel " +
"(device_id, data_type, data_device_id, name, manufacturer, model, owner, civil_code, block, " +
"address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, end_time, secrecy, " +
"ip_address, port, password, status, longitude, latitude, gb_longitude, gb_latitude, ptz_type, position_type, room_type, use_type, " +
"ip_address, port, password, status, longitude, latitude, ptz_type, position_type, room_type, use_type, " +
"supply_light_type, direction_type, resolution, business_group_id, download_speed, svc_space_support_mod, " +
"svc_time_support_mode, create_time, update_time, sub_count, stream_id, has_audio, gps_time, stream_identification, channel_type) " +
"values " +
"<foreach collection='addChannels' index='index' item='item' separator=','> " +
"(#{item.deviceId}, #{item.dataType}, #{item.dataDeviceId}, #{item.name}, #{item.manufacturer}, #{item.model}, #{item.owner}, #{item.civilCode}, #{item.block}, " +
"#{item.address}, #{item.parental}, #{item.parentId}, #{item.safetyWay}, #{item.registerWay}, #{item.certNum}, #{item.certifiable}, #{item.errCode}, #{item.endTime}, #{item.secrecy}, " +
"#{item.ipAddress}, #{item.port}, #{item.password}, #{item.status}, #{item.longitude}, #{item.latitude}, #{item.gbLongitude}, #{item.gbLatitude}, #{item.ptzType}, #{item.positionType}, #{item.roomType}, #{item.useType}, " +
"#{item.ipAddress}, #{item.port}, #{item.password}, #{item.status}, #{item.longitude}, #{item.latitude}, #{item.ptzType}, #{item.positionType}, #{item.roomType}, #{item.useType}, " +
"#{item.supplyLightType}, #{item.directionType}, #{item.resolution}, #{item.businessGroupId}, #{item.downloadSpeed}, #{item.svcSpaceSupportMod}," +
" #{item.svcTimeSupportMode}, #{item.createTime}, #{item.updateTime}, #{item.subCount}, #{item.streamId}, #{item.hasAudio}, #{item.gpsTime}, #{item.streamIdentification}, #{item.channelType}) " +
"</foreach> " +
@@ -534,8 +532,6 @@ public interface DeviceChannelMapper {
", status=#{status}" +
", longitude=#{longitude}" +
", latitude=#{latitude}" +
", gb_longitude=#{gbLongitude}" +
", gb_latitude=#{gbLatitude}" +
", ptz_type=#{ptzType}" +
", position_type=#{positionType}" +
", room_type=#{roomType}" +

View File

@@ -65,16 +65,19 @@ public class EventPublisher {
}
public void channelEventPublishForUpdate(CommonGBChannel commonGBChannel, CommonGBChannel deviceChannelForOld) {
log.info("[通道改变内部分发-更新] {}", commonGBChannel.getGbDeviceId());
ChannelEvent channelEvent = ChannelEvent.getInstanceForUpdate(this, Collections.singletonList(commonGBChannel), Collections.singletonList(deviceChannelForOld));
applicationEventPublisher.publishEvent(channelEvent);
}
public void channelEventPublishForUpdate(List<CommonGBChannel> channelList, List<CommonGBChannel> channelListForOld) {
log.info("[通道改变内部分发-更新] 数量: {}", channelList.size());
ChannelEvent channelEvent = ChannelEvent.getInstanceForUpdate(this, channelList, channelListForOld);
applicationEventPublisher.publishEvent(channelEvent);
}
public void channelEventPublish(List<CommonGBChannel> channelList, ChannelEvent.ChannelEventMessageType type) {
log.info("[通道改变内部分发-{}] 数量: {}", type, channelList.size());
ChannelEvent channelEvent = ChannelEvent.getInstance(this, type, channelList);
applicationEventPublisher.publishEvent(channelEvent);
}

View File

@@ -24,11 +24,11 @@ public interface IGbChannelService {
int offline(CommonGBChannel commonGBChannel);
int offline(List<CommonGBChannel> commonGBChannelList);
int offline(List<CommonGBChannel> commonGBChannelList, boolean permission);
int online(CommonGBChannel commonGBChannel);
int online(List<CommonGBChannel> commonGBChannelList);
int online(List<CommonGBChannel> commonGBChannelList, boolean permission);
void batchAdd(List<CommonGBChannel> commonGBChannels);
@@ -78,7 +78,7 @@ public interface IGbChannelService {
void deleteChannelToGroupByGbDevice(List<Integer> deviceIds);
void batchUpdate(List<CommonGBChannel> commonGBChannels);
void batchUpdateForStreamPushRedisMsg(List<CommonGBChannel> commonGBChannels, boolean permission);
CommonGBChannel queryOneWithPlatform(Integer platformId, String channelDeviceId);

View File

@@ -187,7 +187,7 @@ public class GbChannelServiceImpl implements IGbChannelService, CommandLineRunne
@Override
public int update(CommonGBChannel commonGBChannel) {
log.info("[更新通道] 通道ID: {}, ", commonGBChannel.getGbId());
log.info("[更新通道] 通道ID: {}, ", commonGBChannel.toString());
if (commonGBChannel.getGbId() <= 0) {
log.warn("[更新通道] 未找到数据库ID更新失败 {}({})", commonGBChannel.getGbName(), commonGBChannel.getGbDeviceId());
return 0;
@@ -248,32 +248,33 @@ public class GbChannelServiceImpl implements IGbChannelService, CommandLineRunne
@Override
@Transactional
public int offline(List<CommonGBChannel> commonGBChannelList) {
public int offline(List<CommonGBChannel> commonGBChannelList, boolean permission) {
if (commonGBChannelList.isEmpty()) {
log.warn("[多个通道离线] 通道数量为0更新失败");
return 0;
}
log.info("[通道离线] 共 {} 个", commonGBChannelList.size());
int limitCount = 1000;
int result = 0;
if (commonGBChannelList.size() > limitCount) {
for (int i = 0; i < commonGBChannelList.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > commonGBChannelList.size()) {
toIndex = commonGBChannelList.size();
if (permission) {
int limitCount = 1000;
if (commonGBChannelList.size() > limitCount) {
for (int i = 0; i < commonGBChannelList.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > commonGBChannelList.size()) {
toIndex = commonGBChannelList.size();
}
result += commonGBChannelMapper.updateStatusForListById(commonGBChannelList.subList(i, toIndex), "OFF");
}
result += commonGBChannelMapper.updateStatusForListById(commonGBChannelList.subList(i, toIndex), "OFF");
} else {
result += commonGBChannelMapper.updateStatusForListById(commonGBChannelList, "OFF");
}
} else {
result += commonGBChannelMapper.updateStatusForListById(commonGBChannelList, "OFF");
log.info("[通道离线] 保存入库 共 {} 个改变", result);
}
if (result > 0) {
try {
// 发送catalog
eventPublisher.channelEventPublish(commonGBChannelList, ChannelEvent.ChannelEventMessageType.OFF);
} catch (Exception e) {
log.warn("[多个通道离线] 发送失败,数量:{}", commonGBChannelList.size(), e);
}
try {
// 发送catalog
eventPublisher.channelEventPublish(commonGBChannelList, ChannelEvent.ChannelEventMessageType.OFF);
} catch (Exception e) {
log.warn("[多个通道离线] 发送失败,数量:{}", commonGBChannelList.size(), e);
}
return result;
}
@@ -298,24 +299,26 @@ public class GbChannelServiceImpl implements IGbChannelService, CommandLineRunne
@Override
@Transactional
public int online(List<CommonGBChannel> commonGBChannelList) {
public int online(List<CommonGBChannel> commonGBChannelList, boolean permission) {
if (commonGBChannelList.isEmpty()) {
log.warn("[多个通道上线] 通道数量为0更新失败");
return 0;
}
// 批量更新
int limitCount = 1000;
int result = 0;
if (commonGBChannelList.size() > limitCount) {
for (int i = 0; i < commonGBChannelList.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > commonGBChannelList.size()) {
toIndex = commonGBChannelList.size();
if (permission) {
// 批量更新
int limitCount = 1000;
if (commonGBChannelList.size() > limitCount) {
for (int i = 0; i < commonGBChannelList.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > commonGBChannelList.size()) {
toIndex = commonGBChannelList.size();
}
result += commonGBChannelMapper.updateStatusForListById(commonGBChannelList.subList(i, toIndex), "ON");
}
result += commonGBChannelMapper.updateStatusForListById(commonGBChannelList.subList(i, toIndex), "ON");
} else {
result += commonGBChannelMapper.updateStatusForListById(commonGBChannelList, "ON");
}
} else {
result += commonGBChannelMapper.updateStatusForListById(commonGBChannelList, "ON");
}
try {
// 发送catalog
@@ -358,27 +361,29 @@ public class GbChannelServiceImpl implements IGbChannelService, CommandLineRunne
}
@Override
public void batchUpdate(List<CommonGBChannel> commonGBChannels) {
public void batchUpdateForStreamPushRedisMsg(List<CommonGBChannel> commonGBChannels, boolean permission) {
if (commonGBChannels.isEmpty()) {
log.warn("[更新多个通道] 通道数量为0更新失败");
return;
}
List<CommonGBChannel> oldCommonGBChannelList = commonGBChannelMapper.queryOldChanelListByChannels(commonGBChannels);
// 批量保存
int limitCount = 1000;
int result = 0;
if (commonGBChannels.size() > limitCount) {
for (int i = 0; i < commonGBChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > commonGBChannels.size()) {
toIndex = commonGBChannels.size();
if (permission) {
// 批量保存
int limitCount = 1000;
int result = 0;
if (commonGBChannels.size() > limitCount) {
for (int i = 0; i < commonGBChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > commonGBChannels.size()) {
toIndex = commonGBChannels.size();
}
result += commonGBChannelMapper.batchUpdate(commonGBChannels.subList(i, toIndex));
}
result += commonGBChannelMapper.batchUpdate(commonGBChannels.subList(i, toIndex));
} else {
result += commonGBChannelMapper.batchUpdate(commonGBChannels);
}
} else {
result += commonGBChannelMapper.batchUpdate(commonGBChannels);
log.info("[更新多个通道] 通道数量为{},成功保存:{}", commonGBChannels.size(), result);
}
log.info("[更新多个通道] 通道数量为{},成功保存:{}", commonGBChannels.size(), result);
// 发送通过更新通知
try {
// 发送通知

View File

@@ -269,14 +269,12 @@ public class GroupServiceImpl implements IGroupService {
if (businessGroupInDb == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "业务分组不存在");
}
List<Group> groupList = new LinkedList<>();
groupList.add(businessGroupInDb);
Group group = groupManager.queryOneByDeviceId(deviceId, businessGroup);
if (group == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "虚拟组织不存在");
}
List<Group> allParent = getAllParent(group);
groupList.addAll(allParent);
List<Group> groupList = new LinkedList<>(allParent);
groupList.add(group);
return groupList;
}
@@ -286,10 +284,9 @@ public class GroupServiceImpl implements IGroupService {
return new ArrayList<>();
}
List<Group> groupList = new ArrayList<>();
Group parent = groupManager.queryOneByDeviceId(group.getParentDeviceId(), group.getBusinessGroup());
if (parent == null) {
return groupList;
return new ArrayList<>();
}
List<Group> allParent = getAllParent(parent);
allParent.add(parent);

View File

@@ -236,8 +236,9 @@ public class RegionServiceImpl implements IRegionService {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "行政区划不存在");
}
List<Region> allParent = getAllParent(region);
allParent.add(region);
return allParent;
List<Region> regionList = new LinkedList<>(allParent);
regionList.add(region);
return regionList;
}
@@ -246,15 +247,13 @@ public class RegionServiceImpl implements IRegionService {
return new ArrayList<>();
}
List<Region> regionList = new LinkedList<>();
Region parent = regionMapper.queryByDeviceId(region.getParentDeviceId());
if (parent == null) {
return regionList;
return new ArrayList<>();
}
regionList.add(parent);
List<Region> allParent = getAllParent(parent);
regionList.addAll(allParent);
return regionList;
allParent.add(parent);
return allParent;
}
@Override