Commit 7d8a0fc351ed7585dc77597652e21aa655247439

Authored by 王鑫
1 parent 368716c9

fix():添加设备列表搜索,通道搜索

src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java
... ... @@ -118,12 +118,14 @@ public interface IDeviceService {
118 118  
119 119 /**
120 120 * 树形查询接口
121   - * @param deviceId 设备ID
122   - * @param parentId 父ID
  121 + *
  122 + * @param deviceId 设备ID
  123 + * @param parentId 父ID
123 124 * @param onlyCatalog 只获取目录
  125 + * @param onload
124 126 * @return
125 127 */
126   - List<BaseTree<DeviceChannel>> queryVideoDeviceTree(String deviceId, String parentId, boolean onlyCatalog);
  128 + List<BaseTree<DeviceChannel>> queryVideoDeviceTree(String deviceId, String parentId, boolean onlyCatalog, String onload);
127 129  
128 130 /**
129 131 * 查询树节点下的通道
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
... ... @@ -43,6 +43,7 @@ import java.text.ParseException;
43 43 import java.time.Instant;
44 44 import java.util.*;
45 45 import java.util.concurrent.TimeUnit;
  46 +import java.util.stream.Collectors;
46 47  
47 48 /**
48 49 * 设备业务(目录订阅)
... ... @@ -427,7 +428,7 @@ public class DeviceServiceImpl implements IDeviceService {
427 428  
428 429  
429 430 @Override
430   - public List<BaseTree<DeviceChannel>> queryVideoDeviceTree(String deviceId, String parentId, boolean onlyCatalog) {
  431 + public List<BaseTree<DeviceChannel>> queryVideoDeviceTree(String deviceId, String parentId, boolean onlyCatalog, String onload) {
431 432 Device device = deviceMapper.getDeviceByDeviceId(deviceId);
432 433 if (device == null) {
433 434 return null;
... ... @@ -435,7 +436,16 @@ public class DeviceServiceImpl implements IDeviceService {
435 436 if (ObjectUtils.isEmpty(parentId) ) {
436 437 parentId = deviceId;
437 438 }
438   - List<DeviceChannel> rootNodes = deviceChannelMapper.getSubChannelsByDeviceId(deviceId, parentId, onlyCatalog);
  439 + List<DeviceChannel> rootNodes = null;
  440 + if ("the".equals(onload)){
  441 + rootNodes = deviceChannelMapper.getSubChannelsByDeviceId(deviceId, parentId, onlyCatalog)
  442 + .stream().filter(ch -> Objects.equals(ch.getChannelId(), "34020000001310000001")
  443 + || Objects.equals(ch.getChannelId(), "34020000001310000002")).collect(Collectors.toList());
  444 + }else {
  445 + rootNodes = deviceChannelMapper.getSubChannelsByDeviceId(deviceId, parentId, onlyCatalog);
  446 + }
  447 +
  448 +
439 449 return transportChannelsToTree(rootNodes, "");
440 450 }
441 451  
... ...
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java
... ... @@ -10,17 +10,17 @@ import com.github.pagehelper.PageInfo;
10 10  
11 11 import java.util.List;
12 12  
13   -/**
  13 +/**
14 14 * @description:视频设备数据存储接口
15 15 * @author: swwheihei
16   - * @date: 2020年5月6日 下午2:14:31
  16 + * @date: 2020年5月6日 下午2:14:31
17 17 */
18 18 @SuppressWarnings("rawtypes")
19 19 public interface IVideoManagerStorage {
20 20  
21   - /**
  21 + /**
22 22 * 根据设备ID判断设备是否存在
23   - *
  23 + *
24 24 * @param deviceId 设备ID
25 25 * @return true:存在 false:不存在
26 26 */
... ... @@ -40,10 +40,10 @@ public interface IVideoManagerStorage {
40 40 * @param channelId 通道ID
41 41 */
42 42 public void stopPlay(String deviceId, String channelId);
43   -
44   - /**
  43 +
  44 + /**
45 45 * 获取设备
46   - *
  46 + *
47 47 * @param deviceId 设备ID
48 48 * @return DShadow 设备对象
49 49 */
... ... @@ -58,7 +58,7 @@ public interface IVideoManagerStorage {
58 58 * @return
59 59 */
60 60 public PageInfo<DeviceChannel> queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count);
61   -
  61 +
62 62 public List<DeviceChannelExtend> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List<String> channelIds, String query, Boolean hasSubChannel, Boolean online, int start, int limit);
63 63  
64 64  
... ... @@ -87,11 +87,20 @@ public interface IVideoManagerStorage {
87 87  
88 88 /**
89 89 * 获取多个设备
90   - * @param page 当前页数
91   - * @param count 每页数量
  90 + *
  91 + * @param page 当前页数
  92 + * @param count 每页数量
  93 + * @param deviceId
  94 + * @return List<Device> 设备对象数组
  95 + */
  96 + public PageInfo<Device> queryVideoDeviceList(int page, int count, Boolean online, String deviceId);/**
  97 + * 获取多个设备
  98 + *
  99 + * @param page 当前页数
  100 + * @param count 每页数量
92 101 * @return List<Device> 设备对象数组
93 102 */
94   - public PageInfo<Device> queryVideoDeviceList(int page, int count,Boolean online);
  103 + public PageInfo<Device> queryVideoDeviceList(int page, int count, Boolean online);
95 104  
96 105 /**
97 106 * 获取多个设备
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
... ... @@ -540,8 +540,8 @@ public interface DeviceChannelMapper {
540 540 "from wvp_device_channel " +
541 541 "where device_id=#{deviceId}" +
542 542 " <if test='parentId != null and parentId != deviceId'> and parent_id = #{parentId} </if>" +
543   - " <if test='parentId == null or parentId == deviceId'> and parent_id is null or parent_id = #{deviceId}</if>" +
544   - " <if test='onlyCatalog == true '> and parental = 1 </if>" +
  543 + " <if test='parentId == null or parentId == deviceId'> and (parent_id is null or parent_id = #{deviceId} ) </if>" +
  544 + " <if test='onlyCatalog == true '> and parental = 1 </if>" +
545 545 " </script>"})
546 546 List<DeviceChannel> getSubChannelsByDeviceId(@Param("deviceId") String deviceId, @Param("parentId") String parentId, @Param("onlyCatalog") boolean onlyCatalog);
547 547  
... ... @@ -550,4 +550,6 @@ public interface DeviceChannelMapper {
550 550 " <if test='channelId != null'> and channel_id = #{channelId} </if>" +
551 551 "</script>")
552 552 void updateChannelStreamIdentification(DeviceChannel channel);
  553 +
  554 +
553 555 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
... ... @@ -170,6 +170,49 @@ public interface DeviceMapper {
170 170 )
171 171 List<Device> getDevices(Boolean onLine);
172 172  
  173 + @Select(
  174 + " <script>" +
  175 + "SELECT " +
  176 + "device_id, " +
  177 + "coalesce(custom_name, name) as name, " +
  178 + "password, " +
  179 + "manufacturer, " +
  180 + "model, " +
  181 + "firmware, " +
  182 + "transport," +
  183 + "stream_mode," +
  184 + "ip,"+
  185 + "sdp_ip,"+
  186 + "local_ip,"+
  187 + "port,"+
  188 + "host_address,"+
  189 + "expires,"+
  190 + "register_time,"+
  191 + "keepalive_time,"+
  192 + "create_time,"+
  193 + "update_time,"+
  194 + "charset,"+
  195 + "subscribe_cycle_for_catalog,"+
  196 + "subscribe_cycle_for_mobile_position,"+
  197 + "mobile_position_submission_interval,"+
  198 + "subscribe_cycle_for_alarm,"+
  199 + "ssrc_check,"+
  200 + "as_message_channel,"+
  201 + "broadcast_push_after_ack,"+
  202 + "geo_coord_sys,"+
  203 + "on_line,"+
  204 + "media_server_id,"+
  205 + "(SELECT count(0) FROM wvp_device_channel WHERE device_id=de.device_id) as channel_count " +
  206 + "FROM wvp_device de" +
  207 + "<where>" +
  208 + " <if test=\"onLine != null\"> AND on_line=${onLine}</if>"+
  209 + " <if test=\"deviceId != null and deviceId != ''\"> AND coalesce(custom_name, name) like CONCAT('%',#{deviceId},'%')</if>" +
  210 + "</where>"+
  211 + " order by on_line desc,create_time desc "+
  212 + " </script>"
  213 + )
  214 + List<Device> getDevicesByDeviceId(@Param("onLine") Boolean onLine, @Param("deviceId") String deviceId);
  215 +
173 216 @Delete("DELETE FROM wvp_device WHERE device_id=#{deviceId}")
174 217 int del(String deviceId);
175 218  
... ...
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
... ... @@ -7,7 +7,6 @@ import com.genersoft.iot.vmp.gb28181.bean.*;
7 7 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
8 8 import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
9 9 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
10   -import com.genersoft.iot.vmp.service.IGbStreamService;
11 10 import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
12 11 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
13 12 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
... ... @@ -445,12 +444,20 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
445 444 /**
446 445 * 获取多个设备
447 446 *
448   - * @param page 当前页数
449   - * @param count 每页数量
  447 + * @param page 当前页数
  448 + * @param count 每页数量
  449 + * @param deviceId
450 450 * @return PageInfo<Device> 分页设备对象数组
451 451 */
452 452 @Override
453   - public PageInfo<Device> queryVideoDeviceList(int page, int count,Boolean online) {
  453 + public PageInfo<Device> queryVideoDeviceList(int page, int count, Boolean online, String deviceId) {
  454 + PageHelper.startPage(page, count);
  455 + List<Device> all = deviceMapper.getDevicesByDeviceId(online,deviceId);
  456 + return new PageInfo<>(all);
  457 + }
  458 +
  459 + @Override
  460 + public PageInfo<Device> queryVideoDeviceList(int page, int count, Boolean online) {
454 461 PageHelper.startPage(page, count);
455 462 List<Device> all = deviceMapper.getDevices(online);
456 463 return new PageInfo<>(all);
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
... ... @@ -112,10 +112,10 @@ public class DeviceQuery {
112 112 @Parameter(name = "online", description = "在线状态")
113 113 @GetMapping("/devices")
114 114 @Options()
115   - public PageInfo<Device> devices(int page, int count,Boolean online) {
  115 + public PageInfo<Device> devices(int page, int count,Boolean online,String deviceId) {
116 116 // if (page == null) page = 0;
117 117 // if (count == null) count = 20;
118   - return storager.queryVideoDeviceList(page, count, online);
  118 + return storager.queryVideoDeviceList(page, count, online, deviceId);
119 119 }
120 120  
121 121 /**
... ... @@ -541,6 +541,7 @@ public class DeviceQuery {
541 541 public ResponseEntity<PageInfo> getTree(@PathVariable String deviceId,
542 542 @RequestParam(required = false) String parentId,
543 543 @RequestParam(required = false) Boolean onlyCatalog,
  544 + @RequestParam(required = false) String online,
544 545 int page, int count) {
545 546  
546 547  
... ... @@ -551,7 +552,7 @@ public class DeviceQuery {
551 552 onlyCatalog = false;
552 553 }
553 554  
554   - List<BaseTree<DeviceChannel>> treeData = deviceService.queryVideoDeviceTree(deviceId, parentId, onlyCatalog);
  555 + List<BaseTree<DeviceChannel>> treeData = deviceService.queryVideoDeviceTree(deviceId, parentId, onlyCatalog, online);
555 556 if (treeData == null || (page - 1) * count > treeData.size()) {
556 557 PageInfo<BaseTree<DeviceChannel>> pageInfo = new PageInfo<>();
557 558 pageInfo.setPageNum(page);
... ...
src/main/resources/application.yml
... ... @@ -2,6 +2,6 @@ spring:
2 2 application:
3 3 name: wvp
4 4 profiles:
5   - active: local
  5 + active: wx-local
6 6 server:
7   - port: 18080
8 7 \ No newline at end of file
  8 + port: 18080
... ...
web_src/config/index.js
... ... @@ -11,14 +11,14 @@ module.exports = {
11 11 assetsPublicPath: "/",
12 12 proxyTable: {
13 13 "/debug": {
14   - target: "http://192.168.20.215:18089",
  14 + target: "http://127.0.0.1:16000",
15 15 changeOrigin: true,
16 16 pathRewrite: {
17 17 "^/debug": "/",
18 18 },
19 19 },
20 20 "/static/snap": {
21   - target: "http://61.169.120.202:18089",
  21 + target: "http://127.0.0.1:16000",
22 22 changeOrigin: true,
23 23 // pathRewrite: {
24 24 // '^/static/snap': '/static/snap'
... ...
web_src/src/components/DeviceList.vue
... ... @@ -10,7 +10,8 @@
10 10 <el-option label="在线" value="true"></el-option>
11 11 <el-option label="离线" value="false"></el-option>
12 12 </el-select>
13   -
  13 + <el-input size="mini" style="width: 8rem; margin-right: 1rem;" placeholder="请输入名称关键字" v-model="deviceId"></el-input>
  14 + <el-button icon="el-icon-search" size="mini" style="margin-right: 1rem;" type="primary" @click="getDeviceList()">搜索</el-button>
14 15 <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="add">添加设备
15 16 </el-button>
16 17 <el-button icon="el-icon-refresh-right" circle size="mini" :loading="getDeviceListLoading"
... ... @@ -114,7 +115,7 @@ export default {
114 115 return {
115 116 deviceList: [], //设备列表
116 117 currentDevice: {}, //当前操作设备对象
117   -
  118 + deviceId: '',
118 119 videoComponentList: [],
119 120 updateLooper: 0, //数据刷新轮训标志
120 121 currentDeviceChannelsLenth: 0,
... ... @@ -167,7 +168,8 @@ export default {
167 168 params: {
168 169 page: this.currentPage,
169 170 count: this.count,
170   - online:this.online
  171 + online:this.online,
  172 + deviceId: this.deviceId
171 173 }
172 174 }).then( (res)=> {
173 175 if (res.data.code === 0) {
... ...
web_src/src/components/common/DeviceTree.vue
... ... @@ -3,8 +3,17 @@
3 3 <el-container>
4 4 <el-header>设备列表</el-header>
5 5 <el-main style="background-color: #ffffff;">
  6 + <el-input v-model="filterText" placeholder="输入关键字进行过滤"
  7 + clearable size="small"
  8 + prefix-icon="el-icon-search" style="margin-bottom: 5px" />
6 9 <div class="device-tree-main-box">
7   - <el-tree ref="gdTree" :props="defaultProps" :load="loadNode" lazy @node-click="handleNodeClick"@node-contextmenu="handleContextMenu" node-key="id" style="min-width: 100%; display:inline-block !important;">
  10 + <el-tree ref="gdTree"
  11 + :props="defaultProps"
  12 + :load="loadNode" lazy
  13 + :filter-node-method="filterNode"
  14 + @node-click="handleNodeClick"
  15 + @node-contextmenu="handleContextMenu"
  16 + node-key="id" style="min-width: 100%; display:inline-block !important;">
8 17 <span class="custom-tree-node" slot-scope="{ node, data }" style="width: 100%">
9 18 <span v-if="node.data.type === 0 && node.data.online" title="在线设备" class="device-online iconfont icon-jiedianleizhukongzhongxin2"></span>
10 19 <span v-if="node.data.type === 0 && !node.data.online " title="离线设备" class="device-offline iconfont icon-jiedianleizhukongzhongxin2"></span>
... ... @@ -37,6 +46,11 @@ import DeviceService from &quot;../service/DeviceService.js&quot;;
37 46  
38 47 export default {
39 48 name: 'DeviceTree',
  49 + watch: {
  50 + filterText(val) {
  51 + this.$refs.gdTree.filter(val);
  52 + }
  53 + },
40 54 data() {
41 55 return {
42 56 deviceService: new DeviceService(),
... ... @@ -44,11 +58,35 @@ export default {
44 58 children: 'children',
45 59 label: 'name',
46 60 isLeaf: 'isLeaf'
47   - }
  61 + },
  62 + filterText: '',
  63 + online: 'the'
48 64 };
49 65 },
50 66 props: ['device', 'onlyCatalog', 'clickEvent', 'contextMenuEvent'],
51 67 methods: {
  68 + /**
  69 + * 模糊查询树
  70 + */
  71 + filterNode(value, data, node) {
  72 + console.log('查询 ====》',value,node)
  73 + if (!value) return true;
  74 + return this.findSearKey(node, value)
  75 + },
  76 + /**
  77 + * 递归搜索父级是否包含关键字
  78 + */
  79 + findSearKey(node, key) {
  80 + if (node.label.toLowerCase().indexOf(key) !== -1 || node.label.toUpperCase().indexOf(key) !== -1) {
  81 + return true;
  82 + } else {
  83 + if (node.parent.parent == null) {
  84 + return false;
  85 + } else {
  86 + return this.findSearKey(node.parent, key);
  87 + }
  88 + }
  89 + },
52 90 handleNodeClick(data,node,element) {
53 91 let deviceNode = this.$refs.gdTree.getNode(data.userData.deviceId)
54 92 if(typeof (this.clickEvent) == "function") {
... ... @@ -104,9 +142,8 @@ export default {
104 142 }
105 143 }else {
106 144 let channelArray = []
107   -
  145 + console.log("online ===> ", this.online)
108 146 this.deviceService.getTree(node.data.userData.deviceId, node.data.id, this.onlyCatalog, catalogData =>{
109   - console.log(catalogData)
110 147 channelArray = channelArray.concat(catalogData)
111 148 this.channelDataHandler(channelArray, resolve)
112 149 },(endCatalogData) => {
... ...
web_src/src/components/live.vue
... ... @@ -149,10 +149,13 @@ export default {
149 149 } else {
150 150 that.$message.error(res.data.msg);
151 151 }
  152 + that.loading = false
152 153 }).catch(function (e) {
  154 + that.loading = false
153 155 }).finally(() => {
154 156 that.loading = false
155 157 });
  158 +
156 159 },
157 160 setPlayUrl(url, idx) {
158 161 this.$set(this.videoUrl, idx, url)
... ...
web_src/src/components/service/DeviceService.js
... ... @@ -134,7 +134,7 @@ class DeviceService{
134 134 }).catch(errorCallback);
135 135 }
136 136  
137   - getTree(deviceId, parentId, onlyCatalog, callback, endCallback, errorCallback) {
  137 + getTree(deviceId, parentId, onlyCatalog, callback, endCallback, errorCallback ) {
138 138 let currentPage = 1;
139 139 let count = 100;
140 140 let catalogList = []
... ... @@ -166,7 +166,8 @@ class DeviceService{
166 166 page: currentPage,
167 167 count: count,
168 168 parentId: parentId,
169   - onlyCatalog: onlyCatalog
  169 + onlyCatalog: onlyCatalog,
  170 + online: 'the'
170 171 }
171 172 }).then((res) =>{
172 173 if (typeof (callback) == "function") callback(res.data)
... ...