Browse Source

修复兼容接口查询通道列表查询

pull/295/head
648540858 3 years ago
parent
commit
7241e0d2d2
  1. 2
      src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
  2. 16
      src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
  3. 5
      src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
  4. 10
      src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java

2
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java

@ -90,6 +90,8 @@ public interface IVideoManagerStorager {
*/ */
public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count); public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count);
public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit);
/** /**
* 获取某个设备的通道列表 * 获取某个设备的通道列表
* *

16
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java

@ -168,4 +168,20 @@ public interface DeviceChannelMapper {
"</foreach>" + "</foreach>" +
"</script>"}) "</script>"})
void batchUpdate(List<DeviceChannel> updateChannels); void batchUpdate(List<DeviceChannel> updateChannels);
@Select(value = {" <script>" +
"SELECT * FROM ( "+
" SELECT * , (SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount FROM device_channel dc " +
" WHERE dc.deviceId=#{deviceId} " +
" <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>) dcr" +
" WHERE 1=1 " +
" <if test='hasSubChannel == true' > AND subCount >0</if>" +
" <if test='hasSubChannel == false' > AND subCount=0</if>" +
" ORDER BY channelId ASC" +
" LIMIT #{limit} OFFSET #{start}" +
" </script>"})
List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, int start, int limit);
} }

5
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java

@ -258,6 +258,11 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
return new PageInfo<>(all); return new PageInfo<>(all);
} }
@Override
public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit) {
return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit);
}
@Override @Override
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) { public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) {
return deviceChannelMapper.queryChannels(deviceId, null,null, null, null); return deviceChannelMapper.queryChannels(deviceId, null,null, null, null);

10
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java

@ -110,14 +110,14 @@ public class ApiDeviceController {
return result; return result;
} }
List<DeviceChannel> deviceChannels; List<DeviceChannel> deviceChannels;
List<DeviceChannel> allDeviceChannelList = storager.queryChannelsByDeviceId(serial);
if (start == null || limit ==null) { if (start == null || limit ==null) {
deviceChannels = storager.queryChannelsByDeviceId(serial); deviceChannels = allDeviceChannelList;
result.put("ChannelCount", deviceChannels.size()); result.put("ChannelCount", deviceChannels.size());
}else { }else {
start ++; deviceChannels = storager.queryChannelsByDeviceIdWithStartAndLimit(serial, null, null, null,start, limit);
PageInfo pageResult = storager.queryChannelsByDeviceId(serial, null, null, null,start, limit); int total = allDeviceChannelList.size();
result.put("ChannelCount", pageResult.getList().size()); result.put("ChannelCount", total);
deviceChannels = pageResult.getList();
} }
JSONArray channleJSONList = new JSONArray(); JSONArray channleJSONList = new JSONArray();

Loading…
Cancel
Save