提交 e7241d13 authored 作者: whydesc's avatar whydesc

--新增业务流程履历表

上级 151ebb5b
......@@ -284,92 +284,6 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
}
}
// 给第一步申请人节点设置任务执行人和意见
// Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().singleResult();
// if (Objects.nonNull(task)) {
// taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), sysUser.getRealname() + "发起流程申请");
// taskService.setAssignee(task.getId(),sysUser.getUsername());
// taskService.complete(task.getId(), variables);
// }
/*======================todo 启动之后 回调以及关键数据保存======================*/
/**
//业务数据id
String dataId = variables.get("dataId").toString();
//如果保存数据前未调用必调的FlowCommonService.initActBusiness方法,就会有问题
FlowMyBusiness business = flowMyBusinessService.getByDataId(dataId);
//设置数据
FlowNextDto nextFlowNode = flowTaskService.getNextFlowNode(task.getId(), variables);
taskService.complete(task.getId(), variables);
//下一个实例节点 多实例会是一个list,随意取一个即可 数组中定义Key是一致的
//Task task2 = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().singleResult();
List<Task> task2List = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().list();
Task task2 = null;
if(task2List.size()>0) task2 = task2List.get(0);
String doneUsers = business.getDoneUsers();
// 处理过流程的人
JSONArray doneUserList = new JSONArray();
if (StrUtil.isNotBlank(doneUsers)){
doneUserList = JSON.parseArray(doneUsers);
}
if (!doneUserList.contains(sysUser.getUsername())){
doneUserList.add(sysUser.getUsername());
}
if (nextFlowNode!=null){
//**有下一个节点
UserTask nextTask = nextFlowNode.getUserTask();
//能够处理下个节点的候选人
List<SysUser> nextFlowNodeUserList = nextFlowNode.getUserList();
List<String> collect_username = nextFlowNodeUserList.stream().map(SysUser::getUsername).collect(Collectors.toList());
//spring容器类名
String serviceImplName = business.getServiceImplName();
FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName);
List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionKey(), variables);
if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)){
// 删除后重写
for (Task task2One : task2List) {
for (String oldUser : collect_username) {
taskService.deleteCandidateUser(task2One.getId(),oldUser);
}
}
// 业务层有指定候选人,覆盖
for (Task task2One : task2List) {
for (String newUser : beforeParamsCandidateUsernames) {
taskService.addCandidateUser(task2One.getId(),newUser);
}
}
business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames));
}
business.setProcessDefinitionId(procDefId)
.setProcessInstanceId(processInstance.getProcessInstanceId())
.setActStatus(ActStatus.start)
.setProposer(sysUser.getUsername())
.setTaskId(task2.getId())
.setTaskName(nextTask.getName())
.setTaskNameId(nextTask.getId())
.setPriority(nextTask.getPriority())
.setDoneUsers(doneUserList.toJSONString())
.setTodoUsers(JSON.toJSONString(collect_username))
;
} else {
// **没有下一个节点,流程已经结束了
business.setProcessDefinitionId(procDefId)
.setProcessInstanceId(processInstance.getProcessInstanceId())
.setActStatus(ActStatus.pass)
.setProposer(sysUser.getUsername())
.setDoneUsers(doneUserList.toJSONString())
;
}
flowMyBusinessService.updateById(business);
//spring容器类名
String serviceImplName = business.getServiceImplName();
FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName);
// 流程处理完后,进行回调业务层
business.setValues(variables);
if (flowCallBackService!=null)flowCallBackService.afterFlowHandle(business);
*/
return Result.OK("流程启动成功");
} catch (Exception e) {
e.printStackTrace();
......@@ -519,85 +433,8 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
}
/*======================todo 启动之后 回调以及关键数据保存======================*/
/**
//业务数据id
String dataId = variables.get("dataId").toString();
//如果保存数据前未调用必调的FlowCommonService.initActBusiness方法,就会有问题
FlowMyBusiness business = flowMyBusinessService.getByDataId(dataId);
//设置数据
FlowNextDto nextFlowNode = flowTaskService.getNextFlowNode(task.getId(), variables);
taskService.complete(task.getId(), variables);
//下一个实例节点 多实例会是一个list,随意取一个即可 数组中定义Key是一致的
//Task task2 = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().singleResult();
List<Task> task2List = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().list();
Task task2 = null;
if(task2List.size()>0) task2 = task2List.get(0);
String doneUsers = business.getDoneUsers();
// 处理过流程的人
JSONArray doneUserList = new JSONArray();
if (StrUtil.isNotBlank(doneUsers)){
doneUserList = JSON.parseArray(doneUsers);
}
if (!doneUserList.contains(sysUser.getUsername())){
doneUserList.add(sysUser.getUsername());
}
if (nextFlowNode!=null){
//**有下一个节点
UserTask nextTask = nextFlowNode.getUserTask();
//能够处理下个节点的候选人
List<SysUser> nextFlowNodeUserList = nextFlowNode.getUserList();
List<String> collect_username = nextFlowNodeUserList.stream().map(SysUser::getUsername).collect(Collectors.toList());
//spring容器类名
String serviceImplName = business.getServiceImplName();
FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName);
List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionKey(), variables);
if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)){
// 删除后重写
for (Task task2One : task2List) {
for (String oldUser : collect_username) {
taskService.deleteCandidateUser(task2One.getId(),oldUser);
}
}
// 业务层有指定候选人,覆盖
for (Task task2One : task2List) {
for (String newUser : beforeParamsCandidateUsernames) {
taskService.addCandidateUser(task2One.getId(),newUser);
}
}
business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames));
}
business.setProcessDefinitionId(procDefId)
.setProcessInstanceId(processInstance.getProcessInstanceId())
.setActStatus(ActStatus.start)
.setProposer(sysUser.getUsername())
.setTaskId(task2.getId())
.setTaskName(nextTask.getName())
.setTaskNameId(nextTask.getId())
.setPriority(nextTask.getPriority())
.setDoneUsers(doneUserList.toJSONString())
.setTodoUsers(JSON.toJSONString(collect_username))
;
} else {
// **没有下一个节点,流程已经结束了
business.setProcessDefinitionId(procDefId)
.setProcessInstanceId(processInstance.getProcessInstanceId())
.setActStatus(ActStatus.pass)
.setProposer(sysUser.getUsername())
.setDoneUsers(doneUserList.toJSONString())
;
}
flowMyBusinessService.updateById(business);
//spring容器类名
String serviceImplName = business.getServiceImplName();
FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName);
// 流程处理完后,进行回调业务层
business.setValues(variables);
if (flowCallBackService!=null)flowCallBackService.afterFlowHandle(business);
*/
return Result.OK(result);
} catch (Exception e) {
e.printStackTrace();
......
......@@ -63,6 +63,7 @@ import org.jeecg.modules.flowable.flow.FlowableUtils;
import org.jeecg.modules.flowable.service.IFlowTaskService;
import org.jeecg.modules.stm.my.entity.MyTask;
import org.jeecg.modules.stm.my.entity.MyTaskFlow;
import org.jeecg.modules.stm.my.service.IMyTaskFlowHisService;
import org.jeecg.modules.stm.my.service.IMyTaskFlowService;
import org.jeecg.modules.stm.my.service.IMyTaskService;
import org.jeecg.modules.system.service.ISysUserService;
......@@ -103,6 +104,8 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
private IMyTaskService myTaskService;
@Autowired
private IMyTaskFlowService myTaskFlowService;
@Autowired
private IMyTaskFlowHisService myTaskFlowHisService;
/**
* 完成任务
......@@ -302,168 +305,6 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
return Result.OK();
/**
Task task = taskService.createTaskQuery().taskId(taskVo.getTaskId()).singleResult();
if (Objects.isNull(task)){
return Result.error("任务不存在");
}
SysUser loginUser = iFlowThirdService.getLoginUser();
if (DelegationState.PENDING.equals(task.getDelegationState())) {
taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.DELEGATE.getType(), taskVo.getComment());
//taskService.resolveTask(taskVo.getTaskId(), taskVo.getValues());
} else {
taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.NORMAL.getType(), taskVo.getComment());
taskService.setAssignee(taskVo.getTaskId(), loginUser.getUsername());
//taskService.complete(taskVo.getTaskId(), taskVo.getValues());
}
*/
/*======================审批通过 回调以及关键数据保存======================*/
/**
//业务数据id
String dataId = taskVo.getDataId();
//如果保存数据前未调用必调的FlowCommonService.initActBusiness方法,就会有问题
FlowMyBusiness business = flowMyBusinessService.getByDataId(dataId);
//spring容器类名
String serviceImplName = business.getServiceImplName();
FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName);
// 流程变量
Map<String, Object> flowBeforeParamsValues = flowCallBackService.flowValuesOfTask(business.getTaskNameId(),taskVo.getValues());
//设置数据
Map<String, Object> values = taskVo.getValues();
if (MapUtil.isNotEmpty(flowBeforeParamsValues)){
// 业务层有设置变量,使用业务层的变量
values = flowBeforeParamsValues;
}
FlowNextDto nextFlowNode = this.getNextFlowNode(task.getId(), values);
//下一个实例节点
if (DelegationState.PENDING.equals(task.getDelegationState())) {
taskService.resolveTask(taskVo.getTaskId(), values);
} else {
taskService.complete(taskVo.getTaskId(), values);
}
List<Task> task2List = taskService.createTaskQuery().processInstanceId(business.getProcessInstanceId()).active().list();
Task task2 = null;
if (CollUtil.isNotEmpty(task2List)){
task2 = task2List.get(0);
}
// 下个节点候选人
List<String> beforeParamsCandidateUsernames = Lists.newArrayList();
if(task2!=null){
beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionKey(),taskVo.getValues());
}
List<String> candidateUsers = taskVo.getCandidateUsers();
if (CollUtil.isNotEmpty(candidateUsers)){
// 前端传入候选人 覆盖
beforeParamsCandidateUsernames = candidateUsers;
}
String doneUsers = business.getDoneUsers();
// 处理过流程的人
JSONArray doneUserList = new JSONArray();
if (StrUtil.isNotBlank(doneUsers)){
doneUserList = JSON.parseArray(doneUsers);
}
if (!doneUserList.contains(loginUser.getUsername())){
doneUserList.add(loginUser.getUsername());
}
if (task2!=null && task.getTaskDefinitionKey().equals(task2.getTaskDefinitionKey())){
// * 当前节点是会签节点,没有走完
business.setActStatus(ActStatus.doing)
.setTaskId(task2.getId())
.setDoneUsers(doneUserList.toJSONString())
;
String todoUsersStr = business.getTodoUsers();
JSONArray todosArr = JSON.parseArray(todoUsersStr);
// 删除后重写
for (Task task2One : task2List) {
for (Object oldUser : todosArr) {
taskService.deleteCandidateUser(task2One.getId(),oldUser.toString());
}
}
// 重写
if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)){
beforeParamsCandidateUsernames.remove(loginUser.getUsername());
// 业务层有指定候选人,覆盖
for (Task task2One : task2List) {
for (String newUser : beforeParamsCandidateUsernames) {
taskService.addCandidateUser(task2One.getId(),newUser);
}
}
business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames));
} else {
todosArr.remove(loginUser.getUsername());
for (Task task2One : task2List) {
for (Object oldUser : todosArr) {
taskService.addCandidateUser(task2One.getId(),oldUser.toString());
}
}
business.setTodoUsers(todosArr.toJSONString());
}
} else {
// * 下一节点是会签节点 或 普通用户节点,逻辑一致
if (nextFlowNode!=null){
//**有下一个节点
UserTask nextTask = nextFlowNode.getUserTask();
//能够处理下个节点的候选人
List<SysUser> nextFlowNodeUserList = nextFlowNode.getUserList();
List<String> collect_username = nextFlowNodeUserList.stream().map(SysUser::getUsername).collect(Collectors.toList());
if (CollUtil.isNotEmpty(candidateUsers)){
// 前端传入候选人
collect_username = candidateUsers;
}
business.setActStatus(ActStatus.doing)
.setTaskId(task2.getId())
.setTaskNameId(nextTask.getId())
.setTaskName(nextTask.getName())
.setPriority(nextTask.getPriority())
.setDoneUsers(doneUserList.toJSONString())
.setTodoUsers(JSON.toJSONString(collect_username))
;
// 删除后重写
for (Task task2One : task2List) {
for (String oldUser : collect_username) {
taskService.deleteCandidateUser(task2One.getId(),oldUser);
}
}
if (CollUtil.isEmpty(candidateUsers)&&CollUtil.isNotEmpty(beforeParamsCandidateUsernames)){
// 前端没有传入候选人 && 业务层有指定候选人,覆盖
for (Task task2One : task2List) {
for (String newUser : beforeParamsCandidateUsernames) {
taskService.addCandidateUser(task2One.getId(),newUser);
}
}
business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames));
} else {
for (Task task2One : task2List) {
for (String oldUser : collect_username) {
taskService.addCandidateUser(task2One.getId(),oldUser);
}
}
}
} else {
// **没有下一个节点,流程已经结束了
business.setActStatus(ActStatus.pass)
.setDoneUsers(doneUserList.toJSONString())
.setTodoUsers("")
.setTaskId("")
.setTaskNameId("")
.setTaskName("")
;
}
}
flowMyBusinessService.updateById(business);
// 流程处理完后,进行回调业务层
business.setValues(values);
if (flowCallBackService!=null)flowCallBackService.afterFlowHandle(business);
return Result.OK();
*/
}
@Override
public Result completeByDateId(FlowTaskVo flowTaskVo){
......@@ -601,223 +442,6 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
} catch (FlowableException e) {
throw new CustomException("无法取消或开始活动");
}
/**
if (taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult().isSuspended()) {
throw new CustomException("任务处于挂起状态");
}
// 当前任务 task
Task task = taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult();
// 获取流程定义信息
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
// 获取所有节点信息
Process process = repositoryService.getBpmnModel(processDefinition.getId()).getProcesses().get(0);
// 获取全部节点列表,包含子节点
Collection<FlowElement> allElements = FlowableUtils.getAllElements(process.getFlowElements(), null);
// 获取当前任务节点元素
FlowElement source = null;
if (allElements != null) {
for (FlowElement flowElement : allElements) {
// 类型为用户节点
if (flowElement.getId().equals(task.getTaskDefinitionKey())) {
// 获取节点信息
source = flowElement;
}
}
}
// 目的获取所有跳转到的节点 targetIds
// 获取当前节点的所有父级用户任务节点
// 深度优先算法思想:延边迭代深入
List<UserTask> parentUserTaskList = FlowableUtils.iteratorFindParentUserTasks(source, null, null);
if (parentUserTaskList == null || parentUserTaskList.size() == 0) {
throw new CustomException("当前节点为初始任务节点,不能驳回");
}
// 获取活动 ID 即节点 Key
List<String> parentUserTaskKeyList = new ArrayList<>();
parentUserTaskList.forEach(item -> parentUserTaskKeyList.add(item.getId()));
// 获取全部历史节点活动实例,即已经走过的节点历史,数据采用开始时间升序
List<HistoricTaskInstance> historicTaskInstanceList = historyService.createHistoricTaskInstanceQuery().processInstanceId(task.getProcessInstanceId()).orderByHistoricTaskInstanceStartTime().asc().list();
// 数据清洗,将回滚导致的脏数据清洗掉
List<String> lastHistoricTaskInstanceList = FlowableUtils.historicTaskInstanceClean(allElements, historicTaskInstanceList);
// 此时历史任务实例为倒序,获取最后走的节点
List<String> targetIds = new ArrayList<>();
// 循环结束标识,遇到当前目标节点的次数
int number = 0;
StringBuilder parentHistoricTaskKey = new StringBuilder();
for (String historicTaskInstanceKey : lastHistoricTaskInstanceList) {
// 当会签时候会出现特殊的,连续都是同一个节点历史数据的情况,这种时候跳过
if (parentHistoricTaskKey.toString().equals(historicTaskInstanceKey)) {
continue;
}
parentHistoricTaskKey = new StringBuilder(historicTaskInstanceKey);
if (historicTaskInstanceKey.equals(task.getTaskDefinitionKey())) {
number++;
}
// 在数据清洗后,历史节点就是唯一一条从起始到当前节点的历史记录,理论上每个点只会出现一次
// 在流程中如果出现循环,那么每次循环中间的点也只会出现一次,再出现就是下次循环
// number == 1,第一次遇到当前节点
// number == 2,第二次遇到,代表最后一次的循环范围
if (number == 2) {
break;
}
// 如果当前历史节点,属于父级的节点,说明最后一次经过了这个点,需要退回这个点
if (parentUserTaskKeyList.contains(historicTaskInstanceKey)) {
targetIds.add(historicTaskInstanceKey);
}
}
// 目的获取所有需要被跳转的节点 currentIds
// 取其中一个父级任务,因为后续要么存在公共网关,要么就是串行公共线路
UserTask oneUserTask = parentUserTaskList.get(0);
// 获取所有正常进行的任务节点 Key,这些任务不能直接使用,需要找出其中需要撤回的任务
List<Task> runTaskList = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId()).list();
List<String> runTaskKeyList = new ArrayList<>();
runTaskList.forEach(item -> runTaskKeyList.add(item.getTaskDefinitionKey()));
// 需驳回任务列表
List<String> currentIds = new ArrayList<>();
// 通过父级网关的出口连线,结合 runTaskList 比对,获取需要撤回的任务
List<UserTask> currentUserTaskList = FlowableUtils.iteratorFindChildUserTasks(oneUserTask, runTaskKeyList, null, null);
currentUserTaskList.forEach(item -> currentIds.add(item.getId()));
// 规定:并行网关之前节点必须需存在唯一用户任务节点,如果出现多个任务节点,则并行网关节点默认为结束节点,原因为不考虑多对多情况
if (targetIds.size() > 1 && currentIds.size() > 1) {
throw new CustomException("任务出现多对多情况,无法撤回");
}
// 循环获取那些需要被撤回的节点的ID,用来设置驳回原因
List<String> currentTaskIds = new ArrayList<>();
currentIds.forEach(currentId -> runTaskList.forEach(runTask -> {
if (currentId.equals(runTask.getTaskDefinitionKey())) {
currentTaskIds.add(runTask.getId());
}
}));
// 设置驳回意见
currentTaskIds.forEach(item -> taskService.addComment(item, task.getProcessInstanceId(), FlowComment.REJECT.getType(), flowTaskVo.getComment()));
SysUser loginUser = iFlowThirdService.getLoginUser();
try {
// 设置处理人
taskService.setAssignee(task.getId(), loginUser.getUsername());
// 如果父级任务多于 1 个,说明当前节点不是并行节点,原因为不考虑多对多情况
if (targetIds.size() > 1) {
// 1 对 多任务跳转,currentIds 当前节点(1),targetIds 跳转到的节点(多)
runtimeService.createChangeActivityStateBuilder()
.processInstanceId(task.getProcessInstanceId()).
moveSingleActivityIdToActivityIds(currentIds.get(0), targetIds).changeState();
}
// 如果父级任务只有一个,因此当前任务可能为网关中的任务
if (targetIds.size() == 1) {
// 1 对 1 或 多 对 1 情况,currentIds 当前要跳转的节点列表(1或多),targetIds.get(0) 跳转到的节点(1)
runtimeService.createChangeActivityStateBuilder()
.processInstanceId(task.getProcessInstanceId())
.moveActivityIdsToSingleActivityId(currentIds, targetIds.get(0)).changeState();
}
*/
/*======================驳回 回调以及关键数据保存======================*/
/**
//业务数据id
String dataId = flowTaskVo.getDataId();
if (dataId==null) return;
//如果保存数据前未调用必调的FlowCommonService.initActBusiness方法,就会有问题
FlowMyBusiness business = flowMyBusinessService.getByDataId(dataId);
// 驳回到了上一个节点等待处理
List<Task> task2List = taskService.createTaskQuery().processInstanceId(business.getProcessInstanceId()).active().list();
Task task2 = task2List.get(0);
//spring容器类名
String serviceImplName = business.getServiceImplName();
FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName);
Map<String, Object> values = flowTaskVo.getValues();
if (values ==null){
values = MapUtil.newHashMap();
values.put("dataId",dataId);
} else {
values.put("dataId",dataId);
}
List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionKey(), values);
//设置数据
String doneUsers = business.getDoneUsers();
// 处理过流程的人
JSONArray doneUserList = new JSONArray();
if (StrUtil.isNotBlank(doneUsers)){
doneUserList = JSON.parseArray(doneUsers);
}
if (!doneUserList.contains(loginUser.getUsername())){
doneUserList.add(loginUser.getUsername());
}
business.setActStatus(ActStatus.reject)
.setTaskId(task2.getId())
.setTaskNameId(task2.getTaskDefinitionKey())
.setTaskName(task2.getName())
.setDoneUsers(doneUserList.toJSONString())
;
FlowElement targetElement = null;
if (allElements != null) {
for (FlowElement flowElement : allElements) {
// 类型为用户节点
if (flowElement.getId().equals(task2.getTaskDefinitionKey())) {
// 获取节点信息
targetElement = flowElement;
}
}
}
if (targetElement!=null){
UserTask targetTask = (UserTask) targetElement;
business.setPriority(targetTask.getPriority());
if (StrUtil.equals(business.getTaskNameId(),ProcessConstants.START_NODE)){
// 开始节点。设置处理人为申请人
business.setTodoUsers(JSON.toJSONString(Lists.newArrayList(business.getProposer())));
taskService.setAssignee(business.getTaskId(),business.getProposer());
} else {
List<SysUser> sysUserFromTask = getSysUserFromTask(targetTask);
List<String> collect_username = sysUserFromTask.stream().map(SysUser::getUsername).collect(Collectors.toList());
// 前端存入的候选人
List<String> candidateUsers = flowTaskVo.getCandidateUsers();
if (CollUtil.isNotEmpty(candidateUsers)){
collect_username = candidateUsers;
}
business.setTodoUsers(JSON.toJSONString(collect_username));
// 删除后重写
for (Task task2One : task2List) {
for (String oldUser : collect_username) {
taskService.deleteCandidateUser(task2One.getId(),oldUser);
}
}
if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)){
if (CollUtil.isNotEmpty(candidateUsers)){
beforeParamsCandidateUsernames = candidateUsers;
}
// 业务层有指定候选人,覆盖
for (Task task2One : task2List) {
for (String newUser : beforeParamsCandidateUsernames) {
taskService.addCandidateUser(task2One.getId(), newUser);
}
}
business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames));
} else {
for (Task task2One : task2List) {
for (String oldUser : collect_username) {
taskService.addCandidateUser(task2One.getId(), oldUser);
}
}
}
}
}
flowMyBusinessService.updateById(business);
// 流程处理完后,进行回调业务层
business.setValues(values);
if (flowCallBackService!=null) flowCallBackService.afterFlowHandle(business);
} catch (FlowableObjectNotFoundException e) {
throw new CustomException("未找到流程实例,流程可能已发生变化");
} catch (FlowableException e) {
throw new CustomException("无法取消或开始活动");
}
*/
}
@Override
public void taskReturnByDataId(FlowTaskVo flowTaskVo){
......
package org.jeecg.modules.stm.my.controller;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.query.QueryRuleEnum;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.stm.my.entity.MyTaskFlowHis;
import org.jeecg.modules.stm.my.service.IMyTaskFlowHisService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: my_task_flow_his
* @Author: jeecg-boot
* @Date: 2026-04-10
* @Version: V1.0
*/
@Tag(name="my_task_flow_his")
@RestController
@RequestMapping("/my/myTaskFlowHis")
@Slf4j
public class MyTaskFlowHisController extends JeecgController<MyTaskFlowHis, IMyTaskFlowHisService> {
@Autowired
private IMyTaskFlowHisService myTaskFlowHisService;
/**
* 分页列表查询
*
* @param myTaskFlowHis
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "my_task_flow_his-分页列表查询")
@Operation(summary="my_task_flow_his-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<MyTaskFlowHis>> queryPageList(MyTaskFlowHis myTaskFlowHis,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<MyTaskFlowHis> queryWrapper = QueryGenerator.initQueryWrapper(myTaskFlowHis, req.getParameterMap());
Page<MyTaskFlowHis> page = new Page<MyTaskFlowHis>(pageNo, pageSize);
IPage<MyTaskFlowHis> pageList = myTaskFlowHisService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param myTaskFlowHis
* @return
*/
@AutoLog(value = "my_task_flow_his-添加")
@Operation(summary="my_task_flow_his-添加")
@RequiresPermissions("my:my_task_flow_his:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody MyTaskFlowHis myTaskFlowHis) {
myTaskFlowHisService.save(myTaskFlowHis);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param myTaskFlowHis
* @return
*/
@AutoLog(value = "my_task_flow_his-编辑")
@Operation(summary="my_task_flow_his-编辑")
@RequiresPermissions("my:my_task_flow_his:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody MyTaskFlowHis myTaskFlowHis) {
myTaskFlowHisService.updateById(myTaskFlowHis);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "my_task_flow_his-通过id删除")
@Operation(summary="my_task_flow_his-通过id删除")
@RequiresPermissions("my:my_task_flow_his:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
myTaskFlowHisService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "my_task_flow_his-批量删除")
@Operation(summary="my_task_flow_his-批量删除")
@RequiresPermissions("my:my_task_flow_his:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.myTaskFlowHisService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "my_task_flow_his-通过id查询")
@Operation(summary="my_task_flow_his-通过id查询")
@GetMapping(value = "/queryById")
public Result<MyTaskFlowHis> queryById(@RequestParam(name="id",required=true) String id) {
MyTaskFlowHis myTaskFlowHis = myTaskFlowHisService.getById(id);
if(myTaskFlowHis==null) {
return Result.error("未找到对应数据");
}
return Result.OK(myTaskFlowHis);
}
/**
* 导出excel
*
* @param request
* @param myTaskFlowHis
*/
@RequiresPermissions("my:my_task_flow_his:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MyTaskFlowHis myTaskFlowHis) {
return super.exportXls(request, myTaskFlowHis, MyTaskFlowHis.class, "my_task_flow_his");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequiresPermissions("my:my_task_flow_his:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, MyTaskFlowHis.class);
}
}
package org.jeecg.modules.stm.my.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import org.jeecg.common.constant.ProvinceCityArea;
import org.jeecg.common.util.SpringContextUtils;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: my_task_flow_his
* @Author: jeecg-boot
* @Date: 2026-04-10
* @Version: V1.0
*/
@Data
@TableName("my_task_flow_his")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description="my_task_flow_his")
public class MyTaskFlowHis implements Serializable {
private static final long serialVersionUID = 1L;
/**id*/
@TableId(type = IdType.AUTO)
@Schema(description = "id")
private java.lang.Integer id;
/**表单的表名ID*/
@Excel(name = "表单的表名ID", width = 15)
@Schema(description = "表单的表名ID")
private java.lang.String formTableName;
/**业务主表ID*/
@Excel(name = "业务主表ID", width = 15)
@Schema(description = "业务主表ID")
private java.lang.String targetId;
/**部署ID*/
@Excel(name = "部署ID", width = 15)
@Schema(description = "部署ID")
private java.lang.String deployId;
/**任务ID*/
@Excel(name = "任务ID", width = 15)
@Schema(description = "任务ID")
private java.lang.String taskId;
/**实例ID*/
@Excel(name = "实例ID", width = 15)
@Schema(description = "实例ID")
private java.lang.String procInsId;
/**执行ID*/
@Excel(name = "执行ID", width = 15)
@Schema(description = "执行ID")
private java.lang.String executionId;
/**流程定义ID*/
@Excel(name = "流程定义ID", width = 15)
@Schema(description = "流程定义ID")
private java.lang.String procDefId;
/**代办人*/
@Excel(name = "代办人", width = 15)
@Schema(description = "代办人")
private java.lang.String uid;
/**代办角色*/
@Excel(name = "代办角色", width = 15)
@Schema(description = "代办角色")
private java.lang.String roleid;
/**节点ID*/
@Excel(name = "节点ID", width = 15)
@Schema(description = "节点ID")
private java.lang.String taskDefinitionKey;
/**操作时间*/
@Excel(name = "操作时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "操作时间")
private java.util.Date optionTime;
/**操作人*/
@Excel(name = "操作人", width = 15)
@Schema(description = "操作人")
private java.lang.String optionId;
/**操作类型*/
@Excel(name = "操作类型", width = 15)
@Schema(description = "操作类型")
private java.lang.String optionType;
/**节点类型*/
@Excel(name = "节点类型", width = 15)
@Schema(description = "节点类型")
private java.lang.String taskType;
}
package org.jeecg.modules.stm.my.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.stm.my.entity.MyTaskFlowHis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: my_task_flow_his
* @Author: jeecg-boot
* @Date: 2026-04-10
* @Version: V1.0
*/
public interface MyTaskFlowHisMapper extends BaseMapper<MyTaskFlowHis> {
}
package org.jeecg.modules.stm.my.service;
import org.jeecg.modules.stm.my.entity.MyTaskFlowHis;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: my_task_flow_his
* @Author: jeecg-boot
* @Date: 2026-04-10
* @Version: V1.0
*/
public interface IMyTaskFlowHisService extends IService<MyTaskFlowHis> {
}
package org.jeecg.modules.stm.my.service.impl;
import org.jeecg.modules.stm.my.entity.MyTaskFlowHis;
import org.jeecg.modules.stm.my.mapper.MyTaskFlowHisMapper;
import org.jeecg.modules.stm.my.service.IMyTaskFlowHisService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: my_task_flow_his
* @Author: jeecg-boot
* @Date: 2026-04-10
* @Version: V1.0
*/
@Service
public class MyTaskFlowHisServiceImpl extends ServiceImpl<MyTaskFlowHisMapper, MyTaskFlowHis> implements IMyTaskFlowHisService {
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.stm.my.mapper.MyTaskFlowHisMapper">
</mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论