Procházet zdrojové kódy

流程处理-撤回

tags/24080901
CMM před 1 rokem
rodič
revize
73fa845c6d
3 změnil soubory, kde provedl 162 přidání a 147 odebrání
  1. +0
    -35
      pmapi/src/main/java/com/ningdatech/pmapi/common/statemachine/builder/ProjectDeclareStateMachineBuilder.java
  2. +0
    -28
      pmapi/src/main/java/com/ningdatech/pmapi/common/statemachine/event/ProjectStatusChangeEvent.java
  3. +162
    -84
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java

+ 0
- 35
pmapi/src/main/java/com/ningdatech/pmapi/common/statemachine/builder/ProjectDeclareStateMachineBuilder.java Zobrazit soubor

@@ -92,11 +92,6 @@ public class ProjectDeclareStateMachineBuilder {
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),projectDeclareAction.new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,projectDeclareAction.new ProjectDeclareChoiceAction()).and()
// 待预审撤回,从待预审到单位内部审核中
.withExternal()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.event(ProjectStatusChangeEvent.PENDING_PREQUALIFICATION_WITHDRAW).and()
// 省级部门联审通过,从省级部门联审中到预审中
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
@@ -157,21 +152,11 @@ public class ProjectDeclareStateMachineBuilder {
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.BE_SUSPENDED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND).and()
// 年度计划中撤回,从年度计划中到部门联审中
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.event(ProjectStatusChangeEvent.IN_THE_ANNUAL_PLAN_WITHDRAW).and()
// 方案待申报申报方案,从方案待申报到方案评审中
.withExternal()
.source(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.DECLARE_PLAN).and()
// 方案待申报撤回,从方案待申报到年度计划中
.withExternal()
.source(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.target(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.event(ProjectStatusChangeEvent.PLAN_TO_DECLARE_WITHDRAW).and()
// 方案评审通过,从方案评审中到待立项批复
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
@@ -192,41 +177,21 @@ public class ProjectDeclareStateMachineBuilder {
.source(ProjectStatusEnum.TO_BE_APPROVED)
.target(ProjectStatusEnum.TO_BE_PURCHASED)
.event(ProjectStatusChangeEvent.PROJECT_APPROVAL).and()
// 待立项批复撤回,从待立项批复到方案评审中
.withExternal()
.source(ProjectStatusEnum.TO_BE_APPROVED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.TO_BE_APPROVED_WITHDRAW).and()
// 待采购采购备案,从待采购到建设中
.withExternal()
.source(ProjectStatusEnum.TO_BE_PURCHASED)
.target(ProjectStatusEnum.UNDER_CONSTRUCTION)
.event(ProjectStatusChangeEvent.PURCHASE_PUT_ON_RECORD).and()
// 待采购撤回,从待采购到待立项批复
.withExternal()
.source(ProjectStatusEnum.TO_BE_PURCHASED)
.target(ProjectStatusEnum.TO_BE_APPROVED)
.event(ProjectStatusChangeEvent.TO_BE_PURCHASED_WITHDRAW).and()
// 建设中初验备案,从建设中到待终验
.withExternal()
.source(ProjectStatusEnum.UNDER_CONSTRUCTION)
.target(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.event(ProjectStatusChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD).and()
// 建设中撤回,从建设中到待采购
.withExternal()
.source(ProjectStatusEnum.UNDER_CONSTRUCTION)
.target(ProjectStatusEnum.TO_BE_PURCHASED)
.event(ProjectStatusChangeEvent.UNDER_CONSTRUCTION_WITHDRAW).and()
// 待终验终验申请,从待终验到终验审核中
.withExternal()
.source(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_APPLICATION).and()
// 待终验撤回,从待终验到建设中
.withExternal()
.source(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.target(ProjectStatusEnum.UNDER_CONSTRUCTION)
.event(ProjectStatusChangeEvent.TO_BE_FINALLY_INSPECTED_WITHDRAW).and()
// 终审审核通过,从终审审核中到已归档
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)


+ 0
- 28
pmapi/src/main/java/com/ningdatech/pmapi/common/statemachine/event/ProjectStatusChangeEvent.java Zobrazit soubor

@@ -114,10 +114,6 @@ public enum ProjectStatusChangeEvent {
*/
UNDER_INTERNAL_WITHDRAW(null, null, 10001),
/**
* 待预审时被撤回(项目状态进入:单位内部审核中)
*/
PENDING_PREQUALIFICATION_WITHDRAW(null, null, 10003),
/**
* 省级部门联审中时被撤回(项目状态进入:待预审)
*/
JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW(null, null, 10004),
@@ -130,34 +126,10 @@ public enum ProjectStatusChangeEvent {
*/
DEPARTMENT_JOINT_REVIEW_WITHDRAW(null, null, 10008),
/**
* 年度计划中时被撤回(项目状态进入:部门联审中)
*/
IN_THE_ANNUAL_PLAN_WITHDRAW(null, null, 10010),
/**
* 方案待申报时被撤回(项目状态进入:年度计划中)
*/
PLAN_TO_DECLARE_WITHDRAW(null, null, 10016),
/**
* 方案评审中时被撤回(项目状态进入:方案待申报)
*/
SCHEME_UNDER_REVIEW_WITHDRAW(null, null, 10012),
/**
* 待立项批复时被撤回(项目状态进入:方案评审中)
*/
TO_BE_APPROVED_WITHDRAW(null, null, 10014),
/**
* 待采购时被撤回(项目状态进入:待立项批复)
*/
TO_BE_PURCHASED_WITHDRAW(null, null, 20001),
/**
* 建设中时被撤回(项目状态进入:待采购)
*/
UNDER_CONSTRUCTION_WITHDRAW(null, null, 20002),
/**
* 待终验时被撤回(项目状态进入:建设中)
*/
TO_BE_FINALLY_INSPECTED_WITHDRAW(null, null, 20003),
/**
* 终验审核中时被撤回(项目状态进入:待终验)
*/
FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW(null, null, 20004);


+ 162
- 84
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java Zobrazit soubor

@@ -24,6 +24,7 @@ import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter;
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent;
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils;
import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.todocenter.bean.entity.ProcessComment;
@@ -42,7 +43,6 @@ import com.ningdatech.pmapi.todocenter.zwdd.model.MessageContent;
import com.ningdatech.pmapi.todocenter.zwdd.model.MessageText;
import com.ningdatech.pmapi.user.entity.UserInfo;
import com.ningdatech.pmapi.user.service.IUserInfoService;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import com.wflow.bean.do_.UserDo;
import com.wflow.bean.entity.WflowCcTasks;
import com.wflow.bean.entity.WflowModelHistorys;
@@ -78,6 +78,7 @@ import org.flowable.engine.history.HistoricProcessInstanceQuery;
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
import org.flowable.engine.runtime.ActivityInstance;
import org.flowable.engine.runtime.Execution;
import org.flowable.engine.task.Comment;
import org.flowable.task.api.Task;
import org.flowable.task.api.TaskInfo;
import org.flowable.task.api.TaskQuery;
@@ -110,7 +111,6 @@ public class TodoCenterManage {
private final RepositoryService repositoryService;
private final RuntimeService runtimeService;
private final UserDeptOrLeaderService userDeptOrLeaderService;
private final ProcessInstanceService processService;
private final FormService formService;
private final ManagementService managementService;
private final HistoryService historyService;
@@ -137,8 +137,9 @@ public class TodoCenterManage {
// 获取登录用户ID
// long userId = LoginUserUtil.getUserId();

Long userId = 381496L;
// Long userId = 6418616L;
// Long userId = 381496L;
Long userId = 6418616L;
// Long userId = 61769799L;
TaskQuery taskQuery = taskService.createTaskQuery();
taskQuery.active().taskCandidateOrAssigned(String.valueOf(userId)).orderByTaskCreateTime().desc();
List<Task> taskList = taskQuery.list();
@@ -300,10 +301,16 @@ public class TodoCenterManage {

// Long userId = LoginUserUtil.getUserId();

// Long userId = 381496L;
Long userId = 381496L;

Long userId = 6418616L;
// Long userId = 6418616L;

// 若进行的是撤回操作(流程发起人和当前流程审核人的前一个审核人操作)
if (param.getAction().equals(ProcessHandlerEnum.WITHDRAW)){
HistoricTaskInstance handledTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(param.getTaskId()).singleResult();
doWithDrawProcess(handledTaskInstance, userId);
return;
}
Task task = taskService.createTaskQuery().taskId(param.getTaskId()).active().singleResult();
HashMap<String, Object> formData = new HashMap<>(32);
if (Objects.isNull(task)) {
@@ -330,10 +337,6 @@ public class TodoCenterManage {
formService.updateInstanceFormData(param.getInstanceId(), formData);
doBackTask(task, userId, param);
break;
// 撤回
case WITHDRAW:
doWithDrawProcess(task, userId);
break;
default:
throw new IllegalStateException("Unexpected value: " + param.getAction());
}
@@ -354,33 +357,38 @@ public class TodoCenterManage {

Map<String, Object> var = new HashMap<>(16);
var.put("approve_" + task.getId(), param.getAction());

// 保存审核意见
if (hasComment(param.getAuditInfo())) {
// 执行自定义的保存评论的功能
managementService.executeCommand(new SaveCommentCmd(param.getTaskId(), param.getInstanceId(),
String.valueOf(userId), JSONObject.toJSONString(param.getAuditInfo())));
}

// TODO 中止流程并使项目进入对应状态,给项目创建人、流程发起人发送浙政钉工作通知:【项目名称】的【流程名称】被驳回,请及时处理。
// 获取流程定义
Process process = ProcessDefinitionUtil.getProcess(task.getProcessDefinitionId());

// 获取bpm对象
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
// 获取根节点即流程发起节点
FlowNode rootNode = (FlowNode) process.getFlowElement("root", true);
FlowNode rootNode = (FlowNode) bpmnModel.getFlowElement("root");

// TODO 中止流程并使项目进入对应状态,给项目创建人、流程发起人发送浙政钉工作通知:【项目名称】的【流程名称】被驳回,请及时处理。
sendWorkNoticeToStartUser(task, projectName, rootNode);
// sendWorkNoticeToStartUser(task, projectName, rootNode);

// 更新项目状态
updateRejectProjectStatus(task);
updateRejectProjectStatus(userId,declaredProject);
taskService.complete(param.getTaskId(), var);
}

/**
* 当为驳回操作时,更新项目表中的项目状态
*
* @param task 当前任务
* @param userId
* @param declaredProject
* @return void
* @author CMM
* @since 2023/02/08
*/
private void updateRejectProjectStatus(Task task) {
// 获取当前登录用户
Long userId = LoginUserUtil.getUserId();
// 获取当前申报项目
Project declaredProject = projectService
.getOne(Wrappers.lambdaQuery(Project.class).eq(Project::getInstCode, task.getProcessInstanceId()));
private void updateRejectProjectStatus(Long userId, Project declaredProject) {
// 获取当前流程项目状态
Integer projectStatusSecond = declaredProject.getStatus();
// 根据当前状态获取对应的通过事件
@@ -432,7 +440,7 @@ public class TodoCenterManage {
Project declaredProject = projectService
.getOne(Wrappers.lambdaQuery(Project.class).eq(Project::getInstCode, task.getProcessInstanceId()));
// 更新项目状态到下一个状态
updatePassProjectStatus(task, userId, declaredProject);
updatePassProjectStatus(userId, declaredProject);
taskService.complete(param.getTaskId(), var);
}

@@ -458,19 +466,48 @@ public class TodoCenterManage {
managementService.executeCommand(new SaveCommentCmd(param.getTaskId(), param.getInstanceId(),
String.valueOf(userId), JSONObject.toJSONString(param.getAuditInfo())));
}
updatePassProjectStatus(task, userId, declaredProject);
taskService.complete(param.getTaskId(), var);

// 获取bpm对象
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
// 传节点定义key 获取当前节点
FlowNode currentNode = (FlowNode) bpmnModel.getFlowElement(task.getTaskDefinitionKey());


// TODO 若当前流程是预审流程,需要在提交预审申报的时候,调用状态机判断申报后的项目状态,
// 若是省级部门联审中,要对接外部接口,获取省级部门联审的结果,更新项目状态(预审申报提交的时候处理)

// 需要先通过后才能有下一个节点的信息
taskService.complete(param.getTaskId(), var);

// 获取流程下一个节点的审核用户ID
String nextUserId = getNextUserId(currentNode, processInstanceId);
// 若有下一个审核人,向其发送浙政钉工作通知:标题:审核任务 内容:【单位名称】的【项目名称】需要您审核。
// 获取当前流程状态
Integer status = declaredProject.getStatus();
// 若当前登录用户是最后一个审批人
HistoricProcessInstance instance = historyService
.createHistoricProcessInstanceQuery()
.processInstanceId(processInstanceId)
.singleResult();
if (HisProInsEndActId.END.equals(instance.getEndActivityId())) {
switch (Objects.requireNonNull(ProjectStatusEnum.getValue(status))) {
// 当前项目状态是单位内部审核中
case UNDER_INTERNAL_AUDIT:
// 当前项目状态是预审中
case PRE_APPLYING:
// 当前项目状态是部门联审中
case DEPARTMENT_JOINT_REVIEW:
// 当前项目状态是方案评审中
case SCHEME_UNDER_REVIEW:
// 当前项目状态是终验审核中
case FINAL_ACCEPTANCE_IS_UNDER_REVIEW:
updatePassProjectStatus(userId, declaredProject);
break;
default:
throw new IllegalStateException("Unexpected value: " + status);
}
}
// 若有下一个审核人(当前节点的用户),向其发送浙政钉工作通知:标题:审核任务 内容:【单位名称】的【项目名称】需要您审核。
if (Objects.nonNull(nextUserId)) {
UserInfo auditUserInfo = userInfoService.getById(Long.valueOf(nextUserId));
// UserInfo auditUserInfo = userInfoService.getById(Long.valueOf(nextUserId));
// TODO 获取浙政钉用户dingKey,向其发送浙政钉工作通知
String msg = String.format(PASS_MSG_TEMPLATE, null, projectName);
// sendWorkNotice(auditUserInfo,msg);
@@ -478,22 +515,20 @@ public class TodoCenterManage {
// 若没有,向发起人发送浙政钉工作通知:【项目名称】已通过【流程名称】,请及时开始下一步操作。
// TODO 向其发送浙政钉工作通知 获取根节点的孩子节点(即发起人节点),向其发送浙政钉工作通知
// 获取根节点即流程发起节点
FlowNode rootNode = (FlowNode) bpmnModel.getFlowElement("root");
// FlowNode rootNode = (FlowNode) bpmnModel.getFlowElement("root");
// sendWorkNoticeToStartUser(task, projectName, rootNode);
}
}

/**
* 当为通过操作时,更新项目表中项目状态
*
* @param task 当前任务
* @param userId
* @param declaredProject
* @return void
* @author CMM
* @since 2023/02/08
*/
private void updatePassProjectStatus(Task task, Long userId, Project declaredProject) {
private void updatePassProjectStatus(Long userId, Project declaredProject) {
// 获取当前流程项目状态
Integer projectStatusSecond = declaredProject.getStatus();
// 根据当前状态获取对应的通过事件
@@ -520,7 +555,7 @@ public class TodoCenterManage {
* @since 2023/02/03
*/
private void sendWorkNoticeToStartUser(Task task, String projectName, FlowNode rootNode) {
String startUserId = getRootUserId(rootNode);
String startUserId = getRootUserId(rootNode, task.getProcessInstanceId());
UserInfo startUserInfo = userInfoService.getById(Long.valueOf(startUserId));
// 从历史表获取最新版本的流程
WflowModels wflowModels = getLastWflowModels(task);
@@ -530,14 +565,15 @@ public class TodoCenterManage {
}

/**
* 获取流程发起节点的浙政钉用户ID
* 获取流程发起节点的用户ID
*
* @param rootNode 根节点
* @param processInstanceId
* @return java.lang.String
* @author CMM
* @since 2023/02/02
*/
private String getRootUserId(FlowNode rootNode) {
private String getRootUserId(FlowNode rootNode, String processInstanceId) {
String rootUserId = null;
// 输出连线
List<SequenceFlow> outgoingFlows = rootNode.getOutgoingFlows();
@@ -548,8 +584,11 @@ public class TodoCenterManage {
// TODO 若要会签需判断候选人
// 发起事件
if (targetFlowElement instanceof StartEvent) {
UserTask userTask = (UserTask) targetFlowElement;
rootUserId = userTask.getAssignee();
String actId = targetFlowElement.getId();
ActivityInstance activityInstance = runtimeService.createActivityInstanceQuery()
.processInstanceId(processInstanceId).activityId(actId).singleResult();
String executionId = activityInstance.getExecutionId();
rootUserId = runtimeService.getVariable(executionId, "initiator", String.class);
break;
}
}
@@ -560,7 +599,7 @@ public class TodoCenterManage {
/**
* 获取当前节点的下一个节点的审核用户ID
*
* @param currentNode 当前节点
* @param currentNode 当前节点
* @param processInstanceId
* @return java.lang.String 下一个节点的浙政钉用户ID
* @author CMM
@@ -646,70 +685,106 @@ public class TodoCenterManage {
/**
* 撤销流程处理
*
* @param task 当前任务
* @param userId
* @param handledTaskInstance 已处理的历史任务实例
* @param userId 当前登录用户ID
*/
private void doWithDrawProcess(Task task, Long userId) {
// 获取流程定义
Process process = ProcessDefinitionUtil.getProcess(task.getProcessDefinitionId());
// 获取当前运行流程的发起人节点信息
FlowNode rootNode = (FlowNode) process.getFlowElement("root", true);
// 获取当前节点
FlowNode currentNode = (FlowNode) process.getFlowElement(task.getTaskDefinitionKey(), true);
String rootUserId = getRootUserId(rootNode);
private void doWithDrawProcess(HistoricTaskInstance handledTaskInstance, Long userId) {
String processInstanceId = handledTaskInstance.getProcessInstanceId();
// 获取当前流程实例待审核任务信息
Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
// 获取当前流程实例信息
HistoricProcessInstance historicProcessInstance = historyService
.createHistoricProcessInstanceQuery()
.processInstanceId(processInstanceId)
.singleResult();
// 流程发起人ID
String startUserId = historicProcessInstance.getStartUserId();
// 获取当前申报项目
Project declaredProject = projectService.getOne(Wrappers.lambdaQuery(Project.class)
.eq(Project::getInstCode, processInstanceId));
String projectName = declaredProject.getProjectName();

// 获取bpm对象
BpmnModel bpmnModel = repositoryService.getBpmnModel(handledTaskInstance.getProcessDefinitionId());
// 传节点定义key 获取传入节点(撤回操作人在流程配置中所在的节点)
FlowNode handledNode = (FlowNode) bpmnModel.getFlowElement(handledTaskInstance.getTaskDefinitionKey());

// 获取当前流程状态
Integer status = declaredProject.getStatus();

// 判断当前登录用户是否是流程发起人
if (rootUserId.equals(String.valueOf(userId))) {
if (startUserId.equals(String.valueOf(userId))) {
// TODO 若是流程发起人点击撤回,项目回到上一个状态,并删除当前审核人对应的待办记录
updateWithdrawProjectStatus(task, userId);
// 若是流程发起人点击撤回,项目回到上一个状态,需调用状态机更新项目状态
switch (Objects.requireNonNull(ProjectStatusEnum.getValue(status))) {
// 当前项目状态是单位内部审核中
case UNDER_INTERNAL_AUDIT:
// 当前项目状态是预审中
case PRE_APPLYING:
// 当前项目状态是部门联审中
case DEPARTMENT_JOINT_REVIEW:
// 当前项目状态是方案评审中
case SCHEME_UNDER_REVIEW:
// 当前项目状态是终验审核中
case FINAL_ACCEPTANCE_IS_UNDER_REVIEW:
updateWithdrawProjectStatus(userId, declaredProject);
break;
default:
throw new IllegalStateException("Unexpected value: " + status);
}
List<Execution> executions = runtimeService.createExecutionQuery()
.processInstanceId(task.getProcessInstanceId()).onlyChildExecutions().list();
.processInstanceId(handledTaskInstance.getProcessInstanceId()).onlyChildExecutions().list();
// 强制流程指向撤回
runtimeService.createChangeActivityStateBuilder().processInstanceId(task.getProcessInstanceId())
runtimeService.createChangeActivityStateBuilder()
.processInstanceId(task.getProcessInstanceId())
.moveActivityIdTo(task.getTaskDefinitionKey(), HisProInsEndActId.WITHDRAW)
.moveExecutionsToSingleActivityId(
executions.stream().map(Execution::getId).collect(Collectors.toList()), HisProInsEndActId.WITHDRAW)
.moveExecutionsToSingleActivityId(executions.stream()
.map(Execution::getId)
.collect(Collectors.toList()), HisProInsEndActId.WITHDRAW)
.changeState();
} else {
FlowElementsContainer parentContainer = currentNode.getParentContainer();
for (FlowElement flowElement : parentContainer.getFlowElements()) {
UserTask beforeUserTask = (UserTask) flowElement;
if (beforeUserTask.getAssignee().equals(String.valueOf(userId))) {
// TODO 若是前一个审核人点击撤回,在审核记录中移除自己提交过的审核意见、
// 待我处理中移除当前审核人的待办记录、
// 待我处理中增加自己的待办记录、
// 我已处理中去掉自己之前处理的记录
// 更新项目状态
updateWithdrawProjectStatus(task, userId);
HistoricTaskInstance beforeTaskInstance =
historyService.createHistoricTaskInstanceQuery().taskId(beforeUserTask.getId()).singleResult();
List<Execution> executions = runtimeService.createExecutionQuery()
.processInstanceId(beforeTaskInstance.getProcessInstanceId()).onlyChildExecutions().list();
// 强制流程指向撤回
runtimeService.createChangeActivityStateBuilder().processInstanceId(task.getProcessInstanceId())
.moveActivityIdTo(flowElement.getId(), HisProInsEndActId.WITHDRAW)
.moveExecutionsToSingleActivityId(
executions.stream().map(Execution::getId).collect(Collectors.toList()),
HisProInsEndActId.WITHDRAW)
.changeState();
break;
}
// TODO 获取前一个审核节点审核人信息

// TODO 判断前一个审核人的部门和当前登录用户的部门是否是同一个,如果是同一个才可以撤回,否则抛出异常
Boolean orgFlag = true;
if (orgFlag){
// 注意:是前一个审核人,说明此时仍在一个审核流程中,项目状态不需要改变
// 在审核记录中移除前一个审核人提交过的审核意见
Comment comment = taskService.getProcessInstanceComments(processInstanceId).stream()
.filter(c -> c.getTaskId().equals(handledTaskInstance.getId()))
.findFirst()
.get();
taskService.deleteComment(comment.getId());
// 我已处理中去掉自己之前处理的记录
String taskInstanceId = handledTaskInstance.getId();
historyService.deleteHistoricTaskInstance(taskInstanceId);

List<Execution> executions = runtimeService.createExecutionQuery()
.processInstanceId(handledTaskInstance.getProcessInstanceId()).onlyChildExecutions().list();
// 强制流程指向前一个审核人节点
runtimeService.createChangeActivityStateBuilder()
.processInstanceId(task.getProcessInstanceId())
.moveActivityIdsToSingleActivityId(executions.stream()
.map(Execution::getActivityId)
.collect(Collectors.toList()), handledNode.getId())
.changeState();
}else {
throw new BizException("下一个审核人和您不是同一个部门,无法撤回!");
}

}
}


/**
* 当为撤回操作时,更新项目表中的项目状态为前一个状态
*
* @param task 当前任务
* @param userId
* @param declaredProject
* @return void
* @author CMM
* @since 2023/02/08
*/
private void updateWithdrawProjectStatus(Task task, Long userId) {
// 获取当前申报项目
Project declaredProject = projectService
.getOne(Wrappers.lambdaQuery(Project.class).eq(Project::getInstCode, task.getProcessInstanceId()));
private void updateWithdrawProjectStatus(Long userId, Project declaredProject) {
// 获取当前流程项目状态
Integer projectStatusSecond = declaredProject.getStatus();
// 根据当前状态获取对应的撤回事件
@@ -923,7 +998,10 @@ public class TodoCenterManage {
public PageVo<ResToBeProcessedDTO> queryHandledProjectList(ReqToBeProcessedDTO param) {
// 获取登录用户ID
// long userId = LoginUserUtil.getUserId();

Long userId = 381496L;
// Long userId = 6418616L;
// Long userId = 61769799L;

// 自定义sql查询所有已办的任务实例
String nativeSql = "SELECT aht.* FROM ACT_HI_TASKINST AS aht \n"


Načítá se…
Zrušit
Uložit