diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowDefinitionController.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowDefinitionController.java index d518259..c4015ee 100644 --- a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowDefinitionController.java +++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowDefinitionController.java @@ -77,7 +77,7 @@ public class FlowDefinitionController extends BaseController { InputStream in = null; try { in = file.getInputStream(); - flowDefinitionService.importFile(name, category, in); + flowDefinitionService.importFile(name, category, null , in); } catch (Exception e) { log.error("导入失败:", e); return AjaxResult.success(e.getMessage()); @@ -102,7 +102,6 @@ public class FlowDefinitionController extends BaseController { } catch (Exception e) { return AjaxResult.error("加载xml文件异常"); } - } @ApiOperation(value = "读取图片文件") @@ -129,7 +128,6 @@ public class FlowDefinitionController extends BaseController { e.printStackTrace(); } } - } @ApiOperation(value = "保存流程设计器内的xml文件") @@ -138,7 +136,7 @@ public class FlowDefinitionController extends BaseController { InputStream in = null; try { in = new ByteArrayInputStream(vo.getXml().getBytes(StandardCharsets.UTF_8)); - flowDefinitionService.importFile(vo.getName(), vo.getCategory(), in); + flowDefinitionService.importFile(vo.getName(), vo.getCategory(), vo.getOwnerDeptId(), in); } catch (Exception e) { log.error("导入失败:", e); return AjaxResult.error(e.getMessage()); @@ -151,7 +149,6 @@ public class FlowDefinitionController extends BaseController { log.error("关闭输入流出错", e); } } - return AjaxResult.success("导入成功"); } diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/domain/FlowSaveXmlVo.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/domain/FlowSaveXmlVo.java index d267fb3..46d9fbe 100644 --- a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/domain/FlowSaveXmlVo.java +++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/domain/FlowSaveXmlVo.java @@ -21,6 +21,11 @@ public class FlowSaveXmlVo implements Serializable { */ private String category; + /** + * 流程单位 + */ + private String ownerDeptId; + /** * xml 文件 */ diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowDefinitionService.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowDefinitionService.java index 11bc7bd..bdf0a99 100644 --- a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowDefinitionService.java +++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowDefinitionService.java @@ -33,7 +33,7 @@ public interface IFlowDefinitionService { * @param category * @param in */ - void importFile(String name, String category, InputStream in); + void importFile(String name, String category, String OwnerDeptId, InputStream in); /** * 读取xml diff --git a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java index ae3c064..36e1b20 100644 --- a/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java +++ b/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java @@ -3,10 +3,13 @@ package com.yanzhu.flowable.service.impl; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.yanzhu.common.core.text.Convert; +import com.yanzhu.common.utils.StringUtils; import com.yanzhu.flowable.common.constant.ProcessConstants; import com.yanzhu.common.core.domain.AjaxResult; import com.yanzhu.common.core.domain.entity.SysUser; import com.yanzhu.common.utils.SecurityUtils; +import com.yanzhu.system.domain.flowable.FlowDeptVo; import com.yanzhu.system.domain.flowable.FlowQueryVo; import com.yanzhu.system.domain.FlowProcDefDto; import com.yanzhu.flowable.factory.FlowServiceFactory; @@ -98,16 +101,31 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl * * 当每个key的流程第一次部署时,指定版本为1。对其后所有使用相同key的流程定义, * 部署时版本会在该key当前已部署的最高版本号基础上加1。key参数用于区分流程定义 - * @param name - * @param category - * @param in + * @param name 流程名称 + * @param category 流程类型 + * @param OwnerDeptId 流程单位 + * @param in 流程文件流 */ @Override - public void importFile(String name, String category, InputStream in) { + public void importFile(String name, String category, String OwnerDeptId, InputStream in) { Deployment deploy = repositoryService.createDeployment().addInputStream(name + BPMN_FILE_SUFFIX, in).name(name).category(category).deploy(); ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult(); repositoryService.setProcessDefinitionCategory(definition.getId(), category); - + /**新增流程单位关系**/ + FlowDeptVo flowDeptVo = new FlowDeptVo(); + flowDeptVo.setProcdefId(definition.getId()); + //超管能为 + if(SecurityUtils.isAdmin(SecurityUtils.getUserId())){ + if(StringUtils.isNotEmpty(OwnerDeptId)){ + // OwnerDeptId转换Long失败...默认返回null + flowDeptVo.setDeptId(Convert.toLong(OwnerDeptId)); + } + }else{ + // 从部门祖籍列表中获取项目单位信息... + Long projectDeptId = Convert.toLong(SecurityUtils.getLoginUser().getUser().getDept().getAncestors().split(",")[2]); + flowDeptVo.setDeptId(projectDeptId); + } + flowDeployMapper.insertActReProcdefDept(flowDeptVo); } /** diff --git a/yanzhu-system/src/main/java/com/yanzhu/system/domain/flowable/FlowDeptVo.java b/yanzhu-system/src/main/java/com/yanzhu/system/domain/flowable/FlowDeptVo.java new file mode 100644 index 0000000..baa5283 --- /dev/null +++ b/yanzhu-system/src/main/java/com/yanzhu/system/domain/flowable/FlowDeptVo.java @@ -0,0 +1,39 @@ +package com.yanzhu.system.domain.flowable; + +import com.yanzhu.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + + +/** + *
工作流项目单位关系
+ *
+ * @author JiangYuQi
+ * @date 2024-02-23
+ */
+@Data
+@ApiModel("工作流项目单位关系")
+public class FlowDeptVo extends BaseEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /** 流程定义主键 */
+ private String procdefId;
+
+ /** 流程定义单位 */
+ private Long deptId;
+
+ /** 流程定义排序 */
+ private String sort;
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+ .append("procdefId", getProcdefId())
+ .append("deptId", getDeptId())
+ .append("sort", getSort())
+ .toString();
+ }
+}
diff --git a/yanzhu-system/src/main/java/com/yanzhu/system/mapper/FlowDeployMapper.java b/yanzhu-system/src/main/java/com/yanzhu/system/mapper/FlowDeployMapper.java
index 5997a74..ea95b3d 100644
--- a/yanzhu-system/src/main/java/com/yanzhu/system/mapper/FlowDeployMapper.java
+++ b/yanzhu-system/src/main/java/com/yanzhu/system/mapper/FlowDeployMapper.java
@@ -1,6 +1,7 @@
package com.yanzhu.system.mapper;
import com.yanzhu.system.domain.FlowProcDefDto;
+import com.yanzhu.system.domain.flowable.FlowDeptVo;
import com.yanzhu.system.domain.flowable.FlowQueryVo;
import org.apache.ibatis.annotations.Param;
@@ -21,4 +22,12 @@ public interface FlowDeployMapper {
* @return
*/
List