Merge branch 'wvp-28181-2.0' into wvp-28181-2.0

pull/713/head
648540858 2023-01-05 09:38:11 +08:00 committed by GitHub
commit ce035dbcdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 99 additions and 82 deletions

View File

@ -11,7 +11,7 @@
<groupId>com.genersoft</groupId> <groupId>com.genersoft</groupId>
<artifactId>wvp-pro</artifactId> <artifactId>wvp-pro</artifactId>
<version>2.6.6</version> <version>2.6.7</version>
<name>web video platform</name> <name>web video platform</name>
<description>国标28181视频平台</description> <description>国标28181视频平台</description>

View File

@ -1,43 +1,3 @@
alter table media_server -- 2.6.6->2.6.7
drop column streamNoneReaderDelayMS;
alter table media_server
drop column sendRtpPortRange;
alter table stream_proxy
add enable_disable_none_reader bit(1) default null;
alter table device alter table device
add mediaServerId varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'auto'; add keepaliveIntervalTime int default null;
alter table device
add custom_name varchar(255) default null;
alter table device
add sdpIp varchar(50) default null;
alter table device
add localIp varchar(50) default null;
alter table device
add password varchar(255) default null;
alter table device
modify ip varchar(50) null;
alter table device
modify port int null;
alter table device
modify expires int null;
alter table device
modify subscribeCycleForCatalog int null;
alter table device
modify hostAddress varchar(50) null;
alter table stream_proxy
change enable_hls enable_audio bit null;

View File

@ -70,6 +70,8 @@ public class VideoManagerConstants {
public static final String SYSTEM_INFO_DISK_PREFIX = "VMP_SYSTEM_INFO_DISK_"; public static final String SYSTEM_INFO_DISK_PREFIX = "VMP_SYSTEM_INFO_DISK_";
public static final String REGISTER_EXPIRE_TASK_KEY_PREFIX = "VMP_device_register_expire_";

View File

@ -94,6 +94,13 @@ public class Device {
@Schema(description = "心跳时间") @Schema(description = "心跳时间")
private String keepaliveTime; private String keepaliveTime;
/**
*
*/
@Schema(description = "心跳间隔")
private int keepaliveIntervalTime;
/** /**
* *
*/ */
@ -413,4 +420,12 @@ public class Device {
public void setLocalIp(String localIp) { public void setLocalIp(String localIp) {
this.localIp = localIp; this.localIp = localIp;
} }
public int getKeepaliveIntervalTime() {
return keepaliveIntervalTime;
}
public void setKeepaliveIntervalTime(int keepaliveIntervalTime) {
this.keepaliveIntervalTime = keepaliveIntervalTime;
}
} }

View File

@ -1,5 +1,7 @@
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
@ -43,6 +45,9 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
@Autowired @Autowired
private UserSetting userSetting; private UserSetting userSetting;
@Autowired
private DynamicTask dynamicTask;
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
notifyMessageHandler.addHandler(cmdType, this); notifyMessageHandler.addHandler(cmdType, this);
@ -68,6 +73,13 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort()))); device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort())));
device.setIp(remoteAddressInfo.getIp()); device.setIp(remoteAddressInfo.getIp());
} }
if (device.getKeepaliveTime() == null) {
device.setKeepaliveIntervalTime(60);
}else {
long lastTime = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(device.getKeepaliveTime());
device.setKeepaliveIntervalTime(new Long(System.currentTimeMillis()/1000-lastTime).intValue());
}
device.setKeepaliveTime(DateUtil.getNow()); device.setKeepaliveTime(DateUtil.getNow());
if (device.getOnline() == 1) { if (device.getOnline() == 1) {
@ -75,9 +87,15 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
}else { }else {
// 对于已经离线的设备判断他的注册是否已经过期 // 对于已经离线的设备判断他的注册是否已经过期
if (!deviceService.expire(device)){ if (!deviceService.expire(device)){
device.setOnline(0);
deviceService.online(device); deviceService.online(device);
} }
} }
// 刷新过期任务
String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + device.getDeviceId();
// 如果三次心跳失败,则设置设备离线
dynamicTask.startDelay(registerExpireTaskKey, ()-> deviceService.offline(device.getDeviceId()), device.getKeepaliveIntervalTime()*1000*3);
} }
@Override @Override

View File

@ -99,7 +99,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
HashMap<String, DeviceChannel> channelsInStore = new HashMap<>(); HashMap<String, DeviceChannel> channelsInStore = new HashMap<>();
Device device = deviceMapper.getDeviceByDeviceId(deviceId); Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (channels != null && channels.size() > 0) { if (channels != null && channels.size() > 0) {
List<DeviceChannel> channelList = channelMapper.queryChannels(deviceId, null, null, null, null); List<DeviceChannel> channelList = channelMapper.queryChannels(deviceId, null, null, null, null,null);
if (channelList.size() == 0) { if (channelList.size() == 0) {
for (DeviceChannel channel : channels) { for (DeviceChannel channel : channels) {
channel.setDeviceId(deviceId); channel.setDeviceId(deviceId);

View File

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.service.impl; package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.bean.*;
@ -45,8 +46,6 @@ public class DeviceServiceImpl implements IDeviceService {
private final static Logger logger = LoggerFactory.getLogger(DeviceServiceImpl.class); private final static Logger logger = LoggerFactory.getLogger(DeviceServiceImpl.class);
private final String registerExpireTaskKeyPrefix = "device-register-expire-";
@Autowired @Autowired
private DynamicTask dynamicTask; private DynamicTask dynamicTask;
@ -101,7 +100,10 @@ public class DeviceServiceImpl implements IDeviceService {
redisCatchStorage.clearCatchByDeviceId(device.getDeviceId()); redisCatchStorage.clearCatchByDeviceId(device.getDeviceId());
} }
device.setUpdateTime(now); device.setUpdateTime(now);
if (device.getKeepaliveIntervalTime() == 0) {
// 默认心跳间隔60
device.setKeepaliveIntervalTime(60);
}
// 第一次上线 或则设备之前是离线状态--进行通道同步和设备信息查询 // 第一次上线 或则设备之前是离线状态--进行通道同步和设备信息查询
if (device.getCreateTime() == null) { if (device.getCreateTime() == null) {
device.setOnline(1); device.setOnline(1);
@ -116,7 +118,6 @@ public class DeviceServiceImpl implements IDeviceService {
} }
sync(device); sync(device);
}else { }else {
if(device.getOnline() == 0){ if(device.getOnline() == 0){
device.setOnline(1); device.setOnline(1);
device.setCreateTime(now); device.setCreateTime(now);
@ -153,19 +154,19 @@ public class DeviceServiceImpl implements IDeviceService {
addMobilePositionSubscribe(device); addMobilePositionSubscribe(device);
} }
// 刷新过期任务 // 刷新过期任务
String registerExpireTaskKey = registerExpireTaskKeyPrefix + device.getDeviceId(); String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + device.getDeviceId();
// 增加一个10秒给设备重发消息的机会 // 如果第一次注册那么必须在60 * 3时间内收到一个心跳否则设备离线
dynamicTask.startDelay(registerExpireTaskKey, ()-> offline(device.getDeviceId()), (device.getExpires() + 10) * 1000); dynamicTask.startDelay(registerExpireTaskKey, ()-> offline(device.getDeviceId()), device.getKeepaliveIntervalTime() * 1000 * 3);
} }
@Override @Override
public void offline(String deviceId) { public void offline(String deviceId) {
logger.info("[设备离线] device{}", deviceId); logger.error("[设备离线] device{}", deviceId);
Device device = deviceMapper.getDeviceByDeviceId(deviceId); Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device == null) { if (device == null) {
return; return;
} }
String registerExpireTaskKey = registerExpireTaskKeyPrefix + deviceId; String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + deviceId;
dynamicTask.stop(registerExpireTaskKey); dynamicTask.stop(registerExpireTaskKey);
device.setOnline(0); device.setOnline(0);
redisCatchStorage.updateDevice(device); redisCatchStorage.updateDevice(device);
@ -408,7 +409,7 @@ public class DeviceServiceImpl implements IDeviceService {
if (parentId.length() < 14 ) { if (parentId.length() < 14 ) {
return null; return null;
} }
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null); List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null,null);
List<BaseTree<DeviceChannel>> trees = transportChannelsToTree(deviceChannels, parentId); List<BaseTree<DeviceChannel>> trees = transportChannelsToTree(deviceChannels, parentId);
return trees; return trees;
} }
@ -453,7 +454,7 @@ public class DeviceServiceImpl implements IDeviceService {
if (parentId.length() < 14 ) { if (parentId.length() < 14 ) {
return null; return null;
} }
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null); List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null,null);
return deviceChannels; return deviceChannels;
} }
@ -517,7 +518,7 @@ public class DeviceServiceImpl implements IDeviceService {
} }
}else { }else {
if (haveChannel) { if (haveChannel) {
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, null, null, null, null); List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, null, null, null, null,null);
if (deviceChannels != null && deviceChannels.size() > 0) { if (deviceChannels != null && deviceChannels.size() > 0) {
result.addAll(deviceChannels); result.addAll(deviceChannels);
} }

View File

@ -59,7 +59,7 @@ public interface IVideoManagerStorage {
*/ */
public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count); public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count);
public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit); public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit,List<String> channelIds);
/** /**
@ -68,7 +68,7 @@ public interface IVideoManagerStorage {
* @param deviceId ID * @param deviceId ID
* @return * @return
*/ */
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId); public List<DeviceChannel> queryChannelsByDeviceId(String deviceId,Boolean online,List<String> channelIds);
public List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId); public List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
/** /**
@ -91,14 +91,14 @@ public interface IVideoManagerStorage {
* @param count * @param count
* @return List<Device> * @return List<Device>
*/ */
public PageInfo<Device> queryVideoDeviceList(int page, int count); public PageInfo<Device> queryVideoDeviceList(int page, int count,Boolean online);
/** /**
* *
* *
* @return List<Device> * @return List<Device>
*/ */
public List<Device> queryVideoDeviceList(); public List<Device> queryVideoDeviceList(Boolean online);

View File

@ -76,9 +76,12 @@ public interface DeviceChannelMapper {
" <if test='online == false' > AND dc.status=0</if>" + " <if test='online == false' > AND dc.status=0</if>" +
" <if test='hasSubChannel == true' > AND dc.subCount > 0 </if>" + " <if test='hasSubChannel == true' > AND dc.subCount > 0 </if>" +
" <if test='hasSubChannel == false' > AND dc.subCount = 0 </if>" + " <if test='hasSubChannel == false' > AND dc.subCount = 0 </if>" +
"<if test='channelIds != null'> AND dc.channelId in <foreach item='item' index='index' collection='channelIds' open='(' separator=',' close=')'>" +
"#{item} " +
"</foreach> </if>" +
"ORDER BY dc.channelId " + "ORDER BY dc.channelId " +
" </script>"}) " </script>"})
List<DeviceChannel> queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online); List<DeviceChannel> queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online,List<String> channelIds);
@Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND channelId=#{channelId}") @Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND channelId=#{channelId}")
DeviceChannel queryChannel(String deviceId, String channelId); DeviceChannel queryChannel(String deviceId, String channelId);
@ -254,11 +257,14 @@ public interface DeviceChannelMapper {
" <if test='online == false' > AND dc1.status=0</if>" + " <if test='online == false' > AND dc1.status=0</if>" +
" <if test='hasSubChannel == true' > AND dc1.subCount >0</if>" + " <if test='hasSubChannel == true' > AND dc1.subCount >0</if>" +
" <if test='hasSubChannel == false' > AND dc1.subCount=0</if>" + " <if test='hasSubChannel == false' > AND dc1.subCount=0</if>" +
"<if test='channelIds != null'> AND dc1.channelId in <foreach item='item' index='index' collection='channelIds' open='(' separator=',' close=')'>" +
"#{item} " +
"</foreach> </if>" +
"ORDER BY dc1.channelId ASC " + "ORDER BY dc1.channelId ASC " +
"Limit #{limit} OFFSET #{start}" + "Limit #{limit} OFFSET #{start}" +
" </script>"}) " </script>"})
List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String parentChannelId, String query, List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String parentChannelId, String query,
Boolean hasSubChannel, Boolean online, int start, int limit); Boolean hasSubChannel, Boolean online, int start, int limit,List<String> channelIds);
@Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND status=1") @Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND status=1")
List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId); List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);

View File

@ -61,6 +61,7 @@ public interface DeviceMapper {
"expires," + "expires," +
"registerTime," + "registerTime," +
"keepaliveTime," + "keepaliveTime," +
"keepaliveIntervalTime," +
"createTime," + "createTime," +
"updateTime," + "updateTime," +
"charset," + "charset," +
@ -88,6 +89,7 @@ public interface DeviceMapper {
"#{expires}," + "#{expires}," +
"#{registerTime}," + "#{registerTime}," +
"#{keepaliveTime}," + "#{keepaliveTime}," +
"#{keepaliveIntervalTime}," +
"#{createTime}," + "#{createTime}," +
"#{updateTime}," + "#{updateTime}," +
"#{charset}," + "#{charset}," +
@ -117,12 +119,15 @@ public interface DeviceMapper {
"<if test=\"online != null\">, online=#{online}</if>" + "<if test=\"online != null\">, online=#{online}</if>" +
"<if test=\"registerTime != null\">, registerTime=#{registerTime}</if>" + "<if test=\"registerTime != null\">, registerTime=#{registerTime}</if>" +
"<if test=\"keepaliveTime != null\">, keepaliveTime=#{keepaliveTime}</if>" + "<if test=\"keepaliveTime != null\">, keepaliveTime=#{keepaliveTime}</if>" +
"<if test=\"keepaliveIntervalTime != null\">, keepaliveIntervalTime=#{keepaliveIntervalTime}</if>" +
"<if test=\"expires != null\">, expires=#{expires}</if>" + "<if test=\"expires != null\">, expires=#{expires}</if>" +
"WHERE deviceId=#{deviceId}"+ "WHERE deviceId=#{deviceId}"+
" </script>"}) " </script>"})
int update(Device device); int update(Device device);
@Select("SELECT " + @Select(
" <script>" +
"SELECT " +
"deviceId, " + "deviceId, " +
"coalesce(custom_name, name) as name, " + "coalesce(custom_name, name) as name, " +
"password, " + "password, " +
@ -150,8 +155,11 @@ public interface DeviceMapper {
"geoCoordSys," + "geoCoordSys," +
"treeType," + "treeType," +
"online," + "online," +
"(SELECT count(0) FROM device_channel WHERE deviceId=de.deviceId) as channelCount FROM device de") "(SELECT count(0) FROM device_channel WHERE deviceId=de.deviceId) as channelCount FROM device de" +
List<Device> getDevices(); "<if test=\"online != null\"> where online=${online}</if>"+
" </script>"
)
List<Device> getDevices(Boolean online);
@Delete("DELETE FROM device WHERE deviceId=#{deviceId}") @Delete("DELETE FROM device WHERE deviceId=#{deviceId}")
int del(String deviceId); int del(String deviceId);

View File

@ -231,31 +231,31 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
PageHelper.startPage(page, count); PageHelper.startPage(page, count);
List<DeviceChannel> all; List<DeviceChannel> all;
if (catalogUnderDevice != null && catalogUnderDevice) { if (catalogUnderDevice != null && catalogUnderDevice) {
all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online); all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online,null);
// 海康设备的parentId是SIP id // 海康设备的parentId是SIP id
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, sipConfig.getId(), query, hasSubChannel, online); List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, sipConfig.getId(), query, hasSubChannel, online,null);
all.addAll(deviceChannels); all.addAll(deviceChannels);
}else { }else {
all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online); all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online,null);
} }
return new PageInfo<>(all); return new PageInfo<>(all);
} }
@Override @Override
public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit) { public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit,List<String> channelIds) {
return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit); return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit,channelIds);
} }
@Override @Override
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) { public List<DeviceChannel> queryChannelsByDeviceId(String deviceId,Boolean online,List<String> channelIds) {
return deviceChannelMapper.queryChannels(deviceId, null,null, null, null); return deviceChannelMapper.queryChannels(deviceId, null,null, null, online,channelIds);
} }
@Override @Override
public PageInfo<DeviceChannel> querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, int page, int count) { public PageInfo<DeviceChannel> querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, int page, int count) {
PageHelper.startPage(page, count); PageHelper.startPage(page, count);
List<DeviceChannel> all = deviceChannelMapper.queryChannels(deviceId, parentChannelId, query, hasSubChannel, online); List<DeviceChannel> all = deviceChannelMapper.queryChannels(deviceId, parentChannelId, query, hasSubChannel, online,null);
return new PageInfo<>(all); return new PageInfo<>(all);
} }
@ -278,9 +278,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
* @return PageInfo<Device> * @return PageInfo<Device>
*/ */
@Override @Override
public PageInfo<Device> queryVideoDeviceList(int page, int count) { public PageInfo<Device> queryVideoDeviceList(int page, int count,Boolean online) {
PageHelper.startPage(page, count); PageHelper.startPage(page, count);
List<Device> all = deviceMapper.getDevices(); List<Device> all = deviceMapper.getDevices(online);
return new PageInfo<>(all); return new PageInfo<>(all);
} }
@ -290,9 +290,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
* @return List<Device> * @return List<Device>
*/ */
@Override @Override
public List<Device> queryVideoDeviceList() { public List<Device> queryVideoDeviceList(Boolean online) {
List<Device> deviceList = deviceMapper.getDevices(); List<Device> deviceList = deviceMapper.getDevices(online);
return deviceList; return deviceList;
} }

View File

@ -99,7 +99,7 @@ public class DeviceQuery {
@GetMapping("/devices") @GetMapping("/devices")
public PageInfo<Device> devices(int page, int count){ public PageInfo<Device> devices(int page, int count){
return storager.queryVideoDeviceList(page, count); return storager.queryVideoDeviceList(page, count,null);
} }
/** /**

View File

@ -10,8 +10,10 @@ import com.github.pagehelper.PageInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
@ -59,10 +61,10 @@ public class ApiDeviceController {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
List<Device> devices; List<Device> devices;
if (start == null || limit ==null) { if (start == null || limit ==null) {
devices = storager.queryVideoDeviceList(); devices = storager.queryVideoDeviceList(online);
result.put("DeviceCount", devices.size()); result.put("DeviceCount", devices.size());
}else { }else {
PageInfo<Device> deviceList = storager.queryVideoDeviceList(start/limit, limit); PageInfo<Device> deviceList = storager.queryVideoDeviceList(start/limit, limit,online);
result.put("DeviceCount", deviceList.getTotal()); result.put("DeviceCount", deviceList.getTotal());
devices = deviceList.getList(); devices = deviceList.getList();
} }
@ -114,12 +116,17 @@ public class ApiDeviceController {
return result; return result;
} }
List<DeviceChannel> deviceChannels; List<DeviceChannel> deviceChannels;
List<DeviceChannel> allDeviceChannelList = storager.queryChannelsByDeviceId(serial); List<String> channelIds = null;
if (!StringUtils.isEmpty(code)) {
String[] split = code.trim().split(",");
channelIds = Arrays.asList(split);
}
List<DeviceChannel> allDeviceChannelList = storager.queryChannelsByDeviceId(serial,online,channelIds);
if (start == null || limit ==null) { if (start == null || limit ==null) {
deviceChannels = allDeviceChannelList; deviceChannels = allDeviceChannelList;
result.put("ChannelCount", deviceChannels.size()); result.put("ChannelCount", deviceChannels.size());
}else { }else {
deviceChannels = storager.queryChannelsByDeviceIdWithStartAndLimit(serial, null, null, null,start, limit); deviceChannels = storager.queryChannelsByDeviceIdWithStartAndLimit(serial, null, null, online,start, limit,channelIds);
int total = allDeviceChannelList.size(); int total = allDeviceChannelList.size();
result.put("ChannelCount", total); result.put("ChannelCount", total);
} }