Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Activity_Demo
Overview
Overview
Details
Activity
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
dengwei
Activity_Demo
Commits
ea43fb81
Commit
ea43fb81
authored
Oct 28, 2022
by
xuzhiyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
84f3734f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
14 deletions
+57
-14
pom.xml
pom.xml
+2
-6
SwaggerConfig.java
src/main/java/com/oyc/activiti/config/SwaggerConfig.java
+34
-0
ActivityProcessesController.java
.../oyc/activiti/controller/ActivityProcessesController.java
+21
-8
No files found.
pom.xml
View file @
ea43fb81
...
...
@@ -43,11 +43,7 @@
<version>
${crypto.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-project-info-reports-plugin
</artifactId>
<version>
3.0.0
</version>
</dependency>
<dependency>
...
...
@@ -64,7 +60,7 @@
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
8.0.21
</version>
</dependency>
<!-- druid -->
<dependency>
...
...
src/main/java/com/oyc/activiti/config/SwaggerConfig.java
View file @
ea43fb81
package
com
.
oyc
.
activiti
.
config
;
import
com.google.common.base.Predicates
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.service.Contact
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
/**
...
...
@@ -12,4 +20,30 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public
class
SwaggerConfig
{
@Bean
public
Docket
webApiConfig
(){
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
groupName
(
"webApi"
)
//调用apiInfo方法,创建一个ApiInfo实例,
// 里面是展示在文档页面信息内容
.
apiInfo
(
webApiInfo
())
.
select
()
.
paths
(
Predicates
.
not
(
PathSelectors
.
regex
(
"/admin/.*"
)))
.
paths
(
Predicates
.
not
(
PathSelectors
.
regex
(
"/error.*"
)))
.
build
();
}
// api文档的详细信息
private
ApiInfo
webApiInfo
(){
return
new
ApiInfoBuilder
()
.
title
(
"流程接口测试"
)
//标题
.
description
(
"本文档描述接口测试用例"
)
//描述
.
version
(
"1.0"
)
//版本
.
contact
(
new
Contact
(
"java"
,
"localhost:8083/swagger-ui.html"
,
"123@qq.com"
))
.
build
();
}
}
src/main/java/com/oyc/activiti/controller/ActivityProcessesController.java
View file @
ea43fb81
package
com
.
oyc
.
activiti
.
controller
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.activiti.bpmn.model.BpmnModel
;
import
org.activiti.bpmn.model.FlowNode
;
import
org.activiti.bpmn.model.SequenceFlow
;
...
...
@@ -47,6 +50,7 @@ import java.util.Map;
*/
@RestController
@RequestMapping
(
"processes"
)
@Api
(
tags
={
"流程接口"
})
public
class
ActivityProcessesController
{
@Resource
...
...
@@ -68,6 +72,7 @@ public class ActivityProcessesController {
* 部署申请流程
*/
@GetMapping
(
"deploy"
)
@ApiOperation
(
value
=
"部署申请流程"
,
notes
=
"部署申请流程"
)
public
ResponseEntity
<
Map
<
String
,
Object
>>
deployProcesses
()
{
HashMap
<
String
,
Object
>
resultMap
=
new
HashMap
<>(
8
);
//部署对象
...
...
@@ -91,7 +96,8 @@ public class ActivityProcessesController {
* 启动申请流程--传入申请流程的key
*/
@GetMapping
(
"start"
)
public
ResponseEntity
startProcessByKey
(
@RequestParam
String
processesKey
)
{
@ApiOperation
(
value
=
"启动申请流程"
,
notes
=
"传入申请流程的key"
)
public
ResponseEntity
startProcessByKey
(
@ApiParam
(
value
=
"申请流程的key"
,
required
=
true
)
@RequestParam
String
processesKey
)
{
HashMap
<
String
,
Object
>
resultMap
=
new
HashMap
<>(
8
);
ProcessInstance
processInstance
=
runtimeService
.
startProcessInstanceByKey
(
processesKey
);
resultMap
.
put
(
"id"
,
processInstance
.
getId
());
...
...
@@ -110,7 +116,8 @@ public class ActivityProcessesController {
* @param userName 用户名(zhangsan)
*/
@GetMapping
(
"task"
)
public
ResponseEntity
getTaskByUserName
(
@RequestParam
String
processDefinitionKey
,
@RequestParam
String
userName
)
{
@ApiOperation
(
value
=
"获取待办流程"
,
notes
=
"根据流程key和用户名获取待办流程"
)
public
ResponseEntity
getTaskByUserName
(
@ApiParam
(
value
=
"申请流程的key"
,
required
=
true
)
@RequestParam
String
processDefinitionKey
,
@ApiParam
(
value
=
"用户名"
,
required
=
true
)
@RequestParam
String
userName
)
{
ArrayList
<
Object
>
resultList
=
new
ArrayList
<>();
List
<
Task
>
taskList
=
taskService
.
createTaskQuery
()
.
processDefinitionKey
(
processDefinitionKey
)
...
...
@@ -148,7 +155,8 @@ public class ActivityProcessesController {
* @throws
*/
@GetMapping
(
"completeTask"
)
public
ResponseEntity
completeTaskById
(
@RequestParam
String
taskId
)
{
@ApiOperation
(
value
=
"完成任务"
,
notes
=
"根据任务id完成任务"
)
public
ResponseEntity
completeTaskById
(
@ApiParam
(
value
=
"任务id"
,
required
=
true
)
@RequestParam
String
taskId
)
{
taskService
.
complete
(
taskId
);
return
ResponseEntity
.
ok
(
String
.
format
(
"任务id为:%s 已经完成"
,
taskId
));
}
...
...
@@ -161,7 +169,8 @@ public class ActivityProcessesController {
* @throws
*/
@GetMapping
(
"assigneeTask"
)
public
ResponseEntity
assigneeTaskById
(
@RequestParam
String
taskId
,
@RequestParam
String
userName
)
{
@ApiOperation
(
value
=
"任务委派"
,
notes
=
"根据任务id委派(转派、转交)给指定用户"
)
public
ResponseEntity
assigneeTaskById
(
@ApiParam
(
value
=
"任务id"
,
required
=
true
)
@RequestParam
String
taskId
,
@ApiParam
(
value
=
"用户名称"
,
required
=
true
)
@RequestParam
String
userName
)
{
taskService
.
setAssignee
(
taskId
,
userName
);
return
ResponseEntity
.
ok
(
String
.
format
(
"任务id为:%s 已经委派(转派、转交)给 %s"
,
taskId
,
userName
));
}
...
...
@@ -174,7 +183,8 @@ public class ActivityProcessesController {
* @throws
*/
@GetMapping
(
"suspendOrActivateProcessDefinition"
)
public
ResponseEntity
suspendOrActivateProcessDefinition
(
@RequestParam
String
processDefinitionId
)
{
@ApiOperation
(
value
=
"挂起激活流程定义"
,
notes
=
"挂起激活流程定义"
)
public
ResponseEntity
suspendOrActivateProcessDefinition
(
@ApiParam
(
value
=
"流程定义Id"
,
required
=
true
)
@RequestParam
String
processDefinitionId
)
{
// 获得流程定义
ProcessDefinition
processDefinition
=
repositoryService
.
createProcessDefinitionQuery
()
...
...
@@ -200,7 +210,8 @@ public class ActivityProcessesController {
* 生成流程图
*/
@RequestMapping
(
"createProcessImg"
)
public
void
createProcessImg
(
@RequestParam
String
processInstanceId
,
HttpServletResponse
response
)
throws
Exception
{
@ApiOperation
(
value
=
"生成流程图"
,
notes
=
"生成流程图"
)
public
void
createProcessImg
(
@ApiParam
(
value
=
"流程Id"
,
required
=
true
)
@RequestParam
String
processInstanceId
,
HttpServletResponse
response
)
throws
Exception
{
//获取历史流程实例
HistoricProcessInstance
processInstance
=
historyService
.
createHistoricProcessInstanceQuery
().
processInstanceId
(
processInstanceId
).
singleResult
();
//根据流程定义获取输入流
...
...
@@ -225,7 +236,8 @@ public class ActivityProcessesController {
* 生成流程图
*/
@RequestMapping
(
"viewProcessImg"
)
public
void
viewProcessImg
(
@RequestParam
String
processInstanceId
,
HttpServletResponse
response
)
throws
Exception
{
@ApiOperation
(
value
=
"生成流程图"
,
notes
=
"生成流程图"
)
public
void
viewProcessImg
(
@ApiParam
(
value
=
"流程Id"
,
required
=
true
)
@RequestParam
String
processInstanceId
,
HttpServletResponse
response
)
throws
Exception
{
//获取历史流程实例
try
{
HistoricProcessInstance
processInstance
=
historyService
.
createHistoricProcessInstanceQuery
().
processInstanceId
(
processInstanceId
).
singleResult
();
...
...
@@ -242,7 +254,8 @@ public class ActivityProcessesController {
* 生成流程图(高亮)
*/
@RequestMapping
(
"viewProcessImgHighLighted"
)
public
void
viewProcessImgHighLighted
(
@RequestParam
String
processInstanceId
,
HttpServletResponse
response
)
{
@ApiOperation
(
value
=
"生成流程图(高亮)"
,
notes
=
"生成流程图(高亮)"
)
public
void
viewProcessImgHighLighted
(
@ApiParam
(
value
=
"流程Id"
,
required
=
true
)
@RequestParam
String
processInstanceId
,
HttpServletResponse
response
)
{
try
{
byte
[]
processImage
=
getProcessImage
(
processInstanceId
);
OutputStream
outputStream
=
response
.
getOutputStream
();
...
...
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