|
@@ -1,11 +1,10 @@
|
|
package com.qmth.sop.server.api;
|
|
package com.qmth.sop.server.api;
|
|
|
|
|
|
-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.boot.api.exception.ApiException;
|
|
|
|
+import com.qmth.sop.business.activiti.ProcessEventRejectCmd;
|
|
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.FlowResult;
|
|
import com.qmth.sop.business.bean.result.FlowResult;
|
|
import com.qmth.sop.business.bean.result.FlowTaskResult;
|
|
import com.qmth.sop.business.bean.result.FlowTaskResult;
|
|
import com.qmth.sop.business.entity.TFCustomFlow;
|
|
import com.qmth.sop.business.entity.TFCustomFlow;
|
|
@@ -15,8 +14,11 @@ import com.qmth.sop.business.entity.TFFlowLog;
|
|
import com.qmth.sop.business.service.*;
|
|
import com.qmth.sop.business.service.*;
|
|
import com.qmth.sop.common.contant.SystemConstant;
|
|
import com.qmth.sop.common.contant.SystemConstant;
|
|
import com.qmth.sop.common.enums.*;
|
|
import com.qmth.sop.common.enums.*;
|
|
|
|
+import com.qmth.sop.common.lock.MemoryLock;
|
|
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 com.qmth.sop.common.util.Result;
|
|
|
|
+import com.qmth.sop.common.util.ResultUtil;
|
|
import io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
import org.activiti.bpmn.model.BpmnModel;
|
|
import org.activiti.bpmn.model.BpmnModel;
|
|
import org.activiti.bpmn.model.FlowNode;
|
|
import org.activiti.bpmn.model.FlowNode;
|
|
@@ -25,6 +27,7 @@ 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.TaskServiceImpl;
|
|
import org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior;
|
|
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;
|
|
@@ -38,7 +41,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -49,7 +51,7 @@ import java.util.zip.ZipInputStream;
|
|
|
|
|
|
@Api(tags = "测试流程表单htmlController")
|
|
@Api(tags = "测试流程表单htmlController")
|
|
@RestController
|
|
@RestController
|
|
-@RequestMapping("/activiti/form/html")
|
|
|
|
|
|
+@RequestMapping("/flow")
|
|
public class ActivitiFromHtmlController {
|
|
public class ActivitiFromHtmlController {
|
|
private final static Logger log = LoggerFactory.getLogger(ActivitiFromHtmlController.class);
|
|
private final static Logger log = LoggerFactory.getLogger(ActivitiFromHtmlController.class);
|
|
|
|
|
|
@@ -80,114 +82,83 @@ public class ActivitiFromHtmlController {
|
|
@Resource
|
|
@Resource
|
|
TFFlowLogService tfFlowLogService;
|
|
TFFlowLogService tfFlowLogService;
|
|
|
|
|
|
- /**
|
|
|
|
- * 注册流程
|
|
|
|
- *
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ MemoryLock memoryLock;
|
|
|
|
+
|
|
@ApiOperation(value = "创建流程接口")
|
|
@ApiOperation(value = "创建流程接口")
|
|
@RequestMapping(value = "/createDeployment", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/createDeployment", 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> createDeployment() throws IOException {
|
|
|
|
|
|
+ public Result createDeployment() throws IOException {
|
|
DeploymentBuilder builder = repositoryService.createDeployment();
|
|
DeploymentBuilder builder = repositoryService.createDeployment();
|
|
ClassPathResource resource = new ClassPathResource("testform1.zip");
|
|
ClassPathResource resource = new ClassPathResource("testform1.zip");
|
|
ZipInputStream zip = new ZipInputStream(resource.getInputStream());
|
|
ZipInputStream zip = new ZipInputStream(resource.getInputStream());
|
|
builder.addZipInputStream(zip);
|
|
builder.addZipInputStream(zip);
|
|
- return flowStart(builder.deploy().getId(), null, null);
|
|
|
|
|
|
+ return formPropertiesGet(builder.deploy().getId(), null);
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "获取流程部署信息")
|
|
@ApiOperation(value = "获取流程部署信息")
|
|
- @RequestMapping(value = "/flow/deployment/data", method = RequestMethod.POST)
|
|
|
|
|
|
+ @RequestMapping(value = "/deployment/data", method = RequestMethod.POST)
|
|
@ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
@ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
- public Map<String, Object> getFlowData() {
|
|
|
|
- return Collections.singletonMap("data", tfCustomFlowService.findFlowDeploymentList());
|
|
|
|
|
|
+ public Result getDeploymentData() {
|
|
|
|
+ return ResultUtil.ok(tfCustomFlowService.findFlowDeploymentList());
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "获取流程表单属性接口")
|
|
@ApiOperation(value = "获取流程表单属性接口")
|
|
- @RequestMapping(value = "/flow/formPropertie/get", method = RequestMethod.POST)
|
|
|
|
|
|
+ @RequestMapping(value = "/form_properties/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") @RequestParam(required = false) String flowDeploymentId,
|
|
|
|
- @ApiParam(value = "流程id") @RequestParam(required = false) Long flowId,
|
|
|
|
- @ApiParam(value = "流程任务id") @RequestParam(required = false) Long taskId) {
|
|
|
|
|
|
+ public Result formPropertiesGet(@ApiParam(value = "流程部署id") @RequestParam(required = false) String flowDeploymentId,
|
|
|
|
+ @ApiParam(value = "流程任务id") @RequestParam(required = false) Long taskId) {
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
FlowResult flowResult = null;
|
|
FlowResult flowResult = null;
|
|
TFCustomFlow tfCustomFlow = null;
|
|
TFCustomFlow tfCustomFlow = null;
|
|
if (Objects.nonNull(flowDeploymentId)) {
|
|
if (Objects.nonNull(flowDeploymentId)) {
|
|
- String processDefinitionId = null;
|
|
|
|
tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
|
|
tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
|
|
- Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
|
|
|
|
|
|
+ Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
|
|
if (Objects.isNull(tfCustomFlow.getFlowDefinitionId())) {
|
|
if (Objects.isNull(tfCustomFlow.getFlowDefinitionId())) {
|
|
- processDefinitionId = activitiConsumerService.findProcessDefinitionIdByDeploymentId(flowDeploymentId);
|
|
|
|
|
|
+ String processDefinitionId = activitiConsumerService.findProcessDefinitionIdByDeploymentId(flowDeploymentId);
|
|
tfCustomFlow.setFlowDefinitionId(processDefinitionId);
|
|
tfCustomFlow.setFlowDefinitionId(processDefinitionId);
|
|
tfCustomFlowService.updateById(tfCustomFlow);
|
|
tfCustomFlowService.updateById(tfCustomFlow);
|
|
- } else {
|
|
|
|
- processDefinitionId = tfCustomFlow.getFlowDefinitionId();
|
|
|
|
}
|
|
}
|
|
flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
|
|
flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
|
|
map = this.getFlowFormPropertie(flowResult, map, 1);
|
|
map = this.getFlowFormPropertie(flowResult, map, 1);
|
|
} else {
|
|
} else {
|
|
- List<Task> taskList = null;
|
|
|
|
- if (Objects.nonNull(flowId) && !Objects.equals(flowId, "")) {
|
|
|
|
- taskList = taskService.createTaskQuery().processInstanceId(String.valueOf(flowId)).list();
|
|
|
|
- } else if (Objects.nonNull(taskId) && !Objects.equals(taskId, "")) {
|
|
|
|
- taskList = taskService.createTaskQuery().taskId(String.valueOf(taskId)).list();
|
|
|
|
|
|
+ List<Task> taskList = taskService.createTaskQuery().taskId(String.valueOf(taskId)).list();
|
|
|
|
+ if (CollectionUtils.isEmpty(taskList)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("流程任务数据为空!");
|
|
}
|
|
}
|
|
- if (!CollectionUtils.isEmpty(taskList)) {
|
|
|
|
- if (Objects.isNull(flowId)) {
|
|
|
|
- flowId = Long.parseLong(taskList.get(0).getProcessInstanceId());
|
|
|
|
- }
|
|
|
|
- TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, flowId));
|
|
|
|
- Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有实例数据!"));
|
|
|
|
- tfCustomFlow = tfCustomFlowService.getById(tfCustomFlowEntity.gettFCustomFlowId());
|
|
|
|
- Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
|
|
|
|
|
|
+ Long flowId = Long.parseLong(taskList.get(0).getProcessInstanceId());
|
|
|
|
+ TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, flowId));
|
|
|
|
+ Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有实例数据!"));
|
|
|
|
+ tfCustomFlow = tfCustomFlowService.getById(tfCustomFlowEntity.gettFCustomFlowId());
|
|
|
|
+ Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
|
|
|
|
|
|
- flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
|
|
|
|
- LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
|
|
- for (Task task : taskList) {
|
|
|
|
- FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
|
|
|
|
- map = this.getFlowFormPropertie(flowResult, map, currFlowTaskResult.getSetup());
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
|
|
|
|
+ LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
|
|
+ for (Task task : taskList) {
|
|
|
|
+ FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
|
|
|
|
+ map = this.getFlowFormPropertie(flowResult, map, currFlowTaskResult.getSetup());
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
map.put(SystemConstant.FLOW_DEPLOYMENT_ID, tfCustomFlow.getFlowDeploymentId());
|
|
map.put(SystemConstant.FLOW_DEPLOYMENT_ID, tfCustomFlow.getFlowDeploymentId());
|
|
map.put(SystemConstant.ID, tfCustomFlow.getId());
|
|
map.put(SystemConstant.ID, tfCustomFlow.getId());
|
|
- return map;
|
|
|
|
|
|
+ return ResultUtil.ok(map);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 获取表单属性
|
|
|
|
- *
|
|
|
|
- * @param flowResult
|
|
|
|
- * @param map
|
|
|
|
- * @param setup
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public Map<String, Object> getFlowFormPropertie(FlowResult flowResult, Map<String, Object> map, int setup) {
|
|
|
|
- Map<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
|
|
- for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
|
|
|
|
- FlowTaskResult flowTaskResultTemp = GsonUtil.fromJson(GsonUtil.toJson(entry.getValue()), FlowTaskResult.class);
|
|
|
|
- if (flowTaskResultTemp.getSetup().intValue() == setup) {
|
|
|
|
- map.put(SystemConstant.FORM_PROPERTIES, flowTaskResultTemp);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return map;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "启动流程接口")
|
|
|
|
- @RequestMapping(value = "/start/flow", method = RequestMethod.POST)
|
|
|
|
|
|
+ @ApiOperation(value = "流程审批接口")
|
|
|
|
+ @RequestMapping(value = "/approve", 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> 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) {
|
|
|
|
|
|
+ public Result approve(@ApiParam(value = "流程部署id") @RequestParam(required = false) String flowDeploymentId,
|
|
|
|
+ @ApiParam(value = "流程操作", required = true) @RequestParam FlowApprovePassEnum approve,
|
|
|
|
+ @ApiParam(value = "流程任务id") @RequestParam(required = false) Long taskId,
|
|
|
|
+ @ApiParam(value = "流程表单数据") @RequestParam(required = false) String formProperties,
|
|
|
|
+ @ApiParam(value = "流程审批人") @RequestParam(required = false) List<Long> approveUserIds,
|
|
|
|
+ @ApiParam(value = "流程审批意见") @RequestParam(required = false) String approveRemark,
|
|
|
|
+// @ApiParam(value = "上传文件") @RequestParam(required = false) MultipartFile file,
|
|
|
|
+ HttpServletRequest request) {
|
|
Map<String, Object> map = new HashMap<>();
|
|
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();
|
|
@@ -199,102 +170,246 @@ public class ActivitiFromHtmlController {
|
|
}
|
|
}
|
|
map.putAll(formDataMap);
|
|
map.putAll(formDataMap);
|
|
|
|
|
|
- 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("流程没有部署数据!"));
|
|
|
|
|
|
+ List<String> approveIdList = null;
|
|
|
|
+ if (!CollectionUtils.isEmpty(approveUserIds)) {
|
|
|
|
+ approveIdList = approveUserIds.stream().map(s -> String.valueOf(s)).collect(Collectors.toList());
|
|
|
|
+ } else {
|
|
|
|
+ approveIdList.add("123");//否则是当前登录用户
|
|
|
|
+ }
|
|
String processFlowId = null;
|
|
String processFlowId = null;
|
|
TFCustomFlowEntity tfCustomFlowEntity = null;
|
|
TFCustomFlowEntity tfCustomFlowEntity = null;
|
|
TFFlowApprove tfFlowApprove = null;
|
|
TFFlowApprove tfFlowApprove = null;
|
|
- if (Objects.isNull(flowId)) {
|
|
|
|
- map.put(DefaultInstanceConvertToMultiInstance.DEFAULT_ASSIGNEE_LIST + 1, approveIdList);
|
|
|
|
|
|
+ Task taskTemp = null;
|
|
|
|
+ FlowResult flowResult = null;
|
|
|
|
+ if (Objects.nonNull(flowDeploymentId) && Objects.isNull(taskId)) {
|
|
|
|
+ TFCustomFlow tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
|
|
|
|
+ Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
|
|
|
|
+
|
|
|
|
+ map.put(SystemConstant.DEFAULT_ASSIGNEE_LIST + 1, approveIdList);
|
|
ProcessInstance processInstance = runtimeService.startProcessInstanceById(tfCustomFlow.getFlowDefinitionId(), map);
|
|
ProcessInstance processInstance = runtimeService.startProcessInstanceById(tfCustomFlow.getFlowDefinitionId(), map);
|
|
processFlowId = processInstance.getId();
|
|
processFlowId = processInstance.getId();
|
|
tfCustomFlowEntity = new TFCustomFlowEntity(tfCustomFlow.getId(), null);
|
|
tfCustomFlowEntity = new TFCustomFlowEntity(tfCustomFlow.getId(), null);
|
|
tfFlowApprove = new TFFlowApprove(null, Long.parseLong(approveIdList.get(approveIdList.size() - 1)), FlowStatusEnum.valueOf(approve.name()), 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));
|
|
|
|
|
|
+ flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
|
|
|
|
+ } else if (Objects.nonNull(taskId)) {
|
|
|
|
+ taskTemp = taskService.createTaskQuery().taskId(String.valueOf(taskId)).singleResult();
|
|
|
|
+ Optional.ofNullable(taskTemp).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程任务数据为空!"));
|
|
|
|
+ processFlowId = taskTemp.getProcessInstanceId();
|
|
}
|
|
}
|
|
- 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);
|
|
|
|
|
|
+ boolean lock = memoryLock.lock(SystemConstant.LOCK_FLOW_TASK_PREFIX + processFlowId, processFlowId, SystemConstant.LOCK_FLOW_TASK_TIME_OUT);
|
|
|
|
+ if (!lock) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("正在审批中,请稍候再试!");
|
|
}
|
|
}
|
|
- LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
|
|
|
|
+ try {
|
|
|
|
+ List<Task> taskList = new ArrayList<>();
|
|
|
|
+ if (Objects.isNull(taskTemp)) {
|
|
|
|
+ taskList = taskService.createTaskQuery().processInstanceId(processFlowId).list();
|
|
|
|
+ } else {
|
|
|
|
+ tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, Long.parseLong(processFlowId)));
|
|
|
|
+ Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有实例数据!"));
|
|
|
|
+ flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
|
|
|
|
|
|
- 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)) {
|
|
|
|
|
|
+ tfFlowApprove = tfFlowApproveService.getOne(new QueryWrapper<TFFlowApprove>().lambda().eq(TFFlowApprove::getFlowId, Long.parseLong(processFlowId)));
|
|
|
|
+ Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有审批数据!"));
|
|
|
|
+ taskList.add(taskTemp);
|
|
|
|
+ }
|
|
|
|
+ List<TFFlowLog> tfFlowLogList = new ArrayList<>();
|
|
|
|
+ LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
|
|
+
|
|
|
|
+ tfCustomFlowEntity.setFlowId(Long.parseLong(processFlowId));
|
|
|
|
+ tfFlowApprove.setFlowId(Long.parseLong(processFlowId));
|
|
|
|
+ tfFlowApprove.setApproveMaxSetup(setupMap.size());
|
|
for (Task task : taskList) {
|
|
for (Task task : taskList) {
|
|
- String currActivityId = task.getTaskDefinitionKey();
|
|
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
|
|
- FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId);
|
|
|
|
- FlowTaskResult currFlowTaskResult = null, nextFlowTaskResult = null;
|
|
|
|
|
|
+ FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(task.getTaskDefinitionKey());
|
|
|
|
+ FlowTaskResult currFlowTaskResult = null, nextFlowTaskResult = null, formDataFlowTaskResult = null;
|
|
Integer nrOfCompletedInstances = null, nrOfInstances = null;
|
|
Integer nrOfCompletedInstances = null, nrOfInstances = null;
|
|
boolean multiInstance = false;
|
|
boolean multiInstance = false;
|
|
if (currFlow instanceof UserTask) {
|
|
if (currFlow instanceof UserTask) {
|
|
if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
|
if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
|
|
- nrOfCompletedInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_COMPLETED_INSTANCES);
|
|
|
|
|
|
+ nrOfCompletedInstances = (Integer) taskService.getVariable(task.getId(), SystemConstant.NR_OF_COMPLETED_INSTANCES);
|
|
nrOfCompletedInstances++;
|
|
nrOfCompletedInstances++;
|
|
- nrOfInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_INSTANCES);
|
|
|
|
|
|
+ nrOfInstances = (Integer) taskService.getVariable(task.getId(), SystemConstant.NR_OF_INSTANCES);
|
|
multiInstance = true;
|
|
multiInstance = true;
|
|
}
|
|
}
|
|
- if (Objects.isNull(formProperties)) {
|
|
|
|
- currFlowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
|
|
|
|
- } else {
|
|
|
|
- currFlowTaskResult = JSONObject.parseObject(formProperties, FlowTaskResult.class);
|
|
|
|
|
|
+ currFlowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
|
|
|
|
+ if (Objects.nonNull(formProperties)) {
|
|
|
|
+ formDataFlowTaskResult = JSONObject.parseObject(formProperties, FlowTaskResult.class);
|
|
}
|
|
}
|
|
int currSetup = currFlowTaskResult.getSetup().intValue();
|
|
int currSetup = currFlowTaskResult.getSetup().intValue();
|
|
- currSetup = currSetup == setupMap.size() - 1 ? 0 : currSetup + 1;
|
|
|
|
-
|
|
|
|
|
|
+ if (currSetup != 1 && approve == FlowApprovePassEnum.START) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("只有流程第一步才需要提交!");
|
|
|
|
+ }
|
|
//流程流水日志
|
|
//流程流水日志
|
|
TFFlowLog tfFlowLog = new TFFlowLog(null, Long.parseLong(task.getAssignee()), null,
|
|
TFFlowLog tfFlowLog = new TFFlowLog(null, Long.parseLong(task.getAssignee()), null,
|
|
- FlowApproveOperationEnum.valueOf(approve.name()), currFlowTaskResult.getSetup(),
|
|
|
|
- FlowApproveSetupEnum.START.getTitle(), Long.parseLong(processFlowId),
|
|
|
|
|
|
+ currFlowTaskResult.getSetup(), Long.parseLong(processFlowId),
|
|
Long.parseLong(task.getId()), tfCustomFlowEntity.getId(), approveIdList.toString().replaceAll("\\[", "").replaceAll("\\]", ""));
|
|
Long.parseLong(task.getId()), tfCustomFlowEntity.getId(), approveIdList.toString().replaceAll("\\[", "").replaceAll("\\]", ""));
|
|
|
|
+ if (approve == FlowApprovePassEnum.PASS || approve == FlowApprovePassEnum.DRAFT || approve == FlowApprovePassEnum.START) {
|
|
|
|
+ currSetup = currSetup == setupMap.size() - 1 ? 0 : currSetup + 1;
|
|
|
|
+ nextFlowTaskResult = this.getNextFlowTaskResult(nrOfCompletedInstances,
|
|
|
|
+ nrOfInstances,
|
|
|
|
+ currFlowTaskResult,
|
|
|
|
+ nextFlowTaskResult,
|
|
|
|
+ currSetup,
|
|
|
|
+ setupMap,
|
|
|
|
+ approve);
|
|
|
|
|
|
- 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);
|
|
|
|
|
|
+ this.approvePass(currFlowTaskResult,
|
|
|
|
+ setupMap,
|
|
|
|
+ multiInstance,
|
|
|
|
+ nrOfCompletedInstances,
|
|
|
|
+ nrOfInstances,
|
|
|
|
+ tfFlowApprove,
|
|
|
|
+ tfFlowLog,
|
|
|
|
+ nextFlowTaskResult,
|
|
|
|
+ map,
|
|
|
|
+ approve,
|
|
|
|
+ approveRemark);
|
|
|
|
+ map.put(SystemConstant.DEFAULT_ASSIGNEE_LIST + nextFlowTaskResult.getSetup(), approveIdList);
|
|
|
|
+ } else if (approve == FlowApprovePassEnum.REJECT || approve == FlowApprovePassEnum.CANCEL) {
|
|
|
|
+ currSetup = currSetup - 1;
|
|
|
|
+ nextFlowTaskResult = this.getNextFlowTaskResult(nrOfCompletedInstances,
|
|
|
|
+ nrOfInstances,
|
|
|
|
+ currFlowTaskResult,
|
|
|
|
+ nextFlowTaskResult,
|
|
|
|
+ currSetup,
|
|
|
|
+ setupMap,
|
|
|
|
+ approve);
|
|
|
|
+
|
|
|
|
+ this.approveReject(multiInstance,
|
|
|
|
+ map,
|
|
|
|
+ currFlowTaskResult,
|
|
|
|
+ nextFlowTaskResult,
|
|
|
|
+ tfFlowApprove,
|
|
|
|
+ tfFlowLog,
|
|
|
|
+ approve,
|
|
|
|
+ approveRemark);
|
|
|
|
+ }
|
|
|
|
+ if (Objects.nonNull(formDataFlowTaskResult) && Objects.equals(task.getTaskDefinitionKey(), formDataFlowTaskResult.getTaskKey())) {
|
|
|
|
+ setupMap.put(task.getTaskDefinitionKey(), formDataFlowTaskResult);
|
|
|
|
+ }
|
|
flowResult.setSetupMap(setupMap);
|
|
flowResult.setSetupMap(setupMap);
|
|
tfCustomFlowEntity.setFlowProcessVar(JacksonUtil.parseJson(flowResult));
|
|
tfCustomFlowEntity.setFlowProcessVar(JacksonUtil.parseJson(flowResult));
|
|
- if (approve == FlowApprovePassEnum.START) {
|
|
|
|
|
|
+ if (approve != FlowApprovePassEnum.DRAFT && approve != FlowApprovePassEnum.REJECT) {
|
|
taskService.complete(task.getId(), map);
|
|
taskService.complete(task.getId(), map);
|
|
|
|
+ } else if (approve == FlowApprovePassEnum.REJECT) {
|
|
|
|
+ ((TaskServiceImpl) taskService).getCommandExecutor().execute(new ProcessEventRejectCmd(task.getId(), nextFlowTaskResult.getTaskKey(), map));
|
|
|
|
+ if (Objects.nonNull(map.get(SystemConstant.DEFAULT_ASSIGNEE_LIST + nextFlowTaskResult.getSetup()))) {
|
|
|
|
+ List<String> rejectApproveIdList = (List<String>) map.get(SystemConstant.DEFAULT_ASSIGNEE_LIST + nextFlowTaskResult.getSetup());
|
|
|
|
+ tfFlowLog.setPendApproveId(rejectApproveIdList.toString().replaceAll("\\[", "").replaceAll("\\]", ""));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
tfFlowLogList.add(tfFlowLog);
|
|
tfFlowLogList.add(tfFlowLog);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ tfCustomFlowEntityService.saveOrUpdate(tfCustomFlowEntity);
|
|
|
|
+ tfFlowApproveService.saveOrUpdate(tfFlowApprove);
|
|
|
|
+ tfFlowLogService.saveBatch(tfFlowLogList);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(SystemConstant.LOG_ERROR, e);
|
|
|
|
+ if (e instanceof ApiException) {
|
|
|
|
+ ResultUtil.error((ApiException) e, e.getMessage());
|
|
|
|
+ } else {
|
|
|
|
+ ResultUtil.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ } finally {
|
|
|
|
+ memoryLock.unlock(SystemConstant.LOCK_FLOW_TASK_PREFIX + processFlowId);
|
|
}
|
|
}
|
|
- tfCustomFlowEntityService.saveOrUpdate(tfCustomFlowEntity);
|
|
|
|
- tfFlowApproveService.saveOrUpdate(tfFlowApprove);
|
|
|
|
- tfFlowLogService.saveBatch(tfFlowLogList);
|
|
|
|
- return Collections.singletonMap("success", true);
|
|
|
|
|
|
+ return ResultUtil.ok(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "获取待办接口")
|
|
|
|
+ @RequestMapping(value = "/getTaskList", method = RequestMethod.POST)
|
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
|
|
+ public Result getTaskList(@ApiParam(value = "用户id", required = true) @RequestParam Long userId) {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ List<FormPropertyBean> formPropertyList = new LinkedList<>();
|
|
|
|
+ List<Task> taskList = taskService.createTaskQuery().taskAssignee(String.valueOf(userId)).list();
|
|
|
|
+ if (!CollectionUtils.isEmpty(taskList)) {
|
|
|
|
+ for (Task t : taskList) {
|
|
|
|
+ TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, Long.parseLong(t.getProcessInstanceId())));
|
|
|
|
+ Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有实例数据!"));
|
|
|
|
+ TFCustomFlow tfCustomFlow = tfCustomFlowService.getById(tfCustomFlowEntity.gettFCustomFlowId());
|
|
|
|
+ Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
|
|
|
|
+
|
|
|
|
+ FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
|
|
|
|
+ LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
|
|
+ for (Task task : taskList) {
|
|
|
|
+ FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
|
|
|
|
+ map = this.getFlowFormPropertie(flowResult, map, currFlowTaskResult.getSetup());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ formPropertyList.add(new FormPropertyBean(Long.parseLong(t.getProcessInstanceId()), Long.parseLong(t.getId()), userId, (FlowTaskResult) map.get(SystemConstant.FORM_PROPERTIES)));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return ResultUtil.ok(formPropertyList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// @ApiOperation(value = "流程提交接口")
|
|
|
|
+// @RequestMapping(value = "/complete", method = RequestMethod.POST)
|
|
|
|
+// @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
|
|
+// public Map<String, Object> complete(@ApiParam(value = "流程taskId", required = true) @RequestParam String taskId,
|
|
|
|
+// @ApiParam(value = "上传文件") @RequestParam(required = false) MultipartFile[] files, HttpServletRequest
|
|
|
|
+// request) {
|
|
|
|
+// Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
|
|
|
+// Map<String, Object> varMap = new HashMap<>();
|
|
|
|
+// Map<String, String> formDataMap = new HashMap<>();
|
|
|
|
+// Map<String, String[]> parameterMap = request.getParameterMap();
|
|
|
|
+// Set<Map.Entry<String, String[]>> entrySet = parameterMap.entrySet();
|
|
|
|
+// for (Map.Entry<String, String[]> entry : entrySet) {
|
|
|
|
+// String key = entry.getKey();
|
|
|
|
+// String[] value = entry.getValue();
|
|
|
|
+// formDataMap.put(key, value[0]);
|
|
|
|
+// }
|
|
|
|
+// varMap.putAll(formDataMap);
|
|
|
|
+// String flowTaskId = task.getId();
|
|
|
|
+// String processInstanceId = task.getProcessInstanceId();
|
|
|
|
+// String processDefinitionId = task.getProcessDefinitionId();
|
|
|
|
+// formService.submitTaskFormData(flowTaskId, formDataMap);
|
|
|
|
+// List<Task> taskList = taskService.createTaskQuery().processInstanceId(processInstanceId).list();
|
|
|
|
+// if (!CollectionUtils.isEmpty(taskList)) {
|
|
|
|
+// List<FormPropertyBean> formPropertyList = new LinkedList<>();
|
|
|
|
+// for (Task t : taskList) {
|
|
|
|
+// String nextFlowTaskId = t.getId();
|
|
|
|
+// Object o = formService.getRenderedTaskForm(nextFlowTaskId);
|
|
|
|
+// log.info("userId:{},taskId:{},flowId:{},processDefinitionId:{}", t.getAssignee(), nextFlowTaskId, processInstanceId, processDefinitionId);
|
|
|
|
+// 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(), null));
|
|
|
|
+// }
|
|
|
|
+// varMap.put("formProperties", formPropertyList);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// return varMap;
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "结束流程接口")
|
|
|
|
+ @RequestMapping(value = "/delete", method = RequestMethod.POST)
|
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
|
|
+ public Result delete(String runId) {
|
|
|
|
+ return ResultUtil.ok(activitiConsumerService.deleteProcessInstance(runId));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取表单属性
|
|
|
|
+ *
|
|
|
|
+ * @param flowResult
|
|
|
|
+ * @param map
|
|
|
|
+ * @param setup
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public Map<String, Object> getFlowFormPropertie(FlowResult flowResult, Map<String, Object> map, int setup) {
|
|
|
|
+ Map<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
|
|
+ for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
|
|
|
|
+ FlowTaskResult flowTaskResultTemp = GsonUtil.fromJson(GsonUtil.toJson(entry.getValue()), FlowTaskResult.class);
|
|
|
|
+ if (flowTaskResultTemp.getSetup().intValue() == setup) {
|
|
|
|
+ map.put(SystemConstant.FORM_PROPERTIES, flowTaskResultTemp);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return map;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -310,6 +425,7 @@ public class ActivitiFromHtmlController {
|
|
* @param nextFlowTaskResult
|
|
* @param nextFlowTaskResult
|
|
* @param map
|
|
* @param map
|
|
* @param approvePass
|
|
* @param approvePass
|
|
|
|
+ * @param approveRemark
|
|
*/
|
|
*/
|
|
public void approvePass(FlowTaskResult currFlowTaskResult,
|
|
public void approvePass(FlowTaskResult currFlowTaskResult,
|
|
Map<String, FlowTaskResult> setupMap,
|
|
Map<String, FlowTaskResult> setupMap,
|
|
@@ -320,7 +436,8 @@ public class ActivitiFromHtmlController {
|
|
TFFlowLog tfFlowLog,
|
|
TFFlowLog tfFlowLog,
|
|
FlowTaskResult nextFlowTaskResult,
|
|
FlowTaskResult nextFlowTaskResult,
|
|
Map<String, Object> map,
|
|
Map<String, Object> map,
|
|
- FlowApprovePassEnum approvePass) {
|
|
|
|
|
|
+ FlowApprovePassEnum approvePass,
|
|
|
|
+ String approveRemark) {
|
|
if (multiInstance) {
|
|
if (multiInstance) {
|
|
map.computeIfAbsent(FlowApproveOperationEnum.REJECT.getId() + currFlowTaskResult.getSetup(), v -> 0);
|
|
map.computeIfAbsent(FlowApproveOperationEnum.REJECT.getId() + currFlowTaskResult.getSetup(), v -> 0);
|
|
}
|
|
}
|
|
@@ -352,7 +469,46 @@ public class ActivitiFromHtmlController {
|
|
} else {
|
|
} else {
|
|
tfFlowLog.setApproveOperation(FlowApproveOperationEnum.APPROVE);
|
|
tfFlowLog.setApproveOperation(FlowApproveOperationEnum.APPROVE);
|
|
}
|
|
}
|
|
- map.put(SystemConstant.APPROVE, nextFlowTaskResult.getTaskKey());
|
|
|
|
|
|
+ if (Objects.nonNull(approveRemark)) {
|
|
|
|
+ tfFlowLog.setApproveRemark(approveRemark);
|
|
|
|
+ } else {
|
|
|
|
+ tfFlowLog.setApproveRemark(tfFlowLog.getApproveOperation().getTitle());
|
|
|
|
+ }
|
|
|
|
+// map.put(SystemConstant.APPROVE, nextFlowTaskResult.getTaskKey());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 审批驳回
|
|
|
|
+ *
|
|
|
|
+ * @param multiInstance
|
|
|
|
+ * @param map
|
|
|
|
+ * @param currFlowTaskResult
|
|
|
|
+ * @param nextFlowTaskResult
|
|
|
|
+ * @param tfFlowApprove
|
|
|
|
+ * @param tfFlowLog
|
|
|
|
+ * @param approvePass
|
|
|
|
+ * @param approveRemark
|
|
|
|
+ */
|
|
|
|
+ protected void approveReject(boolean multiInstance,
|
|
|
|
+ Map<String, Object> map,
|
|
|
|
+ FlowTaskResult currFlowTaskResult,
|
|
|
|
+ FlowTaskResult nextFlowTaskResult,
|
|
|
|
+ TFFlowApprove tfFlowApprove,
|
|
|
|
+ TFFlowLog tfFlowLog,
|
|
|
|
+ FlowApprovePassEnum approvePass,
|
|
|
|
+ String approveRemark) {
|
|
|
|
+ if (multiInstance) {
|
|
|
|
+ map.computeIfAbsent(FlowApproveOperationEnum.REJECT.getId() + currFlowTaskResult.getSetup(), v -> 1);
|
|
|
|
+ }
|
|
|
|
+// map.put(SystemConstant.APPROVE, nextFlowTaskResult.getTaskKey());
|
|
|
|
+ tfFlowApprove.setSetup(nextFlowTaskResult.getSetup());
|
|
|
|
+ tfFlowApprove.setStatus(FlowStatusEnum.convertToEnum(approvePass.name()));
|
|
|
|
+ tfFlowLog.setApproveOperation(FlowApproveOperationEnum.convertToEnum(approvePass.name()));
|
|
|
|
+ if (Objects.nonNull(approveRemark)) {
|
|
|
|
+ tfFlowLog.setApproveRemark(approveRemark);
|
|
|
|
+ } else {
|
|
|
|
+ tfFlowLog.setApproveRemark(tfFlowLog.getApproveOperation().getTitle());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -409,78 +565,4 @@ public class ActivitiFromHtmlController {
|
|
}
|
|
}
|
|
return nextFlowTaskResult;
|
|
return nextFlowTaskResult;
|
|
}
|
|
}
|
|
-
|
|
|
|
- @ApiOperation(value = "获取待办接口")
|
|
|
|
- @RequestMapping(value = "/getTaskList", method = RequestMethod.POST)
|
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
|
|
- public Map<String, Object> getTaskList(@ApiParam(value = "用户id", required = true) @RequestParam String
|
|
|
|
- userId, HttpServletRequest request) {
|
|
|
|
- Map<String, Object> varMap = new HashMap<>();
|
|
|
|
- List<Task> taskList = taskService.createTaskQuery().taskAssignee(userId).list();
|
|
|
|
- if (!CollectionUtils.isEmpty(taskList)) {
|
|
|
|
- List<FormPropertyBean> formPropertyList = new LinkedList<>();
|
|
|
|
- for (Task t : taskList) {
|
|
|
|
- String flowTaskId = t.getId();
|
|
|
|
- String processInstanceId = t.getProcessInstanceId();
|
|
|
|
- String processDefinitionId = t.getProcessDefinitionId();
|
|
|
|
- log.info("用户id:{},taskId:{},flowId:{},processDefinitionId:{},formKey:{}", userId, flowTaskId, processInstanceId, processDefinitionId, t.getFormKey());
|
|
|
|
- if (Objects.nonNull(t.getFormKey())) {
|
|
|
|
- Object o = formService.getRenderedTaskForm(flowTaskId);
|
|
|
|
- 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, userId, null));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- varMap.put("formProperties", formPropertyList);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return varMap;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "流程提交接口")
|
|
|
|
- @RequestMapping(value = "/complete", method = RequestMethod.POST)
|
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
|
|
- public Map<String, Object> complete(@ApiParam(value = "流程taskId", required = true) @RequestParam String taskId,
|
|
|
|
- @ApiParam(value = "上传文件") @RequestParam(required = false) MultipartFile[] files, HttpServletRequest
|
|
|
|
- request) {
|
|
|
|
- Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
|
|
|
- Map<String, Object> varMap = new HashMap<>();
|
|
|
|
- Map<String, String> formDataMap = new HashMap<>();
|
|
|
|
- Map<String, String[]> parameterMap = request.getParameterMap();
|
|
|
|
- Set<Map.Entry<String, String[]>> entrySet = parameterMap.entrySet();
|
|
|
|
- for (Map.Entry<String, String[]> entry : entrySet) {
|
|
|
|
- String key = entry.getKey();
|
|
|
|
- String[] value = entry.getValue();
|
|
|
|
- formDataMap.put(key, value[0]);
|
|
|
|
- }
|
|
|
|
- varMap.putAll(formDataMap);
|
|
|
|
- String flowTaskId = task.getId();
|
|
|
|
- String processInstanceId = task.getProcessInstanceId();
|
|
|
|
- String processDefinitionId = task.getProcessDefinitionId();
|
|
|
|
- formService.submitTaskFormData(flowTaskId, formDataMap);
|
|
|
|
- List<Task> taskList = taskService.createTaskQuery().processInstanceId(processInstanceId).list();
|
|
|
|
- if (!CollectionUtils.isEmpty(taskList)) {
|
|
|
|
- List<FormPropertyBean> formPropertyList = new LinkedList<>();
|
|
|
|
- for (Task t : taskList) {
|
|
|
|
- String nextFlowTaskId = t.getId();
|
|
|
|
- Object o = formService.getRenderedTaskForm(nextFlowTaskId);
|
|
|
|
- log.info("userId:{},taskId:{},flowId:{},processDefinitionId:{}", t.getAssignee(), nextFlowTaskId, processInstanceId, processDefinitionId);
|
|
|
|
- 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(), null));
|
|
|
|
- }
|
|
|
|
- varMap.put("formProperties", formPropertyList);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return varMap;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "结束流程接口")
|
|
|
|
- @RequestMapping(value = "/deleteProcessInstance", method = RequestMethod.POST)
|
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
|
|
- public boolean deleteProcessInstance(String runId) {
|
|
|
|
- return activitiConsumerService.deleteProcessInstance(runId);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|