From 02fa716c48528ec2344a965d8d479d3a8a894940 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Wed, 18 May 2022 10:09:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E5=8F=B0=E9=A1=B5=E9=9D=A2=E9=A9=B3?= =?UTF-8?q?=E5=9B=9E=E5=90=8E=EF=BC=8C=E9=87=8D=E6=96=B0=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E5=8F=91=E8=B5=B7=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/RejectController.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 renren-admin/src/main/java/io/renren/common/controller/RejectController.java diff --git a/renren-admin/src/main/java/io/renren/common/controller/RejectController.java b/renren-admin/src/main/java/io/renren/common/controller/RejectController.java new file mode 100644 index 00000000..c16b2334 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/common/controller/RejectController.java @@ -0,0 +1,55 @@ +package io.renren.common.controller; + + +import io.renren.common.utils.Result; +import io.renren.modules.activiti.service.ActTaskService; +import io.renren.modules.sys.dto.SysUserDTO; +import io.renren.modules.sys.service.SysUserService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.activiti.engine.TaskService; +import org.activiti.engine.task.Task; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicReference; + +@Api(tags = "前台流程驳回") +@RestController +@RequestMapping("/reject/center") +public class RejectController { + @Autowired + protected TaskService taskService; + @Autowired + private ActTaskService actTaskService; + @Autowired + private SysUserService sysUserService; + + + @PostMapping("relaunch/{taskId}") + @ApiOperation("携带更新后的表单重新发起流程") + public Result relaunch(@PathVariable("taskId") String taskId, @RequestBody Map params) { + if (StringUtils.isEmpty(taskId)) { + return new Result().error("流程taskId未传参"); + } + AtomicReference result = new AtomicReference<>(new Result().error("重新发起流程失败")); + Optional taskOptional = Optional.ofNullable(taskService.createTaskQuery().taskId(taskId).includeProcessVariables().singleResult()); + taskOptional.ifPresent(task -> { + Map combineResultMap = new HashMap<>(); + combineResultMap.putAll(task.getProcessVariables()); + combineResultMap.putAll(params); + taskService.setVariables(task.getId(), combineResultMap); // 更新 + taskService.setVariable(task.getId(), "backToFirst", Boolean.FALSE); // + taskService.setVariable(task.getId(), "completeEntry", Boolean.FALSE); // + Optional userDTOOptional = Optional.ofNullable(sysUserService.get(Long.valueOf(task.getAssignee()))); + String name = userDTOOptional.isPresent() ? userDTOOptional.get().getRealName() : ""; + actTaskService.completeTask(task.getId(), name + "重新发起审核"); + result.set(new Result().ok(name + "重新发起审核成功")); + }); + return result.get(); + } +}