|
@@ -3,6 +3,7 @@ package com.qmth.sop.server.api;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.qmth.sop.business.activiti.DefaultInstanceConvertToMultiInstance;
|
|
import com.qmth.sop.business.bean.FormPropertyBean;
|
|
import com.qmth.sop.business.bean.FormPropertyBean;
|
|
import com.qmth.sop.business.bean.result.FlowFormWidgetResult;
|
|
import com.qmth.sop.business.bean.result.FlowFormWidgetResult;
|
|
import com.qmth.sop.business.bean.result.FlowResult;
|
|
import com.qmth.sop.business.bean.result.FlowResult;
|
|
@@ -12,17 +13,19 @@ import com.qmth.sop.business.entity.TFCustomFlowEntity;
|
|
import com.qmth.sop.business.entity.TFFlowApprove;
|
|
import com.qmth.sop.business.entity.TFFlowApprove;
|
|
import com.qmth.sop.business.entity.TFFlowLog;
|
|
import com.qmth.sop.business.entity.TFFlowLog;
|
|
import com.qmth.sop.business.service.*;
|
|
import com.qmth.sop.business.service.*;
|
|
-import com.qmth.sop.common.enums.ExceptionResultEnum;
|
|
|
|
-import com.qmth.sop.common.enums.FlowApproveOperationEnum;
|
|
|
|
-import com.qmth.sop.common.enums.FlowApproveSetupEnum;
|
|
|
|
-import com.qmth.sop.common.enums.FlowStatusEnum;
|
|
|
|
|
|
+import com.qmth.sop.common.contant.SystemConstant;
|
|
|
|
+import com.qmth.sop.common.enums.*;
|
|
import com.qmth.sop.common.util.GsonUtil;
|
|
import com.qmth.sop.common.util.GsonUtil;
|
|
import com.qmth.sop.common.util.JacksonUtil;
|
|
import com.qmth.sop.common.util.JacksonUtil;
|
|
import io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
|
|
+import org.activiti.bpmn.model.BpmnModel;
|
|
|
|
+import org.activiti.bpmn.model.FlowNode;
|
|
|
|
+import org.activiti.bpmn.model.UserTask;
|
|
import org.activiti.engine.FormService;
|
|
import org.activiti.engine.FormService;
|
|
import org.activiti.engine.RepositoryService;
|
|
import org.activiti.engine.RepositoryService;
|
|
import org.activiti.engine.RuntimeService;
|
|
import org.activiti.engine.RuntimeService;
|
|
import org.activiti.engine.TaskService;
|
|
import org.activiti.engine.TaskService;
|
|
|
|
+import org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior;
|
|
import org.activiti.engine.repository.DeploymentBuilder;
|
|
import org.activiti.engine.repository.DeploymentBuilder;
|
|
import org.activiti.engine.runtime.ProcessInstance;
|
|
import org.activiti.engine.runtime.ProcessInstance;
|
|
import org.activiti.engine.task.Task;
|
|
import org.activiti.engine.task.Task;
|
|
@@ -41,6 +44,7 @@ import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
import java.util.zip.ZipInputStream;
|
|
import java.util.zip.ZipInputStream;
|
|
|
|
|
|
@Api(tags = "测试流程表单htmlController")
|
|
@Api(tags = "测试流程表单htmlController")
|
|
@@ -100,78 +104,79 @@ public class ActivitiFromHtmlController {
|
|
return Collections.singletonMap("data", tfCustomFlowService.findFlowDeploymentList());
|
|
return Collections.singletonMap("data", tfCustomFlowService.findFlowDeploymentList());
|
|
}
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "获取流程提交表单属性接口")
|
|
|
|
- @RequestMapping(value = "/flow/start", method = RequestMethod.POST)
|
|
|
|
|
|
+ @ApiOperation(value = "获取流程表单属性接口")
|
|
|
|
+ @RequestMapping(value = "/flow/formData/get", method = RequestMethod.POST)
|
|
@Transactional
|
|
@Transactional
|
|
@ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
@ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
- public Map<String, Object> flowStart(@ApiParam(value = "部署流程id", required = true) @RequestParam String deploymentId) {
|
|
|
|
|
|
+ public Map<String, Object> flowStart(@ApiParam(value = "流程部署id", required = true) @RequestParam String flowDeploymentId) {
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
String processDefinitionId = null;
|
|
String processDefinitionId = null;
|
|
- TFCustomFlow tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getActFlowId, deploymentId));
|
|
|
|
|
|
+ TFCustomFlow tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
|
|
Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
|
|
Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
|
|
- if (Objects.isNull(tfCustomFlow.getFlowKey())) {
|
|
|
|
- processDefinitionId = activitiConsumerService.findProcessDefinitionIdByDeploymentId(deploymentId);
|
|
|
|
- tfCustomFlow.setFlowKey(processDefinitionId);
|
|
|
|
|
|
+ if (Objects.isNull(tfCustomFlow.getFlowDefinitionId())) {
|
|
|
|
+ processDefinitionId = activitiConsumerService.findProcessDefinitionIdByDeploymentId(flowDeploymentId);
|
|
|
|
+ tfCustomFlow.setFlowDefinitionId(processDefinitionId);
|
|
tfCustomFlowService.updateById(tfCustomFlow);
|
|
tfCustomFlowService.updateById(tfCustomFlow);
|
|
} else {
|
|
} else {
|
|
- processDefinitionId = tfCustomFlow.getFlowKey();
|
|
|
|
|
|
+ processDefinitionId = tfCustomFlow.getFlowDefinitionId();
|
|
}
|
|
}
|
|
FlowResult flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
|
|
FlowResult flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
|
|
Map<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
Map<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
|
|
for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
|
|
FlowTaskResult flowTaskResultTemp = GsonUtil.fromJson(GsonUtil.toJson(entry.getValue()), FlowTaskResult.class);
|
|
FlowTaskResult flowTaskResultTemp = GsonUtil.fromJson(GsonUtil.toJson(entry.getValue()), FlowTaskResult.class);
|
|
if (flowTaskResultTemp.getSetup().intValue() == 1) {
|
|
if (flowTaskResultTemp.getSetup().intValue() == 1) {
|
|
- map.put("setup", flowTaskResultTemp.getSetup());
|
|
|
|
- map.put("formProperties", flowTaskResultTemp.getFormProperty());
|
|
|
|
|
|
+ map.put(SystemConstant.FORM_PROPERTIES, flowTaskResultTemp);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- map.put("processDefinitionId", processDefinitionId);
|
|
|
|
- map.put("deploymentId", deploymentId);
|
|
|
|
- map.put("id", tfCustomFlow.getId());
|
|
|
|
|
|
+ map.put(SystemConstant.FLOW_DEPLOYMENT_ID, flowDeploymentId);
|
|
|
|
+ map.put(SystemConstant.ID, tfCustomFlow.getId());
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "获取流程表单属性接口")
|
|
|
|
- @RequestMapping(value = "/getFlowFormData", method = RequestMethod.POST)
|
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
|
|
- public Map<String, Object> getFlowFormData(@ApiParam(value = "流程id") @RequestParam(required = false) String flowId,
|
|
|
|
- @ApiParam(value = "流程任务id") @RequestParam(required = false) String taskId) {
|
|
|
|
-// List<Task> taskList = null;
|
|
|
|
-// if (Objects.nonNull(flowId) && !Objects.equals(flowId, "")) {
|
|
|
|
-// taskList = taskService.createTaskQuery().processInstanceId(flowId).list();
|
|
|
|
-// } else if (Objects.nonNull(taskId) && !Objects.equals(taskId, "")) {
|
|
|
|
-// taskList = taskService.createTaskQuery().taskId(taskId).list();
|
|
|
|
-// }
|
|
|
|
- Map<String, Object> varMap = new HashMap<>();
|
|
|
|
-// if (!CollectionUtils.isEmpty(taskList)) {
|
|
|
|
-// List<FormPropertyBean> formPropertyList = new LinkedList<>();
|
|
|
|
-// for (Task t : taskList) {
|
|
|
|
-// String flowTaskId = t.getId();
|
|
|
|
-// String processInstanceId = t.getProcessInstanceId();
|
|
|
|
-// Object o = formService.getRenderedTaskForm(flowTaskId);
|
|
|
|
-//// List<FormProperty> formProperties = taskFormData.getFormProperties();
|
|
|
|
-// log.info("taskId:{},flowId:{}", flowTaskId, processInstanceId);
|
|
|
|
-// if (Objects.nonNull(o)) {
|
|
|
|
-// log.info("task formProperties:{}", JacksonUtil.parseJson(o));
|
|
|
|
-// List<FlowFormWidgetResult> list = JSONArray.parseArray(o.toString(), FlowFormWidgetResult.class);
|
|
|
|
-// formPropertyList.add(new FormPropertyBean(processInstanceId, flowTaskId, t.getAssignee(), list));
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// varMap.put("formProperties", formPropertyList);
|
|
|
|
-// }
|
|
|
|
- return varMap;
|
|
|
|
- }
|
|
|
|
|
|
+// @ApiOperation(value = "获取流程表单属性接口")
|
|
|
|
+// @RequestMapping(value = "/flow/formData", method = RequestMethod.POST)
|
|
|
|
+// @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
|
|
+// public Map<String, Object> getFlowFormData(@ApiParam(value = "流程id") @RequestParam(required = false) String flowId,
|
|
|
|
+// @ApiParam(value = "流程任务id") @RequestParam(required = false) String taskId) {
|
|
|
|
+//// List<Task> taskList = null;
|
|
|
|
+//// if (Objects.nonNull(flowId) && !Objects.equals(flowId, "")) {
|
|
|
|
+//// taskList = taskService.createTaskQuery().processInstanceId(flowId).list();
|
|
|
|
+//// } else if (Objects.nonNull(taskId) && !Objects.equals(taskId, "")) {
|
|
|
|
+//// taskList = taskService.createTaskQuery().taskId(taskId).list();
|
|
|
|
+//// }
|
|
|
|
+// Map<String, Object> varMap = new HashMap<>();
|
|
|
|
+//// if (!CollectionUtils.isEmpty(taskList)) {
|
|
|
|
+//// List<FormPropertyBean> formPropertyList = new LinkedList<>();
|
|
|
|
+//// for (Task t : taskList) {
|
|
|
|
+//// String flowTaskId = t.getId();
|
|
|
|
+//// String processInstanceId = t.getProcessInstanceId();
|
|
|
|
+//// Object o = formService.getRenderedTaskForm(flowTaskId);
|
|
|
|
+////// List<FormProperty> formProperties = taskFormData.getFormProperties();
|
|
|
|
+//// log.info("taskId:{},flowId:{}", flowTaskId, processInstanceId);
|
|
|
|
+//// if (Objects.nonNull(o)) {
|
|
|
|
+//// log.info("task formProperties:{}", JacksonUtil.parseJson(o));
|
|
|
|
+//// List<FlowFormWidgetResult> list = JSONArray.parseArray(o.toString(), FlowFormWidgetResult.class);
|
|
|
|
+//// formPropertyList.add(new FormPropertyBean(processInstanceId, flowTaskId, t.getAssignee(), list));
|
|
|
|
+//// }
|
|
|
|
+//// }
|
|
|
|
+//// varMap.put("formProperties", formPropertyList);
|
|
|
|
+//// }
|
|
|
|
+// return varMap;
|
|
|
|
+// }
|
|
|
|
|
|
@ApiOperation(value = "启动流程接口")
|
|
@ApiOperation(value = "启动流程接口")
|
|
- @RequestMapping(value = "/startActivityDemo", method = RequestMethod.POST)
|
|
|
|
|
|
+ @RequestMapping(value = "/start/flow", method = RequestMethod.POST)
|
|
@Transactional
|
|
@Transactional
|
|
@ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
@ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
- public Map<String, Object> startActivityDemo(@ApiParam(value = "流程定义id", required = true) @RequestParam Long id,
|
|
|
|
- @ApiParam(value = "审批人id", required = true) @RequestParam String approveId,
|
|
|
|
- @ApiParam(value = "上传文件") @RequestParam(required = false) MultipartFile file,
|
|
|
|
- HttpServletRequest request) {
|
|
|
|
- Map<String, Object> varMap = new HashMap<>();
|
|
|
|
|
|
+ public Map<String, Object> startFlow(@ApiParam(value = "流程部署id", required = true) @RequestParam String flowDeploymentId,
|
|
|
|
+ @ApiParam(value = "流程操作", required = true) @RequestParam FlowApprovePassEnum approve,
|
|
|
|
+ @ApiParam(value = "流程id") @RequestParam(required = false) Long flowId,
|
|
|
|
+ @ApiParam(value = "流程表单数据") @RequestParam(required = false) String formProperties,
|
|
|
|
+ @ApiParam(value = "流程审批人") @RequestParam(required = false) List<Long> approveUserIds,
|
|
|
|
+ @ApiParam(value = "上传文件") @RequestParam(required = false) MultipartFile file,
|
|
|
|
+ HttpServletRequest request) {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
Map<String, String> formDataMap = new HashMap<>();
|
|
Map<String, String> formDataMap = new HashMap<>();
|
|
Map<String, String[]> parameterMap = request.getParameterMap();
|
|
Map<String, String[]> parameterMap = request.getParameterMap();
|
|
Set<Map.Entry<String, String[]>> entrySet = parameterMap.entrySet();
|
|
Set<Map.Entry<String, String[]>> entrySet = parameterMap.entrySet();
|
|
@@ -180,55 +185,224 @@ public class ActivitiFromHtmlController {
|
|
String[] value = entry.getValue();
|
|
String[] value = entry.getValue();
|
|
formDataMap.put(key, value[0]);
|
|
formDataMap.put(key, value[0]);
|
|
}
|
|
}
|
|
- varMap.putAll(formDataMap);
|
|
|
|
|
|
+ map.putAll(formDataMap);
|
|
|
|
|
|
- TFCustomFlow tfCustomFlow = tfCustomFlowService.getById(id);
|
|
|
|
|
|
+ List<String> approveIdList = approveUserIds.stream().map(s -> String.valueOf(s)).collect(Collectors.toList());
|
|
|
|
+ TFCustomFlow tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
|
|
Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
|
|
Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
|
|
- ProcessInstance processInstance = runtimeService.startProcessInstanceById(tfCustomFlow.getFlowKey(), varMap);
|
|
|
|
-// ProcessInstance processInstance = formService.submitStartFormData(tfCustomFlow.getFlowKey(), varMap);
|
|
|
|
- if (Objects.nonNull(processInstance)) {
|
|
|
|
- TFCustomFlowEntity tfCustomFlowEntity = new TFCustomFlowEntity(tfCustomFlow.getId(), null);
|
|
|
|
- TFFlowApprove tfFlowApprove = new TFFlowApprove(null, Long.parseLong(approveId), FlowStatusEnum.START, null);
|
|
|
|
- TFFlowLog tfFlowLog = new TFFlowLog(null, tfFlowApprove.getApproveId(), null, FlowApproveOperationEnum.START, FlowApproveSetupEnum.START.getSetup(), FlowApproveSetupEnum.START.getTitle());
|
|
|
|
- List<Task> taskList = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
|
|
|
|
- if (!CollectionUtils.isEmpty(taskList)) {
|
|
|
|
- FlowResult flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
|
|
|
|
- Map<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
|
|
- tfCustomFlowEntity.setFlowProcessVar(tfCustomFlow.getFlowProcessVar());
|
|
|
|
- List<FormPropertyBean> formPropertyList = new LinkedList<>();
|
|
|
|
- for (Task t : taskList) {
|
|
|
|
- String flowTaskId = t.getId();
|
|
|
|
- Long flowId = Long.parseLong(t.getProcessInstanceId());
|
|
|
|
- varMap.put("flowId", t.getProcessInstanceId());
|
|
|
|
- varMap.put("taskId", flowTaskId);
|
|
|
|
- tfCustomFlowEntity.setFlowId(flowId);
|
|
|
|
- tfFlowApprove.setFlowId(flowId);
|
|
|
|
- tfFlowApprove.setApproveMaxSetup(setupMap.size());
|
|
|
|
- tfFlowLog.setFlowId(flowId);
|
|
|
|
- tfFlowLog.setTaskId(Long.parseLong(flowTaskId));
|
|
|
|
- tfFlowLog.setPendApproveId(Arrays.asList(approveId).toString().replaceAll("\\[", "").replaceAll("\\]", ""));
|
|
|
|
- log.info("flowTaskId:{},flowId:{}", flowTaskId, flowId);
|
|
|
|
-// Object o = formService.getRenderedTaskForm(flowTaskId);
|
|
|
|
- FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(setupMap.get(t.getTaskDefinitionKey())), FlowTaskResult.class);
|
|
|
|
- if (Objects.nonNull(currFlowTaskResult)) {
|
|
|
|
- log.info("task formProperties:{}", JacksonUtil.parseJson(currFlowTaskResult));
|
|
|
|
- formPropertyList.add(new FormPropertyBean(t.getProcessInstanceId(), flowTaskId, currFlowTaskResult));
|
|
|
|
|
|
+ String processFlowId = null;
|
|
|
|
+ TFCustomFlowEntity tfCustomFlowEntity = null;
|
|
|
|
+ TFFlowApprove tfFlowApprove = null;
|
|
|
|
+ if (Objects.isNull(flowId)) {
|
|
|
|
+ map.put(DefaultInstanceConvertToMultiInstance.DEFAULT_ASSIGNEE_LIST + 1, approveIdList);
|
|
|
|
+ ProcessInstance processInstance = runtimeService.startProcessInstanceById(tfCustomFlow.getFlowDefinitionId(), map);
|
|
|
|
+ processFlowId = processInstance.getId();
|
|
|
|
+ tfCustomFlowEntity = new TFCustomFlowEntity(tfCustomFlow.getId(), null);
|
|
|
|
+ tfFlowApprove = new TFFlowApprove(null, Long.parseLong(approveIdList.get(approveIdList.size() - 1)), FlowStatusEnum.valueOf(approve.name()), null);
|
|
|
|
+ } else {
|
|
|
|
+ processFlowId = String.valueOf(flowId);
|
|
|
|
+ tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, flowId));
|
|
|
|
+ tfFlowApprove = tfFlowApproveService.getOne(new QueryWrapper<TFFlowApprove>().lambda().eq(TFFlowApprove::getFlowId, flowId));
|
|
|
|
+ }
|
|
|
|
+ Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有实例数据!"));
|
|
|
|
+ Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有审批数据!"));
|
|
|
|
+
|
|
|
|
+ List<TFFlowLog> tfFlowLogList = new ArrayList<>();
|
|
|
|
+ FlowResult flowResult = null;
|
|
|
|
+ if (Objects.nonNull(tfCustomFlowEntity.getFlowProcessVar())) {
|
|
|
|
+ flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
|
|
|
|
+ } else {
|
|
|
|
+ flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
|
|
|
|
+ }
|
|
|
|
+ LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
|
|
+
|
|
|
|
+ tfCustomFlowEntity.setFlowId(Long.parseLong(processFlowId));
|
|
|
|
+ tfFlowApprove.setFlowId(Long.parseLong(processFlowId));
|
|
|
|
+ tfFlowApprove.setApproveMaxSetup(setupMap.size());
|
|
|
|
+ List<Task> taskList = taskService.createTaskQuery().processInstanceId(processFlowId).list();
|
|
|
|
+ if (!CollectionUtils.isEmpty(taskList)) {
|
|
|
|
+ for (Task task : taskList) {
|
|
|
|
+ String currActivityId = task.getTaskDefinitionKey();
|
|
|
|
+ BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
|
|
|
|
+ FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId);
|
|
|
|
+ FlowTaskResult currFlowTaskResult = null, nextFlowTaskResult = null;
|
|
|
|
+ Integer nrOfCompletedInstances = null, nrOfInstances = null;
|
|
|
|
+ boolean multiInstance = false;
|
|
|
|
+ if (currFlow instanceof UserTask) {
|
|
|
|
+ if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
|
|
|
+ nrOfCompletedInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_COMPLETED_INSTANCES);
|
|
|
|
+ nrOfCompletedInstances++;
|
|
|
|
+ nrOfInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_INSTANCES);
|
|
|
|
+ multiInstance = true;
|
|
|
|
+ }
|
|
|
|
+ if (Objects.isNull(formProperties)) {
|
|
|
|
+ currFlowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
|
|
|
|
+ } else {
|
|
|
|
+ currFlowTaskResult = JSONObject.parseObject(formProperties, FlowTaskResult.class);
|
|
|
|
+ }
|
|
|
|
+ int currSetup = currFlowTaskResult.getSetup().intValue();
|
|
|
|
+ currSetup = currSetup == setupMap.size() - 1 ? 0 : currSetup + 1;
|
|
|
|
+
|
|
|
|
+ //流程流水日志
|
|
|
|
+ TFFlowLog tfFlowLog = new TFFlowLog(null, Long.parseLong(task.getAssignee()), null,
|
|
|
|
+ FlowApproveOperationEnum.valueOf(approve.name()), currFlowTaskResult.getSetup(),
|
|
|
|
+ FlowApproveSetupEnum.START.getTitle(), Long.parseLong(processFlowId),
|
|
|
|
+ Long.parseLong(task.getId()), tfCustomFlowEntity.getId(), approveIdList.toString().replaceAll("\\[", "").replaceAll("\\]", ""));
|
|
|
|
+
|
|
|
|
+ nextFlowTaskResult = this.getNextFlowTaskResult(nrOfCompletedInstances,
|
|
|
|
+ nrOfInstances,
|
|
|
|
+ currFlowTaskResult,
|
|
|
|
+ nextFlowTaskResult,
|
|
|
|
+ currSetup,
|
|
|
|
+ setupMap,
|
|
|
|
+ approve);
|
|
|
|
+
|
|
|
|
+ this.approvePass(currFlowTaskResult,
|
|
|
|
+ setupMap,
|
|
|
|
+ multiInstance,
|
|
|
|
+ nrOfCompletedInstances,
|
|
|
|
+ nrOfInstances,
|
|
|
|
+ tfFlowApprove,
|
|
|
|
+ tfFlowLog,
|
|
|
|
+ nextFlowTaskResult,
|
|
|
|
+ map,
|
|
|
|
+ approve);
|
|
|
|
+
|
|
|
|
+ map.put(DefaultInstanceConvertToMultiInstance.DEFAULT_ASSIGNEE_LIST + nextFlowTaskResult.getSetup(), approveIdList);
|
|
|
|
+ setupMap.put(task.getTaskDefinitionKey(), currFlowTaskResult);
|
|
|
|
+ flowResult.setSetupMap(setupMap);
|
|
|
|
+ tfCustomFlowEntity.setFlowProcessVar(JacksonUtil.parseJson(flowResult));
|
|
|
|
+ if (approve == FlowApprovePassEnum.START) {
|
|
|
|
+ taskService.complete(task.getId(), map);
|
|
}
|
|
}
|
|
|
|
+ tfFlowLogList.add(tfFlowLog);
|
|
}
|
|
}
|
|
- varMap.put("formProperties", formPropertyList);
|
|
|
|
}
|
|
}
|
|
- tfCustomFlowEntityService.save(tfCustomFlowEntity);
|
|
|
|
- tfFlowLog.setObjectId(tfCustomFlowEntity.getId());
|
|
|
|
- tfFlowApproveService.save(tfFlowApprove);
|
|
|
|
- tfFlowLogService.save(tfFlowLog);
|
|
|
|
}
|
|
}
|
|
- return varMap;
|
|
|
|
|
|
+ tfCustomFlowEntityService.saveOrUpdate(tfCustomFlowEntity);
|
|
|
|
+ tfFlowApproveService.saveOrUpdate(tfFlowApprove);
|
|
|
|
+ tfFlowLogService.saveBatch(tfFlowLogList);
|
|
|
|
+ return Collections.singletonMap("success", true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 审批通过
|
|
|
|
+ *
|
|
|
|
+ * @param currFlowTaskResult
|
|
|
|
+ * @param setupMap
|
|
|
|
+ * @param multiInstance
|
|
|
|
+ * @param nrOfCompletedInstances
|
|
|
|
+ * @param nrOfInstances
|
|
|
|
+ * @param tfFlowApprove
|
|
|
|
+ * @param tfFlowLog
|
|
|
|
+ * @param nextFlowTaskResult
|
|
|
|
+ * @param map
|
|
|
|
+ * @param approvePass
|
|
|
|
+ */
|
|
|
|
+ protected void approvePass(FlowTaskResult currFlowTaskResult,
|
|
|
|
+ Map<String, FlowTaskResult> setupMap,
|
|
|
|
+ boolean multiInstance,
|
|
|
|
+ Integer nrOfCompletedInstances,
|
|
|
|
+ Integer nrOfInstances,
|
|
|
|
+ TFFlowApprove tfFlowApprove,
|
|
|
|
+ TFFlowLog tfFlowLog,
|
|
|
|
+ FlowTaskResult nextFlowTaskResult,
|
|
|
|
+ Map<String, Object> map,
|
|
|
|
+ FlowApprovePassEnum approvePass) {
|
|
|
|
+ if (multiInstance) {
|
|
|
|
+ map.computeIfAbsent(FlowApproveOperationEnum.REJECT.getId() + currFlowTaskResult.getSetup(), v -> 0);
|
|
|
|
+ }
|
|
|
|
+ if (currFlowTaskResult.getSetup().intValue() == setupMap.size() - 1) {
|
|
|
|
+ if (multiInstance && Objects.nonNull(nrOfCompletedInstances)
|
|
|
|
+ && Objects.nonNull(nrOfInstances)
|
|
|
|
+ && nrOfCompletedInstances.intValue() == nrOfInstances.intValue()) {
|
|
|
|
+ tfFlowApprove.setStatus(FlowStatusEnum.FINISH);
|
|
|
|
+ tfFlowApprove.setSetup(FlowApproveSetupEnum.FINISH.getSetup());
|
|
|
|
+ } else if (!multiInstance) {
|
|
|
|
+ tfFlowApprove.setStatus(FlowStatusEnum.FINISH);
|
|
|
|
+ tfFlowApprove.setSetup(FlowApproveSetupEnum.FINISH.getSetup());
|
|
|
|
+ } else {
|
|
|
|
+ tfFlowApprove.setStatus(FlowStatusEnum.AUDITING);
|
|
|
|
+ tfFlowApprove.setSetup(nextFlowTaskResult.getSetup());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (approvePass == FlowApprovePassEnum.DRAFT || approvePass == FlowApprovePassEnum.START) {
|
|
|
|
+ tfFlowApprove.setStatus(FlowStatusEnum.valueOf(approvePass.name()));
|
|
|
|
+ } else {
|
|
|
|
+ tfFlowApprove.setStatus(FlowStatusEnum.AUDITING);
|
|
|
|
+ }
|
|
|
|
+ tfFlowApprove.setSetup(nextFlowTaskResult.getSetup());
|
|
|
|
+ }
|
|
|
|
+ if (tfFlowApprove.getStatus() == FlowStatusEnum.START) {
|
|
|
|
+ tfFlowLog.setApproveOperation(FlowApproveOperationEnum.START);
|
|
|
|
+ } else if (tfFlowApprove.getStatus() == FlowStatusEnum.DRAFT) {
|
|
|
|
+ tfFlowLog.setApproveOperation(FlowApproveOperationEnum.DRAFT);
|
|
|
|
+ } else {
|
|
|
|
+ tfFlowLog.setApproveOperation(FlowApproveOperationEnum.APPROVE);
|
|
|
|
+ }
|
|
|
|
+ map.put(SystemConstant.APPROVE, nextFlowTaskResult.getTaskKey());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取流程下一节点
|
|
|
|
+ *
|
|
|
|
+ * @param nrOfCompletedInstances
|
|
|
|
+ * @param nrOfInstances
|
|
|
|
+ * @param currFlowTaskResult
|
|
|
|
+ * @param nextFlowTaskResult
|
|
|
|
+ * @param currSetup
|
|
|
|
+ * @param setupMap
|
|
|
|
+ * @param approvePass
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public FlowTaskResult getNextFlowTaskResult(Integer nrOfCompletedInstances,
|
|
|
|
+ Integer nrOfInstances,
|
|
|
|
+ FlowTaskResult currFlowTaskResult,
|
|
|
|
+ FlowTaskResult nextFlowTaskResult,
|
|
|
|
+ int currSetup,
|
|
|
|
+ Map<String, FlowTaskResult> setupMap,
|
|
|
|
+ FlowApprovePassEnum approvePass) {
|
|
|
|
+ if (approvePass == FlowApprovePassEnum.PASS || approvePass == FlowApprovePassEnum.START || approvePass == FlowApprovePassEnum.DRAFT) {
|
|
|
|
+ if (Objects.nonNull(nrOfCompletedInstances)
|
|
|
|
+ && Objects.nonNull(nrOfInstances)
|
|
|
|
+ && nrOfCompletedInstances.intValue() != nrOfInstances.intValue() || approvePass == FlowApprovePassEnum.DRAFT) {
|
|
|
|
+ nextFlowTaskResult = currFlowTaskResult;
|
|
|
|
+ } else {
|
|
|
|
+ nextFlowTaskResult = this.getNextFlowTaskResult(setupMap, currSetup, nextFlowTaskResult);
|
|
|
|
+ }
|
|
|
|
+ } else if (approvePass == FlowApprovePassEnum.REJECT || approvePass == FlowApprovePassEnum.CANCEL) {
|
|
|
|
+ nextFlowTaskResult = this.getNextFlowTaskResult(setupMap, currSetup, nextFlowTaskResult);
|
|
|
|
+ }
|
|
|
|
+ Optional.ofNullable(nextFlowTaskResult).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("该节点不能审批通过"));
|
|
|
|
+ return nextFlowTaskResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取下级审核节点
|
|
|
|
+ *
|
|
|
|
+ * @param setupMap
|
|
|
|
+ * @param currSetup
|
|
|
|
+ * @param nextFlowTaskResult
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public FlowTaskResult getNextFlowTaskResult(Map<String, FlowTaskResult> setupMap,
|
|
|
|
+ int currSetup,
|
|
|
|
+ FlowTaskResult nextFlowTaskResult) {
|
|
|
|
+ for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
|
|
|
|
+ FlowTaskResult flowTaskResultTemp = GsonUtil.fromJson(GsonUtil.toJson(entry.getValue()), FlowTaskResult.class);
|
|
|
|
+ if (flowTaskResultTemp.getSetup().intValue() == currSetup) {
|
|
|
|
+ nextFlowTaskResult = flowTaskResultTemp;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return nextFlowTaskResult;
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "获取待办接口")
|
|
@ApiOperation(value = "获取待办接口")
|
|
@RequestMapping(value = "/getTaskList", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/getTaskList", method = RequestMethod.POST)
|
|
@ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
@ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
- public Map<String, Object> getTaskList(@ApiParam(value = "用户id", required = true) @RequestParam String userId, HttpServletRequest request) {
|
|
|
|
|
|
+ public Map<String, Object> getTaskList(@ApiParam(value = "用户id", required = true) @RequestParam String
|
|
|
|
+ userId, HttpServletRequest request) {
|
|
Map<String, Object> varMap = new HashMap<>();
|
|
Map<String, Object> varMap = new HashMap<>();
|
|
List<Task> taskList = taskService.createTaskQuery().taskAssignee(userId).list();
|
|
List<Task> taskList = taskService.createTaskQuery().taskAssignee(userId).list();
|
|
if (!CollectionUtils.isEmpty(taskList)) {
|
|
if (!CollectionUtils.isEmpty(taskList)) {
|
|
@@ -256,7 +430,8 @@ public class ActivitiFromHtmlController {
|
|
@RequestMapping(value = "/complete", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/complete", method = RequestMethod.POST)
|
|
@ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
@ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
public Map<String, Object> complete(@ApiParam(value = "流程taskId", required = true) @RequestParam String taskId,
|
|
public Map<String, Object> complete(@ApiParam(value = "流程taskId", required = true) @RequestParam String taskId,
|
|
- @ApiParam(value = "上传文件") @RequestParam(required = false) MultipartFile[] files, HttpServletRequest request) {
|
|
|
|
|
|
+ @ApiParam(value = "上传文件") @RequestParam(required = false) MultipartFile[] files, HttpServletRequest
|
|
|
|
+ request) {
|
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
|
Map<String, Object> varMap = new HashMap<>();
|
|
Map<String, Object> varMap = new HashMap<>();
|
|
Map<String, String> formDataMap = new HashMap<>();
|
|
Map<String, String> formDataMap = new HashMap<>();
|