| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.asrs.entity.TvDevice; |
| | | import com.zy.asrs.mapper.TvDeviceMapper; |
| | | import com.zy.asrs.service.TvDeviceService; |
| | |
| | | |
| | | @Override |
| | | public String testConnection(Long id) throws Exception { |
| | | TvDevice device = this.selectById(id); |
| | | TvDevice device = this.getById(id); |
| | | if (device == null) { |
| | | throw new RuntimeException("设备不存在"); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public int refreshAllStatus() { |
| | | List<TvDevice> devices = this.selectList(null); |
| | | List<TvDevice> devices = this.list(new QueryWrapper<>()); |
| | | int count = 0; |
| | | for (TvDevice device : devices) { |
| | | try { |
| | |
| | | |
| | | @Override |
| | | public String installApk(Long deviceId, String apkPath) throws Exception { |
| | | TvDevice device = this.selectById(deviceId); |
| | | TvDevice device = this.getById(deviceId); |
| | | if (device == null) { |
| | | throw new RuntimeException("设备不存在"); |
| | | } |
| | |
| | | public List<String> batchInstallApk(List<Long> deviceIds, String apkPath) { |
| | | List<String> results = new ArrayList<>(); |
| | | for (Long deviceId : deviceIds) { |
| | | TvDevice device = this.selectById(deviceId); |
| | | TvDevice device = this.getById(deviceId); |
| | | String deviceName = device != null ? device.getName() : "ID:" + deviceId; |
| | | try { |
| | | String result = installApk(deviceId, apkPath); |
| | |
| | | |
| | | @Override |
| | | public List<TvDevice> getOnlineDevices() { |
| | | return this.selectList(new EntityWrapper<TvDevice>().eq("status", 1)); |
| | | return this.list(new QueryWrapper<TvDevice>().eq("status", 1)); |
| | | } |
| | | |
| | | @Override |
| | | public String launchApp(Long deviceId, String packageName) throws Exception { |
| | | TvDevice device = this.selectById(deviceId); |
| | | TvDevice device = this.getById(deviceId); |
| | | if (device == null) { |
| | | throw new RuntimeException("设备不存在"); |
| | | } |
| | |
| | | public List<String> batchLaunchApp(List<Long> deviceIds, String packageName) { |
| | | List<String> results = new ArrayList<>(); |
| | | for (Long deviceId : deviceIds) { |
| | | TvDevice device = this.selectById(deviceId); |
| | | TvDevice device = this.getById(deviceId); |
| | | String deviceName = device != null ? device.getName() : "ID:" + deviceId; |
| | | try { |
| | | String result = launchApp(deviceId, packageName); |
| | |
| | | |
| | | @Override |
| | | public String captureScreen(Long deviceId) throws Exception { |
| | | TvDevice device = this.selectById(deviceId); |
| | | TvDevice device = this.getById(deviceId); |
| | | if (device == null) { |
| | | throw new RuntimeException("设备不存在"); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public String stopApp(Long deviceId, String packageName) throws Exception { |
| | | TvDevice device = this.selectById(deviceId); |
| | | TvDevice device = this.getById(deviceId); |
| | | if (device == null) { |
| | | throw new RuntimeException("设备不存在"); |
| | | } |
| | |
| | | public List<String> batchRestartApp(List<Long> deviceIds, String packageName) { |
| | | List<String> results = new ArrayList<>(); |
| | | for (Long deviceId : deviceIds) { |
| | | TvDevice device = this.selectById(deviceId); |
| | | TvDevice device = this.getById(deviceId); |
| | | String deviceName = device != null ? device.getName() : "ID:" + deviceId; |
| | | try { |
| | | String result = restartApp(deviceId, packageName); |