diff --git a/pmapi/.idea/compiler.xml b/pmapi/.idea/compiler.xml index 083ac82..5439b93 100644 --- a/pmapi/.idea/compiler.xml +++ b/pmapi/.idea/compiler.xml @@ -2,6 +2,7 @@ + diff --git a/pmapi/.idea/misc.xml b/pmapi/.idea/misc.xml index d31b37a..d5cd614 100644 --- a/pmapi/.idea/misc.xml +++ b/pmapi/.idea/misc.xml @@ -8,5 +8,5 @@ - + \ No newline at end of file diff --git a/pmapi/.idea/sonarlint/issuestore/0/0/002597a7f172f343a6cffcd273be74aa895d74b3 b/pmapi/.idea/sonarlint/issuestore/0/0/002597a7f172f343a6cffcd273be74aa895d74b3 new file mode 100644 index 0000000..0c7d268 --- /dev/null +++ b/pmapi/.idea/sonarlint/issuestore/0/0/002597a7f172f343a6cffcd273be74aa895d74b3 @@ -0,0 +1,3 @@ + +U +java:S1118":Add a private constructor to hide the implicit public one.(۫ \ No newline at end of file diff --git a/pmapi/.idea/sonarlint/issuestore/0/2/02999ca52b20720a6dba73a2ea57a018dba90084 b/pmapi/.idea/sonarlint/issuestore/0/2/02999ca52b20720a6dba73a2ea57a018dba90084 new file mode 100644 index 0000000..1f74f1e --- /dev/null +++ b/pmapi/.idea/sonarlint/issuestore/0/2/02999ca52b20720a6dba73a2ea57a018dba90084 @@ -0,0 +1,3 @@ + +U +java:S1118":Add a private constructor to hide the implicit public one.( \ No newline at end of file diff --git a/pmapi/.idea/sonarlint/issuestore/0/3/032c44040c9d507864de35d7170661addf623095 b/pmapi/.idea/sonarlint/issuestore/0/3/032c44040c9d507864de35d7170661addf623095 new file mode 100644 index 0000000..e69de29 diff --git a/pmapi/.idea/sonarlint/issuestore/3/a/3a29a241dcf97a75f4de88a48dacd988a7193f67 b/pmapi/.idea/sonarlint/issuestore/3/a/3a29a241dcf97a75f4de88a48dacd988a7193f67 new file mode 100644 index 0000000..e69de29 diff --git a/pmapi/.idea/sonarlint/issuestore/4/d/4d181ee0ef35161a71fa355047c13e9ab5aa4793 b/pmapi/.idea/sonarlint/issuestore/4/d/4d181ee0ef35161a71fa355047c13e9ab5aa4793 new file mode 100644 index 0000000..e69de29 diff --git a/pmapi/.idea/sonarlint/issuestore/7/a/7a4df0ff8172ed96c29e54029f6ecac024700aa5 b/pmapi/.idea/sonarlint/issuestore/7/a/7a4df0ff8172ed96c29e54029f6ecac024700aa5 new file mode 100644 index 0000000..dfefc2b --- /dev/null +++ b/pmapi/.idea/sonarlint/issuestore/7/a/7a4df0ff8172ed96c29e54029f6ecac024700aa5 @@ -0,0 +1,95 @@ + +o +java:S1192"SDefine a constant instead of duplicating this literal "Unexpected value: " 3 times.( +n +java:S1192"WDefine a constant instead of duplicating this literal "状态机执行失败!" 3 times.( +e +java:S1192"IDefine a constant instead of duplicating this literal "approve_" 5 times.( +t java:S135"YReduce the total number of break and continue statements in this loop to use at most one.(Î +A +java:S5411"*Use the primitive boolean expression here.( +Z +java:S2583"CChange this condition so that it does not always evaluate to "true"( +W java:S125"src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java,d\7\d7146276b7a0a780dc7631a29b70c58f9c37fac3 \ No newline at end of file diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/entity/ProgressNode.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/entity/ProgressNode.java deleted file mode 100644 index 5befcad..0000000 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/entity/ProgressNode.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.ningdatech.pmapi.todocenter.bean.entity; - -import com.ningdatech.pmapi.todocenter.bean.vo.ProgressNodeAuditInfoVo; -import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; -import com.wflow.workflow.bean.process.enums.ApprovalModeEnum; -import com.wflow.workflow.bean.process.enums.NodeTypeEnum; -import com.wflow.workflow.enums.ProcessHandlerEnum; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.Date; - -/** - * 流程节点实体 - * - * @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 ProcessInstanceUserDto user; - /** - * 该节点动作操作类型 - */ - private ProcessHandlerEnum action; - /** - * 审核信息 - */ - private ProgressNodeAuditInfoVo auditInfo; - /** - * 处理结果 - */ - private ProcessHandlerEnum result; - /** - * 开始时间 - */ - private Date startTime; - /** - * 结束时间 - */ - private Date finishTime; -} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/vo/ProcessProgressDetailVo.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/vo/ProcessProgressDetailVo.java index 3fa2ead..1767942 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/vo/ProcessProgressDetailVo.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/vo/ProcessProgressDetailVo.java @@ -1,19 +1,13 @@ package com.ningdatech.pmapi.todocenter.bean.vo; -import com.ningdatech.pmapi.todocenter.bean.entity.ProgressNode; import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; -import com.wflow.workflow.bean.process.form.Form; +import com.wflow.workflow.bean.vo.ProcessProgressVo; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; - -import java.util.Date; -import java.util.List; -import java.util.Map; - /** * 流程进展详情实体 * @@ -25,44 +19,19 @@ import java.util.Map; @AllArgsConstructor @NoArgsConstructor public class ProcessProgressDetailVo { + /** - * 审批实例ID - */ - private String instanceId; - /** - * 表单配置项 - */ - private List
formItems; - /** - * 表单值 - */ - private Map formData; - /** - * 流程进度步骤 - */ - private List progress; - /** - * 流程定义名称 - */ - private String processDefName; - /** - * 版本 + * 流程处理详情 */ - private Integer version; + private ProcessProgressVo processProgressVo; + /** * 流程状态 */ private String status; /** - * 流程结果 - */ - private String result; - /** * 发起人 */ private ProcessInstanceUserDto startUser; - /** - * 发起时间 - */ - private Date startTime; + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/vo/ProgressNodeAuditInfoVo.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/vo/ProgressNodeAuditInfoVo.java deleted file mode 100644 index 22bf75b..0000000 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/vo/ProgressNodeAuditInfoVo.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.ningdatech.pmapi.todocenter.bean.vo; - -import com.ningdatech.pmapi.todocenter.bean.entity.ProcessComment; -import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.Date; - -/** - * 流程节点审核信息 - * - * @author CMM - * @since 2023/02/01 16:52 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class ProgressNodeAuditInfoVo extends ProcessComment { - @ApiModelProperty("评论ID") - private String id; - - @ApiModelProperty("评论") - private String type; - - @ApiModelProperty("任务ID") - private String taskId; - - @ApiModelProperty("评论类型") - private String commentType; - - @ApiModelProperty("评论用户信息") - private ProcessInstanceUserDto user; - - @ApiModelProperty("评论时间") - private Date createTime; -} 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 86ddac8..3bd2333 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 @@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.model.PageVo; -import com.ningdatech.basic.util.NdDateUtils; import com.ningdatech.pmapi.common.constant.CommonConstant; import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter; import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent; @@ -24,10 +23,8 @@ import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; import com.ningdatech.pmapi.projectlib.service.IProjectService; import com.ningdatech.pmapi.todocenter.bean.entity.ProcessComment; -import com.ningdatech.pmapi.todocenter.bean.entity.ProgressNode; import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo; import com.ningdatech.pmapi.todocenter.bean.vo.ProcessProgressDetailVo; -import com.ningdatech.pmapi.todocenter.bean.vo.ProgressNodeAuditInfoVo; import com.ningdatech.pmapi.todocenter.enumeration.IsAppendProjectEnum; import com.ningdatech.pmapi.todocenter.extension.cmd.BackToHisApprovalNodeCmd; import com.ningdatech.pmapi.todocenter.extension.cmd.SaveCommentCmd; @@ -40,22 +37,20 @@ import com.ningdatech.pmapi.user.entity.UserInfo; import com.ningdatech.pmapi.user.service.IUserInfoService; import com.ningdatech.zwdd.client.ZwddClient; import com.wflow.bean.entity.WflowCcTasks; -import com.wflow.bean.entity.WflowModelHistorys; import com.wflow.bean.entity.WflowModels; import com.wflow.contants.HisProInsEndActId; import com.wflow.exception.BusinessException; import com.wflow.mapper.WflowCcTasksMapper; import com.wflow.mapper.WflowModelHistorysMapper; -import com.wflow.utils.CodeUtil; import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; -import com.wflow.workflow.bean.process.ProcessNode; +import com.wflow.workflow.bean.process.ProgressNode; import com.wflow.workflow.bean.process.enums.ApprovalModeEnum; import com.wflow.workflow.bean.process.enums.NodeTypeEnum; -import com.wflow.workflow.bean.process.form.Form; import com.wflow.workflow.bean.process.props.ApprovalProps; import com.wflow.workflow.bean.vo.ProcessInstanceVo; +import com.wflow.workflow.bean.vo.ProcessProgressVo; import com.wflow.workflow.bean.vo.ProcessTaskVo; -import com.wflow.workflow.config.WflowGlobalVarDef; +import com.wflow.workflow.bean.vo.ProgressNodeAuditInfoVo; import com.wflow.workflow.enums.ProcessHandlerEnum; import com.wflow.workflow.enums.ProcessStatusEnum; import com.wflow.workflow.service.*; @@ -72,14 +67,12 @@ 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.history.HistoricTaskInstance; import org.flowable.variable.api.history.HistoricVariableInstance; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletResponse; import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -816,183 +809,25 @@ public class TodoCenterManage { * @return 流程进度及表单详情 */ public ProcessProgressDetailVo getProcessDetail(String instanceId, Long projectId) { - HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery() - .processInstanceId(instanceId) - .singleResult(); - // 取表单及表单数据 - HistoricVariableInstance forms = historyService.createHistoricVariableInstanceQuery() - .processInstanceId(instanceId) - .variableName(WflowGlobalVarDef.WFLOW_FORMS) - .singleResult(); - List formDatas = null; - - List historicTaskInstances = historyService.createHistoricTaskInstanceQuery() - .processInstanceId(instanceId).list(); - formDatas = historyService.createHistoricVariableInstanceQuery() - .executionIds(historicTaskInstances.stream() - .map(HistoricTaskInstance::getExecutionId) - .collect(Collectors.toSet())) - .processInstanceId(instanceId).list(); - - // 取节点设置 - HistoricVariableInstance nodeProps = historyService.createHistoricVariableInstanceQuery() - .processInstanceId(instanceId).variableName(WflowGlobalVarDef.WFLOW_NODE_PROPS).singleResult(); - Map nodePropsValue = (Map) nodeProps.getValue(); - - WflowModelHistorys modelHistory = modelHistorysMapper.selectOne(new QueryWrapper<>(WflowModelHistorys.builder() - .processDefId(instance.getProcessDefinitionId()) - .version(instance.getProcessDefinitionVersion()) - .build())); - ProcessNode currentNode = nodeCatchService.reloadProcessByStr(modelHistory.getProcess()).get("undefined"); - - //UserInfo userInfo = userInfoService.getById(Long.valueOf(instance.getStartUserId())); - //HashSet userSet = new HashSet<>(); - //userSet.add(String.valueOf(userInfo.getId())); - //Map userMap = userInfoService.getUserMapByIds(userSet); - //ProcessInstanceUserDto startUser = userMap.get(String.valueOf(userInfo.getId())); - List taskRecords = getHisTaskRecords(instanceId, nodePropsValue); - // 获取添加抄送任务 - taskRecords.addAll(getCcTaskRecords(instanceId)); - if (ObjectUtil.isNull(instance.getEndTime())) { - // TODO 下版实现 获取等待中且还未开始的任务,如果存在条件则需要直接解析条件 - taskRecords.addAll(getFutureTask(instanceId)); + ProcessProgressVo progressInstanceDetail = processInstanceService.getProgressInstanceDetail(null, instanceId); + List progressInfo = progressInstanceDetail.getProgressInfo(); + + Set userSet = progressInfo.stream().map(ProgressNode::getUserId).collect(Collectors.toSet()); + Map userMapByIds = userInfoService.getUserMapByIds(userSet); + + // 装配节点审核人员信息 + for (ProgressNode progressNode : progressInfo) { + progressNode.setUser(userMapByIds.get(progressNode.getUserId())); } - taskRecords = taskRecords.stream() - .sorted(Comparator.comparing(ProgressNode::getStartTime)) - .collect(Collectors.toList()); - taskRecords.add(0, ProgressNode.builder() - .nodeId("root") - .name("提交申请") - //.user(userInfoVO) - .nodeType(NodeTypeEnum.ROOT) - .startTime(instance.getStartTime()) - .finishTime(instance.getStartTime()) - .taskId("root") - .result(ProcessHandlerEnum.PASS).build()); - // 提取全量表单数据 - Map formData = formDatas.stream() - .filter(CodeUtil.distinctByKey(HistoricVariableInstance::getVariableName)) - .collect(Collectors.toMap(HistoricVariableInstance::getVariableName, HistoricVariableInstance::getValue)); - ProcessProgressDetailVo res = ProcessProgressDetailVo.builder() - .instanceId(instanceId) - .version(instance.getProcessDefinitionVersion()) - .formItems(formService.filterFormAndDataByPermConfig((List) forms.getValue(), formData, currentNode)) - .formData(formData).processDefName(instance.getProcessDefinitionName()) - .result(instance.getEndActivityId()) - .startTime(instance.getStartTime()) - .progress(taskRecords) - .build(); - //res.setStartUser(startUser); + progressInstanceDetail.setProgressInfo(progressInfo); + ProcessProgressDetailVo res = new ProcessProgressDetailVo(); + res.setProcessProgressVo(progressInstanceDetail); Project project = projectService.getById(projectId); res.setStatus(ProcessStatusEnum.getDescByCode(project.getProcessStatus())); return res; } /** - * 获取抄送的流程实例信息 - * - * @param instanceId 实例ID - * @return 抄送我的流程 - */ - private List getCcTaskRecords(String instanceId) { - Set ccUsers = new HashSet<>(); - List ccList = ccTasksMapper.selectList(new QueryWrapper() - .eq("instance_id", instanceId)) - .stream() - .map(task -> { - ccUsers.add(task.getUserId()); - return ProgressNode.builder().nodeId(task.getNodeId()).nodeType(NodeTypeEnum.CC) - .name(task.getNodeName()) - .user(ProcessInstanceUserDto.builder().userId(task.getUserId()).build()) - .startTime(task.getCreateTime()) - .finishTime(task.getCreateTime()) - .build(); - }).collect(Collectors.toList()); - if (isNotEmpty(ccUsers)) { - Map userMap = userInfoService.getUserMapByIds(ccUsers); - ccList.stream().peek(v -> v.setUser(userMap.get(v.getUser().getUserId()))).collect(Collectors.toList()); - } - return ccList; - } - - /** - * 获取流程的审批历史记录 - * - * @param instanceId 审批实例ID - * @param nodeProps 节点设置 - * @return 历史记录列表 - */ - private List getHisTaskRecords(String instanceId, Map nodeProps) { - List list = historyService.createHistoricActivityInstanceQuery() - .processInstanceId(instanceId).orderByHistoricActivityInstanceStartTime().asc().list(); - Set userSet = new HashSet<>(); - // 获取节点处理结果 - Map varMap = historyService.createHistoricVariableInstanceQuery() - .processInstanceId(instanceId) - .variableNameLike("approve_%") - .list().stream() - .collect(Collectors.toMap(HistoricVariableInstance::getVariableName, v -> (ProcessHandlerEnum) v.getValue())); - - Map> commentMap = new HashMap<>(); - // 统一处理所有评论数据,省的多次查询 - List cmvos = taskService.getProcessInstanceComments(instanceId).stream() - .map(comment -> { - userSet.add(comment.getUserId()); - ProgressNodeAuditInfoVo progressNodeAuditInfoVo = ProgressNodeAuditInfoVo.builder() - .id(comment.getId()) - .taskId(comment.getTaskId()) - .commentType(comment.getType()) - .type("COMMENT") - .createTime(comment.getTime()) - .user(ProcessInstanceUserDto.builder().userId(comment.getUserId()).build()) - .build(); - ProcessComment processComment = JSONObject.parseObject(comment.getFullMessage(), ProcessComment.class); - progressNodeAuditInfoVo.setText(processComment.getText()); - progressNodeAuditInfoVo.setAttachments(processComment.getAttachments()); - return progressNodeAuditInfoVo; - }).collect(Collectors.toList()); - cmvos.forEach(cm -> { - // 把评论数据按照task进行归类 - String taskId = Optional.ofNullable(cm.getTaskId()).orElse(instanceId); - List vos = commentMap.computeIfAbsent(taskId, k -> new ArrayList<>()); - vos.add(cm); - }); - // 再将评论按照任务一次构建,方便取出 - Map commentsMap = - cmvos.stream().collect(Collectors.toMap(ProgressNodeAuditInfoVo::getTaskId, c -> c)); - List progressNodes = list.stream().filter(his -> ObjectUtil.isNotNull(his.getTaskId())) - .map(his -> { - Object props = nodeProps.get(his.getActivityId()); - ApprovalModeEnum approvalMode = null; - if (props instanceof ApprovalProps) { - approvalMode = ((ApprovalProps) props).getMode(); - } - userSet.add(his.getAssignee()); - return ProgressNode.builder() - .nodeId(his.getActivityId()) - .name(his.getActivityName()) - .nodeType(NodeTypeEnum.APPROVAL) - .user(ProcessInstanceUserDto.builder().userId(his.getAssignee()).build()) - .startTime(his.getStartTime()) - .finishTime(his.getEndTime()) - .taskId(his.getTaskId()) - .approvalMode(approvalMode) - .auditInfo(commentsMap.get(his.getTaskId())) - .result(varMap.get("approve_" + his.getTaskId())).build(); - }).collect(Collectors.toList()); - if (isNotEmpty(userSet)) { - Map userMap = userInfoService.getUserMapByIds(userSet); - progressNodes.stream().peek(v -> v.setUser(userMap.get(v.getUser().getUserId()))).collect(Collectors.toList()); - } - return progressNodes; - } - - private List getFutureTask(String instanceId) { - // 根据流程遍历后续节点,期间要穿越后续包含并行网关和条件网关的节点 - return Collections.emptyList(); - } - - /** * 待办中心我已处理项目列表查询 * * @param param