diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java index d3a9ae9e..4c4ce21a 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java @@ -100,7 +100,7 @@ public interface IVideoManagerStorage { * @param deviceId 设备ID * @return */ - public List queryChannelsByDeviceId(String deviceId); + public List queryChannelsByDeviceId(String deviceId, List channelIds,Integer start, Integer limit); public List queryOnlineChannelsByDeviceId(String deviceId); /** diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index 312d3e03..2e7fab57 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java @@ -71,6 +71,23 @@ public interface DeviceChannelMapper { " "}) List queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online); + + @Select(value = {" "}) + List queryChannelsByDeviceOrChannnelIds(String deviceId, List channelIds,Integer start, Integer limit); + + @Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND channelId=#{channelId}") DeviceChannel queryChannel(String deviceId, String channelId); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index 661a69b3..ef56b3f4 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -354,8 +354,8 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @Override - public List queryChannelsByDeviceId(String deviceId) { - return deviceChannelMapper.queryChannels(deviceId, null,null, null, null); + public List queryChannelsByDeviceId(String deviceId, List channels,Integer start, Integer limit) { + return deviceChannelMapper.queryChannelsByDeviceOrChannnelIds(deviceId, channels, start, limit); } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java index d4928ec7..da5d3c7b 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java @@ -9,8 +9,11 @@ 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 java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -92,6 +95,7 @@ public class ApiDeviceController { @RequestMapping(value = "/channellist") public JSONObject channellist( String serial, @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,19 +113,16 @@ public class ApiDeviceController { result.put("ChannelList", "[]"); return result; } - List deviceChannels; - List allDeviceChannelList = storager.queryChannelsByDeviceId(serial); - if (start == null || limit ==null) { - deviceChannels = allDeviceChannelList; - result.put("ChannelCount", deviceChannels.size()); - }else { - deviceChannels = storager.queryChannelsByDeviceIdWithStartAndLimit(serial, null, null, null,start, limit); - int total = allDeviceChannelList.size(); - result.put("ChannelCount", total); + List channelIds = null; + if (!StringUtils.isEmpty(code)) { + String[] split = code.trim().split(","); + channelIds = Arrays.asList(split); } + List allDeviceChannelList = storager.queryChannelsByDeviceId(serial, channelIds,start, limit); + result.put("ChannelCount", allDeviceChannelList.size()); JSONArray channleJSONList = new JSONArray(); - for (DeviceChannel deviceChannel : deviceChannels) { + for (DeviceChannel deviceChannel : allDeviceChannelList) { JSONObject deviceJOSNChannel = new JSONObject(); deviceJOSNChannel.put("ID", deviceChannel.getChannelId()); deviceJOSNChannel.put("DeviceID", device.getDeviceId());