提交 fa796d0f authored 作者: yangli's avatar yangli

.

上级 782f64a9
...@@ -2,6 +2,7 @@ package com.priusis.controller; ...@@ -2,6 +2,7 @@ package com.priusis.controller;
import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.StrUtil;
import com.priusis.lib.R; import com.priusis.lib.R;
import com.priusis.util.SysConfigUtil; import com.priusis.util.SysConfigUtil;
import lombok.SneakyThrows; import lombok.SneakyThrows;
...@@ -36,24 +37,25 @@ public class RemoteControlController { ...@@ -36,24 +37,25 @@ public class RemoteControlController {
/** /**
* 接受远程控制请求 * 接受远程控制请求
*
*/ */
@GetMapping(value = "accept_request") @GetMapping(value = "accept_request")
public R<Void> acceptRequest() throws IOException { public R<Void> acceptRequest() throws IOException {
String requestParams = SysConfigUtil.getProperty("control.request"); String requestParams = SysConfigUtil.getProperty("control.request");
if (StrUtil.isBlank(requestParams)) return R.error("无远程请求");
SysConfigUtil.saveProperty("control.request", null); SysConfigUtil.saveProperty("control.request", null);
// todo 根据参数开启VNC // 开启VNC Server
Runtime.getRuntime().exec("cmd /c C:\\Program Files\\RealVNC\\VNC Server\\vncserver.exe");
// todo 从参数里取出控制的时间,单位分钟 // todo 从参数里取出控制的时间,单位分钟
int minute = 30; int minute = 1;
// 定时任务,指定分钟后执行一次 // 定时任务,指定分钟后执行一次
Timer timer = new Timer(); Timer timer = new Timer();
timer.schedule(new TimerTask() { timer.schedule(new TimerTask() {
@SneakyThrows @SneakyThrows
@Override @Override
public void run() { public void run() {
// 杀掉VNC进程 // 杀掉VNC Server进程
Process process = Runtime.getRuntime().exec("cmd /c tasklist /fo csv | findstr winvnc"); Process process = Runtime.getRuntime().exec("cmd /c tasklist /fo csv | findstr vncserver.exe");
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"))) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"))) {
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论