|
@@ -3,14 +3,16 @@ package com.qmth.distributed.print.business.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
+import com.qmth.distributed.print.business.activiti.custom.service.DefaultInstanceConvertToMultiInstance;
|
|
|
+import com.qmth.distributed.print.business.activiti.custom.service.MultiWorkFlow;
|
|
|
import com.qmth.distributed.print.business.bean.flow.CustomFlowDto;
|
|
|
+import com.qmth.distributed.print.business.bean.flow.CustomFlowPropertyDto;
|
|
|
import com.qmth.distributed.print.business.bean.flow.CustomFlowSaveDto;
|
|
|
+import com.qmth.distributed.print.business.bean.flow.link.FlowTaskLink;
|
|
|
+import com.qmth.distributed.print.business.bean.flow.link.FlowTaskNode;
|
|
|
import com.qmth.distributed.print.business.bean.result.*;
|
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
|
-import com.qmth.distributed.print.business.enums.CustomFlowDynamicBuildEnum;
|
|
|
-import com.qmth.distributed.print.business.enums.CustomFlowTypeEnum;
|
|
|
-import com.qmth.distributed.print.business.enums.ExamStatusEnum;
|
|
|
-import com.qmth.distributed.print.business.enums.FlowModelEnum;
|
|
|
+import com.qmth.distributed.print.business.enums.*;
|
|
|
import com.qmth.distributed.print.business.service.*;
|
|
|
import com.qmth.teachcloud.common.bean.params.ApproveUserResult;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
@@ -18,7 +20,6 @@ import com.qmth.teachcloud.common.entity.BasicSchool;
|
|
|
import com.qmth.teachcloud.common.entity.SysOrg;
|
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
import com.qmth.teachcloud.common.enums.*;
|
|
|
-import com.qmth.teachcloud.common.service.CommonCacheService;
|
|
|
import com.qmth.teachcloud.common.service.SysOrgService;
|
|
|
import com.qmth.teachcloud.common.service.SysUserService;
|
|
|
import com.qmth.teachcloud.common.util.RedisUtil;
|
|
@@ -46,6 +47,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.util.*;
|
|
@@ -108,7 +110,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
TExamTaskFlowService tExamTaskFlowService;
|
|
|
|
|
|
@Resource
|
|
|
- CommonCacheService commonCacheService;
|
|
|
+ MultiWorkFlow multiWorkFlow;
|
|
|
|
|
|
/**
|
|
|
* 注册流程
|
|
@@ -134,6 +136,18 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
builder.deploy();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 上传流程文件
|
|
|
+ *
|
|
|
+ * @param file
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void uploadDeployment(File file) throws IOException {
|
|
|
+ DeploymentBuilder builder = repositoryService.createDeployment();
|
|
|
+ builder.addInputStream(file.getName(), new FileInputStream(file));
|
|
|
+ builder.deploy();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据流程key开启一个流程
|
|
|
*
|
|
@@ -326,6 +340,9 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
|
|
|
//流程审批
|
|
|
TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(SystemConstant.convertIdToLong(processInstanceId), examTask.getSchoolId());
|
|
|
+ if (Objects.isNull(tfFlowApprove)) {
|
|
|
+ tfFlowApprove = new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(processInstanceId), sysUser.getId(), FlowStatusEnum.END, sysUser.getId(), FlowModelEnum.SYSTEM);
|
|
|
+ }
|
|
|
|
|
|
//流程审批记录
|
|
|
TFFlowApproveLog tfFlowApproveLog = tfFlowApproveLogService.findByFlowId(SystemConstant.convertIdToLong(processInstanceId));
|
|
@@ -341,31 +358,36 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
if (Objects.isNull(tfFlowApproveLog)) {
|
|
|
tfFlowApproveLog = new TFFlowApproveLog(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(processInstanceId), examTask.getId(), sysUser.getId(), sysUser.getId());
|
|
|
}
|
|
|
- //广东医科大学流程
|
|
|
- if (Objects.nonNull(processDefinitionEntity) && (processDefinitionEntity.getKey().contains(SystemConstant.GDYKDX_FLOW_KEY)
|
|
|
- || processDefinitionEntity.getKey().contains(SystemConstant.GDYKDX_SUB_FLOW_KEY))) {
|
|
|
- if (setupEnum == FlowApproveSetupEnum.SUBMIT) {//命题提交
|
|
|
- this.assignSubmit(task, sysUser, tfFlowApprove, tfFlowLog, map);
|
|
|
- } else if (setupEnum == FlowApproveSetupEnum.PRIMARY_APPROVE) {//主任提交
|
|
|
- this.directorApprove(task, sysUser, tfFlowApprove, tfFlowApproveLog, tfFlowLog, remark, processDefinitionEntity, map);
|
|
|
- } else if (setupEnum == FlowApproveSetupEnum.SECOND_APPROVE) {//院长提交
|
|
|
- this.presidentApprove(task, sysUser, tfFlowApprove, tfFlowApproveLog, tfFlowLog, remark, map, objectMap, processInstanceId);
|
|
|
- } else if (setupEnum == FlowApproveSetupEnum.THREE_APPROVE) {//命题提交
|
|
|
- this.teacherApprove(task, sysUser, tfFlowApprove, tfFlowApproveLog, tfFlowLog, remark, map);
|
|
|
- } else if (setupEnum == FlowApproveSetupEnum.FOUR_APPROVE) {//印刷员提交
|
|
|
- this.printApprove(task, sysUser, tfFlowApprove, tfFlowApproveLog, tfFlowLog, remark, map);
|
|
|
- }
|
|
|
- }//江西中医药大学
|
|
|
- else if (Objects.nonNull(processDefinitionEntity) && processDefinitionEntity.getKey().contains(SystemConstant.JXZYY_FLOW_KEY)) {
|
|
|
- if (setupEnum == FlowApproveSetupEnum.SUBMIT) {//命题提交
|
|
|
- this.assignSubmit(task, sysUser, tfFlowApprove, tfFlowLog, map);
|
|
|
- } else if (setupEnum == FlowApproveSetupEnum.PRIMARY_APPROVE) {//主任提交
|
|
|
- this.directorApprove(task, sysUser, tfFlowApprove, tfFlowApproveLog, tfFlowLog, remark, processDefinitionEntity, map);
|
|
|
- }
|
|
|
- } else {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("未配置流程学校code");
|
|
|
- }
|
|
|
+// //广东医科大学流程
|
|
|
+// if (Objects.nonNull(processDefinitionEntity) && (processDefinitionEntity.getKey().contains(SystemConstant.GDYKDX_FLOW_KEY)
|
|
|
+// || processDefinitionEntity.getKey().contains(SystemConstant.GDYKDX_SUB_FLOW_KEY))) {
|
|
|
+// if (setupEnum == FlowApproveSetupEnum.SUBMIT) {//命题提交
|
|
|
+// this.assignSubmit(task, sysUser, tfFlowApprove, tfFlowLog, map);
|
|
|
+// } else if (setupEnum == FlowApproveSetupEnum.PRIMARY_APPROVE) {//主任提交
|
|
|
+// this.directorApprove(task, sysUser, tfFlowApprove, tfFlowApproveLog, tfFlowLog, remark, processDefinitionEntity, map);
|
|
|
+// } else if (setupEnum == FlowApproveSetupEnum.SECOND_APPROVE) {//院长提交
|
|
|
+// this.presidentApprove(task, sysUser, tfFlowApprove, tfFlowApproveLog, tfFlowLog, remark, map, objectMap, processInstanceId);
|
|
|
+// } else if (setupEnum == FlowApproveSetupEnum.THREE_APPROVE) {//命题提交
|
|
|
+// this.teacherApprove(task, sysUser, tfFlowApprove, tfFlowApproveLog, tfFlowLog, remark, map);
|
|
|
+// } else if (setupEnum == FlowApproveSetupEnum.FOUR_APPROVE) {//印刷员提交
|
|
|
+// this.printApprove(task, sysUser, tfFlowApprove, tfFlowApproveLog, tfFlowLog, remark, map);
|
|
|
+// }
|
|
|
+// }//江西中医药大学
|
|
|
+// else if (Objects.nonNull(processDefinitionEntity) && processDefinitionEntity.getKey().contains(SystemConstant.JXZYY_FLOW_KEY)) {
|
|
|
+// if (setupEnum == FlowApproveSetupEnum.SUBMIT) {//命题提交
|
|
|
+// this.assignSubmit(task, sysUser, tfFlowApprove, tfFlowLog, map);
|
|
|
+// } else if (setupEnum == FlowApproveSetupEnum.PRIMARY_APPROVE) {//主任提交
|
|
|
+// this.directorApprove(task, sysUser, tfFlowApprove, tfFlowApproveLog, tfFlowLog, remark, processDefinitionEntity, map);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// throw ExceptionResultEnum.ERROR.exception("未配置流程学校code");
|
|
|
+// }
|
|
|
}
|
|
|
+ tfFlowApprove.setStatus(FlowStatusEnum.AUDITING);
|
|
|
+ tfFlowApprove.setSetup(FlowApproveSetupEnum.PRIMARY_APPROVE.getSetup());
|
|
|
+ tfFlowLog.setApproveSetup(FlowApproveSetupEnum.PRIMARY_APPROVE.getSetup());
|
|
|
+ tfFlowLog.setApproveOperation(FlowApproveOperationEnum.SUBMIT);
|
|
|
+
|
|
|
tfFlowApprove.updateInfo(sysUser.getId());
|
|
|
tfFlowApproveLog.updateInfo(sysUser.getId());
|
|
|
tfFlowApprove.setApproveId(sysUser.getId());
|
|
@@ -1413,112 +1435,118 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void dynamicBuildBpmn(CustomFlowSaveDto customFlowSaveDto, String id) throws IOException {
|
|
|
- BasicSchool basicSchool = commonCacheService.schoolCache(customFlowSaveDto.getSchoolId());
|
|
|
-
|
|
|
BpmnModel model = new BpmnModel();
|
|
|
Process process = new Process();
|
|
|
model.addProcess(process);
|
|
|
- id = basicSchool.getCode() + "_" + id;
|
|
|
process.setId(id);
|
|
|
|
|
|
- // 判断是否仅为一个节点任务
|
|
|
-// List<String> taskList = new ArrayList<String>();
|
|
|
-// taskList.add("报销申请");
|
|
|
-//// taskList.add("主管审批");
|
|
|
-//// taskList.add("经理审批");
|
|
|
-//// taskList.add("总经理审批");
|
|
|
-// //单节点任务
|
|
|
-// if (taskList.size() == 1) {
|
|
|
-// process.addFlowElement(createStartEvent());
|
|
|
-// process.addFlowElement(createUserTask("task1", taskList.get(0), null));
|
|
|
-// process.addFlowElement(createEndEvent());
|
|
|
-// process.addFlowElement(createSequenceFlow("start", "task1", "", ""));
|
|
|
-// process.addFlowElement(createSequenceFlow("task1", "end", "", ""));
|
|
|
-// } else {
|
|
|
-// // 多节点任务
|
|
|
-// // 构造开始节点任务
|
|
|
-// process.addFlowElement(createStartEvent());
|
|
|
-// // 构造首个节点任务
|
|
|
-// process.addFlowElement(createUserTask("task1", taskList.get(0), null));
|
|
|
-// // 构造除去首尾节点的任务
|
|
|
-// for (int i = 1; i < taskList.size() - 1; i++) {
|
|
|
-// process.addFlowElement(createExclusiveGateway("createExclusiveGateway" + i));
|
|
|
-// process.addFlowElement(createUserTask("task" + (i + 1), taskList.get(i), null));
|
|
|
-// }
|
|
|
-// // 构造尾节点任务
|
|
|
-// process.addFlowElement(createExclusiveGateway("createExclusiveGateway" + (taskList.size() - 1)));
|
|
|
-// process.addFlowElement(createUserTask("task" + taskList.size(), taskList.get(taskList.size() - 1), null));
|
|
|
-// // 构造结束节点任务
|
|
|
-// process.addFlowElement(createEndEvent());
|
|
|
-//
|
|
|
-// // 构造连线(加网关)
|
|
|
-// process.addFlowElement(createSequenceFlow("start", "task1", "", ""));
|
|
|
-// // 第一个节点任务到第二个百分百通过的,因此不存在网关
|
|
|
-// process.addFlowElement(createSequenceFlow("task1", "task2", "", ""));
|
|
|
-// for (int i = 1; i < taskList.size(); i++) {
|
|
|
-// process.addFlowElement(createSequenceFlow("task" + (i + 1), "createExclusiveGateway" + i, "", ""));
|
|
|
-// // 判断网关走向(同意则直接到下一节点即可,不同意需要判断回退层级,决定回退到哪个节点,returnLevel等于0,即回退到task1)
|
|
|
-// // i等于几,即意味着回退的线路有几种可能,例如i等于1,即是task2,那么只能回退 到task1
|
|
|
-// // 如果i等于2,即是task3,那么此时可以回退到task1和task2;returnLevel =1 ,即回退到task1,所以这里我是扩展了可以驳回到任意阶段节点任务
|
|
|
-// for (int j = 1; j <= i; j++) {
|
|
|
-// process.addFlowElement(createSequenceFlow("createExclusiveGateway" + i, "task" + j, "不通过",
|
|
|
-// "${result == '0' && returnLevel== '" + j + "'}"));
|
|
|
-// }
|
|
|
-// // 操作结果为通过时,需要判断是否为最后一个节点任务,若是则直接到end
|
|
|
-// if (i == taskList.size() - 1) {
|
|
|
-// process.addFlowElement(
|
|
|
-// createSequenceFlow("createExclusiveGateway" + i, "end", "通过", "${result == '1'} "));
|
|
|
-//
|
|
|
-// } else {
|
|
|
-// process.addFlowElement(createSequenceFlow("createExclusiveGateway" + i, "task" + (i + 2), "通过",
|
|
|
-// "${result == '1'}"));
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
List<CustomFlowDto> customFlowLists = customFlowSaveDto.getCustomFlowLists();
|
|
|
Map<CustomFlowTypeEnum, CustomFlowDto> customFlowTypeEnumCustomFlowDtoMap = new HashMap<>();
|
|
|
- String firstProcessId = null, lastProcessId = null;
|
|
|
- LinkedList processLinkedList = new LinkedList();
|
|
|
+ FlowTaskLink flowTaskLink = new FlowTaskLink();
|
|
|
+ Map<String, Object> flowVarMap = new HashMap<>();
|
|
|
for (int i = 0; i < customFlowLists.size(); i++) {
|
|
|
CustomFlowDto customFlowDto = customFlowLists.get(i);
|
|
|
+ FlowTaskNode node = new FlowTaskNode(customFlowDto);
|
|
|
+ flowTaskLink.add(node);
|
|
|
switch (customFlowDto.getType()) {
|
|
|
- case START:
|
|
|
+ case START://开始节点
|
|
|
if (customFlowTypeEnumCustomFlowDtoMap.containsKey(CustomFlowTypeEnum.START)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("流程只能有一个开始节点!");
|
|
|
} else {
|
|
|
customFlowTypeEnumCustomFlowDtoMap.computeIfAbsent(CustomFlowTypeEnum.START, v -> customFlowDto);
|
|
|
}
|
|
|
+ customFlowDto.setFlowTaskId(CustomFlowDynamicBuildEnum.START.getId());
|
|
|
process.addFlowElement(createStartEvent());
|
|
|
break;
|
|
|
- case PROCESS:
|
|
|
- if (Objects.isNull(firstProcessId)) {
|
|
|
- firstProcessId = CustomFlowDynamicBuildEnum.USER_TASK.getId() + i;
|
|
|
+ case PROCESS://过程节点
|
|
|
+ customFlowDto.setFlowTaskId(CustomFlowDynamicBuildEnum.USER_TASK.getId() + i);
|
|
|
+ CustomFlowPropertyDto customFlowPropertyDto = customFlowDto.getProperty();
|
|
|
+ List<String> approveUserIds = new ArrayList<>();//审批用户
|
|
|
+ List<String> copyUserIds = new ArrayList<>();//抄送用户
|
|
|
+ if (Objects.nonNull(customFlowDto.getProperty())) {
|
|
|
+ //选人属性
|
|
|
+ switch (customFlowPropertyDto.getApproveUserType()) {
|
|
|
+ case USER://用户
|
|
|
+ if (Objects.nonNull(customFlowPropertyDto.getApproveUsers()) && customFlowPropertyDto.getApproveUsers().size() > 0) {
|
|
|
+ approveUserIds.addAll(customFlowPropertyDto.getApproveUsers().stream().map(x -> String.valueOf(x.getId())).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ROLE://角色
|
|
|
+ if (Objects.nonNull(customFlowPropertyDto.getApproveRoles()) && customFlowPropertyDto.getApproveRoles().size() > 0) {
|
|
|
+ List<SysUser> sysUserList = sysUserService.findByRoleIds(customFlowPropertyDto.getApproveRoles().stream().map(x -> x.getId()).collect(Collectors.toList()));
|
|
|
+ approveUserIds.addAll(sysUserList.stream().map(x -> String.valueOf(x.getId())).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //审批属性
|
|
|
+ switch (customFlowPropertyDto.getMultipleUserApproveType()) {
|
|
|
+ case ORDER://依次审批
|
|
|
+ case ALL://会签审批
|
|
|
+ flowVarMap.computeIfAbsent(DefaultInstanceConvertToMultiInstance.DEFAULT_ASSIGNEE_LIST + i, v -> approveUserIds);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //驳回属性
|
|
|
+ switch (customFlowPropertyDto.getRejectType()) {
|
|
|
+ case PREV://上一节点
|
|
|
+ break;
|
|
|
+ case START://发起人节点
|
|
|
+ break;
|
|
|
+ case PREV_ALL://该节点前全部节点
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //驳回再提交属性
|
|
|
+ switch (customFlowPropertyDto.getRejectResubmitType()) {
|
|
|
+ case NORMAL://按正常流程提交
|
|
|
+ break;
|
|
|
+ case PREV_STEP://提交到驳回节点
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //抄送用户
|
|
|
+ if (Objects.nonNull(customFlowPropertyDto.getCopyForUsers())) {
|
|
|
+ copyUserIds.addAll(customFlowPropertyDto.getCopyForUsers().stream().map(x -> String.valueOf(x.getId())).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
}
|
|
|
- lastProcessId = CustomFlowDynamicBuildEnum.USER_TASK.getId() + i;
|
|
|
- process.addFlowElement(createUserTask(lastProcessId, customFlowDto.getContent(), null));
|
|
|
+// process.addFlowElement(createUserTask(CustomFlowDynamicBuildEnum.USER_TASK.getId() + i, customFlowDto.getContent(), null));
|
|
|
+ process.addFlowElement(createUserTask(CustomFlowDynamicBuildEnum.USER_TASK.getId() + i, "审批人", approveUserIds, customFlowPropertyDto.getMultipleUserApproveType()));
|
|
|
+ //提取过程节点属性
|
|
|
break;
|
|
|
- case END:
|
|
|
+ case END://结束节点
|
|
|
if (customFlowTypeEnumCustomFlowDtoMap.containsKey(CustomFlowTypeEnum.END)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("流程只能有一个结束节点!");
|
|
|
} else {
|
|
|
customFlowTypeEnumCustomFlowDtoMap.computeIfAbsent(CustomFlowTypeEnum.END, v -> customFlowDto);
|
|
|
}
|
|
|
+ customFlowDto.setFlowTaskId(CustomFlowDynamicBuildEnum.END.getId());
|
|
|
process.addFlowElement(createEndEvent());
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- process.addFlowElement(createSequenceFlow(CustomFlowTypeEnum.START.name(), firstProcessId, "", ""));
|
|
|
- process.addFlowElement(createSequenceFlow(lastProcessId, CustomFlowTypeEnum.END.name(), "", ""));
|
|
|
+
|
|
|
+ for (int i = 1; i < flowTaskLink.size() - 1; i++) {
|
|
|
+ FlowTaskNode flowTaskNode = flowTaskLink.get(i);
|
|
|
+ process.addFlowElement(createSequenceFlow(flowTaskNode.getBefore().getTask().getFlowTaskId(), flowTaskNode.getTask().getFlowTaskId(), "", ""));
|
|
|
+ }
|
|
|
+ process.addFlowElement(createSequenceFlow(flowTaskLink.getLast().getBefore().getTask().getFlowTaskId(), flowTaskLink.getLast().getTask().getFlowTaskId(), "", ""));
|
|
|
|
|
|
//生成图像信息
|
|
|
new BpmnAutoLayout(model).execute();
|
|
|
//部署流程
|
|
|
Deployment deployment = repositoryService.createDeployment().addBpmnModel(id + "-dynamic-model.bpmn", model)
|
|
|
.name(id + "-multiple process deployment").deploy();
|
|
|
+
|
|
|
//启动流程
|
|
|
- ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(id);
|
|
|
+ ProcessInstance processInstance = flowVarMap.size() > 0 ? runtimeService.startProcessInstanceByKey(id, flowVarMap) : runtimeService.startProcessInstanceByKey(id);
|
|
|
+
|
|
|
//保存png图片和xml文件(这一步可做可不做)
|
|
|
InputStream processDiagram = repositoryService.getProcessDiagram(processInstance.getProcessDefinitionId());
|
|
|
FileUtils.copyInputStreamToFile(processDiagram, new File("target" + File.separator + id + "-multiple-process-diagram.png"));
|
|
@@ -1526,8 +1554,9 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
// InputStream processBpmn = repositoryService.getResourceAsStream(deployment.getId(), id + "-dynamic-model.bpmn");
|
|
|
// FileUtils.copyInputStreamToFile(processBpmn, new File("target" + File.separator + id + "-multiple-process.bpmn20.xml"));
|
|
|
|
|
|
+ File file = new File("target" + File.separator + id + "-multiple-process.bpmn");
|
|
|
InputStream processBpmn = repositoryService.getResourceAsStream(deployment.getId(), id + "-dynamic-model.bpmn");
|
|
|
- FileUtils.copyInputStreamToFile(processBpmn, new File("target" + File.separator + id + "-multiple-process.bpmn"));
|
|
|
+ FileUtils.copyInputStreamToFile(processBpmn, file);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1537,7 +1566,8 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
*/
|
|
|
protected StartEvent createStartEvent() {
|
|
|
StartEvent startEvent = new StartEvent();
|
|
|
- startEvent.setId(CustomFlowTypeEnum.START.name());
|
|
|
+ startEvent.setId(CustomFlowDynamicBuildEnum.START.getId());
|
|
|
+ startEvent.setName(CustomFlowDynamicBuildEnum.START.getTitle());
|
|
|
return startEvent;
|
|
|
}
|
|
|
|
|
@@ -1548,7 +1578,8 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
*/
|
|
|
protected EndEvent createEndEvent() {
|
|
|
EndEvent endEvent = new EndEvent();
|
|
|
- endEvent.setId(CustomFlowTypeEnum.END.name());
|
|
|
+ endEvent.setId(CustomFlowDynamicBuildEnum.END.getId());
|
|
|
+ endEvent.setName(CustomFlowDynamicBuildEnum.END.getTitle());
|
|
|
return endEvent;
|
|
|
}
|
|
|
|
|
@@ -1566,6 +1597,87 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
return userTask;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param id 对应我们画流程图中节点任务id
|
|
|
+ * @param name 节点任务名称
|
|
|
+ * @param assignees 任务的执行者(这一块自行决定是否添加每一环节的执行者,若是动态分配的话,可以不用传值)
|
|
|
+ * @param customFlowMultipleUserApproveTypeEnum
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ protected UserTask createUserTask(String id, String name, List<String> assignees, CustomFlowMultipleUserApproveTypeEnum customFlowMultipleUserApproveTypeEnum) {
|
|
|
+ UserTask userTask = new UserTask();
|
|
|
+ userTask.setName(name);
|
|
|
+ userTask.setId(id);
|
|
|
+// userTask.setAssignee("${assignee}");
|
|
|
+
|
|
|
+// // 多实例
|
|
|
+// MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = new MultiInstanceLoopCharacteristics();
|
|
|
+//// multiInstanceLoopCharacteristics.setSequential(false);
|
|
|
+// multiInstanceLoopCharacteristics.setSequential(true);
|
|
|
+// multiInstanceLoopCharacteristics.setInputDataItem("${assigneeList}");
|
|
|
+// multiInstanceLoopCharacteristics.setElementVariable("assignee");
|
|
|
+//
|
|
|
+// // 注入循环控制
|
|
|
+// userTask.setLoopCharacteristics(multiInstanceLoopCharacteristics);
|
|
|
+//
|
|
|
+// ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();
|
|
|
+// // 创建任务实例
|
|
|
+// UserTaskActivityBehavior userTaskActivityBehavior = processEngineConfiguration.getActivityBehaviorFactory().createUserTaskActivityBehavior(userTask);
|
|
|
+// // 创建behavior
|
|
|
+//// ParallelMultiInstanceBehavior behavior = new ParallelMultiInstanceBehavior(userTask, userTaskActivityBehavior);
|
|
|
+// SequentialMultiInstanceBehavior behavior = new SequentialMultiInstanceBehavior(userTask, userTaskActivityBehavior);
|
|
|
+// // 获取表达式解析工具
|
|
|
+// behavior.setCollectionElementVariable("assignee");
|
|
|
+//
|
|
|
+// // 注入表达式
|
|
|
+// ExpressionManager expressionManager = processEngineConfiguration.getExpressionManager();
|
|
|
+// behavior.setCollectionExpression(expressionManager.createExpression("${assigneeList}"));
|
|
|
+
|
|
|
+ boolean isSequential = false;
|
|
|
+ if (customFlowMultipleUserApproveTypeEnum == CustomFlowMultipleUserApproveTypeEnum.ORDER) {
|
|
|
+ userTask = multiWorkFlow.createMultiInstanceLoopCharacteristics(userTask, !isSequential);
|
|
|
+ } else if (customFlowMultipleUserApproveTypeEnum == CustomFlowMultipleUserApproveTypeEnum.ALL) {
|
|
|
+ userTask = multiWorkFlow.createMultiInstanceLoopCharacteristics(userTask, isSequential);
|
|
|
+ } else {
|
|
|
+ userTask.setCandidateUsers(assignees);
|
|
|
+ }
|
|
|
+ return userTask;
|
|
|
+ }
|
|
|
+
|
|
|
+// /**
|
|
|
+// * @param id 对应我们画流程图中节点任务id
|
|
|
+// * @param name 节点任务名称
|
|
|
+// * @param assignees
|
|
|
+// * @param customFlowMultipleUserApproveTypeEnum
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// protected UserTask createUserTask(String id, String name, List<String> assignees, CustomFlowMultipleUserApproveTypeEnum customFlowMultipleUserApproveTypeEnum) {
|
|
|
+// UserTask userTask = new UserTask();
|
|
|
+// userTask.setName(name);
|
|
|
+// userTask.setId(id);
|
|
|
+// switch (customFlowMultipleUserApproveTypeEnum) {
|
|
|
+// case ORDER:
|
|
|
+// case ALL:
|
|
|
+// MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = new MultiInstanceLoopCharacteristics();
|
|
|
+// multiInstanceLoopCharacteristics.setLoopCardinality(String.valueOf(assignees.size()));
|
|
|
+//// multiInstanceLoopCharacteristics.setInputDataItem(assignees.toString().replaceAll("\\[", "").replaceAll("\\]", ""));
|
|
|
+// multiInstanceLoopCharacteristics.setCompletionCondition("${nrOfActiveInstances == nrOfInstances}");
|
|
|
+//// multiInstanceLoopCharacteristics.setElementVariable("assignee");
|
|
|
+// if (customFlowMultipleUserApproveTypeEnum == CustomFlowMultipleUserApproveTypeEnum.ORDER) {
|
|
|
+// multiInstanceLoopCharacteristics.setSequential(true);
|
|
|
+// } else {
|
|
|
+// multiInstanceLoopCharacteristics.setSequential(false);
|
|
|
+// }
|
|
|
+// userTask.setLoopCharacteristics(multiInstanceLoopCharacteristics);
|
|
|
+// break;
|
|
|
+// default:
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// //设置审批人
|
|
|
+//// userTask.setCandidateUsers(assignees);
|
|
|
+// return userTask;
|
|
|
+// }
|
|
|
+
|
|
|
/**
|
|
|
* @param id 网关id
|
|
|
* @return
|