Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
haikang-client
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
杨立
haikang-client
Commits
2d22ae6e
提交
2d22ae6e
authored
9月 29, 2021
作者:
yangli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
.
上级
7bcf29de
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
34 行增加
和
13 行删除
+34
-13
ProgramController.java
...c/main/java/com/priusis/controller/ProgramController.java
+31
-13
application.yml
apq-pc-client/src/main/resources/application.yml
+3
-0
没有找到文件。
apq-pc-client/src/main/java/com/priusis/controller/ProgramController.java
浏览文件 @
2d22ae6e
...
@@ -53,9 +53,19 @@ public class ProgramController {
...
@@ -53,9 +53,19 @@ public class ProgramController {
@Value
(
value
=
"${apq.url.upgrade}"
)
@Value
(
value
=
"${apq.url.upgrade}"
)
private
String
upgradeUrl
;
private
String
upgradeUrl
;
@Value
(
value
=
"apq.url.install-status-upissue"
)
private
String
installStatusUpIssueUrl
;
@Value
(
value
=
"apq.url.upgrade-status-upissue"
)
private
String
upgradeStatusUpIssueUrl
;
@Value
(
value
=
"${apq.url.add-program}"
)
@Value
(
value
=
"${apq.url.add-program}"
)
private
String
addProgramUrl
;
private
String
addProgramUrl
;
@Resource
@Resource
private
InstalledProgramCache
installedProgramCache
;
private
InstalledProgramCache
installedProgramCache
;
...
@@ -102,12 +112,13 @@ public class ProgramController {
...
@@ -102,12 +112,13 @@ public class ProgramController {
return
R
.
success
(
page
.
setRecords
(
list
));
return
R
.
success
(
page
.
setRecords
(
list
));
}
}
private
static
final
Set
<
Lo
ng
>
SET
=
new
ConcurrentHashSet
<>();
private
static
final
Set
<
Stri
ng
>
SET
=
new
ConcurrentHashSet
<>();
private
static
final
Map
<
Lo
ng
,
Thread
>
MAP
=
new
ConcurrentHashMap
<>();
private
static
final
Map
<
Stri
ng
,
Thread
>
MAP
=
new
ConcurrentHashMap
<>();
@GetMapping
(
value
=
"download_and_install"
)
@GetMapping
(
value
=
"{type}/download_and_install"
)
public
void
downloadAndInstall
(
@RequestParam
@NotNull
Long
id
,
public
void
downloadAndInstall
(
@PathVariable
@Pattern
(
regexp
=
"install|upgrade"
)
String
type
,
@RequestParam
@NotNull
Long
id
,
@RequestParam
@NotBlank
String
url
,
@RequestParam
@NotBlank
String
url
,
HttpServletResponse
response
)
throws
IOException
{
HttpServletResponse
response
)
throws
IOException
{
File
dir
=
new
File
(
SysConfigUtil
.
getProperty
(
"download.path"
,
File
dir
=
new
File
(
SysConfigUtil
.
getProperty
(
"download.path"
,
...
@@ -116,11 +127,12 @@ public class ProgramController {
...
@@ -116,11 +127,12 @@ public class ProgramController {
HttpResponse
rsp
=
HttpUtil
.
createGet
(
url
).
execute
(
true
);
HttpResponse
rsp
=
HttpUtil
.
createGet
(
url
).
execute
(
true
);
double
length
=
rsp
.
contentLength
();
double
length
=
rsp
.
contentLength
();
DecimalFormat
decimalFormat
=
new
DecimalFormat
(
"0.#####"
);
DecimalFormat
decimalFormat
=
new
DecimalFormat
(
"0.#####"
);
String
key
=
type
+
"-"
+
id
;
File
file
=
rsp
.
writeBodyForFile
(
dir
,
new
StreamProgress
()
{
File
file
=
rsp
.
writeBodyForFile
(
dir
,
new
StreamProgress
()
{
@SneakyThrows
@SneakyThrows
@Override
@Override
public
void
start
()
{
public
void
start
()
{
SET
.
add
(
id
);
SET
.
add
(
key
);
response
.
getWriter
().
write
(
"0\n"
);
response
.
getWriter
().
write
(
"0\n"
);
}
}
...
@@ -134,23 +146,29 @@ public class ProgramController {
...
@@ -134,23 +146,29 @@ public class ProgramController {
@Override
@Override
public
void
finish
()
{
public
void
finish
()
{
response
.
getWriter
().
close
();
response
.
getWriter
().
close
();
SET
.
remove
(
id
);
SET
.
remove
(
key
);
}
}
});
});
MAP
.
put
(
id
,
new
Thread
(()
->
{
MAP
.
put
(
key
,
new
Thread
(()
->
{
int
exitVal
=
-
1
;
try
{
try
{
Runtime
.
getRuntime
().
exec
(
"cmd /c "
+
file
.
getPath
()
).
waitFor
();
exitVal
=
Runtime
.
getRuntime
().
exec
(
"cmd /c \""
+
file
.
getPath
()
+
"\""
).
waitFor
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"执行安装文件 {} 失败"
,
file
.
getPath
(),
e
);
log
.
error
(
"执行安装文件 {} 失败"
,
file
.
getPath
(),
e
);
}
}
MAP
.
remove
(
id
);
MAP
.
remove
(
key
);
if
(
exitVal
==
0
)
{
HttpUtil
.
post
(
StrUtil
.
format
(
type
.
equals
(
"install"
)
?
installStatusUpIssueUrl
:
upgradeStatusUpIssueUrl
,
MacAddrUtil
.
get
(),
id
),
(
String
)
null
);
}
}));
}));
MAP
.
get
(
id
).
start
();
MAP
.
get
(
key
).
start
();
}
}
@GetMapping
(
value
=
"is_installing"
)
@GetMapping
(
value
=
"{type}/is_installing"
)
public
R
<
Boolean
>
isInstalling
(
@RequestParam
@NotNull
Long
id
)
{
public
R
<
Boolean
>
isInstalling
(
@PathVariable
@Pattern
(
regexp
=
"install|upgrade"
)
String
type
,
return
R
.
success
(
MAP
.
containsKey
(
id
));
@RequestParam
@NotNull
Long
id
)
{
return
R
.
success
(
MAP
.
containsKey
(
type
+
"-"
+
id
));
}
}
@GetMapping
(
value
=
"get_version"
)
@GetMapping
(
value
=
"get_version"
)
...
...
apq-pc-client/src/main/resources/application.yml
浏览文件 @
2d22ae6e
...
@@ -44,9 +44,12 @@ apq:
...
@@ -44,9 +44,12 @@ apq:
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/getClientList?macAddress={}&pageNum={}&pageSize={}
upgrade
:
/ops/upgrade/getClientList?macAddress={}&pageNum={}&pageSize={}
install-status-upissue
:
/ops/install/upIssueStatus/{}/{}
upgrade-status-upissue
:
/ops/upgrade/upIssueStatus/{}/{}
add-program
:
/ops/program/addFacProgram
add-program
:
/ops/program/addFacProgram
send-control-req
:
/facility/facility/remoteRequest
send-control-req
:
/facility/facility/remoteRequest
# VNC中继服务器
# VNC中继服务器
vnc-repeater
:
120.24.236.245:5500
vnc-repeater
:
120.24.236.245:5500
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论