1. 修改流程的表单定义,支持业务表单。

2. 流程提交时,记录表单值
This commit is contained in:
YunaiV 2022-01-16 02:26:37 +08:00
parent aac6cc7bf8
commit db3c713122
15 changed files with 190 additions and 107 deletions

View File

@ -32,6 +32,8 @@ public class BpmProcessDefinitionController {
@Resource @Resource
private BpmProcessDefinitionService bpmDefinitionService; private BpmProcessDefinitionService bpmDefinitionService;
// TODO 芋艿权限相关
@GetMapping ("/page") @GetMapping ("/page")
@ApiOperation(value = "获得流程定义分页") @ApiOperation(value = "获得流程定义分页")
@PreAuthorize("@ss.hasPermission('bpm:model:query')") // 暂时使用 model 的权限标识 @PreAuthorize("@ss.hasPermission('bpm:model:query')") // 暂时使用 model 的权限标识

View File

@ -18,6 +18,7 @@ public class BpmFormRespVO extends BpmFormBaseVO {
@ApiModelProperty(value = "表单编号", required = true, example = "1024") @ApiModelProperty(value = "表单编号", required = true, example = "1024")
private Long id; private Long id;
@ApiModelProperty(value = "表单的配置", required = true, notes = "JSON 字符串") @ApiModelProperty(value = "表单的配置", required = true, notes = "JSON 字符串")
@NotNull(message = "表单的配置不能为空") @NotNull(message = "表单的配置不能为空")
private String conf; private String conf;

View File

@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
@ApiModel("流程定义 Response VO") @ApiModel("流程定义 Response VO")
@Data @Data
@ -27,8 +29,22 @@ public class BpmProcessDefinitionRespVO {
@NotEmpty(message = "流程分类不能为空") @NotEmpty(message = "流程分类不能为空")
private String category; 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; 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<String> 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 枚举") @ApiModelProperty(value = "中断状态", required = true, example = "1", notes = "参见 SuspensionState 枚举")
private Integer suspensionState; private Integer suspensionState;

View File

@ -83,7 +83,7 @@ public interface BpmModelConvert {
void copyTo(BpmModelMetaInfoRespDTO from, @MappingTarget BpmModelBaseVO to); void copyTo(BpmModelMetaInfoRespDTO from, @MappingTarget BpmModelBaseVO to);
default BpmDefinitionCreateReqDTO convert2(Model model) { default BpmDefinitionCreateReqDTO convert2(Model model, BpmFormDO form) {
BpmDefinitionCreateReqDTO createReqDTO = new BpmDefinitionCreateReqDTO(); BpmDefinitionCreateReqDTO createReqDTO = new BpmDefinitionCreateReqDTO();
createReqDTO.setModelId(model.getId()); createReqDTO.setModelId(model.getId());
createReqDTO.setName(model.getName()); createReqDTO.setName(model.getName());
@ -92,6 +92,11 @@ public interface BpmModelConvert {
BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class);
// metaInfo // metaInfo
copyTo(metaInfo, createReqDTO); copyTo(metaInfo, createReqDTO);
// form
if (form != null) {
createReqDTO.setFormConf(form.getConf());
createReqDTO.setFormFields(form.getFields());
}
return createReqDTO; return createReqDTO;
} }

View File

@ -11,6 +11,7 @@ import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.repository.ProcessDefinition;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Named; import org.mapstruct.Named;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@ -38,19 +39,17 @@ public interface BpmProcessDefinitionConvert {
} }
default BpmProcessDefinitionPageItemRespVO convert(ProcessDefinition bean, Deployment deployment, default BpmProcessDefinitionPageItemRespVO convert(ProcessDefinition bean, Deployment deployment,
BpmProcessDefinitionExtDO processDefinitionDO, BpmFormDO form) { BpmProcessDefinitionExtDO processDefinitionExtDO, BpmFormDO form) {
BpmProcessDefinitionPageItemRespVO respVO = convert(bean); BpmProcessDefinitionPageItemRespVO respVO = convert(bean);
respVO.setSuspensionState(bean.isSuspended() ? SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode()); respVO.setSuspensionState(bean.isSuspended() ? SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode());
if (deployment != null) { if (deployment != null) {
respVO.setDeploymentTime(deployment.getDeploymentTime()); respVO.setDeploymentTime(deployment.getDeploymentTime());
} }
if (form != null) { if (form != null) {
respVO.setFormId(form.getId());
respVO.setFormName(form.getName()); respVO.setFormName(form.getName());
} }
if (processDefinitionDO != null) { // 复制通用属性
respVO.setDescription(processDefinitionDO.getDescription()); copyTo(processDefinitionExtDO, respVO);
}
return respVO; return respVO;
} }
@ -63,9 +62,8 @@ public interface BpmProcessDefinitionConvert {
return CollectionUtils.convertList(list, processDefinition -> { return CollectionUtils.convertList(list, processDefinition -> {
BpmProcessDefinitionRespVO respVO = convert3(processDefinition); BpmProcessDefinitionRespVO respVO = convert3(processDefinition);
BpmProcessDefinitionExtDO processDefinitionExtDO = processDefinitionDOMap.get(processDefinition.getId()); BpmProcessDefinitionExtDO processDefinitionExtDO = processDefinitionDOMap.get(processDefinition.getId());
if (processDefinitionExtDO != null) { // 复制通用属性
respVO.setFormId(processDefinitionExtDO.getFormId()); copyTo(processDefinitionExtDO, respVO);
}
return respVO; return respVO;
}); });
} }
@ -79,4 +77,7 @@ public interface BpmProcessDefinitionConvert {
SuspensionState.ACTIVE.getStateCode(); SuspensionState.ACTIVE.getStateCode();
} }
@Mapping(source = "from.id", target = "to.id", ignore = true)
void copyTo(BpmProcessDefinitionExtDO from, @MappingTarget BpmProcessDefinitionRespVO to);
} }

View File

@ -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<String> fields;
/**
* 表单值
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private Map<String, Object> values;
}

View File

@ -1,12 +1,17 @@
package cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition; 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 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.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*; import lombok.*;
import org.activiti.engine.repository.Model; import org.activiti.engine.repository.Model;
import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.repository.ProcessDefinition;
import java.util.List;
/** /**
* Bpm 流程定义的拓展表 * Bpm 流程定义的拓展表
* 主要解决 Activiti {@link ProcessDefinition} 不支持拓展字段所以新建拓展表 * 主要解决 Activiti {@link ProcessDefinition} 不支持拓展字段所以新建拓展表
@ -43,11 +48,45 @@ public class BpmProcessDefinitionExtDO extends BaseDO {
* 描述 * 描述
*/ */
private String description; private String description;
/** /**
* 表单编号 * 表单类型
*
* 关联 {@link BpmModelFormTypeEnum}
*/
private Integer formType;
/**
* 动态表单编号
* 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL}
* *
* 关联 {@link BpmFormDO#getId()} * 关联 {@link BpmFormDO#getId()}
*/ */
private Long formId; private Long formId;
/**
* 表单的配置
* 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL}
*
* 冗余 {@link BpmFormDO#getConf()}
*/
private String formConf;
/**
* 表单项的数组
* 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL}
*
* 冗余 {@link BpmFormDO#getFields()} ()}
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<String> formFields;
/**
* 自定义表单的提交路径使用 Vue 的路由地址
* 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM}
*/
private String formCustomCreatePath;
/**
* 自定义表单的查看路径使用 Vue 的路由地址
* 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM}
*/
private String formCustomViewPath;
} }

View File

@ -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.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceStatusEnum; import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceStatusEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; 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.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
@ -12,6 +14,7 @@ import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.runtime.ProcessInstance;
import java.util.Date; import java.util.Date;
import java.util.Map;
/** /**
* Bpm 流程实例的拓展表 * Bpm 流程实例的拓展表
@ -78,4 +81,10 @@ public class BpmProcessInstanceExtDO extends BaseDO {
*/ */
private Date endTime; private Date endTime;
/**
* 表单值
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private Map<String, Object> formVariables;
} }

View File

@ -1,10 +1,18 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto; 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 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 lombok.Data;
import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Objects;
/** /**
* 流程定义创建 Request DTO * 流程定义创建 Request DTO
@ -57,6 +65,16 @@ public class BpmDefinitionCreateReqDTO {
* 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL}
*/ */
private Long formId; private Long formId;
/**
* 表单的配置
* 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL}
*/
private String formConf;
/**
* 表单项的数组
* 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL}
*/
private List<String> formFields;
/** /**
* 自定义表单的提交路径使用 Vue 的路由地址 * 自定义表单的提交路径使用 Vue 的路由地址
* 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM}
@ -68,6 +86,22 @@ public class BpmDefinitionCreateReqDTO {
*/ */
private String formCustomViewPath; 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);
}
} }

View File

@ -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.controller.definition.vo.rule.BpmTaskAssignRuleRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmModelConvert; 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.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.BpmProcessDefinitionService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; 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 org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashSet; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.*; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.*;
@ -177,15 +175,13 @@ public class BpmModelServiceImpl implements BpmModelService {
} }
// TODO 芋艿校验流程图的有效性例如说是否有开始的元素是否有结束的元素 // TODO 芋艿校验流程图的有效性例如说是否有开始的元素是否有结束的元素
// 校验表单已配 // 校验表单已配
BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); // 校验表单存在
if (metaInfo == null || metaInfo.getFormType() == null) { BpmFormDO form = checkFormConfig(model);
throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG);
}
// 校验任务分配规则已配置 // 校验任务分配规则已配置
checkTaskAssignRuleAllConfig(id); checkTaskAssignRuleAllConfig(id);
// 创建流程定义 // 创建流程定义
BpmDefinitionCreateReqDTO definitionCreateReqDTO = BpmModelConvert.INSTANCE.convert2(model) BpmDefinitionCreateReqDTO definitionCreateReqDTO = BpmModelConvert.INSTANCE.convert2(model, form)
.setBpmnXml(StrUtil.utf8Str(bpmnBytes)); .setBpmnXml(StrUtil.utf8Str(bpmnBytes));
String definitionId = processDefinitionService.createProcessDefinition(definitionCreateReqDTO); 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 @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void deleteModel(String id) { public void deleteModel(String id) {

View File

@ -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_KEY_NOT_MATCH;
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.PROCESS_DEFINITION_NAME_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.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<ProcessDefinition> processDefinitions = definitionQuery.orderByProcessDefinitionVersion().desc() List<ProcessDefinition> processDefinitions = definitionQuery.orderByProcessDefinitionVersion().desc()
.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
if (CollUtil.isEmpty(processDefinitions)) { if (CollUtil.isEmpty(processDefinitions)) {
return new PageResult<>(Collections.emptyList(), definitionQuery.count()); return new PageResult<>(emptyList(), definitionQuery.count());
} }
// 获得 Deployment Map // 获得 Deployment Map
Set<String> deploymentIds = new HashSet<>(); Set<String> deploymentIds = new HashSet<>();
processDefinitions.forEach(definition -> CollectionUtils.addIfNotNull(deploymentIds, definition.getDeploymentId())); processDefinitions.forEach(definition -> addIfNotNull(deploymentIds, definition.getDeploymentId()));
Map<String, Deployment> deploymentMap = getDeploymentMap(deploymentIds); Map<String, Deployment> deploymentMap = getDeploymentMap(deploymentIds);
// 获得 BpmProcessDefinitionDO Map // 获得 BpmProcessDefinitionDO Map
List<BpmProcessDefinitionExtDO> processDefinitionDOs = processDefinitionMapper.selectListByProcessDefinitionIds( List<BpmProcessDefinitionExtDO> processDefinitionDOs = processDefinitionMapper.selectListByProcessDefinitionIds(
convertList(processDefinitions, ProcessDefinition::getId)); convertList(processDefinitions, ProcessDefinition::getId));
Map<String, BpmProcessDefinitionExtDO> processDefinitionDOMap = CollectionUtils.convertMap(processDefinitionDOs, Map<String, BpmProcessDefinitionExtDO> processDefinitionDOMap = convertMap(processDefinitionDOs,
BpmProcessDefinitionExtDO::getProcessDefinitionId); BpmProcessDefinitionExtDO::getProcessDefinitionId);
// 获得 Form Map // 获得 Form Map
Set<Long> formIds = CollectionUtils.convertSet(processDefinitionDOs, BpmProcessDefinitionExtDO::getFormId); Set<Long> formIds = convertSet(processDefinitionDOs, BpmProcessDefinitionExtDO::getFormId);
Map<Long, BpmFormDO> formMap = bpmFormService.getFormMap(formIds); Map<Long, BpmFormDO> formMap = bpmFormService.getFormMap(formIds);
// 拼接结果 // 拼接结果
@ -109,7 +110,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
// 获得 BpmProcessDefinitionDO Map // 获得 BpmProcessDefinitionDO Map
List<BpmProcessDefinitionExtDO> processDefinitionDOs = processDefinitionMapper.selectListByProcessDefinitionIds( List<BpmProcessDefinitionExtDO> processDefinitionDOs = processDefinitionMapper.selectListByProcessDefinitionIds(
convertList(processDefinitions, ProcessDefinition::getId)); convertList(processDefinitions, ProcessDefinition::getId));
Map<String, BpmProcessDefinitionExtDO> processDefinitionDOMap = CollectionUtils.convertMap(processDefinitionDOs, Map<String, BpmProcessDefinitionExtDO> processDefinitionDOMap = convertMap(processDefinitionDOs,
BpmProcessDefinitionExtDO::getProcessDefinitionId); BpmProcessDefinitionExtDO::getProcessDefinitionId);
// 执行查询并返回 // 执行查询并返回
return BpmProcessDefinitionConvert.INSTANCE.convertList3(processDefinitions, processDefinitionDOMap); return BpmProcessDefinitionConvert.INSTANCE.convertList3(processDefinitions, processDefinitionDOMap);
@ -152,11 +153,11 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
@Override @Override
public List<Deployment> getDeployments(Set<String> ids) { public List<Deployment> getDeployments(Set<String> ids) {
if (CollUtil.isEmpty(ids)) { if (CollUtil.isEmpty(ids)) {
return Collections.emptyList(); return emptyList();
} }
List<Deployment> list = new ArrayList<>(ids.size()); List<Deployment> list = new ArrayList<>(ids.size());
for (String id : ids) { for (String id : ids) {
CollectionUtils.addIfNotNull(list, getDeployment(id)); addIfNotNull(list, getDeployment(id));
} }
return list; return list;
} }
@ -169,7 +170,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
@Override @Override
public List<ProcessDefinition> getProcessDefinitionListByDeploymentIds(Set<String> deploymentIds) { public List<ProcessDefinition> getProcessDefinitionListByDeploymentIds(Set<String> deploymentIds) {
if (CollUtil.isEmpty(deploymentIds)) { if (CollUtil.isEmpty(deploymentIds)) {
return Collections.emptyList(); return emptyList();
} }
return repositoryService.createProcessDefinitionQuery().deploymentIds(deploymentIds).list(); return repositoryService.createProcessDefinitionQuery().deploymentIds(deploymentIds).list();
} }

View File

@ -86,9 +86,9 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
// 设置流程名字 // 设置流程名字
runtimeService.setProcessInstanceName(instance.getId(), definition.getName()); runtimeService.setProcessInstanceName(instance.getId(), definition.getName());
// TODO 芋艿临时使用, 保证分配 // 补全流程实例的拓展表
// List<Task> tasks = taskService.getTasksByProcessInstanceId(instance.getId()); processInstanceExtMapper.updateByProcessInstanceId(new BpmProcessInstanceExtDO().setProcessInstanceId(instance.getId())
// tasks.forEach(task -> taskService.updateTaskAssign(task.getId(), userId)); .setFormVariables(createReqVO.getVariables()));
// 添加初始的评论 TODO 芋艿在思考下 // 添加初始的评论 TODO 芋艿在思考下
// Task task = taskService.createTaskQuery().processInstanceId(instance.getId()).singleResult(); // Task task = taskService.createTaskQuery().processInstanceId(instance.getId()).singleResult();
@ -98,9 +98,6 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
// String type = "normal"; // String type = "normal";
// taskService.addComment(task.getId(), instance.getProcessInstanceId(), type, // taskService.addComment(task.getId(), instance.getProcessInstanceId(), type,
// String.format("%s 发起流程申请", user.getNickname())); // String.format("%s 发起流程申请", user.getNickname()));
// // TODO 芋艿应该不用下面两个步骤
//// taskService.setAssignee(task.getId(), String.valueOf(userId));
//// taskService.complete(task.getId(), variables);
// } // }
return instance.getId(); return instance.getId();
} }

View File

@ -15,11 +15,14 @@
<span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span> <span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="表单信息" align="center" prop="formId"> <el-table-column label="表单信息" align="center" prop="formType" width="200">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button v-if="scope.row.formId" type="text" @click="handleFormDetail(scope.row)"> <el-button v-if="scope.row.formId" type="text" @click="handleFormDetail(scope.row)">
<span>{{ scope.row.formName }}</span> <span>{{ scope.row.formName }}</span>
</el-button> </el-button>
<el-button v-else-if="scope.row.formCustomCreatePath" type="text" @click="handleFormDetail(scope.row)">
<span>{{ scope.row.formCustomCreatePath }}</span>
</el-button>
<label v-else>暂无表单</label> <label v-else>暂无表单</label>
</template> </template>
</el-table-column> </el-table-column>
@ -134,16 +137,19 @@ export default {
}, },
/** 流程表单的详情按钮操作 */ /** 流程表单的详情按钮操作 */
handleFormDetail(row) { handleFormDetail(row) {
getForm(row.formId).then(response => { //
if (row.formId) {
// //
const data = response.data
this.detailForm = { this.detailForm = {
...JSON.parse(data.conf), ...JSON.parse(row.formConf),
fields: decodeFields(data.fields) fields: decodeFields(row.formFields)
} }
// //
this.detailOpen = true this.detailOpen = true
}) //
} else if (row.formCustomCreatePath) {
this.$router.push({ path: row.formCustomCreatePath});
}
}, },
/** 流程图的详情按钮操作 */ /** 流程图的详情按钮操作 */
handleBpmnDetail(row) { handleBpmnDetail(row) {

View File

@ -50,11 +50,14 @@
<span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span> <span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="表单信息" align="center" prop="formId"> <el-table-column label="表单信息" align="center" prop="formType" width="200">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button v-if="scope.row.formId" type="text" @click="handleFormDetail(scope.row)"> <el-button v-if="scope.row.formId" type="text" @click="handleFormDetail(scope.row)">
<span>{{ scope.row.formName }}</span> <span>{{ scope.row.formName }}</span>
</el-button> </el-button>
<el-button v-else-if="scope.row.formCustomCreatePath" type="text" @click="handleFormDetail(scope.row)">
<span>{{ scope.row.formCustomCreatePath }}</span>
</el-button>
<label v-else>暂无表单</label> <label v-else>暂无表单</label>
</template> </template>
</el-table-column> </el-table-column>
@ -450,6 +453,8 @@ export default {
}, },
/** 流程表单的详情按钮操作 */ /** 流程表单的详情按钮操作 */
handleFormDetail(row) { handleFormDetail(row) {
//
if (row.formId) {
getForm(row.formId).then(response => { getForm(row.formId).then(response => {
// //
const data = response.data const data = response.data
@ -460,6 +465,10 @@ export default {
// //
this.detailOpen = true this.detailOpen = true
}) })
//
} else if (row.formCustomCreatePath) {
this.$router.push({ path: row.formCustomCreatePath});
}
}, },
/** 流程图的详情按钮操作 */ /** 流程图的详情按钮操作 */
handleBpmnDetail(row) { handleBpmnDetail(row) {