From a83ee95e103bba8c1134c134dbecab682a4719ef Mon Sep 17 00:00:00 2001 From: jiang <893224616@qq.com> Date: Wed, 28 Dec 2022 10:58:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=BC=E5=AE=B9=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DeviceChannelServiceImpl.java | 2 +- .../vmp/service/impl/DeviceServiceImpl.java | 6 ++--- .../vmp/storager/IVideoManagerStorage.java | 8 +++---- .../vmp/storager/dao/DeviceChannelMapper.java | 10 ++++++-- .../iot/vmp/storager/dao/DeviceMapper.java | 11 ++++++--- .../impl/VideoManagerStorageImpl.java | 24 +++++++++---------- .../vmanager/gb28181/device/DeviceQuery.java | 2 +- .../vmp/web/gb28181/ApiDeviceController.java | 15 ++++++++---- 8 files changed, 48 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java index 9db2d683..880b6971 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java @@ -99,7 +99,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { HashMap channelsInStore = new HashMap<>(); Device device = deviceMapper.getDeviceByDeviceId(deviceId); if (channels != null && channels.size() > 0) { - List channelList = channelMapper.queryChannels(deviceId, null, null, null, null); + List channelList = channelMapper.queryChannels(deviceId, null, null, null, null,null); if (channelList.size() == 0) { for (DeviceChannel channel : channels) { channel.setDeviceId(deviceId); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index a47e2445..ac329181 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -408,7 +408,7 @@ public class DeviceServiceImpl implements IDeviceService { if (parentId.length() < 14 ) { return null; } - List deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null); + List deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null,null); List> trees = transportChannelsToTree(deviceChannels, parentId); return trees; } @@ -453,7 +453,7 @@ public class DeviceServiceImpl implements IDeviceService { if (parentId.length() < 14 ) { return null; } - List deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null); + List deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null,null); return deviceChannels; } @@ -517,7 +517,7 @@ public class DeviceServiceImpl implements IDeviceService { } }else { if (haveChannel) { - List deviceChannels = deviceChannelMapper.queryChannels(deviceId, null, null, null, null); + List deviceChannels = deviceChannelMapper.queryChannels(deviceId, null, null, null, null,null); if (deviceChannels != null && deviceChannels.size() > 0) { result.addAll(deviceChannels); } 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 ab437467..b4644bfb 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java @@ -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 List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit); + public List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit,List channelIds); /** @@ -68,7 +68,7 @@ public interface IVideoManagerStorage { * @param deviceId 设备ID * @return */ - public List queryChannelsByDeviceId(String deviceId); + public List queryChannelsByDeviceId(String deviceId,Boolean online,List channelIds); public List queryOnlineChannelsByDeviceId(String deviceId); /** @@ -91,14 +91,14 @@ public interface IVideoManagerStorage { * @param count 每页数量 * @return List 设备对象数组 */ - public PageInfo queryVideoDeviceList(int page, int count); + public PageInfo queryVideoDeviceList(int page, int count,Boolean online); /** * 获取多个设备 * * @return List 设备对象数组 */ - public List queryVideoDeviceList(); + public List queryVideoDeviceList(Boolean online); 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 53072b2d..386cce39 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 @@ -76,9 +76,12 @@ public interface DeviceChannelMapper { " AND dc.status=0" + " AND dc.subCount > 0 " + " AND dc.subCount = 0 " + + " AND dc.channelId in " + + "#{item} " + + " " + "ORDER BY dc.channelId " + " "}) - List queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online); + List queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online,List channelIds); @Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND channelId=#{channelId}") DeviceChannel queryChannel(String deviceId, String channelId); @@ -254,11 +257,14 @@ public interface DeviceChannelMapper { " AND dc1.status=0" + " AND dc1.subCount >0" + " AND dc1.subCount=0" + + " AND dc1.channelId in " + + "#{item} " + + " " + "ORDER BY dc1.channelId ASC " + "Limit #{limit} OFFSET #{start}" + " "}) List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String parentChannelId, String query, - Boolean hasSubChannel, Boolean online, int start, int limit); + Boolean hasSubChannel, Boolean online, int start, int limit,List channelIds); @Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND status=1") List queryOnlineChannelsByDeviceId(String deviceId); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java index 0e616921..b9a58176 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java @@ -122,7 +122,9 @@ public interface DeviceMapper { " "}) int update(Device device); - @Select("SELECT " + + @Select( + " " + ) + List getDevices(Boolean online); @Delete("DELETE FROM device WHERE deviceId=#{deviceId}") int del(String deviceId); 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 377b20f2..c773036f 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 @@ -231,31 +231,31 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { PageHelper.startPage(page, count); List all; if (catalogUnderDevice != null && catalogUnderDevice) { - all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online); + all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online,null); // 海康设备的parentId是SIP id - List deviceChannels = deviceChannelMapper.queryChannels(deviceId, sipConfig.getId(), query, hasSubChannel, online); + List deviceChannels = deviceChannelMapper.queryChannels(deviceId, sipConfig.getId(), query, hasSubChannel, online,null); all.addAll(deviceChannels); }else { - all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online); + all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online,null); } return new PageInfo<>(all); } @Override - public List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit) { - return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit); + public List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit,List channelIds) { + return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit,channelIds); } @Override - public List queryChannelsByDeviceId(String deviceId) { - return deviceChannelMapper.queryChannels(deviceId, null,null, null, null); + public List queryChannelsByDeviceId(String deviceId,Boolean online,List channelIds) { + return deviceChannelMapper.queryChannels(deviceId, null,null, null, online,channelIds); } @Override public PageInfo querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, int page, int count) { PageHelper.startPage(page, count); - List all = deviceChannelMapper.queryChannels(deviceId, parentChannelId, query, hasSubChannel, online); + List all = deviceChannelMapper.queryChannels(deviceId, parentChannelId, query, hasSubChannel, online,null); return new PageInfo<>(all); } @@ -278,9 +278,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { * @return PageInfo 分页设备对象数组 */ @Override - public PageInfo queryVideoDeviceList(int page, int count) { + public PageInfo queryVideoDeviceList(int page, int count,Boolean online) { PageHelper.startPage(page, count); - List all = deviceMapper.getDevices(); + List all = deviceMapper.getDevices(online); return new PageInfo<>(all); } @@ -290,9 +290,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { * @return List 设备对象数组 */ @Override - public List queryVideoDeviceList() { + public List queryVideoDeviceList(Boolean online) { - List deviceList = deviceMapper.getDevices(); + List deviceList = deviceMapper.getDevices(online); return deviceList; } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java index d4694c52..11bc6211 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java @@ -99,7 +99,7 @@ public class DeviceQuery { @GetMapping("/devices") public PageInfo devices(int page, int count){ - return storager.queryVideoDeviceList(page, count); + return storager.queryVideoDeviceList(page, count,null); } /** 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 a5458b05..e5f42272 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 @@ -10,8 +10,10 @@ 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.Arrays; import java.util.List; /** @@ -59,10 +61,10 @@ public class ApiDeviceController { JSONObject result = new JSONObject(); List devices; if (start == null || limit ==null) { - devices = storager.queryVideoDeviceList(); + devices = storager.queryVideoDeviceList(online); result.put("DeviceCount", devices.size()); }else { - PageInfo deviceList = storager.queryVideoDeviceList(start/limit, limit); + PageInfo deviceList = storager.queryVideoDeviceList(start/limit, limit,online); result.put("DeviceCount", deviceList.getTotal()); devices = deviceList.getList(); } @@ -114,12 +116,17 @@ public class ApiDeviceController { return result; } List deviceChannels; - List allDeviceChannelList = storager.queryChannelsByDeviceId(serial); + List channelIds = null; + if (!StringUtils.isEmpty(code)) { + String[] split = code.trim().split(","); + channelIds = Arrays.asList(split); + } + List allDeviceChannelList = storager.queryChannelsByDeviceId(serial,online,channelIds); if (start == null || limit ==null) { deviceChannels = allDeviceChannelList; result.put("ChannelCount", deviceChannels.size()); }else { - deviceChannels = storager.queryChannelsByDeviceIdWithStartAndLimit(serial, null, null, null,start, limit); + deviceChannels = storager.queryChannelsByDeviceIdWithStartAndLimit(serial, null, null, online,start, limit,channelIds); int total = allDeviceChannelList.size(); result.put("ChannelCount", total); }