diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/handle/PassHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/handle/PassHandle.java new file mode 100644 index 0000000..e5fe92e --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/handle/PassHandle.java @@ -0,0 +1,73 @@ +package com.ningdatech.pmapi.todocenter.handle; + +import cn.hutool.core.collection.CollUtil; +import com.ningdatech.pmapi.todocenter.model.vo.ProcessProgressDetailVo; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.flowable.engine.RuntimeService; +import org.flowable.engine.runtime.ActivityInstance; +import org.springframework.stereotype.Component; +import java.util.List; + +/** + * @Classname PassHandle + * @Description + * @Date 2023/5/5 14:46 + * @Author PoffyZhang + */ +@Component +@Slf4j +@AllArgsConstructor +public class PassHandle { + + private final RuntimeService runtimeService; + + /** + * 判断节点类型 + * @param instanceId + * @param employeeCode + * @return + */ + public void checkCanPassOrSeal(String instanceId,String taskId,String employeeCode, ProcessProgressDetailVo res) { + + List activities = runtimeService.createActivityInstanceQuery() + .taskAssignee(employeeCode) + .processInstanceId(instanceId) + .unfinished() + .orderByActivityInstanceStartTime() + .asc() + .list(); + + if(CollUtil.isEmpty(activities)){ + res.setCanPass(Boolean.FALSE); + res.setCanReject(Boolean.FALSE); + res.setCanSeal(Boolean.FALSE); + return; + } + + for(ActivityInstance activity : activities){ + if(StringUtils.isNotBlank(taskId)){ + if(taskId.equals(activity.getTaskId())){ + if(StringUtils.isNotBlank(activity.getActivityId())){ + res.setCanReject(Boolean.TRUE); + if(activity.getActivityId().startsWith("node")){ + res.setCanPass(Boolean.TRUE); + }else if(activity.getActivityId().startsWith("seal")){ + res.setCanSeal(Boolean.TRUE); + } + } + } + } + + if(StringUtils.isNotBlank(activity.getActivityId())){ + res.setCanReject(Boolean.TRUE); + if(activity.getActivityId().startsWith("node")){ + res.setCanPass(Boolean.TRUE); + }else if(activity.getActivityId().startsWith("seal")){ + res.setCanSeal(Boolean.TRUE); + } + } + } + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java index db6814d..696b06c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java @@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletResponse; import cn.hutool.core.util.ObjectUtil; import com.ningdatech.pmapi.projectdeclared.manage.DeclaredProjectManage; import com.ningdatech.pmapi.todocenter.constant.TodoCenterContant; +import com.ningdatech.pmapi.todocenter.handle.PassHandle; import com.ningdatech.pmapi.todocenter.handle.WithDrawHandle; import com.ningdatech.pmapi.todocenter.model.vo.TodoNumVO; import com.wflow.workflow.enums.ProcessHandlerEnum; @@ -141,6 +142,8 @@ public class TodoCenterManage { private final WithDrawHandle withDrawHandle; + private final PassHandle passHandle; + /** * 待办中心待我处理项目列表查询 * @@ -462,6 +465,7 @@ public class TodoCenterManage { * @return 流程进度及表单详情 */ public ProcessProgressDetailVo getProcessDetail(ProcessDetailReq request) { + String employeeCode = LoginUserUtil.loginUserDetail().getEmployeeCode(); String instanceId = request.getInstanceId(); String nodeId = request.getNodeId(); Long projectId = request.getProjectId(); @@ -480,6 +484,7 @@ public class TodoCenterManage { res.setStatus(progressInstanceDetail.getStatus()); res.setProjectId(projectId); res.setCanWithdraw(withDrawHandle.checkCanWithdraw(instanceId,progressInstanceDetail)); + passHandle.checkCanPassOrSeal(request.getInstanceId(),request.getTaskId(),employeeCode,res); return res; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/req/ProcessDetailReq.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/req/ProcessDetailReq.java index 8134e47..a3aeece 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/req/ProcessDetailReq.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/req/ProcessDetailReq.java @@ -27,4 +27,7 @@ public class ProcessDetailReq { @ApiModelProperty("项目ID") private Long projectId; + + @ApiModelProperty("任务ID") + private String taskId; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/vo/ProcessProgressDetailVo.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/vo/ProcessProgressDetailVo.java index 3387b6c..a03d802 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/vo/ProcessProgressDetailVo.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/vo/ProcessProgressDetailVo.java @@ -1,6 +1,7 @@ package com.ningdatech.pmapi.todocenter.model.vo; +import com.wflow.workflow.bean.process.enums.NodeTypeEnum; import com.wflow.workflow.bean.vo.ProcessProgressVo; import lombok.AllArgsConstructor; @@ -33,5 +34,23 @@ public class ProcessProgressDetailVo { */ private Long projectId; + /** + * 能否撤回 + */ private Boolean canWithdraw = Boolean.FALSE; + + /** + * 能否通过 + */ + private Boolean canPass = Boolean.FALSE; + + /** + * 能否盖章 + */ + private Boolean canSeal = Boolean.FALSE; + + /** + * 能否驳回 + */ + private Boolean canReject = Boolean.FALSE; }