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
c96bbef5
Commit
c96bbef5
authored
Dec 31, 2020
by
mcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
离线任务编辑
parent
8aead7d8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
137 additions
and
20 deletions
+137
-20
DvTaskRuleTDao.java
src/main/java/com/jz/dmp/modules/dao/DvTaskRuleTDao.java
+9
-0
DmpDevelopTaskService.java
...ava/com/jz/dmp/modules/service/DmpDevelopTaskService.java
+1
-0
DvTaskRuleTService.java
...n/java/com/jz/dmp/modules/service/DvTaskRuleTService.java
+11
-1
DmpDevelopTaskServiceImpl.java
...z/dmp/modules/service/impl/DmpDevelopTaskServiceImpl.java
+6
-0
DvTaskRuleTServiceImpl.java
...m/jz/dmp/modules/service/impl/DvTaskRuleTServiceImpl.java
+17
-0
OfflineSynchServiceImpl.java
.../jz/dmp/modules/service/impl/OfflineSynchServiceImpl.java
+82
-19
DvTaskRuleTMapper.xml
src/main/resources/mapper/dmp/DvTaskRuleTMapper.xml
+11
-0
No files found.
src/main/java/com/jz/dmp/modules/dao/DvTaskRuleTDao.java
View file @
c96bbef5
...
@@ -79,4 +79,13 @@ public interface DvTaskRuleTDao {
...
@@ -79,4 +79,13 @@ public interface DvTaskRuleTDao {
*/
*/
int
deleteById
(
Long
taskRuleId
);
int
deleteById
(
Long
taskRuleId
);
List
<
Long
>
getTaskRuleIdsList
(
Integer
taskId
)
throws
Exception
;
/**
* 批量删除rule信息
*
* @param listRules
* @return
*/
void
delRulesByIds
(
@Param
(
"listRules"
)
List
<
Long
>
listRules
)
throws
Exception
;
}
}
\ No newline at end of file
src/main/java/com/jz/dmp/modules/service/DmpDevelopTaskService.java
View file @
c96bbef5
...
@@ -13,4 +13,5 @@ public interface DmpDevelopTaskService {
...
@@ -13,4 +13,5 @@ public interface DmpDevelopTaskService {
JsonResult
submitSyncing
(
DmpDevelopTask
task
)
throws
Exception
;
JsonResult
submitSyncing
(
DmpDevelopTask
task
)
throws
Exception
;
}
}
\ No newline at end of file
src/main/java/com/jz/dmp/modules/service/DvTaskRuleTService.java
View file @
c96bbef5
...
@@ -53,5 +53,15 @@ public interface DvTaskRuleTService {
...
@@ -53,5 +53,15 @@ public interface DvTaskRuleTService {
*/
*/
boolean
deleteById
(
Long
taskRuleId
);
boolean
deleteById
(
Long
taskRuleId
);
void
saveRule
(
List
<
DvTaskRuleT
>
list
)
throws
Exception
;
void
saveRule
(
List
<
DvTaskRuleT
>
list
)
throws
Exception
;
List
<
Long
>
getTaskRuleIdsList
(
Integer
taskId
)
throws
Exception
;
/**
* 批量删除rule信息
*
* @param listRules
* @return
*/
void
delRulesByIds
(
List
<
Long
>
listRules
)
throws
Exception
;
}
}
\ No newline at end of file
src/main/java/com/jz/dmp/modules/service/impl/DmpDevelopTaskServiceImpl.java
View file @
c96bbef5
...
@@ -52,6 +52,12 @@ public class DmpDevelopTaskServiceImpl implements DmpDevelopTaskService {
...
@@ -52,6 +52,12 @@ public class DmpDevelopTaskServiceImpl implements DmpDevelopTaskService {
@Autowired
@Autowired
private
DmpSyncingDatasourceService
dmpSyncingDatasourceService
;
private
DmpSyncingDatasourceService
dmpSyncingDatasourceService
;
/**
* 添加保存dmp数据(包含校验数据)
*
* @Author Bellamy
* @Date 2020/12/20
*/
@Override
@Override
public
JsonResult
submitSyncing
(
DmpDevelopTask
task
)
throws
Exception
{
public
JsonResult
submitSyncing
(
DmpDevelopTask
task
)
throws
Exception
{
String
xmlContent
;
String
xmlContent
;
...
...
src/main/java/com/jz/dmp/modules/service/impl/DvTaskRuleTServiceImpl.java
View file @
c96bbef5
...
@@ -81,6 +81,7 @@ public class DvTaskRuleTServiceImpl implements DvTaskRuleTService {
...
@@ -81,6 +81,7 @@ public class DvTaskRuleTServiceImpl implements DvTaskRuleTService {
/**
/**
* 保存规则列表信息
* 保存规则列表信息
*
* @param list
* @param list
* @throws Exception
* @throws Exception
*/
*/
...
@@ -88,4 +89,20 @@ public class DvTaskRuleTServiceImpl implements DvTaskRuleTService {
...
@@ -88,4 +89,20 @@ public class DvTaskRuleTServiceImpl implements DvTaskRuleTService {
public
void
saveRule
(
List
<
DvTaskRuleT
>
list
)
throws
Exception
{
public
void
saveRule
(
List
<
DvTaskRuleT
>
list
)
throws
Exception
{
dvTaskRuleTDao
.
insertBatch
(
list
);
dvTaskRuleTDao
.
insertBatch
(
list
);
}
}
@Override
public
List
<
Long
>
getTaskRuleIdsList
(
Integer
taskId
)
throws
Exception
{
return
dvTaskRuleTDao
.
getTaskRuleIdsList
(
taskId
);
}
/**
* 批量删除rule信息
*
* @param listRules
* @return
*/
@Override
public
void
delRulesByIds
(
List
<
Long
>
listRules
)
throws
Exception
{
dvTaskRuleTDao
.
delRulesByIds
(
listRules
);
}
}
}
\ No newline at end of file
src/main/java/com/jz/dmp/modules/service/impl/OfflineSynchServiceImpl.java
View file @
c96bbef5
...
@@ -459,14 +459,87 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
...
@@ -459,14 +459,87 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
public
JsonResult
updateSyncTask
(
SyncDmpTaskAddReq
syncDmpTaskAddReq
)
throws
Exception
{
public
JsonResult
updateSyncTask
(
SyncDmpTaskAddReq
syncDmpTaskAddReq
)
throws
Exception
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
Map
<
String
,
Object
>
reqParam
=
syncDmpTaskAddReq
.
getParams
();
Map
<
String
,
Object
>
reqParam
=
syncDmpTaskAddReq
.
getParams
();
if
(
reqParam
.
size
()
>
0
&&
reqParam
!=
null
)
{
if
(
reqParam
.
size
()
>
0
&&
reqParam
!=
null
)
{
JsonResult
jsonResult
=
addSyncing
(
reqParam
);
Integer
projectId
=
Integer
.
valueOf
(
reqParam
.
get
(
"projectId"
).
toString
());
DmpDevelopTask
data
=
(
DmpDevelopTask
)
jsonResult
.
getData
();
Integer
parentId
=
Integer
.
valueOf
(
reqParam
.
get
(
"parentId"
).
toString
());
//父节点ID
saveRuleInfo
(
result
,
reqParam
,
jsonResult
,
String
.
valueOf
(
data
.
getId
()));
String
taskName
=
(
String
)
reqParam
.
get
(
"taskName"
);
//任务名称 业务节点名称 一对一
Integer
treeId
=
Integer
.
valueOf
(
reqParam
.
get
(
"treeId"
).
toString
());
//树节点ID
Integer
taskId
=
Integer
.
valueOf
(
reqParam
.
get
(
"taskId"
).
toString
());
//任务ID
if
(
StringUtils
.
isBlank
(
taskName
))
{
return
new
JsonResult
(
ResultCode
.
PARAMS_ERROR
,
"任务名称不能为空"
);
}
Map
<
String
,
Object
>
scriptMap
=
(
Map
<
String
,
Object
>)
reqParam
.
get
(
"scripts"
);
//任务json数据
Object
content
=
scriptMap
.
get
(
"content"
);
String
xmlTdb
=
XmlUtils
.
getPropertyValue
(
content
,
"target_db_connection"
);
if
(
null
!=
content
&&
xmlTdb
.
length
()
==
0
)
{
// 包含content但未取出值条件才成立
return
new
JsonResult
(
ResultCode
.
PARAMS_ERROR
,
"脚本内容中缺失目标数据源(target_db_connection)"
);
}
//保存目标库类型
Map
<
String
,
Object
>
writer
=
(
Map
<
String
,
Object
>)
scriptMap
.
get
(
"writer"
);
// 目标数据
String
targetDb
=
(
String
)
writer
.
get
(
"targetDbConnection"
);
// 目标库名称
String
targetTable
=
(
String
)
writer
.
get
(
"targetTable"
);
// 目标库表名称
Map
<
String
,
Object
>
reader
=
(
Map
<
String
,
Object
>)
scriptMap
.
get
(
"reader"
);
//源数据
String
sourceDbName
=
(
String
)
reader
.
get
(
"dbConnection"
);
// 源库名称
String
sourceTableName
=
(
String
)
reader
.
get
(
"registerTableName"
);
// 源库表名称
Integer
dataSourceId
=
null
;
//数据源ID
if
(
StringUtils
.
isNotBlank
(
targetDb
))
{
//根据 目标库和项目id 查询
dataSourceId
=
dmpDevelopTaskDao
.
getDbInfoByParam
(
targetDb
,
projectId
);
}
DmpDevelopTask
task
=
new
DmpDevelopTask
();
task
.
setProjectId
(
projectId
);
task
.
setParentId
(
parentId
);
task
.
setTaskType
(
"2"
);
//任务类型
task
.
setDatasourceId
(
dataSourceId
);
//数据源ID
task
.
setType
(
"3"
);
//task.setTaskName(taskName);
task
.
setTaskDesc
(
"Syncing Task"
);
//任务描述
task
.
setIsSubmit
(
"0"
);
//是否已提交
task
.
setTreeId
(
treeId
);
task
.
setDataStatus
(
"1"
);
String
script
=
JsonMapper
.
toJsonString
(
reqParam
);
byte
[]
data
=
null
;
try
{
data
=
script
.
getBytes
(
"utf-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
task
.
setData
(
data
);
//json 数据
task
.
setTargetDbName
(
targetDb
);
task
.
setTargetTableName
(
targetTable
);
task
.
setSourceTableName
(
sourceTableName
);
task
.
setSourceDbName
(
sourceDbName
);
task
.
setId
(
taskId
);
dmpDevelopTaskDao
.
update
(
task
);
//更新任务
logger
.
info
(
"################################## 更新任务数据结束 ############################################"
);
DmpNavigationTree
dmpNavigationTree
=
new
DmpNavigationTree
();
dmpNavigationTree
.
setName
(
taskName
);
dmpNavigationTree
.
setId
(
treeId
);
dmpNavigationTreeDao
.
update
(
dmpNavigationTree
);
//更新节点 树
logger
.
info
(
"################################## 更新节点 树 结束 ############################################"
);
//更新规则信息
List
<
DvTaskRuleT
>
list
=
new
ArrayList
<>();
//查询TaskRuleID 集合
List
<
Long
>
listRules
=
dvTaskRuleTService
.
getTaskRuleIdsList
(
taskId
);
if
(
CollectionUtils
.
isNotEmpty
(
listRules
)){
//批量删除rule信息
dvTaskRuleTService
.
delRulesByIds
(
listRules
);
List
<
Map
>
taskRules
=
(
List
<
Map
>)
reqParam
.
get
(
"taskRules"
);
//保存dmp数据校验规则信息
settRuleInfo
(
String
.
valueOf
(
taskId
),
taskRules
,
list
);
}
//保存时提交XML
dmpDevelopTaskService
.
submitSyncing
(
task
);
}
}
return
new
JsonResult
(
ResultCode
.
SUCCESS
,
result
);
return
new
JsonResult
(
ResultCode
.
SUCCESS
);
}
}
/**
/**
...
@@ -480,7 +553,7 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
...
@@ -480,7 +553,7 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
Integer
parentId
=
Integer
.
valueOf
(
body
.
get
(
"parentId"
).
toString
());
//父节点ID
Integer
parentId
=
Integer
.
valueOf
(
body
.
get
(
"parentId"
).
toString
());
//父节点ID
String
taskName
=
(
String
)
body
.
get
(
"taskName"
);
//任务名称 业务节点名称 一对一
String
taskName
=
(
String
)
body
.
get
(
"taskName"
);
//任务名称 业务节点名称 一对一
Integer
treeId
=
Integer
.
valueOf
(
body
.
get
(
"treeId"
).
toString
());
//树节点ID
Integer
treeId
=
Integer
.
valueOf
(
body
.
get
(
"treeId"
).
toString
());
//树节点ID
Integer
taskId
=
null
;
//任务ID
//
Integer taskId = null; //任务ID
if
(
StringUtils
.
isBlank
(
taskName
))
{
if
(
StringUtils
.
isBlank
(
taskName
))
{
return
new
JsonResult
(
ResultCode
.
PARAMS_ERROR
,
"任务名称不能为空"
);
return
new
JsonResult
(
ResultCode
.
PARAMS_ERROR
,
"任务名称不能为空"
);
...
@@ -539,16 +612,8 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
...
@@ -539,16 +612,8 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
task
.
setTargetTableName
(
targetTable
);
task
.
setTargetTableName
(
targetTable
);
task
.
setSourceTableName
(
sourceTableName
);
task
.
setSourceTableName
(
sourceTableName
);
task
.
setSourceDbName
(
sourceDbName
);
task
.
setSourceDbName
(
sourceDbName
);
if
(
StringUtils
.
isNotEmpty
(
body
.
get
(
"taskId"
).
toString
()))
{
dmpDevelopTaskDao
.
insert
(
task
);
//保存任务数据
taskId
=
Integer
.
valueOf
(
body
.
get
(
"taskId"
).
toString
());
//任务ID
logger
.
info
(
"################################## 新增任务数据结束 ############################################"
);
task
.
setId
(
taskId
);
dmpDevelopTaskDao
.
update
(
task
);
logger
.
info
(
"################################## 编辑任务数据结束 ############################################"
);
}
else
{
dmpDevelopTaskDao
.
insert
(
task
);
//保存任务数据
logger
.
info
(
"################################## 新增任务数据结束 ############################################"
);
}
//保存时提交XML
//保存时提交XML
dmpDevelopTaskService
.
submitSyncing
(
task
);
dmpDevelopTaskService
.
submitSyncing
(
task
);
...
@@ -581,7 +646,7 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
...
@@ -581,7 +646,7 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
}
}
/**
/**
* 保存dmp数据校验信息
* 保存dmp数据校验
规则
信息
*
*
* @param taskId
* @param taskId
* @param rules
* @param rules
...
@@ -598,8 +663,6 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
...
@@ -598,8 +663,6 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
taskRuleT
.
setRuleValue
(
ruleValue
);
taskRuleT
.
setRuleValue
(
ruleValue
);
list
.
add
(
taskRuleT
);
list
.
add
(
taskRuleT
);
}
}
//dvTaskRuleTService.
//批量新增任务与规则关系表
//批量新增任务与规则关系表
dvTaskRuleTService
.
saveRule
(
list
);
dvTaskRuleTService
.
saveRule
(
list
);
}
}
...
...
src/main/resources/mapper/dmp/DvTaskRuleTMapper.xml
View file @
c96bbef5
...
@@ -132,4 +132,15 @@
...
@@ -132,4 +132,15 @@
delete from dmp_web.dv_task_rule_t where task_rule_id = #{taskRuleId}
delete from dmp_web.dv_task_rule_t where task_rule_id = #{taskRuleId}
</delete>
</delete>
<select
id=
"getTaskRuleIdsList"
resultType=
"java.lang.Long"
>
SELECT task_rule_id FROM dv_task_rule_t WHERE task_id=#{taskId}
</select>
<delete
id=
"delRulesByIds"
parameterType=
"java.lang.Long"
>
DELETE FROM dv_task_rule_t WHERE task_rule_id IN
<foreach
item=
"item"
collection=
"listRules"
separator=
","
open=
"("
close=
")"
index=
""
>
#{item}
</foreach>
</delete>
</mapper>
</mapper>
\ No newline at end of file
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