包路径调整
This commit is contained in:
parent
d8245bf7da
commit
c8a25efd28
@ -1,4 +1,4 @@
|
||||
package cn.axzo.server.repository.entity;
|
||||
package cn.axzo.server.repository.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.server.repository.entity;
|
||||
package cn.axzo.server.repository.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.server.repository.mapper;
|
||||
|
||||
import cn.axzo.server.service.dto.process.BpmProcessInstanceExtDO;
|
||||
import cn.axzo.server.repository.dataobject.BpmProcessInstanceExtDO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.server.repository.mapper;
|
||||
|
||||
import cn.axzo.server.repository.entity.BpmTaskExtDO;
|
||||
import cn.axzo.server.repository.dataobject.BpmTaskExtDO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package cn.axzo.server.service;
|
||||
|
||||
import cn.axzo.server.service.dto.response.process.BpmProcessInstanceVO;
|
||||
import org.flowable.common.engine.impl.db.SuspensionState;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
|
||||
public interface BpmProcessDefinitionService {
|
||||
@ -17,6 +19,20 @@ public interface BpmProcessDefinitionService {
|
||||
* */
|
||||
ProcessDefinition getActiveProcessDefinitionByKey(String key);
|
||||
|
||||
/**
|
||||
* 获得历史的流程实例
|
||||
*
|
||||
* @param id 流程实例的编号
|
||||
* @return 历史的流程实例
|
||||
*/
|
||||
HistoricProcessInstance getHistoricProcessInstance(String id, String tenantId);
|
||||
|
||||
/**
|
||||
* 获得流程实例 VO 信息
|
||||
*
|
||||
* @param id 流程实例的编号
|
||||
* @return 流程实例
|
||||
*/
|
||||
BpmProcessInstanceVO getProcessInstanceVO(String id, String tenantId);
|
||||
|
||||
}
|
||||
|
||||
@ -1,7 +1,19 @@
|
||||
package cn.axzo.server.service;
|
||||
|
||||
import cn.axzo.server.service.dto.request.process.BpmProcessInstanceCreateDTO;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
|
||||
public interface BpmProcessInstanceService {
|
||||
|
||||
/**
|
||||
* 获得流程实例
|
||||
*
|
||||
* @param id 流程实例的编号
|
||||
* @return 流程实例, 租户Id不必传
|
||||
*/
|
||||
ProcessInstance getProcessInstance(String id, String tenantId);
|
||||
|
||||
Boolean updateProcessStatus(String processInstanceId, String status);
|
||||
|
||||
public String createProcessInstance(BpmProcessInstanceCreateDTO processInstanceCreateDTO);
|
||||
}
|
||||
|
||||
@ -1,98 +0,0 @@
|
||||
package cn.axzo.server.service.dto.process;
|
||||
|
||||
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.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@TableName(value = "bpm_process_instance_ext", autoResultMap = true)
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class BpmProcessInstanceExtDO {
|
||||
/**
|
||||
* 编号,自增
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 流程实例的名字
|
||||
* <p>
|
||||
* 冗余 ProcessInstance 的 name 属性,用于筛选
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 自定义的流程实例的编号
|
||||
*/
|
||||
private String customProInstId;
|
||||
/**
|
||||
* 流程实例的编号
|
||||
* <p>
|
||||
* 关联 ProcessInstance 的 id 属性
|
||||
*/
|
||||
private String processInstanceId;
|
||||
/**
|
||||
* 流程定义的编号
|
||||
* <p>
|
||||
* 关联 ProcessDefinition 的 id 属性
|
||||
*/
|
||||
private String processDefinitionId;
|
||||
/**
|
||||
* 流程分类
|
||||
* <p>
|
||||
* 冗余 ProcessDefinition 的 category 属性 数据字典 bpm_model_category
|
||||
*/
|
||||
private String category;
|
||||
/**
|
||||
* 流程实例的状态
|
||||
* <p>
|
||||
* 枚举 {@link BpmProcessInstanceStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 流程实例的结果
|
||||
* <p>
|
||||
* 枚举 {@link BpmProcessInstanceResultEnum}
|
||||
*/
|
||||
private Integer result;
|
||||
/**
|
||||
* 结束时间
|
||||
* <p>
|
||||
* 冗余 HistoricProcessInstance 的 endTime 属性
|
||||
*/
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 提交的表单值
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private Map<String, Object> formVariables;
|
||||
|
||||
/**
|
||||
* 发起人所在的工作台ID(企业/项目)
|
||||
* <p>
|
||||
* 使用租户字段隔离
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 发起人所在的项目工作台中的具体单位ID
|
||||
*/
|
||||
private Long startCompanyId;
|
||||
|
||||
/**
|
||||
* 发起人的身份ID
|
||||
*/
|
||||
private Long startIdentityId;
|
||||
|
||||
/**
|
||||
* 发起人的姓名
|
||||
*/
|
||||
private String startUserName;
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package cn.axzo.server.service.dto.request.process;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class BpmProcessInstanceCreateDTO {
|
||||
|
||||
/**
|
||||
* 流程定义的标识
|
||||
*/
|
||||
@NotEmpty(message = "流程定义的标识不能为空")
|
||||
private String processDefinitionKey;
|
||||
/**
|
||||
* 变量实例
|
||||
*/
|
||||
private Map<String, Object> variables;
|
||||
|
||||
/**
|
||||
* 业务的唯一标识
|
||||
* <p>
|
||||
* 例如说,请假申请的编号。通过它,可以查询到对应的实例
|
||||
*/
|
||||
@NotEmpty(message = "业务的唯一标识")
|
||||
private String businessKey;
|
||||
|
||||
/**
|
||||
* 发起人所在的(企业/项目)租户ID
|
||||
*/
|
||||
@NotNull(message = "租户Id")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 发起人所在的项目部下的具体公司ID
|
||||
*/
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 发起人的身份ID
|
||||
*/
|
||||
@NotNull(message = "用户Id/身份 ID 不能为空")
|
||||
private Long identityId;
|
||||
|
||||
/**
|
||||
* 发起人的姓名
|
||||
*/
|
||||
@NotBlank(message = "姓名不能为空")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 自定义的流程实例名称
|
||||
*/
|
||||
private String customProcessInstanceName;
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package cn.axzo.server.service.dto.response.process;
|
||||
|
||||
|
||||
import cn.axzo.server.repository.dataobject.BpmProcessInstanceExtDO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
|
||||
@Data
|
||||
public class BpmProcessInstanceVO {
|
||||
|
||||
@ApiModelProperty("引擎表内部的ProcessInstance对象")
|
||||
private ProcessInstance processInstance;
|
||||
|
||||
|
||||
private BpmProcessInstanceExtDO processInstanceExtDO;
|
||||
|
||||
|
||||
}
|
||||
@ -2,9 +2,11 @@ package cn.axzo.server.service.impl;
|
||||
|
||||
import cn.axzo.framework.domain.ServiceException;
|
||||
import cn.axzo.server.service.BpmProcessDefinitionService;
|
||||
import cn.axzo.server.service.dto.response.process.BpmProcessInstanceVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.common.engine.impl.db.SuspensionState;
|
||||
import org.flowable.engine.RepositoryService;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.repository.Deployment;
|
||||
import org.flowable.engine.repository.Model;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
@ -79,4 +81,14 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
||||
.singleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HistoricProcessInstance getHistoricProcessInstance(String id, String tenantId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmProcessInstanceVO getProcessInstanceVO(String id, String tenantId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,181 +2,80 @@ package cn.axzo.server.service.impl;
|
||||
|
||||
import cn.axzo.server.repository.mapper.BpmProcessInstanceExtMapper;
|
||||
import cn.axzo.server.service.BpmProcessDefinitionService;
|
||||
import cn.axzo.server.service.BpmProcessInstanceService;
|
||||
import cn.axzo.server.service.BpmTaskService;
|
||||
import cn.axzo.server.service.dto.request.process.BpmProcessInstanceCreateDTO;
|
||||
import com.github.xiaoymin.knife4j.core.util.StrUtil;
|
||||
import org.flowable.engine.*;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.flowable.engine.runtime.ProcessInstanceQuery;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class BpmProcessInstanceServiceImpl {
|
||||
@Service
|
||||
public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService {
|
||||
|
||||
// @Autowired
|
||||
// private TaskService engineTaskService;
|
||||
// @Autowired
|
||||
// private RepositoryService repositoryService;
|
||||
// @Autowired
|
||||
// private ManagementService managementService;
|
||||
//
|
||||
// @Autowired
|
||||
// private RuntimeService runtimeService;
|
||||
// @Autowired
|
||||
// private BpmProcessInstanceExtMapper processInstanceExtMapper;
|
||||
// @Autowired
|
||||
// @Lazy // 解决循环依赖
|
||||
// private BpmTaskService taskService;
|
||||
// @Autowired
|
||||
// private BpmProcessDefinitionService processDefinitionService;
|
||||
// @Autowired
|
||||
// private HistoryService historyService;
|
||||
//
|
||||
// @Override
|
||||
// public ProcessInstance getProcessInstance(String id, String tenantId) {
|
||||
// ProcessInstanceQuery instanceQuery = runtimeService.createProcessInstanceQuery()
|
||||
// .processInstanceId(id);
|
||||
// if (StrUtil.isNotBlank(tenantId)) {
|
||||
// instanceQuery.processInstanceTenantId(tenantId);
|
||||
// }
|
||||
// return instanceQuery.singleResult();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ProcessInstance getProcessInstance(String id, String tenantId, boolean hasVariable) {
|
||||
// ProcessInstanceQuery instanceQuery = runtimeService.createProcessInstanceQuery();
|
||||
// instanceQuery.processInstanceId(id);
|
||||
// if (hasVariable) {
|
||||
// instanceQuery.includeProcessVariables();
|
||||
// }
|
||||
// if (StrUtil.isNotBlank(tenantId)) {
|
||||
// instanceQuery.processInstanceTenantId(tenantId);
|
||||
// }
|
||||
// return instanceQuery.singleResult();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<ProcessInstance> getProcessInstances(Set<String> ids) {
|
||||
// return runtimeService.createProcessInstanceQuery().processInstanceIds(ids).list();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public PageResult<BpmProcessInstancePageItemRespVO> getMyProcessInstancePage(
|
||||
// BpmProcessInstanceMyPageReqVO pageReqVO) {
|
||||
// // 通过 BpmProcessInstanceExtDO 表,先查询到对应的分页
|
||||
// PageResult<BpmProcessInstanceExtDO> pageResult = processInstanceExtMapper.selectPage(null,
|
||||
// pageReqVO);
|
||||
// if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
// return new PageResult<>(pageResult.getTotal());
|
||||
// }
|
||||
//
|
||||
// // 获得流程 Task Map
|
||||
// List<String> processInstanceIds = convertList(pageResult.getList(),
|
||||
// BpmProcessInstanceExtDO::getProcessInstanceId);
|
||||
// Map<String, List<Task>> taskMap = taskService.getTaskMapByProcessInstanceIds(
|
||||
// processInstanceIds);
|
||||
// // 转换返回
|
||||
// return BpmProcessInstanceConvert.INSTANCE.convertPage(pageResult, taskMap);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public String createProcessInstance(@Valid BpmProcessInstanceCreateReqVO reqVO) {
|
||||
// // 获得流程定义
|
||||
// ProcessDefinition definition = processDefinitionService.getProcessDefinition2(
|
||||
// reqVO.getProcessDefinitionId());
|
||||
// // 发起流程
|
||||
// reqVO.getVariables().put(INTERNAL_EXECUTIVE_UNIT_ID, reqVO.getExecutiveUnitId());
|
||||
// return createProcessInstanceForAxzo(reqVO.getWorkspaceId(), reqVO.getCompanyId(),
|
||||
// reqVO.getIdentityId(), reqVO.getStartUserName(), reqVO.getCustomProcessInstanceName(),
|
||||
// definition, reqVO.getVariables(), null);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public String createProcessInstance(@Valid BpmProcessInstanceCreateReqDTO reqDTO) {
|
||||
// ProcessDefinition definition = processDefinitionService.getActiveProcessDefinition(
|
||||
// reqDTO.getProcessDefinitionKey());
|
||||
// return createProcessInstanceForAxzo(reqDTO.getWorkspaceId(), reqDTO.getCompanyId(),
|
||||
// reqDTO.getIdentityId(), reqDTO.getUserName(), reqDTO.getCustomProcessInstanceName(),
|
||||
// definition, reqDTO.getVariables(), reqDTO.getBusinessKey());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String createProcessInstance(Long userId,
|
||||
// @Valid BpmProcessInstanceCreateReqDTO createReqDTO) {
|
||||
// // 获得流程定义
|
||||
// ProcessDefinition definition = processDefinitionService.getActiveProcessDefinition(
|
||||
// createReqDTO.getProcessDefinitionKey());
|
||||
// // 发起流程
|
||||
// return createProcessInstance0(userId, definition, createReqDTO.getVariables(),
|
||||
// createReqDTO.getBusinessKey());
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public BpmProcessInstanceRespVO getProcessInstanceVO(String id, String tenantId) {
|
||||
// // 获得流程实例
|
||||
// HistoricProcessInstance processInstance = getHistoricProcessInstance(id, tenantId);
|
||||
// if (processInstance == null) {
|
||||
// return null;
|
||||
// }
|
||||
// BpmProcessInstanceExtDO processInstanceExt = processInstanceExtMapper.selectByProcessInstanceId(
|
||||
// id, tenantId);
|
||||
// Assert.notNull(processInstanceExt, "流程实例拓展({}) 不存在", id);
|
||||
//
|
||||
// // 获得流程定义
|
||||
// ProcessDefinition processDefinition = processDefinitionService
|
||||
// .getProcessDefinition(processInstance.getProcessDefinitionId());
|
||||
// Assert.notNull(processDefinition, "流程定义({}) 不存在", processInstance.getProcessDefinitionId());
|
||||
// BpmProcessDefinitionExtDO processDefinitionExt = processDefinitionService.getProcessDefinitionExt(
|
||||
// processInstance.getProcessDefinitionId());
|
||||
// Assert.notNull(processDefinitionExt, "流程定义拓展({}) 不存在", id);
|
||||
// String bpmnXml = processDefinitionService.getProcessDefinitionBpmnXML(
|
||||
// processInstance.getProcessDefinitionId());
|
||||
//
|
||||
// // 拼接数据
|
||||
// BpmProcessInstanceRespVO bpmProcessInstanceRespVO = BpmProcessInstanceConvert.INSTANCE.convert2(
|
||||
// processInstance, processInstanceExt, processDefinition, processDefinitionExt, bpmnXml, null,
|
||||
// null);
|
||||
// // 设置发起人姓名
|
||||
// String startUserName = processInstanceExtMapper.selectOne(
|
||||
// new QueryWrapper<BpmProcessInstanceExtDO>().lambda()
|
||||
// .eq(BpmProcessInstanceExtDO::getProcessInstanceId, processInstance.getId()))
|
||||
// .getStartUserName();
|
||||
// BpmProcessInstanceRespVO.User startUser = bpmProcessInstanceRespVO.getStartUser();
|
||||
// startUser.setStartUserName(startUserName);
|
||||
// bpmProcessInstanceRespVO.setStartUser(startUser);
|
||||
//
|
||||
// // 拼接结果
|
||||
// return bpmProcessInstanceRespVO;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void cancelProcessInstance(@Valid BpmProcessInstanceCancelReqVO cancelReqVO) {
|
||||
// // 校验流程实例存在
|
||||
// ProcessInstance instance = getProcessInstance(cancelReqVO.getId(),
|
||||
// String.valueOf(cancelReqVO.getWorkspaceId()));
|
||||
// if (instance == null) {
|
||||
// throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS);
|
||||
// }
|
||||
// // 只能取消自己的
|
||||
// Long workspaceId = cancelReqVO.getWorkspaceId();
|
||||
// Long identityId = cancelReqVO.getIdentityId();
|
||||
// if (!Objects.equals(instance.getStartUserId(),
|
||||
// workspaceId + "_" + identityId)) {
|
||||
// throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF);
|
||||
// }
|
||||
// Map<String, Object> variables = new HashMap<>();
|
||||
// variables.put(INTERNAL_END_USER_WORKSPACE_ID, cancelReqVO.getWorkspaceId());
|
||||
// variables.put(INTERNAL_END_USER_NAME, cancelReqVO.getName());
|
||||
// variables.put(INTERNAL_END_USER_IDENTITY_ID, cancelReqVO.getIdentityId());
|
||||
// runtimeService.setVariables(instance.getProcessInstanceId(), variables);
|
||||
//
|
||||
// // 通过删除流程实例,实现流程实例的取消,
|
||||
// // 删除流程实例,正则执行任务ACT_RU_TASK. 任务会被删除。通过历史表查询
|
||||
// deleteProcessInstance(cancelReqVO.getId(),
|
||||
// BpmProcessInstanceDeleteReasonEnum.CANCEL_TASK.format(cancelReqVO.getReason()));
|
||||
// }
|
||||
@Autowired
|
||||
private TaskService engineTaskService;
|
||||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
@Autowired
|
||||
private ManagementService managementService;
|
||||
|
||||
@Autowired
|
||||
private RuntimeService runtimeService;
|
||||
@Autowired
|
||||
private BpmProcessInstanceExtMapper processInstanceExtMapper;
|
||||
@Autowired
|
||||
@Lazy // 解决循环依赖
|
||||
private BpmTaskService taskService;
|
||||
@Autowired
|
||||
private BpmProcessDefinitionService processDefinitionService;
|
||||
@Autowired
|
||||
private HistoryService historyService;
|
||||
|
||||
@Override
|
||||
public ProcessInstance getProcessInstance(String id, String tenantId) {
|
||||
ProcessInstanceQuery instanceQuery = runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(id);
|
||||
if (StrUtil.isNotBlank(tenantId)) {
|
||||
instanceQuery.processInstanceTenantId(tenantId);
|
||||
}
|
||||
return instanceQuery.singleResult();
|
||||
}
|
||||
|
||||
|
||||
public ProcessInstance getProcessInstance(String id, String tenantId, boolean hasVariable) {
|
||||
ProcessInstanceQuery instanceQuery = runtimeService.createProcessInstanceQuery();
|
||||
instanceQuery.processInstanceId(id);
|
||||
if (hasVariable) {
|
||||
instanceQuery.includeProcessVariables();
|
||||
}
|
||||
if (StrUtil.isNotBlank(tenantId)) {
|
||||
instanceQuery.processInstanceTenantId(tenantId);
|
||||
}
|
||||
return instanceQuery.singleResult();
|
||||
}
|
||||
|
||||
|
||||
public List<ProcessInstance> getProcessInstances(Set<String> ids) {
|
||||
return runtimeService.createProcessInstanceQuery().processInstanceIds(ids).list();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean updateProcessStatus(String processInstanceId, String status) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createProcessInstance(BpmProcessInstanceCreateDTO processInstanceCreateDTO) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user