diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmProcessDefinitionController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmProcessDefinitionController.java index f7d7bbc9c..bef74733e 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmProcessDefinitionController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmProcessDefinitionController.java @@ -32,6 +32,8 @@ public class BpmProcessDefinitionController { @Resource private BpmProcessDefinitionService bpmDefinitionService; + // TODO 芋艿:权限相关 + @GetMapping ("/page") @ApiOperation(value = "获得流程定义分页") @PreAuthorize("@ss.hasPermission('bpm:model:query')") // 暂时使用 model 的权限标识 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/form/BpmFormRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/form/BpmFormRespVO.java index cd7302b5c..89c2eb930 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/form/BpmFormRespVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/form/BpmFormRespVO.java @@ -18,6 +18,7 @@ public class BpmFormRespVO extends BpmFormBaseVO { @ApiModelProperty(value = "表单编号", required = true, example = "1024") private Long id; + @ApiModelProperty(value = "表单的配置", required = true, notes = "JSON 字符串") @NotNull(message = "表单的配置不能为空") private String conf; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/process/BpmProcessDefinitionRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/process/BpmProcessDefinitionRespVO.java index 8e3435b18..4e0f51864 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/process/BpmProcessDefinitionRespVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/process/BpmProcessDefinitionRespVO.java @@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; @ApiModel("流程定义 Response VO") @Data @@ -27,8 +29,22 @@ public class BpmProcessDefinitionRespVO { @NotEmpty(message = "流程分类不能为空") private String category; - @ApiModelProperty(value = "表单编号", example = "1024") + @ApiModelProperty(value = "表单类型", notes = "参见 bpm_model_form_type 数据字典", example = "1") + private Integer formType; + @ApiModelProperty(value = "表单编号", example = "1024", notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空") private Long formId; + @ApiModelProperty(value = "表单的配置", required = true, + notes = "JSON 字符串。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空") + private String formConf; + @ApiModelProperty(value = "表单项的数组", required = true, + notes = "JSON 字符串的数组。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空") + private List formFields; + @ApiModelProperty(value = "自定义表单的提交路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/create", + notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空") + private String formCustomCreatePath; + @ApiModelProperty(value = "自定义表单的查看路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/view", + notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空") + private String formCustomViewPath; @ApiModelProperty(value = "中断状态", required = true, example = "1", notes = "参见 SuspensionState 枚举") private Integer suspensionState; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmModelConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmModelConvert.java index 880c52a2a..ceecfcfa4 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmModelConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmModelConvert.java @@ -83,7 +83,7 @@ public interface BpmModelConvert { void copyTo(BpmModelMetaInfoRespDTO from, @MappingTarget BpmModelBaseVO to); - default BpmDefinitionCreateReqDTO convert2(Model model) { + default BpmDefinitionCreateReqDTO convert2(Model model, BpmFormDO form) { BpmDefinitionCreateReqDTO createReqDTO = new BpmDefinitionCreateReqDTO(); createReqDTO.setModelId(model.getId()); createReqDTO.setName(model.getName()); @@ -92,6 +92,11 @@ public interface BpmModelConvert { BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); // metaInfo copyTo(metaInfo, createReqDTO); + // form + if (form != null) { + createReqDTO.setFormConf(form.getConf()); + createReqDTO.setFormFields(form.getFields()); + } return createReqDTO; } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmProcessDefinitionConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmProcessDefinitionConvert.java index 48ea21cc9..8cb9fb356 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmProcessDefinitionConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmProcessDefinitionConvert.java @@ -11,6 +11,7 @@ import org.activiti.engine.repository.Deployment; import org.activiti.engine.repository.ProcessDefinition; import org.mapstruct.Mapper; import org.mapstruct.Mapping; +import org.mapstruct.MappingTarget; import org.mapstruct.Named; import org.mapstruct.factory.Mappers; @@ -38,19 +39,17 @@ public interface BpmProcessDefinitionConvert { } default BpmProcessDefinitionPageItemRespVO convert(ProcessDefinition bean, Deployment deployment, - BpmProcessDefinitionExtDO processDefinitionDO, BpmFormDO form) { + BpmProcessDefinitionExtDO processDefinitionExtDO, BpmFormDO form) { BpmProcessDefinitionPageItemRespVO respVO = convert(bean); respVO.setSuspensionState(bean.isSuspended() ? SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode()); if (deployment != null) { respVO.setDeploymentTime(deployment.getDeploymentTime()); } if (form != null) { - respVO.setFormId(form.getId()); respVO.setFormName(form.getName()); } - if (processDefinitionDO != null) { - respVO.setDescription(processDefinitionDO.getDescription()); - } + // 复制通用属性 + copyTo(processDefinitionExtDO, respVO); return respVO; } @@ -63,9 +62,8 @@ public interface BpmProcessDefinitionConvert { return CollectionUtils.convertList(list, processDefinition -> { BpmProcessDefinitionRespVO respVO = convert3(processDefinition); BpmProcessDefinitionExtDO processDefinitionExtDO = processDefinitionDOMap.get(processDefinition.getId()); - if (processDefinitionExtDO != null) { - respVO.setFormId(processDefinitionExtDO.getFormId()); - } + // 复制通用属性 + copyTo(processDefinitionExtDO, respVO); return respVO; }); } @@ -79,4 +77,7 @@ public interface BpmProcessDefinitionConvert { SuspensionState.ACTIVE.getStateCode(); } + @Mapping(source = "from.id", target = "to.id", ignore = true) + void copyTo(BpmProcessDefinitionExtDO from, @MappingTarget BpmProcessDefinitionRespVO to); + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/definition/BpmFormDataDO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/definition/BpmFormDataDO.java deleted file mode 100644 index dc9c19dc8..000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/definition/BpmFormDataDO.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.List; -import java.util.Map; - -/** - * 工作流的表单结果 - * 用户每次填写工作流的申请表单时,会保存一条记录到该表】 - * - * @author 芋道源码 - */ -@TableName(value = "bpm_form_data", autoResultMap = true) -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmFormDataDO extends BaseDO { - - /** - * 编号 - */ - private Long id; - /** - * 表单编号 - * - * 关联 {@link BpmFormDO#getId()} - */ - private Long formId; - /** - * 状态 - */ - private Integer status; - /** - * 表单配置 - * - * 冗余 {@link BpmFormDO#getFields()} - * 主要考虑,表单是可以修改的 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List fields; - /** - * 表单值 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private Map values; - -} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/definition/BpmProcessDefinitionExtDO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/definition/BpmProcessDefinitionExtDO.java index 7bfa86e8a..007ad43f3 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/definition/BpmProcessDefinitionExtDO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/definition/BpmProcessDefinitionExtDO.java @@ -1,12 +1,17 @@ package cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition; +import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmModelFormTypeEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.*; import org.activiti.engine.repository.Model; import org.activiti.engine.repository.ProcessDefinition; +import java.util.List; + /** * Bpm 流程定义的拓展表 * 主要解决 Activiti {@link ProcessDefinition} 不支持拓展字段,所以新建拓展表 @@ -43,11 +48,45 @@ public class BpmProcessDefinitionExtDO extends BaseDO { * 描述 */ private String description; + /** - * 表单编号 + * 表单类型 + * + * 关联 {@link BpmModelFormTypeEnum} + */ + private Integer formType; + /** + * 动态表单编号 + * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 * * 关联 {@link BpmFormDO#getId()} */ private Long formId; + /** + * 表单的配置 + * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 + * + * 冗余 {@link BpmFormDO#getConf()} + */ + private String formConf; + /** + * 表单项的数组 + * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 + * + * 冗余 {@link BpmFormDO#getFields()} ()} + */ + @TableField(typeHandler = JacksonTypeHandler.class) + private List formFields; + /** + * 自定义表单的提交路径,使用 Vue 的路由地址 + * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 + */ + private String formCustomCreatePath; + /** + * 自定义表单的查看路径,使用 Vue 的路由地址 + * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 + */ + private String formCustomViewPath; + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java index 36a2490e1..6f4a2f0a6 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java @@ -3,7 +3,9 @@ package cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task; import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum; import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceStatusEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -12,6 +14,7 @@ import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.runtime.ProcessInstance; import java.util.Date; +import java.util.Map; /** * Bpm 流程实例的拓展表 @@ -78,4 +81,10 @@ public class BpmProcessInstanceExtDO extends BaseDO { */ private Date endTime; + /** + * 表单值 + */ + @TableField(typeHandler = JacksonTypeHandler.class) + private Map formVariables; + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/dto/BpmDefinitionCreateReqDTO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/dto/BpmDefinitionCreateReqDTO.java index 82ed49be2..c36725061 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/dto/BpmDefinitionCreateReqDTO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/dto/BpmDefinitionCreateReqDTO.java @@ -1,10 +1,18 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmFormDO; import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmModelFormTypeEnum; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.Data; +import javax.validation.constraints.AssertTrue; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.util.List; +import java.util.Objects; /** * 流程定义创建 Request DTO @@ -57,6 +65,16 @@ public class BpmDefinitionCreateReqDTO { * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 */ private Long formId; + /** + * 表单的配置 + * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 + */ + private String formConf; + /** + * 表单项的数组 + * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 + */ + private List formFields; /** * 自定义表单的提交路径,使用 Vue 的路由地址 * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 @@ -68,6 +86,22 @@ public class BpmDefinitionCreateReqDTO { */ private String formCustomViewPath; + @AssertTrue(message = "流程表单信息不全") + public boolean isNormalFormTypeValid() { + // 如果非业务表单,则直接通过 + if (!Objects.equals(formType, BpmModelFormTypeEnum.NORMAL.getType())) { + return true; + } + return formId != null && StrUtil.isNotEmpty(formConf) && CollUtil.isNotEmpty(formFields); + } + @AssertTrue(message = "业务表单信息不全") + public boolean isNormalCustomTypeValid() { + // 如果非业务表单,则直接通过 + if (!Objects.equals(formType, BpmModelFormTypeEnum.CUSTOM.getType())) { + return true; + } + return StrUtil.isNotEmpty(formCustomCreatePath) && StrUtil.isNotEmpty(formCustomViewPath); + } } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmModelServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmModelServiceImpl.java index 476dbb7b4..ca32a0e0c 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmModelServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmModelServiceImpl.java @@ -7,6 +7,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.model.* import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule.BpmTaskAssignRuleRespVO; import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmModelConvert; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmFormDO; +import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmModelFormTypeEnum; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; @@ -36,10 +37,7 @@ import org.springframework.util.ObjectUtils; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.function.Consumer; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.*; @@ -177,15 +175,13 @@ public class BpmModelServiceImpl implements BpmModelService { } // TODO 芋艿:校验流程图的有效性;例如说,是否有开始的元素,是否有结束的元素; // 校验表单已配 - BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); - if (metaInfo == null || metaInfo.getFormType() == null) { - throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG); - } + // 校验表单存在 + BpmFormDO form = checkFormConfig(model); // 校验任务分配规则已配置 checkTaskAssignRuleAllConfig(id); // 创建流程定义 - BpmDefinitionCreateReqDTO definitionCreateReqDTO = BpmModelConvert.INSTANCE.convert2(model) + BpmDefinitionCreateReqDTO definitionCreateReqDTO = BpmModelConvert.INSTANCE.convert2(model, form) .setBpmnXml(StrUtil.utf8Str(bpmnBytes)); String definitionId = processDefinitionService.createProcessDefinition(definitionCreateReqDTO); @@ -221,6 +217,28 @@ public class BpmModelServiceImpl implements BpmModelService { }); } + /** + * 校验流程表单已配置 + * + * @param model 流程模型 + * @return 流程表单 + */ + private BpmFormDO checkFormConfig(Model model) { + BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); + if (metaInfo == null || metaInfo.getFormType() == null) { + throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG); + } + // 校验表单存在 + if (Objects.equals(metaInfo.getFormType(), BpmModelFormTypeEnum.NORMAL.getType())) { + BpmFormDO form = formService.getForm(metaInfo.getFormId()); + if (form == null) { + throw exception(FORM_NOT_EXISTS); + } + return form; + } + return null; + } + @Override @Transactional(rollbackFor = Exception.class) public void deleteModel(String id) { diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java index fdb8abb30..9b5ec5d36 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java @@ -34,7 +34,8 @@ import java.util.*; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.PROCESS_DEFINITION_KEY_NOT_MATCH; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.PROCESS_DEFINITION_NAME_NOT_MATCH; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; +import static java.util.Collections.emptyList; /** * 流程定义实现 @@ -70,22 +71,22 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ List processDefinitions = definitionQuery.orderByProcessDefinitionVersion().desc() .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); if (CollUtil.isEmpty(processDefinitions)) { - return new PageResult<>(Collections.emptyList(), definitionQuery.count()); + return new PageResult<>(emptyList(), definitionQuery.count()); } // 获得 Deployment Map Set deploymentIds = new HashSet<>(); - processDefinitions.forEach(definition -> CollectionUtils.addIfNotNull(deploymentIds, definition.getDeploymentId())); + processDefinitions.forEach(definition -> addIfNotNull(deploymentIds, definition.getDeploymentId())); Map deploymentMap = getDeploymentMap(deploymentIds); // 获得 BpmProcessDefinitionDO Map List processDefinitionDOs = processDefinitionMapper.selectListByProcessDefinitionIds( convertList(processDefinitions, ProcessDefinition::getId)); - Map processDefinitionDOMap = CollectionUtils.convertMap(processDefinitionDOs, + Map processDefinitionDOMap = convertMap(processDefinitionDOs, BpmProcessDefinitionExtDO::getProcessDefinitionId); // 获得 Form Map - Set formIds = CollectionUtils.convertSet(processDefinitionDOs, BpmProcessDefinitionExtDO::getFormId); + Set formIds = convertSet(processDefinitionDOs, BpmProcessDefinitionExtDO::getFormId); Map formMap = bpmFormService.getFormMap(formIds); // 拼接结果 @@ -109,7 +110,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ // 获得 BpmProcessDefinitionDO Map List processDefinitionDOs = processDefinitionMapper.selectListByProcessDefinitionIds( convertList(processDefinitions, ProcessDefinition::getId)); - Map processDefinitionDOMap = CollectionUtils.convertMap(processDefinitionDOs, + Map processDefinitionDOMap = convertMap(processDefinitionDOs, BpmProcessDefinitionExtDO::getProcessDefinitionId); // 执行查询,并返回 return BpmProcessDefinitionConvert.INSTANCE.convertList3(processDefinitions, processDefinitionDOMap); @@ -152,11 +153,11 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ @Override public List getDeployments(Set ids) { if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); + return emptyList(); } List list = new ArrayList<>(ids.size()); for (String id : ids) { - CollectionUtils.addIfNotNull(list, getDeployment(id)); + addIfNotNull(list, getDeployment(id)); } return list; } @@ -169,7 +170,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ @Override public List getProcessDefinitionListByDeploymentIds(Set deploymentIds) { if (CollUtil.isEmpty(deploymentIds)) { - return Collections.emptyList(); + return emptyList(); } return repositoryService.createProcessDefinitionQuery().deploymentIds(deploymentIds).list(); } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java index e738da0a6..8c9e0b919 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java @@ -86,9 +86,9 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService // 设置流程名字 runtimeService.setProcessInstanceName(instance.getId(), definition.getName()); - // TODO 芋艿:临时使用, 保证分配 -// List tasks = taskService.getTasksByProcessInstanceId(instance.getId()); -// tasks.forEach(task -> taskService.updateTaskAssign(task.getId(), userId)); + // 补全流程实例的拓展表 + processInstanceExtMapper.updateByProcessInstanceId(new BpmProcessInstanceExtDO().setProcessInstanceId(instance.getId()) + .setFormVariables(createReqVO.getVariables())); // 添加初始的评论 TODO 芋艿:在思考下 // Task task = taskService.createTaskQuery().processInstanceId(instance.getId()).singleResult(); @@ -98,9 +98,6 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService // String type = "normal"; // taskService.addComment(task.getId(), instance.getProcessInstanceId(), type, // String.format("%s 发起流程申请", user.getNickname())); -// // TODO 芋艿:应该不用下面两个步骤 -//// taskService.setAssignee(task.getId(), String.valueOf(userId)); -//// taskService.complete(task.getId(), variables); // } return instance.getId(); } diff --git a/yudao-admin-server/src/main/resources/processes/leave-update.bpmn_bak b/yudao-admin-server/src/main/resources/processes/oa-leave.bpmn_bak similarity index 100% rename from yudao-admin-server/src/main/resources/processes/leave-update.bpmn_bak rename to yudao-admin-server/src/main/resources/processes/oa-leave.bpmn_bak diff --git a/yudao-admin-ui/src/views/bpm/definition/index.vue b/yudao-admin-ui/src/views/bpm/definition/index.vue index 6960c0a01..ec89f82b4 100644 --- a/yudao-admin-ui/src/views/bpm/definition/index.vue +++ b/yudao-admin-ui/src/views/bpm/definition/index.vue @@ -15,11 +15,14 @@ {{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }} - + @@ -134,16 +137,19 @@ export default { }, /** 流程表单的详情按钮操作 */ handleFormDetail(row) { - getForm(row.formId).then(response => { + // 流程表单 + if (row.formId) { // 设置值 - const data = response.data this.detailForm = { - ...JSON.parse(data.conf), - fields: decodeFields(data.fields) + ...JSON.parse(row.formConf), + fields: decodeFields(row.formFields) } // 弹窗打开 this.detailOpen = true - }) + // 业务表单 + } else if (row.formCustomCreatePath) { + this.$router.push({ path: row.formCustomCreatePath}); + } }, /** 流程图的详情按钮操作 */ handleBpmnDetail(row) { diff --git a/yudao-admin-ui/src/views/bpm/model/index.vue b/yudao-admin-ui/src/views/bpm/model/index.vue index 96b4a3a3e..d290395c7 100644 --- a/yudao-admin-ui/src/views/bpm/model/index.vue +++ b/yudao-admin-ui/src/views/bpm/model/index.vue @@ -50,11 +50,14 @@ {{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }} - + @@ -450,16 +453,22 @@ export default { }, /** 流程表单的详情按钮操作 */ handleFormDetail(row) { - getForm(row.formId).then(response => { - // 设置值 - const data = response.data - this.detailForm = { - ...JSON.parse(data.conf), - fields: decodeFields(data.fields) - } - // 弹窗打开 - this.detailOpen = true - }) + // 流程表单 + if (row.formId) { + getForm(row.formId).then(response => { + // 设置值 + const data = response.data + this.detailForm = { + ...JSON.parse(data.conf), + fields: decodeFields(data.fields) + } + // 弹窗打开 + this.detailOpen = true + }) + // 业务表单 + } else if (row.formCustomCreatePath) { + this.$router.push({ path: row.formCustomCreatePath}); + } }, /** 流程图的详情按钮操作 */ handleBpmnDetail(row) {