调整 definition =》processDefinition,主要考虑更加明确一些

This commit is contained in:
YunaiV 2022-01-03 22:13:12 +08:00
parent 5eef27da6e
commit bcdc117e59
9 changed files with 54 additions and 54 deletions

View File

@ -2,7 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import io.swagger.annotations.Api;
@ -21,18 +21,19 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Api(tags = "流程定义")
@RestController
@RequestMapping("/bpm/definition")
@RequestMapping("/bpm/process-definition")
@Validated
public class BpmDefinitionController {
public class BpmProcessDefinitionController {
@Resource
private BpmDefinitionService bpmDefinitionService;
private BpmProcessDefinitionService bpmDefinitionService;
@GetMapping ("/page")
@ApiOperation(value = "获得流程定义分页")
@PreAuthorize("@ss.hasPermission('bpm:model:query')") // 暂时使用 model 的权限标识
public CommonResult<PageResult<BpmProcessDefinitionPageItemRespVO>> getDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO) {
return success(bpmDefinitionService.getDefinitionPage(pageReqVO));
public CommonResult<PageResult<BpmProcessDefinitionPageItemRespVO>> getProcessDefinitionPage(
BpmProcessDefinitionPageReqVO pageReqVO) {
return success(bpmDefinitionService.getProcessDefinitionPage(pageReqVO));
}
// TODO 芋艿需要重写该方法
@ -49,8 +50,8 @@ public class BpmDefinitionController {
@ApiOperation(value = "获得流程定义的 BPMN XML")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class)
@PreAuthorize("@ss.hasPermission('bpm:model:query')") // 暂时使用 model 的权限标识
public CommonResult<String> getDefinitionBpmnXML(@RequestParam("id") String id) {
String bpmnXML = bpmDefinitionService.getDefinitionBpmnXML(id);
public CommonResult<String> getProcessDefinitionBpmnXML(@RequestParam("id") String id) {
String bpmnXML = bpmDefinitionService.getProcessDefinitionBpmnXML(id);
return success(bpmnXML);
}

View File

@ -12,7 +12,7 @@ import java.util.Date;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class BpmProcessDefinitionPageItemRespVO extends ProcessDefinitionRespVO {
public class BpmProcessDefinitionPageItemRespVO extends BpmProcessDefinitionRespVO {
@ApiModelProperty(value = "表单名字", example = "请假表单")
private String formName;

View File

@ -8,7 +8,7 @@ import javax.validation.constraints.NotEmpty;
@ApiModel("流程定义 Response VO")
@Data
public class ProcessDefinitionRespVO {
public class BpmProcessDefinitionRespVO {
@ApiModelProperty(value = "编号", required = true, example = "1024")
private String id;

View File

@ -13,7 +13,6 @@ public interface BpmErrorCodeConstants {
ErrorCode PROCESS_INSTANCE_NOT_EXISTS = new ErrorCode(1009000001, "流程实例不存在");
ErrorCode HIGHLIGHT_IMG_ERROR = new ErrorCode(1009000002, "获取高亮流程图异常");
// ========== OA 流程模块 1-009-001-000 ==========
ErrorCode OA_LEAVE_NOT_EXISTS = new ErrorCode(1009001001, "请假申请不存在");
ErrorCode OA_PM_POST_NOT_EXISTS = new ErrorCode(1009001002, "项目经理岗位未设置");
@ -29,9 +28,9 @@ public interface BpmErrorCodeConstants {
ErrorCode MODEL_KEY_VALID = new ErrorCode(1009002002, "流程标识格式不正确,需要以字母或下划线开头,后接任意字母、数字、中划线、下划线、句点!");
// ========== 流程定义 1-009-003-000 ==========
ErrorCode DEFINITION_KEY_NOT_MATCH = new ErrorCode(1009003000, "流程定义的标识期望是({}),当前是({}),请修改 BPMN 流程图");
ErrorCode DEFINITION_NAME_NOT_MATCH = new ErrorCode(1009003001, "流程定义的名字期望是({}),当前是({}),请修改 BPMN 流程图");
ErrorCode DEFINITION_NOT_EXISTS = new ErrorCode(1009003002, "流程定义不存在");
ErrorCode PROCESS_DEFINITION_KEY_NOT_MATCH = new ErrorCode(1009003000, "流程定义的标识期望是({}),当前是({}),请修改 BPMN 流程图");
ErrorCode PROCESS_DEFINITION_NAME_NOT_MATCH = new ErrorCode(1009003001, "流程定义的名字期望是({}),当前是({}),请修改 BPMN 流程图");
ErrorCode PROCESS_DEFINITION_NOT_EXISTS = new ErrorCode(1009003002, "流程定义不存在");
// ========== 动态表单模块 1-009-004-000 ==========
ErrorCode FORM_NOT_EXISTS = new ErrorCode(1009004000, "动态表单不存在");

View File

@ -20,7 +20,7 @@ import java.util.Set;
* @author yunlong.li
* @author ZJQ
*/
public interface BpmDefinitionService {
public interface BpmProcessDefinitionService {
/**
* 获得流程定义分页
@ -28,7 +28,7 @@ public interface BpmDefinitionService {
* @param pageReqVO 分页入参
* @return 流程定义 Page
*/
PageResult<BpmProcessDefinitionPageItemRespVO> getDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO);
PageResult<BpmProcessDefinitionPageItemRespVO> getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO);
/**
* 获得流程定义对应的 BPMN XML
@ -36,7 +36,7 @@ public interface BpmDefinitionService {
* @param id 流程定义编号
* @return BPMN XML
*/
String getDefinitionBpmnXML(String id);
String getProcessDefinitionBpmnXML(String id);
/**
* 获得 Bpmn 模型
@ -52,7 +52,7 @@ public interface BpmDefinitionService {
* @param id 编号
* @return 流程定义
*/
ProcessDefinition getDefinition(String id);
ProcessDefinition getProcessDefinition(String id);
/**
* 获得 id 对应的 Deployment
@ -86,7 +86,7 @@ public interface BpmDefinitionService {
* @param deploymentId 部署编号
* @return 流程定义
*/
ProcessDefinition getDefinitionByDeploymentId(String deploymentId);
ProcessDefinition getProcessDefinitionByDeploymentId(String deploymentId);
/**
* 获得 deploymentIds 对应的 ProcessDefinition 数组
@ -94,7 +94,7 @@ public interface BpmDefinitionService {
* @param deploymentIds 部署编号的数组
* @return 流程定义的数组
*/
List<ProcessDefinition> getDefinitionListByDeploymentIds(Set<String> deploymentIds);
List<ProcessDefinition> getProcessDefinitionListByDeploymentIds(Set<String> deploymentIds);
/**
* 创建流程定义
@ -102,7 +102,7 @@ public interface BpmDefinitionService {
* @param createReqDTO 创建信息
* @return 流程编号
*/
String createDefinition(@Valid BpmDefinitionCreateReqDTO createReqDTO);
String createProcessDefinition(@Valid BpmDefinitionCreateReqDTO createReqDTO);
/**
* 更新流程定义的挂起状态
@ -110,6 +110,6 @@ public interface BpmDefinitionService {
* @param id 流程定义的编号
* @param state 挂起状态 {@link org.activiti.engine.impl.persistence.entity.SuspensionState}
*/
void updateDefinitionSuspensionState(String id, Integer state);
void updateProcessDefinitionState(String id, Integer state);
}

View File

@ -8,7 +8,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmDefinition
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionDO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmProcessDefinitionMapper;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
import cn.iocoder.yudao.adminserver.modules.bpm.service.form.BpmFormService;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -29,8 +29,8 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.*;
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.DEFINITION_KEY_NOT_MATCH;
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.DEFINITION_NAME_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.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
@ -44,7 +44,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
@Service
@Validated
@Slf4j
public class BpmDefinitionServiceImpl implements BpmDefinitionService {
public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionService {
private static final String BPMN_FILE_SUFFIX = ".bpmn";
@ -59,7 +59,7 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService {
private BpmProcessDefinitionMapper processDefinitionMapper;
@Override
public PageResult<BpmProcessDefinitionPageItemRespVO> getDefinitionPage(BpmProcessDefinitionPageReqVO pageVO) {
public PageResult<BpmProcessDefinitionPageItemRespVO> getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageVO) {
ProcessDefinitionQuery definitionQuery = repositoryService.createProcessDefinitionQuery();
if (StrUtil.isNotBlank(pageVO.getKey())) {
definitionQuery.processDefinitionKey(pageVO.getKey());
@ -94,7 +94,7 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService {
}
@Override
public String getDefinitionBpmnXML(String id) {
public String getProcessDefinitionBpmnXML(String id) {
BpmnModel bpmnModel = repositoryService.getBpmnModel(id);
if (bpmnModel == null) {
return null;
@ -109,7 +109,7 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService {
}
@Override
public ProcessDefinition getDefinition(String id) {
public ProcessDefinition getProcessDefinition(String id) {
return repositoryService.getProcessDefinition(id);
}
@ -134,12 +134,12 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService {
}
@Override
public ProcessDefinition getDefinitionByDeploymentId(String deploymentId) {
public ProcessDefinition getProcessDefinitionByDeploymentId(String deploymentId) {
return repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).singleResult();
}
@Override
public List<ProcessDefinition> getDefinitionListByDeploymentIds(Set<String> deploymentIds) {
public List<ProcessDefinition> getProcessDefinitionListByDeploymentIds(Set<String> deploymentIds) {
if (CollUtil.isEmpty(deploymentIds)) {
return Collections.emptyList();
}
@ -148,7 +148,7 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService {
@Override
@Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作所以开启事务
public String createDefinition(BpmDefinitionCreateReqDTO createReqDTO) {
public String createProcessDefinition(BpmDefinitionCreateReqDTO createReqDTO) {
// 创建 Deployment 部署
Deployment deploy = repositoryService.createDeployment()
.key(createReqDTO.getKey()).name(createReqDTO.getName()).category(createReqDTO.getCategory())
@ -162,10 +162,10 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService {
// 注意 2目前该项目的设计上需要保证 ModelDeploymentProcessDefinition 使用相同的 key保证关联性
// 否则会导致 ProcessDefinition 的分页无法查询到
if (!Objects.equals(definition.getKey(), createReqDTO.getKey())) {
throw exception(DEFINITION_KEY_NOT_MATCH, createReqDTO.getKey(), definition.getKey());
throw exception(PROCESS_DEFINITION_KEY_NOT_MATCH, createReqDTO.getKey(), definition.getKey());
}
if (!Objects.equals(definition.getName(), createReqDTO.getName())) {
throw exception(DEFINITION_NAME_NOT_MATCH, createReqDTO.getName(), definition.getName());
throw exception(PROCESS_DEFINITION_NAME_NOT_MATCH, createReqDTO.getName(), definition.getName());
}
// 插入拓展表
@ -176,7 +176,7 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService {
}
@Override
public void updateDefinitionSuspensionState(String id, Integer state) {
public void updateProcessDefinitionState(String id, Integer state) {
// 激活
if (Objects.equals(SuspensionState.ACTIVE.getStateCode(), state)) {
repositoryService.activateProcessDefinitionById(id, true, null);
@ -187,7 +187,7 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService {
repositoryService.suspendProcessDefinitionById(id, true, null);
return;
}
log.error("[updateDefinitionSuspensionState][流程定义({}) 修改未知状态({})]", id, state);
log.error("[updateProcessDefinitionState][流程定义({}) 修改未知状态({})]", id, state);
}
}

View File

@ -4,7 +4,7 @@ import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.*;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.model.BpmModelConvert;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
import cn.iocoder.yudao.adminserver.modules.bpm.service.form.BpmFormService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.model.BpmModelService;
@ -52,7 +52,7 @@ public class BpmModelServiceImpl implements BpmModelService {
@Resource
private BpmFormService bpmFormService;
@Resource
private BpmDefinitionService bpmDefinitionService;
private BpmProcessDefinitionService bpmProcessDefinitionService;
@Override
public PageResult<BpmModelPageItemRespVO> getModelPage(ModelPageReqVO pageVO) {
@ -80,9 +80,9 @@ public class BpmModelServiceImpl implements BpmModelService {
// 获得 Deployment Map
Set<String> deploymentIds = new HashSet<>();
models.forEach(model -> CollectionUtils.addIfNotNull(deploymentIds, model.getDeploymentId()));
Map<String, Deployment> deploymentMap = bpmDefinitionService.getDeploymentMap(deploymentIds);
Map<String, Deployment> deploymentMap = bpmProcessDefinitionService.getDeploymentMap(deploymentIds);
// 获得 ProcessDefinition Map
List<ProcessDefinition> processDefinitions = bpmDefinitionService.getDefinitionListByDeploymentIds(deploymentIds);
List<ProcessDefinition> processDefinitions = bpmProcessDefinitionService.getProcessDefinitionListByDeploymentIds(deploymentIds);
Map<String, ProcessDefinition> processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId);
// 拼接结果
@ -157,18 +157,18 @@ public class BpmModelServiceImpl implements BpmModelService {
// 创建流程定义
BpmDefinitionCreateReqDTO definitionCreateReqDTO = BpmModelConvert.INSTANCE.convert2(model)
.setBpmnXml(StrUtil.utf8Str(bpmnBytes));
String definitionId = bpmDefinitionService.createDefinition(definitionCreateReqDTO);
String definitionId = bpmProcessDefinitionService.createProcessDefinition(definitionCreateReqDTO);
// 将老的流程定义进行挂起也就是说只有最新部署的流程定义才可以发起任务
if (StrUtil.isNotEmpty(model.getDeploymentId())) {
ProcessDefinition oldDefinition = bpmDefinitionService.getDefinitionByDeploymentId(model.getDeploymentId());
ProcessDefinition oldDefinition = bpmProcessDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId());
if (oldDefinition != null) {
bpmDefinitionService.updateDefinitionSuspensionState(oldDefinition.getId(), SuspensionState.SUSPENDED.getStateCode());
bpmProcessDefinitionService.updateProcessDefinitionState(oldDefinition.getId(), SuspensionState.SUSPENDED.getStateCode());
}
}
// 更新 model deploymentId进行关联
ProcessDefinition definition = bpmDefinitionService.getDefinition(definitionId);
ProcessDefinition definition = bpmProcessDefinitionService.getProcessDefinition(definitionId);
model.setDeploymentId(definition.getDeploymentId());
repositoryService.saveModel(model);
}
@ -192,13 +192,13 @@ public class BpmModelServiceImpl implements BpmModelService {
throw exception(MODEL_NOT_EXISTS);
}
// 校验流程定义存在
ProcessDefinition definition = bpmDefinitionService.getDefinitionByDeploymentId(model.getDeploymentId());
ProcessDefinition definition = bpmProcessDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId());
if (definition == null) {
throw exception(DEFINITION_NOT_EXISTS);
throw exception(PROCESS_DEFINITION_NOT_EXISTS);
}
// 更新状态
bpmDefinitionService.updateDefinitionSuspensionState(definition.getId(), state);
bpmProcessDefinitionService.updateProcessDefinitionState(definition.getId(), state);
}
private Model getModelByKey(String key) {

View File

@ -1,16 +1,16 @@
import request from '@/utils/request'
export function getDefinitionPage(query) {
export function getProcessDefinitionPage(query) {
return request({
url: '/bpm/definition/page',
url: '/bpm/process-definition/page',
method: 'get',
params: query
})
}
export function getDefinitionBpmnXML(id) {
export function getProcessDefinitionBpmnXML(id) {
return request({
url: '/bpm/definition/get-bpmn-xml?id=' + id,
url: '/bpm/process-definition/get-bpmn-xml?id=' + id,
method: 'get'
})
}

View File

@ -60,7 +60,7 @@
</template>
<script>
import {getDefinitionBpmnXML, getDefinitionPage} from "@/api/bpm/definition";
import {getProcessDefinitionBpmnXML, getProcessDefinitionPage} from "@/api/bpm/definition";
import {DICT_TYPE, getDictDatas} from "@/utils/dict";
import {getForm} from "@/api/bpm/form";
import {decodeFields} from "@/utils/formGenerator";
@ -113,7 +113,7 @@ export default {
/** 查询流程定义列表 */
getList() {
this.loading = true;
getDefinitionPage(this.queryParams).then(response => {
getProcessDefinitionPage(this.queryParams).then(response => {
this.list = response.data.list;
this.total = response.data.total;
this.loading = false;
@ -135,7 +135,7 @@ export default {
},
/** 流程图的详情按钮操作 */
handleBpmnDetail(row) {
getDefinitionBpmnXML(row.id).then(response => {
getProcessDefinitionBpmnXML(row.id).then(response => {
this.bpmnXML = response.data
//
this.showBpmnOpen = true