Commit f082797d9bf323084ebc6216c84eb00f05da868f
1 parent
b6137471
完成向上级联->选择通道-003
Showing
14 changed files
with
285 additions
and
60 deletions
README.md
| @@ -40,7 +40,7 @@ https://gitee.com/18010473990/wvp-GB28181.git | @@ -40,7 +40,7 @@ https://gitee.com/18010473990/wvp-GB28181.git | ||
| 40 | - [X] WEB添加上级平台 | 40 | - [X] WEB添加上级平台 |
| 41 | - [X] 注册 | 41 | - [X] 注册 |
| 42 | - [X] 心跳保活 | 42 | - [X] 心跳保活 |
| 43 | - - [ ] 通道选择 | 43 | + - [X] 通道选择 |
| 44 | - [ ] 通道推送 | 44 | - [ ] 通道推送 |
| 45 | - [ ] 点播 | 45 | - [ ] 点播 |
| 46 | - [ ] 云台控制 | 46 | - [ ] 云台控制 |
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
| @@ -206,9 +206,9 @@ public interface IVideoManagerStorager { | @@ -206,9 +206,9 @@ public interface IVideoManagerStorager { | ||
| 206 | void outlineForAllParentPlatform(); | 206 | void outlineForAllParentPlatform(); |
| 207 | 207 | ||
| 208 | /** | 208 | /** |
| 209 | - * 查询通道信息, 不区分设备 | 209 | + * 查询通道信息,不区分设备(已关联平台或全部) |
| 210 | */ | 210 | */ |
| 211 | - PageInfo<ChannelReduce> queryChannelListInAll(int page, int count, String query, Boolean online, Boolean channelType, String parentChannelId); | 211 | + PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, Boolean inPlatform); |
| 212 | 212 | ||
| 213 | 213 | ||
| 214 | /** | 214 | /** |
| @@ -218,4 +218,14 @@ public interface IVideoManagerStorager { | @@ -218,4 +218,14 @@ public interface IVideoManagerStorager { | ||
| 218 | * @return | 218 | * @return |
| 219 | */ | 219 | */ |
| 220 | int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces); | 220 | int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces); |
| 221 | + | ||
| 222 | + /** | ||
| 223 | + * 移除上级平台的通道信息 | ||
| 224 | + * @param platformId | ||
| 225 | + * @param channelReduces | ||
| 226 | + * @return | ||
| 227 | + */ | ||
| 228 | + int delChannelForGB(String platformId, List<ChannelReduce> channelReduces); | ||
| 229 | + | ||
| 230 | + | ||
| 221 | } | 231 | } |
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
| @@ -4,6 +4,7 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | @@ -4,6 +4,7 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | ||
| 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 5 | import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce; | 5 | import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce; |
| 6 | import org.apache.ibatis.annotations.*; | 6 | import org.apache.ibatis.annotations.*; |
| 7 | +import org.springframework.stereotype.Repository; | ||
| 7 | 8 | ||
| 8 | import java.util.List; | 9 | import java.util.List; |
| 9 | 10 | ||
| @@ -11,6 +12,7 @@ import java.util.List; | @@ -11,6 +12,7 @@ import java.util.List; | ||
| 11 | * 用于存储设备通道信息 | 12 | * 用于存储设备通道信息 |
| 12 | */ | 13 | */ |
| 13 | @Mapper | 14 | @Mapper |
| 15 | +@Repository | ||
| 14 | public interface DeviceChannelMapper { | 16 | public interface DeviceChannelMapper { |
| 15 | 17 | ||
| 16 | @Insert("INSERT INTO device_channel (channelId, deviceId, name, manufacture, model, owner, civilCode, block, " + | 18 | @Insert("INSERT INTO device_channel (channelId, deviceId, name, manufacture, model, owner, civilCode, block, " + |
| @@ -79,18 +81,22 @@ public interface DeviceChannelMapper { | @@ -79,18 +81,22 @@ public interface DeviceChannelMapper { | ||
| 79 | 81 | ||
| 80 | @Select(value = {" <script>" + | 82 | @Select(value = {" <script>" + |
| 81 | "SELECT * FROM ( "+ | 83 | "SELECT * FROM ( "+ |
| 82 | - " SELECT dc.channelId, dc.deviceId, dc.name, de.manufacturer, de.hostAddress, " + | ||
| 83 | - "(SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount " + | ||
| 84 | - "FROM device_channel dc LEFT JOIN device de ON dc.deviceId = de.deviceId" + | 84 | + " SELECT dc.channelId, dc.deviceId, dc.name, de.manufacturer, de.hostAddress, " + |
| 85 | + "(SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount, " + | ||
| 86 | + "pc.platformId " + | ||
| 87 | + "FROM device_channel dc " + | ||
| 88 | + "LEFT JOIN device de ON dc.deviceId = de.deviceId " + | ||
| 89 | + "LEFT JOIN platform_gb_channel pc on pc.deviceId = dc.deviceId AND pc.channelId = dc.channelId " + | ||
| 90 | + " WHERE 1=1 " + | ||
| 91 | + " <if test=\"query != null\"> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " + | ||
| 92 | + " <if test=\"online == true\" > AND dc.status=1</if> " + | ||
| 93 | + " <if test=\"online == false\" > AND dc.status=0</if> " + | ||
| 94 | + " <if test=\"platformId != null and inPlatform == true\"> AND pc.platformId=#{platformId} </if> " + | ||
| 95 | + ") dcr" + | ||
| 85 | " WHERE 1=1 " + | 96 | " WHERE 1=1 " + |
| 86 | - " <if test=\"query != null\"> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " + | ||
| 87 | - " <if test=\"parentChannelId != null\"> AND dc.parentId=#{parentChannelId} </if> " + | ||
| 88 | - " <if test=\"online == true\" > AND dc.status=1</if>" + | ||
| 89 | - " <if test=\"online == false\" > AND dc.status=0</if>) dcr" + | ||
| 90 | - " WHERE 1=1 " + | ||
| 91 | - " <if test=\"hasSubChannel == true\" > AND subCount >0</if>" + | ||
| 92 | - " <if test=\"hasSubChannel == false\" > AND subCount=0</if>" + | 97 | + " <if test=\"hasSubChannel!= null and hasSubChannel == true\" > AND subCount >0</if> " + |
| 98 | + " <if test=\"hasSubChannel!= null and hasSubChannel == false\" > AND subCount=0</if> " + | ||
| 93 | " </script>"}) | 99 | " </script>"}) |
| 94 | 100 | ||
| 95 | - List<ChannelReduce> queryChannelListInAll(String query, Boolean online, Boolean hasSubChannel, String parentChannelId); | 101 | + List<ChannelReduce> queryChannelListInAll(String query, Boolean online, Boolean hasSubChannel, String platformId, Boolean inPlatform); |
| 96 | } | 102 | } |
src/main/java/com/genersoft/iot/vmp/storager/dao/PatformChannelMapper.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.storager.dao; | ||
| 2 | + | ||
| 3 | +import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce; | ||
| 4 | +import org.apache.ibatis.annotations.Delete; | ||
| 5 | +import org.apache.ibatis.annotations.Insert; | ||
| 6 | +import org.apache.ibatis.annotations.Mapper; | ||
| 7 | +import org.apache.ibatis.annotations.Select; | ||
| 8 | +import org.springframework.stereotype.Repository; | ||
| 9 | + | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +@Mapper | ||
| 13 | +@Repository | ||
| 14 | +public interface PatformChannelMapper { | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 查询列表里已经关联的 | ||
| 18 | + */ | ||
| 19 | + @Select("<script> "+ | ||
| 20 | + "SELECT deviceAndChannelId FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceAndChannelId in" + | ||
| 21 | + "<foreach collection='deviceAndChannelIds' open='(' item='id_' separator=',' close=')'> '${id_}'</foreach>" + | ||
| 22 | + "</script>") | ||
| 23 | + List<String> findChannelRelatedPlatform(String platformId, List<String> deviceAndChannelIds); | ||
| 24 | + | ||
| 25 | + @Insert("<script> "+ | ||
| 26 | + "INSERT INTO platform_gb_channel (channelId, deviceId, platformId, deviceAndChannelId) VALUES" + | ||
| 27 | + "<foreach collection='channelReducesToAdd' item='item' separator=','> ('${item.channelId}','${item.deviceId}', '${platformId}', '${item.deviceId}_${item.channelId}' )</foreach>" + | ||
| 28 | + "</script>") | ||
| 29 | + int addChannels(String platformId, List<ChannelReduce> channelReducesToAdd); | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + @Delete("<script> "+ | ||
| 33 | + "DELETE FROM platform_gb_channel WHERE deviceAndChannelId in" + | ||
| 34 | + "<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > '${item.deviceId}_${item.channelId}'</foreach>" + | ||
| 35 | + "</script>") | ||
| 36 | + int delChannelForGB(String platformId, List<ChannelReduce> channelReducesToDel); | ||
| 37 | +} |
src/main/java/com/genersoft/iot/vmp/storager/dao/patformChannelMapper.java deleted
100644 → 0
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
| @@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | @@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | ||
| 9 | import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; | 9 | import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; |
| 10 | import com.genersoft.iot.vmp.storager.dao.DeviceMapper; | 10 | import com.genersoft.iot.vmp.storager.dao.DeviceMapper; |
| 11 | import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; | 11 | import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; |
| 12 | +import com.genersoft.iot.vmp.storager.dao.PatformChannelMapper; | ||
| 12 | import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce; | 13 | import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce; |
| 13 | import com.github.pagehelper.PageHelper; | 14 | import com.github.pagehelper.PageHelper; |
| 14 | import com.github.pagehelper.PageInfo; | 15 | import com.github.pagehelper.PageInfo; |
| @@ -39,6 +40,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { | @@ -39,6 +40,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { | ||
| 39 | @Autowired | 40 | @Autowired |
| 40 | private IRedisCatchStorage redisCatchStorage; | 41 | private IRedisCatchStorage redisCatchStorage; |
| 41 | 42 | ||
| 43 | + @Autowired | ||
| 44 | + private PatformChannelMapper patformChannelMapper; | ||
| 45 | + | ||
| 42 | 46 | ||
| 43 | 47 | ||
| 44 | 48 | ||
| @@ -275,17 +279,46 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { | @@ -275,17 +279,46 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { | ||
| 275 | 279 | ||
| 276 | 280 | ||
| 277 | @Override | 281 | @Override |
| 278 | - public PageInfo<ChannelReduce> queryChannelListInAll(int page, int count, String query, Boolean online, | ||
| 279 | - Boolean channelType, String parentChannelId) { | 282 | + public PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, |
| 283 | + Boolean channelType, String platformId, Boolean inPlatform) { | ||
| 280 | PageHelper.startPage(page, count); | 284 | PageHelper.startPage(page, count); |
| 281 | - List<ChannelReduce> all = deviceChannelMapper.queryChannelListInAll(query, online, channelType, parentChannelId); | 285 | + List<ChannelReduce> all = deviceChannelMapper.queryChannelListInAll(query, online, channelType, platformId, inPlatform); |
| 282 | return new PageInfo<>(all); | 286 | return new PageInfo<>(all); |
| 283 | } | 287 | } |
| 284 | 288 | ||
| 285 | 289 | ||
| 286 | - @Transactional | ||
| 287 | @Override | 290 | @Override |
| 288 | public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces) { | 291 | public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces) { |
| 289 | - return 0; | 292 | + |
| 293 | + Map<String, ChannelReduce> deviceAndChannels = new HashMap<>(); | ||
| 294 | + for (ChannelReduce channelReduce : channelReduces) { | ||
| 295 | + deviceAndChannels.put(channelReduce.getDeviceId() + "_" + channelReduce.getChannelId(), channelReduce); | ||
| 296 | + } | ||
| 297 | + List<String> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet()); | ||
| 298 | + // 查询当前已经存在的 | ||
| 299 | + List<String> relatedPlatformchannels = patformChannelMapper.findChannelRelatedPlatform(platformId, deviceAndChannelList); | ||
| 300 | + if (relatedPlatformchannels != null) { | ||
| 301 | + deviceAndChannelList.removeAll(relatedPlatformchannels); | ||
| 302 | + } | ||
| 303 | + for (String relatedPlatformchannel : relatedPlatformchannels) { | ||
| 304 | + deviceAndChannels.remove(relatedPlatformchannel); | ||
| 305 | + } | ||
| 306 | + List<ChannelReduce> channelReducesToAdd = new ArrayList<>(deviceAndChannels.values()); | ||
| 307 | + // 对剩下的数据进行存储 | ||
| 308 | + int result = 0; | ||
| 309 | + if (channelReducesToAdd.size() > 0) { | ||
| 310 | + result = patformChannelMapper.addChannels(platformId, channelReducesToAdd); | ||
| 311 | + } | ||
| 312 | + | ||
| 313 | + return result; | ||
| 314 | + } | ||
| 315 | + | ||
| 316 | + | ||
| 317 | + @Override | ||
| 318 | + public int delChannelForGB(String platformId, List<ChannelReduce> channelReduces) { | ||
| 319 | + | ||
| 320 | + int result = patformChannelMapper.delChannelForGB(platformId, channelReduces); | ||
| 321 | + | ||
| 322 | + return result; | ||
| 290 | } | 323 | } |
| 291 | } | 324 | } |
src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java
| @@ -151,15 +151,21 @@ public class PlatformController { | @@ -151,15 +151,21 @@ public class PlatformController { | ||
| 151 | @RequestMapping("/platforms/channelList") | 151 | @RequestMapping("/platforms/channelList") |
| 152 | @ResponseBody | 152 | @ResponseBody |
| 153 | public PageInfo<ChannelReduce> channelList(int page, int count, | 153 | public PageInfo<ChannelReduce> channelList(int page, int count, |
| 154 | + @RequestParam(required = false) String platformId, | ||
| 154 | @RequestParam(required = false) String query, | 155 | @RequestParam(required = false) String query, |
| 155 | @RequestParam(required = false) Boolean online, | 156 | @RequestParam(required = false) Boolean online, |
| 157 | + @RequestParam(required = false) Boolean choosed, | ||
| 156 | @RequestParam(required = false) Boolean channelType){ | 158 | @RequestParam(required = false) Boolean channelType){ |
| 157 | 159 | ||
| 158 | if (logger.isDebugEnabled()) { | 160 | if (logger.isDebugEnabled()) { |
| 159 | logger.debug("查询所有所有通道API调用"); | 161 | logger.debug("查询所有所有通道API调用"); |
| 160 | } | 162 | } |
| 161 | - | ||
| 162 | - PageInfo<ChannelReduce> channelReduces = storager.queryChannelListInAll(page, count, query, online, channelType, null); | 163 | + PageInfo<ChannelReduce> channelReduces = null; |
| 164 | + if (platformId != null ) { | ||
| 165 | + channelReduces = storager.queryAllChannelList(page, count, query, online, channelType, platformId, choosed); | ||
| 166 | + }else { | ||
| 167 | + channelReduces = storager.queryAllChannelList(page, count, query, online, channelType, null, false); | ||
| 168 | + } | ||
| 163 | 169 | ||
| 164 | return channelReduces; | 170 | return channelReduces; |
| 165 | } | 171 | } |
| @@ -177,5 +183,17 @@ public class PlatformController { | @@ -177,5 +183,17 @@ public class PlatformController { | ||
| 177 | return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK); | 183 | return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK); |
| 178 | } | 184 | } |
| 179 | 185 | ||
| 186 | + @RequestMapping("/platforms/delChannelForGB") | ||
| 187 | + @ResponseBody | ||
| 188 | + public ResponseEntity<String> delChannelForGB(@RequestBody UpdateChannelParam param){ | ||
| 189 | + | ||
| 190 | + if (logger.isDebugEnabled()) { | ||
| 191 | + logger.debug("给上级平台添加国标通道API调用"); | ||
| 192 | + } | ||
| 193 | + int result = storager.delChannelForGB(param.getPlatformId(), param.getChannelReduces()); | ||
| 194 | + | ||
| 195 | + return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK); | ||
| 196 | + } | ||
| 197 | + | ||
| 180 | 198 | ||
| 181 | } | 199 | } |
src/main/java/com/genersoft/iot/vmp/vmanager/platform/bean/ChannelReduce.java
| @@ -35,6 +35,11 @@ public class ChannelReduce { | @@ -35,6 +35,11 @@ public class ChannelReduce { | ||
| 35 | */ | 35 | */ |
| 36 | private int subCount; | 36 | private int subCount; |
| 37 | 37 | ||
| 38 | + /** | ||
| 39 | + * 平台Id | ||
| 40 | + */ | ||
| 41 | + private String platformId; | ||
| 42 | + | ||
| 38 | 43 | ||
| 39 | public String getChannelId() { | 44 | public String getChannelId() { |
| 40 | return channelId; | 45 | return channelId; |
| @@ -75,4 +80,20 @@ public class ChannelReduce { | @@ -75,4 +80,20 @@ public class ChannelReduce { | ||
| 75 | public void setHostAddress(String hostAddress) { | 80 | public void setHostAddress(String hostAddress) { |
| 76 | this.hostAddress = hostAddress; | 81 | this.hostAddress = hostAddress; |
| 77 | } | 82 | } |
| 83 | + | ||
| 84 | + public int getSubCount() { | ||
| 85 | + return subCount; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + public void setSubCount(int subCount) { | ||
| 89 | + this.subCount = subCount; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + public String getPlatformId() { | ||
| 93 | + return platformId; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public void setPlatformId(String platformId) { | ||
| 97 | + this.platformId = platformId; | ||
| 98 | + } | ||
| 78 | } | 99 | } |
src/main/resources/application.yml
src/main/resources/wvp.sqlite
No preview for this file type
web_src/src/components/ParentPlatformList.vue
| @@ -89,9 +89,9 @@ export default { | @@ -89,9 +89,9 @@ export default { | ||
| 89 | }; | 89 | }; |
| 90 | }, | 90 | }, |
| 91 | computed: { | 91 | computed: { |
| 92 | - | 92 | + |
| 93 | getcurrentDeviceChannels: function() { | 93 | getcurrentDeviceChannels: function() { |
| 94 | - | 94 | + |
| 95 | } | 95 | } |
| 96 | }, | 96 | }, |
| 97 | mounted() { | 97 | mounted() { |
| @@ -155,7 +155,7 @@ export default { | @@ -155,7 +155,7 @@ export default { | ||
| 155 | getPlatformList: function() { | 155 | getPlatformList: function() { |
| 156 | let that = this; | 156 | let that = this; |
| 157 | 157 | ||
| 158 | - this.$axios.get(`/api/platforms/${that.count}/${that.currentPage - 1}`) | 158 | + this.$axios.get(`/api/platforms/${that.count}/${that.currentPage}`) |
| 159 | .then(function (res) { | 159 | .then(function (res) { |
| 160 | that.total = res.data.total; | 160 | that.total = res.data.total; |
| 161 | that.platformList = res.data.list; | 161 | that.platformList = res.data.list; |
web_src/src/components/channelList.vue
| @@ -110,7 +110,7 @@ export default { | @@ -110,7 +110,7 @@ export default { | ||
| 110 | if (this.autoList) { | 110 | if (this.autoList) { |
| 111 | this.updateLooper = setInterval(this.initData, 5000); | 111 | this.updateLooper = setInterval(this.initData, 5000); |
| 112 | } | 112 | } |
| 113 | - | 113 | + |
| 114 | }, | 114 | }, |
| 115 | destroyed() { | 115 | destroyed() { |
| 116 | this.$destroy('videojs'); | 116 | this.$destroy('videojs'); |
web_src/src/components/gb28181/chooseChannel.vue
| @@ -4,17 +4,13 @@ | @@ -4,17 +4,13 @@ | ||
| 4 | <el-dialog title="选择通道" top="2rem" width="70%" :close-on-click-modal="false" :visible.sync="showDialog" :destroy-on-close="true" @close="close()"> | 4 | <el-dialog title="选择通道" top="2rem" width="70%" :close-on-click-modal="false" :visible.sync="showDialog" :destroy-on-close="true" @close="close()"> |
| 5 | <el-tabs v-model="tabActiveName" > | 5 | <el-tabs v-model="tabActiveName" > |
| 6 | <el-tab-pane label="国标通道" name="gbChannel"> | 6 | <el-tab-pane label="国标通道" name="gbChannel"> |
| 7 | - | ||
| 8 | <el-container> | 7 | <el-container> |
| 9 | <el-main style="background-color: #FFF;"> | 8 | <el-main style="background-color: #FFF;"> |
| 10 | - <chooseChannelForGb :chooseChanage=chooseChanage ></chooseChannelForGb> | 9 | + <chooseChannelForGb :platformId=platformId ></chooseChannelForGb> |
| 11 | </el-main> | 10 | </el-main> |
| 12 | - <el-footer> | ||
| 13 | - <el-button size="mini" type="primary" style="float: right" @click="save()">保存</el-button> | ||
| 14 | - </el-footer> | ||
| 15 | </el-container> | 11 | </el-container> |
| 16 | - | ||
| 17 | - | 12 | + |
| 13 | + | ||
| 18 | </el-tab-pane> | 14 | </el-tab-pane> |
| 19 | <el-tab-pane label="直播流通道" name="streamchannel"> | 15 | <el-tab-pane label="直播流通道" name="streamchannel"> |
| 20 | <!-- TODO --> | 16 | <!-- TODO --> |
| @@ -41,7 +37,6 @@ export default { | @@ -41,7 +37,6 @@ export default { | ||
| 41 | // }; | 37 | // }; |
| 42 | // } | 38 | // } |
| 43 | }, | 39 | }, |
| 44 | - created() {}, | ||
| 45 | data() { | 40 | data() { |
| 46 | return { | 41 | return { |
| 47 | isLoging: false, | 42 | isLoging: false, |
| @@ -49,12 +44,11 @@ export default { | @@ -49,12 +44,11 @@ export default { | ||
| 49 | platformId: "", | 44 | platformId: "", |
| 50 | isLoging: false, | 45 | isLoging: false, |
| 51 | showDialog: false, | 46 | showDialog: false, |
| 52 | - chooseData: [] | ||
| 53 | - | 47 | + chooseData: {} |
| 48 | + | ||
| 54 | }; | 49 | }; |
| 55 | }, | 50 | }, |
| 56 | methods: { | 51 | methods: { |
| 57 | - | ||
| 58 | openDialog: function (platformId, closeCallback) { | 52 | openDialog: function (platformId, closeCallback) { |
| 59 | console.log(platformId) | 53 | console.log(platformId) |
| 60 | this.platformId = platformId | 54 | this.platformId = platformId |
| @@ -88,10 +82,6 @@ export default { | @@ -88,10 +82,6 @@ export default { | ||
| 88 | }).catch(function (error) { | 82 | }).catch(function (error) { |
| 89 | console.log(error); | 83 | console.log(error); |
| 90 | }); | 84 | }); |
| 91 | - }, | ||
| 92 | - chooseChanage: function(val) { | ||
| 93 | - console.log(val) | ||
| 94 | - this.chooseData = val; | ||
| 95 | } | 85 | } |
| 96 | } | 86 | } |
| 97 | }; | 87 | }; |
web_src/src/components/gb28181/chooseChannelForGb.vue
| @@ -3,19 +3,28 @@ | @@ -3,19 +3,28 @@ | ||
| 3 | <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;"> | 3 | <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;"> |
| 4 | 搜索: <el-input @input="search" style="margin-right: 1rem; width: auto;" size="mini" placeholder="关键字" prefix-icon="el-icon-search" v-model="searchSrt" clearable> </el-input> | 4 | 搜索: <el-input @input="search" style="margin-right: 1rem; width: auto;" size="mini" placeholder="关键字" prefix-icon="el-icon-search" v-model="searchSrt" clearable> </el-input> |
| 5 | 5 | ||
| 6 | - 通道类型: <el-select size="mini" @change="search" style="margin-right: 1rem;" v-model="channelType" placeholder="请选择" default-first-option> | 6 | + 通道类型: <el-select size="mini" @change="search" style="margin-right: 1rem; width:6rem" v-model="channelType" placeholder="请选择" default-first-option> |
| 7 | <el-option label="全部" value=""></el-option> | 7 | <el-option label="全部" value=""></el-option> |
| 8 | <el-option label="设备" value="false"></el-option> | 8 | <el-option label="设备" value="false"></el-option> |
| 9 | <el-option label="子目录" value="true"></el-option> | 9 | <el-option label="子目录" value="true"></el-option> |
| 10 | </el-select> | 10 | </el-select> |
| 11 | - 在线状态: <el-select size="mini" style="margin-right: 1rem;" @change="search" v-model="online" placeholder="请选择" default-first-option> | 11 | + |
| 12 | + 选择状态: <el-select size="mini" style="margin-right: 1rem; width:6rem" v-model="choosed" @change="search" placeholder="请选择" default-first-option> | ||
| 13 | + <el-option label="全部" value=""></el-option> | ||
| 14 | + <el-option label="已选择" value="true"></el-option> | ||
| 15 | + <el-option label="未选择" value="false"></el-option> | ||
| 16 | + </el-select> | ||
| 17 | + | ||
| 18 | + 在线状态: <el-select size="mini" style="margin-right: 1rem; width:6rem" @change="search" v-model="online" placeholder="请选择" default-first-option> | ||
| 12 | <el-option label="全部" value=""></el-option> | 19 | <el-option label="全部" value=""></el-option> |
| 13 | <el-option label="在线" value="true"></el-option> | 20 | <el-option label="在线" value="true"></el-option> |
| 14 | <el-option label="离线" value="false"></el-option> | 21 | <el-option label="离线" value="false"></el-option> |
| 15 | </el-select> | 22 | </el-select> |
| 23 | + | ||
| 24 | + <el-checkbox @change="shareAllCheckedChanage">全部共享</el-checkbox> | ||
| 16 | </div> | 25 | </div> |
| 17 | - <el-table ref="gbChannelsTable" :data="gbChannels" border style="width: 100%" @selection-change="chooseChanage" > | ||
| 18 | - <el-table-column type="selection" width="55" align="center" fixed> </el-table-column> | 26 | + <el-table ref="gbChannelsTable" :data="gbChannels" border style="width: 100%" @selection-change="checkedChanage" > |
| 27 | + <el-table-column type="selection" width="55" align="center" fixed > </el-table-column> | ||
| 19 | <el-table-column prop="channelId" label="通道编号" width="210"> | 28 | <el-table-column prop="channelId" label="通道编号" width="210"> |
| 20 | </el-table-column> | 29 | </el-table-column> |
| 21 | <el-table-column prop="name" label="通道名称"> | 30 | <el-table-column prop="name" label="通道名称"> |
| @@ -50,22 +59,32 @@ export default { | @@ -50,22 +59,32 @@ export default { | ||
| 50 | // }; | 59 | // }; |
| 51 | // } | 60 | // } |
| 52 | }, | 61 | }, |
| 53 | - props: ['chooseChanage'], | 62 | + props: ['platformId'], |
| 54 | created() { | 63 | created() { |
| 55 | this.initData(); | 64 | this.initData(); |
| 56 | }, | 65 | }, |
| 57 | data() { | 66 | data() { |
| 58 | return { | 67 | return { |
| 59 | gbChannels: [], | 68 | gbChannels: [], |
| 69 | + gbChoosechannel:{}, | ||
| 60 | searchSrt: "", | 70 | searchSrt: "", |
| 61 | channelType: "", | 71 | channelType: "", |
| 62 | online: "", | 72 | online: "", |
| 63 | - currentPage: parseInt(this.$route.params.page), | ||
| 64 | - count: parseInt(this.$route.params.count), | ||
| 65 | - total: 0 | ||
| 66 | - | 73 | + choosed: "", |
| 74 | + currentPage: 0, | ||
| 75 | + count: 15, | ||
| 76 | + total: 0, | ||
| 77 | + eventEnanle: false | ||
| 78 | + | ||
| 67 | }; | 79 | }; |
| 68 | }, | 80 | }, |
| 81 | + watch:{ | ||
| 82 | + platformId(newData, oldData){ | ||
| 83 | + console.log(newData) | ||
| 84 | + this.initData() | ||
| 85 | + | ||
| 86 | + }, | ||
| 87 | + }, | ||
| 69 | methods: { | 88 | methods: { |
| 70 | initData: function() { | 89 | initData: function() { |
| 71 | this.getChannelList(); | 90 | this.getChannelList(); |
| @@ -75,30 +94,128 @@ export default { | @@ -75,30 +94,128 @@ export default { | ||
| 75 | this.initData(); | 94 | this.initData(); |
| 76 | }, | 95 | }, |
| 77 | handleSizeChange: function (val) { | 96 | handleSizeChange: function (val) { |
| 78 | - this.count = val; | 97 | + this.count = val; |
| 98 | + console.log(val) | ||
| 79 | this.initData(); | 99 | this.initData(); |
| 80 | 100 | ||
| 81 | }, | 101 | }, |
| 102 | + rowcheckedChanage: function (val, row) { | ||
| 103 | + console.log(val) | ||
| 104 | + console.log(row) | ||
| 105 | + }, | ||
| 106 | + checkedChanage: function (val) { | ||
| 107 | + var that = this; | ||
| 108 | + if (!that.eventEnanle) { | ||
| 109 | + return; | ||
| 110 | + } | ||
| 111 | + var tabelData = JSON.parse(JSON.stringify(this.$refs.gbChannelsTable.data)); | ||
| 112 | + console.log("checkedChanage") | ||
| 113 | + console.log(val) | ||
| 114 | + | ||
| 115 | + var newData = {}; | ||
| 116 | + var addData = []; | ||
| 117 | + var delData = []; | ||
| 118 | + if (val.length > 0) { | ||
| 119 | + for (let i = 0; i < val.length; i++) { | ||
| 120 | + const element = val[i]; | ||
| 121 | + var key = element.deviceId + "_" + element.channelId; | ||
| 122 | + newData[key] = element; | ||
| 123 | + if (!!!that.gbChoosechannel[key]){ | ||
| 124 | + addData.push(element) | ||
| 125 | + }else{ | ||
| 126 | + delete that.gbChoosechannel[key] | ||
| 127 | + } | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + var oldKeys = Object.keys(that.gbChoosechannel); | ||
| 131 | + if (oldKeys.length > 0) { | ||
| 132 | + for (let i = 0; i < oldKeys.length; i++) { | ||
| 133 | + const key = oldKeys[i]; | ||
| 134 | + delData.push(that.gbChoosechannel[key]) | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + }else{ | ||
| 139 | + var oldKeys = Object.keys(that.gbChoosechannel); | ||
| 140 | + if (oldKeys.length > 0) { | ||
| 141 | + for (let i = 0; i < oldKeys.length; i++) { | ||
| 142 | + const key = oldKeys[i]; | ||
| 143 | + delData.push(that.gbChoosechannel[key]) | ||
| 144 | + } | ||
| 145 | + } | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + that.gbChoosechannel = newData; | ||
| 149 | + if (Object.keys(addData).length >0) { | ||
| 150 | + that.$axios({ | ||
| 151 | + method:"post", | ||
| 152 | + url:"/api/platforms/updateChannelForGB", | ||
| 153 | + data:{ | ||
| 154 | + platformId: that.platformId, | ||
| 155 | + channelReduces: addData | ||
| 156 | + } | ||
| 157 | + }).then((res)=>{ | ||
| 158 | + console.log("保存成功") | ||
| 159 | + }).catch(function (error) { | ||
| 160 | + console.log(error); | ||
| 161 | + }); | ||
| 162 | + } | ||
| 163 | + if (Object.keys(delData).length >0) { | ||
| 164 | + that.$axios({ | ||
| 165 | + method:"post", | ||
| 166 | + url:"/api/platforms/delChannelForGB", | ||
| 167 | + data:{ | ||
| 168 | + platformId: that.platformId, | ||
| 169 | + channelReduces: delData | ||
| 170 | + } | ||
| 171 | + }).then((res)=>{ | ||
| 172 | + console.log("移除成功") | ||
| 173 | + }).catch(function (error) { | ||
| 174 | + console.log(error); | ||
| 175 | + }); | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + }, | ||
| 179 | + shareAllCheckedChanage: function (val) { | ||
| 180 | + this.chooseChanage(null, val) | ||
| 181 | + }, | ||
| 82 | getChannelList: function () { | 182 | getChannelList: function () { |
| 83 | let that = this; | 183 | let that = this; |
| 84 | 184 | ||
| 85 | this.$axios.get(`/api/platforms/channelList`, { | 185 | this.$axios.get(`/api/platforms/channelList`, { |
| 86 | params: { | 186 | params: { |
| 87 | - page: that.currentPage - 1, | 187 | + page: that.currentPage, |
| 88 | count: that.count, | 188 | count: that.count, |
| 89 | query: that.searchSrt, | 189 | query: that.searchSrt, |
| 90 | online: that.online, | 190 | online: that.online, |
| 191 | + choosed: that.choosed, | ||
| 192 | + platformId: that.platformId, | ||
| 91 | channelType: that.channelType | 193 | channelType: that.channelType |
| 92 | } | 194 | } |
| 93 | }) | 195 | }) |
| 94 | .then(function (res) { | 196 | .then(function (res) { |
| 95 | - console.log(res); | ||
| 96 | that.total = res.data.total; | 197 | that.total = res.data.total; |
| 97 | that.gbChannels = res.data.list; | 198 | that.gbChannels = res.data.list; |
| 199 | + that.gbChoosechannel = {}; | ||
| 98 | // 防止出现表格错位 | 200 | // 防止出现表格错位 |
| 99 | that.$nextTick(() => { | 201 | that.$nextTick(() => { |
| 100 | that.$refs.gbChannelsTable.doLayout(); | 202 | that.$refs.gbChannelsTable.doLayout(); |
| 203 | + // 默认选中 | ||
| 204 | + var chooseGBS = []; | ||
| 205 | + for (let i = 0; i < res.data.list.length; i++) { | ||
| 206 | + const row = res.data.list[i]; | ||
| 207 | + console.log(row.platformId) | ||
| 208 | + if (row.platformId == that.platformId) { | ||
| 209 | + that.$refs.gbChannelsTable.toggleRowSelection(row, true); | ||
| 210 | + chooseGBS.push(row) | ||
| 211 | + that.gbChoosechannel[row.deviceId+ "_" + row.channelId] = row; | ||
| 212 | + | ||
| 213 | + } | ||
| 214 | + } | ||
| 215 | + that.eventEnanle = true; | ||
| 216 | + // that.checkedChanage(chooseGBS) | ||
| 101 | }) | 217 | }) |
| 218 | + console.log(that.gbChoosechannel) | ||
| 102 | }) | 219 | }) |
| 103 | .catch(function (error) { | 220 | .catch(function (error) { |
| 104 | console.log(error); | 221 | console.log(error); |