提交 6641cda0 authored 作者: wangqiang's avatar wangqiang

Merge remote-tracking branch 'origin/master'

...@@ -70,14 +70,16 @@ public class RemoteControlController { ...@@ -70,14 +70,16 @@ public class RemoteControlController {
*/ */
@GetMapping(value = "accept_request") @GetMapping(value = "accept_request")
public R<Void> acceptRequest(@RequestParam @NotNull Long minutes) public R<Void> acceptRequest(@RequestParam @NotNull Long minutes)
throws IOException, ConfigParser.DuplicateSectionException, ConfigParser.NoSectionException { throws IOException, ConfigParser.DuplicateSectionException, ConfigParser.NoSectionException, InterruptedException {
Boolean hasRequest = Convert.toBool(SysConfigUtil.saveProperty("control.request", "0"), false); Boolean hasRequest = Convert.toBool(SysConfigUtil.saveProperty("control.request", "0"), false);
if (!hasRequest) return R.error("无远程请求"); if (!hasRequest) return R.error("无远程请求");
return startVncServer(minutes); return startVncServer(minutes);
} }
private R<Void> startVncServer(long minutes) private Timer timer = new Timer();
throws IOException, ConfigParser.DuplicateSectionException, ConfigParser.NoSectionException {
private synchronized R<Void> startVncServer(long minutes)
throws IOException, ConfigParser.DuplicateSectionException, ConfigParser.NoSectionException, InterruptedException {
// 查询设备的远程ID // 查询设备的远程ID
String remoteId = getRemoteId(); String remoteId = getRemoteId();
if (StrUtil.isBlank(remoteId)) return R.error("未查询到设备的远程ID"); if (StrUtil.isBlank(remoteId)) return R.error("未查询到设备的远程ID");
...@@ -97,11 +99,12 @@ public class RemoteControlController { ...@@ -97,11 +99,12 @@ public class RemoteControlController {
configParser.write(file); configParser.write(file);
// 重启VNC Server服务 // 重启VNC Server服务
Runtime.getRuntime().exec("cmd /c net stop uvnc_service"); timer.cancel();
Runtime.getRuntime().exec("cmd /c net start uvnc_service"); Runtime.getRuntime().exec("cmd /c net stop uvnc_service").waitFor();
Runtime.getRuntime().exec("cmd /c net start uvnc_service").waitFor();
// 定时任务,指定分钟后执行一次 // 定时任务,指定分钟后执行一次
Timer timer = new Timer(); timer = new Timer();
timer.schedule(new TimerTask() { timer.schedule(new TimerTask() {
@SneakyThrows @SneakyThrows
@Override @Override
...@@ -126,7 +129,7 @@ public class RemoteControlController { ...@@ -126,7 +129,7 @@ public class RemoteControlController {
@GetMapping(value = "send_request") @GetMapping(value = "send_request")
public R<Void> sendRequest(@RequestParam @NotNull Long minutes) public R<Void> sendRequest(@RequestParam @NotNull Long minutes)
throws IOException, ConfigParser.DuplicateSectionException, ConfigParser.NoSectionException { throws IOException, ConfigParser.DuplicateSectionException, ConfigParser.NoSectionException, InterruptedException {
JSONObject rsp = JSONUtil.parseObj(HttpUtil.post(gateway + sendControlReqUrl, JSONObject rsp = JSONUtil.parseObj(HttpUtil.post(gateway + sendControlReqUrl,
JSONUtil.createObj().set("minutes", minutes).set("macAddress", getMacAddress()).toString())); JSONUtil.createObj().set("minutes", minutes).set("macAddress", getMacAddress()).toString()));
if (ObjectUtil.notEqual(rsp.getInt("code"), 0)) return R.error(rsp.getStr("msg")); if (ObjectUtil.notEqual(rsp.getInt("code"), 0)) return R.error(rsp.getStr("msg"));
......
...@@ -44,7 +44,7 @@ apq: ...@@ -44,7 +44,7 @@ apq:
url: url:
device_info: /facility/facility/getByMacAddress?macAddress={} device_info: /facility/facility/getByMacAddress?macAddress={}
install: /ops/install/getClientList?macAddress={}&pageNum={}&pageSize={} install: /ops/install/getClientList?macAddress={}&pageNum={}&pageSize={}
upgrade: /ops/upgrade/getList?macAddress={}&pageNum={}&pageSize={} upgrade: /ops/upgrade/getClientList?macAddress={}&pageNum={}&pageSize={}
add-program: /ops/program/addFacProgram add-program: /ops/program/addFacProgram
send-control-req: / send-control-req: /
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论