|
@@ -10,10 +10,7 @@ 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.CustomFlowMultipleUserApproveTypeEnum;
|
|
|
-import com.qmth.distributed.print.business.enums.CustomFlowRejectResubmitTypeEnum;
|
|
|
-import com.qmth.distributed.print.business.enums.CustomFlowTypeEnum;
|
|
|
-import com.qmth.distributed.print.business.enums.ExamStatusEnum;
|
|
|
+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;
|
|
@@ -116,6 +113,9 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
@Resource
|
|
|
TFCustomFlowService tfCustomFlowService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TFCustomFlowListService tfCustomFlowListService;
|
|
|
+
|
|
|
/**
|
|
|
* 注册流程
|
|
|
*
|
|
@@ -184,48 +184,69 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
@Override
|
|
|
public ProcessInstance flowStart(Map<String, Object> map) {
|
|
|
String id = (String) map.get(SystemConstant.ID);
|
|
|
- BpmnModel model = (BpmnModel) map.get(SystemConstant.MODEL);
|
|
|
Map flowProcessVarMap = (Map) map.get(SystemConstant.FLOW_PROCESS_VAR_MAP);
|
|
|
Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
|
|
|
Map<String, Object> varMap = new HashMap<>();
|
|
|
- agginessMap.forEach((k, v) -> {
|
|
|
- if (v instanceof CustomFlowVarDto) {
|
|
|
- CustomFlowVarDto customFlowVarDto = (CustomFlowVarDto) v;
|
|
|
- varMap.computeIfAbsent(customFlowVarDto.getFlowTaskVar(), s -> customFlowVarDto.getApproveIds().size() == 1 ? customFlowVarDto.getApproveIds().get(0) : customFlowVarDto.getApproveIds());
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- //部署流程
|
|
|
- String bpmnName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_MODEL_NAME;
|
|
|
- String bpmnPngName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_PNG_NAME;
|
|
|
- String bpmnProcessName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_PROCESS_NAME;
|
|
|
- String bpmnDeploymentName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_DEPLOYMENT_NAME;
|
|
|
- Deployment deployment = repositoryService.createDeployment().addBpmnModel(bpmnName, model).name(bpmnDeploymentName).deploy();
|
|
|
-
|
|
|
+ Gson gson = new Gson();
|
|
|
+ for (Map.Entry<String, CustomFlowVarDto> entry : agginessMap.entrySet()) {
|
|
|
+ CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(entry.getValue()), CustomFlowVarDto.class);
|
|
|
+ varMap.computeIfAbsent(customFlowVarDto.getFlowTaskVar(), s -> customFlowVarDto.getApproveIds().size() == 1 ? customFlowVarDto.getApproveIds().get(0) : customFlowVarDto.getApproveIds());
|
|
|
+ }
|
|
|
//启动流程
|
|
|
ProcessInstance processInstance = varMap.size() > 0 ? runtimeService.startProcessInstanceByKey(id, varMap) : runtimeService.startProcessInstanceByKey(id);
|
|
|
+ map.computeIfAbsent(SystemConstant.PROCESS_DEFINITION_ID, v -> processInstance.getProcessDefinitionId());
|
|
|
+ map.computeIfAbsent(SystemConstant.FLOW_ID, v -> processInstance.getProcessInstanceId());
|
|
|
+ map.computeIfAbsent(SystemConstant.FLOW_STATUS, v -> FlowStatusEnum.START);
|
|
|
+ this.createFlowPicture(map);
|
|
|
+ this.flowApproveStart(map);
|
|
|
+ return processInstance;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建流程图片
|
|
|
+ *
|
|
|
+ * @param map
|
|
|
+ */
|
|
|
+ protected void createFlowPicture(Map<String, Object> map) {
|
|
|
+ String id = (String) map.get(SystemConstant.FLOW_LIST_ID);
|
|
|
+ String processDefinitionId = (String) map.get(SystemConstant.PROCESS_DEFINITION_ID);
|
|
|
+ String bpmnPngName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_PNG_NAME;
|
|
|
|
|
|
- //保存png图片和xml文件(这一步可做可不做)
|
|
|
- InputStream processDiagram = repositoryService.getProcessDiagram(processInstance.getProcessDefinitionId());
|
|
|
+ //保存png图片(这一步可做可不做)
|
|
|
+ InputStream processDiagram = repositoryService.getProcessDiagram(processDefinitionId);
|
|
|
try {
|
|
|
FileUtils.copyInputStreamToFile(processDiagram, new File(SystemConstant.TEMP_FILES_DIR + File.separator + DefaultInstanceConvertToMultiInstance.BPMN_NAME + File.separator + bpmnPngName));
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 部署流程
|
|
|
+ *
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ protected Deployment flowDeployment(Map<String, Object> map) {
|
|
|
+ String id = (String) map.get(SystemConstant.ID);
|
|
|
+ BpmnModel model = (BpmnModel) map.get(SystemConstant.MODEL);
|
|
|
|
|
|
-// InputStream processBpmn = repositoryService.getResourceAsStream(deployment.getId(), bpmnName);
|
|
|
-// FileUtils.copyInputStreamToFile(processBpmn, new File(SystemConstant.TEMP_FILES_DIR + File.separator + DefaultInstanceConvertToMultiInstance.BPMN_NAME + File.separator + id + "-multiple-process.bpmn20.xml"));
|
|
|
+ //部署流程
|
|
|
+ String bpmnName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_MODEL_NAME;
|
|
|
+ String bpmnDeploymentName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_DEPLOYMENT_NAME;
|
|
|
+ String bpmnProcessName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_PROCESS_NAME;
|
|
|
+
|
|
|
+ Deployment deployment = repositoryService.createDeployment().addBpmnModel(bpmnName, model).name(bpmnDeploymentName).deploy();
|
|
|
+ map.remove(SystemConstant.MODEL);
|
|
|
|
|
|
+ //保存xml文件(这一步可做可不做)
|
|
|
InputStream processBpmn = repositoryService.getResourceAsStream(deployment.getId(), bpmnName);
|
|
|
try {
|
|
|
FileUtils.copyInputStreamToFile(processBpmn, new File(SystemConstant.TEMP_FILES_DIR + File.separator + DefaultInstanceConvertToMultiInstance.BPMN_NAME + File.separator + bpmnProcessName));
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- map.computeIfAbsent(SystemConstant.PROCESS_DEFINITION_ID, v -> processInstance.getProcessDefinitionId());
|
|
|
- map.computeIfAbsent(SystemConstant.FLOW_ID, v -> processInstance.getProcessInstanceId());
|
|
|
- map.remove(SystemConstant.MODEL);
|
|
|
- return processInstance;
|
|
|
+ return deployment;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -306,8 +327,20 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
Optional.ofNullable(map.get(SystemConstant.FLOW_STATUS)).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程状态不能为空"));
|
|
|
FlowStatusEnum flowStatusEnum = (FlowStatusEnum) map.get(SystemConstant.FLOW_STATUS);
|
|
|
|
|
|
- Long approveId = Objects.nonNull(map.get(SystemConstant.APPROVE_ID)) ? (Long) map.get(SystemConstant.APPROVE_ID) : null;
|
|
|
- tfFlowApproveService.save(new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), approveId, flowStatusEnum, sysUser.getId()));
|
|
|
+ String approveId = Objects.nonNull(map.get(SystemConstant.APPROVE_ID)) ? (String) map.get(SystemConstant.APPROVE_ID) : null;
|
|
|
+ tfFlowApproveService.save(new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), sysUser.getId(), flowStatusEnum, sysUser.getId()));
|
|
|
+
|
|
|
+ Long examTaskId = (Long) map.get(SystemConstant.EXAM_TASK_ID);
|
|
|
+ //TODO 测试用
|
|
|
+ ExamTask examTask = examTaskService.getById(examTaskId);
|
|
|
+ examTask.setFlowId(SystemConstant.convertIdToLong(flowId));
|
|
|
+ examTaskService.updateById(examTask);
|
|
|
+
|
|
|
+ TExamTaskFlow tExamTaskFlow = tExamTaskFlowService.findByFlowLevel(examTaskId);
|
|
|
+ tExamTaskFlow.setFlowId(SystemConstant.convertIdToLong(flowId));
|
|
|
+ tExamTaskFlowService.updateById(tExamTaskFlow);
|
|
|
+
|
|
|
+ tfFlowLogService.save(new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), examTaskId, sysUser.getId(), sysUser.getId(), "提交流程", approveId, FlowApproveOperationEnum.SUBMIT));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -345,8 +378,8 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
Map<String, Object> objectMap = new HashMap<>();
|
|
|
TFFlowLog tfFlowLog = null;
|
|
|
|
|
|
- TFCustomFlow tfCustomFlow = tfCustomFlowService.findByFlowId(flowId);
|
|
|
- Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlow);
|
|
|
+ TFCustomFlowList tfCustomFlowList = tfCustomFlowListService.findByFlowId(flowId);
|
|
|
+ Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowList);
|
|
|
|
|
|
String remark = null;
|
|
|
FlowTaskResult currFlowTaskResult = null, nextFlowTaskResult = null;
|
|
@@ -1091,8 +1124,8 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
multiInstance = true;
|
|
|
}
|
|
|
|
|
|
- TFCustomFlow tfCustomFlow = tfCustomFlowService.findByFlowId(tfFlowApprove.getFlowId());
|
|
|
- Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlow);
|
|
|
+ TFCustomFlowList tfCustomFlowList = tfCustomFlowListService.findByFlowId(tfFlowApprove.getFlowId());
|
|
|
+ Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowList);
|
|
|
Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
|
|
|
if (Objects.nonNull(tfFlowApprove.getTransferAssignee())) {
|
|
|
agginessMap = JacksonUtil.readJson(tfFlowApprove.getTransferAssignee(), Map.class);
|
|
@@ -2041,7 +2074,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
map.computeIfAbsent(SystemConstant.ID, v -> id);
|
|
|
map.computeIfAbsent(SystemConstant.MODEL, v -> model);
|
|
|
map.computeIfAbsent(SystemConstant.FLOW_PROCESS_VAR_MAP, v -> flowProcessVarMap);
|
|
|
- this.flowStart(map);
|
|
|
+ this.flowDeployment(map);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
@@ -2173,42 +2206,61 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 修改启动流程候选人
|
|
|
+ * 启动自定义流程
|
|
|
*
|
|
|
- * @param customFlowId
|
|
|
+ * @param taskId
|
|
|
* @param approveId
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public void customFlowStartUpdateApproveId(Long customFlowId, Long approveId) {
|
|
|
- TFCustomFlow tfCustomFlow = tfCustomFlowService.getById(customFlowId);
|
|
|
+ public void customFlowStart(Long taskId, Long approveId) {
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+ TFCustomFlow tfCustomFlow = tfCustomFlowService.findMaxVersion(sysUser.getSchoolId(), sysUser.getOrgId(), TFCustomTypeEnum.ELECTRON_FLOW);
|
|
|
+ Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到自定义流程数据"));
|
|
|
+
|
|
|
+ TFCustomFlowList tfCustomFlowList = new TFCustomFlowList(tfCustomFlow.getId(), sysUser.getId());
|
|
|
Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlow);
|
|
|
- Task task = taskService.createTaskQuery().processInstanceId(String.valueOf(tfCustomFlow.getFlowId())).singleResult();
|
|
|
- task.setAssignee(String.valueOf(approveId));
|
|
|
- taskService.saveTask(task);
|
|
|
- Map<String, Object> map = JacksonUtil.readJson(tfCustomFlow.getFlowProcessVar(), Map.class);
|
|
|
Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
|
|
|
agginessMap.put(CustomFlowTypeEnum.USER_TASK.getId() + DefaultInstanceConvertToMultiInstance.DEFAULT_USER_TASK, new CustomFlowVarDto(SystemConstant.APPROVE_ID, new ArrayList(Arrays.asList(String.valueOf(approveId)))));
|
|
|
flowProcessVarMap.put(SystemConstant.AGGINESS_MAP, agginessMap);
|
|
|
- map.put(SystemConstant.FLOW_PROCESS_VAR_MAP, flowProcessVarMap);
|
|
|
- tfCustomFlow.setFlowProcessVar(JacksonUtil.parseJson(map));
|
|
|
- tfCustomFlowService.updateById(tfCustomFlow);
|
|
|
|
|
|
- map.put(SystemConstant.FLOW_ID, String.valueOf(tfCustomFlow.getFlowId()));
|
|
|
- map.put(SystemConstant.FLOW_STATUS, FlowStatusEnum.START);
|
|
|
- map.put(SystemConstant.APPROVE_ID, approveId);
|
|
|
- this.flowApproveStart(map);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.computeIfAbsent(SystemConstant.ID, v -> tfCustomFlow.getFlowKey());
|
|
|
+ map.computeIfAbsent(SystemConstant.FLOW_PROCESS_VAR_MAP, v -> flowProcessVarMap);
|
|
|
+ map.computeIfAbsent(SystemConstant.FLOW_LIST_ID, v -> String.valueOf(tfCustomFlowList.getId()));
|
|
|
+ map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> String.valueOf(approveId));
|
|
|
+ map.computeIfAbsent(SystemConstant.EXAM_TASK_ID, v -> taskId);
|
|
|
+ this.flowStart(map);
|
|
|
+
|
|
|
+ tfCustomFlow.setActFlowId((String) map.get(SystemConstant.PROCESS_DEFINITION_ID));
|
|
|
+ tfCustomFlowList.setFlowId(SystemConstant.convertIdToLong((String) map.get(SystemConstant.FLOW_ID)));
|
|
|
+
|
|
|
+ map.remove(SystemConstant.APPROVE_ID);
|
|
|
+ map.remove(SystemConstant.FLOW_LIST_ID);
|
|
|
+ map.remove(SystemConstant.PROCESS_DEFINITION_ID);
|
|
|
+ map.remove(SystemConstant.FLOW_STATUS);
|
|
|
+ tfCustomFlowList.setFlowProcessVar(JacksonUtil.parseJson(map));
|
|
|
+ tfCustomFlow.setUpdateId(sysUser.getId());
|
|
|
+ tfCustomFlowListService.save(tfCustomFlowList);
|
|
|
+ tfCustomFlowService.updateById(tfCustomFlow);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取流程变量
|
|
|
*
|
|
|
- * @param tfCustomFlow
|
|
|
+ * @param o
|
|
|
* @return
|
|
|
*/
|
|
|
- protected Map<String, Object> getFlowProcessVarMap(TFCustomFlow tfCustomFlow) {
|
|
|
- Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到自定义流程数据"));
|
|
|
- Map<String, Object> varMap = JacksonUtil.readJson(tfCustomFlow.getFlowProcessVar(), Map.class);
|
|
|
+ protected Map<String, Object> getFlowProcessVarMap(Object o) {
|
|
|
+ Optional.ofNullable(o).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到自定义流程数据"));
|
|
|
+ Map<String, Object> varMap = null;
|
|
|
+ if (o instanceof TFCustomFlow) {
|
|
|
+ o = (TFCustomFlow) o;
|
|
|
+ varMap = JacksonUtil.readJson(((TFCustomFlow) o).getFlowProcessVar(), Map.class);
|
|
|
+ } else if (o instanceof TFCustomFlowList) {
|
|
|
+ o = (TFCustomFlowList) o;
|
|
|
+ varMap = JacksonUtil.readJson(((TFCustomFlowList) o).getFlowProcessVar(), Map.class);
|
|
|
+ }
|
|
|
Optional.ofNullable(varMap).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("自定义流程变量数据为空"));
|
|
|
Map<String, Object> flowProcessVarMap = (Map<String, Object>) varMap.get(SystemConstant.FLOW_PROCESS_VAR_MAP);
|
|
|
Optional.ofNullable(flowProcessVarMap).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("自定义流程节点变量数据为空"));
|