临时提交

This commit is contained in:
lin
2025-10-20 23:17:09 +08:00
parent 86266acb15
commit d48e0cc031
4 changed files with 18 additions and 68 deletions

View File

@@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.gb28181.bean.Platform; import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent; import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent;
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.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.gb28181.event.subscribe.mobilePosition.MobilePositionEvent; import com.genersoft.iot.vmp.gb28181.event.subscribe.mobilePosition.MobilePositionEvent;
import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.bean.MediaServer;
@@ -17,10 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/** /**
* @description:Event事件通知推送器支持推送在线事件、离线事件 * @description:Event事件通知推送器支持推送在线事件、离线事件
@@ -62,11 +60,18 @@ public class EventPublisher {
applicationEventPublisher.publishEvent(outEvent); applicationEventPublisher.publishEvent(outEvent);
} }
public void channelEventPublish(CommonGBChannel deviceChannel, ChannelEvent.ChannelEventMessageType type) {
catalogEventPublish(Collections.singletonList(deviceChannel), type);
}
private void catalogEventPublish(List<CommonGBChannel> channelList, ChannelEvent.ChannelEventMessageType type) {
ChannelEvent channelEvent = ChannelEvent.getInstance(this, type, channelList);
applicationEventPublisher.publishEvent(channelEvent);
}
public void catalogEventPublish(Platform platform, CommonGBChannel deviceChannel, String type) { public void catalogEventPublish(Platform platform, CommonGBChannel deviceChannel, String type) {
List<CommonGBChannel> deviceChannelList = new ArrayList<>(); catalogEventPublish(platform, Collections.singletonList(deviceChannel), type);
deviceChannelList.add(deviceChannel);
catalogEventPublish(platform, deviceChannelList, type);
} }
public void catalogEventPublish(Platform platform, List<CommonGBChannel> deviceChannels, String type) { public void catalogEventPublish(Platform platform, List<CommonGBChannel> deviceChannels, String type) {
if (platform != null && !userSetting.getServerId().equals(platform.getServerId())) { if (platform != null && !userSetting.getServerId().equals(platform.getServerId())) {

View File

@@ -30,69 +30,14 @@ public class ChannelEvent extends ApplicationEvent {
enum ChannelEventMessageType { public enum ChannelEventMessageType {
ADD, UPDATE, DELETE, ONLINE, OFFLINE, OFFLINE_LIST ADD, UPDATE, DELETE, ONLINE, OFFLINE, VLOST, DEFECT
} }
public static ChannelEvent getInstanceForAdd(Object source, CommonGBChannel channel) { public static ChannelEvent getInstance(Object source, ChannelEventMessageType messageType, List<CommonGBChannel> channelList) {
return getInstance(source, ChannelEventMessageType.ADD, channel);
}
public static ChannelEvent getInstanceForAddList(Object source, List<CommonGBChannel> channels) {
ChannelEvent channelEvent = new ChannelEvent(source);
channelEvent.setMessageType(ChannelEventMessageType.ADD);
channelEvent.setChannels(channels);
return channelEvent;
}
public static ChannelEvent getInstanceForUpdate(Object source, CommonGBChannel channel) {
return getInstance(source, ChannelEventMessageType.UPDATE, channel);
}
public static ChannelEvent getInstanceForUpdateList(Object source, List<CommonGBChannel> channels) {
ChannelEvent channelEvent = new ChannelEvent(source);
channelEvent.setMessageType(ChannelEventMessageType.UPDATE);
channelEvent.setChannels(channels);
return channelEvent;
}
public static ChannelEvent getInstanceForDelete(Object source, CommonGBChannel channel) {
return getInstance(source, ChannelEventMessageType.DELETE, channel);
}
public static ChannelEvent getInstanceForOnline(Object source, CommonGBChannel channel) {
return getInstance(source, ChannelEventMessageType.ONLINE, channel);
}
public static ChannelEvent getInstanceForOnlineList(Object source, List<CommonGBChannel> channels) {
ChannelEvent channelEvent = new ChannelEvent(source);
channelEvent.setMessageType(ChannelEventMessageType.ONLINE);
channelEvent.setChannels(channels);
return channelEvent;
}
public static ChannelEvent getInstanceForOffline(Object source, CommonGBChannel channel) {
return getInstance(source, ChannelEventMessageType.OFFLINE, channel);
}
public static ChannelEvent getInstanceForOfflineList(Object source, List<CommonGBChannel> channel) {
ChannelEvent channelEvent = new ChannelEvent(source);
channelEvent.setMessageType(ChannelEventMessageType.OFFLINE);
channelEvent.setChannels(channel);
return channelEvent;
}
public static Object getInstanceForDeleteList(Object source, List<CommonGBChannel> commonGBChannels) {
ChannelEvent channelEvent = new ChannelEvent(source);
channelEvent.setMessageType(ChannelEventMessageType.DELETE);
channelEvent.setChannels(commonGBChannels);
return channelEvent;
}
private static ChannelEvent getInstance(Object source, ChannelEventMessageType messageType, CommonGBChannel channel) {
ChannelEvent channelEvent = new ChannelEvent(source); ChannelEvent channelEvent = new ChannelEvent(source);
channelEvent.setMessageType(messageType); channelEvent.setMessageType(messageType);
channelEvent.setChannels(Collections.singletonList(channel)); channelEvent.setChannels(channelList);
return channelEvent; return channelEvent;
} }

View File

@@ -135,7 +135,8 @@ public class GbChannelServiceImpl implements IGbChannelService {
return 0; return 0;
} }
// 确定编号是否重复 // 确定编号是否重复
if (commonGBChannelMapper.queryByDeviceId(commonGBChannel.getGbDeviceId()).size() > 1) { List<CommonGBChannel> channels = commonGBChannelMapper.queryByDeviceId(commonGBChannel.getGbDeviceId());
if (channels.size() > 1) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "国标编号重复,请修改编号后保存"); throw new ControllerException(ErrorCode.ERROR100.getCode(), "国标编号重复,请修改编号后保存");
} }
commonGBChannel.setUpdateTime(DateUtil.getNow()); commonGBChannel.setUpdateTime(DateUtil.getNow());

View File

@@ -242,7 +242,6 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
} }
} }
} }
// 发送消息 // 发送消息
try { try {
// 发送catalog // 发送catalog