From 00bb00a69828a9b5035531662d975fde8b957a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Fri, 20 Dec 2024 11:50:52 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=B8=B4=E6=97=B6=E4=BF=AE=E5=A4=8D=20wa?= =?UTF-8?q?rm=E5=8F=82=E6=95=B0=E8=AF=BB=E5=8F=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/controller/WarmFlowController.java | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/warm/flow/ui/controller/WarmFlowController.java diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/warm/flow/ui/controller/WarmFlowController.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/warm/flow/ui/controller/WarmFlowController.java new file mode 100644 index 000000000..b7fe87a4d --- /dev/null +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/warm/flow/ui/controller/WarmFlowController.java @@ -0,0 +1,162 @@ +/* + * Copyright 2024-2025, Warm-Flow (290631660@qq.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.dromara.warm.flow.ui.controller; + +import org.dromara.warm.flow.core.FlowFactory; +import org.dromara.warm.flow.core.dto.ApiResult; +import org.dromara.warm.flow.core.entity.Node; +import org.dromara.warm.flow.core.exception.FlowException; +import org.dromara.warm.flow.core.invoker.FrameInvoker; +import org.dromara.warm.flow.core.utils.ExceptionUtil; +import org.dromara.warm.flow.ui.dto.DefDto; +import org.dromara.warm.flow.ui.dto.HandlerQuery; +import org.dromara.warm.flow.ui.service.HandlerSelectService; +import org.dromara.warm.flow.ui.vo.HandlerSelectVo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import java.util.Collections; +import java.util.List; + +/** + * 设计器Controller 可选择是否放行,放行可与业务系统共享权限,主要是用来访问业务系统数据 + * + * @author warm + */ +@RestController +@RequestMapping("/warm-flow") +public class WarmFlowController { + + private static final Logger log = LoggerFactory.getLogger(WarmFlowController.class); + + /** + * 保存流程xml字符串 + * @param defDto 流程定义dto + * @return ApiResult + * @throws Exception 异常 + */ + @PostMapping("/save-xml") + @Transactional(rollbackFor = Exception.class) + public ApiResult saveXml(@RequestBody DefDto defDto) throws Exception { + FlowFactory.defService().saveXml(defDto.getId(), defDto.getXmlString()); + return ApiResult.ok(); + } + + /** + * 获取流程xml字符串 + * @param id 流程定义id + * @return ApiResult + */ + @GetMapping("/xml-string/{id}") + public ApiResult xmlString(@PathVariable("id") Long id) { + try { + return ApiResult.ok(FlowFactory.defService().xmlString(id)); + } catch (Exception e) { + log.error("获取流程xml字符串", e); + throw new FlowException(ExceptionUtil.handleMsg("获取流程xml字符串失败", e)); + } + } + + /** + * 保存流程json字符串 + * + * @param defDto 流程定义dto + * @return ApiResult + * @throws Exception 异常 + * @author xiarg + * @since 2024/10/29 16:31 + */ + @PostMapping("/save-json") + @Transactional(rollbackFor = Exception.class) + public ApiResult saveJson(@RequestBody DefDto defDto) throws Exception { + FlowFactory.defService().saveJson(defDto.getId(), defDto.getJsonString()); + return ApiResult.ok(); + } + + /** + * 获取流程xml字符串 + * + * @param id 流程定义id + * @return ApiResult + * @author xiarg + * @since 2024/10/29 16:31 + */ + @GetMapping("/json-string/{id}") + public ApiResult jsonString(@PathVariable("id") Long id) { + try { + return ApiResult.ok(FlowFactory.defService().jsonString(id)); + } catch (Exception e) { + log.error("获取流程json字符串", e); + throw new FlowException(ExceptionUtil.handleMsg("获取流程json字符串失败", e)); + } + } + + /** + * 办理人权限设置列表tabs页签 + * @return List + */ + @GetMapping("/handler-type") + public ApiResult> handlerType() { + try { + // 需要业务系统实现该接口 + HandlerSelectService handlerSelectService = FrameInvoker.getBean(HandlerSelectService.class); + if (handlerSelectService == null) { + return ApiResult.ok(Collections.emptyList()); + } + List handlerType = handlerSelectService.getHandlerType(); + return ApiResult.ok(handlerType); + } catch (Exception e) { + log.error("办理人权限设置列表tabs页签异常", e); + throw new FlowException(ExceptionUtil.handleMsg("办理人权限设置列表tabs页签失败", e)); + } + } + + /** + * 办理人权限设置列表结果 + * @return HandlerSelectVo + */ + @GetMapping("/handler-result") + public ApiResult handlerResult(HandlerQuery query) { + try { + // 需要业务系统实现该接口 + HandlerSelectService handlerSelectService = FrameInvoker.getBean(HandlerSelectService.class); + if (handlerSelectService == null) { + return ApiResult.ok(new HandlerSelectVo()); + } + HandlerSelectVo handlerSelectVo = handlerSelectService.getHandlerSelect(query); + return ApiResult.ok(handlerSelectVo); + } catch (Exception e) { + log.error("办理人权限设置列表结果异常", e); + throw new FlowException(ExceptionUtil.handleMsg("办理人权限设置列表结果失败", e)); + } + } + /** + * 获取所有的前置节点集合 + * @return List + */ + @GetMapping("/previous-node-list/{definitionId}/{nowNodeCode}") + public ApiResult> previousNodeList(@PathVariable("definitionId") Long definitionId, + @PathVariable("nowNodeCode") String nowNodeCode) { + try { + return ApiResult.ok(FlowFactory.nodeService().previousNodeList(definitionId, nowNodeCode)); + } catch (Exception e) { + log.error("获取所有的前置节点集合异常", e); + throw new FlowException(ExceptionUtil.handleMsg("获取所有的前置节点集合失败", e)); + } + } +}