diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java index 9816c39..f7546b3 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java @@ -497,16 +497,21 @@ public class ProjectLibManage { .ne(Project::getId, project.getId()) .eq(Project::getProjectCode, project.getProjectCode())); - //采取批量删除 批量添加的方式 批量删除建设方案申报后的应用信息 + //采取批量删除 批量添加的方式 批量删除建设方案申报后的应用信息及关联的核心业务 List projectCodeList = projectService.list(Wrappers.lambdaQuery(Project.class) .eq(Project::getProjectCode, project.getProjectCode()) .eq(Project::getIsConstruct, isConstruct)).stream() .map(Project::getProjectCode).collect(Collectors.toList()); - projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class) + + List applications = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) .eq(ProjectApplication::getProjectCode, project.getProjectCode()) .in(CollUtil.isNotEmpty(projectCodeList), ProjectApplication::getProjectCode, projectCodeList) - .eq(ProjectApplication::getIsConstruct, isConstruct) - .eq(ProjectApplication::getProjectVersion, project.getVersion())); + .eq(ProjectApplication::getProjectVersion, project.getVersion()) + .eq(ProjectApplication::getIsConstruct, Boolean.TRUE)); + projectApplicationService.removeBatchByIds(applications); + List applicationIds = applications.stream().map(ProjectApplication::getId).collect(Collectors.toList()); + projectCoreBusinessIndicatorsService.remove(Wrappers.lambdaQuery(ProjectCoreBusinessIndicators.class) + .in(ProjectCoreBusinessIndicators::getApplicationId,applicationIds)); //app List applicationList = projecDto.getApplicationList(); 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 bab2441..bfc5efb 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 @@ -17,7 +17,11 @@ import cn.hutool.core.util.ObjectUtil; import com.ningdatech.basic.exception.BizException; import com.ningdatech.pmapi.common.constant.RegionConst; import com.ningdatech.pmapi.common.enumeration.CommonEnum; +import com.ningdatech.pmapi.performance.model.dto.ProjectCoreBusinessDTO; +import com.ningdatech.pmapi.performance.model.entity.ProjectCoreBusinessIndicators; +import com.ningdatech.pmapi.performance.service.IProjectCoreBusinessIndicatorsService; import com.ningdatech.pmapi.projectlib.enumeration.*; +import com.ningdatech.pmapi.projectlib.model.dto.ProjectApplicationDTO; import com.ningdatech.pmapi.sys.model.entity.Region; import com.ningdatech.pmapi.sys.service.IRegionService; import com.ningdatech.pmapi.todocenter.constant.TodoCenterConstant; @@ -140,6 +144,7 @@ public class TodoCenterManage { private final IRegionService regionService; private final ITodoService todoService; + private final IProjectCoreBusinessIndicatorsService projectCoreBusinessIndicatorsService; /** * 待办中心待我处理项目列表查询 @@ -1115,19 +1120,23 @@ public class TodoCenterManage { //再修改应用信息 Boolean isApp = Objects.nonNull(projectDto.getIncludeApplication()) && 1 == projectDto.getIncludeApplication() ? Boolean.TRUE : Boolean.FALSE; - Long projectDtoId = projectDto.getId(); - Project projectInfo = projectService.getById(projectDtoId); ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class).eq(ProjectInst::getInstCode, instCode)); Integer instType = projectInst.getInstType(); //批量删除 - projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class) + List applicationList = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) .eq(ProjectApplication::getProjectCode, project.getProjectCode()) - .eq(ProjectApplication::getProjectVersion,project.getVersion())); - - if(isApp && CollUtil.isNotEmpty(projectDto.getApplicationList())){ - //批量添加 - List applications = projectDto.getApplicationList().stream().map(application -> { + .eq(ProjectApplication::getProjectVersion, project.getVersion()) + .eq(ProjectApplication::getIsConstruct, Boolean.TRUE)); + projectApplicationService.removeBatchByIds(applicationList); + List applicationIds = applicationList.stream().map(ProjectApplication::getId).collect(Collectors.toList()); + projectCoreBusinessIndicatorsService.remove(Wrappers.lambdaQuery(ProjectCoreBusinessIndicators.class) + .in(ProjectCoreBusinessIndicators::getApplicationId,applicationIds)); + + List applications = projectDto.getApplicationList(); + if(isApp && CollUtil.isNotEmpty(applications)){ + // 添加应用关联的核心业务 + for (ProjectApplicationDTO application : applications) { ProjectApplication projectApplication = new ProjectApplication(); BeanUtils.copyProperties(application, projectApplication); projectApplication.setId(null); @@ -1139,9 +1148,19 @@ public class TodoCenterManage { projectApplication.setIsConstruct(Boolean.TRUE); } projectApplication.setProjectVersion(project.getVersion()); - return projectApplication; - }).collect(Collectors.toList()); - projectApplicationService.saveBatch(applications); + boolean result = projectApplicationService.save(projectApplication); + // 保存应用关联的核心业务 + List coreBusinessList = application.getCoreBusinessList(); + Boolean hasCoreBusiness = CollUtil.isNotEmpty(coreBusinessList) ? Boolean.TRUE : Boolean.FALSE; + if (Boolean.TRUE.equals(result) && Boolean.TRUE.equals(hasCoreBusiness)){ + for (ProjectCoreBusinessDTO coreBusiness : coreBusinessList) { + ProjectCoreBusinessIndicators projectCoreBusinessIndicators = new ProjectCoreBusinessIndicators(); + BeanUtils.copyProperties(coreBusiness, projectCoreBusinessIndicators); + projectCoreBusinessIndicators.setApplicationId(application.getId()); + projectCoreBusinessIndicatorsService.save(projectCoreBusinessIndicators); + } + } + } } return Boolean.TRUE; }