update - 自测调整工作流实例的创建
This commit is contained in:
parent
ff3dcc2f71
commit
0477f52f1c
@ -5,15 +5,14 @@ import cn.axzo.workflow.core.common.enums.BpmFlowNodeType;
|
||||
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
|
||||
import cn.axzo.workflow.core.service.dto.BpmJsonNode;
|
||||
import cn.axzo.workflow.core.service.dto.request.BpmJsonNodeProperty;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.flowable.bpmn.BpmnAutoLayout;
|
||||
import org.flowable.bpmn.converter.BpmnXMLConverter;
|
||||
import org.flowable.bpmn.model.*;
|
||||
import org.flowable.bpmn.model.Process;
|
||||
import org.flowable.bpmn.model.*;
|
||||
import org.flowable.engine.delegate.ExecutionListener;
|
||||
import org.flowable.engine.delegate.TaskListener;
|
||||
import org.flowable.engine.repository.Model;
|
||||
@ -22,7 +21,8 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.axzo.workflow.core.common.BpmConstants.*;
|
||||
import static cn.axzo.workflow.core.common.BpmConstants.END_EVENT_ID;
|
||||
import static cn.axzo.workflow.core.common.BpmConstants.EXPRESSION_CLASS;
|
||||
import static cn.axzo.workflow.core.common.enums.BpmErrorCode.BPM_META_DATA_FORMAT_ERROR;
|
||||
import static org.flowable.bpmn.model.ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION;
|
||||
|
||||
@ -323,6 +323,7 @@ public class BpmTransformUtil {
|
||||
FlowableListener createTaskListener = new FlowableListener();
|
||||
createTaskListener.setEvent(TaskListener.EVENTNAME_ALL_EVENTS);
|
||||
createTaskListener.setImplementationType(IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
|
||||
// FIXME 如果监听器想设置多个,这里还需要额外处理
|
||||
createTaskListener.setImplementation("${engineTaskEventListener}");
|
||||
userTask.setTaskListeners(Arrays.asList(createTaskListener));
|
||||
if("root".equalsIgnoreCase(id)){
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package cn.axzo.workflow.core.listener.custom;
|
||||
|
||||
import cn.axzo.workflow.core.listener.BpmProcessEventListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/7/10 18:22
|
||||
*/
|
||||
@Component
|
||||
public class CustomBpmProcessEventListener implements BpmProcessEventListener {
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package cn.axzo.workflow.core.listener.custom;
|
||||
|
||||
import cn.axzo.workflow.core.listener.BpmTaskEventListener;
|
||||
import org.flowable.task.service.delegate.DelegateTask;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/7/10 18:22
|
||||
*/
|
||||
@Component
|
||||
public class CustomBpmTaskEventListener implements BpmTaskEventListener {
|
||||
@Override
|
||||
public void created(DelegateTask delegateTask) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assigned(DelegateTask delegateTask) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completed(DelegateTask delegateTask) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleted(DelegateTask delegateTask) {
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
package cn.axzo.workflow.core.service;
|
||||
|
||||
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessDefinitionPageDTO;
|
||||
import cn.axzo.workflow.core.service.dto.response.process.BpmProcessDefinitionPageItemRespVO;
|
||||
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
|
||||
import cn.axzo.workflow.core.service.dto.response.process.BpmProcessDefinitionPageItemRespVO;
|
||||
import org.flowable.common.engine.impl.db.SuspensionState;
|
||||
import org.flowable.engine.repository.Model;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
@ -13,8 +13,8 @@ public interface BpmProcessDefinitionService {
|
||||
/**
|
||||
* 创建流程定义
|
||||
* 模型发布时,会自动调用,通常情况无需手动创建
|
||||
* */
|
||||
String createProcessDeinition(Model model, byte[] bpmnBytes);
|
||||
*/
|
||||
String createProcessDefinition(Model model, byte[] bpmnBytes);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -22,10 +22,6 @@ public interface BpmTaskService {
|
||||
* @return*/
|
||||
BpmPageResult<BpmTaskTodoPageItemRespVO> getDoneTaskPage(BpmTaskTodoBpmPageDTO taskDonePageD);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 同意
|
||||
* */
|
||||
|
||||
@ -31,7 +31,7 @@ public class BpmJsonNode {
|
||||
private BpmJsonNodeProperty property;
|
||||
|
||||
/* 内部使用,不需要外界传 */
|
||||
private Map incoming = new HashMap();
|
||||
private transient Map incoming = new HashMap();
|
||||
|
||||
|
||||
public BpmJsonNode() {
|
||||
|
||||
@ -28,7 +28,7 @@ public class BpmModelCreateDTO {
|
||||
* 默认 1
|
||||
* OA 2
|
||||
*/
|
||||
@ApiModelProperty(value = "所属业务", notes = "参见 bpm_model_category 数据字典", example = "1")
|
||||
@ApiModelProperty(value = "所属业务", notes = "由业务自定义", example = "1")
|
||||
@NotBlank(message = "所属业务不能为空")
|
||||
private String category;
|
||||
|
||||
|
||||
@ -10,6 +10,10 @@ import java.util.Map;
|
||||
@Data
|
||||
public class BpmProcessInstanceCreateDTO {
|
||||
|
||||
/**
|
||||
* 流程定义的 id
|
||||
*/
|
||||
private String processDefinitionId;
|
||||
/**
|
||||
* 流程定义的标识
|
||||
*/
|
||||
@ -31,7 +35,6 @@ public class BpmProcessInstanceCreateDTO {
|
||||
/**
|
||||
* 发起人所在的(企业/项目)租户ID
|
||||
*/
|
||||
@NotNull(message = "租户Id")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
|
||||
@ -1,17 +1,19 @@
|
||||
package cn.axzo.workflow.core.service.impl;
|
||||
|
||||
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
|
||||
import cn.axzo.workflow.core.constants.BpmnConstants;
|
||||
import cn.axzo.workflow.core.repository.entity.BpmDictDataDO;
|
||||
import cn.axzo.workflow.core.repository.mapper.BpmDictDataMapper;
|
||||
import cn.axzo.workflow.core.service.BpmCategoryService;
|
||||
import cn.axzo.workflow.core.service.converter.BpmCategoryConverter;
|
||||
import cn.axzo.workflow.core.service.dto.request.model.BpmCategoryDTO;
|
||||
import cn.axzo.workflow.core.service.dto.request.model.BpmCategoryCreateDTO;
|
||||
import cn.axzo.workflow.core.service.dto.request.model.BpmCategoryDTO;
|
||||
import cn.axzo.workflow.core.service.dto.request.model.BpmCategoryUpdateDTO;
|
||||
import cn.axzo.workflow.core.service.dto.response.model.BpmCategoryItemVo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -19,12 +21,13 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class BpmCategoryServiceImpl implements BpmCategoryService, BpmnConstants {
|
||||
public class BpmCategoryServiceImpl extends ServiceImpl<BpmDictDataMapper, BpmDictDataDO> implements BpmCategoryService, BpmnConstants {
|
||||
@Resource
|
||||
private BpmDictDataMapper bpmDictDataMapper;
|
||||
|
||||
@ -32,6 +35,12 @@ public class BpmCategoryServiceImpl implements BpmCategoryService, BpmnConstants
|
||||
|
||||
@Override
|
||||
public int createBpmCategory(BpmCategoryCreateDTO createDTO) {
|
||||
Optional<BpmDictDataDO> oneOpt = this.lambdaQuery().eq(BpmDictDataDO::getLabel, createDTO.getLabel())
|
||||
.eq(BpmDictDataDO::getValue, createDTO.getValue())
|
||||
.oneOpt();
|
||||
if (oneOpt.isPresent()) {
|
||||
throw new WorkflowEngineException("分类已存在");
|
||||
}
|
||||
BpmDictDataDO bpmDictDataDO = new BpmDictDataDO();
|
||||
bpmDictDataDO.setDictType(BPM_MODEL_CATEGORY);
|
||||
bpmDictDataDO.setLabel(createDTO.getLabel());
|
||||
|
||||
@ -1,25 +1,25 @@
|
||||
package cn.axzo.workflow.core.service.impl;
|
||||
|
||||
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
|
||||
import cn.axzo.workflow.core.common.utils.BpmTransformUtil;
|
||||
import cn.axzo.workflow.core.service.BpmModelService;
|
||||
import cn.axzo.workflow.core.service.BpmProcessDefinitionService;
|
||||
import cn.axzo.workflow.core.service.converter.BpmModelConverter;
|
||||
import cn.axzo.workflow.core.service.dto.request.model.BpmModelCreateDTO;
|
||||
import cn.axzo.workflow.core.service.dto.request.model.BpmModelBpmPageDTO;
|
||||
import cn.axzo.workflow.core.service.dto.request.model.BpmModelCreateDTO;
|
||||
import cn.axzo.workflow.core.service.dto.request.model.BpmModelUpdateDTO;
|
||||
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
|
||||
import cn.axzo.workflow.core.service.dto.response.model.BpmModelDetailVO;
|
||||
import cn.axzo.workflow.core.service.dto.response.model.BpmModelPageItemVO;
|
||||
import cn.axzo.workflow.core.common.utils.BpmTransformUtil;
|
||||
import cn.azxo.framework.common.utils.StringUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.flowable.common.engine.impl.db.SuspensionState;
|
||||
import org.flowable.engine.RepositoryService;
|
||||
import org.flowable.engine.repository.Model;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
@ -57,6 +57,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
repositoryService.saveModel(model);
|
||||
//存储Bpmn协议
|
||||
if (createDTO.getNode() != null) {
|
||||
//FIXME 在底层 Service 中直接将 jsonToXml 有风险,应先判断数据格式是否是 JSON
|
||||
byte[] bpmn = BpmTransformUtil.transformBpmnJsonToXml(createDTO.getNode(), model);
|
||||
saveModelBpmnXml(model, bpmn);
|
||||
}
|
||||
@ -83,27 +84,28 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
|
||||
@Override
|
||||
public void updateBpmModel(BpmModelUpdateDTO updateDTO) {
|
||||
Model model = repositoryService.createModelQuery().modelKey(updateDTO.getKey()).singleResult();
|
||||
if (ObjectUtils.isEmpty(model)) {
|
||||
Model originModel = repositoryService.createModelQuery().modelId(updateDTO.getId()).singleResult();
|
||||
if (ObjectUtils.isEmpty(originModel)) {
|
||||
throw new RuntimeException("模型不存在");
|
||||
}
|
||||
model.setName(updateDTO.getName());
|
||||
model.setMetaInfo(JSON.toJSONString(updateDTO.getMetaInfo()));
|
||||
model.setCategory(updateDTO.getCategory());
|
||||
model.setKey(updateDTO.getKey());
|
||||
model.setTenantId(updateDTO.getTenantId());
|
||||
originModel.setName(updateDTO.getName());
|
||||
originModel.setMetaInfo(JSON.toJSONString(updateDTO.getMetaInfo()));
|
||||
originModel.setCategory(updateDTO.getCategory());
|
||||
originModel.setKey(updateDTO.getKey());
|
||||
originModel.setTenantId(updateDTO.getTenantId());
|
||||
//存储Bpmn协议
|
||||
if (updateDTO.getNode() != null) {
|
||||
byte[] bpmn = BpmTransformUtil.transformBpmnJsonToXml(updateDTO.getNode(), model);
|
||||
saveModelBpmnXml(model, bpmn);
|
||||
//FIXME 入参是否强制为 JSON 格式?
|
||||
byte[] bpmn = BpmTransformUtil.transformBpmnJsonToXml(updateDTO.getNode(), originModel);
|
||||
saveModelBpmnXml(originModel, bpmn);
|
||||
}
|
||||
repositoryService.saveModel(model);
|
||||
repositoryService.saveModel(originModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String deployBpmModelById(String modelId) {
|
||||
Model model = this.repositoryService.getModel(modelId);
|
||||
if (org.springframework.util.ObjectUtils.isEmpty(model)) {
|
||||
if (ObjectUtils.isEmpty(model)) {
|
||||
throw new WorkflowEngineException(MODEL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@ -112,10 +114,10 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
throw new WorkflowEngineException(MODEL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
processDefinitionService.createProcessDeinition(model, bpmnBytes);
|
||||
processDefinitionService.createProcessDefinition(model, bpmnBytes);
|
||||
|
||||
// TODO 没跑通
|
||||
String definitionId = this.processDefinitionService.createProcessDeinition(model, bpmnBytes);
|
||||
String definitionId = this.processDefinitionService.createProcessDefinition(model, bpmnBytes);
|
||||
// 挂起原来的流程定义
|
||||
this.updateProcessDefinitionSuspended(model.getDeploymentId());
|
||||
ProcessDefinition definition = this.processDefinitionService.getProcessDefinition(definitionId);
|
||||
@ -143,7 +145,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
|
||||
private void saveModelBpmnXml(Model model, String bpmnXml) {
|
||||
if (!StringUtils.isBlank(bpmnXml)) {
|
||||
this.repositoryService.addModelEditorSource(model.getId(), bpmnXml.getBytes());
|
||||
saveModelBpmnXml(model, bpmnXml.getBytes());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
package cn.axzo.workflow.core.service.impl;
|
||||
|
||||
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
|
||||
import cn.axzo.workflow.core.common.utils.BpmCollectionUtils;
|
||||
import cn.axzo.workflow.core.repository.entity.ProcessDefinitionExtDO;
|
||||
import cn.axzo.workflow.core.repository.mapper.BpmProcessDefinitionExtMapper;
|
||||
import cn.axzo.workflow.core.service.BpmProcessDefinitionService;
|
||||
import cn.axzo.workflow.core.service.converter.BpmProcessDefinitionConvert;
|
||||
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessDefinitionPageDTO;
|
||||
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
|
||||
import cn.axzo.workflow.core.service.dto.response.process.BpmProcessDefinitionPageItemRespVO;
|
||||
import cn.axzo.workflow.core.service.BpmProcessDefinitionService;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -20,7 +21,6 @@ import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.engine.repository.ProcessDefinitionQuery;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -40,7 +40,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
||||
private BpmProcessDefinitionExtMapper processDefinitionExtMapper;
|
||||
|
||||
@Override
|
||||
public String createProcessDeinition(Model model, byte[] bpmnBytes) {
|
||||
public String createProcessDefinition(Model model, byte[] bpmnBytes) {
|
||||
if (model == null || bpmnBytes == null) {
|
||||
return null;
|
||||
}
|
||||
@ -160,7 +160,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
||||
|
||||
@Override
|
||||
public ProcessDefinition getActiveProcessDefinitionByKey(String key) {
|
||||
return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).active()
|
||||
return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).latestVersion()
|
||||
.singleResult();
|
||||
}
|
||||
|
||||
|
||||
@ -7,16 +7,15 @@ import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
|
||||
import cn.axzo.workflow.core.common.utils.BpmCollectionUtils;
|
||||
import cn.axzo.workflow.core.repository.entity.BpmProcessInstanceExtDO;
|
||||
import cn.axzo.workflow.core.repository.mapper.BpmProcessInstanceExtMapper;
|
||||
import cn.axzo.workflow.core.service.BpmProcessDefinitionService;
|
||||
import cn.axzo.workflow.core.service.BpmProcessInstanceService;
|
||||
import cn.axzo.workflow.core.service.converter.BpmProcessInstanceConvert;
|
||||
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceCreateDTO;
|
||||
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceMyPageReqVO;
|
||||
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceWithdrawDTO;
|
||||
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
|
||||
import cn.axzo.workflow.core.service.dto.response.process.BpmProcessInstancePageItemVO;
|
||||
import cn.axzo.workflow.core.service.dto.response.process.BpmProcessInstanceVO;
|
||||
import cn.axzo.workflow.core.service.BpmProcessDefinitionService;
|
||||
import cn.axzo.workflow.core.service.BpmProcessInstanceService;
|
||||
import cn.axzo.workflow.core.service.BpmTaskService;
|
||||
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceCreateDTO;
|
||||
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceWithdrawDTO;
|
||||
import cn.azxo.framework.common.utils.StringUtils;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
@ -132,8 +131,9 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||
|
||||
|
||||
@Override
|
||||
public String createProcessInstance(BpmProcessInstanceCreateDTO processInstanceCreateDTO) {
|
||||
ProcessDefinition definition = processDefinitionService.getActiveProcessDefinitionByKey(processInstanceCreateDTO.getProcessDefinitionKey());
|
||||
public String createProcessInstance(BpmProcessInstanceCreateDTO createDTO) {
|
||||
ProcessDefinition definition =
|
||||
processDefinitionService.getActiveProcessDefinitionByKey(createDTO.getProcessDefinitionKey());
|
||||
// 校验流程定义
|
||||
if (definition == null) {
|
||||
throw new WorkflowEngineException(PROCESS_DEFINITION_NOT_EXISTS);
|
||||
@ -141,32 +141,33 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||
if (definition.isSuspended()) {
|
||||
throw new WorkflowEngineException(PROCESS_DEFINITION_IS_SUSPENDED);
|
||||
}
|
||||
processInstanceCreateDTO.getVariables().put(INTERNAL_START_USER_NAME, processInstanceCreateDTO.getUserName());
|
||||
createDTO.getVariables().put(INTERNAL_START_USER_NAME, createDTO.getUserName());
|
||||
|
||||
// 创建流程实例
|
||||
// 设置流程实例的开始人,参考https://wenku.baidu.com/view/5538062e7a563c1ec5da50e2524de518964bd3f9.html
|
||||
String startUserId = String.valueOf(processInstanceCreateDTO.getIdentityId());
|
||||
String startUserId = String.valueOf(createDTO.getIdentityId());
|
||||
Authentication.setAuthenticatedUserId(startUserId);
|
||||
String name = StringUtils.isNotBlank(processInstanceCreateDTO.getCustomProcessInstanceName()) ? processInstanceCreateDTO.getCustomProcessInstanceName()
|
||||
String name = StringUtils.isNotBlank(createDTO.getCustomProcessInstanceName()) ?
|
||||
createDTO.getCustomProcessInstanceName()
|
||||
: definition.getName();
|
||||
// 设置流程名字
|
||||
ProcessInstance instance = runtimeService.createProcessInstanceBuilder()
|
||||
.processDefinitionId(definition.getId())
|
||||
.businessKey(processInstanceCreateDTO.getBusinessKey())
|
||||
.variables(processInstanceCreateDTO.getVariables())
|
||||
.businessKey(createDTO.getBusinessKey())
|
||||
.variables(createDTO.getVariables())
|
||||
.name(name)
|
||||
.tenantId(String.valueOf(processInstanceCreateDTO.getTenantId()))
|
||||
.tenantId(String.valueOf(createDTO.getTenantId()))
|
||||
.start();
|
||||
|
||||
BpmProcessInstanceExtDO extDO = new BpmProcessInstanceExtDO();
|
||||
extDO.setProcessInstanceId(instance.getId());
|
||||
extDO.setName(name);
|
||||
extDO.setTenantId(processInstanceCreateDTO.getTenantId());
|
||||
extDO.setStartCompanyId(processInstanceCreateDTO.getCompanyId());
|
||||
extDO.setStartIdentityId(processInstanceCreateDTO.getIdentityId());
|
||||
extDO.setStartUserName(processInstanceCreateDTO.getUserName());
|
||||
extDO.setFormVariables(processInstanceCreateDTO.getVariables());
|
||||
extDO.setExt(processInstanceCreateDTO.getExt());
|
||||
extDO.setTenantId(createDTO.getTenantId());
|
||||
extDO.setStartCompanyId(createDTO.getCompanyId());
|
||||
extDO.setStartIdentityId(createDTO.getIdentityId());
|
||||
extDO.setStartUserName(createDTO.getUserName());
|
||||
extDO.setFormVariables(createDTO.getVariables());
|
||||
extDO.setExt(createDTO.getExt());
|
||||
// 补全流程实例的拓展表
|
||||
processInstanceExtMapper.updateByProcessInstanceId(extDO);
|
||||
|
||||
|
||||
@ -5,3 +5,30 @@ ALTER TABLE `bpm_dict_data`
|
||||
CHANGE COLUMN `update_time` `update_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON
|
||||
UPDATE CURRENT_TIMESTAMP COMMENT '更新时间' AFTER `update_by`,
|
||||
CHANGE COLUMN `deleted` `is_delete` bigint NOT NULL DEFAULT b'0' COMMENT '是否删除' AFTER `update_at`;
|
||||
|
||||
|
||||
ALTER TABLE `bpm_process_definition_ext`
|
||||
CHANGE COLUMN `creator` `create_by` varchar (64) NULL DEFAULT '' COMMENT '创建者' AFTER `form_custom_view_path`,
|
||||
CHANGE COLUMN `create_time` `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间' AFTER `create_by`,
|
||||
CHANGE COLUMN `updater` `update_by` varchar (64) NULL DEFAULT '' COMMENT '更新者' AFTER `create_at`,
|
||||
CHANGE COLUMN `update_time` `update_at` datetime NULL DEFAULT CURRENT_TIMESTAMP ON
|
||||
UPDATE CURRENT_TIMESTAMP COMMENT '更新时间' AFTER `update_by`,
|
||||
CHANGE COLUMN `deleted` `is_delete` bigint NOT NULL DEFAULT b'0' COMMENT '是否删除' AFTER `update_at`;
|
||||
|
||||
|
||||
ALTER TABLE `bpm_process_instance_ext`
|
||||
CHANGE COLUMN `creator` `create_by` varchar (64) NULL DEFAULT '' COMMENT '创建者' AFTER `form_variables`,
|
||||
CHANGE COLUMN `create_time` `create_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间' AFTER `create_by`,
|
||||
CHANGE COLUMN `updater` `update_by` varchar (64) NULL DEFAULT '' COMMENT '更新者' AFTER `create_at`,
|
||||
CHANGE COLUMN `update_time` `update_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON
|
||||
UPDATE CURRENT_TIMESTAMP COMMENT '更新时间' AFTER `update_by`,
|
||||
CHANGE COLUMN `deleted` `is_delete` bigint NOT NULL DEFAULT b'0' COMMENT '是否删除' AFTER `update_at`;
|
||||
|
||||
|
||||
ALTER TABLE `sz-workflow`.`bpm_task_ext`
|
||||
CHANGE COLUMN `creator` `create_by` varchar (64) NULL DEFAULT '' COMMENT '创建者' AFTER `process_definition_id`,
|
||||
CHANGE COLUMN `create_time` `create_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间' AFTER `create_by`,
|
||||
CHANGE COLUMN `updater` `update_by` varchar (64) NULL DEFAULT '' COMMENT '更新者' AFTER `create_at`,
|
||||
CHANGE COLUMN `update_time` `update_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON
|
||||
UPDATE CURRENT_TIMESTAMP COMMENT '更新时间' AFTER `update_by`,
|
||||
CHANGE COLUMN `deleted` `is_delete` bigint NOT NULL DEFAULT b'0' COMMENT '是否删除' AFTER `update_at`;
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
package cn.axzo.server.controller.common;
|
||||
|
||||
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
|
||||
/**
|
||||
* 全局异常处理器
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/7/10 17:10
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
@ExceptionHandler(WorkflowEngineException.class)
|
||||
@ResponseBody
|
||||
public CommonResponse<?> workflowEnginException(WorkflowEngineException exception) {
|
||||
return CommonResponse.error(exception.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(ConstraintViolationException.class)
|
||||
@ResponseBody
|
||||
public CommonResponse<?> constraintException(ConstraintViolationException exception) {
|
||||
return CommonResponse.error(exception.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@ -11,13 +11,16 @@ import cn.azxo.framework.common.model.CommonResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Slf4j
|
||||
@RequestMapping("/web/v1/api/BpmModel")
|
||||
@RestController
|
||||
@Validated
|
||||
public class BpmModelController {
|
||||
|
||||
@Autowired
|
||||
@ -27,52 +30,51 @@ public class BpmModelController {
|
||||
* 获取流程模型的查询结果
|
||||
*/
|
||||
@GetMapping("/getModelPage")
|
||||
public CommonResponse<BpmPageResult<BpmModelPageItemVO>> create(@Valid @RequestBody BpmModelBpmPageDTO dto) {
|
||||
public CommonResponse<BpmPageResult<BpmModelPageItemVO>> modelPage(@Valid @RequestBody BpmModelBpmPageDTO dto) {
|
||||
log.info("获取流程模型getModelPage===>>>参数:{}", JSON.toJSONString(dto));
|
||||
BpmPageResult<BpmModelPageItemVO> result=bpmModelService.getModelPage(dto);
|
||||
BpmPageResult<BpmModelPageItemVO> result = bpmModelService.getModelPage(dto);
|
||||
return CommonResponse.success(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建流程,
|
||||
* return modelId的主键
|
||||
* */
|
||||
@PostMapping("/create")
|
||||
*/
|
||||
@PutMapping("/create")
|
||||
public CommonResponse<String> create(@Valid @RequestBody BpmModelCreateDTO dto) {
|
||||
log.info("创建流程createBpmModel===>>>参数:{}", JSON.toJSONString(dto));
|
||||
String result=bpmModelService.createBpmModel(dto);
|
||||
String result = bpmModelService.createBpmModel(dto);
|
||||
return CommonResponse.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模型
|
||||
* */
|
||||
@GetMapping("/getModelDetailById")
|
||||
*/
|
||||
@GetMapping("/get")
|
||||
public CommonResponse<BpmModelDetailVO> getModelDetailById(@RequestBody String modelId) {
|
||||
log.info("获取模型getModelDetailById===>>>参数:{}", JSON.toJSONString(modelId));
|
||||
BpmModelDetailVO result=bpmModelService.getModelDetailById(modelId);
|
||||
BpmModelDetailVO result = bpmModelService.getModelDetailById(modelId);
|
||||
return CommonResponse.success(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取模型
|
||||
* */
|
||||
@GetMapping("/getModelDetailByKey")
|
||||
*/
|
||||
@GetMapping("/getByKey")
|
||||
public CommonResponse<BpmModelDetailVO> getModelDetailByKey(@RequestBody String modelKey) {
|
||||
log.info("获取模型getModelDetailByKey===>>>参数:{}", JSON.toJSONString(modelKey));
|
||||
BpmModelDetailVO result=bpmModelService.getModelDetailByKey(modelKey);
|
||||
BpmModelDetailVO result = bpmModelService.getModelDetailByKey(modelKey);
|
||||
return CommonResponse.success(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改流程信息
|
||||
* */
|
||||
@PutMapping("/updateBpmModel")
|
||||
public CommonResponse updateBpmModel(@Valid @RequestBody BpmModelUpdateDTO dto) {
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public CommonResponse<String> updateBpmModel(@Valid @RequestBody BpmModelUpdateDTO dto) {
|
||||
log.info("修改流程信息updateBpmModel===>>>参数:{}", JSON.toJSONString(dto));
|
||||
bpmModelService.updateBpmModel(dto);
|
||||
return CommonResponse.success();
|
||||
@ -82,11 +84,11 @@ public class BpmModelController {
|
||||
/**
|
||||
* 部署模型
|
||||
* return 部署完成的流程定义Id
|
||||
* */
|
||||
@PostMapping("/deployBpmModelById")
|
||||
public CommonResponse<String> deployBpmModelById(@RequestBody String modelId) {
|
||||
*/
|
||||
@PostMapping("/deploy")
|
||||
public CommonResponse<String> deployBpmModelById(@Valid @NotBlank(message = "模型 ID 不能为空") String modelId) {
|
||||
log.info("部署模型deployBpmModelById===>>>参数:{}", JSON.toJSONString(modelId));
|
||||
String result=bpmModelService.deployBpmModelById(modelId);
|
||||
String result = bpmModelService.deployBpmModelById(modelId);
|
||||
return CommonResponse.success(result);
|
||||
}
|
||||
|
||||
@ -94,19 +96,19 @@ public class BpmModelController {
|
||||
/**
|
||||
* 部署模型
|
||||
* return 部署完成的流程定义Id
|
||||
* */
|
||||
@PostMapping("/deployBpmModelByKey")
|
||||
public CommonResponse<String> deployBpmModelByKey(@RequestBody String modelKey) {
|
||||
*/
|
||||
@PostMapping("/deployByKey")
|
||||
public CommonResponse<String> deployBpmModelByKey(@Valid @NotBlank(message = "模型 Key 不能为空") String modelKey) {
|
||||
log.info("部署模型deployBpmModelByKey===>>>参数:{}", JSON.toJSONString(modelKey));
|
||||
String result=bpmModelService.deployBpmModelByKey(modelKey);
|
||||
String result = bpmModelService.deployBpmModelByKey(modelKey);
|
||||
return CommonResponse.success(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除模型
|
||||
* */
|
||||
@PostMapping("/deleteBpmModel")
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public CommonResponse deleteBpmModel(@RequestBody String id) {
|
||||
log.info("删除模型deleteBpmModel===>>>参数:{}", JSON.toJSONString(id));
|
||||
bpmModelService.deleteBpmModel(id);
|
||||
|
||||
@ -29,7 +29,7 @@ public class BpmProcessDefinitionController {
|
||||
@PostMapping("/createProcessDeinition")
|
||||
public CommonResponse<String> createProcessDeinition(@RequestBody Model model, byte[] bpmnBytes) {
|
||||
log.info("创建流程定义createProcessDeinition===>>>参数:{}", JSON.toJSONString(model));
|
||||
String result=bpmProcessDefinitionService.createProcessDeinition(model,bpmnBytes);
|
||||
String result = bpmProcessDefinitionService.createProcessDefinition(model, bpmnBytes);
|
||||
return CommonResponse.success(result);
|
||||
}
|
||||
|
||||
|
||||
@ -2,8 +2,8 @@ package cn.axzo.server.controller.web;
|
||||
|
||||
import cn.axzo.workflow.core.service.BpmProcessInstanceService;
|
||||
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceCreateDTO;
|
||||
import cn.axzo.workflow.core.service.dto.response.process.BpmProcessInstanceVO;
|
||||
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceWithdrawDTO;
|
||||
import cn.axzo.workflow.core.service.dto.response.process.BpmProcessInstanceVO;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -26,7 +26,7 @@ public class BpmProcessInstanceController {
|
||||
/**
|
||||
* 发起审核
|
||||
* */
|
||||
@PostMapping("/createProcessInstance")
|
||||
@PutMapping("/create")
|
||||
public CommonResponse<String> createProcessInstance(@Valid @RequestBody BpmProcessInstanceCreateDTO dto) {
|
||||
log.info("发起审核createProcessInstance===>>>参数:{}", JSON.toJSONString(dto));
|
||||
String result=bpmProcessInstanceService.createProcessInstance(dto);
|
||||
@ -40,7 +40,7 @@ public class BpmProcessInstanceController {
|
||||
* @param id 流程实例的编号
|
||||
* @return 流程实例, 租户Id不必传
|
||||
*/
|
||||
@GetMapping("/getProcessInstance")
|
||||
@GetMapping("/get")
|
||||
public CommonResponse<ProcessInstance> getProcessInstance( @RequestBody String id, String tenantId) {
|
||||
log.info("获得流程实例 getProcessInstance===>>>参数:{},{}", id,tenantId);
|
||||
ProcessInstance result=bpmProcessInstanceService.getProcessInstance(id,tenantId);
|
||||
@ -55,7 +55,7 @@ public class BpmProcessInstanceController {
|
||||
* @param hasVariable 查询结果是否包含流程参数,
|
||||
* @return 流程实例, 租户Id不必传
|
||||
*/
|
||||
@GetMapping("/getProcessInstances")
|
||||
@GetMapping("/hasVariable/get")
|
||||
public CommonResponse<ProcessInstance> getProcessInstances( @RequestBody String id, String tenantId, boolean hasVariable) {
|
||||
log.info("获得流程实例 getProcessInstances===>>>参数:{},{}", id,tenantId);
|
||||
ProcessInstance result=bpmProcessInstanceService.getProcessInstance(id,tenantId,hasVariable);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user