Browse Source

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

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

2
pom.xml

@ -224,7 +224,7 @@
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}-${maven.build.timestamp}</finalName>
<plugins>

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

@ -89,6 +89,8 @@ public interface IVideoManagerStorager {
* @return
*/
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>" +
"</script>"})
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);
}
@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
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) {
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;
}
List<DeviceChannel> deviceChannels;
List<DeviceChannel> allDeviceChannelList = storager.queryChannelsByDeviceId(serial);
if (start == null || limit ==null) {
deviceChannels = storager.queryChannelsByDeviceId(serial);
deviceChannels = allDeviceChannelList;
result.put("ChannelCount", deviceChannels.size());
}else {
start ++;
PageInfo pageResult = storager.queryChannelsByDeviceId(serial, null, null, null,start, limit);
result.put("ChannelCount", pageResult.getList().size());
deviceChannels = pageResult.getList();
deviceChannels = storager.queryChannelsByDeviceIdWithStartAndLimit(serial, null, null, null,start, limit);
int total = allDeviceChannelList.size();
result.put("ChannelCount", total);
}
JSONArray channleJSONList = new JSONArray();

Loading…
Cancel
Save