mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-24 07:55:06 +08:00
完善 bpmnProcessDesigner 流程设计器的使用,基本可用了!
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.form;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.*;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.convert.form.BpmFormConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.form.BpmFormService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@ -62,13 +61,11 @@ public class BpmFormController {
|
||||
return success(BpmFormConvert.INSTANCE.convert(form));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得动态表单列表")
|
||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
|
||||
@PreAuthorize("@ss.hasPermission('bpm:form:query')")
|
||||
public CommonResult<List<BpmFormRespVO>> getFormList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<BpmFormDO> list = formService.getFormList(ids);
|
||||
return success(BpmFormConvert.INSTANCE.convertList(list));
|
||||
@GetMapping("/list-all-simple")
|
||||
@ApiOperation(value = "获得动态表单的精简列表", notes = "用于表单下拉框")
|
||||
public CommonResult<List<BpmFormSimpleRespVO>> getSimpleForms() {
|
||||
List<BpmFormDO> list = formService.getFormList();
|
||||
return success(BpmFormConvert.INSTANCE.convertList2(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
|
@ -0,0 +1,17 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel("流程表单精简 Response VO")
|
||||
@Data
|
||||
public class BpmFormSimpleRespVO {
|
||||
|
||||
@ApiModelProperty(value = "表单编号", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "表单名称", required = true, example = "芋道")
|
||||
private String name;
|
||||
|
||||
}
|
@ -6,6 +6,8 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("流程模型的创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ -18,4 +20,7 @@ public class BpmModelRespVO extends BpmModelBaseVO {
|
||||
@ApiModelProperty(value = "BPMN XML", required = true)
|
||||
private String bpmnXml;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.convert.form;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormCreateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormSimpleRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormUpdateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@ -26,7 +27,7 @@ public interface BpmFormConvert {
|
||||
|
||||
BpmFormRespVO convert(BpmFormDO bean);
|
||||
|
||||
List<BpmFormRespVO> convertList(List<BpmFormDO> list);
|
||||
List<BpmFormSimpleRespVO> convertList2(List<BpmFormDO> list);
|
||||
|
||||
PageResult<BpmFormRespVO> convertPage(PageResult<BpmFormDO> page);
|
||||
|
||||
|
@ -57,7 +57,20 @@ public interface ModelConvert {
|
||||
return modelRespVO;
|
||||
}
|
||||
|
||||
BpmModelRespVO convert(Model model);
|
||||
default BpmModelRespVO convert(Model model) {
|
||||
BpmModelRespVO modelRespVO = new BpmModelRespVO();
|
||||
modelRespVO.setId(model.getId());
|
||||
modelRespVO.setName(model.getName());
|
||||
modelRespVO.setKey(model.getKey());
|
||||
modelRespVO.setCategory(model.getCategory());
|
||||
modelRespVO.setCreateTime(model.getCreateTime());
|
||||
BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class);
|
||||
if (metaInfo != null) {
|
||||
modelRespVO.setFormId(metaInfo.getFormId());
|
||||
modelRespVO.setDescription(metaInfo.getDescription());
|
||||
}
|
||||
return modelRespVO;
|
||||
}
|
||||
|
||||
default BpmDefinitionCreateReqDTO convert2(Model model) {
|
||||
BpmDefinitionCreateReqDTO createReqDTO = new BpmDefinitionCreateReqDTO();
|
||||
|
@ -26,6 +26,8 @@ public interface BpmErrorCodeConstants {
|
||||
// ========== OA 工作流模块 1-009-002-000 ==========
|
||||
ErrorCode BPM_MODEL_KEY_EXISTS = new ErrorCode(1009002000, "已经存在流程标识为【{}】的流程");
|
||||
ErrorCode BPMN_MODEL_NOT_EXISTS = new ErrorCode(1009002001, "流程模型不存在");
|
||||
ErrorCode BPMN_MODEL_KEY_VALID = new ErrorCode(1009002002, "流程标识格式不正确,需要以字母或下划线开头,后接任意字母、数字、中划线、下划线、句点!");
|
||||
|
||||
|
||||
ErrorCode BPMN_MODEL_ERROR = new ErrorCode(1004001002, "工作流模型异常");
|
||||
ErrorCode BPMN_MODEL_PROCESS_NOT_EXISTS = new ErrorCode(1004001009, "流程数据为空");
|
||||
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormUpdate
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import org.activiti.engine.repository.Model;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
@ -52,6 +53,13 @@ public interface BpmFormService {
|
||||
*/
|
||||
BpmFormDO getForm(Long id);
|
||||
|
||||
/**
|
||||
* 获得动态表单列表
|
||||
*
|
||||
* @return 动态表单列表
|
||||
*/
|
||||
List<BpmFormDO> getFormList();
|
||||
|
||||
/**
|
||||
* 获得动态表单列表
|
||||
*
|
||||
|
@ -75,6 +75,11 @@ public class BpmFormServiceImpl implements BpmFormService {
|
||||
return formMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BpmFormDO> getFormList() {
|
||||
return formMapper.selectList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BpmFormDO> getFormList(Collection<Long> ids) {
|
||||
return formMapper.selectBatchIds(ids);
|
||||
|
@ -13,6 +13,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.repository.Model;
|
||||
@ -29,8 +30,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.BPMN_MODEL_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.BPM_MODEL_KEY_EXISTS;
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
|
||||
@ -89,6 +89,9 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
@Override
|
||||
public BpmModelRespVO getModel(String id) {
|
||||
Model model = repositoryService.getModel(id);
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
BpmModelRespVO modelRespVO = ModelConvert.INSTANCE.convert(model);
|
||||
// 拼接 bpmn XML
|
||||
byte[] bpmnBytes = repositoryService.getModelEditorSource(id);
|
||||
@ -99,12 +102,12 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务
|
||||
public String createModel(BpmModelCreateReqVO createReqVO) {
|
||||
checkKeyNCName(createReqVO.getKey());
|
||||
// 校验流程标识已经存在
|
||||
Model keyModel = this.getModelByKey(createReqVO.getKey());
|
||||
if (keyModel != null) {
|
||||
throw exception(BPM_MODEL_KEY_EXISTS);
|
||||
throw exception(BPM_MODEL_KEY_EXISTS, createReqVO.getKey());
|
||||
}
|
||||
// TODO @芋艿:需要校验下 key 的格式
|
||||
|
||||
// 创建流程定义
|
||||
Model model = repositoryService.newModel();
|
||||
@ -119,12 +122,12 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务
|
||||
public void updateModel(BpmModelUpdateReqVO updateReqVO) {
|
||||
checkKeyNCName(updateReqVO.getKey());
|
||||
// 校验流程模型存在
|
||||
Model model = repositoryService.getModel(updateReqVO.getId());
|
||||
if (model == null) {
|
||||
throw exception(BPMN_MODEL_NOT_EXISTS);
|
||||
}
|
||||
// TODO @芋艿:需要校验下 key 的格式
|
||||
|
||||
// 修改流程定义
|
||||
ModelConvert.INSTANCE.copy(model, updateReqVO);
|
||||
@ -173,4 +176,10 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
return repositoryService.createModelQuery().modelKey(key).singleResult();
|
||||
}
|
||||
|
||||
private void checkKeyNCName(String key) {
|
||||
if (!ValidationUtils.isXmlNCName(key)) {
|
||||
throw exception(BPMN_MODEL_KEY_VALID);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user