Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jz-dmp-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姚本章
jz-dmp-service
Commits
e4d163f7
Commit
e4d163f7
authored
Mar 12, 2021
by
mcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
aaf004b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
59 deletions
+93
-59
OfflineSynchServiceImpl.java
.../jz/dmp/modules/service/impl/OfflineSynchServiceImpl.java
+93
-59
No files found.
src/main/java/com/jz/dmp/modules/service/impl/OfflineSynchServiceImpl.java
View file @
e4d163f7
...
...
@@ -786,36 +786,38 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
}
List
<
SynchTableColumnsReq
>
list
=
req
.
get
(
"params"
);
for
(
SynchTableColumnsReq
str
:
list
)
{
//通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo
dsInfos
=
offlineSynchDao
.
querySourceDbInfoBySourceId
(
str
.
getSourceDbId
());
DmpAgentDatasourceInfo
dsInfo
=
new
DmpAgentDatasourceInfo
();
BeanUtils
.
copyProperties
(
dsInfos
,
dsInfo
);
if
(
dsInfo
==
null
)
{
throw
new
RuntimeException
(
"数据源配置信息不存在!"
);
}
//解码源数据库密码
if
(
StringUtils
.
isNotBlank
(
dsInfo
.
getPassword
()))
{
dsInfo
.
setPassword
(
new
BaseService
().
decode
(
dsInfo
.
getPassword
(),
publicKey
));
}
if
(
null
!=
str
.
getSourceDbId
()
&&
null
!=
str
.
getTargetTableName
())
{
//通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo
dsInfos
=
offlineSynchDao
.
querySourceDbInfoBySourceId
(
str
.
getSourceDbId
());
DmpAgentDatasourceInfo
dsInfo
=
new
DmpAgentDatasourceInfo
();
BeanUtils
.
copyProperties
(
dsInfos
,
dsInfo
);
if
(
dsInfo
==
null
)
{
throw
new
RuntimeException
(
"数据源配置信息不存在!"
);
}
//解码源数据库密码
if
(
StringUtils
.
isNotBlank
(
dsInfo
.
getPassword
()))
{
dsInfo
.
setPassword
(
new
BaseService
().
decode
(
dsInfo
.
getPassword
(),
publicKey
));
}
//创建jdbc,获取数据源表字段
DmpAgentResult
rst
=
dmpDsAgentServiceImp
.
getTableColumnList
(
dsInfo
,
str
.
getTargetTableName
());
if
(!
rst
.
getCode
().
val
().
equals
(
"200"
))
{
return
new
JsonResult
(
rst
.
getCode
(),
rst
.
getMessage
());
}
else
{
//成功
List
<
Map
>
returnList
=
(
List
<
Map
>)
JsonMapper
.
fromJsonString
(
rst
.
getMessage
(),
List
.
class
);
if
(
returnList
!=
null
&&
returnList
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
returnList
.
size
();
i
++)
{
Map
map
=
returnList
.
get
(
i
);
//离线同步
map
.
put
(
"id"
,
++
len
);
map
.
put
(
"fieldAlias"
,
map
.
get
(
"name"
));
//字段别名
map
.
put
(
"isPk"
,
0
);
//主键
map
.
put
(
"isPt"
,
0
);
//分区
//实时同步:脱敏算法
map
.
put
(
"arithmetic"
,
"HmacSHA256"
);
returnData
.
add
(
map
);
//创建jdbc,获取数据源表字段
DmpAgentResult
rst
=
dmpDsAgentServiceImp
.
getTableColumnList
(
dsInfo
,
str
.
getTargetTableName
());
if
(!
rst
.
getCode
().
val
().
equals
(
"200"
))
{
return
new
JsonResult
(
rst
.
getCode
(),
rst
.
getMessage
());
}
else
{
//成功
List
<
Map
>
returnList
=
(
List
<
Map
>)
JsonMapper
.
fromJsonString
(
rst
.
getMessage
(),
List
.
class
);
if
(
returnList
!=
null
&&
returnList
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
returnList
.
size
();
i
++)
{
Map
map
=
returnList
.
get
(
i
);
//离线同步
map
.
put
(
"id"
,
++
len
);
map
.
put
(
"fieldAlias"
,
map
.
get
(
"name"
));
//字段别名
map
.
put
(
"isPk"
,
0
);
//主键
map
.
put
(
"isPt"
,
0
);
//分区
//实时同步:脱敏算法
map
.
put
(
"arithmetic"
,
"HmacSHA256"
);
returnData
.
add
(
map
);
}
}
}
}
...
...
@@ -1051,36 +1053,38 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
int
num
=
0
;
for
(
SynchTableColumnsReq
str
:
list
)
{
num
++;
//通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo
dsInfos
=
offlineSynchDao
.
querySourceDbInfoBySourceId
(
str
.
getSourceDbId
());
DmpAgentDatasourceInfo
dsInfo
=
new
DmpAgentDatasourceInfo
();
BeanUtils
.
copyProperties
(
dsInfos
,
dsInfo
);
if
(
dsInfo
==
null
)
{
throw
new
RuntimeException
(
"数据源配置信息不存在!"
);
}
//解码源数据库密码
if
(
StringUtils
.
isNotBlank
(
dsInfo
.
getPassword
()))
{
dsInfo
.
setPassword
(
new
BaseService
().
decode
(
dsInfo
.
getPassword
(),
publicKey
));
}
if
(
null
!=
str
.
getSourceDbId
()
&&
null
!=
str
.
getTargetTableName
())
{
//通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo
dsInfos
=
offlineSynchDao
.
querySourceDbInfoBySourceId
(
str
.
getSourceDbId
());
DmpAgentDatasourceInfo
dsInfo
=
new
DmpAgentDatasourceInfo
();
BeanUtils
.
copyProperties
(
dsInfos
,
dsInfo
);
if
(
dsInfo
==
null
)
{
throw
new
RuntimeException
(
"数据源配置信息不存在!"
);
}
//解码源数据库密码
if
(
StringUtils
.
isNotBlank
(
dsInfo
.
getPassword
()))
{
dsInfo
.
setPassword
(
new
BaseService
().
decode
(
dsInfo
.
getPassword
(),
publicKey
));
}
//创建jdbc,获取数据源表字段
DmpAgentResult
rst
=
dmpDsAgentServiceImp
.
getTableColumnList
(
dsInfo
,
str
.
getTargetTableName
());
if
(!
rst
.
getCode
().
val
().
equals
(
"200"
))
{
return
new
JsonResult
(
rst
.
getCode
(),
rst
.
getMessage
());
}
else
{
//成功
List
<
Map
>
returnList
=
(
List
<
Map
>)
JsonMapper
.
fromJsonString
(
rst
.
getMessage
(),
List
.
class
);
if
(
returnList
!=
null
&&
returnList
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
returnList
.
size
();
i
++)
{
Map
map
=
returnList
.
get
(
i
);
//离线同步
map
.
put
(
"id"
,
++
len
);
map
.
put
(
"fieldAlias"
,
map
.
get
(
"name"
));
//字段别名
map
.
put
(
"isPk"
,
0
);
//主键
map
.
put
(
"isPt"
,
0
);
//分区
returnData
.
add
(
map
);
if
(
num
==
1
)
{
syncData
.
add
(
map
);
//创建jdbc,获取数据源表字段
DmpAgentResult
rst
=
dmpDsAgentServiceImp
.
getTableColumnList
(
dsInfo
,
str
.
getTargetTableName
());
if
(!
rst
.
getCode
().
val
().
equals
(
"200"
))
{
return
new
JsonResult
(
rst
.
getCode
(),
rst
.
getMessage
());
}
else
{
//成功
List
<
Map
>
returnList
=
(
List
<
Map
>)
JsonMapper
.
fromJsonString
(
rst
.
getMessage
(),
List
.
class
);
if
(
returnList
!=
null
&&
returnList
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
returnList
.
size
();
i
++)
{
Map
map
=
returnList
.
get
(
i
);
//离线同步
map
.
put
(
"id"
,
++
len
);
map
.
put
(
"fieldAlias"
,
map
.
get
(
"name"
));
//字段别名
map
.
put
(
"isPk"
,
0
);
//主键
map
.
put
(
"isPt"
,
0
);
//分区
returnData
.
add
(
map
);
if
(
num
==
1
)
{
syncData
.
add
(
map
);
}
}
}
}
...
...
@@ -1100,9 +1104,39 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
*/
@Override
public
JsonResult
querySyncTaskInfoById
(
String
id
)
throws
Exception
{
Map
returnMap
=
new
HashMap
();
DmpDevelopTask
dmpDevelopTask
=
dmpDevelopTaskDao
.
selectTaskById
(
id
);
if
(
StringUtils
.
isNotEmpty
(
dmpDevelopTask
.
getScript
()))
{
Map
map
=
(
Map
)
JSONObject
.
parse
(
dmpDevelopTask
.
getScript
());
Map
scripts
=
(
Map
)
map
.
get
(
"scripts"
);
Integer
projectId
=
Integer
.
valueOf
((
String
)
map
.
get
(
"projectId"
));
Map
reader
=
(
Map
)
scripts
.
get
(
"reader"
);
Map
writer
=
(
Map
)
scripts
.
get
(
"writer"
);
String
sourceDbType
=
String
.
valueOf
(
reader
.
get
(
"sourceDbType"
));
String
sourceDbId
=
String
.
valueOf
(
reader
.
get
(
"sourceDbId"
));
String
[]
sourceDbName
=
String
.
valueOf
(
reader
.
get
(
"dbConnection"
)).
split
(
","
);
String
targetDbType
=
String
.
valueOf
(
writer
.
get
(
"targetDbType"
));
String
targetDbId
=
String
.
valueOf
(
writer
.
get
(
"targetDbId"
));
String
targetName
=
String
.
valueOf
(
writer
.
get
(
"targetDbConnection"
));
//数据源
JsonResult
sourceDb
=
querygSourceDbList
(
projectId
,
sourceDbType
);
returnMap
.
put
(
"sourceDb"
,
sourceDb
.
getData
());
JsonResult
targetDb
=
querygSourceDbList
(
projectId
,
targetDbType
);
returnMap
.
put
(
"targetDb"
,
targetDb
.
getData
());
//表
String
[]
sourceDbIds
=
sourceDbId
.
split
(
","
);
for
(
int
i
=
0
;
i
<
sourceDbIds
.
length
;
i
++)
{
JsonResult
sourceTable
=
querygSourceTableList
(
Long
.
valueOf
(
sourceDbIds
[
i
]),
""
);
returnMap
.
put
(
sourceDbName
[
i
],
sourceTable
.
getData
());
}
JsonResult
targetTable
=
querygSourceTableList
(
Long
.
valueOf
(
targetDbId
),
""
);
returnMap
.
put
(
targetName
,
targetTable
.
getData
());
return
JsonResult
.
ok
(
dmpDevelopTask
);
}
returnMap
.
put
(
"task"
,
dmpDevelopTask
);
return
JsonResult
.
ok
(
returnMap
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment