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
2669b6b6
Commit
2669b6b6
authored
Mar 12, 2021
by
mcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
2d72b7b0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
151 additions
and
15 deletions
+151
-15
TaskTreeTypeEnum.java
src/main/java/com/jz/common/enums/TaskTreeTypeEnum.java
+73
-0
DmpRealtimeSyncInfo.java
...in/java/com/jz/dmp/modules/model/DmpRealtimeSyncInfo.java
+12
-0
OfflineSynchServiceImpl.java
.../jz/dmp/modules/service/impl/OfflineSynchServiceImpl.java
+66
-15
No files found.
src/main/java/com/jz/common/enums/TaskTreeTypeEnum.java
0 → 100644
View file @
2669b6b6
package
com
.
jz
.
common
.
enums
;
/**
* 任务树类型
*
* @author Bellamy
* @since 2021-01-04 14:30:23
*/
public
enum
TaskTreeTypeEnum
{
/**
* 离线同步
*/
SYNC
(
"SYNC"
,
"01"
),
/**
* 实时同步
*/
SSTB
(
"SSTB"
,
"02"
),
/**
* 数据开发
*/
SJKF
(
"SJKF"
,
"03"
),
/**
* SHELL
*/
SHELL
(
"SHELL"
,
"04"
),
/**
* SQL
*/
SQL
(
"SQL"
,
"05"
),
;
private
String
code
;
private
String
value
;
private
TaskTreeTypeEnum
(
String
code
,
String
value
)
{
this
.
code
=
code
;
this
.
value
=
value
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
public
static
TaskTreeTypeEnum
get
(
String
code
)
{
if
(
code
==
null
)
{
return
null
;
}
for
(
TaskTreeTypeEnum
status
:
values
())
{
if
(
status
.
getCode
().
equalsIgnoreCase
(
code
))
{
return
status
;
}
}
return
null
;
}
}
src/main/java/com/jz/dmp/modules/model/DmpRealtimeSyncInfo.java
View file @
2669b6b6
...
@@ -166,6 +166,10 @@ public class DmpRealtimeSyncInfo implements Serializable {
...
@@ -166,6 +166,10 @@ public class DmpRealtimeSyncInfo implements Serializable {
@ApiModelProperty
(
value
=
"scriptJson"
)
@ApiModelProperty
(
value
=
"scriptJson"
)
private
String
scriptJson
;
private
String
scriptJson
;
@ApiModelProperty
(
value
=
"任务名称"
)
private
String
name
;
public
Integer
getId
()
{
public
Integer
getId
()
{
return
id
;
return
id
;
}
}
...
@@ -421,4 +425,12 @@ public class DmpRealtimeSyncInfo implements Serializable {
...
@@ -421,4 +425,12 @@ public class DmpRealtimeSyncInfo implements Serializable {
public
void
setScriptJson
(
String
scriptJson
)
{
public
void
setScriptJson
(
String
scriptJson
)
{
this
.
scriptJson
=
scriptJson
;
this
.
scriptJson
=
scriptJson
;
}
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
}
}
\ No newline at end of file
src/main/java/com/jz/dmp/modules/service/impl/OfflineSynchServiceImpl.java
View file @
2669b6b6
...
@@ -8,6 +8,7 @@ import com.jz.agent.service.DmpDsAgentService;
...
@@ -8,6 +8,7 @@ import com.jz.agent.service.DmpDsAgentService;
import
com.jz.common.constant.JsonResult
;
import
com.jz.common.constant.JsonResult
;
import
com.jz.common.constant.ResultCode
;
import
com.jz.common.constant.ResultCode
;
import
com.jz.common.enums.DelFlagEnum
;
import
com.jz.common.enums.DelFlagEnum
;
import
com.jz.common.enums.TaskTreeTypeEnum
;
import
com.jz.common.page.BasePageBean
;
import
com.jz.common.page.BasePageBean
;
import
com.jz.common.page.PageInfoResponse
;
import
com.jz.common.page.PageInfoResponse
;
import
com.jz.common.persistence.BaseService
;
import
com.jz.common.persistence.BaseService
;
...
@@ -96,6 +97,9 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
...
@@ -96,6 +97,9 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
@Autowired
@Autowired
private
DmpDevelopTaskHistoryMapper
dmpDevelopTaskHistoryMapper
;
private
DmpDevelopTaskHistoryMapper
dmpDevelopTaskHistoryMapper
;
@Autowired
private
DmpRealtimeSyncInfoDao
dmpRealtimeSyncInfoDao
;
@Autowired
@Autowired
private
RedisTemplate
redisTemplate
;
private
RedisTemplate
redisTemplate
;
...
@@ -893,8 +897,29 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
...
@@ -893,8 +897,29 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
tree
.
setIsEnable
(
"1"
);
tree
.
setIsEnable
(
"1"
);
tree
.
setDataStatus
(
"1"
);
tree
.
setDataStatus
(
"1"
);
int
len
=
dmpNavigationTreeDao
.
insert
(
tree
);
int
len
=
dmpNavigationTreeDao
.
insert
(
tree
);
if
(
len
>
0
)
if
(
len
>
0
)
{
return
JsonResult
.
ok
();
if
(
TaskTreeTypeEnum
.
SYNC
.
getValue
().
equals
(
newSynchTaskReq
.
getType
()))
{
DmpDevelopTask
dmpDevelopTask
=
new
DmpDevelopTask
();
dmpDevelopTask
.
setTreeId
(
tree
.
getId
());
dmpDevelopTask
.
setVersion
(
"1.0"
);
dmpDevelopTask
.
setCreateTime
(
new
Date
());
dmpDevelopTask
.
setCreateUserId
(
SessionUtils
.
getCurrentUserId
());
dmpDevelopTask
.
setDataStatus
(
DelFlagEnum
.
NO
.
getValue
());
dmpDevelopTask
.
setName
(
tree
.
getName
());
dmpDevelopTaskDao
.
insert
(
dmpDevelopTask
);
return
JsonResult
.
ok
(
dmpDevelopTask
);
}
else
if
(
TaskTreeTypeEnum
.
SSTB
.
getValue
().
equals
(
newSynchTaskReq
.
getType
()))
{
DmpRealtimeSyncInfo
dmpRealtimeSyncInfo
=
new
DmpRealtimeSyncInfo
();
dmpRealtimeSyncInfo
.
setTreeId
(
String
.
valueOf
(
tree
.
getId
()));
dmpRealtimeSyncInfo
.
setVersion
(
"1.0"
);
dmpRealtimeSyncInfo
.
setCrePerson
(
SessionUtils
.
getCurrentUserId
());
dmpRealtimeSyncInfo
.
setCreateTime
(
new
Date
());
dmpRealtimeSyncInfo
.
setProjectId
(
newSynchTaskReq
.
getProjectId
());
dmpRealtimeSyncInfo
.
setName
(
tree
.
getName
());
dmpRealtimeSyncInfoDao
.
insert
(
dmpRealtimeSyncInfo
);
return
JsonResult
.
ok
(
dmpRealtimeSyncInfo
);
}
}
return
JsonResult
.
error
();
return
JsonResult
.
error
();
}
}
...
@@ -908,15 +933,14 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
...
@@ -908,15 +933,14 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
*/
*/
@Override
@Override
public
JsonResult
getDataPreview
(
OfflineDataPreview
req
)
throws
Exception
{
public
JsonResult
getDataPreview
(
OfflineDataPreview
req
)
throws
Exception
{
List
<
Map
<
String
,
List
<
Object
>>>
data1
=
new
ArrayList
<>();
List
<
Object
>
listHeard
=
new
ArrayList
<>();
List
<
Object
>
listHeard
=
new
ArrayList
<>();
List
<
Map
>
tableData
=
new
ArrayList
<>();
Map
returnData
=
new
HashMap
();
Map
returnData
=
new
HashMap
();
if
(
req
.
getParams
()
==
null
||
req
.
getParams
().
size
()
==
0
)
{
if
(
req
.
getParams
()
==
null
||
req
.
getParams
().
size
()
==
0
)
{
throw
new
RuntimeException
(
"请求参数不能为空!"
);
throw
new
RuntimeException
(
"请求参数不能为空!"
);
}
}
for
(
int
m
=
0
;
m
<
req
.
getParams
().
size
();
m
++)
{
for
(
SynchTableColumnsReq
str
:
req
.
getParams
())
{
SynchTableColumnsReq
str
=
req
.
getParams
().
get
(
m
);
//通过源数据库id ,查询数据源配置
//通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo
dsInfos
=
offlineSynchDao
.
querySourceDbInfoBySourceId
(
str
.
getSourceDbId
());
DmpAgentDatasourceInfo
dsInfos
=
offlineSynchDao
.
querySourceDbInfoBySourceId
(
str
.
getSourceDbId
());
DmpAgentDatasourceInfo
dsInfo
=
new
DmpAgentDatasourceInfo
();
DmpAgentDatasourceInfo
dsInfo
=
new
DmpAgentDatasourceInfo
();
...
@@ -928,7 +952,10 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
...
@@ -928,7 +952,10 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
if
(
StringUtils
.
isNotBlank
(
dsInfo
.
getPassword
()))
{
if
(
StringUtils
.
isNotBlank
(
dsInfo
.
getPassword
()))
{
dsInfo
.
setPassword
(
new
BaseService
().
decode
(
dsInfo
.
getPassword
(),
publicKey
));
dsInfo
.
setPassword
(
new
BaseService
().
decode
(
dsInfo
.
getPassword
(),
publicKey
));
}
}
//只展示第一张表数据
if
(
m
>
0
)
{
break
;
}
//创建jdbc,获取数据源数据预览
//创建jdbc,获取数据源数据预览
DmpAgentResult
rst
=
dmpDsAgentServiceImp
.
previewData
(
dsInfo
,
str
.
getTargetTableName
());
DmpAgentResult
rst
=
dmpDsAgentServiceImp
.
previewData
(
dsInfo
,
str
.
getTargetTableName
());
if
(!
rst
.
getCode
().
val
().
equals
(
"200"
))
{
if
(!
rst
.
getCode
().
val
().
equals
(
"200"
))
{
...
@@ -936,9 +963,32 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
...
@@ -936,9 +963,32 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
}
else
{
}
else
{
//成功,包含表字段和行数据
//成功,包含表字段和行数据
Map
<
String
,
List
<
Object
>>
returnList
=
(
Map
<
String
,
List
<
Object
>>)
JSONObject
.
parse
(
rst
.
getMessage
());
Map
<
String
,
List
<
Object
>>
returnList
=
(
Map
<
String
,
List
<
Object
>>)
JSONObject
.
parse
(
rst
.
getMessage
());
if
(
returnList
!=
null
&&
returnList
.
size
()
>
0
)
{
if
(
returnList
!=
null
&&
returnList
.
size
()
>
0
)
{
List
<
Object
>
header
=
returnList
.
get
(
"header"
);
//表头 字段
List
<
Object
>
header
=
returnList
.
get
(
"header"
);
//表头 字段
listHeard
.
addAll
(
header
);
listHeard
.
addAll
(
header
);
//拼接每张表头
List
<
List
<
Object
>>
columnData
=
Collections
.
singletonList
(
returnList
.
get
(
"result"
));
//行数据
List
<
Object
>
rowData
=
columnData
.
get
(
0
);
for
(
int
i
=
0
;
i
<
rowData
.
size
();
i
++)
{
//表所有数据
List
<
Object
>
row
=
(
List
<
Object
>)
rowData
.
get
(
i
);
//每行数据
Map
colKeyValue
=
new
LinkedHashMap
();
for
(
int
j
=
0
;
j
<
header
.
size
();
j
++)
{
//表头
for
(
int
h
=
0
;
h
<
row
.
size
();
h
++)
{
if
(
j
==
h
)
{
System
.
out
.
print
(
header
.
get
(
j
)
+
" "
+
row
.
get
(
h
));
colKeyValue
.
put
(
header
.
get
(
j
),
row
.
get
(
h
));
break
;
}
}
}
tableData
.
add
(
colKeyValue
);
}
}
/* if (returnList != null && returnList.size() > 0) {
List<Object> header = returnList.get("header"); //表头 字段
listHeard.addAll(header); //拼接每张表头
List<List<Object>> columnData = Collections.singletonList(returnList.get("result"));//行数据
List<List<Object>> columnData = Collections.singletonList(returnList.get("result"));//行数据
for (int i = 0; i < columnData.size(); i++) {
for (int i = 0; i < columnData.size(); i++) {
List<Object> rowData = columnData.get(i);
List<Object> rowData = columnData.get(i);
...
@@ -946,22 +996,23 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
...
@@ -946,22 +996,23 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
map1.put("value", rowData);
map1.put("value", rowData);
data1.add(map1);
data1.add(map1);
}
}
}
}
*/
}
}
}
}
/* //两张表字段横向拼接展示 ,data1所有表的数据
if (data1.size() > 0 && data1 != null) {
if (data1.size() > 0 && data1 != null) {
for (int i = 0; i < data1.size(); i++) {
for (int i = 0; i < data1.size(); i++) {
Map mapa = data1.get(i);
Map mapa = data1.get(i);
List
<
List
<
Object
>>
lista
=
(
List
<
List
<
Object
>>)
mapa
.
get
(
"value"
);
List<List<Object>> lista = (List<List<Object>>) mapa.get("value");
//遍历第i个表数据
List
<
List
<
Object
>>
reData
=
new
ArrayList
<>();
List<List<Object>> reData = new ArrayList<>();
//每次循环将数据添加进去
int c = ++i;
int c = ++i;
for
(
int
a
=
0
;
a
<
lista
.
size
();
a
++)
{
for (int a = 0; a < lista.size(); a++) {
//遍历第i个表数据
List<Object> obj1 = lista.get(a);
List<Object> obj1 = lista.get(a);
if (c < data1.size()) {
if (c < data1.size()) {
Map mapb = data1.get(c);
Map mapb = data1.get(c);
List<List<Object>> listb = (List<List<Object>>) mapb.get("value");
List<List<Object>> listb = (List<List<Object>>) mapb.get("value");
for
(
int
b
=
0
;
b
<
listb
.
size
();
b
++)
{
for (int b = 0; b < listb.size(); b++) {
//遍历第i+1个表数据
List<Object> obj2 = listb.get(b);
List<Object> obj2 = listb.get(b);
if (a == b) {
if (a == b) {
obj1.addAll(obj2);
obj1.addAll(obj2);
...
@@ -974,9 +1025,9 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
...
@@ -974,9 +1025,9 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
mapa.put("value", reData);
mapa.put("value", reData);
}
}
}
}
*/
returnData
.
put
(
"header"
,
listHeard
);
returnData
.
put
(
"header"
,
listHeard
);
returnData
.
put
(
"rowDatas"
,
data1
.
get
(
0
)
);
returnData
.
put
(
"rowDatas"
,
tableData
);
return
JsonResult
.
ok
(
returnData
);
return
JsonResult
.
ok
(
returnData
);
}
}
...
...
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