优化兼容的接口
parent
5dc08a45f8
commit
0cf52c375f
|
@ -100,7 +100,7 @@ public interface IVideoManagerStorage {
|
|||
* @param deviceId 设备ID
|
||||
* @return
|
||||
*/
|
||||
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId);
|
||||
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId, List<String> channelIds,Integer start, Integer limit);
|
||||
public List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
|
||||
|
||||
/**
|
||||
|
|
|
@ -71,6 +71,23 @@ public interface DeviceChannelMapper {
|
|||
" </script>"})
|
||||
List<DeviceChannel> queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online);
|
||||
|
||||
|
||||
@Select(value = {" <script>" +
|
||||
"SELECT " +
|
||||
"dc.* " +
|
||||
"from " +
|
||||
"device_channel dc " +
|
||||
"WHERE " +
|
||||
"dc.deviceId = #{deviceId} " +
|
||||
"<if test='channelIds != null'> AND dc.channelId in <foreach item='item' index='index' collection='channelIds' open='(' separator=',' close=')'>" +
|
||||
"#{item} " +
|
||||
"</foreach> </if>" +
|
||||
"GROUP BY dc.channelId " +
|
||||
"<if test='start != null and limit != null ' > Limit #{limit} OFFSET #{start} </if>" +
|
||||
" </script>"})
|
||||
List<DeviceChannel> queryChannelsByDeviceOrChannnelIds(String deviceId, List<String> channelIds,Integer start, Integer limit);
|
||||
|
||||
|
||||
@Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND channelId=#{channelId}")
|
||||
DeviceChannel queryChannel(String deviceId, String channelId);
|
||||
|
||||
|
|
|
@ -354,8 +354,8 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
|||
|
||||
|
||||
@Override
|
||||
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) {
|
||||
return deviceChannelMapper.queryChannels(deviceId, null,null, null, null);
|
||||
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId, List<String> channels,Integer start, Integer limit) {
|
||||
return deviceChannelMapper.queryChannelsByDeviceOrChannnelIds(deviceId, channels, start, limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<DeviceChannel> deviceChannels;
|
||||
List<DeviceChannel> 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<String> channelIds = null;
|
||||
if (!StringUtils.isEmpty(code)) {
|
||||
String[] split = code.trim().split(",");
|
||||
channelIds = Arrays.asList(split);
|
||||
}
|
||||
List<DeviceChannel> 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());
|
||||
|
|
Loading…
Reference in New Issue