Merge remote-tracking branch 'origin/dev/master-通道结构重构' into dev/master-通道结构重构

pull/1642/head
648540858 2024-09-28 12:48:05 +08:00
commit b4688f53dc
17 changed files with 171 additions and 106 deletions

View File

@ -10,7 +10,7 @@ import lombok.Data;
@Schema(description = "业务分组树") @Schema(description = "业务分组树")
public class GroupTree extends Group{ public class GroupTree extends Group{
@Schema(description = "是否有子节点") @Schema(description = "树节点ID")
private String treeId; private String treeId;
@Schema(description = "是否有子节点") @Schema(description = "是否有子节点")

View File

@ -10,6 +10,9 @@ import lombok.Data;
@Schema(description = "区域树") @Schema(description = "区域树")
public class RegionTree extends Region { public class RegionTree extends Region {
@Schema(description = "树节点ID")
private String treeId;
@Schema(description = "是否有子节点") @Schema(description = "是否有子节点")
private boolean isLeaf; private boolean isLeaf;

View File

@ -263,6 +263,7 @@ public interface CommonGBChannelMapper {
@Select("<script>" + @Select("<script>" +
" select " + " select " +
" id," + " id," +
" concat('channel', id) as tree_id," +
" coalesce(gb_device_id, device_id) as device_id," + " coalesce(gb_device_id, device_id) as device_id," +
" coalesce(gb_name, name) as name, " + " coalesce(gb_name, name) as name, " +
" coalesce(gb_parent_id, parent_id) as parent_device_id, " + " coalesce(gb_parent_id, parent_id) as parent_device_id, " +
@ -352,6 +353,7 @@ public interface CommonGBChannelMapper {
@Select("<script>" + @Select("<script>" +
" select " + " select " +
" id," + " id," +
" concat('channel', id) as tree_id," +
" coalesce(gb_device_id, device_id) as device_id," + " coalesce(gb_device_id, device_id) as device_id," +
" coalesce(gb_name, name) as name, " + " coalesce(gb_name, name) as name, " +
" coalesce(gb_parent_id, parent_id) as parent_device_id, " + " coalesce(gb_parent_id, parent_id) as parent_device_id, " +

View File

@ -688,18 +688,10 @@ public interface DeviceChannelMapper {
@Update({"<script>" + @Update({"<script>" +
"<foreach collection='channels' item='item' separator=';'>" + "<foreach collection='channels' item='item' separator=';'>" +
"UPDATE wvp_device_channel SET status='ON' WHERE device_id=#{item.deviceId}" + "UPDATE wvp_device_channel SET status=#{item.status} WHERE device_id=#{item.deviceId}" +
"</foreach>" + "</foreach>" +
"</script>"}) "</script>"})
int batchOnlineForNotify(List<DeviceChannel> channels); int batchUpdateStatus(List<DeviceChannel> channels);
@Update({"<script>" +
"<foreach collection='channels' item='item' separator=';'>" +
"UPDATE wvp_device_channel SET status='OFF' WHERE device_id=#{item.deviceId}" +
"</foreach>" +
"</script>"})
int batchOfflineForNotify(List<DeviceChannel> channels);
@Select("select count(1) from wvp_device_channel where status = 'ON'") @Select("select count(1) from wvp_device_channel where status = 'ON'")
int getOnlineCount(); int getOnlineCount();

View File

@ -67,6 +67,7 @@ public interface GroupMapper {
@Select(" <script>" + @Select(" <script>" +
" SELECT " + " SELECT " +
" * , " + " * , " +
" concat('group', id) as tree_id," +
" 0 as type," + " 0 as type," +
" false as is_leaf" + " false as is_leaf" +
" from wvp_common_group " + " from wvp_common_group " +

View File

@ -72,6 +72,7 @@ public interface RegionMapper {
@Select(" <script>" + @Select(" <script>" +
" SELECT " + " SELECT " +
" *, " + " *, " +
" concat('region', id) as tree_id," +
" 0 as type," + " 0 as type," +
" false as is_leaf" + " false as is_leaf" +
" from wvp_common_region " + " from wvp_common_region " +

View File

@ -96,10 +96,10 @@ public class ChannelProvider {
sqlBuild.append(" AND coalesce(gb_civil_code, civil_code) is null"); sqlBuild.append(" AND coalesce(gb_civil_code, civil_code) is null");
} }
if (params.get("hasGroup") != null && (Boolean)params.get("hasGroup")) { if (params.get("hasGroup") != null && (Boolean)params.get("hasGroup")) {
sqlBuild.append(" AND coalesce(gb_business_group_id, business_group_id) is not null"); sqlBuild.append(" AND coalesce(gb_parent_id, parent_id) is not null");
} }
if (params.get("hasGroup") != null && !(Boolean)params.get("hasGroup")) { if (params.get("hasGroup") != null && !(Boolean)params.get("hasGroup")) {
sqlBuild.append(" AND coalesce(gb_business_group_id, business_group_id) is null"); sqlBuild.append(" AND coalesce(gb_parent_id, parent_id) is null");
} }
return sqlBuild.toString(); return sqlBuild.toString();
} }

View File

@ -3,8 +3,8 @@ package com.genersoft.iot.vmp.gb28181.service;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce; import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce;
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
@ -47,15 +47,7 @@ public interface IDeviceChannelService {
*/ */
int deleteChannelsForNotify(List<DeviceChannel> deleteChannelList); int deleteChannelsForNotify(List<DeviceChannel> deleteChannelList);
/** int updateChannelsStatus(List<DeviceChannel> channels);
* 线
*/
int channelsOnlineForNotify(List<DeviceChannel> channels);
/**
* 线
*/
int channelsOfflineForNotify(List<DeviceChannel> channels);
/** /**
* *

View File

@ -193,13 +193,45 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
} }
@Override @Override
public int deleteChannelsForNotify(List<DeviceChannel> deleteChannelList) { @Transactional
return channelMapper.batchDelForNotify(deleteChannelList); public int deleteChannelsForNotify(List<DeviceChannel> channels) {
int limitCount = 1000;
int result = 0;
if (!channels.isEmpty()) {
if (channels.size() > limitCount) {
for (int i = 0; i < channels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > channels.size()) {
toIndex = channels.size();
}
result += channelMapper.batchDel(channels.subList(i, toIndex));
}
}else {
result += channelMapper.batchDel(channels);
}
}
return result;
} }
@Transactional
@Override @Override
public int channelsOnlineForNotify(List<DeviceChannel> channels) { public int updateChannelsStatus(List<DeviceChannel> channels) {
return channelMapper.batchOnlineForNotify(channels); int limitCount = 1000;
int result = 0;
if (!channels.isEmpty()) {
if (channels.size() > limitCount) {
for (int i = 0; i < channels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > channels.size()) {
toIndex = channels.size();
}
result += channelMapper.batchUpdateStatus(channels.subList(i, toIndex));
}
}else {
result += channelMapper.batchUpdateStatus(channels);
}
}
return result;
} }
@Override @Override
@ -207,12 +239,6 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
channelMapper.online(channel.getId()); channelMapper.online(channel.getId());
} }
@Override
public int channelsOfflineForNotify(List<DeviceChannel> channels) {
return channelMapper.batchOfflineForNotify(channels);
}
@Override @Override
public void offline(DeviceChannel channel) { public void offline(DeviceChannel channel) {
channelMapper.offline(channel.getId()); channelMapper.offline(channel.getId());
@ -242,6 +268,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
} }
@Override @Override
@Transactional
public synchronized void batchUpdateChannelForNotify(List<DeviceChannel> channels) { public synchronized void batchUpdateChannelForNotify(List<DeviceChannel> channels) {
String now = DateUtil.getNow(); String now = DateUtil.getNow();
for (DeviceChannel channel : channels) { for (DeviceChannel channel : channels) {
@ -264,8 +291,27 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
} }
@Override @Override
@Transactional
public void batchAddChannel(List<DeviceChannel> channels) { public void batchAddChannel(List<DeviceChannel> channels) {
String now = DateUtil.getNow();
for (DeviceChannel channel : channels) {
channel.setUpdateTime(now);
channel.setCreateTime(now);
}
int limitCount = 1000;
if (!channels.isEmpty()) {
if (channels.size() > limitCount) {
for (int i = 0; i < channels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > channels.size()) {
toIndex = channels.size();
}
channelMapper.batchAdd(channels.subList(i, toIndex));
}
}else {
channelMapper.batchAdd(channels); channelMapper.batchAdd(channels);
}
}
for (DeviceChannel channel : channels) { for (DeviceChannel channel : channels) {
if (channel.getParentId() != null) { if (channel.getParentId() != null) {
channelMapper.updateChannelSubCount(channel.getDeviceDbId(), channel.getParentId()); channelMapper.updateChannelSubCount(channel.getDeviceDbId(), channel.getParentId());
@ -340,7 +386,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("time", DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(mobilePosition.getTime())); jsonObject.put("time", DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(mobilePosition.getTime()));
jsonObject.put("serial", mobilePosition.getDeviceId()); jsonObject.put("serial", mobilePosition.getDeviceId());
jsonObject.put("code", mobilePosition.getChannelId()); jsonObject.put("code", channel.getDeviceId());
jsonObject.put("longitude", mobilePosition.getLongitude()); jsonObject.put("longitude", mobilePosition.getLongitude());
jsonObject.put("latitude", mobilePosition.getLatitude()); jsonObject.put("latitude", mobilePosition.getLatitude());
jsonObject.put("altitude", mobilePosition.getAltitude()); jsonObject.put("altitude", mobilePosition.getAltitude());

View File

@ -39,8 +39,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
@Component @Component
public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent { public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent {
private final List<DeviceChannel> updateChannelOnlineList = new CopyOnWriteArrayList<>(); private final List<DeviceChannel> updateChannelForStatusChange = new CopyOnWriteArrayList<>();
private final List<DeviceChannel> updateChannelOfflineList = new CopyOnWriteArrayList<>();
private final Map<String, DeviceChannel> updateChannelMap = new ConcurrentHashMap<>(); private final Map<String, DeviceChannel> updateChannelMap = new ConcurrentHashMap<>();
private final Map<String, DeviceChannel> addChannelMap = new ConcurrentHashMap<>(); private final Map<String, DeviceChannel> addChannelMap = new ConcurrentHashMap<>();
@ -60,6 +59,10 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
@Autowired @Autowired
private IDeviceChannelService deviceChannelService; private IDeviceChannelService deviceChannelService;
// @Scheduled(fixedRate = 2000) //每400毫秒执行一次
// public void showSize(){
// log.warn("[notify-目录订阅] 待处理消息数量: {}", taskQueue.size() );
// }
@Transactional @Transactional
public void process(RequestEvent evt) { public void process(RequestEvent evt) {
@ -75,7 +78,14 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
if (taskQueue.isEmpty()) { if (taskQueue.isEmpty()) {
return; return;
} }
for (HandlerCatchData take : taskQueue) { List<HandlerCatchData> handlerCatchDataList = new ArrayList<>();
while (!taskQueue.isEmpty()) {
handlerCatchDataList.add(taskQueue.poll());
}
if (handlerCatchDataList.isEmpty()) {
return;
}
for (HandlerCatchData take : handlerCatchDataList) {
if (take == null) { if (take == null) {
continue; continue;
} }
@ -119,14 +129,17 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
log.error("[解析CatalogChannelEvent]失败原文: \n{}", new String(evt.getRequest().getRawContent(), Charset.forName(device.getCharset()))); log.error("[解析CatalogChannelEvent]失败原文: \n{}", new String(evt.getRequest().getRawContent(), Charset.forName(device.getCharset())));
continue; continue;
} }
if (log.isDebugEnabled()){
log.info("[收到目录订阅]{}/{}-{}", device.getDeviceId(), log.debug("[收到目录订阅]{}/{}-{}", device.getDeviceId(),
catalogChannelEvent.getChannel().getDeviceId(), catalogChannelEvent.getEvent()); catalogChannelEvent.getChannel().getDeviceId(), catalogChannelEvent.getEvent());
}
DeviceChannel channel = catalogChannelEvent.getChannel();
switch (catalogChannelEvent.getEvent()) { switch (catalogChannelEvent.getEvent()) {
case CatalogEvent.ON: case CatalogEvent.ON:
// 上线 // 上线
log.info("[收到通道上线通知] 来自设备: {}, 通道 {}", device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId()); log.info("[收到通道上线通知] 来自设备: {}, 通道 {}", device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId());
updateChannelOnlineList.add(catalogChannelEvent.getChannel()); channel.setStatus("ON");
updateChannelForStatusChange.add(channel);
if (userSetting.getDeviceStatusNotify()) { if (userSetting.getDeviceStatusNotify()) {
// 发送redis消息 // 发送redis消息
redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId(), true); redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId(), true);
@ -138,7 +151,8 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
if (userSetting.getRefuseChannelStatusChannelFormNotify()) { if (userSetting.getRefuseChannelStatusChannelFormNotify()) {
log.info("[收到通道离线通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId()); log.info("[收到通道离线通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId());
} else { } else {
updateChannelOfflineList.add(catalogChannelEvent.getChannel()); channel.setStatus("OFF");
updateChannelForStatusChange.add(channel);
if (userSetting.getDeviceStatusNotify()) { if (userSetting.getDeviceStatusNotify()) {
// 发送redis消息 // 发送redis消息
redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId(), false); redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId(), false);
@ -151,7 +165,8 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
if (userSetting.getRefuseChannelStatusChannelFormNotify()) { if (userSetting.getRefuseChannelStatusChannelFormNotify()) {
log.info("[收到通道视频丢失通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId()); log.info("[收到通道视频丢失通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId());
} else { } else {
updateChannelOfflineList.add(catalogChannelEvent.getChannel()); channel.setStatus("OFF");
updateChannelForStatusChange.add(channel);
if (userSetting.getDeviceStatusNotify()) { if (userSetting.getDeviceStatusNotify()) {
// 发送redis消息 // 发送redis消息
redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId(), false); redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId(), false);
@ -164,7 +179,8 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
if (userSetting.getRefuseChannelStatusChannelFormNotify()) { if (userSetting.getRefuseChannelStatusChannelFormNotify()) {
log.info("[收到通道视频故障通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId()); log.info("[收到通道视频故障通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId());
} else { } else {
updateChannelOfflineList.add(catalogChannelEvent.getChannel()); channel.setStatus("OFF");
updateChannelForStatusChange.add(channel);
if (userSetting.getDeviceStatusNotify()) { if (userSetting.getDeviceStatusNotify()) {
// 发送redis消息 // 发送redis消息
redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId(), false); redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId(), false);
@ -178,7 +194,6 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
DeviceChannel deviceChannel = deviceChannelService.getOne(deviceId, catalogChannelEvent.getChannel().getDeviceId()); DeviceChannel deviceChannel = deviceChannelService.getOne(deviceId, catalogChannelEvent.getChannel().getDeviceId());
if (deviceChannel != null) { if (deviceChannel != null) {
log.info("[增加通道] 已存在,不发送通知只更新,设备: {}, 通道 {}", device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId()); log.info("[增加通道] 已存在,不发送通知只更新,设备: {}, 通道 {}", device.getDeviceId(), catalogChannelEvent.getChannel().getDeviceId());
DeviceChannel channel = catalogChannelEvent.getChannel();
channel.setId(deviceChannel.getId()); channel.setId(deviceChannel.getId());
channel.setHasAudio(deviceChannel.isHasAudio()); channel.setHasAudio(deviceChannel.isHasAudio());
channel.setUpdateTime(DateUtil.getNow()); channel.setUpdateTime(DateUtil.getNow());
@ -210,7 +225,6 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
// 判断此通道是否存在 // 判断此通道是否存在
DeviceChannel deviceChannelForUpdate = deviceChannelService.getOne(deviceId, catalogChannelEvent.getChannel().getDeviceId()); DeviceChannel deviceChannelForUpdate = deviceChannelService.getOne(deviceId, catalogChannelEvent.getChannel().getDeviceId());
if (deviceChannelForUpdate != null) { if (deviceChannelForUpdate != null) {
DeviceChannel channel = catalogChannelEvent.getChannel();
channel.setId(deviceChannelForUpdate.getId()); channel.setId(deviceChannelForUpdate.getId());
channel.setHasAudio(deviceChannelForUpdate.isHasAudio()); channel.setHasAudio(deviceChannelForUpdate.isHasAudio());
channel.setUpdateTime(DateUtil.getNow()); channel.setUpdateTime(DateUtil.getNow());
@ -242,8 +256,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
taskQueue.clear(); taskQueue.clear();
if (!updateChannelMap.keySet().isEmpty() if (!updateChannelMap.keySet().isEmpty()
|| !addChannelMap.keySet().isEmpty() || !addChannelMap.keySet().isEmpty()
|| !updateChannelOnlineList.isEmpty() || !updateChannelForStatusChange.isEmpty()
|| !updateChannelOfflineList.isEmpty()
|| !deleteChannelList.isEmpty()) { || !deleteChannelList.isEmpty()) {
executeSave(); executeSave();
} }
@ -256,14 +269,9 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
log.error("[存储收到的增加通道] 异常: ", e ); log.error("[存储收到的增加通道] 异常: ", e );
} }
try { try {
executeSaveForOnline(); executeSaveForStatus();
} catch (Exception e) { } catch (Exception e) {
log.error("[存储收到的通道上线] 异常: ", e ); log.error("[存储收到的通道状态变化] 异常: ", e );
}
try {
executeSaveForOffline();
} catch (Exception e) {
log.error("[存储收到的通道离线] 异常: ", e );
} }
try { try {
executeSaveForUpdate(); executeSaveForUpdate();
@ -301,17 +309,10 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
} }
} }
private void executeSaveForOnline(){ private void executeSaveForStatus(){
if (!updateChannelOnlineList.isEmpty()) { if (!updateChannelForStatusChange.isEmpty()) {
deviceChannelService.channelsOnlineForNotify(updateChannelOnlineList); deviceChannelService.updateChannelsStatus(updateChannelForStatusChange);
updateChannelOnlineList.clear(); updateChannelForStatusChange.clear();
}
}
private void executeSaveForOffline(){
if (!updateChannelOfflineList.isEmpty()) {
deviceChannelService.channelsOfflineForNotify(updateChannelOfflineList);
updateChannelOfflineList.clear();
} }
} }
} }

View File

@ -24,6 +24,7 @@ import org.springframework.util.ObjectUtils;
import javax.sip.RequestEvent; import javax.sip.RequestEvent;
import javax.sip.header.FromHeader; import javax.sip.header.FromHeader;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
@ -65,7 +66,14 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
if (taskQueue.isEmpty()) { if (taskQueue.isEmpty()) {
return; return;
} }
for (HandlerCatchData take : taskQueue) { List<HandlerCatchData> handlerCatchDataList = new ArrayList<>();
while (!taskQueue.isEmpty()) {
handlerCatchDataList.add(taskQueue.poll());
}
if (handlerCatchDataList.isEmpty()) {
return;
}
for (HandlerCatchData take : handlerCatchDataList) {
if (take == null) { if (take == null) {
continue; continue;
} }
@ -89,13 +97,15 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
mobilePosition.setDeviceId(device.getDeviceId()); mobilePosition.setDeviceId(device.getDeviceId());
mobilePosition.setDeviceName(device.getName()); mobilePosition.setDeviceName(device.getName());
mobilePosition.setCreateTime(DateUtil.getNow()); mobilePosition.setCreateTime(DateUtil.getNow());
DeviceChannel deviceChannel = null;
List<Element> elements = rootElement.elements(); List<Element> elements = rootElement.elements();
for (Element element : elements) { for (Element element : elements) {
switch (element.getName()){ switch (element.getName()){
case "DeviceID": case "DeviceID":
String channelId = element.getStringValue(); String channelId = element.getStringValue();
if (!deviceId.equals(channelId)) { if (!deviceId.equals(channelId)) {
DeviceChannel deviceChannel = deviceChannelService.getOne(device.getDeviceId(), channelId); deviceChannel = deviceChannelService.getOne(device.getDeviceId(), channelId);
if (deviceChannel != null) { if (deviceChannel != null) {
mobilePosition.setChannelId(deviceChannel.getId()); mobilePosition.setChannelId(deviceChannel.getId());
} }
@ -154,13 +164,13 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
}catch (Exception e) { }catch (Exception e) {
log.error("[向上级转发移动位置失败] ", e); log.error("[向上级转发移动位置失败] ", e);
} }
if (mobilePosition.getChannelId() == null || mobilePosition.getChannelId().equals(mobilePosition.getDeviceId())) { if (mobilePosition.getChannelId() == null) {
List<DeviceChannel> channels = deviceChannelService.queryChaneListByDeviceId(mobilePosition.getDeviceId()); List<DeviceChannel> channels = deviceChannelService.queryChaneListByDeviceId(mobilePosition.getDeviceId());
channels.forEach(channel -> { channels.forEach(channel -> {
// 发送redis消息。 通知位置信息的变化 // 发送redis消息。 通知位置信息的变化
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("time", DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(mobilePosition.getTime())); jsonObject.put("time", DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(mobilePosition.getTime()));
jsonObject.put("serial", channel.getDeviceId()); jsonObject.put("serial", device.getDeviceId());
jsonObject.put("code", channel.getDeviceId()); jsonObject.put("code", channel.getDeviceId());
jsonObject.put("longitude", mobilePosition.getLongitude()); jsonObject.put("longitude", mobilePosition.getLongitude());
jsonObject.put("latitude", mobilePosition.getLatitude()); jsonObject.put("latitude", mobilePosition.getLatitude());
@ -171,10 +181,11 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
}); });
}else { }else {
// 发送redis消息。 通知位置信息的变化 // 发送redis消息。 通知位置信息的变化
if (deviceChannel != null) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("time", DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(mobilePosition.getTime())); jsonObject.put("time", DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(mobilePosition.getTime()));
jsonObject.put("serial", mobilePosition.getDeviceId()); jsonObject.put("serial", mobilePosition.getDeviceId());
jsonObject.put("code", mobilePosition.getChannelId()); jsonObject.put("code", deviceChannel.getDeviceId());
jsonObject.put("longitude", mobilePosition.getLongitude()); jsonObject.put("longitude", mobilePosition.getLongitude());
jsonObject.put("latitude", mobilePosition.getLatitude()); jsonObject.put("latitude", mobilePosition.getLatitude());
jsonObject.put("altitude", mobilePosition.getAltitude()); jsonObject.put("altitude", mobilePosition.getAltitude());
@ -182,6 +193,7 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
jsonObject.put("speed", mobilePosition.getSpeed()); jsonObject.put("speed", mobilePosition.getSpeed());
redisCatchStorage.sendMobilePositionMsg(jsonObject); redisCatchStorage.sendMobilePositionMsg(jsonObject);
} }
}
} catch (DocumentException e) { } catch (DocumentException e) {
log.error("未处理的异常 ", e); log.error("未处理的异常 ", e);
} }

View File

@ -29,7 +29,6 @@ public class RedisPushStreamResponseListener implements MessageListener {
@Autowired @Autowired
private ThreadPoolTaskExecutor taskExecutor; private ThreadPoolTaskExecutor taskExecutor;
private Map<String, PushStreamResponseEvent> responseEvents = new ConcurrentHashMap<>(); private Map<String, PushStreamResponseEvent> responseEvents = new ConcurrentHashMap<>();
public interface PushStreamResponseEvent{ public interface PushStreamResponseEvent{

View File

@ -241,7 +241,7 @@ public class RedisRpcController {
return response; return response;
} }
MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServer, sendRtpItem.getApp(), sendRtpItem.getStream()); MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServer, sendRtpItem.getApp(), sendRtpItem.getStream());
if (mediaInfo != null) { if (mediaInfo == null) {
log.info("[redis-rpc] startSendRtp->流不在线: {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream() ); log.info("[redis-rpc] startSendRtp->流不在线: {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream() );
WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "流不在线"); WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "流不在线");
response.setBody(wvpResult); response.setBody(wvpResult);

View File

@ -16,7 +16,7 @@
<vue-easy-tree <vue-easy-tree
class="flow-tree" class="flow-tree"
ref="veTree" ref="veTree"
node-key="deviceId" node-key="treeId"
height="78vh" height="78vh"
lazy lazy
style="padding: 0 0 2rem 0.5rem" style="padding: 0 0 2rem 0.5rem"
@ -29,7 +29,7 @@
> >
<span class="custom-tree-node" slot-scope="{ node, data }"> <span class="custom-tree-node" slot-scope="{ node, data }">
<span @click.stop v-if="edit"> <span @click.stop v-if="edit">
<el-radio v-if="node.data.type === 0 && node.level > 2" style="margin-right: 0" v-model="chooseId" @input="chooseIdChange(node.data.deviceId, node.data.businessGroup)" :label="node.data.deviceId">{{''}}</el-radio> <el-radio v-if="node.data.type === 0 && node.level > 2" style="margin-right: 0" v-model="chooseId" @input="chooseIdChange(node.data.treeId, node.data.deviceId, node.data.businessGroup)" :label="node.data.deviceId">{{''}}</el-radio>
</span> </span>
<span v-if="node.data.type === 0" style="color: #409EFF" class="iconfont icon-bianzubeifen3"></span> <span v-if="node.data.type === 0" style="color: #409EFF" class="iconfont icon-bianzubeifen3"></span>
<span v-if="node.data.type === 1" style="color: #409EFF" class="iconfont icon-shexiangtou2"></span> <span v-if="node.data.type === 1" style="color: #409EFF" class="iconfont icon-shexiangtou2"></span>
@ -57,6 +57,7 @@ export default {
return { return {
props: { props: {
label: "name", label: "name",
id: "treeId"
}, },
showCode: false, showCode: false,
searchSrt: "", searchSrt: "",
@ -74,6 +75,7 @@ export default {
loadNode: function (node, resolve) { loadNode: function (node, resolve) {
if (node.level === 0) { if (node.level === 0) {
resolve([{ resolve([{
treeId: "",
deviceId: "", deviceId: "",
name: "根资源组", name: "根资源组",
isLeaf: false, isLeaf: false,
@ -127,6 +129,7 @@ export default {
} }
}).then((res) => { }).then((res) => {
console.log("移除成功") console.log("移除成功")
console.log(node)
if (this.onChannelChange) { if (this.onChannelChange) {
this.onChannelChange() this.onChannelChange()
} }
@ -274,6 +277,7 @@ export default {
if (this.onChannelChange) { if (this.onChannelChange) {
this.onChannelChange() this.onChannelChange()
} }
console.log(node)
node.loaded = false node.loaded = false
node.expand(); node.expand();
}else { }else {
@ -332,14 +336,18 @@ export default {
}) })
}, },
refreshNode: function (node) { refreshNode: function (node) {
console.log(node)
node.loaded = false node.loaded = false
node.expand(); node.expand();
}, },
refresh: function (id) { refresh: function (id) {
console.log("刷新节点: " + id)
// node // node
let node = this.$refs.veTree.getNode(id) let node = this.$refs.veTree.getNode(id)
if (node) {
node.loaded = false node.loaded = false
node.expand(); node.expand();
}
}, },
addGroup: function (id, node) { addGroup: function (id, node) {
this.$refs.groupEdit.openDialog({ this.$refs.groupEdit.openDialog({
@ -351,6 +359,7 @@ export default {
parentId: node.data.id, parentId: node.data.id,
businessGroup: node.level > 2 ? node.data.businessGroup: node.data.deviceId, businessGroup: node.level > 2 ? node.data.businessGroup: node.data.deviceId,
},form => { },form => {
console.log(node)
node.loaded = false node.loaded = false
node.expand(); node.expand();
}, id); }, id);
@ -358,6 +367,7 @@ export default {
editGroup: function (id, node) { editGroup: function (id, node) {
console.log(node) console.log(node)
this.$refs.groupEdit.openDialog(node.data,form => { this.$refs.groupEdit.openDialog(node.data,form => {
console.log(node)
node.parent.loaded = false node.parent.loaded = false
node.parent.expand(); node.parent.expand();
}, id); }, id);

View File

@ -16,7 +16,7 @@
<vue-easy-tree <vue-easy-tree
class="flow-tree" class="flow-tree"
ref="veTree" ref="veTree"
node-key="deviceId" node-key="treeId"
height="78vh" height="78vh"
lazy lazy
style="padding: 0 0 2rem 0.5rem" style="padding: 0 0 2rem 0.5rem"
@ -29,7 +29,7 @@
> >
<span class="custom-tree-node" slot-scope="{ node, data }"> <span class="custom-tree-node" slot-scope="{ node, data }">
<span @click.stop v-if="edit"> <span @click.stop v-if="edit">
<el-radio v-if="node.data.type === 0 && node.level !== 1 " style="margin-right: 0" v-model="chooseId" @input="chooseIdChange" :label="node.data.deviceId">{{''}}</el-radio> <el-radio v-if="node.data.type === 0 && node.level !== 1 " style="margin-right: 0" v-model="chooseId" @input="chooseIdChange(node.data.treeId, node.data.deviceId)" :label="node.data.deviceId">{{''}}</el-radio>
</span> </span>
<span v-if="node.data.type === 0" style="color: #409EFF" class="iconfont icon-bianzubeifen3"></span> <span v-if="node.data.type === 0" style="color: #409EFF" class="iconfont icon-bianzubeifen3"></span>
<span v-if="node.data.type === 1" style="color: #409EFF" class="iconfont icon-shexiangtou2"></span> <span v-if="node.data.type === 1" style="color: #409EFF" class="iconfont icon-shexiangtou2"></span>
@ -74,6 +74,7 @@ export default {
loadNode: function (node, resolve) { loadNode: function (node, resolve) {
if (node.level === 0) { if (node.level === 0) {
resolve([{ resolve([{
treeId: "",
deviceId: "", deviceId: "",
name: "根资源组", name: "根资源组",
isLeaf: false, isLeaf: false,
@ -336,8 +337,11 @@ export default {
refresh: function (id) { refresh: function (id) {
// node // node
let node = this.$refs.veTree.getNode(id) let node = this.$refs.veTree.getNode(id)
if (node) {
node.loaded = false node.loaded = false
node.expand(); node.expand();
}
}, },
addRegion: function (id, node) { addRegion: function (id, node) {

View File

@ -67,8 +67,8 @@
<el-table-column label="添加状态" min-width="100"> <el-table-column label="添加状态" min-width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<div slot="reference" class="name-wrapper"> <div slot="reference" class="name-wrapper">
<el-tag size="medium" :title="scope.row.gbBusinessGroupId" v-if="scope.row.gbBusinessGroupId"></el-tag> <el-tag size="medium" :title="scope.row.gbParentId" v-if="scope.row.gbParentId"></el-tag>
<el-tag size="medium" type="info" v-if="!scope.row.gbBusinessGroupId"></el-tag> <el-tag size="medium" type="info" v-if="!scope.row.gbParentId"></el-tag>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
@ -113,6 +113,7 @@ export default {
total: 0, total: 0,
loading: false, loading: false,
loadSnap: {}, loadSnap: {},
groupDeviceId: "",
groupId: "", groupId: "",
businessGroup: "", businessGroup: "",
multipleSelection: [] multipleSelection: []
@ -175,12 +176,10 @@ export default {
} }
}, },
rowDblclick: function (row, rowIndex) { rowDblclick: function (row, rowIndex) {
if (row.gbParentId) {
this.$refs.groupTree.refresh(row.gbParentId)
}
}, },
add: function (row) { add: function (row) {
if (!this.groupId) { if (!this.groupDeviceId) {
this.$message.info({ this.$message.info({
showClose: true, showClose: true,
message: "请选择左侧行政区划节点" message: "请选择左侧行政区划节点"
@ -204,7 +203,7 @@ export default {
method: 'post', method: 'post',
url: `/api/common/channel/group/add`, url: `/api/common/channel/group/add`,
data: { data: {
parentId: this.groupId, parentId: this.groupDeviceId,
businessGroup: this.businessGroup, businessGroup: this.businessGroup,
channelIds: channels channelIds: channels
} }
@ -261,7 +260,7 @@ export default {
}) })
this.getChannelList() this.getChannelList()
// //
this.$refs.groupTree.refresh(this.groupId) this.$refs.groupTree.refresh(this.groupDeviceId)
}else { }else {
this.$message.error({ this.$message.error({
showClose: true, showClose: true,
@ -292,8 +291,9 @@ export default {
treeNodeClickEvent: function (device, data, isCatalog) { treeNodeClickEvent: function (device, data, isCatalog) {
}, },
chooseIdChange: function (id, businessGroup) { chooseIdChange: function (id, deviceId, businessGroup) {
this.groupId = id; this.groupId = id;
this.groupDeviceId = deviceId;
this.businessGroup = businessGroup; this.businessGroup = businessGroup;
}, },
} }

View File

@ -114,6 +114,7 @@ export default {
loading: false, loading: false,
loadSnap: {}, loadSnap: {},
regionId: "", regionId: "",
regionDeviceId: "",
multipleSelection: [] multipleSelection: []
}; };
}, },
@ -175,12 +176,12 @@ export default {
} }
}, },
rowDblclick: function (row, rowIndex) { rowDblclick: function (row, rowIndex) {
if (row.gbCivilCode) { // if (row.gbCivilCode) {
this.$refs.regionTree.refresh(row.gbCivilCode) // this.$refs.regionTree.refresh(row.gbCivilCode)
} // }
}, },
add: function (row) { add: function (row) {
if (!this.regionId) { if (!this.regionDeviceId) {
this.$message.info({ this.$message.info({
showClose: true, showClose: true,
message: "请选择左侧行政区划节点" message: "请选择左侧行政区划节点"
@ -204,7 +205,7 @@ export default {
method: 'post', method: 'post',
url: `/api/common/channel/region/add`, url: `/api/common/channel/region/add`,
data: { data: {
civilCode: this.regionId, civilCode: this.regionDeviceId,
channelIds: channels channelIds: channels
} }
}).then((res)=> { }).then((res)=> {
@ -290,7 +291,8 @@ export default {
treeNodeClickEvent: function (device, data, isCatalog) { treeNodeClickEvent: function (device, data, isCatalog) {
}, },
chooseIdChange: function (id) { chooseIdChange: function (id, deviceId) {
this.regionDeviceId = deviceId;
this.regionId = id; this.regionId = id;
}, },
} }