Browse Source

待办中心待我处理处理功能

tags/24080901
CMM 2 years ago
parent
commit
4cefc73f61
10 changed files with 156 additions and 157 deletions
  1. +0
    -62
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/entity/ProcessTask.java
  2. +68
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/entity/ProgressNode.java
  3. +2
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/vo/ProcessProgressDetailVo.java
  4. +25
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/constant/HisProInsEndActId.java
  5. +3
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java
  6. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/enums/ProcessStatusEnum.java
  7. +1
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/extension/cmd/BackToHisApprovalNodeCmd.java
  8. +50
    -84
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java
  9. +5
    -5
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqProcessHandlerDTO.java
  10. +1
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/res/ResToBeProcessedDTO.java

+ 0
- 62
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/entity/ProcessTask.java View File

@@ -1,62 +0,0 @@
package com.ningdatech.pmapi.todocenter.bean.entity;

import com.wflow.workflow.bean.process.OrgUser;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
* 流程任务实体
*
* @author CMM
* @since 2023/01/30 16:57
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ProcessTask {
//任务ID
private String taskId;
//任务定义key
private String taskDefKey;
//流程定义ID
private String processDefId;
//流程执行ID
private String executionId;
//任务名称
private String taskName;
//任务归属节点
private String nodeId;

//任务处理结果
private String taskResult;

//部署ID
private String deployId;
//流程定义名称
private String processDefName;
//版本
private Integer version;
//实例ID
private String instanceId;


//流程发起人
private String ownerId;
private OrgUser owner;
//流程发起人部门ID
private String ownerDeptId;
//流程发起人部门名称
private String ownerDeptName;

//流程实例创建时间
private Date createTime;
//task创建时间
private Date taskCreateTime;
//task完成时间
private Date taskEndTime;
}

+ 68
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/entity/ProgressNode.java View File

@@ -0,0 +1,68 @@
package com.ningdatech.pmapi.todocenter.bean.entity;

import com.ningdatech.pmapi.todocenter.model.dto.req.ReqProcessHandlerDTO;
import com.wflow.workflow.bean.process.OrgUser;
import com.wflow.workflow.bean.process.enums.ApprovalModeEnum;
import com.wflow.workflow.bean.process.enums.NodeTypeEnum;
import com.wflow.workflow.bean.vo.ProcessHandlerParamsVo;
import com.wflow.workflow.bean.vo.TaskCommentVo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

/**
* 流程节点实体
*
* @author CMM
* @since 2023/01/31 12:24
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ProgressNode {
/**
* 节点ID
*/
private String nodeId;
/**
* 任务ID
*/
private String taskId;
/**
* 审批类型
*/
private ApprovalModeEnum approvalMode;
/**
* 节点类型
*/
private NodeTypeEnum nodeType;
/**
* 节点名称
*/
private String name;
/**
* 节点相关人员
*/
private OrgUser user;
/**
* 该节点动作操作类型
*/
private ReqProcessHandlerDTO.Action action;
/**
* 处理结果
*/
private ReqProcessHandlerDTO.Action result;
/**
* 开始时间
*/
private Date startTime;
/**
* 结束时间
*/
private Date finishTime;
}

pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/vo/ProcessProgressVo.java → pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/vo/ProcessProgressDetailVo.java View File

@@ -1,5 +1,6 @@
package com.ningdatech.pmapi.todocenter.bean.vo; package com.ningdatech.pmapi.todocenter.bean.vo;


import com.ningdatech.pmapi.todocenter.bean.entity.ProgressNode;
import com.wflow.workflow.bean.process.OrgUser; import com.wflow.workflow.bean.process.OrgUser;
import com.wflow.workflow.bean.process.form.Form; import com.wflow.workflow.bean.process.form.Form;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -21,7 +22,7 @@ import java.util.Map;
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class ProcessProgressVo {
public class ProcessProgressDetailVo {
/** /**
* 审批实例ID * 审批实例ID
*/ */

+ 25
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/constant/HisProInsEndActId.java View File

@@ -0,0 +1,25 @@
package com.ningdatech.pmapi.todocenter.constant;
/**
* 历史流程实例终点活跃ID状态
* @author CMM
* @since 2023/01/31 15:13
*/
public interface HisProInsEndActId {
/**
* 流程被驳回
*/
public static final String REJECT = "refuse-end";
/**
* 流程被退回
*/
public static final String BACK = "back-end";
/**
* 流程被撤回
*/
public static final String WITHDRAW = "cancel-end";
/**
* 流程结束
*/
public static final String END = "process-end";

}

+ 3
- 2
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java View File

@@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;


import com.ningdatech.pmapi.common.util.ExcelDownUtil; import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.todocenter.bean.vo.ProcessProgressDetailVo;
import com.ningdatech.pmapi.todocenter.model.dto.req.ReqProcessHandlerDTO; import com.ningdatech.pmapi.todocenter.model.dto.req.ReqProcessHandlerDTO;
import com.wflow.utils.R; import com.wflow.utils.R;
import com.wflow.workflow.bean.vo.ProcessHandlerParamsVo; import com.wflow.workflow.bean.vo.ProcessHandlerParamsVo;
@@ -65,8 +66,8 @@ public class TodoCenterController {
* @return 流程进度及表单详情 * @return 流程进度及表单详情
*/ */
@GetMapping("progress/{instanceId}/{nodeId}") @GetMapping("progress/{instanceId}/{nodeId}")
public ApiResponse<Object> getProcessDetail(@PathVariable String instanceId,
@PathVariable(required = false) String nodeId) {
public ApiResponse<ProcessProgressDetailVo> getProcessDetail(@PathVariable String instanceId,
@PathVariable(required = false) String nodeId) {
return ApiResponse.ofSuccess(todoCenterManage.getProcessDetail(nodeId, instanceId)); return ApiResponse.ofSuccess(todoCenterManage.getProcessDetail(nodeId, instanceId));
} }




+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/enums/ProcessStatusEnum.java View File

@@ -27,7 +27,7 @@ public enum ProcessStatusEnum {
/** /**
* 被退回 * 被退回
*/ */
BE_RETURNED(2, "被退回"),
BE_BACKED(2, "被退回"),


/** /**
* 被驳回 * 被驳回


+ 1
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/extension/cmd/BackToHisApprovalNodeCmd.java View File

@@ -47,6 +47,7 @@ public class BackToHisApprovalNodeCmd implements Command<String>, Serializable {


@Override @Override
public String execute(CommandContext commandContext) { public String execute(CommandContext commandContext) {

if (targetNodeId == null || targetNodeId.length() == 0) { if (targetNodeId == null || targetNodeId.length() == 0) {
throw new FlowableException("退回的目标节点不能为空"); throw new FlowableException("退回的目标节点不能为空");
} }


+ 50
- 84
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java View File

@@ -3,7 +3,6 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.exception.BizException;
@@ -11,7 +10,9 @@ import com.ningdatech.basic.util.NdDateUtils;
import com.ningdatech.pmapi.common.constant.ProjectDeclareConstants; import com.ningdatech.pmapi.common.constant.ProjectDeclareConstants;
import com.ningdatech.pmapi.common.util.ExcelDownUtil; import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.common.util.ExcelExportStyle; import com.ningdatech.pmapi.common.util.ExcelExportStyle;
import com.ningdatech.pmapi.todocenter.bean.entity.ProcessTask;
import com.ningdatech.pmapi.todocenter.bean.entity.ProgressNode;
import com.ningdatech.pmapi.todocenter.bean.vo.ProcessProgressDetailVo;
import com.ningdatech.pmapi.todocenter.constant.HisProInsEndActId;
import com.ningdatech.pmapi.todocenter.enums.ProcessStatusEnum; import com.ningdatech.pmapi.todocenter.enums.ProcessStatusEnum;
import com.ningdatech.pmapi.todocenter.extension.cmd.BackToHisApprovalNodeCmd; import com.ningdatech.pmapi.todocenter.extension.cmd.BackToHisApprovalNodeCmd;
import com.ningdatech.pmapi.todocenter.model.dto.req.ReqProcessHandlerDTO; import com.ningdatech.pmapi.todocenter.model.dto.req.ReqProcessHandlerDTO;
@@ -30,16 +31,13 @@ import com.wflow.workflow.bean.process.enums.ApprovalModeEnum;
import com.wflow.workflow.bean.process.enums.NodeTypeEnum; import com.wflow.workflow.bean.process.enums.NodeTypeEnum;
import com.wflow.workflow.bean.process.form.Form; import com.wflow.workflow.bean.process.form.Form;
import com.wflow.workflow.bean.process.props.ApprovalProps; import com.wflow.workflow.bean.process.props.ApprovalProps;
import com.wflow.workflow.bean.vo.ProcessHandlerParamsVo;
import com.wflow.workflow.bean.vo.ProcessProgressVo; import com.wflow.workflow.bean.vo.ProcessProgressVo;
import com.wflow.workflow.bean.vo.TaskCommentVo;
import com.wflow.workflow.bean.vo.ProcessTaskVo;
import com.wflow.workflow.config.WflowGlobalVarDef; import com.wflow.workflow.config.WflowGlobalVarDef;
import com.wflow.workflow.service.*; import com.wflow.workflow.service.*;
import com.wflow.workflow.service.FormService; import com.wflow.workflow.service.FormService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.assertj.core.util.Lists;
import org.assertj.core.util.Maps; import org.assertj.core.util.Maps;
import org.flowable.common.engine.impl.identity.Authentication;
import org.flowable.engine.*; import org.flowable.engine.*;
import org.flowable.engine.history.HistoricActivityInstance; import org.flowable.engine.history.HistoricActivityInstance;
import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.engine.history.HistoricProcessInstance;
@@ -116,7 +114,7 @@ public class TodoCenterManage {
ProcessInstanceOwnerDto owner = runtimeService.getVariable(task.getExecutionId(), "owner", ProcessInstanceOwnerDto.class); ProcessInstanceOwnerDto owner = runtimeService.getVariable(task.getExecutionId(), "owner", ProcessInstanceOwnerDto.class);
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult(); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
staterUsers.add(owner.getOwner()); staterUsers.add(owner.getOwner());
ProcessTask processTask = ProcessTask.builder()
ProcessTaskVo processTaskVo = ProcessTaskVo.builder()
.taskId(task.getId()) .taskId(task.getId())
.taskName(task.getName()) .taskName(task.getName())
.taskDefKey(task.getTaskDefinitionKey()) .taskDefKey(task.getTaskDefinitionKey())
@@ -133,7 +131,7 @@ public class TodoCenterManage {
.createTime(processInstance.getStartTime()) .createTime(processInstance.getStartTime())
.taskCreateTime(task.getCreateTime()) .taskCreateTime(task.getCreateTime())
.build(); .build();
res.setProcessTaskInfo(processTask);
res.setProcessTaskInfo(processTaskVo);
String projectName = (String) formData.get(ProjectDeclareConstants.BasicInformation.PROJECT_NAME); String projectName = (String) formData.get(ProjectDeclareConstants.BasicInformation.PROJECT_NAME);
res.setProjectName(projectName); res.setProjectName(projectName);
res.setReportUnitId(owner.getOwnerDeptId()); res.setReportUnitId(owner.getOwnerDeptId());
@@ -195,15 +193,15 @@ public class TodoCenterManage {
switch (param.getAction()) { switch (param.getAction()) {
// 通过 // 通过
case pass: case pass:
formData.put("audit_pass_opinion",param.getAuditApprovalOpinion());
formData.put("audit_pass_appendix",param.getAuditApprovalAppendix());
formData.put("audit_pass_opinion",param.getAuditPassOpinion());
formData.put("audit_pass_appendix",param.getAuditPassAppendix());
formData.put("audit_pass_time", auditTime); formData.put("audit_pass_time", auditTime);
formService.updateInstanceFormData(param.getInstanceId(), formData); formService.updateInstanceFormData(param.getInstanceId(), formData);
doPass(task, param); doPass(task, param);
// 盖章并通过 // 盖章并通过
case seal_pass: case seal_pass:
formData.put("seal_pass_opinion",param.getSealApprovalOpinion());
formData.put("seal_pass_appendix",param.getSealApprovalAppendix());
formData.put("seal_pass_opinion",param.getSealPassOpinion());
formData.put("seal_pass_appendix",param.getSealPassAppendix());
Date sealPassTime = NdDateUtils.localDateTime2Date(LocalDateTime.now()); Date sealPassTime = NdDateUtils.localDateTime2Date(LocalDateTime.now());
formData.put("seal_pass_time",sealPassTime); formData.put("seal_pass_time",sealPassTime);
formService.updateInstanceFormData(param.getInstanceId(), formData); formService.updateInstanceFormData(param.getInstanceId(), formData);
@@ -231,7 +229,6 @@ public class TodoCenterManage {
default: default:
throw new IllegalStateException("Unexpected value: " + param.getAction()); throw new IllegalStateException("Unexpected value: " + param.getAction());
} }
Authentication.setAuthenticatedUserId(null);
} }


/** /**
@@ -242,7 +239,7 @@ public class TodoCenterManage {
*/ */
private void doReject(Task task, ReqProcessHandlerDTO param) { private void doReject(Task task, ReqProcessHandlerDTO param) {
Map<String, Object> var = new HashMap<>(16); Map<String, Object> var = new HashMap<>(16);
var.put("reject_" + task.getId(), param.getAction());
var.put("approve_" + task.getId(), param.getAction());
// TODO 中止流程并使项目进入对应状态 // TODO 中止流程并使项目进入对应状态
// TODO 给项目创建人、流程发起人发送浙政钉工作通知:【项目名称】的【流程名称】被驳回,请及时处理。 // TODO 给项目创建人、流程发起人发送浙政钉工作通知:【项目名称】的【流程名称】被驳回,请及时处理。
taskService.complete(param.getTaskId(), var); taskService.complete(param.getTaskId(), var);
@@ -256,7 +253,7 @@ public class TodoCenterManage {
*/ */
private void doSealPass(Task task, ReqProcessHandlerDTO param) { private void doSealPass(Task task, ReqProcessHandlerDTO param) {
Map<String, Object> var = new HashMap<>(16); Map<String, Object> var = new HashMap<>(16);
var.put("seal_pass_" + task.getId(), param.getAction());
var.put("approve_" + task.getId(), param.getAction());
// TODO 判断项目申报单位级别,区县单位申报有上级主管单位意见栏,市级单位没有 // TODO 判断项目申报单位级别,区县单位申报有上级主管单位意见栏,市级单位没有
// TODO 市级单位:为大数据局;区县单位:为大数据中心(根据附件区分?) // TODO 市级单位:为大数据局;区县单位:为大数据中心(根据附件区分?)
taskService.complete(param.getTaskId(), var); taskService.complete(param.getTaskId(), var);
@@ -270,7 +267,7 @@ public class TodoCenterManage {
*/ */
private void doPass(Task task, ReqProcessHandlerDTO param) { private void doPass(Task task, ReqProcessHandlerDTO param) {
Map<String, Object> var = new HashMap<>(16); Map<String, Object> var = new HashMap<>(16);
var.put("pass_" + task.getId(), param.getAction());
var.put("approve_" + task.getId(), param.getAction());
// TODO 获取流程下一个节点的审核人 // TODO 获取流程下一个节点的审核人


// TODO 若有下一个审核人,向其发送浙政钉工作通知:标题:审核任务 内容:【单位名称】的【项目名称】需要您审核。 // TODO 若有下一个审核人,向其发送浙政钉工作通知:标题:审核任务 内容:【单位名称】的【项目名称】需要您审核。
@@ -290,12 +287,12 @@ public class TodoCenterManage {
List<Execution> executions = runtimeService.createExecutionQuery() List<Execution> executions = runtimeService.createExecutionQuery()
.processInstanceId(task.getProcessInstanceId()) .processInstanceId(task.getProcessInstanceId())
.onlyChildExecutions().list(); .onlyChildExecutions().list();
// 强制流程指向
// 强制流程指向
runtimeService.createChangeActivityStateBuilder() runtimeService.createChangeActivityStateBuilder()
.processInstanceId(task.getProcessInstanceId()) .processInstanceId(task.getProcessInstanceId())
.moveActivityIdTo(task.getTaskDefinitionKey(), "cancel-end")
.moveActivityIdTo(task.getTaskDefinitionKey(), HisProInsEndActId.WITHDRAW)
.moveExecutionsToSingleActivityId(executions.stream().map(Execution::getId) .moveExecutionsToSingleActivityId(executions.stream().map(Execution::getId)
.collect(Collectors.toList()), "cancel-end")
.collect(Collectors.toList()), HisProInsEndActId.WITHDRAW)
.changeState(); .changeState();
} }


@@ -311,7 +308,7 @@ public class TodoCenterManage {
// TODO 给项目创建人、流程发起人发送浙政钉工作通知:【项目名称】的【流程名称】被退回,请及时处理。 // TODO 给项目创建人、流程发起人发送浙政钉工作通知:【项目名称】的【流程名称】被退回,请及时处理。
//执行自定义回退逻辑 //执行自定义回退逻辑
managementService.executeCommand(new BackToHisApprovalNodeCmd(runtimeService, param.getTaskId(), param.getTargetNode())); managementService.executeCommand(new BackToHisApprovalNodeCmd(runtimeService, param.getTaskId(), param.getTargetNode()));
runtimeService.setVariables(param.getInstanceId(), Maps.newHashMap("back_" + param.getTaskId(), param.getAction()));
runtimeService.setVariables(param.getInstanceId(), Maps.newHashMap("approve_" + param.getTaskId(), param.getAction()));
log.info("用户[{}] 退回流程[{}] [{} -> {}]", userId, param.getInstanceId(), current, param.getTargetNode()); log.info("用户[{}] 退回流程[{}] [{} -> {}]", userId, param.getInstanceId(), current, param.getTargetNode());
} }


@@ -321,7 +318,7 @@ public class TodoCenterManage {
* @param nodeId 当前获取流程人员关联的流程节点ID * @param nodeId 当前获取流程人员关联的流程节点ID
* @return 流程进度及表单详情 * @return 流程进度及表单详情
*/ */
public Object getProcessDetail(String nodeId, String instanceId) {
public ProcessProgressDetailVo getProcessDetail(String nodeId, String instanceId) {
HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery().processInstanceId(instanceId).singleResult(); HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery().processInstanceId(instanceId).singleResult();
// 取表单及表单数据 // 取表单及表单数据
HistoricVariableInstance forms = historyService.createHistoricVariableInstanceQuery() HistoricVariableInstance forms = historyService.createHistoricVariableInstanceQuery()
@@ -332,7 +329,6 @@ public class TodoCenterManage {
HistoricVariableInstance nodeProps = historyService.createHistoricVariableInstanceQuery() HistoricVariableInstance nodeProps = historyService.createHistoricVariableInstanceQuery()
.processInstanceId(instanceId).variableName(WflowGlobalVarDef.WFLOW_NODE_PROPS).singleResult(); .processInstanceId(instanceId).variableName(WflowGlobalVarDef.WFLOW_NODE_PROPS).singleResult();
Map<String, Object> nodePropsValue = (Map<String, Object>) nodeProps.getValue(); Map<String, Object> nodePropsValue = (Map<String, Object>) nodeProps.getValue();

ProcessNode<?> currentNode = null; ProcessNode<?> currentNode = null;
if (StrUtil.isNotBlank(nodeId)) { if (StrUtil.isNotBlank(nodeId)) {
// 搜索当前版本流程的配置 // 搜索当前版本流程的配置
@@ -342,15 +338,17 @@ public class TodoCenterManage {
} }
UserDo users = orgRepositoryService.getUserById(instance.getStartUserId()); UserDo users = orgRepositoryService.getUserById(instance.getStartUserId());
OrgUser startUser = OrgUser.builder().id(users.getUserId()).name(users.getUserName()).avatar(users.getAvatar()).build(); OrgUser startUser = OrgUser.builder().id(users.getUserId()).name(users.getUserName()).avatar(users.getAvatar()).build();
List<ProcessProgressVo.ProgressNode> taskRecords = getHisTaskRecords(instanceId, nodePropsValue);
List<ProgressNode> taskRecords = getHisTaskRecords(instanceId, nodePropsValue);
// 获取添加抄送任务
taskRecords.addAll(getCcTaskRecords(instanceId)); taskRecords.addAll(getCcTaskRecords(instanceId));
if (ObjectUtil.isNull(instance.getEndTime())) { if (ObjectUtil.isNull(instance.getEndTime())) {
taskRecords.addAll(processTaskService.getFutureTask(instanceId));
// TODO 下版实现 获取等待中且还未开始的任务,如果存在条件则需要直接解析条件
taskRecords.addAll(getFutureTask(instanceId));
} }
taskRecords = taskRecords.stream() taskRecords = taskRecords.stream()
.sorted(Comparator.comparing(ProcessProgressVo.ProgressNode::getStartTime))
.sorted(Comparator.comparing(ProgressNode::getStartTime))
.collect(Collectors.toList()); .collect(Collectors.toList());
taskRecords.add(0, ProcessProgressVo.ProgressNode.builder()
taskRecords.add(0, ProgressNode.builder()
.nodeId("root") .nodeId("root")
.name("提交申请") .name("提交申请")
.user(startUser) .user(startUser)
@@ -358,14 +356,14 @@ public class TodoCenterManage {
.startTime(instance.getStartTime()) .startTime(instance.getStartTime())
.finishTime(instance.getStartTime()) .finishTime(instance.getStartTime())
.taskId("root") .taskId("root")
.result(ProcessHandlerParamsVo.Action.agree)
.result(ReqProcessHandlerDTO.Action.pass)
.build()); .build());
// 提取全量表单数据 // 提取全量表单数据
Map<String, Object> formData = formDatas.stream().collect(Collectors.toMap(HistoricVariableInstance::getVariableName, HistoricVariableInstance::getValue)); Map<String, Object> formData = formDatas.stream().collect(Collectors.toMap(HistoricVariableInstance::getVariableName, HistoricVariableInstance::getValue));
HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery() HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery()
.processInstanceId(instanceId).variableName("owner").singleResult(); .processInstanceId(instanceId).variableName("owner").singleResult();
ProcessInstanceOwnerDto owner = (ProcessInstanceOwnerDto) variableInstance.getValue(); ProcessInstanceOwnerDto owner = (ProcessInstanceOwnerDto) variableInstance.getValue();
return ProcessProgressVo.builder()
ProcessProgressDetailVo res = ProcessProgressDetailVo.builder()
.instanceId(instanceId) .instanceId(instanceId)
.version(instance.getProcessDefinitionVersion()) .version(instance.getProcessDefinitionVersion())
.formItems(formService.filterFormAndDataByPermConfig((List<Form>) forms.getValue(), formData, currentNode)) .formItems(formService.filterFormAndDataByPermConfig((List<Form>) forms.getValue(), formData, currentNode))
@@ -373,11 +371,20 @@ public class TodoCenterManage {
.processDefName(instance.getProcessDefinitionName()) .processDefName(instance.getProcessDefinitionName())
.staterUser(startUser) .staterUser(startUser)
.starterDept(null == owner ? null : owner.getOwnerDeptName()) .starterDept(null == owner ? null : owner.getOwnerDeptName())
.status(ObjectUtil.isNull(instance.getEndActivityId()) ? "RUNNING" : "COMPLETE")
.result(instance.getEndActivityId()) .result(instance.getEndActivityId())
.startTime(instance.getStartTime()) .startTime(instance.getStartTime())
.progress(taskRecords) .progress(taskRecords)
.build(); .build();
if (Objects.isNull(instance.getEndActivityId())){
res.setStatus(ProcessStatusEnum.UNDER_REVIEW.name());
} else if (HisProInsEndActId.BACK.equals(instance.getEndActivityId())) {
res.setStatus(ProcessStatusEnum.BE_BACKED.name());
} else if (HisProInsEndActId.REJECT.equals(instance.getEndActivityId())) {
res.setStatus(ProcessStatusEnum.BE_REJECTED.name());
} else if (HisProInsEndActId.END.equals(instance.getEndActivityId())) {
res.setStatus(ProcessStatusEnum.APPROVED.name());
}
return res;
} }


/** /**
@@ -386,16 +393,15 @@ public class TodoCenterManage {
* @param instanceId 实例ID * @param instanceId 实例ID
* @return 抄送我的流程 * @return 抄送我的流程
*/ */
private List<ProcessProgressVo.ProgressNode> getCcTaskRecords(String instanceId) {
private List<ProgressNode> getCcTaskRecords(String instanceId) {
Set<String> ccUsers = new HashSet<>(); Set<String> ccUsers = new HashSet<>();
List<ProcessProgressVo.ProgressNode> ccList = ccTasksMapper.selectList(new QueryWrapper<WflowCcTasks>()
List<ProgressNode> ccList = ccTasksMapper.selectList(new QueryWrapper<WflowCcTasks>()
.eq("instance_id", instanceId)).stream().map(task -> { .eq("instance_id", instanceId)).stream().map(task -> {
ccUsers.add(task.getUserId()); ccUsers.add(task.getUserId());
return ProcessProgressVo.ProgressNode.builder()
return ProgressNode.builder()
.nodeId(task.getNodeId()) .nodeId(task.getNodeId())
.nodeType(NodeTypeEnum.CC) .nodeType(NodeTypeEnum.CC)
.name(task.getNodeName()) .name(task.getNodeName())
.comment(Collections.emptyList())
.user(OrgUser.builder().id(task.getUserId()).build()) .user(OrgUser.builder().id(task.getUserId()).build())
.startTime(task.getCreateTime()) .startTime(task.getCreateTime())
.finishTime(task.getCreateTime()) .finishTime(task.getCreateTime())
@@ -415,46 +421,22 @@ public class TodoCenterManage {
* @param nodeProps 节点设置 * @param nodeProps 节点设置
* @return 历史记录列表 * @return 历史记录列表
*/ */
private List<ProcessProgressVo.ProgressNode> getHisTaskRecords(String instanceId, Map<String, Object> nodeProps) {
private List<ProgressNode> getHisTaskRecords(String instanceId, Map<String, Object> nodeProps) {
List<HistoricActivityInstance> list = historyService.createHistoricActivityInstanceQuery() List<HistoricActivityInstance> list = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(instanceId).orderByHistoricActivityInstanceStartTime().asc().list(); .processInstanceId(instanceId).orderByHistoricActivityInstanceStartTime().asc().list();
Set<String> userSet = new HashSet<>(); Set<String> userSet = new HashSet<>();
//获取节点处理结果 //获取节点处理结果
Map<String, ProcessHandlerParamsVo.Action> varMap = historyService.createHistoricVariableInstanceQuery()
Map<String, ReqProcessHandlerDTO.Action> varMap = historyService.createHistoricVariableInstanceQuery()
.processInstanceId(instanceId).variableNameLike("approve_%").list().stream() .processInstanceId(instanceId).variableNameLike("approve_%").list().stream()
.collect(Collectors.toMap(HistoricVariableInstance::getVariableName, v -> (ProcessHandlerParamsVo.Action) v.getValue()));
Map<String, List<TaskCommentVo>> commentMap = new HashMap<>();
//统一处理所有评论数据,省的多次查询
List<TaskCommentVo> cmvos = taskService.getProcessInstanceComments(instanceId).stream().map(comment -> {
userSet.add(comment.getUserId());
TaskCommentVo commentVo = TaskCommentVo.builder()
.id(comment.getId())
.taskId(comment.getTaskId())
.commentType(comment.getType())
.type("COMMENT")
.createTime(comment.getTime())
.user(OrgUser.builder().id(comment.getUserId()).build())
.build();
ProcessHandlerParamsVo.ProcessComment processComment = JSONObject.parseObject(comment.getFullMessage(), ProcessHandlerParamsVo.ProcessComment.class);
commentVo.setText(processComment.getText());
commentVo.setAttachments(processComment.getAttachments());
return commentVo;
}).collect(Collectors.toList());
cmvos.forEach(cm -> {
//把评论数据按照task进行归类
String taskId = Optional.ofNullable(cm.getTaskId()).orElse(instanceId);
List<TaskCommentVo> vos = commentMap.computeIfAbsent(taskId, k -> new ArrayList<>());
vos.add(cm);
});
List<ProcessProgressVo.ProgressNode> progressNodes = list.stream().filter(his -> ObjectUtil.isNotNull(his.getTaskId())).map(his -> {
.collect(Collectors.toMap(HistoricVariableInstance::getVariableName, v -> (ReqProcessHandlerDTO.Action) v.getValue()));
List<ProgressNode> progressNodes = list.stream().filter(his -> ObjectUtil.isNotNull(his.getTaskId())).map(his -> {
Object props = nodeProps.get(his.getActivityId()); Object props = nodeProps.get(his.getActivityId());
ApprovalModeEnum approvalMode = null; ApprovalModeEnum approvalMode = null;
if (props instanceof ApprovalProps) { if (props instanceof ApprovalProps) {
approvalMode = ((ApprovalProps) props).getMode(); approvalMode = ((ApprovalProps) props).getMode();
} }
userSet.add(his.getAssignee()); userSet.add(his.getAssignee());
List<TaskCommentVo> commentVos = commentMap.getOrDefault(his.getTaskId(), Collections.emptyList());
return ProcessProgressVo.ProgressNode.builder()
return ProgressNode.builder()
.nodeId(his.getActivityId()) .nodeId(his.getActivityId())
.name(his.getActivityName()) .name(his.getActivityName())
.nodeType(NodeTypeEnum.APPROVAL) .nodeType(NodeTypeEnum.APPROVAL)
@@ -463,34 +445,18 @@ public class TodoCenterManage {
.finishTime(his.getEndTime()) .finishTime(his.getEndTime())
.taskId(his.getTaskId()) .taskId(his.getTaskId())
.approvalMode(approvalMode) .approvalMode(approvalMode)
.comment(commentVos)
.result(varMap.get("approve_" + his.getTaskId())) .result(varMap.get("approve_" + his.getTaskId()))
.build(); .build();
}).collect(Collectors.toList()); }).collect(Collectors.toList());
//将非任务类的评论转换成流程节点
progressNodes.addAll(commentMap.getOrDefault(instanceId, Collections.emptyList()).stream().map(cm ->
ProcessProgressVo.ProgressNode.builder()
.nodeId(cm.getId())
.name("参与评论")
.user(cm.getUser())
.startTime(cm.getCreateTime())
.finishTime(cm.getCreateTime())
.taskId(cm.getId())
.comment(Lists.list(cm))
.result(ProcessHandlerParamsVo.Action.comment)
.build()).collect(Collectors.toList()));
if (CollectionUtil.isNotEmpty(userSet)) { if (CollectionUtil.isNotEmpty(userSet)) {
Map<String, OrgUser> map = userDeptOrLeaderService.getUserMapByIds(userSet); Map<String, OrgUser> map = userDeptOrLeaderService.getUserMapByIds(userSet);
progressNodes.forEach(n -> {
if (WflowGlobalVarDef.WFLOW_TASK_AGRRE.equals(n.getUser().getId())
|| WflowGlobalVarDef.WFLOW_TASK_REFUSE.equals(n.getUser().getId())) {
n.setUser(WflowGlobalVarDef.SYS);
} else {
n.setUser(map.get(n.getUser().getId()));
n.getComment().forEach(c -> c.setUser(map.get(c.getUser().getId())));
}
});
progressNodes.forEach(n -> n.setUser(map.get(n.getUser().getId())));
} }
return progressNodes; return progressNodes;
} }

private List<ProgressNode> getFutureTask(String instanceId) {
//根据流程遍历后续节点,期间要穿越后续包含并行网关和条件网关的节点
return Collections.emptyList();
}
} }

+ 5
- 5
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqProcessHandlerDTO.java View File

@@ -43,21 +43,21 @@ public class ReqProcessHandlerDTO {
/** /**
* 审核通过意见 * 审核通过意见
*/ */
private String auditApprovalOpinion;
private String auditPassOpinion;


/** /**
* 审核通过附件 * 审核通过附件
*/ */
private FileBasicInfo auditApprovalAppendix;
private FileBasicInfo auditPassAppendix;
/** /**
* 盖章通过意见 * 盖章通过意见
*/ */
private String sealApprovalOpinion;
private String sealPassOpinion;


/** /**
* 盖章通过附件 * 盖章通过附件
*/ */
private FileBasicInfo sealApprovalAppendix;
private FileBasicInfo sealPassAppendix;
/** /**
* 审核退回意见 * 审核退回意见
*/ */
@@ -76,7 +76,7 @@ public class ReqProcessHandlerDTO {
*/ */
private FileBasicInfo auditRejectAppendix; private FileBasicInfo auditRejectAppendix;
public enum Action{ public enum Action{
//通过、盖章并通过、退回、撤回、驳回
//通过、盖章并通过、退回、撤回、驳回,审核意见类型
pass, seal_pass ,back, withdraw, reject; pass, seal_pass ,back, withdraw, reject;
} }
} }

+ 1
- 2
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/res/ResToBeProcessedDTO.java View File

@@ -3,7 +3,6 @@ package com.ningdatech.pmapi.todocenter.model.dto.res;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;


import com.ningdatech.pmapi.todocenter.bean.entity.ProcessTask;
import com.wflow.workflow.bean.vo.ProcessTaskVo; import com.wflow.workflow.bean.vo.ProcessTaskVo;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -50,5 +49,5 @@ public class ResToBeProcessedDTO implements Serializable {
private LocalDateTime processLaunchTime; private LocalDateTime processLaunchTime;


@ApiModelProperty("流程任务信息") @ApiModelProperty("流程任务信息")
private ProcessTask processTaskInfo;
private ProcessTaskVo processTaskInfo;
} }

Loading…
Cancel
Save