Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datacollector
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
chenweisong
datacollector
Commits
f505809d
Commit
f505809d
authored
Mar 26, 2020
by
chenweisong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
807c0272
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
196 deletions
+0
-196
SubProcessCtrl.java
...in/java/com/keymobile/rest/controller/SubProcessCtrl.java
+0
-196
No files found.
src/main/java/com/keymobile/rest/controller/SubProcessCtrl.java
deleted
100644 → 0
View file @
807c0272
package
com
.
keymobile
.
rest
.
controller
;
import
com.keymobile.rest.common.utils.DateUtil
;
import
io.swagger.annotations.ApiOperation
;
import
org.activiti.engine.HistoryService
;
import
org.activiti.engine.RepositoryService
;
import
org.activiti.engine.RuntimeService
;
import
org.activiti.engine.TaskService
;
import
org.activiti.engine.history.HistoricTaskInstance
;
import
org.activiti.engine.repository.Deployment
;
import
org.activiti.engine.repository.DeploymentBuilder
;
import
org.activiti.engine.runtime.ProcessInstance
;
import
org.activiti.engine.task.Comment
;
import
org.activiti.engine.task.Task
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.*
;
//@RestController
//@RequestMapping(path = "/rest/subprocess")
public
class
SubProcessCtrl
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
SubProcessCtrl
.
class
);
@Autowired
private
RepositoryService
repositoryService
;
@Autowired
private
RuntimeService
runtimeService
;
@Autowired
private
TaskService
taskService
;
@Autowired
private
HistoryService
historyService
;
@ApiOperation
(
value
=
"部署流程"
)
@PostMapping
(
value
=
"/deployment"
)
public
String
deloymentProcess
(
@RequestParam
MultipartFile
file
)
{
String
message
=
null
;
String
fileName
=
file
.
getOriginalFilename
();
try
{
DeploymentBuilder
deployBuilder
=
repositoryService
.
createDeployment
();
if
(
fileName
.
endsWith
(
".bpmn"
))
{
Deployment
deployment
=
deployBuilder
.
addInputStream
(
fileName
,
file
.
getInputStream
()).
deploy
();
logger
.
info
(
deployment
.
getName
());
logger
.
info
(
deployment
.
getId
());
logger
.
info
(
deployment
.
getDeploymentTime
().
toString
());
message
=
"部署流程成功"
;
}
else
{
message
=
"上传文件格式不是bpmn"
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
=
"部署流程发生未知错误"
;
}
return
message
;
}
@ApiOperation
(
value
=
"发起流程并录入"
)
@PostMapping
(
value
=
"/startProcessAndSubmit"
)
public
String
startProcess
(
@RequestParam
String
processKey
,
@RequestParam
String
inputUser
)
{
StringBuilder
message
=
new
StringBuilder
();
message
.
append
(
""
);
ProcessInstance
pi
=
null
;
try
{
Map
<
String
,
Object
>
variables
=
new
HashMap
<>();
variables
.
put
(
"inputUser"
,
inputUser
);
//启动流程
pi
=
runtimeService
.
startProcessInstanceByKey
(
processKey
,
variables
);
//根据流程实例id和发起流程用户获取当前任务
Task
resultTask
=
taskService
.
createTaskQuery
().
processInstanceId
(
pi
.
getId
()).
taskInvolvedUser
(
inputUser
).
singleResult
();
//直接提交标准到下个节点
taskService
.
claim
(
resultTask
.
getId
(),
inputUser
);
//保存审批意见
taskService
.
addComment
(
resultTask
.
getId
(),
pi
.
getId
(),
""
);
//审批任务
taskService
.
complete
(
resultTask
.
getId
());
logger
.
info
(
"流程启动成功,流程id:"
+
pi
.
getId
()
+
",当前任务id:"
+
resultTask
.
getId
());
message
.
append
(
"流程启动成功,流程id:"
).
append
(
pi
.
getId
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
.
append
(
"流程启动发生未知错误"
);
}
return
message
.
toString
();
}
@ApiOperation
(
value
=
"获取待办任务列表"
)
@PostMapping
(
value
=
"/getTaskListByUser"
)
public
List
<
Map
<
String
,
Object
>>
getTaskListByUser
(
@RequestParam
String
user
)
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
List
<
Task
>
resultTask
=
taskService
.
createTaskQuery
().
taskInvolvedUser
(
user
).
list
();
for
(
Task
task
:
resultTask
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"taskId"
,
task
.
getId
());
map
.
put
(
"name"
,
task
.
getName
());
map
.
put
(
"createTime"
,
DateUtil
.
formatDate
(
task
.
getCreateTime
(),
"yyyy-MM-dd HH:mm:ss"
));
map
.
put
(
"processInstanceId"
,
task
.
getProcessInstanceId
());
result
.
add
(
map
);
}
return
result
;
}
@ApiOperation
(
value
=
"审批任务"
)
@PostMapping
(
value
=
"/completeTask"
)
public
String
completeTask
(
@RequestParam
String
taskId
,
@RequestParam
String
user
,
@RequestParam
(
value
=
"result"
,
required
=
false
)
String
result
,
@RequestParam
(
value
=
"assignees"
,
required
=
false
)
String
assignees
,
@RequestParam
String
processInstanceId
,
@RequestParam
(
value
=
"comment"
,
required
=
false
)
String
comment
,
@RequestParam
(
value
=
"applySign"
,
required
=
false
)
String
applySign
)
{
String
message
=
null
;
try
{
if
(
StringUtils
.
isBlank
(
comment
))
{
comment
=
""
;
}
//根据任务id获取当前任务信息
Task
task
=
taskService
.
createTaskQuery
()
// 创建任务查询
.
taskId
(
taskId
)
// 根据任务id查询
.
singleResult
();
Map
<
String
,
Object
>
vars
=
new
HashMap
<>();
//如果是开始录入环节,需要给出子任务录入人员
if
(
task
.
getTaskDefinitionKey
().
indexOf
(
"startEntry"
)
>=
0
)
{
if
(
StringUtils
.
isNotBlank
(
assignees
))
{
String
[]
commentUsers
=
assignees
.
split
(
","
);
vars
.
put
(
"candiateUserList"
,
Arrays
.
asList
(
commentUsers
));
}
}
//认领任务
taskService
.
setAssignee
(
taskId
,
user
);
//保存审批意见
taskService
.
addComment
(
taskId
,
processInstanceId
,
comment
);
//如果需要动态设置参与者
if
(
task
.
getTaskDefinitionKey
().
indexOf
(
"startEntry"
)
<
0
)
{
if
(
StringUtils
.
isNotBlank
(
assignees
))
{
vars
.
put
(
"inputDataApply"
,
assignees
);
}
}
//如果需要审批结果
if
(
StringUtils
.
isNotBlank
(
result
))
{
vars
.
put
(
"_ACTIVITI_SKIP_EXPRESSION_ENABLED"
,
true
);
vars
.
put
(
"sign"
,
result
);
}
//是否跳过负责人审批环节
if
(
StringUtils
.
isNotBlank
(
applySign
))
{
vars
.
put
(
"_ACTIVITI_SKIP_EXPRESSION_ENABLED"
,
true
);
vars
.
put
(
"applySign"
,
applySign
);
}
taskService
.
complete
(
taskId
,
vars
);
message
=
"审批成功"
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
=
"审批失败"
;
}
return
message
;
}
@ApiOperation
(
value
=
"获取审批详情"
)
@PostMapping
(
value
=
"/getTaskDetail"
)
public
List
<
Map
<
String
,
Object
>>
getTaskDetail
(
@RequestParam
String
processInstanceId
)
{
List
<
Map
<
String
,
Object
>>
details
=
new
ArrayList
<>();
List
<
HistoricTaskInstance
>
htiList
=
historyService
.
createHistoricTaskInstanceQuery
()
//历史任务表查询
.
processInstanceId
(
processInstanceId
)
//使用流程实例ID查询
.
orderByTaskCreateTime
().
asc
()
//根据任务创建时间进行排序
.
list
();
for
(
HistoricTaskInstance
hti
:
htiList
)
{
Map
<
String
,
Object
>
detail
=
new
HashMap
<>();
//获取任务id
String
taskId
=
hti
.
getId
();
//根据任务id去comment表获取批注信息
List
<
Comment
>
comments
=
taskService
.
getTaskComments
(
taskId
);
//comment不为空
if
(!
comments
.
isEmpty
())
{
detail
.
put
(
"taskName"
,
hti
.
getName
());
detail
.
put
(
"assignee"
,
hti
.
getAssignee
());
detail
.
put
(
"comment"
,
comments
.
get
(
0
).
getFullMessage
());
detail
.
put
(
"startTime"
,
DateUtil
.
formatDate
(
hti
.
getCreateTime
(),
"yyyy-MM-dd HH:mm:ss"
));
detail
.
put
(
"endTime"
,
DateUtil
.
formatDate
(
hti
.
getEndTime
(),
"yyyy-MM-dd HH:mm:ss"
));
details
.
add
(
detail
);
}
}
return
details
;
}
}
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