From cefdce5e0a34743e6d9784f858265120e75179a1 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 8 Mar 2023 14:46:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=BC=E5=AE=B9=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/storager/IVideoManagerStorage.java | 6 +- .../vmp/storager/dao/DeviceChannelMapper.java | 74 +++++++++++++------ .../impl/VideoManagerStorageImpl.java | 10 ++- .../vmp/web/gb28181/ApiDeviceController.java | 70 ++++++++++-------- ...elExtent.java => DeviceChannelExtend.java} | 68 ++++++----------- 5 files changed, 126 insertions(+), 102 deletions(-) rename src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/{DeviceChannelExtent.java => DeviceChannelExtend.java} (78%) diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java index 938f669b..5965678e 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; +import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; import com.github.pagehelper.PageInfo; import java.util.List; @@ -58,7 +59,7 @@ public interface IVideoManagerStorage { */ public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count); - public List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit,List channelIds); + public List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List channelIds, String query, Boolean hasSubChannel, Boolean online, int start, int limit); /** @@ -374,4 +375,7 @@ public interface IVideoManagerStorage { void cleanContentForPlatform(String serverGBId); List queryChannelWithCatalog(String serverGBId); + + List queryChannelsByDeviceId(String serial, List channelIds, Boolean online); + } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index 83f93343..e33a63ed 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannelInPlatform; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; +import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; @@ -82,7 +83,56 @@ public interface DeviceChannelMapper { " " + "ORDER BY dc.channelId " + " "}) - List queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online,List channelIds); + List queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, List channelIds); + + @Select(value = {" "}) + List queryChannelsWithDeviceInfo(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, List channelIds); + + + @Select(value = {" "}) + List queryChannelsByDeviceIdWithStartAndLimit(String deviceId,List channelIds, String parentChannelId, String query, + Boolean hasSubChannel, Boolean online, int start, int limit); @Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND channelId=#{channelId}") DeviceChannel queryChannel(String deviceId, String channelId); @@ -245,28 +295,6 @@ public interface DeviceChannelMapper { int batchUpdate(List updateChannels); - @Select(value = {" "}) - List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String parentChannelId, String query, - Boolean hasSubChannel, Boolean online, int start, int limit,List channelIds); - @Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND status=1") List queryOnlineChannelsByDeviceId(String deviceId); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index 8eefd396..9475abcd 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -14,6 +14,7 @@ import com.genersoft.iot.vmp.storager.dao.*; import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; +import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.slf4j.Logger; @@ -366,8 +367,8 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { } @Override - public List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit,List channelIds) { - return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit,channelIds); + public List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List channelIds, String query, Boolean hasSubChannel, Boolean online, int start, int limit) { + return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, channelIds, null, query, hasSubChannel, online, start, limit); } @@ -376,6 +377,11 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return deviceChannelMapper.queryChannels(deviceId, null,null, null, online,channelIds); } + @Override + public List queryChannelsByDeviceId(String deviceId, List channelIds, Boolean online) { + return deviceChannelMapper.queryChannelsWithDeviceInfo(deviceId, null,null, null, online,channelIds); + } + @Override public PageInfo querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, int page, int count) { PageHelper.startPage(page, count); diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java index 57c79799..99989608 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java @@ -3,15 +3,17 @@ package com.genersoft.iot.vmp.web.gb28181; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; import com.github.pagehelper.PageInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import java.util.Arrays; import java.util.List; @@ -96,8 +98,8 @@ public class ApiDeviceController { @RequestMapping(value = "/channellist") public JSONObject channellist( String serial, - @RequestParam(required = false)String code, @RequestParam(required = false)String channel_type, + @RequestParam(required = false)String code , @RequestParam(required = false)String dir_serial , @RequestParam(required = false)Integer start, @RequestParam(required = false)Integer limit, @@ -109,54 +111,60 @@ public class ApiDeviceController { // } JSONObject result = new JSONObject(); // 查询设备是否存在 - List deviceChannels; +// Device device = storager.queryVideoDevice(serial); +// if (device == null) { +// result.put("ChannelCount", 0); +// result.put("ChannelList", "[]"); +// return result; +// } + List deviceChannels; List channelIds = null; if (!StringUtils.isEmpty(code)) { String[] split = code.trim().split(","); channelIds = Arrays.asList(split); } - List allDeviceChannelList = storager.queryChannelsByDeviceId(serial,online,channelIds); + List allDeviceChannelList = storager.queryChannelsByDeviceId(serial,channelIds,online); if (start == null || limit ==null) { deviceChannels = allDeviceChannelList; result.put("ChannelCount", deviceChannels.size()); }else { - deviceChannels = storager.queryChannelsByDeviceIdWithStartAndLimit(serial, null, null, online,start, limit,channelIds); + deviceChannels = storager.queryChannelsByDeviceIdWithStartAndLimit(serial,channelIds, null, null, online,start, limit); int total = allDeviceChannelList.size(); result.put("ChannelCount", total); } JSONArray channleJSONList = new JSONArray(); - for (DeviceChannel deviceChannel : deviceChannels) { + for (DeviceChannelExtend deviceChannelExtend : deviceChannels) { JSONObject deviceJOSNChannel = new JSONObject(); - deviceJOSNChannel.put("ID", deviceChannel.getChannelId()); - deviceJOSNChannel.put("DeviceID", device.getDeviceId()); - deviceJOSNChannel.put("DeviceName", device.getName()); - deviceJOSNChannel.put("DeviceOnline", device.getOnline() == 1); - deviceJOSNChannel.put("Channel", 0); // 自定义序号 - deviceJOSNChannel.put("Name", deviceChannel.getName()); + deviceJOSNChannel.put("ID", deviceChannelExtend.getChannelId()); + deviceJOSNChannel.put("DeviceID", deviceChannelExtend.getDeviceId()); + deviceJOSNChannel.put("DeviceName", deviceChannelExtend.getDeviceName()); + deviceJOSNChannel.put("DeviceOnline", deviceChannelExtend.getDeviceOnline() == 1); + deviceJOSNChannel.put("Channel", 0); // TODO 自定义序号 + deviceJOSNChannel.put("Name", deviceChannelExtend.getName()); deviceJOSNChannel.put("Custom", false); deviceJOSNChannel.put("CustomName", ""); - deviceJOSNChannel.put("SubCount", deviceChannel.getSubCount()); // 子节点数, SubCount > 0 表示该通道为子目录 + deviceJOSNChannel.put("SubCount", deviceChannelExtend.getSubCount()); // TODO ? 子节点数, SubCount > 0 表示该通道为子目录 deviceJOSNChannel.put("SnapURL", ""); - deviceJOSNChannel.put("Manufacturer ", deviceChannel.getManufacture()); - deviceJOSNChannel.put("Model", deviceChannel.getModel()); - deviceJOSNChannel.put("Owner", deviceChannel.getOwner()); - deviceJOSNChannel.put("CivilCode", deviceChannel.getCivilCode()); - deviceJOSNChannel.put("Address", deviceChannel.getAddress()); - deviceJOSNChannel.put("Parental", deviceChannel.getParental()); // 当为通道设备时, 是否有通道子设备, 1-有,0-没有 - deviceJOSNChannel.put("ParentID", deviceChannel.getParentId()); // 直接上级编号 - deviceJOSNChannel.put("Secrecy", deviceChannel.getSecrecy()); + deviceJOSNChannel.put("Manufacturer ", deviceChannelExtend.getManufacture()); + deviceJOSNChannel.put("Model", deviceChannelExtend.getModel()); + deviceJOSNChannel.put("Owner", deviceChannelExtend.getOwner()); + deviceJOSNChannel.put("CivilCode", deviceChannelExtend.getCivilCode()); + deviceJOSNChannel.put("Address", deviceChannelExtend.getAddress()); + deviceJOSNChannel.put("Parental", deviceChannelExtend.getParental()); // 当为通道设备时, 是否有通道子设备, 1-有,0-没有 + deviceJOSNChannel.put("ParentID", deviceChannelExtend.getParentId()); // 直接上级编号 + deviceJOSNChannel.put("Secrecy", deviceChannelExtend.getSecrecy()); deviceJOSNChannel.put("RegisterWay", 1); // 注册方式, 缺省为1, 允许值: 1, 2, 3 - // 1-IETF RFC3261, - // 2-基于口令的双向认证, - // 3-基于数字证书的双向认证 - deviceJOSNChannel.put("Status", deviceChannel.getStatus() == 1 ? "ON":"OFF"); - deviceJOSNChannel.put("Longitude", deviceChannel.getLongitude()); - deviceJOSNChannel.put("Latitude", deviceChannel.getLatitude()); - deviceJOSNChannel.put("PTZType ", deviceChannel.getPTZType()); // 云台类型, 0 - 未知, 1 - 球机, 2 - 半球, - // 3 - 固定枪机, 4 - 遥控枪机 + // 1-IETF RFC3261, + // 2-基于口令的双向认证, + // 3-基于数字证书的双向认证 + deviceJOSNChannel.put("Status", deviceChannelExtend.getStatus() == 1 ? "ON":"OFF"); + deviceJOSNChannel.put("Longitude", deviceChannelExtend.getLongitude()); + deviceJOSNChannel.put("Latitude", deviceChannelExtend.getLatitude()); + deviceJOSNChannel.put("PTZType ", deviceChannelExtend.getPTZType()); // 云台类型, 0 - 未知, 1 - 球机, 2 - 半球, + // 3 - 固定枪机, 4 - 遥控枪机 deviceJOSNChannel.put("CustomPTZType", ""); - deviceJOSNChannel.put("StreamID", deviceChannel.getStreamId()); // StreamID 直播流ID, 有值表示正在直播 + deviceJOSNChannel.put("StreamID", deviceChannelExtend.getStreamId()); // StreamID 直播流ID, 有值表示正在直播 deviceJOSNChannel.put("NumOutputs ", -1); // 直播在线人数 channleJSONList.add(deviceJOSNChannel); } diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtent.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java similarity index 78% rename from src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtent.java rename to src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java index 94943524..972d1a6a 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtent.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java @@ -1,165 +1,140 @@ package com.genersoft.iot.vmp.web.gb28181.dto; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "通道信息") -public class DeviceChannelExtent { +public class DeviceChannelExtend { /** * 数据库自增ID */ - @Schema(description = "数据库自增ID") private int id; /** - * 通道国标编号 + * 通道id */ - @Schema(description = "通道国标编号") private String channelId; /** - * 设备国标编号 + * 设备id */ - @Schema(description = "设备国标编号") private String deviceId; /** * 通道名 */ - @Schema(description = "名称") private String name; + + private String deviceName; + + private int deviceOnline; /** * 生产厂商 */ - @Schema(description = "生产厂商") private String manufacture; /** * 型号 */ - @Schema(description = "型号") private String model; /** * 设备归属 */ - @Schema(description = "设备归属") private String owner; /** * 行政区域 */ - @Schema(description = "行政区域") private String civilCode; /** * 警区 */ - @Schema(description = "警区") private String block; /** * 安装地址 */ - @Schema(description = "安装地址") private String address; /** * 是否有子设备 1有, 0没有 */ - @Schema(description = "是否有子设备 1有, 0没有") private int parental; /** * 父级id */ - @Schema(description = "父级id") private String parentId; /** * 信令安全模式 缺省为0; 0:不采用; 2: S/MIME签名方式; 3: S/ MIME加密签名同时采用方式; 4:数字摘要方式 */ - @Schema(description = "信令安全模式 缺省为0; 0:不采用; 2: S/MIME签名方式; 3: S/ MIME加密签名同时采用方式; 4:数字摘要方式") private int safetyWay; /** * 注册方式 缺省为1;1:符合IETFRFC3261标准的认证注册模 式; 2:基于口令的双向认证注册模式; 3:基于数字证书的双向认证注册模式 */ - @Schema(description = "注册方式 缺省为1;1:符合IETFRFC3261标准的认证注册模 式; 2:基于口令的双向认证注册模式; 3:基于数字证书的双向认证注册模式") private int registerWay; /** * 证书序列号 */ - @Schema(description = "证书序列号") private String certNum; /** * 证书有效标识 缺省为0;证书有效标识:0:无效1: 有效 */ - @Schema(description = "证书有效标识 缺省为0;证书有效标识:0:无效1: 有效") private int certifiable; /** * 证书无效原因码 */ - @Schema(description = "证书无效原因码") private int errCode; /** * 证书终止有效期 */ - @Schema(description = "证书终止有效期") private String endTime; /** * 保密属性 缺省为0; 0:不涉密, 1:涉密 */ - @Schema(description = "保密属性 缺省为0; 0:不涉密, 1:涉密") private String secrecy; /** * IP地址 */ - @Schema(description = "IP地址") private String ipAddress; /** * 端口号 */ - @Schema(description = "端口号") private int port; /** * 密码 */ - @Schema(description = "密码") private String password; /** * 云台类型 */ - @Schema(description = "云台类型") private int PTZType; /** * 云台类型描述字符串 */ - @Schema(description = "云台类型描述字符串") private String PTZTypeText; /** * 创建时间 */ - @Schema(description = "创建时间") private String createTime; /** * 更新时间 */ - @Schema(description = "更新时间") private String updateTime; /** @@ -171,79 +146,66 @@ public class DeviceChannelExtent { * OFF * 遇到过NVR下的IPC下发信令可以推流, 但是 Status 响应 OFF */ - @Schema(description = "在线/离线, 1在线,0离线") private int status; /** * 经度 */ - @Schema(description = "经度") private double longitude; /** * 纬度 */ - @Schema(description = "纬度") private double latitude; /** * 经度 GCJ02 */ - @Schema(description = "GCJ02坐标系经度") private double longitudeGcj02; /** * 纬度 GCJ02 */ - @Schema(description = "GCJ02坐标系纬度") private double latitudeGcj02; /** * 经度 WGS84 */ - @Schema(description = "WGS84坐标系经度") private double longitudeWgs84; /** * 纬度 WGS84 */ - @Schema(description = "WGS84坐标系纬度") private double latitudeWgs84; /** * 子设备数 */ - @Schema(description = "子设备数") private int subCount; /** * 流唯一编号,存在表示正在直播 */ - @Schema(description = "流唯一编号,存在表示正在直播") private String streamId; /** * 是否含有音频 */ - @Schema(description = "是否含有音频") private boolean hasAudio; /** * 标记通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划 */ - @Schema(description = "标记通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划") private int channelType; /** * 业务分组 */ - @Schema(description = "业务分组") private String businessGroupId; /** * GPS的更新时间 */ - @Schema(description = "GPS的更新时间") private String gpsTime; public int getId() { @@ -574,4 +536,20 @@ public class DeviceChannelExtent { public void setGpsTime(String gpsTime) { this.gpsTime = gpsTime; } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public int getDeviceOnline() { + return deviceOnline; + } + + public void setDeviceOnline(int deviceOnline) { + this.deviceOnline = deviceOnline; + } }