diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078TerminalController.java b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078TerminalController.java index 876e08882..ac0a5dcf6 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078TerminalController.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078TerminalController.java @@ -68,6 +68,12 @@ public class JT1078TerminalController { assert phoneNumber != null; service.deleteDeviceByPhoneNumber(phoneNumber); } + @Operation(summary = "查询设备", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "phoneNumber", description = "设备手机号", required = true) + @GetMapping("/query") + public JTDevice getDevice(Integer deviceId){ + return service.getDeviceById(deviceId); + } @Operation(summary = "1078-查询部标通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/dao/JTTerminalMapper.java b/src/main/java/com/genersoft/iot/vmp/jt1078/dao/JTTerminalMapper.java index 22b7c1e49..814395c6c 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/dao/JTTerminalMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/dao/JTTerminalMapper.java @@ -99,4 +99,8 @@ public interface JTTerminalMapper { "WHERE phone_number=#{phoneNumber}"+ " "}) void updateDeviceStatus(@Param("connected") boolean connected, @Param("phoneNumber") String phoneNumber); + + @Select("SELECT * FROM wvp_jt_terminal where id=#{deviceId}") + JTDevice getDeviceById(@Param("deviceId") Integer deviceId); + } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java b/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java index 6d1a209e3..0f7a3d660 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java @@ -125,4 +125,7 @@ public interface Ijt1078Service { void addChannel(JTChannel channel); void deleteChannelById(Integer id); + + JTDevice getDeviceById(Integer deviceId); + } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java index ba5757790..f266b75e0 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java @@ -1033,4 +1033,9 @@ public class jt1078ServiceImpl implements Ijt1078Service { public void deleteChannelById(Integer id) { jtChannelMapper.delete(id); } + + @Override + public JTDevice getDeviceById(Integer deviceId) { + return jtDeviceMapper.getDeviceById(deviceId); + } } diff --git a/web_src/src/components/JTChannelList.vue b/web_src/src/components/JTChannelList.vue index f7fc35702..af3534500 100755 --- a/web_src/src/components/JTChannelList.vue +++ b/web_src/src/components/JTChannelList.vue @@ -57,16 +57,6 @@ - 保存 - - import devicePlayer from './dialog/devicePlayer.vue' import uiHeader from '../layout/UiHeader.vue' -import DeviceService from "./service/DeviceService"; import DeviceTree from "./common/DeviceTree"; import channelEdit from "./dialog/jtChannelEdit.vue"; +import JTDeviceService from "./service/JTDeviceService"; export default { name: 'channelList', @@ -136,7 +126,7 @@ export default { }, data() { return { - deviceService: new DeviceService(), + deviceService: new JTDeviceService(), device: null, deviceId: this.$route.params.deviceId, parentChannelId: this.$route.params.parentChannelId, @@ -240,9 +230,11 @@ export default { let that = this; this.$axios({ method: 'get', - url: '/api/play/start/' + deviceId + '/' + channelId, + url: '/api/jt1078/live/start' + deviceId + '/' + channelId, params: { - isSubStream: this.isSubStream + phoneNumber: deviceId, + channelId: channelId, + type: 0, } }).then(function (res) { console.log(res) diff --git a/web_src/src/components/JTDeviceList.vue b/web_src/src/components/JTDeviceList.vue index 7e0f81356..300d1ce8e 100755 --- a/web_src/src/components/JTDeviceList.vue +++ b/web_src/src/components/JTDeviceList.vue @@ -10,20 +10,21 @@ - + - + - + - + - + - + - + - + - + @@ -83,6 +86,7 @@ import uiHeader from '../layout/UiHeader.vue' import deviceEdit from './dialog/jtDeviceEdit.vue' import syncChannelProgress from './dialog/SyncChannelProgress.vue' +import JTDeviceService from "./service/JTDeviceService"; export default { name: 'app', @@ -93,12 +97,9 @@ export default { }, data() { return { + deviceService: new JTDeviceService(), deviceList: [], //设备列表 - currentDevice: {}, //当前操作设备对象 - - videoComponentList: [], updateLooper: 0, //数据刷新轮训标志 - currentDeviceChannelsLenth: 0, winHeight: window.innerHeight - 200, currentPage: 1, count: 15, @@ -106,19 +107,6 @@ export default { getListLoading: false, }; }, - computed: { - getcurrentDeviceChannels: function () { - let data = this.currentDevice['channelMap']; - let channels = null; - if (data) { - channels = Object.keys(data).map(key => { - return data[key]; - }); - this.currentDeviceChannelsLenth = channels.length; - } - return channels; - } - }, mounted() { this.initData(); this.updateLooper = setInterval(this.initData, 10000); @@ -141,23 +129,16 @@ export default { }, getList: function () { this.getListLoading = true; - this.$axios({ - method: 'get', - url: `/api/jt1078/terminal/list`, - params: { - page: this.currentPage, - count: this.count + this.deviceService.getDeviceList(this.currentPage, this.count, (data) => { + if (data.code === 0) { + this.total = data.data.total; + this.deviceList = data.data.list; + } + this.getListLoading = false; + }, () => { + this.getListLoading = false; } - }).then( (res)=> { - if (res.data.code === 0) { - this.total = res.data.data.total; - this.deviceList = res.data.data.list; - } - this.getListLoading = false; - }).catch( (error)=> { - console.error(error); - this.getListLoading = false; - }); + ) }, deleteDevice: function (row) { this.$confirm("确定删除此设备?", '提示', { @@ -167,17 +148,9 @@ export default { center: true, type: 'warning' }).then(() => { - this.$axios({ - method: 'delete', - url: '/api/jt1078/terminal/delete', - params: { - deviceId: row.deviceId - } - }).then((res) => { + this.deviceService.deleteDevice(row.id, (data) => { this.getList(); - }).catch((error) => { - console.error(error); - }); + }) }).catch(() => { }); diff --git a/web_src/src/components/service/JTDeviceService.js b/web_src/src/components/service/JTDeviceService.js new file mode 100755 index 000000000..f67e3cad5 --- /dev/null +++ b/web_src/src/components/service/JTDeviceService.js @@ -0,0 +1,173 @@ +import axios from 'axios'; + +class JTDeviceService{ + + constructor() { + this.$axios = axios; + } + + getDeviceList(currentPage, count, callback, errorCallback){ + this.$axios({ + method: 'get', + url: `/api/jt1078/terminal/list`, + params: { + page: currentPage, + count: count + } + }).then( (res)=> { + if (typeof (callback) == "function") callback(res.data) + }).catch( (error)=> { + console.error(error); + if (typeof (errorCallback) == "function") errorCallback(error) + }); + } + + getDevice(deviceId, callback, errorCallback){ + this.$axios({ + method: 'get', + url:`/api/jt1078/terminal/query`, + params: { + deviceId: deviceId + }, + }).then((res) => { + if (typeof (callback) == "function") callback(res.data) + }).catch((error) => { + console.log(error); + if (typeof (errorCallback) == "function") errorCallback(error) + }); + } + + deleteDevice(deviceId, callback, errorCallback){ + this.$axios({ + method: 'delete', + url: '/api/jt1078/terminal/delete', + params: { + deviceId: deviceId + } + }).then((res) => { + if (typeof (callback) == "function") callback(res.data) + }).catch((error) => { + if (typeof (errorCallback) == "function") errorCallback(error) + }); + } + + + + getAllChannel(isCatalog, catalogUnderDevice, deviceId, callback, endCallback, errorCallback) { + let currentPage = 1; + let count = 100; + let catalogList = [] + this.getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, endCallback, errorCallback) + } + + getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, endCallback, errorCallback) { + this.getChanel(isCatalog, catalogUnderDevice, deviceId, currentPage, count, (data) => { + if (data.list) { + if (typeof (callback) == "function") callback(data.list) + catalogList = catalogList.concat(data.list); + if (catalogList.length < data.total) { + currentPage ++ + this.getAllChannelIteration(isCatalog,catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback) + }else { + console.log(1) + if (typeof (endCallback) == "function") endCallback(catalogList) + } + } + }, errorCallback) + } + getChanel(isCatalog, catalogUnderDevice, deviceId, currentPage, count, callback, errorCallback) { + this.$axios({ + method: 'get', + url: `/api/device/query/devices/${deviceId}/channels`, + params:{ + page: currentPage, + count: count, + query: "", + online: "", + channelType: isCatalog, + catalogUnderDevice: catalogUnderDevice + } + }).then((res) =>{ + if (typeof (callback) == "function") callback(res.data) + }).catch(errorCallback); + } + + + getAllSubChannel(isCatalog, deviceId, channelId, callback, endCallback, errorCallback) { + let currentPage = 1; + let count = 100; + let catalogList = [] + this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, endCallback, errorCallback) + } + + getAllSubChannelIteration(isCatalog, deviceId,channelId, catalogList, currentPage, count, callback, endCallback, errorCallback) { + this.getSubChannel(isCatalog, deviceId, channelId, currentPage, count, (data) => { + if (data.list) { + if (typeof (callback) == "function") callback(data.list) + catalogList = catalogList.concat(data.list); + if (catalogList.length < data.total) { + currentPage ++ + this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, endCallback, errorCallback) + }else { + if (typeof (endCallback) == "function") endCallback(catalogList) + } + } + }, errorCallback) + } + getSubChannel(isCatalog, deviceId, channelId, currentPage, count, callback, errorCallback) { + this.$axios({ + method: 'get', + url: `/api/device/query/sub_channels/${deviceId}/${channelId}/channels`, + params:{ + page: currentPage, + count: count, + query: "", + online: "", + channelType: isCatalog + } + }).then((res) =>{ + if (typeof (callback) == "function") callback(res.data) + }).catch(errorCallback); + } + + getTree(deviceId, parentId, onlyCatalog, callback, endCallback, errorCallback) { + let currentPage = 1; + let count = 100; + let catalogList = [] + this.getTreeIteration(deviceId, parentId, onlyCatalog, catalogList, currentPage, count, callback, endCallback, errorCallback) + } + + getTreeIteration(deviceId, parentId, onlyCatalog, catalogList, currentPage, count, callback, endCallback, errorCallback) { + this.getTreeInfo(deviceId, parentId, onlyCatalog, currentPage, count, (data) => { + if (data.code === 0 && data.data.list) { + if (typeof (callback) == "function") callback(data.data.list) + catalogList = catalogList.concat(data.data.list); + if (catalogList.length < data.data.total) { + currentPage ++ + this.getTreeIteration(deviceId, parentId, onlyCatalog, catalogList, currentPage, count, callback, endCallback, errorCallback) + }else { + if (typeof (endCallback) == "function") endCallback(catalogList) + } + } + }, errorCallback) + } + getTreeInfo(deviceId, parentId, onlyCatalog, currentPage, count, callback, errorCallback) { + if (onlyCatalog == null || typeof onlyCatalog === "undefined") { + onlyCatalog = false; + } + this.$axios({ + method: 'get', + url: `/api/device/query/tree/${deviceId}`, + params:{ + page: currentPage, + count: count, + parentId: parentId, + onlyCatalog: onlyCatalog + } + }).then((res) =>{ + if (typeof (callback) == "function") callback(res.data) + }).catch(errorCallback); + } +} + +export default JTDeviceService;