优化notify消息处理

2.7.1
648540858 2024-10-11 14:09:18 +08:00
parent 2a2a3943f4
commit bbbadccb79
9 changed files with 375 additions and 281 deletions

View File

@ -0,0 +1,38 @@
package com.genersoft.iot.vmp.gb28181.bean;
public class NotifyCatalogChannel {
private Type type;
private DeviceChannel channel;
public enum Type {
ADD, DELETE, UPDATE, STATUS_CHANGED
}
public static NotifyCatalogChannel getInstance(Type type, DeviceChannel channel) {
NotifyCatalogChannel notifyCatalogChannel = new NotifyCatalogChannel();
notifyCatalogChannel.setType(type);
notifyCatalogChannel.setChannel(channel);
return notifyCatalogChannel;
}
public Type getType() {
return type;
}
public void setType(Type type) {
this.type = type;
}
public DeviceChannel getChannel() {
return channel;
}
public void setChannel(DeviceChannel channel) {
this.channel = channel;
}
}

View File

@ -596,7 +596,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
String catalogXmlContent = getCatalogXmlContentForCatalogAddOrUpdate(parentPlatform, channels,
deviceChannels.size(), type, subscribeInfo);
System.out.println(catalogXmlContent);
logger.info("[发送NOTIFY通知]类型: {}发送数量: {}", type, channels.size());
logger.info("[发送NOTIFY通知]类型: {}平台:{} 发送数量: {}", type, parentPlatform.getServerGBId(), channels.size());
sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> {
logger.error("发送NOTIFY通知消息失败。错误{} {}", eventResult.statusCode, eventResult.msg);
}, (eventResult -> {
@ -702,7 +702,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
}else {
channels = deviceChannels.subList(index, deviceChannels.size());
}
logger.info("[发送NOTIFY通知]类型: {}发送数量: {}", type, channels.size());
logger.info("[发送NOTIFY通知]类型: {}平台:{} 发送数量: {}", type, parentPlatform.getServerGBId(), channels.size());
Integer finalIndex = index;
String catalogXmlContent = getCatalogXmlContentForCatalogOther(parentPlatform, channels, type);
sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> {

View File

@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.HandlerCatchData;
import com.genersoft.iot.vmp.gb28181.bean.NotifyCatalogChannel;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
@ -13,6 +14,7 @@ import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
import com.genersoft.iot.vmp.service.IDeviceChannelService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import gov.nist.javax.sip.message.SIPRequest;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.slf4j.Logger;
@ -23,12 +25,12 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.sip.RequestEvent;
import javax.sip.header.CSeqHeader;
import javax.sip.header.FromHeader;
import javax.sip.message.Request;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArrayList;
@ -38,15 +40,9 @@ import java.util.concurrent.CopyOnWriteArrayList;
@Component
public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent {
private final static Logger logger = LoggerFactory.getLogger(NotifyRequestForCatalogProcessor.class);
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> addChannelMap = new ConcurrentHashMap<>();
private final List<DeviceChannel> deleteChannelList = new CopyOnWriteArrayList<>();
private final ConcurrentLinkedQueue<NotifyCatalogChannel> channelList = new ConcurrentLinkedQueue<>();
private ConcurrentLinkedQueue<HandlerCatchData> taskQueue = new ConcurrentLinkedQueue<>();
@ -79,40 +75,49 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
// }
@Scheduled(fixedRate = 400) //每400毫秒执行一次
public void executeTaskQueue(){
@Transactional
public void executeTaskQueue() {
if (taskQueue.isEmpty()) {
return;
}
List<HandlerCatchData> handlerCatchDataList = new ArrayList<>();
while (!taskQueue.isEmpty()) {
handlerCatchDataList.add(taskQueue.poll());
int size = taskQueue.size();
for (int i = 0; i < size; i++) {
HandlerCatchData poll = taskQueue.poll();
if (poll != null) {
handlerCatchDataList.add(poll);
}
}
// while (!taskQueue.isEmpty()) {
// handlerCatchDataList.add(taskQueue.poll());
// }
if (handlerCatchDataList.isEmpty()) {
return;
}
for (HandlerCatchData take : handlerCatchDataList) {
if (take == null) {
logger.warn("[收到目录订阅]:但是队列内任务为空");
continue;
}
RequestEvent evt = take.getEvt();
try {
long start = System.currentTimeMillis();
FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME);
String deviceId = SipUtils.getUserIdFromFromHeader(fromHeader);
Device device = redisCatchStorage.getDevice(deviceId);
if (device == null || !device.isOnLine()) {
logger.warn("[收到目录订阅]{}, 但是设备已经离线", (device != null ? device.getDeviceId() : ""));
return;
continue;
}
Element rootElement = getRootElement(evt, device.getCharset());
if (rootElement == null) {
logger.warn("[ 收到目录订阅 ] content cannot be null, {}", evt.getRequest());
return;
continue;
}
Element deviceListElement = rootElement.element("DeviceList");
if (deviceListElement == null) {
return;
logger.warn("[ 收到目录订阅 ] 解析xml获取DeviceList失败, {}", evt.getRequest());
continue;
}
Iterator<Element> deviceListIterator = deviceListElement.elementIterator();
if (deviceListIterator != null) {
@ -137,7 +142,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
channel.setParentId(null);
}
channel.setDeviceId(device.getDeviceId());
if (logger.isDebugEnabled()){
if (logger.isDebugEnabled()) {
logger.debug("[收到目录订阅]{}/{}", device.getDeviceId(), channel.getChannelId());
}
switch (event) {
@ -145,7 +150,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
// 上线
logger.info("[收到通道上线通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
channel.setStatus(true);
updateChannelForStatusChange.add(channel);
channelList.add(NotifyCatalogChannel.getInstance(NotifyCatalogChannel.Type.STATUS_CHANGED, channel));
if (userSetting.getDeviceStatusNotify()) {
// 发送redis消息
redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), channel.getChannelId(), true);
@ -158,7 +163,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
logger.info("[收到通道离线通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
} else {
channel.setStatus(false);
updateChannelForStatusChange.add(channel);
channelList.add(NotifyCatalogChannel.getInstance(NotifyCatalogChannel.Type.STATUS_CHANGED, channel));
if (userSetting.getDeviceStatusNotify()) {
// 发送redis消息
redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), channel.getChannelId(), false);
@ -172,7 +177,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
logger.info("[收到通道视频丢失通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
} else {
channel.setStatus(false);
updateChannelForStatusChange.add(channel);
channelList.add(NotifyCatalogChannel.getInstance(NotifyCatalogChannel.Type.STATUS_CHANGED, channel));
if (userSetting.getDeviceStatusNotify()) {
// 发送redis消息
redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), channel.getChannelId(), false);
@ -186,7 +191,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
logger.info("[收到通道视频故障通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
} else {
channel.setStatus(false);
updateChannelForStatusChange.add(channel);
channelList.add(NotifyCatalogChannel.getInstance(NotifyCatalogChannel.Type.STATUS_CHANGED, channel));
if (userSetting.getDeviceStatusNotify()) {
// 发送redis消息
redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), channel.getChannelId(), false);
@ -201,10 +206,10 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
if (deviceChannel != null) {
logger.info("[增加通道] 已存在,不发送通知只更新,设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
channel.setId(deviceChannel.getId());
channel.setHasAudio(null);
updateChannelMap.put(channel.getChannelId(), channel);
channel.setHasAudio(deviceChannel.getHasAudio());
channelList.add(NotifyCatalogChannel.getInstance(NotifyCatalogChannel.Type.UPDATE, channel));
} else {
addChannelMap.put(channel.getChannelId(), channel);
channelList.add(NotifyCatalogChannel.getInstance(NotifyCatalogChannel.Type.ADD, channel));
if (userSetting.getDeviceStatusNotify()) {
// 发送redis消息
redisCatchStorage.sendChannelAddOrDelete(device.getDeviceId(), channel.getChannelId(), true);
@ -215,7 +220,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
case CatalogEvent.DEL:
// 删除
logger.info("[收到删除通道通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
deleteChannelList.add(channel);
channelList.add(NotifyCatalogChannel.getInstance(NotifyCatalogChannel.Type.DELETE, channel));
if (userSetting.getDeviceStatusNotify()) {
// 发送redis消息
redisCatchStorage.sendChannelAddOrDelete(device.getDeviceId(), channel.getChannelId(), false);
@ -223,17 +228,17 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
break;
case CatalogEvent.UPDATE:
// 更新
logger.info("[收到更新通道通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
logger.info("[收到更新通道通知] 来自设备: {}, 通道 {}, 状态: {}", device.getDeviceId(), channel.getChannelId(), channel.isStatus());
// 判断此通道是否存在
DeviceChannel deviceChannelForUpdate = deviceChannelService.getOne(deviceId, channel.getChannelId());
if (deviceChannelForUpdate != null) {
channel.setId(deviceChannelForUpdate.getId());
DeviceChannel deviceChannelInDb = deviceChannelService.getOne(deviceId, channel.getChannelId());
if (deviceChannelInDb != null) {
channel.setId(deviceChannelInDb.getId());
channel.setUpdateTime(DateUtil.getNow());
channel.setHasAudio(null);
updateChannelMap.put(channel.getChannelId(), channel);
channel.setHasAudio(deviceChannelInDb.getHasAudio());
channelList.add(NotifyCatalogChannel.getInstance(NotifyCatalogChannel.Type.UPDATE, channel));
} else {
addChannelMap.put(channel.getChannelId(), channel);
channelList.add(NotifyCatalogChannel.getInstance(NotifyCatalogChannel.Type.ADD, channel));
if (userSetting.getDeviceStatusNotify()) {
// 发送redis消息
redisCatchStorage.sendChannelAddOrDelete(device.getDeviceId(), channel.getChannelId(), true);
@ -253,66 +258,39 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
logger.error("未处理的异常 ", e);
}
}
taskQueue.clear();
if (!updateChannelMap.keySet().isEmpty()
|| !addChannelMap.keySet().isEmpty()
|| !updateChannelForStatusChange.isEmpty()
|| !deleteChannelList.isEmpty()) {
if (!channelList.isEmpty()) {
executeSave();
}
}
public void executeSave(){
try {
executeSaveForAdd();
} catch (Exception e) {
logger.error("[存储收到的增加通道] 异常: ", e );
}
try {
executeSaveForStatus();
} catch (Exception e) {
logger.error("[存储收到的通道状态变化] 异常: ", e );
}
try {
executeSaveForUpdate();
} catch (Exception e) {
logger.error("[存储收到的更新通道] 异常: ", e );
}
try {
executeSaveForDelete();
} catch (Exception e) {
logger.error("[存储收到的删除通道] 异常: ", e );
}
@Transactional
public void executeSave() {
int size = channelList.size();
List<NotifyCatalogChannel> channelListForSave = new ArrayList<>();
for (int i = 0; i < size; i++) {
channelListForSave.add(channelList.poll());
}
private void executeSaveForUpdate(){
if (!updateChannelMap.values().isEmpty()) {
logger.info("[存储收到的更新通道], 数量: {}", updateChannelMap.size());
ArrayList<DeviceChannel> deviceChannels = new ArrayList<>(updateChannelMap.values());
deviceChannelService.batchUpdateChannel(deviceChannels);
updateChannelMap.clear();
for (NotifyCatalogChannel notifyCatalogChannel : channelListForSave) {
try {
switch (notifyCatalogChannel.getType()) {
case STATUS_CHANGED:
deviceChannelService.updateChannelStatus(notifyCatalogChannel.getChannel());
break;
case ADD:
deviceChannelService.addChannel(notifyCatalogChannel.getChannel());
break;
case UPDATE:
deviceChannelService.updateChannelForNotify(notifyCatalogChannel.getChannel());
break;
case DELETE:
deviceChannelService.delete(notifyCatalogChannel.getChannel());
break;
}
}catch (Exception e) {
logger.error("[存储收到的通道]类型:{},编号:{}", notifyCatalogChannel.getType(),
notifyCatalogChannel.getChannel().getDeviceId(), e);
}
private void executeSaveForAdd(){
if (!addChannelMap.values().isEmpty()) {
ArrayList<DeviceChannel> deviceChannels = new ArrayList<>(addChannelMap.values());
addChannelMap.clear();
deviceChannelService.batchAddChannel(deviceChannels);
}
}
private void executeSaveForDelete(){
if (!deleteChannelList.isEmpty()) {
deviceChannelService.deleteChannels(deleteChannelList);
deleteChannelList.clear();
}
}
private void executeSaveForStatus(){
if (!updateChannelForStatusChange.isEmpty()) {
deviceChannelService.updateChannelsStaus(updateChannelForStatusChange);
updateChannelForStatusChange.clear();
}
}
}

View File

@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import javax.sip.RequestEvent;
@ -71,7 +72,10 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
}
List<HandlerCatchData> handlerCatchDataList = new ArrayList<>();
while (!taskQueue.isEmpty()) {
handlerCatchDataList.add(taskQueue.poll());
HandlerCatchData poll = taskQueue.poll();
if (poll != null) {
handlerCatchDataList.add(poll);
}
}
if (handlerCatchDataList.isEmpty()) {
return;
@ -89,12 +93,12 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
Element rootElement = getRootElement(evt);
if (rootElement == null) {
logger.error("处理MobilePosition移动位置Notify时未获取到消息体,{}", evt.getRequest());
return;
continue;
}
Device device = redisCatchStorage.getDevice(deviceId);
if (device == null) {
logger.error("处理MobilePosition移动位置Notify时未获取到device,{}", deviceId);
return;
continue;
}
MobilePosition mobilePosition = new MobilePosition();
mobilePosition.setDeviceId(device.getDeviceId());
@ -194,7 +198,6 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
logger.error("未处理的异常 ", e);
}
}
taskQueue.clear();
}
// @Scheduled(fixedRate = 10000)
// public void execute(){

View File

@ -25,7 +25,7 @@ public interface IDeviceChannelService {
* @param deviceId id
* @param channel
*/
void updateChannel(String deviceId, DeviceChannel channel);
void updateChannelForNotify(String deviceId, DeviceChannel channel);
/**
*
@ -102,4 +102,10 @@ public interface IDeviceChannelService {
void offline(DeviceChannel channel);
void delete(DeviceChannel channel);
void updateChannelStatus(DeviceChannel channel);
void addChannel(DeviceChannel channel);
void updateChannelForNotify(DeviceChannel channel);
}

View File

@ -96,7 +96,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
}
@Override
public void updateChannel(String deviceId, DeviceChannel channel) {
public void updateChannelForNotify(String deviceId, DeviceChannel channel) {
String channelId = channel.getChannelId();
channel.setDeviceId(deviceId);
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId);
@ -116,6 +116,11 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
channelMapper.updateChannelSubCount(deviceId,channel.getParentId());
}
@Override
public void updateChannelForNotify(DeviceChannel channel) {
channelMapper.updateForNotify(channel);
}
@Override
public int updateChannels(String deviceId, List<DeviceChannel> channels) {
List<DeviceChannel> addChannels = new ArrayList<>();
@ -280,6 +285,16 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
return result;
}
@Override
public void updateChannelStatus(DeviceChannel channel) {
channelMapper.updateStatus(channel);
}
@Override
public void addChannel(DeviceChannel channel) {
channelMapper.add(channel);
}
@Override
public void online(DeviceChannel channel) {
channelMapper.online(channel.getDeviceId(), channel.getChannelId());

View File

@ -17,14 +17,22 @@ import java.util.List;
@Repository
public interface DeviceChannelMapper {
@Insert("INSERT INTO wvp_device_channel (channel_id, device_id, name, manufacture, model, owner, civil_code, block, " +
"address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, secrecy, " +
"ip_address, port, password, ptz_type, status, stream_id, longitude, latitude, longitude_gcj02, latitude_gcj02, " +
"longitude_wgs84, latitude_wgs84, has_audio, create_time, update_time, business_group_id, gps_time, stream_identification) " +
"VALUES (#{channelId}, #{deviceId}, #{name}, #{manufacture}, #{model}, #{owner}, #{civilCode}, #{block}," +
"#{address}, #{parental}, #{parentId}, #{safetyWay}, #{registerWay}, #{certNum}, #{certifiable}, #{errCode}, #{secrecy}, " +
"#{ipAddress}, #{port}, #{password}, #{ptzType}, #{status}, #{streamId}, #{longitude}, #{latitude}, #{longitudeGcj02}, " +
"#{latitudeGcj02}, #{longitudeWgs84}, #{latitudeWgs84}, #{hasAudio}, #{createTime}, #{updateTime}, #{businessGroupId}, #{gpsTime}, #{streamIdentification})")
@Insert("<script> " +
"insert into wvp_device_channel " +
"(channel_id, device_id, name, manufacture, model, owner, civil_code, block, sub_count, " +
" address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, secrecy, " +
" ip_address,port,password,ptz_type,status,stream_id,longitude,latitude,longitude_gcj02,latitude_gcj02,"+
" longitude_wgs84,latitude_wgs84,has_audio,create_time,update_time,business_group_id,gps_time,stream_identification)"+
"values " +
"(#{channelId}, #{deviceId}, #{name}, #{manufacture}, #{model}, " +
"#{owner}, #{civilCode}, #{block},#{subCount}," +
"#{address}, #{parental}, #{parentId}, #{safetyWay}, #{registerWay}, " +
"#{certNum}, #{certifiable}, #{errCode}, #{secrecy}, " +
"#{ipAddress}, #{port}, #{password}, #{ptzType}, #{status}, " +
"#{streamId}, #{longitude}, #{latitude},#{longitudeGcj02}, " +
"#{latitudeGcj02},#{longitudeWgs84}, #{latitudeWgs84}, #{hasAudio}, now(), now(), " +
"#{businessGroupId}, #{gpsTime}, #{streamIdentification}) " +
"</script>")
int add(DeviceChannel channel);
@Update(value = {" <script>" +
@ -65,6 +73,49 @@ public interface DeviceChannelMapper {
" </script>"})
int update(DeviceChannel channel);
@Update(value = {" <script>" +
" UPDATE" +
" wvp_device_channel" +
" SET update_time=#{updateTime}" +
"<if test='name != null'>, name=#{name}</if>" +
"<if test='manufacture != null'>, manufacture=#{manufacture}</if>" +
"<if test='model != null'>, model=#{model}</if>" +
"<if test='owner != null'>, owner=#{owner}</if>" +
"<if test='civilCode != null'>, civil_code=#{civilCode}</if>" +
"<if test='block != null'>, block=#{block}</if>" +
"<if test='subCount != null'>, sub_count=#{subCount}</if>" +
"<if test='address != null'>, address=#{address}</if>" +
"<if test='parental != null'>, parental=#{parental}</if>" +
"<if test='parentId != null'>, parent_id=#{parentId}</if>" +
"<if test='safetyWay != null'>, safety_way=#{safetyWay}</if>" +
"<if test='registerWay != null'>, register_way=#{registerWay}</if>" +
"<if test='certNum != null'>, cert_num=#{certNum}</if>" +
"<if test='certifiable != null'>, certifiable=#{certifiable}</if>" +
"<if test='errCode != null'>, err_code=#{errCode}</if>" +
"<if test='secrecy != null'>, secrecy=#{secrecy}</if>" +
"<if test='ipAddress != null'>, ip_address=#{ipAddress}</if>" +
"<if test='port != null'>, port=#{port}</if>" +
"<if test='password != null'>, password=#{password}</if>" +
"<if test='ptzType != null'>, ptz_type=#{ptzType}</if>" +
"<if test='status != null'>, status=#{status}</if>" +
"<if test='streamId != null'>, stream_id=#{streamId}</if>" +
"<if test='hasAudio != null'>, has_audio=#{hasAudio}</if>" +
"<if test='longitude != null'>, longitude=#{longitude}</if>" +
"<if test='latitude != null'>, latitude=#{latitude}</if>" +
"<if test='customLongitude != null'>, custom_longitude=#{customLongitude}</if>" +
"<if test='customLatitude != null'>, custom_latitude=#{customLatitude}</if>" +
"<if test='longitudeGcj02 != null'>, longitude_gcj02=#{longitudeGcj02}</if>" +
"<if test='latitudeGcj02 != null'>, latitude_gcj02=#{latitudeGcj02}</if>" +
"<if test='longitudeWgs84 != null'>, longitude_wgs84=#{longitudeWgs84}</if>" +
"<if test='latitudeWgs84 != null'>, latitude_wgs84=#{latitudeWgs84}</if>" +
"<if test='businessGroupId != null'>, business_group_id=#{businessGroupId}</if>" +
"<if test='gpsTime != null'>, gps_time=#{gpsTime}</if>" +
"<if test='streamIdentification != null'>, stream_identification=#{streamIdentification}</if>" +
"<if test='id > 0'>WHERE id=#{id}</if>" +
"<if test='id == 0'>WHERE device_id=#{deviceId} AND channel_id=#{channelId}</if>" +
" </script>"})
int updateForNotify(DeviceChannel channel);
@Select(value = {" <script>" +
"SELECT " +
"dc.id, " +
@ -574,4 +625,7 @@ public interface DeviceChannelMapper {
"</script>"})
void batchUpdatePosition(List<DeviceChannel> channelList);
@Update("UPDATE wvp_device_channel SET status=#{status} WHERE device_id=#{deviceId} AND channel_id=#{channelId}")
void updateStatus(DeviceChannel channel);
}

View File

@ -261,7 +261,7 @@ public class DeviceQuery {
@Parameter(name = "channel", description = "通道信息", required = true)
@PostMapping("/channel/update/{deviceId}")
public void updateChannel(@PathVariable String deviceId,DeviceChannel channel){
deviceChannelService.updateChannel(deviceId, channel);
deviceChannelService.updateChannelForNotify(deviceId, channel);
}
@Operation(summary = "修改通道的码流类型", security = @SecurityRequirement(name = JwtUtils.HEADER))