add - 模拟创建考勤补卡的流程模型, 同时调整JSON 格式转换逻辑
This commit is contained in:
parent
35822fcd86
commit
8caa08ac1a
@ -61,6 +61,7 @@ public class BpmnProcessInstanceCreateDTO {
|
||||
|
||||
@ApiModelProperty(value = "发起人信息")
|
||||
@Valid
|
||||
@NotNull(message = "发起人不能为空")
|
||||
private BpmnTaskDelegateAssigner initiator;
|
||||
|
||||
/**
|
||||
|
||||
@ -185,16 +185,22 @@ public final class BpmnJsonConverterUtil {
|
||||
mainProcess.addFlowElement(convertJsonToElement(StartEvent.class, mainProcess));
|
||||
|
||||
// 解析前端传入的模型设计 json
|
||||
String lastNodeId = create(bpmnJsonNode, mainProcess, bpmnModel, START_EVENT_ID);
|
||||
List<String> lastNodeIds = create(bpmnJsonNode, mainProcess, bpmnModel, START_EVENT_ID);
|
||||
|
||||
// 创建固定的结束节点
|
||||
mainProcess.addFlowElement(convertJsonToElement(EndEvent.class, mainProcess));
|
||||
|
||||
SequenceFlow sequenceFlow = new SequenceFlow();
|
||||
sequenceFlow.setId(id(SEQUENCE_FLOW_ID));
|
||||
sequenceFlow.setSourceRef(lastNodeId);
|
||||
sequenceFlow.setTargetRef(END_EVENT_ID);
|
||||
mainProcess.addFlowElement(sequenceFlow);
|
||||
if (CollectionUtils.isEmpty(lastNodeIds)) {
|
||||
throw new WorkflowEngineException(CONVERTOR_COMMON_ERROR, "未找到链接结束节点的节点数据");
|
||||
}
|
||||
|
||||
lastNodeIds.forEach(lastNodeId -> {
|
||||
SequenceFlow sequenceFlow = new SequenceFlow();
|
||||
sequenceFlow.setId(id(SEQUENCE_FLOW_ID));
|
||||
sequenceFlow.setSourceRef(lastNodeId);
|
||||
sequenceFlow.setTargetRef(END_EVENT_ID);
|
||||
mainProcess.addFlowElement(sequenceFlow);
|
||||
});
|
||||
new BpmnAutoLayout(bpmnModel).execute();
|
||||
return bpmnModel;
|
||||
}
|
||||
@ -369,7 +375,7 @@ public final class BpmnJsonConverterUtil {
|
||||
* @param bpmnModel 最终的 BPMN model
|
||||
* @return 创建的节点的 ID
|
||||
*/
|
||||
private static String create(BpmnJsonNode bpmnJsonNode, Process mainProcess,
|
||||
private static List<String> create(BpmnJsonNode bpmnJsonNode, Process mainProcess,
|
||||
BpmnModel bpmnModel, String... preNodeIds) {
|
||||
FLAT_NODE_MAP.put(bpmnJsonNode.getId(), bpmnJsonNode);
|
||||
// 设置来源节点
|
||||
@ -404,7 +410,7 @@ public final class BpmnJsonConverterUtil {
|
||||
case NODE_TRIGGER:
|
||||
// 这个类型目前暂不支持
|
||||
case NODE_CARBON_COPY:
|
||||
// 这里可以细化, 带后续有实际场景了,再处理, 现目前只有 "抄送" 功能可能会用到
|
||||
// 这里可以细化, 待后续有实际场景了,再处理, 现目前只有 "抄送" 功能可能会用到
|
||||
clz = ServiceTask.class;
|
||||
break;
|
||||
default:
|
||||
@ -451,7 +457,7 @@ public final class BpmnJsonConverterUtil {
|
||||
}
|
||||
|
||||
if (Objects.nonNull(branch.getChildren())) {
|
||||
branchLastNodeIds.add(create(branch.getChildren(), mainProcess, bpmnModel));
|
||||
branchLastNodeIds.addAll(create(branch.getChildren(), mainProcess, bpmnModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -459,7 +465,11 @@ public final class BpmnJsonConverterUtil {
|
||||
// 开始处理下级节点
|
||||
BpmnJsonNode children = bpmnJsonNode.getChildren();
|
||||
if (Objects.isNull(children) || Objects.equals(NODE_EMPTY, children.getType()) || !StringUtils.hasLength(children.getId())) {
|
||||
return flowElement.getId();
|
||||
if (CollectionUtils.isEmpty(branchLastNodeIds)) {
|
||||
return Lists.newArrayList(flowElement.getId());
|
||||
} else {
|
||||
return branchLastNodeIds;
|
||||
}
|
||||
} else {
|
||||
if (CollectionUtils.isEmpty(branchLastNodeIds)) {
|
||||
return create(children, mainProcess, bpmnModel, flowElement.getId());
|
||||
@ -522,7 +532,7 @@ public final class BpmnJsonConverterUtil {
|
||||
// String fileName = "/Users/wangli/work/company/yizhi/workflow-engine/workflow-engine-server/src/main" +
|
||||
// "/resources/权限点模型.json";
|
||||
String fileName = "/Users/wangli/work/company/yizhi/workflow-engine/workflow-engine-server/src/main" +
|
||||
"/resources/kaoqing.json";
|
||||
"/resources/test.json";
|
||||
byte[] bytes = Files.readAllBytes(Paths.get(fileName));
|
||||
String content = new String(bytes, StandardCharsets.UTF_8);
|
||||
|
||||
|
||||
@ -93,15 +93,18 @@ public class EngineTaskEventListener implements TaskListener {
|
||||
|
||||
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();
|
||||
FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();
|
||||
Optional<BpmnNoticeConf> noticeConfig =
|
||||
Optional<BpmnNoticeConf> optNoticeConfig =
|
||||
BpmnMetaParserHelper.getNoticeConfig(ProcessDefinitionUtil.getProcess(processInstance.getProcessDefinitionId()));
|
||||
assigners.stream().filter(i -> Objects.equals(delegateTask.getAssignee(), i.buildAssigneeId())).findAny()
|
||||
.ifPresent(i -> {
|
||||
MessagePushEventImpl event = MessagePushEventBuilder.createEvent(MessagePushEventType.NOTICE, i,
|
||||
noticeConfig.orElse(null), processInstance.getProcessInstanceId(),
|
||||
processInstance.getTenantId(), delegateTask.getId());
|
||||
eventDispatcher.dispatchEvent(event, processEngineConfiguration.getEngineCfgKey());
|
||||
});
|
||||
optNoticeConfig.ifPresent(noticeConf -> {
|
||||
assigners.stream().filter(i -> Objects.equals(delegateTask.getAssignee(), i.buildAssigneeId())).findAny()
|
||||
.ifPresent(i -> {
|
||||
MessagePushEventImpl event = MessagePushEventBuilder.createEvent(MessagePushEventType.PENDING
|
||||
, i,
|
||||
noticeConf, processInstance.getProcessInstanceId(),
|
||||
processInstance.getTenantId(), delegateTask.getId());
|
||||
eventDispatcher.dispatchEvent(event, processEngineConfiguration.getEngineCfgKey());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private List<BpmnTaskEventListener> getOrderedListeners() {
|
||||
|
||||
321
workflow-engine-server/src/main/resources/kaoqing.bpmn20.xml
Normal file
321
workflow-engine-server/src/main/resources/kaoqing.bpmn20.xml
Normal file
File diff suppressed because one or more lines are too long
@ -328,64 +328,74 @@
|
||||
"id": "5",
|
||||
"parentId": "4",
|
||||
"type": "NODE_TASK",
|
||||
"name": "排它网关",
|
||||
"children": {
|
||||
"name": "班组确认",
|
||||
"property": {
|
||||
"approvalMethod": "human",
|
||||
"approverScope": "projectWorkspace",
|
||||
"approverSpecify": "identity",
|
||||
"specifyValue": [
|
||||
"{\"assignee\":\"\",\"assigneeType\":\"\"}"
|
||||
],
|
||||
"multiMode": "AND",
|
||||
"approverEmptyHandleType": "autoPassed"
|
||||
}
|
||||
},
|
||||
"branches": [
|
||||
{
|
||||
"id": "6",
|
||||
"parentId": "5",
|
||||
"type": "NODE_TASK",
|
||||
"name": "班组确认",
|
||||
"property": {}
|
||||
},
|
||||
"branches": [
|
||||
{
|
||||
"id": "7",
|
||||
"parentId": "4",
|
||||
"type": "NODE_CONDITION",
|
||||
"name": "需分包审核",
|
||||
"children": {
|
||||
"id": "9",
|
||||
"parentId": "7",
|
||||
"type": "NODE_TASK",
|
||||
"name": "分包审核",
|
||||
"property": {
|
||||
"approvalMethod": "nobody"
|
||||
}
|
||||
},
|
||||
"parentId": "4",
|
||||
"type": "NODE_CONDITION",
|
||||
"name": "需分包审核",
|
||||
"children": {
|
||||
"id": "8",
|
||||
"parentId": "6",
|
||||
"type": "NODE_TASK",
|
||||
"name": "分包审核",
|
||||
"property": {
|
||||
"groups": [
|
||||
{
|
||||
"conditionsType": "or",
|
||||
"conditions": [
|
||||
{
|
||||
"fieldDataType": "number",
|
||||
"fieldCode": "type2",
|
||||
"operator": "eq"
|
||||
}
|
||||
]
|
||||
}
|
||||
"approvalMethod": "human",
|
||||
"approverScope": "projectWorkspace",
|
||||
"approverSpecify": "position",
|
||||
"specifyValue": [
|
||||
"{\"assignee\":\"\",\"assigneeType\":\"\"}"
|
||||
],
|
||||
"defaultBranch": false,
|
||||
"groupsType": "and"
|
||||
"multiMode": "AND",
|
||||
"approverEmptyHandleType": "autoPassed"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "8",
|
||||
"parentId": "4",
|
||||
"type": "NODE_CONDITION",
|
||||
"name": "无需分包审核",
|
||||
"property": {
|
||||
"defaultBranch": true
|
||||
}
|
||||
"property": {
|
||||
"groups": [
|
||||
{
|
||||
"conditionsType": "or",
|
||||
"conditions": [
|
||||
{
|
||||
"fieldDataType": "number",
|
||||
"fieldCode": "type2",
|
||||
"operator": "eq"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"defaultBranch": false,
|
||||
"groupsType": "and"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "7",
|
||||
"parentId": "4",
|
||||
"type": "NODE_CONDITION",
|
||||
"name": "无需分包审核",
|
||||
"property": {
|
||||
"defaultBranch": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "9",
|
||||
"parentId": "2",
|
||||
"type": "NODE_CONDITION",
|
||||
"name": "总包发起",
|
||||
"name": "班组发起",
|
||||
"property": {
|
||||
"groups": [
|
||||
{
|
||||
@ -399,7 +409,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"defaultBranch": false,
|
||||
"defaultBranch": true,
|
||||
"groupsType": "and"
|
||||
},
|
||||
"children": {
|
||||
@ -407,67 +417,74 @@
|
||||
"parentId": "9",
|
||||
"type": "NODE_EXCLUSIVE_GATEWAY",
|
||||
"children": {
|
||||
"id": "11",
|
||||
"parentId": "4",
|
||||
"id": "6",
|
||||
"parentId": "5",
|
||||
"type": "NODE_TASK",
|
||||
"name": "排它网关",
|
||||
"children": {
|
||||
"id": "6",
|
||||
"parentId": "5",
|
||||
"type": "NODE_TASK",
|
||||
"name": "班组确认",
|
||||
"property": {}
|
||||
},
|
||||
"branches": [
|
||||
{
|
||||
"id": "7",
|
||||
"parentId": "4",
|
||||
"type": "NODE_CONDITION",
|
||||
"name": "需分包审核",
|
||||
"children": {
|
||||
"id": "9",
|
||||
"parentId": "7",
|
||||
"type": "NODE_TASK",
|
||||
"name": "分包审核",
|
||||
"property": {
|
||||
"approvalMethod": "nobody"
|
||||
}
|
||||
},
|
||||
"name": "总包审核",
|
||||
"property": {
|
||||
"approvalMethod": "human",
|
||||
"approverScope": "projectWorkspace",
|
||||
"approverSpecify": "position",
|
||||
"specifyValue": [
|
||||
"{\"assignee\":\"\",\"assigneeType\":\"\"}"
|
||||
],
|
||||
"multiMode": "AND",
|
||||
"approverEmptyHandleType": "autoPassed"
|
||||
}
|
||||
},
|
||||
"branches": [
|
||||
{
|
||||
"id": "11",
|
||||
"parentId": "9",
|
||||
"type": "NODE_CONDITION",
|
||||
"name": "需分包审核",
|
||||
"children": {
|
||||
"id": "13",
|
||||
"parentId": "11",
|
||||
"type": "NODE_TASK",
|
||||
"name": "分包审核",
|
||||
"property": {
|
||||
"groups": [
|
||||
{
|
||||
"conditionsType": "or",
|
||||
"conditions": [
|
||||
{
|
||||
"fieldDataType": "number",
|
||||
"fieldCode": "type2",
|
||||
"operator": "eq"
|
||||
}
|
||||
]
|
||||
}
|
||||
"approvalMethod": "human",
|
||||
"approverScope": "projectWorkspace",
|
||||
"approverSpecify": "identity",
|
||||
"specifyValue": [
|
||||
"{\"assignee\":\"\",\"assigneeType\":\"\"}"
|
||||
],
|
||||
"defaultBranch": false,
|
||||
"groupsType": "and"
|
||||
"multiMode": "AND",
|
||||
"approverEmptyHandleType": "autoPassed"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "8",
|
||||
"parentId": "4",
|
||||
"type": "NODE_CONDITION",
|
||||
"name": "无需分包审核",
|
||||
"property": {
|
||||
"defaultBranch": true
|
||||
}
|
||||
"property": {
|
||||
"groups": [
|
||||
{
|
||||
"conditionsType": "or",
|
||||
"conditions": [
|
||||
{
|
||||
"fieldDataType": "number",
|
||||
"fieldCode": "type2",
|
||||
"operator": "eq"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"defaultBranch": false,
|
||||
"groupsType": "and"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "12",
|
||||
"parentId": "9",
|
||||
"type": "NODE_CONDITION",
|
||||
"name": "无需分包审核",
|
||||
"property": {
|
||||
"defaultBranch": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"property": null
|
||||
},
|
||||
"branches": null,
|
||||
"property": null
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user