| | |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.flowable.engine.TaskService; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.mdm.basesetting.machine.vo.MachineSaveVO; |
| | | import org.springblade.mdm.flow.excution.StartDispatcher; |
| | | import org.springblade.mdm.flow.vo.TaskAssignVO; |
| | | import org.springblade.mdm.program.service.ProcessProgRefService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | private StartDispatcher dispatcher; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private ProcessProgRefService processProgRefService; |
| | | /** |
| | | * 新增 |
| | | */ |
| | | @PostMapping("/start") |
| | | @Operation(summary = "任务计划(派工流程)", description = "启动派工流程") |
| | | public R<Boolean> save(@RequestBody TaskAssignVO startVO) { |
| | | public R<Boolean> start(@RequestBody TaskAssignVO startVO) { |
| | | dispatcher.start(startVO); |
| | | return R.<Boolean>status(true); |
| | | return R.status(true); |
| | | } |
| | | |
| | | @Operation(summary = "完成任务", description = "流向下一个节点") |
| | | @PostMapping("completeTask") |
| | | public R<Void> completeTask(String taskId, String processInstanceId, String comment,@Parameter(name="variables",description = "任务变量")@RequestBody Map<String, Object> variables) { |
| | | public R<Void> completeTask(String taskId, String processInstanceId, String comment,@Parameter(description = "对应的程序id,逗号分隔") String programIds, @Parameter(name = "variables", description = "任务变量") @RequestBody Map<String, Object> variables) { |
| | | // 增加评论 |
| | | if (StringUtil.isNoneBlank(processInstanceId, comment)) { |
| | | taskService.addComment(taskId, processInstanceId, comment); |
| | |
| | | if (Func.isEmpty(variables)) { |
| | | variables = Kv.create(); |
| | | } |
| | | // 完成任务 |
| | | taskService.complete(taskId, variables); |
| | | return R.success("流程提交成功"); |
| | | if(StringUtils.isNotEmpty(programIds)) { |
| | | processProgRefService.addRelations(processInstanceId,Func.toLongList(programIds)); |
| | | } |
| | | |
| | | //加入审批用户 |
| | | variables.put("approveUserNickName",AuthUtil.getNickName()); |
| | | if(variables.containsKey("assignee")){ |
| | | //指定了下一步执行人 |
| | | taskService.complete(taskId, variables); |
| | | return R.success("流程提交成功"); |
| | | }else { |
| | | // 完成任务,给默认用户 |
| | | return R.fail("请指定流程下一步处理人"); |
| | | } |
| | | |
| | | } |
| | | } |