| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | |
| | | @RequestMapping(value = "/tvDevice/{id}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok(tvDeviceService.selectById(id)); |
| | | return R.ok(tvDeviceService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam Map<String, Object> param) { |
| | | excludeTrash(param); |
| | | EntityWrapper<TvDevice> wrapper = new EntityWrapper<>(); |
| | | QueryWrapper<TvDevice> wrapper = new QueryWrapper<>(); |
| | | |
| | | for (Map.Entry<String, Object> entry : param.entrySet()) { |
| | | String key = entry.getKey(); |
| | |
| | | } |
| | | } |
| | | |
| | | wrapper.orderBy("id", false); |
| | | return R.ok(tvDeviceService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | wrapper.orderBy(true, false, "id"); |
| | | return R.ok(tvDeviceService.page(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @RequestMapping(value = "/tvDevice/all/auth") |
| | | @ManagerAuth |
| | | public R listAll() { |
| | | EntityWrapper<TvDevice> wrapper = new EntityWrapper<>(); |
| | | wrapper.orderBy("name", true); |
| | | return R.ok(tvDeviceService.selectList(wrapper)); |
| | | QueryWrapper<TvDevice> wrapper = new QueryWrapper<>(); |
| | | wrapper.orderBy(true, true, "name"); |
| | | return R.ok(tvDeviceService.list(wrapper)); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | // 检查IP是否已存在 |
| | | EntityWrapper<TvDevice> wrapper = new EntityWrapper<>(); |
| | | QueryWrapper<TvDevice> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("ip", device.getIp()); |
| | | if (tvDeviceService.selectCount(wrapper) > 0) { |
| | | if (tvDeviceService.count(wrapper) > 0) { |
| | | return R.error("该IP已存在"); |
| | | } |
| | | |
| | |
| | | device.setStatus((short) 0); |
| | | device.setCreateTime(new Date()); |
| | | device.setUpdateTime(new Date()); |
| | | tvDeviceService.insert(device); |
| | | tvDeviceService.save(device); |
| | | return R.ok(device); |
| | | } |
| | | |
| | |
| | | |
| | | // 检查IP是否已被其他设备使用 |
| | | if (!Cools.isEmpty(device.getIp())) { |
| | | EntityWrapper<TvDevice> wrapper = new EntityWrapper<>(); |
| | | QueryWrapper<TvDevice> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("ip", device.getIp()).ne("id", device.getId()); |
| | | if (tvDeviceService.selectCount(wrapper) > 0) { |
| | | if (tvDeviceService.count(wrapper) > 0) { |
| | | return R.error("该IP已被其他设备使用"); |
| | | } |
| | | } |
| | |
| | | if (ids == null || ids.length == 0) { |
| | | return R.error(); |
| | | } |
| | | tvDeviceService.deleteBatchIds(Arrays.asList(ids)); |
| | | tvDeviceService.removeByIds(Arrays.asList(ids)); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | String result = tvDeviceService.testConnection(id); |
| | | Map<String, Object> data = new HashMap<>(); |
| | | data.put("result", result); |
| | | data.put("device", tvDeviceService.selectById(id)); |
| | | data.put("device", tvDeviceService.getById(id)); |
| | | return R.ok(data); |
| | | } catch (Exception e) { |
| | | return R.error("连接失败: " + e.getMessage()); |
| | |
| | | return R.error("请选择安装设备"); |
| | | } |
| | | |
| | | ApkBuildTask task = apkBuildTaskService.selectById(taskId); |
| | | ApkBuildTask task = apkBuildTaskService.getById(taskId); |
| | | if (task == null) { |
| | | return R.error("打包任务不存在"); |
| | | } |
| | |
| | | String result = tvDeviceService.launchApp(id, packageName); |
| | | Map<String, Object> data = new HashMap<>(); |
| | | data.put("result", result); |
| | | data.put("device", tvDeviceService.selectById(id)); |
| | | data.put("device", tvDeviceService.getById(id)); |
| | | return R.ok(data); |
| | | } catch (Exception e) { |
| | | return R.error("启动失败: " + e.getMessage()); |
| | |
| | | String base64Image = tvDeviceService.captureScreen(id); |
| | | Map<String, Object> data = new HashMap<>(); |
| | | data.put("image", base64Image); |
| | | data.put("device", tvDeviceService.selectById(id)); |
| | | data.put("device", tvDeviceService.getById(id)); |
| | | return R.ok(data); |
| | | } catch (Exception e) { |
| | | return R.error("截图失败: " + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 重启设备上的应用 |
| | | */ |
| | | @RequestMapping(value = "/tvDevice/restartApp/{id}/auth", method = RequestMethod.POST) |
| | | @ManagerAuth |
| | | public R restartApp(@PathVariable("id") Long id, @RequestBody(required = false) JSONObject param) { |
| | | try { |
| | | String packageName = param != null ? param.getString("packageName") : null; |
| | | String result = tvDeviceService.restartApp(id, packageName); |
| | | Map<String, Object> data = new HashMap<>(); |
| | | data.put("result", result); |
| | | data.put("device", tvDeviceService.getById(id)); |
| | | return R.ok(data); |
| | | } catch (Exception e) { |
| | | return R.error("重启失败: " + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 批量重启设备上的应用 |
| | | */ |
| | | @RequestMapping(value = "/tvDevice/batchRestartApp/auth", method = RequestMethod.POST) |
| | | @ManagerAuth |
| | | public R batchRestartApp(@RequestBody JSONObject param) { |
| | | try { |
| | | List<Long> deviceIds = param.getJSONArray("deviceIds").toJavaList(Long.class); |
| | | String packageName = param.getString("packageName"); |
| | | |
| | | if (deviceIds == null || deviceIds.isEmpty()) { |
| | | return R.error("请选择设备"); |
| | | } |
| | | |
| | | List<String> results = tvDeviceService.batchRestartApp(deviceIds, packageName); |
| | | return R.ok(results); |
| | | } catch (Exception e) { |
| | | return R.error("重启失败: " + e.getMessage()); |
| | | } |
| | | } |
| | | } |