648540858
2023-03-08 cefdce5e0a34743e6d9784f858265120e75179a1
优化兼容接口
4个文件已修改
1 文件已重命名
228 ■■■■■ 已修改文件
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java
@@ -5,6 +5,7 @@
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 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 @@
    void cleanContentForPlatform(String serverGBId);
    List<DeviceChannel> queryChannelWithCatalog(String serverGBId);
    List<DeviceChannelExtend> queryChannelsByDeviceId(String serial, List<String> channelIds, Boolean online);
}
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
@@ -5,6 +5,7 @@
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 @@
            "</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);
@@ -244,28 +294,6 @@
            "</script>"})
    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);
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
@@ -14,6 +14,7 @@
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 @@
    }
    @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);
    }
@@ -377,6 +378,11 @@
    }
    @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);
        List<DeviceChannel> all = deviceChannelMapper.queryChannels(deviceId, parentChannelId, query, hasSubChannel, online,null);
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java
@@ -3,15 +3,17 @@
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 @@
    @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 @@
//        }
        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);
        }
src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java
File was renamed from src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtent.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 @@
     * <Status>OFF</Status>
     * 遇到过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 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;
    }
}