前台页面驳回后,重新提交表单发起流程
This commit is contained in:
parent
c073b8fe41
commit
02fa716c48
|
@ -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<String, Object> params) {
|
||||||
|
if (StringUtils.isEmpty(taskId)) {
|
||||||
|
return new Result().error("流程taskId未传参");
|
||||||
|
}
|
||||||
|
AtomicReference<Result> result = new AtomicReference<>(new Result().error("重新发起流程失败"));
|
||||||
|
Optional<Task> taskOptional = Optional.ofNullable(taskService.createTaskQuery().taskId(taskId).includeProcessVariables().singleResult());
|
||||||
|
taskOptional.ifPresent(task -> {
|
||||||
|
Map<String, Object> 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<SysUserDTO> 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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue