Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
adaptation-master
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
912协同工作系统
项目监控管理工具
adaptation-master
Commits
60839c3a
提交
60839c3a
authored
12月 23, 2019
作者:
zhangshuang
浏览文件
操作
浏览文件
下载
差异文件
合并分支 'zs' 到 'master'
Zs 查看合并请求 ty_wyl/adaptation-master1!42
上级
c8209a5f
22122486
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
64 行增加
和
22 行删除
+64
-22
WebSocketServer.java
.../adaptationmaster/adaptor/controller/WebSocketServer.java
+8
-1
SQLExecuteTask.java
...ty/adaptationmaster/adaptor/entity/db/SQLExecuteTask.java
+8
-3
DBMigrateServiceImpl.java
...tionmaster/adaptor/service/Impl/DBMigrateServiceImpl.java
+17
-9
ApusicDeployer.java
.../java/com/zjty/adaptationmaster/utils/ApusicDeployer.java
+20
-4
Regular.java
src/main/java/com/zjty/adaptationmaster/utils/Regular.java
+1
-5
TimeUtil.java
src/main/java/com/zjty/adaptationmaster/utils/TimeUtil.java
+10
-0
没有找到文件。
src/main/java/com/zjty/adaptationmaster/adaptor/controller/WebSocketServer.java
浏览文件 @
60839c3a
package
com
.
zjty
.
adaptationmaster
.
adaptor
.
controller
;
package
com
.
zjty
.
adaptationmaster
.
adaptor
.
controller
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -14,6 +15,7 @@ import java.util.Map;
...
@@ -14,6 +15,7 @@ import java.util.Map;
@ServerEndpoint
(
"/webServer/{uuid}"
)
@ServerEndpoint
(
"/webServer/{uuid}"
)
@Component
@Component
@Slf4j
public
class
WebSocketServer
{
public
class
WebSocketServer
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
private
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
...
@@ -77,7 +79,12 @@ public class WebSocketServer {
...
@@ -77,7 +79,12 @@ public class WebSocketServer {
}
}
}
}
public
static
void
sendIn
(
String
sessionId
,
String
message
)
throws
IOException
{
public
static
void
sendIn
(
String
sessionId
,
String
message
)
throws
IOException
{
map
.
get
(
sessionId
).
sendMessage
(
message
);
try
{
map
.
get
(
sessionId
).
sendMessage
(
message
);
}
catch
(
Exception
e
){
log
.
info
(
"向前台发送日志出错"
);
//e.printStackTrace();
}
}
}
}
}
src/main/java/com/zjty/adaptationmaster/adaptor/entity/db/SQLExecuteTask.java
浏览文件 @
60839c3a
package
com
.
zjty
.
adaptationmaster
.
adaptor
.
entity
.
db
;
package
com
.
zjty
.
adaptationmaster
.
adaptor
.
entity
.
db
;
import
com.zjty.adaptationmaster.utils.Regular
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
public
class
SQLExecuteTask
implements
Runnable
{
public
class
SQLExecuteTask
implements
Runnable
{
private
Connection
connection
;
private
DBManage
dbManage
;
private
String
sql
;
private
String
sql
;
public
SQLExecuteTask
(
Connection
connection
){
public
SQLExecuteTask
(
DBManage
dbManage
){
this
.
connection
=
connection
;
this
.
dbManage
=
dbManage
;
}
}
public
void
setSql
(
String
sql
){
public
void
setSql
(
String
sql
){
this
.
sql
=
sql
;
this
.
sql
=
sql
;
}
}
@Override
@Override
public
void
run
()
{
public
void
run
()
{
Connection
connection
=
null
;
PreparedStatement
preparedStatement
=
null
;
PreparedStatement
preparedStatement
=
null
;
try
{
try
{
connection
=
Regular
.
databaseConnection
(
dbManage
);
preparedStatement
=
connection
.
prepareStatement
(
sql
);
preparedStatement
=
connection
.
prepareStatement
(
sql
);
preparedStatement
.
setQueryTimeout
(
10
);
preparedStatement
.
setQueryTimeout
(
10
);
preparedStatement
.
execute
();
preparedStatement
.
execute
();
...
@@ -28,6 +32,7 @@ public class SQLExecuteTask implements Runnable{
...
@@ -28,6 +32,7 @@ public class SQLExecuteTask implements Runnable{
}
finally
{
}
finally
{
try
{
try
{
preparedStatement
.
close
();
preparedStatement
.
close
();
connection
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
src/main/java/com/zjty/adaptationmaster/adaptor/service/Impl/DBMigrateServiceImpl.java
浏览文件 @
60839c3a
...
@@ -9,6 +9,7 @@ import com.zjty.adaptationmaster.adaptor.repository.DBRecordDao;
...
@@ -9,6 +9,7 @@ import com.zjty.adaptationmaster.adaptor.repository.DBRecordDao;
import
com.zjty.adaptationmaster.adaptor.service.DBMigrateService
;
import
com.zjty.adaptationmaster.adaptor.service.DBMigrateService
;
import
com.zjty.adaptationmaster.base.response.ServerResponse
;
import
com.zjty.adaptationmaster.base.response.ServerResponse
;
import
com.zjty.adaptationmaster.utils.Regular
;
import
com.zjty.adaptationmaster.utils.Regular
;
import
com.zjty.adaptationmaster.utils.TimeUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -142,7 +143,7 @@ public class DBMigrateServiceImpl implements DBMigrateService {
...
@@ -142,7 +143,7 @@ public class DBMigrateServiceImpl implements DBMigrateService {
if
(
s
.
contains
(
";"
)){
if
(
s
.
contains
(
";"
)){
if
(
Regular
.
lowerAndUpper
(
s
,
"CREATE"
)
&&
Regular
.
lowerAndUpper
(
s
,
"TABLE"
)){
if
(
Regular
.
lowerAndUpper
(
s
,
"CREATE"
)
&&
Regular
.
lowerAndUpper
(
s
,
"TABLE"
)){
String
tableName
=
s
.
substring
(
s
.
indexOf
(
"\""
)
+
1
,
s
.
lastIndexOf
(
"\""
));
String
tableName
=
s
.
substring
(
s
.
indexOf
(
"\""
)
+
1
,
s
.
lastIndexOf
(
"\""
));
WebSocketServer
.
sendIn
(
uuid
,
tableName
+
"表创建"
);
WebSocketServer
.
sendIn
(
uuid
,
TimeUtil
.
getNowDate
()
+
" 数据库适配:"
+
tableName
+
"表创建"
);
}
}
preparedStatement1
=
connection1
.
prepareStatement
(
sql
);
preparedStatement1
=
connection1
.
prepareStatement
(
sql
);
preparedStatement1
.
execute
();
preparedStatement1
.
execute
();
...
@@ -151,9 +152,17 @@ public class DBMigrateServiceImpl implements DBMigrateService {
...
@@ -151,9 +152,17 @@ public class DBMigrateServiceImpl implements DBMigrateService {
}
}
if
(
insertList
!=
null
&&
insertList
.
size
()
!=
0
){
if
(
insertList
!=
null
&&
insertList
.
size
()
!=
0
){
for
(
String
insert:
insertList
){
for
(
String
insert:
insertList
){
String
tableName
=
s
.
substring
(
s
.
indexOf
(
"\""
)
+
1
,
s
.
lastIndexOf
(
"\""
));
int
insertIndex
=
insert
.
indexOf
(
"\""
)
+
1
;
WebSocketServer
.
sendIn
(
uuid
,
tableName
+
"表中正在插入"
);
String
tableName
=
""
;
SQLExecuteTask
sqlExecuteTask
=
new
SQLExecuteTask
(
connection1
);
for
(
int
j
=
insertIndex
;
j
<
insert
.
length
();
j
++){
if
(
insert
.
charAt
(
j
)
==
'"'
){
break
;
}
else
{
tableName
+=
insert
.
charAt
(
j
);
}
}
WebSocketServer
.
sendIn
(
uuid
,
TimeUtil
.
getNowDate
()
+
" 数据库适配:"
+
tableName
+
"表正在插入"
);
SQLExecuteTask
sqlExecuteTask
=
new
SQLExecuteTask
(
dbManage1
);
sqlExecuteTask
.
setSql
(
insert
);
sqlExecuteTask
.
setSql
(
insert
);
pool
.
submit
(
sqlExecuteTask
);
pool
.
submit
(
sqlExecuteTask
);
System
.
out
.
println
(
"核心线程数"
+
pool
.
getPoolSize
()
+
"\t"
+
"存活线程数:"
+
pool
.
getActiveCount
()
+
"\t"
+
"等待数量:"
+
pool
.
getQueue
().
size
()
+
"\t"
+
"任务数量:"
+
pool
.
getTaskCount
());
System
.
out
.
println
(
"核心线程数"
+
pool
.
getPoolSize
()
+
"\t"
+
"存活线程数:"
+
pool
.
getActiveCount
()
+
"\t"
+
"等待数量:"
+
pool
.
getQueue
().
size
()
+
"\t"
+
"任务数量:"
+
pool
.
getTaskCount
());
...
@@ -169,10 +178,9 @@ public class DBMigrateServiceImpl implements DBMigrateService {
...
@@ -169,10 +178,9 @@ public class DBMigrateServiceImpl implements DBMigrateService {
//关闭后执行新建索引和外键的sql语句
//关闭后执行新建索引和外键的sql语句
if
(
elseList
!=
null
&&
elseList
.
size
()
!=
0
){
if
(
elseList
!=
null
&&
elseList
.
size
()
!=
0
){
for
(
String
elseChar:
elseList
){
for
(
String
elseChar:
elseList
){
WebSocketServer
.
sendIn
(
uuid
,
"正在创建索引或外键"
);
WebSocketServer
.
sendIn
(
uuid
,
TimeUtil
.
getNowDate
()
+
" 数据库适配:"
+
"创建索引或外键"
);
SQLExecuteTask
sqlExecuteTask
=
new
SQLExecuteTask
(
connection1
);
preparedStatement1
=
connection1
.
prepareStatement
(
elseChar
);
sqlExecuteTask
.
setSql
(
elseChar
);
preparedStatement1
.
execute
();
pool
.
submit
(
sqlExecuteTask
);
}
}
}
}
System
.
out
.
println
(
"sql执行时间为:"
+
(
System
.
currentTimeMillis
()
-
b
));
System
.
out
.
println
(
"sql执行时间为:"
+
(
System
.
currentTimeMillis
()
-
b
));
...
@@ -183,7 +191,7 @@ public class DBMigrateServiceImpl implements DBMigrateService {
...
@@ -183,7 +191,7 @@ public class DBMigrateServiceImpl implements DBMigrateService {
try
{
try
{
bufferedReader
.
close
();
bufferedReader
.
close
();
fileReader
.
close
();
fileReader
.
close
();
//
preparedStatement1.close();
preparedStatement1
.
close
();
connection1
.
close
();
connection1
.
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
src/main/java/com/zjty/adaptationmaster/utils/ApusicDeployer.java
浏览文件 @
60839c3a
package
com
.
zjty
.
adaptationmaster
.
utils
;
package
com
.
zjty
.
adaptationmaster
.
utils
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zjty.adaptationmaster.adaptor.controller.WebSocketServer
;
import
com.zjty.adaptationmaster.adaptor.controller.WebSocketServer
;
import
com.zjty.adaptationmaster.adaptor.entity.Project
;
import
com.zjty.adaptationmaster.adaptor.entity.Project
;
import
com.zjty.adaptationmaster.base.entity.ProjectStatueFromMiddleware
;
import
com.zjty.adaptationmaster.base.entity.ProjectStatueFromMiddleware
;
...
@@ -27,17 +28,32 @@ public class ApusicDeployer {
...
@@ -27,17 +28,32 @@ public class ApusicDeployer {
}
}
public
List
<
ProjectStatueFromMiddleware
>
list
(){
public
List
<
ProjectStatueFromMiddleware
>
list
(){
List
<
ProjectStatueFromMiddleware
>
result
=
new
ArrayList
<>();
List
<
ProjectStatueFromMiddleware
>
result
=
new
ArrayList
<>();
String
command
=
ctlPath
+
" -p '"
+
ctlPwd
+
"' list"
;
String
command
=
ctlPath
+
" list"
;
System
.
out
.
println
(
"command:"
+
command
);
try
{
try
{
Process
exec
=
Runtime
.
getRuntime
().
exec
(
command
);
Process
exec
=
Runtime
.
getRuntime
().
exec
(
command
);
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
exec
.
getInputStream
()));
String
password
=
Const
.
CTLPWD
;
OutputStream
outputStream
=
exec
.
getOutputStream
();
outputStream
.
write
(
password
.
getBytes
());
outputStream
.
flush
();
outputStream
.
close
();
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
exec
.
getInputStream
(),
"GBK"
));
boolean
titleEnd
=
false
;
boolean
titleEnd
=
false
;
String
line
=
null
;
String
line
=
null
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
while
((
line
=
reader
.
readLine
())
!=
null
)
{
if
(
line
.
startsWith
(
"---------------"
))
titleEnd
=
true
;
System
.
out
.
println
(
line
);
if
(
line
.
contains
(
"---------------"
)){
titleEnd
=
true
;
continue
;
}
if
(
titleEnd
){
if
(
titleEnd
){
String
[]
split
=
line
.
split
(
"\\s{2,}"
);
String
[]
split
=
line
.
split
(
"\\s{2,}"
);
ProjectStatueFromMiddleware
projectStatue
=
new
ProjectStatueFromMiddleware
(
split
[
0
],
split
[
1
],
split
[
2
]);
ProjectStatueFromMiddleware
projectStatue
=
null
;
if
(
split
.
length
<
3
){
projectStatue
=
new
ProjectStatueFromMiddleware
(
split
[
0
],
null
,
split
[
1
]);
}
else
{
projectStatue
=
new
ProjectStatueFromMiddleware
(
split
[
0
],
split
[
1
],
split
[
2
]);
}
result
.
add
(
projectStatue
);
result
.
add
(
projectStatue
);
}
}
}
}
...
...
src/main/java/com/zjty/adaptationmaster/utils/Regular.java
浏览文件 @
60839c3a
...
@@ -289,10 +289,6 @@ public class Regular {
...
@@ -289,10 +289,6 @@ public class Regular {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
//mySqlRegular("D:\\sqlFile\\uploads\\63c6e098-73fd-4999-b289-b3d120a07e87.sql","test11111");
mySqlRegular
(
"C:\\Users\\admin\\Desktop\\database\\three.sql"
,
"three"
);
//
File
file
=
new
File
(
"D:\\root\\projects\\adaptationMaster\\uploads\\czq测试系统5\\swiper-4.5.0/target/threem-0.0.1-SNAPSHOT.war"
);
System
.
out
.
println
(
file
.
length
());
System
.
out
.
println
(
file
.
getName
());
}
}
}
}
src/main/java/com/zjty/adaptationmaster/utils/TimeUtil.java
0 → 100644
浏览文件 @
60839c3a
package
com
.
zjty
.
adaptationmaster
.
utils
;
import
java.util.Date
;
public
class
TimeUtil
{
public
static
String
getNowDate
(){
Date
date
=
new
Date
();
return
date
.
getHours
()
+
":"
+
date
.
getMinutes
()
+
":"
+
date
.
getSeconds
();
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论