临时提交

This commit is contained in:
lin
2025-11-04 23:17:13 +08:00
parent c507709690
commit bf5af5779f
6 changed files with 55 additions and 10 deletions

View File

@@ -325,8 +325,11 @@ public interface CommonGBChannelMapper {
@SelectProvider(type = ChannelProvider.class, method = "queryByCivilCode")
List<CommonGBChannel> queryByCivilCode(@Param("civilCode") String civilCode);
@SelectProvider(type = ChannelProvider.class, method = "queryByDataTypeAndDeviceIds")
List<CommonGBChannel> queryByDataTypeAndDeviceIds(@Param("dataType") Integer dataType, List<Integer> deviceIds);
@SelectProvider(type = ChannelProvider.class, method = "queryByGbDeviceIds")
List<CommonGBChannel> queryByGbDeviceIds(@Param("dataType") Integer dataType, List<Integer> deviceIds);
List<CommonGBChannel> queryByGbDeviceIds(List<String> deviceIds);
@Select(value = {" <script>" +
" select id from wvp_device_channel " +

View File

@@ -334,7 +334,7 @@ public class ChannelProvider {
return sqlBuild.toString() ;
}
public String queryByGbDeviceIds(Map<String, Object> params ){
public String queryByDataTypeAndDeviceIds(Map<String, Object> params ){
StringBuilder sqlBuild = new StringBuilder();
sqlBuild.append(BASE_SQL);
sqlBuild.append("where channel_type = 0 and data_type = #{dataType} and data_device_id in ( ");
@@ -352,6 +352,26 @@ public class ChannelProvider {
return sqlBuild.toString() ;
}
public String queryByGbDeviceIds(Map<String, Object> params ){
StringBuilder sqlBuild = new StringBuilder();
sqlBuild.append(BASE_SQL);
sqlBuild.append("where channel_type = 0 and coalesce(gb_device_id, device_id) in ( ");
Collection<String> ids = (Collection<String>)params.get("deviceIds");
boolean first = true;
for (String id : ids) {
if (!first) {
sqlBuild.append(",");
}
sqlBuild.append("'");
sqlBuild.append(id);
sqlBuild.append("'");
first = false;
}
sqlBuild.append(" )");
return sqlBuild.toString() ;
}
public String queryByDeviceIds(Map<String, Object> params ){
StringBuilder sqlBuild = new StringBuilder();
sqlBuild.append(BASE_SQL);

View File

@@ -12,7 +12,6 @@ import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper;
import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.event.channel.ChannelEvent;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
@@ -824,7 +823,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
if (deviceStatusTaskRunner.containsKey(deviceId)) {
deviceStatusTaskRunner.removeTask(deviceId);
}
List<CommonGBChannel> commonGBChannels = commonGBChannelMapper.queryByGbDeviceIds(1, List.of(device.getId()));
List<CommonGBChannel> commonGBChannels = commonGBChannelMapper.queryByDataTypeAndDeviceIds(1, List.of(device.getId()));
try {
// 发送catalog

View File

@@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.gb28181.service.impl;
import com.alibaba.excel.support.cglib.beans.BeanMap;
import com.alibaba.excel.util.BeanMapUtils;
import com.alibaba.fastjson2.JSON;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.common.enums.ChannelDataType;
import com.genersoft.iot.vmp.conf.DynamicTask;
@@ -36,6 +35,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.ConcurrentReferenceHashMap;
import org.springframework.util.ObjectUtils;
import java.time.Duration;
@@ -559,7 +559,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
@Override
public void addChannelToRegionByGbDevice(String civilCode, List<Integer> deviceIds) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181, deviceIds);
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByDataTypeAndDeviceIds(ChannelDataType.GB28181, deviceIds);
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
@@ -581,7 +581,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
@Override
public void deleteChannelToRegionByGbDevice(List<Integer> deviceIds) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181, deviceIds);
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByDataTypeAndDeviceIds(ChannelDataType.GB28181, deviceIds);
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
@@ -702,7 +702,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
@Override
@Transactional
public void addChannelToGroupByGbDevice(String parentId, String businessGroup, List<Integer> deviceIds) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181, deviceIds);
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByDataTypeAndDeviceIds(ChannelDataType.GB28181, deviceIds);
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
@@ -732,7 +732,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
@Override
public void deleteChannelToGroupByGbDevice(List<Integer> deviceIds) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181, deviceIds);
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByDataTypeAndDeviceIds(ChannelDataType.GB28181, deviceIds);
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
@@ -842,7 +842,29 @@ public class GbChannelServiceImpl implements IGbChannelService {
if (gpsMsgInfoList == null || gpsMsgInfoList.isEmpty()) {
return;
}
// 此处来源默认为WGS84, 所以直接入库
commonGBChannelMapper.updateGpsByDeviceId(gpsMsgInfoList);
Map<String, GPSMsgInfo> gpsMsgInfoMap = new ConcurrentReferenceHashMap<>();
for (GPSMsgInfo gpsMsgInfo : gpsMsgInfoList) {
gpsMsgInfoMap.put(gpsMsgInfo.getId(), gpsMsgInfo);
}
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(new ArrayList<>(gpsMsgInfoMap.keySet()));
if (channelList.isEmpty()) {
return;
}
channelList.forEach(commonGBChannel -> {
MobilePosition mobilePosition = new MobilePosition();
mobilePosition.setDeviceId(commonGBChannel.getGbDeviceId());
mobilePosition.setChannelId(commonGBChannel.getGbId());
mobilePosition.setDeviceName(commonGBChannel.getGbName());
mobilePosition.setCreateTime(DateUtil.getNow());
mobilePosition.setTime(DateUtil.getNow());
mobilePosition.setLongitude(commonGBChannel.getGbLongitude());
mobilePosition.setLatitude(commonGBChannel.getGbLatitude());
eventPublisher.mobilePositionEventPublish(mobilePosition);
});
}
@Transactional
@@ -874,7 +896,6 @@ public class GbChannelServiceImpl implements IGbChannelService {
@Override
public CommonGBChannel queryCommonChannelByDeviceChannel(DeviceChannel channel) {
System.out.println(JSON.toJSONString(channel));
return commonGBChannelMapper.queryCommonChannelByDeviceChannel(channel.getDataType(), channel.getDataDeviceId(), channel.getDeviceId());
}

View File

@@ -68,6 +68,7 @@ public class RedisGpsMsgListener implements MessageListener {
for (Message msg : messageDataList) {
try {
GPSMsgInfo gpsMsgInfo = JSON.parseObject(msg.getBody(), GPSMsgInfo.class);
gpsMsgInfo.setStored(false);
gpsMsgInfo.setTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(gpsMsgInfo.getTime()));
log.info("[REDIS的位置变化通知], {}", JSON.toJSONString(gpsMsgInfo));
// 只是放入redis缓存起来

View File

@@ -188,6 +188,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
public void updateGpsMsgInfo(GPSMsgInfo gpsMsgInfo) {
String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId();
Duration duration = Duration.ofSeconds(60L);
gpsMsgInfo.setStored(false);
redisTemplate.opsForHash().put(key, gpsMsgInfo.getId(),gpsMsgInfo);
redisTemplate.expire(key, duration);
// 默认GPS消息保存1分钟