Commit 7241e0d2d21e408877cf2e1c62a19f17a82a9ac9

Authored by 648540858
1 parent a4c93cf6

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

... ... @@ -224,7 +224,7 @@
224 224 </dependencies>
225 225  
226 226  
227   -
  227 +
228 228 <build>
229 229 <finalName>${project.artifactId}-${project.version}-${maven.build.timestamp}</finalName>
230 230 <plugins>
... ...
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
... ... @@ -89,6 +89,8 @@ public interface IVideoManagerStorager {
89 89 * @return
90 90 */
91 91 public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count);
  92 +
  93 + public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit);
92 94  
93 95 /**
94 96 * 获取某个设备的通道列表
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
... ... @@ -168,4 +168,20 @@ public interface DeviceChannelMapper {
168 168 "</foreach>" +
169 169 "</script>"})
170 170 void batchUpdate(List<DeviceChannel> updateChannels);
  171 +
  172 + @Select(value = {" <script>" +
  173 + "SELECT * FROM ( "+
  174 + " SELECT * , (SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount FROM device_channel dc " +
  175 + " WHERE dc.deviceId=#{deviceId} " +
  176 + " <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
  177 + " <if test='parentChannelId != null'> AND dc.parentId=#{parentChannelId} </if> " +
  178 + " <if test='online == true' > AND dc.status=1</if>" +
  179 + " <if test='online == false' > AND dc.status=0</if>) dcr" +
  180 + " WHERE 1=1 " +
  181 + " <if test='hasSubChannel == true' > AND subCount >0</if>" +
  182 + " <if test='hasSubChannel == false' > AND subCount=0</if>" +
  183 + " ORDER BY channelId ASC" +
  184 + " LIMIT #{limit} OFFSET #{start}" +
  185 + " </script>"})
  186 + List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, int start, int limit);
171 187 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
... ... @@ -259,6 +259,11 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
259 259 }
260 260  
261 261 @Override
  262 + public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit) {
  263 + return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit);
  264 + }
  265 +
  266 + @Override
262 267 public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) {
263 268 return deviceChannelMapper.queryChannels(deviceId, null,null, null, null);
264 269 }
... ...
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java
... ... @@ -110,14 +110,14 @@ public class ApiDeviceController {
110 110 return result;
111 111 }
112 112 List<DeviceChannel> deviceChannels;
  113 + List<DeviceChannel> allDeviceChannelList = storager.queryChannelsByDeviceId(serial);
113 114 if (start == null || limit ==null) {
114   - deviceChannels = storager.queryChannelsByDeviceId(serial);
  115 + deviceChannels = allDeviceChannelList;
115 116 result.put("ChannelCount", deviceChannels.size());
116 117 }else {
117   - start ++;
118   - PageInfo pageResult = storager.queryChannelsByDeviceId(serial, null, null, null,start, limit);
119   - result.put("ChannelCount", pageResult.getList().size());
120   - deviceChannels = pageResult.getList();
  118 + deviceChannels = storager.queryChannelsByDeviceIdWithStartAndLimit(serial, null, null, null,start, limit);
  119 + int total = allDeviceChannelList.size();
  120 + result.put("ChannelCount", total);
121 121 }
122 122  
123 123 JSONArray channleJSONList = new JSONArray();
... ...