因为这个项目license问题无法开源,更多技术支持与服务请加入我的知识星球。
1、因为仿钉钉设计器里发送消息处理是一个服务任务,所以要根据这个服务任务进行处理
2、这里目前只对消息进行处理,就是用websocket的发送方式
输入相应的内容,这里也用扩展属性来处理
3、相应的后端代码如下:
public class NotifyNode extends AssigneeNode {
private List<NotifyTypeEnum> types;
private String subject;
private String content;
@Override
public List<FlowElement> convert() {
ArrayList<FlowElement> elements = new ArrayList<>();
// 服务节点
ServiceTask serviceTask = new ServiceTask();
serviceTask.setId(this.getId());
serviceTask.setName(this.getName());
serviceTask.setAsynchronous(false);
serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
serviceTask.setImplementation("org.jeecg.modules.flowable.ServiceTask.notifyDelegate");
//增加扩展属性 add by nbacheng
Map<String, List<ExtensionElement>> extensionElements = new HashMap<String, List<ExtensionElement>>();
ExtensionElement extensionElementTotal = new ExtensionElement();
extensionElementTotal.setName("flowable:properties");
ExtensionElement eElementUser = new ExtensionElement();
eElementUser.setName("flowable:property");
ExtensionAttribute eAttributeUserName = new ExtensionAttribute();
eAttributeUserName.setName("name");
eAttributeUserName.setValue("notifyUserList");
eElementUser.addAttribute(eAttributeUserName);
ExtensionAttribute eAttributeUserValue = new ExtensionAttribute();
eAttributeUserValue.setName("value");
eAttributeUserValue.setValue(StringUtils.join(this.getUsers(), ","));
eElementUser.addAttribute(eAttributeUserValue);
extensionElementTotal.addChildElement(eElementUser);
ExtensionElement eElementSubject = new ExtensionElement();
eElementSubject.setName("flowable:property");
ExtensionAttribute eAttributeSubjectName = new ExtensionAttribute();
eAttributeSubjectName.setName("name");
eAttributeSubjectName.setValue("subject");
eElementSubject.addAttribute(eAttributeSubjectName);
ExtensionAttribute eAttributeSubjectValue = new ExtensionAttribute();
eAttributeSubjectValue.setName("value");
eAttributeSubjectValue.setValue(this.getSubject());
eElementSubject.addAttribute(eAttributeSubjectValue);
extensionElementTotal.addChildElement(eElementSubject);
ExtensionElement eElementContent = new ExtensionElement();
eElementContent.setName("flowable:property");
ExtensionAttribute eAttributeContent = new ExtensionAttribute();
eAttributeContent.setName("name");
eAttributeContent.setValue("content");
eElementContent.addAttribute(eAttributeContent);
ExtensionAttribute eAttributeContentValue = new ExtensionAttribute();
eAttributeContentValue.setName("value");
eAttributeContentValue.setValue(this.getContent());
eElementContent.addAttribute(eAttributeContentValue);
extensionElementTotal.addChildElement(eElementContent);
extensionElements.put("notifyUserList", CollUtil.newArrayList(extensionElementTotal));
serviceTask.setExtensionElements(extensionElements);
elements.add(serviceTask);
// 下一个节点的连线
Node child = this.getChild();
SequenceFlow sequenceFlow = this.buildSequence(child);
elements.add(sequenceFlow);
// 下一个节点
if (Objects.nonNull(child)) {
child.setBranchId(this.getBranchId());
List<FlowElement> flowElements = child.convert();
elements.addAll(flowElements);
}
return elements;
}
}
4、相应的效果图