Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
三久
DolphinScheduler
提交
9a89d594
DolphinScheduler
项目概览
三久
/
DolphinScheduler
与 Fork 源项目一致
Fork自
apache / DolphinScheduler
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DolphinScheduler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9a89d594
编写于
5月 13, 2019
作者:
L
ligang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add batchDeleteProcessInstanceByIds
上级
98450c7b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
82 addition
and
0 deletion
+82
-0
escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessInstanceController.java
.../escheduler/api/controller/ProcessInstanceController.java
+26
-0
escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java
...ler-api/src/main/java/cn/escheduler/api/enums/Status.java
+1
-0
escheduler-api/src/main/java/cn/escheduler/api/service/ProcessInstanceService.java
...ava/cn/escheduler/api/service/ProcessInstanceService.java
+43
-0
escheduler-api/src/test/java/cn/escheduler/api/service/ProcessInstanceServiceTest.java
...cn/escheduler/api/service/ProcessInstanceServiceTest.java
+12
-0
未找到文件。
escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessInstanceController.java
浏览文件 @
9a89d594
...
@@ -282,4 +282,30 @@ public class ProcessInstanceController extends BaseController{
...
@@ -282,4 +282,30 @@ public class ProcessInstanceController extends BaseController{
return
error
(
Status
.
ENCAPSULATION_PROCESS_INSTANCE_GANTT_STRUCTURE_ERROR
.
getCode
(),
ENCAPSULATION_PROCESS_INSTANCE_GANTT_STRUCTURE_ERROR
.
getMsg
());
return
error
(
Status
.
ENCAPSULATION_PROCESS_INSTANCE_GANTT_STRUCTURE_ERROR
.
getCode
(),
ENCAPSULATION_PROCESS_INSTANCE_GANTT_STRUCTURE_ERROR
.
getMsg
());
}
}
}
}
/**
* batch delete process instance by ids, at the same time,
* delete task instance and their mapping relation data
*
* @param loginUser
* @param projectName
* @param processInstanceIds
* @return
*/
@GetMapping
(
value
=
"/batch-delete"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
Result
batchDeleteProcessInstanceByIds
(
@RequestAttribute
(
value
=
Constants
.
SESSION_USER
)
User
loginUser
,
@PathVariable
String
projectName
,
@RequestParam
(
"processInstanceIds"
)
String
processInstanceIds
){
try
{
logger
.
info
(
"delete process instance by ids, login user:{}, project name:{}, process instance ids :{}"
,
loginUser
.
getUserName
(),
projectName
,
processInstanceIds
);
Map
<
String
,
Object
>
result
=
processInstanceService
.
batchDeleteProcessInstanceByIds
(
loginUser
,
projectName
,
processInstanceIds
);
return
returnDataList
(
result
);
}
catch
(
Exception
e
){
logger
.
error
(
BATCH_DELETE_PROCESS_INSTANCE_BY_IDS_ERROR
.
getMsg
(),
e
);
return
error
(
Status
.
BATCH_DELETE_PROCESS_INSTANCE_BY_IDS_ERROR
.
getCode
(),
Status
.
BATCH_DELETE_PROCESS_INSTANCE_BY_IDS_ERROR
.
getMsg
());
}
}
}
}
escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java
浏览文件 @
9a89d594
...
@@ -160,6 +160,7 @@ public enum Status {
...
@@ -160,6 +160,7 @@ public enum Status {
NAME_EXIST
(
10135
,
"name {0} already exists"
),
NAME_EXIST
(
10135
,
"name {0} already exists"
),
SAVE_ERROR
(
10136
,
"save error"
),
SAVE_ERROR
(
10136
,
"save error"
),
DELETE_PROJECT_ERROR_DEFINES_NOT_NULL
(
10137
,
"please delete the process definitions in project first!"
),
DELETE_PROJECT_ERROR_DEFINES_NOT_NULL
(
10137
,
"please delete the process definitions in project first!"
),
BATCH_DELETE_PROCESS_INSTANCE_BY_IDS_ERROR
(
10117
,
"batch delete process instance by ids {0} error"
),
...
...
escheduler-api/src/main/java/cn/escheduler/api/service/ProcessInstanceService.java
浏览文件 @
9a89d594
...
@@ -467,6 +467,7 @@ public class ProcessInstanceService extends BaseDAGService {
...
@@ -467,6 +467,7 @@ public class ProcessInstanceService extends BaseDAGService {
putMsg
(
result
,
Status
.
PROCESS_INSTANCE_NOT_EXIST
,
workflowId
);
putMsg
(
result
,
Status
.
PROCESS_INSTANCE_NOT_EXIST
,
workflowId
);
return
result
;
return
result
;
}
}
int
delete
=
processDao
.
deleteWorkProcessInstanceById
(
workflowId
);
int
delete
=
processDao
.
deleteWorkProcessInstanceById
(
workflowId
);
processDao
.
deleteAllSubWorkProcessByParentId
(
workflowId
);
processDao
.
deleteAllSubWorkProcessByParentId
(
workflowId
);
processDao
.
deleteWorkProcessMapByParentId
(
workflowId
);
processDao
.
deleteWorkProcessMapByParentId
(
workflowId
);
...
@@ -479,6 +480,48 @@ public class ProcessInstanceService extends BaseDAGService {
...
@@ -479,6 +480,48 @@ public class ProcessInstanceService extends BaseDAGService {
return
result
;
return
result
;
}
}
/**
* batch delete process instance by ids, at the same time,delete task instance and their mapping relation data
*
* @param loginUser
* @param projectName
* @param processInstanceIds
* @return
*/
public
Map
<
String
,
Object
>
batchDeleteProcessInstanceByIds
(
User
loginUser
,
String
projectName
,
String
processInstanceIds
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>(
5
);
List
<
Integer
>
deleteFailedIdList
=
new
ArrayList
<
Integer
>();
Project
project
=
projectMapper
.
queryByName
(
projectName
);
Map
<
String
,
Object
>
checkResult
=
projectService
.
checkProjectAndAuth
(
loginUser
,
project
,
projectName
);
Status
resultEnum
=
(
Status
)
checkResult
.
get
(
Constants
.
STATUS
);
if
(
resultEnum
!=
Status
.
SUCCESS
)
{
return
checkResult
;
}
if
(
StringUtils
.
isNotEmpty
(
processInstanceIds
)){
String
[]
processInstanceIdArray
=
processInstanceIds
.
split
(
","
);
for
(
String
strProcessInstanceId:
processInstanceIdArray
)
{
int
processInstanceId
=
Integer
.
parseInt
(
strProcessInstanceId
);
try
{
deleteProcessInstanceById
(
loginUser
,
projectName
,
processInstanceId
);
}
catch
(
Exception
e
)
{
deleteFailedIdList
.
add
(
processInstanceId
);
}
}
}
if
(
deleteFailedIdList
.
size
()
>
0
){
putMsg
(
result
,
Status
.
BATCH_DELETE_PROCESS_INSTANCE_BY_IDS_ERROR
,
StringUtils
.
join
(
deleteFailedIdList
.
toArray
(),
","
));
}
else
{
putMsg
(
result
,
Status
.
SUCCESS
);
}
return
result
;
}
/**
/**
* view process instance variables
* view process instance variables
*
*
...
...
escheduler-api/src/test/java/cn/escheduler/api/service/ProcessInstanceServiceTest.java
浏览文件 @
9a89d594
...
@@ -75,4 +75,16 @@ public class ProcessInstanceServiceTest {
...
@@ -75,4 +75,16 @@ public class ProcessInstanceServiceTest {
Assert
.
assertEquals
(
Status
.
SUCCESS
,
map
.
get
(
Constants
.
STATUS
));
Assert
.
assertEquals
(
Status
.
SUCCESS
,
map
.
get
(
Constants
.
STATUS
));
logger
.
info
(
JSON
.
toJSONString
(
map
));
logger
.
info
(
JSON
.
toJSONString
(
map
));
}
}
@Test
public
void
batchDeleteProcessInstanceByIds
()
throws
Exception
{
User
loginUser
=
new
User
();
loginUser
.
setId
(
2
);
loginUser
.
setUserType
(
UserType
.
GENERAL_USER
);
Map
<
String
,
Object
>
map
=
processInstanceService
.
batchDeleteProcessInstanceByIds
(
loginUser
,
"li_test_1"
,
"4,2,300"
);
Assert
.
assertEquals
(
Status
.
SUCCESS
,
map
.
get
(
Constants
.
STATUS
));
logger
.
info
(
JSON
.
toJSONString
(
map
));
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录