临时提交

This commit is contained in:
lin
2025-10-17 17:03:00 +08:00
parent c10c982954
commit feb7e0e9c4
5 changed files with 126 additions and 6 deletions

View File

@@ -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;
}

View File

@@ -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<CommonGBChannel> channels = event.getChannels();
if (channels.isEmpty()) {
return;
}
List<CameraChannel> 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<Integer> 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<CameraChannel> queryList(Integer page, Integer count, String groupAlias, Boolean status, String geoCoordSys) {
// 构建组织结构信息