Browse Source

app删除bug

tags/24080901
PoffyZhang 1 year ago
parent
commit
7c9e61ad5d
3 changed files with 49 additions and 42 deletions
  1. +6
    -4
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java
  2. +35
    -13
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/HandlerManage.java
  3. +8
    -25
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java

+ 6
- 4
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java View File

@@ -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<ProjectApplication> applications = projectDto.getApplicationList().stream().map(application -> {
ProjectApplication projectApplication = new ProjectApplication();
BeanUtils.copyProperties(application, projectApplication);


+ 35
- 13
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/HandlerManage.java View File

@@ -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<HistoricVariableInstance> 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<Comment> 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;
}
}
}
}
}
}

+ 8
- 25
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java View File

@@ -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<Comment> 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<ProjectApplication> applications = projectDto.getApplicationList().stream().map(application -> {
ProjectApplication projectApplication = new ProjectApplication();


Loading…
Cancel
Save