From feb7e0e9c49811689db86187b301f635d698ad74 Mon Sep 17 00:00:00 2001 From: lin <648540858@qq.com> Date: Fri, 17 Oct 2025 17:03:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/dao/CommonGBChannelMapper.java | 6 ++ .../gb28181/dao/provider/ChannelProvider.java | 27 ++++++- .../gb28181/service/impl/PlayServiceImpl.java | 2 +- .../vmp/web/custom/bean/CameraChannel.java | 19 ++++- .../custom/service/CameraChannelService.java | 78 +++++++++++++++++++ 5 files changed, 126 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java index d6651003e..2e1984681 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java @@ -646,6 +646,9 @@ public interface CommonGBChannelMapper { @SelectProvider(type = ChannelProvider.class, method = "queryListForSyMobile") List queryListForSyMobile(@Param("business") String business); + @SelectProvider(type = ChannelProvider.class, method = "queryCameraChannelById") + CameraChannel queryCameraChannelById(@Param("gbId") Integer id); + @Update("") void saveLevel(List channels); + + @SelectProvider(type = ChannelProvider.class, method = "queryCameraChannelByIds") + List queryCameraChannelByIds(List ids); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java index 7e1e65107..d7cd71eb9 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java @@ -162,6 +162,8 @@ public class ChannelProvider { " wdc.record_plan_id,\n" + " wdc.enable_broadcast,\n" + " wd.device_id as deviceCode,\n" + + " wcg.alias as groupAlias,\n" + + " wcg2.alias as topGroupGAlias,\n" + " coalesce(wdc.gb_device_id, wdc.device_id) as gb_device_id,\n" + " coalesce(wdc.gb_name, wdc.name) as gb_name,\n" + " coalesce(wdc.gb_manufacturer, wdc.manufacturer) as gb_manufacturer,\n" + @@ -197,7 +199,9 @@ public class ChannelProvider { " coalesce(wdc.gb_svc_space_support_mod, wdc.svc_space_support_mod) as gb_svc_space_support_mod,\n" + " coalesce(wdc.gb_svc_time_support_mode, wdc.svc_time_support_mode) as gb_svc_time_support_mode\n" + " from wvp_device_channel wdc\n" + - " left join wvp_device wd on wdc.data_type = 1 AND wd.id = wdc.data_device_id" + " left join wvp_device wd on wdc.data_type = 1 AND wd.id = wdc.data_device_id" + + " left join wvp_common_group wcg on wcg.device_id = coalesce(wdc.gb_parent_id, wdc.parent_id)" + + " left join wvp_common_group wcg2 on wcg2.device_id = wcg.business_group" ; public String queryByDeviceId(Map params ){ @@ -212,6 +216,10 @@ public class ChannelProvider { return BASE_SQL + " where channel_type = 0 and data_type = #{dataType} and data_device_id = #{dataDeviceId}"; } + public String queryCameraChannelById(Map params ){ + return BASE_SQL + " where id = #{gbId}"; + } + public String queryListByCivilCode(Map params ){ StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(BASE_SQL); @@ -824,6 +832,23 @@ public class ChannelProvider { sqlBuild.append(" )"); return sqlBuild.toString() ; } + public String queryCameraChannelByIds(Map params ){ + StringBuilder sqlBuild = new StringBuilder(); + sqlBuild.append(BASE_SQL_FOR_CAMERA_DEVICE); + sqlBuild.append(" where wdc.id in ( "); + + List ids = (List)params.get("ids"); + boolean first = true; + for (Integer id : ids) { + if (!first) { + sqlBuild.append(","); + } + sqlBuild.append(id); + first = false; + } + sqlBuild.append(" )"); + return sqlBuild.toString() ; + } public String queryListForSyMobile(Map params ){ return BASE_SQL_FOR_CAMERA_DEVICE + diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java index 2f578e29b..02ea5fa44 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java @@ -130,7 +130,7 @@ public class PlayServiceImpl implements IPlayService { * 流到来的处理 */ @Async("taskExecutor") - @org.springframework.context.event.EventListener + @EventListener public void onApplicationEvent(MediaArrivalEvent event) { if ("broadcast".equals(event.getApp()) || "talk".equals(event.getApp())) { if (event.getStream().indexOf("_") > 0) { diff --git a/src/main/java/com/genersoft/iot/vmp/web/custom/bean/CameraChannel.java b/src/main/java/com/genersoft/iot/vmp/web/custom/bean/CameraChannel.java index 119581c6a..647b0943c 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/custom/bean/CameraChannel.java +++ b/src/main/java/com/genersoft/iot/vmp/web/custom/bean/CameraChannel.java @@ -6,16 +6,27 @@ import lombok.Getter; import lombok.Setter; +@Getter +@Setter @Schema(description = "摄像头信息") public class CameraChannel extends CommonGBChannel { - @Getter - @Setter @Schema(description = "摄像头设备国标编号") private String deviceCode; - @Getter - @Setter + @Schema(description = "图标路径") private String icon; + + /** + * 分组别名 + */ + @Schema(description = "所属组织结构别名") + private String groupAlias; + + /** + * 分组所属业务分组别名 + */ + @Schema(description = "所属业务分组别名") + private String topGroupGAlias; } diff --git a/src/main/java/com/genersoft/iot/vmp/web/custom/service/CameraChannelService.java b/src/main/java/com/genersoft/iot/vmp/web/custom/service/CameraChannelService.java index ad184852a..a36f53be4 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/custom/service/CameraChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/web/custom/service/CameraChannelService.java @@ -8,8 +8,11 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.FrontEndControlCodeForPTZ; import com.genersoft.iot.vmp.gb28181.bean.Group; +import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; import com.genersoft.iot.vmp.gb28181.dao.GroupMapper; +import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; +import com.genersoft.iot.vmp.gb28181.event.subscribe.mobilePosition.MobilePositionEvent; import com.genersoft.iot.vmp.gb28181.service.IGbChannelControlService; import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService; import com.genersoft.iot.vmp.service.bean.ErrorCallback; @@ -23,6 +26,7 @@ import com.github.xiaoymin.knife4j.core.util.Assert; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; +import org.springframework.context.event.EventListener; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -32,6 +36,9 @@ import java.util.*; @Service public class CameraChannelService implements CommandLineRunner { + private final String REDIS_GPS_MESSAGE = "VM_MSG_MOBILE_GPS"; + private final String REDIS_CHANNEL_MESSAGE = "VM_MSG_MOBILE_CHANNEL"; + @Autowired private CommonGBChannelMapper channelMapper; @@ -102,6 +109,77 @@ public class CameraChannelService implements CommandLineRunner { return true; } + // 监听通道变化,如果是移动设备则发送redis消息 + @EventListener + public void onApplicationEvent(CatalogEvent event) { + List channels = event.getChannels(); + if (channels.isEmpty()) { + return; + } + + List mobilechannelList = null; + if (event.getType().equals(CatalogEvent.DEL)) { + mobilechannelList = new ArrayList<>(); + for (CommonGBChannel channel : channels) { + if (channel.getGbPtzType() != null && channel.getGbPtzType() == 99) { + CameraChannel cameraChannel = new CameraChannel(); + cameraChannel.setGbDeviceId(channel.getGbDeviceId()); + mobilechannelList.add(cameraChannel); + } + } + }else { + List ids = new ArrayList<>(); + channels.forEach((channel -> { + if (channel.getGbPtzType() != null && channel.getGbPtzType() == 99) { + ids.add(channel.getGbId()); + } + })); + if (ids.isEmpty()) { + return; + } + mobilechannelList = channelMapper.queryCameraChannelByIds(ids); + } + if (mobilechannelList == null || mobilechannelList.isEmpty()) { + return; + } + String type = event.getType(); + if (type.equals(CatalogEvent.VLOST) || type.equals(CatalogEvent.DEFECT)) { + type = CatalogEvent.OFF; + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", type); + jsonObject.put("list", mobilechannelList); + log.info("[SY-redis发送通知] 发送 通道信息变化 {}: {}", REDIS_CHANNEL_MESSAGE, jsonObject.toString()); + redisTemplate.convertAndSend(REDIS_CHANNEL_MESSAGE, jsonObject); + + + } + + // 监听GPS消息,如果是移动设备则发送redis消息 + @EventListener + public void onApplicationEvent(MobilePositionEvent event) { + MobilePosition mobilePosition = event.getMobilePosition(); + Integer channelId = mobilePosition.getChannelId(); + CameraChannel cameraChannel = channelMapper.queryCameraChannelById(channelId); + + // 非移动设备类型 不发送 + if (cameraChannel == null || cameraChannel.getGbPtzType() != 99) { + return; + } + // 发送redis消息 + JSONObject jsonObject = new JSONObject(); + jsonObject.put("time", mobilePosition.getTime()); + jsonObject.put("deviceId", mobilePosition.getDeviceId()); + jsonObject.put("longitude", mobilePosition.getLongitude()); + jsonObject.put("latitude", mobilePosition.getLatitude()); + jsonObject.put("altitude", mobilePosition.getAltitude()); + jsonObject.put("direction", mobilePosition.getDirection()); + jsonObject.put("speed", mobilePosition.getSpeed()); + log.debug("[redis发送通知] 发送 移动设备位置信息移动位置 {}: {}", REDIS_GPS_MESSAGE, jsonObject.toString()); + redisTemplate.convertAndSend(REDIS_GPS_MESSAGE, jsonObject); + } + public PageInfo queryList(Integer page, Integer count, String groupAlias, Boolean status, String geoCoordSys) { // 构建组织结构信息