Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
ldmap-download
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
王健
ldmap-download
Commits
785077ca
提交
785077ca
authored
4月 15, 2020
作者:
张航
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复了Socket连接占用的问题(数据只能一条一条发送,不能两条同时发送)
上级
8b147486
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
43 行增加
和
40 行删除
+43
-40
SocketResultData.java
...va/com/comleader/ldmapdownload/bean/SocketResultData.java
+14
-17
DownMapService.java
...a/com/comleader/ldmapdownload/service/DownMapService.java
+1
-1
DownLoadMapWebSocket.java
.../comleader/ldmapdownload/socket/DownLoadMapWebSocket.java
+21
-17
httpclient.properties
src/main/resources/config/httpclient.properties
+2
-1
index.html
src/main/resources/static/index.html
+5
-4
没有找到文件。
src/main/java/com/comleader/ldmapdownload/bean/SocketResultData.java
浏览文件 @
785077ca
...
@@ -82,22 +82,19 @@ public class SocketResultData implements Serializable {
...
@@ -82,22 +82,19 @@ public class SocketResultData implements Serializable {
//public static void main(String[] args) throws InterruptedException {
//public static void main(String[] args) throws InterruptedException {
//
//
// Timer timer = new Timer();
// testTask("Task 1");
// timer.schedule(new TimerTask() {
// testTask("Task 2");
// @Override
// public void run() {
// System.out.println("timer start");
// }
// }, 0, 1000);
// Thread.sleep(1000);
// timer.cancel();
// timer.cancel();
// timer = new Timer();
// timer.schedule(new TimerTask() {
// @Override
// public void run() {
// System.out.println("after cancel");
// }
// }, 1000, 2000);
//}
//}
private
static
void
testTask
(
String
name
)
throws
InterruptedException
{
Timer
timer
=
new
Timer
();
timer
.
schedule
(
new
TimerTask
()
{
@Override
public
void
run
()
{
System
.
out
.
println
(
name
);
}
},
0
,
500
);
Thread
.
sleep
(
2000
);
timer
.
cancel
();
}
}
}
src/main/java/com/comleader/ldmapdownload/service/DownMapService.java
浏览文件 @
785077ca
...
@@ -154,7 +154,7 @@ public class DownMapService {
...
@@ -154,7 +154,7 @@ public class DownMapService {
System
.
out
.
println
(
result
);
System
.
out
.
println
(
result
);
}
}
// 完成标志
// 完成标志
this
.
finished
=
true
;
DownMapService
.
finished
=
true
;
// 结束定时器
// 结束定时器
speedTimer
.
cancel
();
speedTimer
.
cancel
();
scheduleTimer
.
cancel
();
scheduleTimer
.
cancel
();
...
...
src/main/java/com/comleader/ldmapdownload/socket/DownLoadMapWebSocket.java
浏览文件 @
785077ca
...
@@ -170,21 +170,6 @@ public class DownLoadMapWebSocket {
...
@@ -170,21 +170,6 @@ public class DownLoadMapWebSocket {
private
void
downLoadMap
(
SocketResultData
socketData
,
Session
session
)
throws
Exception
{
private
void
downLoadMap
(
SocketResultData
socketData
,
Session
session
)
throws
Exception
{
// 创建定时任务向前端发送速度\进度
// 创建定时任务向前端发送速度\进度
speedTimer
=
new
Timer
();
// 每隔三秒汇报一次
speedTimer
.
schedule
(
new
TimerTask
()
{
@Override
public
void
run
()
{
// 发送了停止命令或者已经完成
if
(
DownMapService
.
stoped
||
DownMapService
.
finished
)
{
speedTimer
.
purge
();
}
else
{
// 发送速度
SocketResultData
speed
=
new
SocketResultData
(
OperationTypeEnum
.
SYS_SUCCESS
,
"下载速度"
+
DownMapService
.
speed
+
"张/s"
,
null
);
AppointSending
(
JSONUtil
.
toJsonStr
(
speed
));
}
}
},
1000
,
1000
);
// 创建定时任务向前端发送进度
// 创建定时任务向前端发送进度
scheduleTimer
=
new
Timer
();
scheduleTimer
=
new
Timer
();
// 每隔0.2秒汇报一次
// 每隔0.2秒汇报一次
...
@@ -203,7 +188,23 @@ public class DownLoadMapWebSocket {
...
@@ -203,7 +188,23 @@ public class DownLoadMapWebSocket {
AppointSending
(
JSONUtil
.
toJsonStr
(
schedule
));
AppointSending
(
JSONUtil
.
toJsonStr
(
schedule
));
}
}
}
}
},
200
,
200
);
},
1000
,
1000
);
speedTimer
=
new
Timer
();
// 每隔三秒汇报一次
speedTimer
.
schedule
(
new
TimerTask
()
{
@Override
public
void
run
()
{
// 发送了停止命令或者已经完成
if
(
DownMapService
.
stoped
||
DownMapService
.
finished
)
{
speedTimer
.
purge
();
}
else
{
// 发送速度
SocketResultData
speed
=
new
SocketResultData
(
OperationTypeEnum
.
SYS_SUCCESS
,
"下载速度"
+
DownMapService
.
speed
+
"张/s"
,
null
);
AppointSending
(
JSONUtil
.
toJsonStr
(
speed
));
}
}
},
2000
,
2000
);
// 发送执行结果(这里是异步阻塞的,会等待downLoad执行完成)
// 发送执行结果(这里是异步阻塞的,会等待downLoad执行完成)
Map
<
String
,
Object
>
resBody
=
downMapService
.
downLoad
(
socketData
.
getBody
(),
session
);
Map
<
String
,
Object
>
resBody
=
downMapService
.
downLoad
(
socketData
.
getBody
(),
session
);
...
@@ -211,6 +212,7 @@ public class DownLoadMapWebSocket {
...
@@ -211,6 +212,7 @@ public class DownLoadMapWebSocket {
",总用时"
+
resBody
.
get
(
"totalTime"
)
+
",失败个数"
+
resBody
.
get
(
"falidNum"
)
+
"(可选择非覆盖重新下载!)"
;
",总用时"
+
resBody
.
get
(
"totalTime"
)
+
",失败个数"
+
resBody
.
get
(
"falidNum"
)
+
"(可选择非覆盖重新下载!)"
;
SocketResultData
resultData
=
new
SocketResultData
(
OperationTypeEnum
.
SYS_SUCCESS
,
msg
,
null
);
SocketResultData
resultData
=
new
SocketResultData
(
OperationTypeEnum
.
SYS_SUCCESS
,
msg
,
null
);
AppointSending
(
JSONUtil
.
toJsonStr
(
resultData
));
AppointSending
(
JSONUtil
.
toJsonStr
(
resultData
));
DownMapService
.
isBusy
=
false
;
// 通知下载完成
// 通知下载完成
AppointSending
(
JSONUtil
.
toJsonStr
(
new
SocketResultData
(
OperationTypeEnum
.
DOWNLOAD_FINISHED
)));
AppointSending
(
JSONUtil
.
toJsonStr
(
new
SocketResultData
(
OperationTypeEnum
.
DOWNLOAD_FINISHED
)));
}
}
...
@@ -235,8 +237,10 @@ public class DownLoadMapWebSocket {
...
@@ -235,8 +237,10 @@ public class DownLoadMapWebSocket {
**/
**/
private
void
AppointSending
(
String
message
)
{
private
void
AppointSending
(
String
message
)
{
try
{
try
{
synchronized
(
session
){
session
.
getBasicRemote
().
sendText
(
message
);
session
.
getBasicRemote
().
sendText
(
message
);
}
catch
(
IOException
e
)
{
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
...
...
src/main/resources/config/httpclient.properties
浏览文件 @
785077ca
...
@@ -7,6 +7,6 @@ http.connectTimeout=60000
...
@@ -7,6 +7,6 @@ http.connectTimeout=60000
#从连接池中获取到连接的最长时间
#从连接池中获取到连接的最长时间
http.connectionRequestTimeout
=
6000000
http.connectionRequestTimeout
=
6000000
#数据传输的最长时间
#数据传输的最长时间
http.socketTimeout
=
1200000
0
http.socketTimeout
=
1200000
#提交请求前测试连接是否可用
#提交请求前测试连接是否可用
http.staleConnectionCheckEnabled
=
true
http.staleConnectionCheckEnabled
=
true
\ No newline at end of file
src/main/resources/static/index.html
浏览文件 @
785077ca
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"initial-scale=1.0, user-scalable=no, width=device-width"
>
<meta
name=
"viewport"
content=
"initial-scale=1.0, user-scalable=no, width=device-width"
>
<title>
E
M MapDownLoader
</title>
<title>
G
M MapDownLoader
</title>
<!-- jquery -->
<!-- jquery -->
<script
src=
"thirdLib/jq/jquery-3.3.1.min.js"
></script>
<script
src=
"thirdLib/jq/jquery-3.3.1.min.js"
></script>
...
@@ -135,15 +135,16 @@
...
@@ -135,15 +135,16 @@
if
(
result
.
type
==
3
)
{
// 更新下载进度
if
(
result
.
type
==
3
)
{
// 更新下载进度
var
schedule
=
result
.
message
;
var
schedule
=
result
.
message
;
console
.
log
(
schedule
);
if
(
schedule
>
100
){
if
(
schedule
>
100
){
schedule
=
100
;
schedule
=
99
;
}
}
console
.
log
(
schedule
);
$
(
"#progressBar"
).
width
(
schedule
+
"%"
);
$
(
"#progressBar"
).
width
(
schedule
+
"%"
);
$
(
"#progressBar"
).
html
(
schedule
+
"%"
);
$
(
"#progressBar"
).
html
(
schedule
+
"%"
);
}
}
if
(
result
.
type
==
4
)
{
// 下载完成,隐藏进度条
if
(
result
.
type
==
4
)
{
// 下载完成,隐藏进度条
// $("#progressDiv").hide();
$
(
"#progressBar"
).
width
(
100
+
"%"
);
$
(
"#progressBar"
).
html
(
100
+
"%"
);
}
}
if
(
result
.
type
==
6
)
{
// 连接信息
if
(
result
.
type
==
6
)
{
// 连接信息
$
(
"#filePath"
).
val
(
result
.
message
);
$
(
"#filePath"
).
val
(
result
.
message
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论