优化兼容接口

pull/783/head
648540858 2023-03-08 14:46:18 +08:00
parent c5ff811378
commit cefdce5e0a
5 changed files with 126 additions and 102 deletions

View File

@ -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<DeviceChannel> queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count);
public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit,List<String> channelIds);
public List<DeviceChannelExtend> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List<String> channelIds, String query, Boolean hasSubChannel, Boolean online, int start, int limit);
/**
@ -374,4 +375,7 @@ public interface IVideoManagerStorage {
void cleanContentForPlatform(String serverGBId);
List<DeviceChannel> queryChannelWithCatalog(String serverGBId);
List<DeviceChannelExtend> queryChannelsByDeviceId(String serial, List<String> channelIds, Boolean online);
}

View File

@ -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 {
"</foreach> </if>" +
"ORDER BY dc.channelId " +
" </script>"})
List<DeviceChannel> queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online,List<String> channelIds);
List<DeviceChannel> queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, List<String> channelIds);
@Select(value = {" <script>" +
"SELECT " +
"dc.*, " +
"de.name as deviceName, " +
"de.online as deviceOnline " +
"from " +
"device_channel dc " +
"LEFT JOIN device de ON dc.deviceId = de.deviceId " +
"WHERE 1=1" +
" <if test='deviceId != null'> AND dc.deviceId = #{deviceId} </if> " +
" <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
" <if test='parentChannelId != null'> AND dc.parentId=#{parentChannelId} </if> " +
" <if test='online == true' > AND dc.status=1</if>" +
" <if test='online == false' > AND dc.status=0</if>" +
" <if test='hasSubChannel == true' > AND dc.subCount > 0 </if>" +
" <if test='hasSubChannel == false' > AND dc.subCount = 0 </if>" +
"<if test='channelIds != null'> AND dc.channelId in <foreach item='item' index='index' collection='channelIds' open='(' separator=',' close=')'>" +
"#{item} " +
"</foreach> </if>" +
"ORDER BY dc.channelId ASC" +
" </script>"})
List<DeviceChannelExtend> queryChannelsWithDeviceInfo(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, List<String> channelIds);
@Select(value = {" <script>" +
"SELECT " +
"dc.*, " +
"de.name as deviceName, " +
"de.online as deviceOnline " +
"from " +
"device_channel dc " +
"LEFT JOIN device de ON dc.deviceId = de.deviceId " +
"WHERE 1=1" +
" <if test='deviceId != null'> AND dc.deviceId = #{deviceId} </if> " +
" <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
" <if test='parentChannelId != null'> AND dc.parentId=#{parentChannelId} </if> " +
" <if test='online == true' > AND dc.status=1</if>" +
" <if test='online == false' > AND dc.status=0</if>" +
" <if test='hasSubChannel == true' > AND dc.subCount > 0 </if>" +
" <if test='hasSubChannel == false' > AND dc.subCount = 0 </if>" +
"<if test='channelIds != null'> AND dc.channelId in <foreach item='item' index='index' collection='channelIds' open='(' separator=',' close=')'>" +
"#{item} " +
"</foreach> </if>" +
"ORDER BY dc.channelId ASC " +
"Limit #{limit} OFFSET #{start}" +
" </script>"})
List<DeviceChannelExtend> queryChannelsByDeviceIdWithStartAndLimit(String deviceId,List<String> 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<DeviceChannel> updateChannels);
@Select(value = {" <script>" +
"SELECT " +
"dc1.* " +
"from " +
"device_channel dc1 " +
"WHERE " +
"dc1.deviceId = #{deviceId} " +
" <if test='query != null'> AND (dc1.channelId LIKE concat('%',#{query},'%') OR dc1.name LIKE concat('%',#{query},'%') OR dc1.name LIKE concat('%',#{query},'%'))</if> " +
" <if test='parentChannelId != null'> AND dc1.parentId=#{parentChannelId} </if> " +
" <if test='online == true' > AND dc1.status=1</if>" +
" <if test='online == false' > AND dc1.status=0</if>" +
" <if test='hasSubChannel == true' > AND dc1.subCount >0</if>" +
" <if test='hasSubChannel == false' > AND dc1.subCount=0</if>" +
"<if test='channelIds != null'> AND dc1.channelId in <foreach item='item' index='index' collection='channelIds' open='(' separator=',' close=')'>" +
"#{item} " +
"</foreach> </if>" +
"ORDER BY dc1.channelId ASC " +
"Limit #{limit} OFFSET #{start}" +
" </script>"})
List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String parentChannelId, String query,
Boolean hasSubChannel, Boolean online, int start, int limit,List<String> channelIds);
@Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND status=1")
List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);

View File

@ -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<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit,List<String> channelIds) {
return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit,channelIds);
public List<DeviceChannelExtend> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List<String> 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<DeviceChannelExtend> queryChannelsByDeviceId(String deviceId, List<String> channelIds, Boolean online) {
return deviceChannelMapper.queryChannelsWithDeviceInfo(deviceId, null,null, null, online,channelIds);
}
@Override
public PageInfo<DeviceChannel> querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, int page, int count) {
PageHelper.startPage(page, count);

View File

@ -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<DeviceChannel> deviceChannels;
// Device device = storager.queryVideoDevice(serial);
// if (device == null) {
// result.put("ChannelCount", 0);
// result.put("ChannelList", "[]");
// return result;
// }
List<DeviceChannelExtend> deviceChannels;
List<String> channelIds = null;
if (!StringUtils.isEmpty(code)) {
String[] split = code.trim().split(",");
channelIds = Arrays.asList(split);
}
List<DeviceChannel> allDeviceChannelList = storager.queryChannelsByDeviceId(serial,online,channelIds);
List<DeviceChannelExtend> 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);
}

View File

@ -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 {
* <Status>OFF</Status>
* NVRIPC 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;
}
}