Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
haikang-client
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
杨立
haikang-client
Commits
68f6fe94
提交
68f6fe94
authored
9月 22, 2021
作者:
yangli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
.
上级
d3587f55
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
37 行增加
和
22 行删除
+37
-22
pom.xml
apq-pc-client/pom.xml
+5
-0
RemoteControlController.java
.../java/com/priusis/controller/RemoteControlController.java
+25
-19
SysConfigUtil.java
...-client/src/main/java/com/priusis/util/SysConfigUtil.java
+3
-3
application.yml
apq-pc-client/src/main/resources/application.yml
+4
-0
没有找到文件。
apq-pc-client/pom.xml
浏览文件 @
68f6fe94
...
@@ -129,6 +129,11 @@
...
@@ -129,6 +129,11 @@
<artifactId>
oshi-core
</artifactId>
<artifactId>
oshi-core
</artifactId>
<version>
3.5.0
</version>
<version>
3.5.0
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.ini4j
</groupId>
<artifactId>
ini4j
</artifactId>
<version>
0.5.2
</version>
</dependency>
<dependency>
<dependency>
<groupId>
junit
</groupId>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<artifactId>
junit
</artifactId>
...
...
apq-pc-client/src/main/java/com/priusis/controller/RemoteControlController.java
浏览文件 @
68f6fe94
...
@@ -8,14 +8,15 @@ import cn.hutool.json.JSONUtil;
...
@@ -8,14 +8,15 @@ import cn.hutool.json.JSONUtil;
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
;
import
org.ini4j.ConfigParser
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.io.
BufferedReader
;
import
java.io.
File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.util.Timer
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
java.util.TimerTask
;
...
@@ -29,6 +30,10 @@ import java.util.TimerTask;
...
@@ -29,6 +30,10 @@ import java.util.TimerTask;
public
class
RemoteControlController
{
public
class
RemoteControlController
{
@Value
(
value
=
"${vnc-repeater}"
)
private
String
vncRepeater
;
/**
/**
* 前端定时任务查询远程控制请求,不为空则表示有请求,展示确认弹窗
* 前端定时任务查询远程控制请求,不为空则表示有请求,展示确认弹窗
*/
*/
...
@@ -41,16 +46,25 @@ public class RemoteControlController {
...
@@ -41,16 +46,25 @@ public class RemoteControlController {
* 接受远程控制请求
* 接受远程控制请求
*/
*/
@GetMapping
(
value
=
"accept_request"
)
@GetMapping
(
value
=
"accept_request"
)
public
R
<
Void
>
acceptRequest
()
throws
IOException
{
public
R
<
Void
>
acceptRequest
()
throws
IOException
,
ConfigParser
.
DuplicateSectionException
,
ConfigParser
.
NoSectionException
{
String
requestParams
=
SysConfigUtil
.
getProperty
(
"control.request"
);
String
requestParams
=
SysConfigUtil
.
saveProperty
(
"control.request"
,
null
);
if
(
StrUtil
.
isBlank
(
requestParams
))
return
R
.
error
(
"无远程请求"
);
if
(
StrUtil
.
isBlank
(
requestParams
))
return
R
.
error
(
"无远程请求"
);
SysConfigUtil
.
saveProperty
(
"control.request"
,
null
);
JSONObject
obj
=
JSONUtil
.
parseObj
(
requestParams
);
JSONObject
obj
=
JSONUtil
.
parseObj
(
requestParams
);
String
id
=
obj
.
getStr
(
"id"
);
String
id
=
obj
.
getStr
(
"id"
);
// 开启VNC Server todo 设置ID
// 设置ID
Runtime
.
getRuntime
().
exec
(
"cmd /c C:\\Program Files\\RealVNC\\VNC Server\\vncserver.exe"
);
File
file
=
new
File
(
"C:\\Program Files\\uvnc bvba\\UltraVNC\\ultravnc.ini"
);
ConfigParser
configParser
=
new
ConfigParser
();
configParser
.
read
(
file
);
if
(!
configParser
.
hasSection
(
"admin"
))
configParser
.
addSection
(
"admin"
);
configParser
.
set
(
"admin"
,
"service_commandline"
,
StrUtil
.
format
(
"-autoreconnect ID:{} -connect {} -run"
,
id
,
vncRepeater
));
configParser
.
write
(
file
);
// 从参数里取出控制的时间,单位分钟
// 重启VNC Server服务
Runtime
.
getRuntime
().
exec
(
"cmd /c net stop uvnc_service"
);
Runtime
.
getRuntime
().
exec
(
"cmd /c net start uvnc_service"
);
// 请求控制的时间,单位分钟
int
minute
=
obj
.
getInt
(
"time"
);
int
minute
=
obj
.
getInt
(
"time"
);
// 定时任务,指定分钟后执行一次
// 定时任务,指定分钟后执行一次
Timer
timer
=
new
Timer
();
Timer
timer
=
new
Timer
();
...
@@ -58,16 +72,8 @@ public class RemoteControlController {
...
@@ -58,16 +72,8 @@ public class RemoteControlController {
@SneakyThrows
@SneakyThrows
@Override
@Override
public
void
run
()
{
public
void
run
()
{
// 杀掉VNC Server进程
// 停止VNC Server服务
Process
process
=
Runtime
.
getRuntime
().
exec
(
"cmd /c tasklist /fo csv | findstr vncserver.exe"
);
Runtime
.
getRuntime
().
exec
(
"cmd /c net stop uvnc_service"
);
try
(
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
(),
"GBK"
)))
{
String
line
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
String
pid
=
line
.
split
(
","
)[
1
].
replace
(
"\""
,
""
);
Runtime
.
getRuntime
().
exec
(
"cmd /c taskkill /pid "
+
pid
).
destroy
();
}
process
.
destroy
();
}
timer
.
cancel
();
timer
.
cancel
();
}
}
},
DateTime
.
now
().
offset
(
DateField
.
MINUTE
,
minute
));
},
DateTime
.
now
().
offset
(
DateField
.
MINUTE
,
minute
));
...
@@ -79,7 +85,7 @@ public class RemoteControlController {
...
@@ -79,7 +85,7 @@ public class RemoteControlController {
*/
*/
@GetMapping
(
value
=
"refuse_request"
)
@GetMapping
(
value
=
"refuse_request"
)
public
R
<
Void
>
refuseRequest
()
throws
IOException
{
public
R
<
Void
>
refuseRequest
()
throws
IOException
{
SysConfigUtil
.
saveProperty
(
"control.request"
,
null
);
// 直接清除请求参数
SysConfigUtil
.
saveProperty
(
"control.request"
,
null
);
return
R
.
success
();
return
R
.
success
();
}
}
}
}
apq-pc-client/src/main/java/com/priusis/util/SysConfigUtil.java
浏览文件 @
68f6fe94
...
@@ -20,13 +20,15 @@ public final class SysConfigUtil {
...
@@ -20,13 +20,15 @@ public final class SysConfigUtil {
return
loadProperties
(
configFile
()).
getProperty
(
key
,
defaultVal
);
return
loadProperties
(
configFile
()).
getProperty
(
key
,
defaultVal
);
}
}
public
static
void
saveProperty
(
String
key
,
String
val
)
throws
IOException
{
public
static
String
saveProperty
(
String
key
,
String
val
)
throws
IOException
{
File
file
=
configFile
();
File
file
=
configFile
();
Properties
properties
=
loadProperties
(
file
);
Properties
properties
=
loadProperties
(
file
);
String
oldVal
=
properties
.
getProperty
(
key
);
properties
.
setProperty
(
key
,
val
);
properties
.
setProperty
(
key
,
val
);
try
(
OutputStream
out
=
new
FileOutputStream
(
file
))
{
try
(
OutputStream
out
=
new
FileOutputStream
(
file
))
{
properties
.
store
(
out
,
null
);
properties
.
store
(
out
,
null
);
}
}
return
oldVal
;
}
}
private
static
Properties
loadProperties
(
File
file
)
throws
IOException
{
private
static
Properties
loadProperties
(
File
file
)
throws
IOException
{
...
@@ -44,6 +46,4 @@ public final class SysConfigUtil {
...
@@ -44,6 +46,4 @@ public final class SysConfigUtil {
if
(!
file
.
exists
())
file
.
createNewFile
();
if
(!
file
.
exists
())
file
.
createNewFile
();
return
file
;
return
file
;
}
}
}
}
apq-pc-client/src/main/resources/application.yml
浏览文件 @
68f6fe94
...
@@ -46,3 +46,7 @@ apq:
...
@@ -46,3 +46,7 @@ apq:
install
:
/ops/install/getList?macAddress={}&pageNum={}&pageSize={}
install
:
/ops/install/getList?macAddress={}&pageNum={}&pageSize={}
upgrade
:
/ops/upgrade/getList?macAddress={}&pageNum={}&pageSize={}
upgrade
:
/ops/upgrade/getList?macAddress={}&pageNum={}&pageSize={}
add-program
:
/ops/program/addFacProgram
add-program
:
/ops/program/addFacProgram
# VNC中继服务器
vnc-repeater
:
120..24.236.245:5500
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论