From 7c9e61ad5d9ac20d97882448c615d942cab84d30 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Wed, 5 Apr 2023 12:19:30 +0800 Subject: [PATCH] =?UTF-8?q?app=E5=88=A0=E9=99=A4bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/DeclaredProjectManage.java | 10 +++-- .../pmapi/todocenter/manage/HandlerManage.java | 48 ++++++++++++++++------ .../pmapi/todocenter/manage/TodoCenterManage.java | 33 ++++----------- 3 files changed, 49 insertions(+), 42 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java index aa11d8e..e32c21e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java @@ -272,10 +272,12 @@ public class DeclaredProjectManage { project.setProjectCode(projectCode); projectService.saveOrUpdate(project); //保存项目应用 - if (CollUtil.isNotEmpty(projectDto.getApplicationList())) { - //采取批量删除 批量添加的方式 - projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class) - .eq(ProjectApplication::getProjectId,project.getId())); + Boolean isApp = Objects.nonNull(projectDto.getIncludeApplication()) && 1 == projectDto.getIncludeApplication() + ? Boolean.TRUE : Boolean.FALSE; + //采取批量删除 批量添加的方式 + projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class) + .eq(ProjectApplication::getProjectId,project.getId())); + if (isApp && CollUtil.isNotEmpty(projectDto.getApplicationList())) { List applications = projectDto.getApplicationList().stream().map(application -> { ProjectApplication projectApplication = new ProjectApplication(); BeanUtils.copyProperties(application, projectApplication); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/HandlerManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/HandlerManage.java index 297cf0c..81c259b 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/HandlerManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/HandlerManage.java @@ -1,5 +1,6 @@ package com.ningdatech.pmapi.todocenter.manage; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -43,21 +44,24 @@ import com.wflow.contants.WflowContant; import com.wflow.workflow.bean.process.ProgressNode; import com.wflow.workflow.bean.process.enums.NodeTypeEnum; import com.wflow.workflow.bean.vo.ProcessProgressVo; +import com.wflow.workflow.enums.ProcessHandlerEnum; import com.wflow.workflow.service.ProcessInstanceService; import com.wflow.workflow.service.ProcessTaskService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.flowable.engine.HistoryService; +import org.flowable.engine.RuntimeService; +import org.flowable.engine.TaskService; import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.engine.task.Comment; +import org.flowable.variable.api.history.HistoricVariableInstance; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; import static com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant.*; @@ -73,26 +77,20 @@ import static com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant.*; @Slf4j public class HandlerManage { - private final ProcessTaskService processTaskService; + private final RuntimeService runtimeService; + + private final TaskService taskService; private final HistoryService historyService; private final IUserInfoService userInfoService; private final IProjectService projectService; - private final ProjectLibManage projectLibManage; private final StateMachineUtils stateMachineUtils; private final IDingEmployeeInfoService dingEmployeeInfoService; private final IDingOrganizationService dingOrganizationService; private final ProcessInstanceService processInstanceService; private final INdWorkNoticeStagingService workNoticeStagingService; - private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; private final IProjectApplicationService projectApplicationService; - private final UserInfoHelper userInfoHelper; - private final BuildUserUtils buildUserUtils; private final IProjectStagingService projectStagingService; private final IProjectInstService projectInstService; - private final PdfUtils pdfUtils; - private final FileService fileService; - private final ICompanySignatureService companySignatureService; - private final StatisticsService statisticsService; private final INotifyService notifyService; private final DeclaredProjectManage declaredProjectManage; @@ -401,4 +399,28 @@ public class HandlerManage { workNoticeInfo.setReceiverUserId(receiverUserId); return workNoticeInfo; } + + public void deleteBackComments(List approves) { + if(CollUtil.isNotEmpty(approves)){ + for(HistoricVariableInstance approve : approves){ + if(approve.getValue() instanceof ProcessHandlerEnum){ + if(ProcessHandlerEnum.BACK.equals(ProcessHandlerEnum.getEnumByName(String.valueOf(approve.getValue())))){ + runtimeService.removeVariable(approve.getProcessInstanceId(),approve.getVariableName()); + + Comment comment; + Optional first = taskService.getProcessInstanceComments(approve.getProcessInstanceId()) + .stream() + .filter(c -> c.getTaskId().equals(approve.getVariableName().replace("approve_", StringUtils.EMPTY))) + .findFirst(); + if (first.isPresent()){ + comment = first.get(); + taskService.deleteComment(comment.getId()); + } + + break; + } + } + } + } + } } 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 f571c4a..4b9472e 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 @@ -891,27 +891,8 @@ public class TodoCenterManage { .processInstanceId(dto.getInstanceId()) .variableNameLike("approve_%") .list(); - if(CollUtil.isNotEmpty(approves)){ - for(HistoricVariableInstance approve : approves){ - if(approve.getValue() instanceof ProcessHandlerEnum){ - if(ProcessHandlerEnum.BACK.equals(ProcessHandlerEnum.getEnumByName(String.valueOf(approve.getValue())))){ - runtimeService.removeVariable(approve.getProcessInstanceId(),approve.getVariableName()); - - Comment comment; - Optional first = taskService.getProcessInstanceComments(approve.getProcessInstanceId()) - .stream() - .filter(c -> c.getTaskId().equals(approve.getVariableName().replace("approve_", StringUtils.EMPTY))) - .findFirst(); - if (first.isPresent()){ - comment = first.get(); - taskService.deleteComment(comment.getId()); - } - - break; - } - } - } - } + //删除 退回的评论和意见 + handlerManage.deleteBackComments(approves); // 更新当前流程状态为审核中 processTaskService.updateProInstStatus(dto.getInstanceId()); @@ -928,10 +909,12 @@ public class TodoCenterManage { throw new BusinessException("项目调整失败"); } //再修改应用信息 - if(CollUtil.isNotEmpty(projectDto.getApplicationList())){ - //采取批量删除 批量添加的方式 - projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class) - .eq(ProjectApplication::getProjectId,project.getId())); + Boolean isApp = Objects.nonNull(projectDto.getIncludeApplication()) && 1 == projectDto.getIncludeApplication() + ? Boolean.TRUE : Boolean.FALSE; + //批量删除 + projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class) + .eq(ProjectApplication::getProjectId,project.getId())); + if(isApp && CollUtil.isNotEmpty(projectDto.getApplicationList())){ //批量添加 List applications = projectDto.getApplicationList().stream().map(application -> { ProjectApplication projectApplication = new ProjectApplication();