remove - 移除从芋道迁移过来的扩展表

This commit is contained in:
wangli 2023-07-26 11:19:41 +08:00
parent 73fa39d117
commit 6aee0c403c
14 changed files with 761 additions and 789 deletions

View File

@ -1,107 +1,107 @@
package cn.axzo.workflow.core.repository.entity;
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.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 cn.axzo.workflow.core.common.enums.BpmProcessInstanceStatusEnum}
*/
private Integer status;
/**
* 流程实例的结果
* <p>
* 枚举 {@link cn.axzo.workflow.core.common.enums.BpmProcessInstanceResultEnum}
*/
private Integer result;
/**
* 创建时间
*/
private Date createAt;
/**
* 结束时间
* <p>
* 冗余 HistoricProcessInstance endTime 属性
*/
private Date endTime;
/**
* 提交的表单值
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private Map<String, Object> formVariables;
/**
* 发起人所在的工作台ID(企业/项目)
* <p>
* 使用租户字段隔离
*/
private String tenantId;
/**
* 发起人的身份ID
*/
private String startUserId;
/**
* 发起人的姓名
*/
private String startUserName;
/**
* 拓展字段业务自定义数据
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private Object ext;
}
//package cn.axzo.workflow.core.repository.entity;
//
//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.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 cn.axzo.workflow.core.common.enums.BpmProcessInstanceStatusEnum}
// */
// private Integer status;
// /**
// * 流程实例的结果
// * <p>
// * 枚举 {@link cn.axzo.workflow.core.common.enums.BpmProcessInstanceResultEnum}
// */
// private Integer result;
//
// /**
// * 创建时间
// */
// private Date createAt;
//
// /**
// * 结束时间
// * <p>
// * 冗余 HistoricProcessInstance endTime 属性
// */
// private Date endTime;
//
// /**
// * 提交的表单值
// */
// @TableField(typeHandler = JacksonTypeHandler.class)
// private Map<String, Object> formVariables;
//
// /**
// * 发起人所在的工作台ID(企业/项目)
// * <p>
// * 使用租户字段隔离
// */
// private String tenantId;
//
// /**
// * 发起人的身份ID
// */
// private String startUserId;
//
// /**
// * 发起人的姓名
// */
// private String startUserName;
//
// /**
// * 拓展字段业务自定义数据
// */
// @TableField(typeHandler = JacksonTypeHandler.class)
// private Object ext;
//
//
//}

View File

@ -1,106 +1,106 @@
package cn.axzo.workflow.core.repository.entity;
import cn.axzo.framework.data.mybatisplus.model.BaseOwnEntity;
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;
@EqualsAndHashCode(callSuper = true)
@TableName(value = "bpm_task_ext", autoResultMap = true)
@Data
@ToString(callSuper = true)
public class TaskExtDO extends BaseOwnEntity<TaskExtDO> {
/**
* 编号自增
*/
@TableId
private Long id;
/**
* 任务的审批人
* <p>
* 冗余 Task assignee 属性
*/
private Long assigneeUserId;
/**
* 任务的名字
* <p>
* 冗余 Task name 属性为了筛选
*/
private String name;
/**
* 任务的编号
* <p>
* 关联 Task id 属性
*/
private String taskId;
/**
* 任务的结果
* <p>
* 枚举 {@link cn.axzo.workflow.core.common.enums.BpmProcessInstanceResultEnum}
*/
private Integer result;
/**
* 审批建议
*/
private String comment;
/**
* 任务的结束时间
* <p>
* 冗余 HistoricTaskInstance endTime 属性
*/
private Date endTime;
/**
* 流程实例的编号
* <p>
* 关联 ProcessInstance id 属性
*/
private String processInstanceId;
/**
* 流程定义的编号
* <p>
* 关联 ProcessDefinition id 属性
*/
private String processDefinitionId;
/**
* 租户ID
* <p>
* 企业或项目工作台ID
*/
private String tenantId;
/**
* 审批人的安心筑用户身份id
*/
private String userId;
/**
* 参与单位下的具体公司ID
*/
private Long companyId;
/**
* 审批人的姓名
*/
private String userName;
/**
* 审批人的组织架构信息, 施工使用
*/
private String organizationalStructureInfo;
/**
* 拓展字段业务自定义数据
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private Map<String, Object> ext;
}
//package cn.axzo.workflow.core.repository.entity;
//
//import cn.axzo.framework.data.mybatisplus.model.BaseOwnEntity;
//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;
//
//@EqualsAndHashCode(callSuper = true)
//@TableName(value = "bpm_task_ext", autoResultMap = true)
//@Data
//@ToString(callSuper = true)
//public class TaskExtDO extends BaseOwnEntity<TaskExtDO> {
//
// /**
// * 编号自增
// */
// @TableId
// private Long id;
// /**
// * 任务的审批人
// * <p>
// * 冗余 Task assignee 属性
// */
// private Long assigneeUserId;
// /**
// * 任务的名字
// * <p>
// * 冗余 Task name 属性为了筛选
// */
// private String name;
// /**
// * 任务的编号
// * <p>
// * 关联 Task id 属性
// */
// private String taskId;
// /**
// * 任务的结果
// * <p>
// * 枚举 {@link cn.axzo.workflow.core.common.enums.BpmProcessInstanceResultEnum}
// */
// private Integer result;
// /**
// * 审批建议
// */
// private String comment;
// /**
// * 任务的结束时间
// * <p>
// * 冗余 HistoricTaskInstance endTime 属性
// */
// private Date endTime;
//
// /**
// * 流程实例的编号
// * <p>
// * 关联 ProcessInstance id 属性
// */
// private String processInstanceId;
// /**
// * 流程定义的编号
// * <p>
// * 关联 ProcessDefinition id 属性
// */
// private String processDefinitionId;
//
// /**
// * 租户ID
// * <p>
// * 企业或项目工作台ID
// */
// private String tenantId;
//
// /**
// * 审批人的安心筑用户身份id
// */
// private String userId;
//
// /**
// * 参与单位下的具体公司ID
// */
// private Long companyId;
//
// /**
// * 审批人的姓名
// */
// private String userName;
//
// /**
// * 审批人的组织架构信息, 施工使用
// */
// private String organizationalStructureInfo;
//
// /**
// * 拓展字段业务自定义数据
// */
// @TableField(typeHandler = JacksonTypeHandler.class)
// private Map<String, Object> ext;
//}

View File

@ -1,46 +1,46 @@
package cn.axzo.workflow.core.repository.mapper;
import cn.axzo.workflow.core.repository.entity.BpmProcessInstanceExtDO;
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceMyPageReqVO;
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.util.StringUtils;
@Mapper
public interface BpmProcessInstanceExtMapper extends BaseMapperX<BpmProcessInstanceExtDO> {
default BpmPageResult<BpmProcessInstanceExtDO> selectPage(BpmProcessInstanceMyPageReqVO reqVO) {
return selectPage(reqVO, new BpmLambdaQueryWrapperX<BpmProcessInstanceExtDO>()
.likeIfPresent(BpmProcessInstanceExtDO::getName, reqVO.getName())
.eqIfPresent(BpmProcessInstanceExtDO::getCustomProInstId, reqVO.getCustomProInstId())
.eqIfPresent(BpmProcessInstanceExtDO::getProcessInstanceId, reqVO.getProcessDefinitionId())
.eqIfPresent(BpmProcessInstanceExtDO::getCategory, reqVO.getCategory())
.eqIfPresent(BpmProcessInstanceExtDO::getStatus, reqVO.getStatus())
.eqIfPresent(BpmProcessInstanceExtDO::getResult, reqVO.getResult())
.eqIfPresent(BpmProcessInstanceExtDO::getTenantId, reqVO.getTenantId())
.eqIfPresent(BpmProcessInstanceExtDO::getStartUserId, reqVO.getUserId())
.eqIfPresent(BpmProcessInstanceExtDO::getResult, reqVO.getResult())
.betweenIfPresent(BpmProcessInstanceExtDO::getCreateAt, reqVO.getBeginCreateTime(),
reqVO.getEndCreateTime())
.orderByAsc(BpmProcessInstanceExtDO::getStatus)
.orderByDesc(BpmProcessInstanceExtDO::getCreateAt));
}
default BpmProcessInstanceExtDO selectByProcessInstanceId(String processInstanceId,
String tenantId) {
if (StringUtils.hasLength(tenantId)) {
return selectOne(BpmProcessInstanceExtDO::getProcessInstanceId, processInstanceId,
BpmProcessInstanceExtDO::getTenantId, tenantId);
} else {
return selectOne(BpmProcessInstanceExtDO::getProcessInstanceId, processInstanceId);
}
}
default void updateByProcessInstanceId(BpmProcessInstanceExtDO updateObj) {
update(updateObj, new QueryWrapper<BpmProcessInstanceExtDO>()
.eq("process_instance_id", updateObj.getProcessInstanceId()));
}
}
//package cn.axzo.workflow.core.repository.mapper;
//
//import cn.axzo.workflow.core.repository.entity.BpmProcessInstanceExtDO;
//import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceMyPageReqVO;
//import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import org.apache.ibatis.annotations.Mapper;
//import org.springframework.util.StringUtils;
//
//@Mapper
//public interface BpmProcessInstanceExtMapper extends BaseMapperX<BpmProcessInstanceExtDO> {
//
// default BpmPageResult<BpmProcessInstanceExtDO> selectPage(BpmProcessInstanceMyPageReqVO reqVO) {
//
// return selectPage(reqVO, new BpmLambdaQueryWrapperX<BpmProcessInstanceExtDO>()
// .likeIfPresent(BpmProcessInstanceExtDO::getName, reqVO.getName())
// .eqIfPresent(BpmProcessInstanceExtDO::getCustomProInstId, reqVO.getCustomProInstId())
// .eqIfPresent(BpmProcessInstanceExtDO::getProcessInstanceId, reqVO.getProcessDefinitionId())
// .eqIfPresent(BpmProcessInstanceExtDO::getCategory, reqVO.getCategory())
// .eqIfPresent(BpmProcessInstanceExtDO::getStatus, reqVO.getStatus())
// .eqIfPresent(BpmProcessInstanceExtDO::getResult, reqVO.getResult())
// .eqIfPresent(BpmProcessInstanceExtDO::getTenantId, reqVO.getTenantId())
// .eqIfPresent(BpmProcessInstanceExtDO::getStartUserId, reqVO.getUserId())
// .eqIfPresent(BpmProcessInstanceExtDO::getResult, reqVO.getResult())
// .betweenIfPresent(BpmProcessInstanceExtDO::getCreateAt, reqVO.getBeginCreateTime(),
// reqVO.getEndCreateTime())
// .orderByAsc(BpmProcessInstanceExtDO::getStatus)
// .orderByDesc(BpmProcessInstanceExtDO::getCreateAt));
// }
//
// default BpmProcessInstanceExtDO selectByProcessInstanceId(String processInstanceId,
// String tenantId) {
// if (StringUtils.hasLength(tenantId)) {
// return selectOne(BpmProcessInstanceExtDO::getProcessInstanceId, processInstanceId,
// BpmProcessInstanceExtDO::getTenantId, tenantId);
// } else {
// return selectOne(BpmProcessInstanceExtDO::getProcessInstanceId, processInstanceId);
// }
// }
//
// default void updateByProcessInstanceId(BpmProcessInstanceExtDO updateObj) {
// update(updateObj, new QueryWrapper<BpmProcessInstanceExtDO>()
// .eq("process_instance_id", updateObj.getProcessInstanceId()));
// }
//
//}

View File

@ -1,28 +1,28 @@
package cn.axzo.workflow.core.repository.mapper;
import cn.axzo.workflow.core.repository.entity.TaskExtDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.Collection;
import java.util.List;
@Mapper
public interface BpmTaskExtMapper extends BaseMapperX<TaskExtDO> {
default void updateByTaskId(TaskExtDO entity) {
update(entity,
new LambdaQueryWrapper<TaskExtDO>().eq(TaskExtDO::getTaskId, entity.getTaskId()));
}
default List<TaskExtDO> selectListByTaskIds(Collection<String> taskIds) {
return selectList(TaskExtDO::getTaskId, taskIds);
}
default List<TaskExtDO> selectListByProcessInstanceId(String processInstanceId) {
return selectList("process_instance_id", processInstanceId);
}
default TaskExtDO selectByTaskId(String taskId) {
return selectOne(TaskExtDO::getTaskId, taskId);
}
}
//package cn.axzo.workflow.core.repository.mapper;
//
//import cn.axzo.workflow.core.repository.entity.TaskExtDO;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import org.apache.ibatis.annotations.Mapper;
//
//import java.util.Collection;
//import java.util.List;
//
//@Mapper
//public interface BpmTaskExtMapper extends BaseMapperX<TaskExtDO> {
// default void updateByTaskId(TaskExtDO entity) {
// update(entity,
// new LambdaQueryWrapper<TaskExtDO>().eq(TaskExtDO::getTaskId, entity.getTaskId()));
// }
//
// default List<TaskExtDO> selectListByTaskIds(Collection<String> taskIds) {
// return selectList(TaskExtDO::getTaskId, taskIds);
// }
//
// default List<TaskExtDO> selectListByProcessInstanceId(String processInstanceId) {
// return selectList("process_instance_id", processInstanceId);
// }
//
// default TaskExtDO selectByTaskId(String taskId) {
// return selectOne(TaskExtDO::getTaskId, taskId);
// }
//}

View File

@ -6,5 +6,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface BpmDictDataMapper extends BaseMapper<ExtAxDictDO> {
public interface ExtAxDictMapper extends BaseMapper<ExtAxDictDO> {
}

View File

@ -7,7 +7,6 @@ import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceMyPag
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 org.flowable.engine.delegate.event.FlowableCancelledEvent;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.form.api.FormInfo;
@ -88,25 +87,25 @@ public interface BpmProcessInstanceService {
*/
BpmProcessInstanceVO getProcessInstanceVO(String processInstanceId, String businessKey, String tenantId);
/**
* 创还能 ProcessInstance 扩展记录
*
* @param instance
*/
void createProcessInstanceExt(ProcessInstance instance);
/**
* 更新 ProcessInstance 扩展记录为取消
*
* @param instance
*/
void updateProcessInstanceExtComplete(ProcessInstance instance);
/**
* 更新 ProcessInstance 扩展记录为完成
*
* @param event
*/
void updateProcessInstanceExtCancel(FlowableCancelledEvent event);
// /**
// * 创还能 ProcessInstance 扩展记录
// *
// * @param instance
// */
// void createProcessInstanceExt(ProcessInstance instance);
//
// /**
// * 更新 ProcessInstance 扩展记录为取消
// *
// * @param instance
// */
// void updateProcessInstanceExtComplete(ProcessInstance instance);
//
// /**
// * 更新 ProcessInstance 扩展记录为完成
// *
// * @param event
// */
// void updateProcessInstanceExtCancel(FlowableCancelledEvent event);
}

View File

@ -1,133 +1,136 @@
package cn.axzo.workflow.core.service.converter;
import cn.axzo.workflow.core.repository.entity.BpmProcessInstanceExtDO;
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
import cn.axzo.workflow.core.service.dto.response.process.BpmProcessInstancePageItemVO;
import org.flowable.task.api.Task;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class BpmProcessInstanceConvert {
public static BpmPageResult<BpmProcessInstancePageItemVO> convertPage(BpmPageResult<BpmProcessInstanceExtDO> page,
Map<String, List<Task>> taskMap) {
List<BpmProcessInstancePageItemVO> list = convertList(page.getList());
list.forEach(respVO -> respVO.setTasks(convertList2(taskMap.get(respVO.getId()))));
return new BpmPageResult<>(list, page.getTotal());
}
public static List<BpmProcessInstancePageItemVO> convertList(List<BpmProcessInstanceExtDO> list){
if ( list == null ) {
return null;
}
List<BpmProcessInstancePageItemVO> list1 = new ArrayList<BpmProcessInstancePageItemVO>( list.size() );
for ( BpmProcessInstanceExtDO bpmProcessInstanceExtDO : list ) {
list1.add( convert( bpmProcessInstanceExtDO ) );
}
return list1;
}
public static BpmProcessInstancePageItemVO convert(BpmProcessInstanceExtDO bean){
if ( bean == null ) {
return null;
}
BpmProcessInstancePageItemVO bpmProcessInstancePageItemRespVO = new BpmProcessInstancePageItemVO();
bpmProcessInstancePageItemRespVO.setId( bean.getProcessInstanceId() );
bpmProcessInstancePageItemRespVO.setCustomProInstId( bean.getCustomProInstId() );
bpmProcessInstancePageItemRespVO.setName( bean.getName() );
bpmProcessInstancePageItemRespVO.setProcessDefinitionId( bean.getProcessDefinitionId() );
bpmProcessInstancePageItemRespVO.setCategory( bean.getCategory() );
bpmProcessInstancePageItemRespVO.setStatus( bean.getStatus() );
bpmProcessInstancePageItemRespVO.setResult(bean.getResult());
bpmProcessInstancePageItemRespVO.setCreateTime(bean.getCreateAt());
bpmProcessInstancePageItemRespVO.setEndTime(bean.getEndTime());
bpmProcessInstancePageItemRespVO.setStartUserName( bean.getStartUserName() );
return bpmProcessInstancePageItemRespVO;
}
public static List<BpmProcessInstancePageItemVO.Task> convertList2(List<Task> tasks){
if ( tasks == null ) {
return null;
}
List<BpmProcessInstancePageItemVO.Task> list = new ArrayList<BpmProcessInstancePageItemVO.Task>( tasks.size() );
for ( Task task : tasks ) {
list.add( taskToTask( task ) );
}
return list;
}
// default BpmProcessInstanceVO convert2(HistoricProcessInstance processInstance, BpmProcessInstanceExtDO processInstanceExt,
// ProcessDefinition processDefinition, BpmProcessDefinitionExtDO processDefinitionExt,
// String bpmnXml, AdminUserRespDTO startUser, DeptRespDTO dept) {
// BpmProcessInstanceRespVO respVO = convert2(processInstance);
// copyTo(processInstanceExt, respVO);
// // definition
// respVO.setProcessDefinition(convert2(processDefinition));
// copyTo(processDefinitionExt, respVO.getProcessDefinition());
// respVO.getProcessDefinition().setBpmnXml(bpmnXml);
// // user
//// if (startUser != null) {
//// respVO.setStartUser(convert2(startUser));
//// if (dept != null) {
//// respVO.getStartUser().setDeptName(dept.getName());
//// }
//// }
//package cn.axzo.workflow.core.service.converter;
//
// String startUserId = processInstance.getStartUserId();
// String[] s = startUserId.split("_");
// Long startWorkspaceId = Long.valueOf(s[0]);
// Long startIdentityId = Long.valueOf(s[1]);
//import cn.axzo.workflow.core.repository.entity.BpmProcessInstanceExtDO;
//import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
//import cn.axzo.workflow.core.service.dto.response.process.BpmProcessInstancePageItemVO;
//import org.flowable.task.api.Task;
//
// BpmProcessInstanceRespVO.User startUser1 = new BpmProcessInstanceRespVO.User();
// startUser1.setWorkspaceId(startWorkspaceId);
// startUser1.setIdentityId(startIdentityId);
// respVO.setStartUser(startUser1);
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//
// return respVO;
//public class BpmProcessInstanceConvert {
//
// public static BpmPageResult<BpmProcessInstancePageItemVO> convertPage(BpmPageResult<BpmProcessInstanceExtDO> page,
// Map<String, List<Task>> taskMap) {
// List<BpmProcessInstancePageItemVO> list = convertList(page.getList());
// list.forEach(respVO -> respVO.setTasks(convertList2(taskMap.get(respVO.getId()))));
// return new BpmPageResult<>(list, page.getTotal());
// }
//
// BpmProcessInstanceRespVO convert2(HistoricProcessInstance bean);
// public static List<BpmProcessInstancePageItemVO> convertList(List<BpmProcessInstanceExtDO> list){
// if ( list == null ) {
// return null;
// }
//
// @Mapping(source = "from.id", target = "to.id", ignore = true)
// void copyTo(BpmProcessInstanceExtDO from, @MappingTarget BpmProcessInstanceRespVO to);
// List<BpmProcessInstancePageItemVO> list1 = new ArrayList<BpmProcessInstancePageItemVO>( list.size() );
// for ( BpmProcessInstanceExtDO bpmProcessInstanceExtDO : list ) {
// list1.add( convert( bpmProcessInstanceExtDO ) );
// }
//
// BpmProcessInstanceRespVO.ProcessDefinition convert2(ProcessDefinition bean);
//
// @Mapping(source = "from.id", target = "to.id", ignore = true)
// void copyTo(BpmProcessDefinitionExtDO from, @MappingTarget BpmProcessInstanceRespVO.ProcessDefinition to);
//
// BpmProcessInstanceRespVO.User convert2(AdminUserRespDTO bean);
//
// default BpmProcessInstanceResultEvent convert(Object source, HistoricProcessInstance instance, Integer result) {
// BpmProcessInstanceResultEvent event = new BpmProcessInstanceResultEvent(source);
// event.setId(instance.getId());
// event.setProcessDefinitionKey(instance.getProcessDefinitionKey());
// event.setBusinessKey(instance.getBusinessKey());
// event.setResult(result);
// return event;
// return list1;
// }
public static BpmProcessInstancePageItemVO.Task taskToTask(Task task) {
if ( task == null ) {
return null;
}
BpmProcessInstancePageItemVO.Task task1 = new BpmProcessInstancePageItemVO.Task();
task1.setId( task.getId() );
task1.setName( task.getName() );
return task1;
}
}
//
// public static BpmProcessInstancePageItemVO convert(BpmProcessInstanceExtDO bean){
// if ( bean == null ) {
// return null;
// }
//
// BpmProcessInstancePageItemVO bpmProcessInstancePageItemRespVO = new BpmProcessInstancePageItemVO();
//
// bpmProcessInstancePageItemRespVO.setId( bean.getProcessInstanceId() );
// bpmProcessInstancePageItemRespVO.setCustomProInstId( bean.getCustomProInstId() );
// bpmProcessInstancePageItemRespVO.setName( bean.getName() );
// bpmProcessInstancePageItemRespVO.setProcessDefinitionId( bean.getProcessDefinitionId() );
// bpmProcessInstancePageItemRespVO.setCategory( bean.getCategory() );
// bpmProcessInstancePageItemRespVO.setStatus( bean.getStatus() );
// bpmProcessInstancePageItemRespVO.setResult(bean.getResult());
// bpmProcessInstancePageItemRespVO.setCreateTime(bean.getCreateAt());
// bpmProcessInstancePageItemRespVO.setEndTime(bean.getEndTime());
// bpmProcessInstancePageItemRespVO.setStartUserName( bean.getStartUserName() );
//
// return bpmProcessInstancePageItemRespVO;
// }
//
// public static List<BpmProcessInstancePageItemVO.Task> convertList2(List<Task> tasks){
// if ( tasks == null ) {
// return null;
// }
//
// List<BpmProcessInstancePageItemVO.Task> list = new ArrayList<BpmProcessInstancePageItemVO.Task>( tasks.size
// () );
// for ( Task task : tasks ) {
// list.add( taskToTask( task ) );
// }
//
// return list;
// }
//
//// default BpmProcessInstanceVO convert2(HistoricProcessInstance processInstance, BpmProcessInstanceExtDO
// processInstanceExt,
//// ProcessDefinition processDefinition, BpmProcessDefinitionExtDO
// processDefinitionExt,
//// String bpmnXml, AdminUserRespDTO startUser, DeptRespDTO dept) {
//// BpmProcessInstanceRespVO respVO = convert2(processInstance);
//// copyTo(processInstanceExt, respVO);
//// // definition
//// respVO.setProcessDefinition(convert2(processDefinition));
//// copyTo(processDefinitionExt, respVO.getProcessDefinition());
//// respVO.getProcessDefinition().setBpmnXml(bpmnXml);
//// // user
////// if (startUser != null) {
////// respVO.setStartUser(convert2(startUser));
////// if (dept != null) {
////// respVO.getStartUser().setDeptName(dept.getName());
////// }
////// }
////
//// String startUserId = processInstance.getStartUserId();
//// String[] s = startUserId.split("_");
//// Long startWorkspaceId = Long.valueOf(s[0]);
//// Long startIdentityId = Long.valueOf(s[1]);
////
//// BpmProcessInstanceRespVO.User startUser1 = new BpmProcessInstanceRespVO.User();
//// startUser1.setWorkspaceId(startWorkspaceId);
//// startUser1.setIdentityId(startIdentityId);
//// respVO.setStartUser(startUser1);
////
//// return respVO;
//// }
////
//// BpmProcessInstanceRespVO convert2(HistoricProcessInstance bean);
////
//// @Mapping(source = "from.id", target = "to.id", ignore = true)
//// void copyTo(BpmProcessInstanceExtDO from, @MappingTarget BpmProcessInstanceRespVO to);
////
//// BpmProcessInstanceRespVO.ProcessDefinition convert2(ProcessDefinition bean);
////
//// @Mapping(source = "from.id", target = "to.id", ignore = true)
//// void copyTo(BpmProcessDefinitionExtDO from, @MappingTarget BpmProcessInstanceRespVO.ProcessDefinition to);
////
//// BpmProcessInstanceRespVO.User convert2(AdminUserRespDTO bean);
////
//// default BpmProcessInstanceResultEvent convert(Object source, HistoricProcessInstance instance, Integer result) {
//// BpmProcessInstanceResultEvent event = new BpmProcessInstanceResultEvent(source);
//// event.setId(instance.getId());
//// event.setProcessDefinitionKey(instance.getProcessDefinitionKey());
//// event.setBusinessKey(instance.getBusinessKey());
//// event.setResult(result);
//// return event;
//// }
//
// public static BpmProcessInstancePageItemVO.Task taskToTask(Task task) {
// if ( task == null ) {
// return null;
// }
//
// BpmProcessInstancePageItemVO.Task task1 = new BpmProcessInstancePageItemVO.Task();
//
// task1.setId( task.getId() );
// task1.setName( task.getName() );
//
// return task1;
// }
//
//
//}

View File

@ -1,71 +1,69 @@
package cn.axzo.workflow.core.service.converter;
import cn.axzo.workflow.core.common.utils.BpmCollectionUtils;
import cn.axzo.workflow.core.repository.entity.TaskExtDO;
import cn.axzo.workflow.core.service.dto.response.task.BpmTaskDonePageItemRespVO;
import cn.axzo.workflow.core.service.dto.response.task.BpmTaskTodoPageItemRespVO;
import cn.hutool.core.util.StrUtil;
import org.flowable.common.engine.impl.db.SuspensionState;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.service.delegate.DelegateTask;
import org.mapstruct.factory.Mappers;
import org.springframework.beans.BeanUtils;
import java.util.List;
import java.util.Map;
public class BpmTaskConvert {
public static TaskExtDO convertTaskExt(DelegateTask task) {
String assignee = task.getAssignee();
TaskExtDO taskExtDO = new TaskExtDO();
taskExtDO.setTaskId(task.getId());
taskExtDO.setTenantId(task.getTenantId());
taskExtDO.setUserId(assignee);
taskExtDO.setProcessDefinitionId(task.getProcessDefinitionId());
taskExtDO.setProcessInstanceId(task.getProcessInstanceId());
taskExtDO.setName(task.getName());
taskExtDO.setCreateAt(task.getCreateTime());
taskExtDO.setUserName(task.getOwner());
return taskExtDO;
}
// public static TaskExtDO convertTaskExt(DelegateTask task) {
// String assignee = task.getAssignee();
// TaskExtDO taskExtDO = new TaskExtDO();
// taskExtDO.setTaskId(task.getId());
// taskExtDO.setTenantId(task.getTenantId());
// taskExtDO.setUserId(assignee);
// taskExtDO.setProcessDefinitionId(task.getProcessDefinitionId());
// taskExtDO.setProcessInstanceId(task.getProcessInstanceId());
// taskExtDO.setName(task.getName());
// taskExtDO.setCreateAt(task.getCreateTime());
// taskExtDO.setUserName(task.getOwner());
// return taskExtDO;
// }
public static List<BpmTaskDonePageItemRespVO> convertList2(List<HistoricTaskInstance> tasks,
Map<String, TaskExtDO> bpmTaskExtDOMap,
Map<String, HistoricProcessInstance> historicProcessInstanceMap) {
return BpmCollectionUtils.convertList(tasks, task -> {
BpmTaskDonePageItemRespVO respVO = convert2(task);
TaskExtDO taskExtDO = bpmTaskExtDOMap.get(task.getId());
BeanUtils.copyProperties(taskExtDO, respVO);
HistoricProcessInstance processInstance = historicProcessInstanceMap.get(
task.getProcessInstanceId());
if (processInstance != null) {
String startUserId = processInstance.getStartUserId();
//convert
BpmTaskTodoPageItemRespVO.ProcessInstance processInstance1 = new BpmTaskTodoPageItemRespVO.ProcessInstance();
processInstance1.setId(processInstance.getId());
processInstance1.setName(processInstance.getName());
processInstance1.setProcessDefinitionId(processInstance.getProcessDefinitionId());
processInstance1.setStartUserId(startUserId);
respVO.setProcessInstance(processInstance1);
}
return respVO;
});
}
// public static List<BpmTaskDonePageItemRespVO> convertList2(List<HistoricTaskInstance> tasks,
// Map<String, TaskExtDO> bpmTaskExtDOMap,
// Map<String, HistoricProcessInstance>
// historicProcessInstanceMap) {
// return BpmCollectionUtils.convertList(tasks, task -> {
// BpmTaskDonePageItemRespVO respVO = convert2(task);
// TaskExtDO taskExtDO = bpmTaskExtDOMap.get(task.getId());
// BeanUtils.copyProperties(taskExtDO, respVO);
// HistoricProcessInstance processInstance = historicProcessInstanceMap.get(
// task.getProcessInstanceId());
// if (processInstance != null) {
// String startUserId = processInstance.getStartUserId();
// //convert
// BpmTaskTodoPageItemRespVO.ProcessInstance processInstance1 = new BpmTaskTodoPageItemRespVO
// .ProcessInstance();
// processInstance1.setId(processInstance.getId());
// processInstance1.setName(processInstance.getName());
// processInstance1.setProcessDefinitionId(processInstance.getProcessDefinitionId());
// processInstance1.setStartUserId(startUserId);
// respVO.setProcessInstance(processInstance1);
// }
// return respVO;
// });
// }
public static BpmTaskDonePageItemRespVO convert2(HistoricTaskInstance bean) {
if ( bean == null ) {
if (bean == null) {
return null;
}
BpmTaskDonePageItemRespVO bpmTaskDonePageItemRespVO = new BpmTaskDonePageItemRespVO();
bpmTaskDonePageItemRespVO.setId( bean.getId() );
bpmTaskDonePageItemRespVO.setName( bean.getName() );
bpmTaskDonePageItemRespVO.setClaimTime( bean.getClaimTime() );
bpmTaskDonePageItemRespVO.setId(bean.getId());
bpmTaskDonePageItemRespVO.setName(bean.getName());
bpmTaskDonePageItemRespVO.setClaimTime(bean.getClaimTime());
bpmTaskDonePageItemRespVO.setCreateTime( bean.getCreateTime() );
bpmTaskDonePageItemRespVO.setEndTime( bean.getEndTime() );
bpmTaskDonePageItemRespVO.setDurationInMillis( bean.getDurationInMillis() );

View File

@ -3,12 +3,9 @@ package cn.axzo.workflow.core.service.engine;
import cn.axzo.workflow.core.listener.BpmProcessEventListener;
import cn.axzo.workflow.core.service.BpmProcessInstanceService;
import com.google.common.collect.ImmutableSet;
import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent;
import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType;
import org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener;
import org.flowable.engine.delegate.event.FlowableCancelledEvent;
import org.flowable.engine.delegate.event.FlowableProcessStartedEvent;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
@ -35,26 +32,26 @@ public class EngineProcessInstanceEventListener extends AbstractFlowableEngineEv
super(PROCESS_INSTANCE_EVENTS);
}
@Override
protected void processCreated(FlowableEngineEntityEvent event) {
processInstanceService.createProcessInstanceExt((ProcessInstance) event.getEntity());
processEventListener.ifAvailable(listener -> listener.onCreated(event));
}
// @Override
// protected void processCreated(FlowableEngineEntityEvent event) {
// processInstanceService.createProcessInstanceExt((ProcessInstance) event.getEntity());
// processEventListener.ifAvailable(listener -> listener.onCreated(event));
// }
@Override
protected void processStarted(FlowableProcessStartedEvent event) {
processEventListener.ifAvailable(listener -> listener.onStarted(event));
}
@Override
protected void processCompleted(FlowableEngineEntityEvent event) {
this.processInstanceService.updateProcessInstanceExtComplete((ProcessInstance) event.getEntity());
processEventListener.ifAvailable(listener -> listener.onCompleted(event));
}
// @Override
// protected void processCompleted(FlowableEngineEntityEvent event) {
// this.processInstanceService.updateProcessInstanceExtComplete((ProcessInstance) event.getEntity());
// processEventListener.ifAvailable(listener -> listener.onCompleted(event));
// }
@Override
protected void processCancelled(FlowableCancelledEvent event) {
processInstanceService.updateProcessInstanceExtCancel(event);
processEventListener.ifAvailable(listener -> listener.onCancelled(event));
}
// @Override
// protected void processCancelled(FlowableCancelledEvent event) {
// processInstanceService.updateProcessInstanceExtCancel(event);
// processEventListener.ifAvailable(listener -> listener.onCancelled(event));
// }
}

View File

@ -32,21 +32,21 @@ public class EngineTaskEventListener implements TaskListener {
switch (delegateTask.getEventName()) {
case TaskListener.EVENTNAME_CREATE:
taskEventListener.created(delegateTask);
taskService.createTaskExt(delegateTask);
// taskService.createTaskExt(delegateTask);
break;
case TaskListener.EVENTNAME_ASSIGNMENT:
taskEventListener.assigned(delegateTask);
taskService.updateTaskExtAssign(delegateTask);
// taskService.updateTaskExtAssign(delegateTask);
break;
case TaskListener.EVENTNAME_COMPLETE:
//审批完成
taskEventListener.completed(delegateTask);
taskService.updateTaskExtComplete(delegateTask);
// taskService.updateTaskExtComplete(delegateTask);
break;
case TaskListener.EVENTNAME_DELETE:
// 审批删除
taskService.updateTaskExtCancel(delegateTask);
taskEventListener.deleted(delegateTask);
// taskService.updateTaskExtCancel(delegateTask);
break;
default:
}

View File

@ -3,7 +3,7 @@ package cn.axzo.workflow.core.service.impl;
import cn.axzo.workflow.core.common.BpmConstants;
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
import cn.axzo.workflow.core.repository.entity.ExtAxDictDO;
import cn.axzo.workflow.core.repository.mapper.BpmDictDataMapper;
import cn.axzo.workflow.core.repository.mapper.ExtAxDictMapper;
import cn.axzo.workflow.core.service.BpmCategoryService;
import cn.axzo.workflow.core.service.converter.BpmCategoryConverter;
import cn.axzo.workflow.core.service.dto.request.model.BpmCategoryCreateDTO;
@ -31,10 +31,10 @@ import static cn.axzo.workflow.core.common.enums.BpmErrorCode.CATEGORY_VALUE_EXI
@Service
@RequiredArgsConstructor
@Slf4j
public class BpmCategoryServiceImpl extends ServiceImpl<BpmDictDataMapper, ExtAxDictDO> implements BpmCategoryService
public class BpmCategoryServiceImpl extends ServiceImpl<ExtAxDictMapper, ExtAxDictDO> implements BpmCategoryService
, BpmConstants {
@Resource
private BpmDictDataMapper bpmDictDataMapper;
private ExtAxDictMapper bpmDictDataMapper;
private final BpmCategoryConverter bpmCategoryConverter;

View File

@ -1,15 +1,10 @@
package cn.axzo.workflow.core.service.impl;
import cn.axzo.workflow.core.common.enums.BpmProcessInstanceDeleteReasonEnum;
import cn.axzo.workflow.core.common.enums.BpmProcessInstanceResultEnum;
import cn.axzo.workflow.core.common.enums.BpmProcessInstanceStatusEnum;
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.BpmProcessInstanceCancelDTO;
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceCreateDTO;
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceCreateWithFormDTO;
@ -19,10 +14,7 @@ import cn.axzo.workflow.core.service.dto.response.process.BpmProcessDefinitionVO
import cn.axzo.workflow.core.service.dto.response.process.BpmProcessInstancePageItemVO;
import cn.axzo.workflow.core.service.dto.response.process.BpmProcessInstanceVO;
import cn.azxo.framework.common.utils.StringUtils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import lombok.extern.slf4j.Slf4j;
import org.flowable.common.engine.impl.db.SuspensionState;
import org.flowable.common.engine.impl.identity.Authentication;
@ -30,18 +22,14 @@ import org.flowable.engine.HistoryService;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.delegate.event.FlowableCancelledEvent;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.history.HistoricProcessInstanceQuery;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.engine.runtime.ProcessInstanceQuery;
import org.flowable.form.api.FormInfo;
import org.flowable.task.api.Task;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Nullable;
import javax.validation.Valid;
@ -49,7 +37,6 @@ import java.util.*;
import static cn.axzo.workflow.core.common.BpmConstants.*;
import static cn.axzo.workflow.core.common.enums.BpmErrorCode.*;
import static cn.axzo.workflow.core.common.utils.BpmCollectionUtils.convertList;
@Service
@Slf4j
@ -61,8 +48,8 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
private RepositoryService repositoryService;
@Autowired
private RuntimeService runtimeService;
@Autowired
private BpmProcessInstanceExtMapper processInstanceExtMapper;
// @Autowired
// private BpmProcessInstanceExtMapper processInstanceExtMapper;
@Autowired
@Lazy // 解决循环依赖
private BpmTaskServiceImpl taskService;
@ -89,18 +76,19 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
@Override
public BpmPageResult<BpmProcessInstancePageItemVO> getMyProcessInstancePage(@Valid BpmProcessInstanceMyPageReqVO pageReqVO) {
// 通过 BpmProcessInstanceExtDO 先查询到对应的分页
BpmPageResult<BpmProcessInstanceExtDO> pageResult = processInstanceExtMapper.selectPage(pageReqVO);
if (CollUtil.isEmpty(pageResult.getList())) {
return new BpmPageResult<>(pageResult.getTotal());
}
// 获得流程 Task Map
List<String> processInstanceIds = convertList(pageResult.getList(),
BpmProcessInstanceExtDO::getProcessInstanceId);
Map<String, List<Task>> taskMap = taskService.getTaskMapByProcessInstanceIds(
processInstanceIds);
// 转换返回
return BpmProcessInstanceConvert.convertPage(pageResult, taskMap);
// BpmPageResult<BpmProcessInstanceExtDO> pageResult = processInstanceExtMapper.selectPage(pageReqVO);
// if (CollUtil.isEmpty(pageResult.getList())) {
// return new BpmPageResult<>(pageResult.getTotal());
// }
//
// // 获得流程 Task Map
// List<String> processInstanceIds = convertList(pageResult.getList(),
// BpmProcessInstanceExtDO::getProcessInstanceId);
// Map<String, List<Task>> taskMap = taskService.getTaskMapByProcessInstanceIds(
// processInstanceIds);
// // 转换返回
// return BpmProcessInstanceConvert.convertPage(pageResult, taskMap);
return null;
}
@Override
@ -169,17 +157,17 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
.tenantId(dto.getTenantId())
.start();
BpmProcessInstanceExtDO extDO = new BpmProcessInstanceExtDO();
extDO.setProcessInstanceId(instance.getId());
extDO.setName(name);
extDO.setTenantId(dto.getTenantId());
// extDO.setStartCompanyId(dto.getCompanyId());
extDO.setStartUserId(dto.getUserId());
extDO.setStartUserName(dto.getUserName());
extDO.setFormVariables(dto.getVariables());
extDO.setExt(dto.getExt());
// 补全流程实例的拓展表
processInstanceExtMapper.updateByProcessInstanceId(extDO);
// BpmProcessInstanceExtDO extDO = new BpmProcessInstanceExtDO();
// extDO.setProcessInstanceId(instance.getId());
// extDO.setName(name);
// extDO.setTenantId(dto.getTenantId());
// // extDO.setStartCompanyId(dto.getCompanyId());
// extDO.setStartUserId(dto.getUserId());
// extDO.setStartUserName(dto.getUserName());
// extDO.setFormVariables(dto.getVariables());
// extDO.setExt(dto.getExt());
// // 补全流程实例的拓展表
// processInstanceExtMapper.updateByProcessInstanceId(extDO);
return instance.getId();
}
@ -207,16 +195,16 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
ProcessInstance instance = runtimeService.startProcessInstanceWithForm(definition.getId(),
dto.getOutcome(), dto.getVariables(), name);
BpmProcessInstanceExtDO extDO = new BpmProcessInstanceExtDO();
extDO.setProcessInstanceId(instance.getId());
extDO.setName(name);
extDO.setTenantId(dto.getTenantId());
extDO.setStartUserId(dto.getUserId());
extDO.setStartUserName(dto.getUserName());
extDO.setFormVariables(dto.getVariables());
extDO.setExt(dto.getExt());
// 补全流程实例的拓展表
processInstanceExtMapper.updateByProcessInstanceId(extDO);
// BpmProcessInstanceExtDO extDO = new BpmProcessInstanceExtDO();
// extDO.setProcessInstanceId(instance.getId());
// extDO.setName(name);
// extDO.setTenantId(dto.getTenantId());
// extDO.setStartUserId(dto.getUserId());
// extDO.setStartUserName(dto.getUserName());
// extDO.setFormVariables(dto.getVariables());
// extDO.setExt(dto.getExt());
// // 补全流程实例的拓展表
// processInstanceExtMapper.updateByProcessInstanceId(extDO);
return instance.getId();
}
@ -285,9 +273,9 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
if (processInstance == null) {
return null;
}
BpmProcessInstanceExtDO processInstanceExt = processInstanceExtMapper.selectByProcessInstanceId(
processInstance.getId(), tenantId);
Assert.notNull(processInstanceExt, "流程实例拓展({}) 不存在", processInstance.getId());
// BpmProcessInstanceExtDO processInstanceExt = processInstanceExtMapper.selectByProcessInstanceId(
// processInstance.getId(), tenantId);
// Assert.notNull(processInstanceExt, "流程实例拓展({}) 不存在", processInstance.getId());
// 获得流程定义
BpmProcessDefinitionVO processDefinition = processDefinitionService
@ -295,98 +283,98 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
Assert.notNull(processDefinition, "流程定义({}) 不存在", processInstance.getProcessDefinitionId());
BpmProcessInstanceVO bpmProcessInstanceVO = new BpmProcessInstanceVO();
BeanUtils.copyProperties(processInstanceExt, bpmProcessInstanceVO);
bpmProcessInstanceVO.setId(processInstance.getId());
bpmProcessInstanceVO.setBusinessKey(processInstance.getBusinessKey());
bpmProcessInstanceVO.setStartUserId(processInstance.getStartUserId());
bpmProcessInstanceVO.setExt(processInstanceExt.getExt());
// BeanUtils.copyProperties(processInstanceExt, bpmProcessInstanceVO);
// bpmProcessInstanceVO.setId(processInstance.getId());
// bpmProcessInstanceVO.setBusinessKey(processInstance.getBusinessKey());
// bpmProcessInstanceVO.setStartUserId(processInstance.getStartUserId());
// bpmProcessInstanceVO.setExt(processInstanceExt.getExt());
// 拼接结果
return bpmProcessInstanceVO;
}
@Override
public void createProcessInstanceExt(ProcessInstance instance) {
// 获得流程定义
BpmProcessDefinitionVO definition = processDefinitionService.getProcessDefinition(
instance.getProcessDefinitionId());
// 插入 BpmProcessInstanceExtDO 对象
BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO();
instanceExtDO.setCustomProInstId(IdWorker.get32UUID());
instanceExtDO.setProcessInstanceId(instance.getId());
instanceExtDO.setProcessDefinitionId(definition.getId());
instanceExtDO.setCategory(definition.getCategory());
instanceExtDO.setName(instance.getName());
instanceExtDO.setTenantId(instance.getTenantId());
instanceExtDO.setFormVariables(instance.getProcessVariables());
instanceExtDO.setStartUserId(instance.getStartUserId());
instanceExtDO.setStatus(BpmProcessInstanceStatusEnum.RUNNING.getStatus());
instanceExtDO.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
processInstanceExtMapper.insert(instanceExtDO);
}
// @Override
// public void createProcessInstanceExt(ProcessInstance instance) {
// 获得流程定义
// BpmProcessDefinitionVO definition = processDefinitionService.getProcessDefinition(
// instance.getProcessDefinitionId());
// 插入 BpmProcessInstanceExtDO 对象
// BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO();
// instanceExtDO.setCustomProInstId(IdWorker.get32UUID());
// instanceExtDO.setProcessInstanceId(instance.getId());
// instanceExtDO.setProcessDefinitionId(definition.getId());
// instanceExtDO.setCategory(definition.getCategory());
// instanceExtDO.setName(instance.getName());
// instanceExtDO.setTenantId(instance.getTenantId());
// instanceExtDO.setFormVariables(instance.getProcessVariables());
// instanceExtDO.setStartUserId(instance.getStartUserId());
// instanceExtDO.setStatus(BpmProcessInstanceStatusEnum.RUNNING.getStatus());
// instanceExtDO.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
// processInstanceExtMapper.insert(instanceExtDO);
// }
@Override
public void updateProcessInstanceExtCancel(FlowableCancelledEvent event) {
// 判断是否为 Reject 不通过如果是则不进行更新
if (BpmProcessInstanceDeleteReasonEnum.isRejectReason((String) event.getCause())) {
return;
}
// @Override
// public void updateProcessInstanceExtCancel(FlowableCancelledEvent event) {
// // 判断是否为 Reject 不通过如果是则不进行更新
// if (BpmProcessInstanceDeleteReasonEnum.isRejectReason((String) event.getCause())) {
// return;
// }
//
// // 需要主动查询因为 instance 只有 id 属性
// // 另外此时如果去查询 ProcessInstance 的话字段是不全的所以去查询了 HistoricProcessInstance
// HistoricProcessInstance processInstance = getHistoricProcessInstance(
// event.getProcessInstanceId(), null);
// // 更新拓展表
// BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO();
// instanceExtDO.setProcessInstanceId(event.getProcessInstanceId());
// instanceExtDO.setEndTime(new Date()); // 由于 ProcessInstance 里没有办法拿到 endTime所以这里设置
// instanceExtDO.setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus());
// instanceExtDO.setResult(BpmProcessInstanceResultEnum.CANCEL.getResult());
//
// processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO);
//
// // 发送流程实例的状态事件
// // processInstanceResultEventPublisher.sendProcessInstanceResultEvent(
// // BpmProcessInstanceConvert.INSTANCE.convert(this, processInstance,
// // instanceExtDO.getResult()));
// }
// 需要主动查询因为 instance 只有 id 属性
// 另外此时如果去查询 ProcessInstance 的话字段是不全的所以去查询了 HistoricProcessInstance
HistoricProcessInstance processInstance = getHistoricProcessInstance(
event.getProcessInstanceId(), null);
// 更新拓展表
BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO();
instanceExtDO.setProcessInstanceId(event.getProcessInstanceId());
instanceExtDO.setEndTime(new Date()); // 由于 ProcessInstance 里没有办法拿到 endTime所以这里设置
instanceExtDO.setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus());
instanceExtDO.setResult(BpmProcessInstanceResultEnum.CANCEL.getResult());
// @Override
// public void updateProcessInstanceExtComplete(ProcessInstance instance) {
// // 需要主动查询因为 instance 只有 id 属性
// // 另外此时如果去查询 ProcessInstance 的话字段是不全的所以去查询了 HistoricProcessInstance
// HistoricProcessInstance processInstance = getHistoricProcessInstance(instance.getId(),
// instance.getTenantId());
// // 更新拓展表
// BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO();
// instanceExtDO.setProcessInstanceId(instance.getProcessInstanceId());
// instanceExtDO.setEndTime(new Date()); // 由于 ProcessInstance 里没有办法拿到 endTime所以这里设置
// instanceExtDO.setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus());
// instanceExtDO.setResult(BpmProcessInstanceResultEnum.APPROVE.getResult()); // 如果正常完全说明审批通过
// processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO);
//
// // 发送流程实例的状态事件
// // processInstanceResultEventPublisher.sendProcessInstanceResultEvent(
// // BpmProcessInstanceConvert.INSTANCE.convert(this, processInstance,
// // instanceExtDO.getResult()));
// }
processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO);
// 发送流程实例的状态事件
// processInstanceResultEventPublisher.sendProcessInstanceResultEvent(
// BpmProcessInstanceConvert.INSTANCE.convert(this, processInstance,
// instanceExtDO.getResult()));
}
@Override
public void updateProcessInstanceExtComplete(ProcessInstance instance) {
// 需要主动查询因为 instance 只有 id 属性
// 另外此时如果去查询 ProcessInstance 的话字段是不全的所以去查询了 HistoricProcessInstance
HistoricProcessInstance processInstance = getHistoricProcessInstance(instance.getId(),
instance.getTenantId());
// 更新拓展表
BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO();
instanceExtDO.setProcessInstanceId(instance.getProcessInstanceId());
instanceExtDO.setEndTime(new Date()); // 由于 ProcessInstance 里没有办法拿到 endTime所以这里设置
instanceExtDO.setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus());
instanceExtDO.setResult(BpmProcessInstanceResultEnum.APPROVE.getResult()); // 如果正常完全说明审批通过
processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO);
// 发送流程实例的状态事件
// processInstanceResultEventPublisher.sendProcessInstanceResultEvent(
// BpmProcessInstanceConvert.INSTANCE.convert(this, processInstance,
// instanceExtDO.getResult()));
}
@Transactional(rollbackFor = Exception.class)
public void updateProcessInstanceExtReject(String id, String comment, String tenantId) {
// 需要主动查询因为 instance 只有 id 属性
ProcessInstance processInstance = getProcessInstance(id, tenantId, false);
// 删除流程实例以实现驳回任务时取消整个审批流程
deleteProcessInstance(id, StrUtil.format(BpmProcessInstanceDeleteReasonEnum.REJECT_TASK.format(comment)));
// 更新 status + result
// 注意不能和上面的逻辑更换位置因为 deleteProcessInstance 会触发流程的取消进而调用 updateProcessInstanceExtCancel 方法
// 设置 result BpmProcessInstanceStatusEnum.CANCEL显然和 result 不一定是一致的
BpmProcessInstanceExtDO processInstanceExtDO = new BpmProcessInstanceExtDO();
processInstanceExtDO.setProcessInstanceId(processInstance.getId());
processInstanceExtDO.setEndTime(new Date());
processInstanceExtDO.setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus());
processInstanceExtDO.setResult(BpmProcessInstanceResultEnum.REJECT.getResult());
processInstanceExtMapper.updateByProcessInstanceId(processInstanceExtDO);
}
// @Transactional(rollbackFor = Exception.class)
// public void updateProcessInstanceExtReject(String id, String comment, String tenantId) {
// // 需要主动查询因为 instance 只有 id 属性
// ProcessInstance processInstance = getProcessInstance(id, tenantId, false);
//
// // 删除流程实例以实现驳回任务时取消整个审批流程
// deleteProcessInstance(id, StrUtil.format(BpmProcessInstanceDeleteReasonEnum.REJECT_TASK.format(comment)));
// // 更新 status + result
// // 注意不能和上面的逻辑更换位置因为 deleteProcessInstance 会触发流程的取消进而调用 updateProcessInstanceExtCancel 方法
// // 设置 result BpmProcessInstanceStatusEnum.CANCEL显然和 result 不一定是一致的
// BpmProcessInstanceExtDO processInstanceExtDO = new BpmProcessInstanceExtDO();
// processInstanceExtDO.setProcessInstanceId(processInstance.getId());
// processInstanceExtDO.setEndTime(new Date());
// processInstanceExtDO.setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus());
// processInstanceExtDO.setResult(BpmProcessInstanceResultEnum.REJECT.getResult());
// processInstanceExtMapper.updateByProcessInstanceId(processInstanceExtDO);
// }
private void deleteProcessInstance(String id, String reason) {
log.info("当前线程: {}", Thread.currentThread().getName());

View File

@ -1,25 +1,17 @@
package cn.axzo.workflow.core.service.impl;
import cn.axzo.workflow.core.common.BpmConstants;
import cn.axzo.workflow.core.common.enums.BpmProcessInstanceDeleteReasonEnum;
import cn.axzo.workflow.core.common.enums.BpmProcessInstanceResultEnum;
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.entity.TaskExtDO;
import cn.axzo.workflow.core.repository.mapper.BpmProcessInstanceExtMapper;
import cn.axzo.workflow.core.repository.mapper.BpmTaskExtMapper;
import cn.axzo.workflow.core.service.BpmTaskService;
import cn.axzo.workflow.core.service.converter.BpmTaskConvert;
import cn.axzo.workflow.core.service.dto.request.task.BpmTaskAuditDTO;
import cn.axzo.workflow.core.service.dto.request.task.BpmTaskTodoBpmPageDTO;
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
import cn.axzo.workflow.core.service.dto.response.task.BpmTaskDonePageItemRespVO;
import cn.axzo.workflow.core.service.dto.response.task.BpmTaskTodoPageItemRespVO;
import cn.azxo.framework.common.utils.StringUtils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RepositoryService;
@ -32,20 +24,15 @@ import org.flowable.task.api.Task;
import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import javax.annotation.Resource;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static cn.axzo.workflow.core.common.BpmConstants.*;
import static cn.axzo.workflow.core.common.enums.BpmErrorCode.*;
import static cn.axzo.workflow.core.common.utils.BpmCollectionUtils.convertMap;
import static cn.axzo.workflow.core.common.utils.BpmCollectionUtils.convertSet;
@Service
@ -62,14 +49,14 @@ public class BpmTaskServiceImpl implements BpmTaskService {
private RepositoryService repositoryService;
@Resource
private BpmProcessInstanceServiceImpl processInstanceService;
@Resource
private BpmTaskExtMapper taskExtMapper;
@Resource
private BpmProcessInstanceExtMapper bpmProcessInstanceExtMapper;
// @Resource
// private BpmTaskExtMapper taskExtMapper;
// @Resource
// private BpmProcessInstanceExtMapper bpmProcessInstanceExtMapper;
@Override
public BpmPageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(BpmTaskTodoBpmPageDTO taskTodoPageDTO) {
BpmProcessInstanceExtDO one = null;
// BpmProcessInstanceExtDO one = null;
// 查询待办任务
TaskQuery taskQuery = taskService.createTaskQuery()
@ -89,9 +76,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
if (taskTodoPageDTO.getEndCreateTime() != null) {
taskQuery.taskCreatedBefore(taskTodoPageDTO.getEndCreateTime());
}
if (Objects.nonNull(one)) {
taskQuery.processInstanceId(one.getProcessInstanceId());
}
// if (Objects.nonNull(one)) {
// taskQuery.processInstanceId(one.getProcessInstanceId());
// }
// 执行查询
List<Task> tasks = taskQuery.listPage((taskTodoPageDTO.getPageNo() - 1) * taskTodoPageDTO.getPageSize(),
@ -108,33 +95,33 @@ public class BpmTaskServiceImpl implements BpmTaskService {
List<BpmTaskTodoPageItemRespVO> bpmTaskTodoPageItemRespVOS = BpmTaskConvert.convertList1(
tasks, processInstanceMap);
Map<String, BpmProcessInstanceExtDO> instanceExtMap = convertMap(
bpmProcessInstanceExtMapper.selectList(
new LambdaQueryWrapper<BpmProcessInstanceExtDO>().in(
BpmProcessInstanceExtDO::getProcessInstanceId, processInstanceIds)),
BpmProcessInstanceExtDO::getProcessInstanceId, Function.identity(), (s, t) -> s);
// Map<String, BpmProcessInstanceExtDO> instanceExtMap = convertMap(
// bpmProcessInstanceExtMapper.selectList(
// new LambdaQueryWrapper<BpmProcessInstanceExtDO>().in(
// BpmProcessInstanceExtDO::getProcessInstanceId, processInstanceIds)),
// BpmProcessInstanceExtDO::getProcessInstanceId, Function.identity(), (s, t) -> s);
// 设置发起人姓名
bpmTaskTodoPageItemRespVOS.forEach(vo -> {
BpmTaskTodoPageItemRespVO.ProcessInstance processInstance = vo.getProcessInstance();
BpmProcessInstanceExtDO instanceExtDO = instanceExtMap.get(processInstance.getId());
if (Objects.nonNull(instanceExtDO)) {
processInstance.setCustomProInstId(instanceExtDO.getCustomProInstId());
processInstance.setCategory(instanceExtDO.getCategory());
processInstance.setStartUserName(instanceExtDO.getStartUserName());
processInstance.setStartTime(instanceExtDO.getCreateAt());
}
// BpmProcessInstanceExtDO instanceExtDO = instanceExtMap.get(processInstance.getId());
// if (Objects.nonNull(instanceExtDO)) {
// processInstance.setCustomProInstId(instanceExtDO.getCustomProInstId());
// processInstance.setCategory(instanceExtDO.getCategory());
// processInstance.setStartUserName(instanceExtDO.getStartUserName());
// processInstance.setStartTime(instanceExtDO.getCreateAt());
// }
});
return new BpmPageResult<>(bpmTaskTodoPageItemRespVOS, taskQuery.count());
}
@Override
public BpmPageResult<BpmTaskTodoPageItemRespVO> getDoneTaskPage(BpmTaskTodoBpmPageDTO taskDonePageD) {
BpmProcessInstanceExtDO one = null;
if (org.springframework.util.StringUtils.hasLength(taskDonePageD.getCustomProInstId())) {
one = bpmProcessInstanceExtMapper.selectOne(
BpmProcessInstanceExtDO::getCustomProInstId, taskDonePageD.getCustomProInstId());
}
// BpmProcessInstanceExtDO one = null;
// if (org.springframework.util.StringUtils.hasLength(taskDonePageD.getCustomProInstId())) {
// one = bpmProcessInstanceExtMapper.selectOne(
// BpmProcessInstanceExtDO::getCustomProInstId, taskDonePageD.getCustomProInstId());
// }
// 查询已办任务
HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery()
@ -155,9 +142,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
Arrays.stream(taskDonePageD.getCategory().split(",")).map(String::trim).collect(Collectors.toList());
taskQuery.processCategoryIn(categorys);
}
if (Objects.nonNull(one)) {
taskQuery.processInstanceId(one.getProcessInstanceId());
}
// if (Objects.nonNull(one)) {
// taskQuery.processInstanceId(one.getProcessInstanceId());
// }
// 执行查询
List<HistoricTaskInstance> tasks =
taskQuery.listPage((taskDonePageD.getPageNo() - 1) * taskDonePageD.getPageSize(),
@ -167,9 +154,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
}
// 获得 TaskExtDO Map
List<TaskExtDO> bpmTaskExtDOs = taskExtMapper.selectListByTaskIds(
convertSet(tasks, HistoricTaskInstance::getId));
Map<String, TaskExtDO> bpmTaskExtDOMap = convertMap(bpmTaskExtDOs, TaskExtDO::getTaskId);
// List<TaskExtDO> bpmTaskExtDOs = taskExtMapper.selectListByTaskIds(
// convertSet(tasks, HistoricTaskInstance::getId));
// Map<String, TaskExtDO> bpmTaskExtDOMap = convertMap(bpmTaskExtDOs, TaskExtDO::getTaskId);
// 获得 ProcessInstance Map
Set<String> processInstanceIds = convertSet(tasks, HistoricTaskInstance::getProcessInstanceId);
Map<String, HistoricProcessInstance> historicProcessInstanceMap =
@ -177,26 +164,26 @@ public class BpmTaskServiceImpl implements BpmTaskService {
processInstanceIds);
// 拼接数据
List<BpmTaskDonePageItemRespVO> bpmTaskDonePageItemRespVOS = BpmTaskConvert.convertList2(
tasks, bpmTaskExtDOMap, historicProcessInstanceMap);
Map<String, BpmProcessInstanceExtDO> instanceExtMap = convertMap(
bpmProcessInstanceExtMapper.selectList(
new LambdaQueryWrapper<BpmProcessInstanceExtDO>().in(
BpmProcessInstanceExtDO::getProcessInstanceId, processInstanceIds)),
BpmProcessInstanceExtDO::getProcessInstanceId, Function.identity(), (s, t) -> s);
// 设置发起人姓名
bpmTaskDonePageItemRespVOS.forEach(vo -> {
BpmTaskTodoPageItemRespVO.ProcessInstance processInstance = vo.getProcessInstance();
BpmProcessInstanceExtDO instanceExtDO = instanceExtMap.get(processInstance.getId());
processInstance.setCustomProInstId(instanceExtDO.getCustomProInstId());
processInstance.setCategory(instanceExtDO.getCategory());
processInstance.setStartUserName(instanceExtDO.getStartUserName());
processInstance.setStartTime(instanceExtDO.getCreateAt());
});
return new BpmPageResult(bpmTaskDonePageItemRespVOS, taskQuery.count());
// List<BpmTaskDonePageItemRespVO> bpmTaskDonePageItemRespVOS = BpmTaskConvert.convertList2(
// tasks, bpmTaskExtDOMap, historicProcessInstanceMap);
//
// Map<String, BpmProcessInstanceExtDO> instanceExtMap = convertMap(
// bpmProcessInstanceExtMapper.selectList(
// new LambdaQueryWrapper<BpmProcessInstanceExtDO>().in(
// BpmProcessInstanceExtDO::getProcessInstanceId, processInstanceIds)),
// BpmProcessInstanceExtDO::getProcessInstanceId, Function.identity(), (s, t) -> s);
//
// // 设置发起人姓名
// bpmTaskDonePageItemRespVOS.forEach(vo -> {
// BpmTaskTodoPageItemRespVO.ProcessInstance processInstance = vo.getProcessInstance();
// BpmProcessInstanceExtDO instanceExtDO = instanceExtMap.get(processInstance.getId());
// processInstance.setCustomProInstId(instanceExtDO.getCustomProInstId());
// processInstance.setCategory(instanceExtDO.getCategory());
// processInstance.setStartUserName(instanceExtDO.getStartUserName());
// processInstance.setStartTime(instanceExtDO.getCreateAt());
// });
// return new BpmPageResult(bpmTaskDonePageItemRespVOS, taskQuery.count());
return null;
}
@Override
@ -221,24 +208,24 @@ public class BpmTaskServiceImpl implements BpmTaskService {
// 满足条件1当前任务是多实例任务节点的子任务
// 满足条件2该子任务完成时将所在多实例任务节点中的其他子任务也一并删除说明此时已经满足了多实例的完成条件
// 此时需要将该任务所在多实例任务节点中的其他子任务更新任务拓展表为已完成
for (Task taskRunningBefore : taskRunningListBefore) {
if (!task.getId().equals(taskRunningBefore.getId())) {
TaskExtDO taskExtDO = new TaskExtDO();
taskExtDO.setTaskId(taskRunningBefore.getId());
taskExtDO.setResult(BpmProcessInstanceResultEnum.APPROVE.getResult());
taskExtDO.setComment("自动完成");
taskExtDO.setEndTime(new Date());
taskExtMapper.updateByTaskId(taskExtDO);
}
}
// for (Task taskRunningBefore : taskRunningListBefore) {
// if (!task.getId().equals(taskRunningBefore.getId())) {
// TaskExtDO taskExtDO = new TaskExtDO();
// taskExtDO.setTaskId(taskRunningBefore.getId());
// taskExtDO.setResult(BpmProcessInstanceResultEnum.APPROVE.getResult());
// taskExtDO.setComment("自动完成");
// taskExtDO.setEndTime(new Date());
// taskExtMapper.updateByTaskId(taskExtDO);
// }
// }
}
TaskExtDO taskExtDO = new TaskExtDO();
taskExtDO.setTaskId(task.getId());
taskExtDO.setResult(BpmProcessInstanceResultEnum.APPROVE.getResult());
taskExtDO.setComment(dto.getComment());
taskExtDO.setEndTime(new Date());
// 更新任务拓展表为通过
taskExtMapper.updateByTaskId(taskExtDO);
// TaskExtDO taskExtDO = new TaskExtDO();
// taskExtDO.setTaskId(task.getId());
// taskExtDO.setResult(BpmProcessInstanceResultEnum.APPROVE.getResult());
// taskExtDO.setComment(dto.getComment());
// taskExtDO.setEndTime(new Date());
// // 更新任务拓展表为通过
// taskExtMapper.updateByTaskId(taskExtDO);
Map<String, Object> transientMap = new HashMap<>();
transientMap.put(BpmConstants.INTERNAL_TASK_COMMENT, dto.getComment());
@ -267,15 +254,15 @@ public class BpmTaskServiceImpl implements BpmTaskService {
runtimeService.setVariables(instance.getProcessInstanceId(), variables);
// 更新任务拓展表为不通过
TaskExtDO taskExtDO = new TaskExtDO();
taskExtDO.setTaskId(task.getId());
taskExtDO.setResult(BpmProcessInstanceResultEnum.REJECT.getResult());
taskExtDO.setComment(taskAuditDTO.getComment());
taskExtDO.setEndTime(new Date());
taskExtMapper.updateByTaskId(taskExtDO);
// 更新流程实例为不通过
processInstanceService.updateProcessInstanceExtReject(instance.getProcessInstanceId(),
taskAuditDTO.getComment(), taskAuditDTO.getTenantId());
// TaskExtDO taskExtDO = new TaskExtDO();
// taskExtDO.setTaskId(task.getId());
// taskExtDO.setResult(BpmProcessInstanceResultEnum.REJECT.getResult());
// taskExtDO.setComment(taskAuditDTO.getComment());
// taskExtDO.setEndTime(new Date());
// taskExtMapper.updateByTaskId(taskExtDO);
// // 更新流程实例为不通过
// processInstanceService.updateProcessInstanceExtReject(instance.getProcessInstanceId(),
// taskAuditDTO.getComment(), taskAuditDTO.getTenantId());
}
@Override
@ -328,68 +315,68 @@ public class BpmTaskServiceImpl implements BpmTaskService {
return taskQuery.singleResult();
}
public void createTaskExt(DelegateTask task) {
TaskExtDO taskExtDO = BpmTaskConvert.convertTaskExt(task);
taskExtDO.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
taskExtMapper.insert(taskExtDO);
}
// public void createTaskExt(DelegateTask task) {
// TaskExtDO taskExtDO = BpmTaskConvert.convertTaskExt(task);
// taskExtDO.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
// taskExtMapper.insert(taskExtDO);
// }
public void updateTaskExtComplete(DelegateTask task) {
TaskExtDO taskExtDO = BpmTaskConvert.convertTaskExt(task);
taskExtDO.setEndTime(new Date());
taskExtMapper.updateByTaskId(taskExtDO);
}
// public void updateTaskExtComplete(DelegateTask task) {
// TaskExtDO taskExtDO = BpmTaskConvert.convertTaskExt(task);
// taskExtDO.setEndTime(new Date());
// taskExtMapper.updateByTaskId(taskExtDO);
// }
public void updateTaskExtAssign(DelegateTask task) {
String assignee = task.getAssignee();
String processDefinitionId = task.getProcessDefinitionId();
String taskDefinitionKey = task.getTaskDefinitionKey();
// 在获取候选人列表时向bpm_task_assignee_info表中插入选择的审批人的信息在这里更新bpm_task_exe表时通过task_id从bpm_task_assigner_info
// 表中获取审批人的完整信息
TaskExtDO taskExtDO = new TaskExtDO();
taskExtDO.setTaskId(task.getId());
taskExtDO.setTenantId(task.getTenantId());
taskExtDO.setUserId(assignee);
taskExtDO.setProcessDefinitionId(processDefinitionId);
taskExtDO.setUserName(task.getOwner());
taskExtMapper.updateByTaskId(taskExtDO);
}
// public void updateTaskExtAssign(DelegateTask task) {
// String assignee = task.getAssignee();
// String processDefinitionId = task.getProcessDefinitionId();
// String taskDefinitionKey = task.getTaskDefinitionKey();
// // 在获取候选人列表时向bpm_task_assignee_info表中插入选择的审批人的信息在这里更新bpm_task_exe表时通过task_id从bpm_task_assigner_info
// // 表中获取审批人的完整信息
// TaskExtDO taskExtDO = new TaskExtDO();
// taskExtDO.setTaskId(task.getId());
// taskExtDO.setTenantId(task.getTenantId());
// taskExtDO.setUserId(assignee);
// taskExtDO.setProcessDefinitionId(processDefinitionId);
// taskExtDO.setUserName(task.getOwner());
// taskExtMapper.updateByTaskId(taskExtDO);
// }
public void updateTaskExtCancel(DelegateTask task) {
// 需要在事务提交后才进行查询不然查询不到历史的原因
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 可能只是活动不是任务所以查询不到
String taskId = task.getId();
HistoricTaskInstance task = getHistoricTask(taskId);
if (task == null) {
return;
}
// 如果任务拓展表已经是完成的状态则跳过
TaskExtDO taskExt = taskExtMapper.selectByTaskId(taskId);
if (taskExt == null) {
log.error("[updateTaskExtCancel][taskId({}) 查找不到对应的记录,可能存在问题]", taskId);
return;
}
// 如果已经是最终的结果则跳过
if (BpmProcessInstanceResultEnum.isEndResult(taskExt.getResult())) {
log.warn("[updateTaskExtCancel][taskId({}) 处于结果({}),无需进行更新]", taskId,
taskExt.getResult());
return;
}
taskExt.setEndTime(new Date());
taskExt.setResult(BpmProcessInstanceResultEnum.CANCEL.getResult());
taskExt.setComment(BpmProcessInstanceDeleteReasonEnum.translateReason(task.getDeleteReason()));
// 更新任务
taskExtMapper.updateById(taskExt);
}
});
}
// public void updateTaskExtCancel(DelegateTask task) {
// // 需要在事务提交后才进行查询不然查询不到历史的原因
// TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
//
// @Override
// public void afterCommit() {
// // 可能只是活动不是任务所以查询不到
// String taskId = task.getId();
// HistoricTaskInstance task = getHistoricTask(taskId);
// if (task == null) {
// return;
// }
//
// // 如果任务拓展表已经是完成的状态则跳过
// TaskExtDO taskExt = taskExtMapper.selectByTaskId(taskId);
// if (taskExt == null) {
// log.error("[updateTaskExtCancel][taskId({}) 查找不到对应的记录,可能存在问题]", taskId);
// return;
// }
// // 如果已经是最终的结果则跳过
// if (BpmProcessInstanceResultEnum.isEndResult(taskExt.getResult())) {
// log.warn("[updateTaskExtCancel][taskId({}) 处于结果({}),无需进行更新]", taskId,
// taskExt.getResult());
// return;
// }
// taskExt.setEndTime(new Date());
// taskExt.setResult(BpmProcessInstanceResultEnum.CANCEL.getResult());
// taskExt.setComment(BpmProcessInstanceDeleteReasonEnum.translateReason(task.getDeleteReason()));
//
// // 更新任务
// taskExtMapper.updateById(taskExt);
// }
//
// });
// }
public HistoricTaskInstance getHistoricTask(String id) {
return historyService.createHistoricTaskInstanceQuery().taskId(id).singleResult();

View File

@ -21,8 +21,8 @@ FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for ACT_EVT_LOG
-- ----------------------------
DROP TABLE IF EXISTS `ext_ax_dict`;
CREATE TABLE `ext_ax_dict`
DROP TABLE IF EXISTS `EXT_AX_DICT`;
CREATE TABLE `EXT_AX_DICT`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '字典编码',
`type` varchar(100) NOT NULL DEFAULT '' COMMENT '字典类型',