提交 c231f6ec 编写于 作者: zhouweidong's avatar zhouweidong

工作流抄送

上级 f7d86193
...@@ -27,6 +27,7 @@ import org.flowable.identitylink.api.IdentityLinkType; ...@@ -27,6 +27,7 @@ import org.flowable.identitylink.api.IdentityLinkType;
import org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntity; import org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntity;
import org.flowable.task.api.Task; import org.flowable.task.api.Task;
import org.flowable.task.service.impl.persistence.entity.TaskEntity; import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.context.expression.MapAccessor; import org.springframework.context.expression.MapAccessor;
...@@ -286,7 +287,7 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener { ...@@ -286,7 +287,7 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener {
} }
} }
} }
else if(evt instanceof FlowableEntityEventImpl && evt.getType() != null && FlowableEngineEventType.PROCESS_COMPLETED == evt.getType() ) else if(evt instanceof FlowableEntityEventImpl && evt.getType() != null && FlowableEngineEventType.PROCESS_COMPLETED == evt.getType())
{ {
FlowableEntityEventImpl event=((FlowableEntityEventImpl) evt); FlowableEntityEventImpl event=((FlowableEntityEventImpl) evt);
FlowableEventType eventType = event.getType(); FlowableEventType eventType = event.getType();
...@@ -322,33 +323,29 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener { ...@@ -322,33 +323,29 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener {
} }
} }
else if(evt instanceof FlowableActivityEventImpl) { else if(evt instanceof FlowableActivityEventImpl && evt.getType() != null && FlowableEngineEventType.ACTIVITY_COMPLETED == evt.getType()) {
FlowableActivityEventImpl event = ((FlowableActivityEventImpl) evt); FlowableActivityEventImpl event = ((FlowableActivityEventImpl) evt);
FlowableEventType eventType = event.getType();
if (eventType == FlowableEngineEventType.ACTIVITY_COMPLETED && "userTask".equals(event.getActivityType())) {
if (event.getExecution().getCurrentFlowElement() instanceof UserTask) { if (event.getExecution().getCurrentFlowElement() instanceof UserTask) {
UserTask task = (UserTask) event.getExecution().getCurrentFlowElement(); UserTask task = (UserTask) event.getExecution().getCurrentFlowElement();
List<Task> exTask = taskService.createTaskQuery().processInstanceId(event.getProcessInstanceId()).list(); String procFunc = wfCoreService.getParam(task, "form", "procfunc");
String sendCopyTag = wfCoreService.getParam(task,"form","procfunc"); if (!StringUtils.isEmpty(procFunc) && procFunc.contains("sendcopy")) {
if(sendCopyTag.contains("sendcopy")){ String sendCopyRoles = wfCoreService.getParam(task, "form", "senduser");
// 从模板中读取抄送人名单 if (StringUtils.isEmpty(sendCopyRoles)) {
String sendCopyUserList = wfCoreService.getParam(task,"form","senduser"); throw new BadRequestAlertException("获取节点抄送用户失败", "", "");
if(StringUtils.isEmpty(sendCopyUserList)){ }
throw new BadRequestAlertException("获取节点抄送用户失败","",""); TaskEntity sendCopyTask = new TaskEntityImpl();
} List<Task> sendCopyTasks = taskService.createTaskQuery().processInstanceId(event.getProcessInstanceId()).list();
String userIds = wfCoreService.getGroupUsers(sendCopyUserList, event.getExecution()); Set<WFMember> sendCopyUsers = wfCoreService.getGroupUsers2(sendCopyRoles, event.getExecution());
TaskEntity sendCopyTask = null; if (sendCopyTasks.size() > 0) {
if(exTask.size()>0){ sendCopyTask = wfCoreService.createTask(sendCopyTasks.get(0));
sendCopyTask = wfCoreService.createTask(exTask.get(0));
} }
sendCopyTask.setId(UUID.randomUUID().toString().toLowerCase()); sendCopyTask.setId(UUID.randomUUID().toString().toLowerCase());
sendCopyTask.setScopeType("sendcopy"); sendCopyTask.setScopeType("sendcopy");
taskService.saveTask(sendCopyTask); taskService.saveTask(sendCopyTask);
// 生成待阅抄送给用户 // 生成待阅抄送给用户
if(!StringUtils.isEmpty(userIds)){ if(!ObjectUtils.isEmpty(sendCopyUsers)){
for (String userid : userIds.split(",")) { for (WFMember user : sendCopyUsers) {
taskService.addUserIdentityLink(sendCopyTask.getId(), userid, "sendcopy"); taskService.addUserIdentityLink(sendCopyTask.getId(), user.getUserid(), "sendcopy");
}
} }
} }
} }
......
...@@ -1923,7 +1923,7 @@ public class WFCoreService ...@@ -1923,7 +1923,7 @@ public class WFCoreService
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId); List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
identityLinks.forEach(idl->{ identityLinks.forEach(idl->{
if(userId.equals(idl.getUserId())){ if(userId.equals(idl.getUserId())){
completeSendCopy(identityLinks,task,userId); completeSendCopyTask(identityLinks,task);
Map map =new HashMap(); Map map =new HashMap();
map.put("taskid",task.getId()); map.put("taskid",task.getId());
map.put("userid",userId); map.put("userid",userId);
...@@ -1938,16 +1938,13 @@ public class WFCoreService ...@@ -1938,16 +1938,13 @@ public class WFCoreService
* 判断除了本身其他link是否已读 * 判断除了本身其他link是否已读
* @return * @return
*/ */
public void completeSendCopy(List<IdentityLink> identityLinks,Task task,String userId){ public void completeSendCopyTask(List<IdentityLink> identityLinks,Task task){
List<IdentityLink> noReadLinks = identityLinks.stream().filter(link -> StringUtils.isEmpty(link.getScopeType())).collect(Collectors.toList()); List<IdentityLink> unReadLinks = identityLinks.stream().filter(link -> StringUtils.isEmpty(link.getScopeType())).collect(Collectors.toList());
// 全部消息已读之后,将抄送任务推送到history表中 String scopeType = task.getScopeType();
String type = task.getScopeType() == null ? "" : task.getScopeType(); if (!StringUtils.isEmpty(scopeType) && "sendcopy".equals(scopeType) && unReadLinks.size() == 1) {
if(type.equals("sendcopy") && noReadLinks.size() == 1){
if(noReadLinks.get(0).getUserId().equals(userId)){
taskService.complete(task.getId()); taskService.complete(task.getId());
} }
} }
}
/** /**
* @param taskId 当前需要回退的节点 * @param taskId 当前需要回退的节点
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册