|
|
@@ -1,14 +1,20 @@ |
|
|
|
package com.ningdatech.pmapi.projectlib.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.ningdatech.pmapi.performance.model.entity.ProjectCoreBusinessIndicators; |
|
|
|
import com.ningdatech.pmapi.performance.service.IProjectCoreBusinessIndicatorsService; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication; |
|
|
|
import com.ningdatech.pmapi.projectlib.mapper.ProjectApplicationMapper; |
|
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
/** |
|
|
|
* <p> |
|
|
@@ -19,7 +25,14 @@ import java.util.List; |
|
|
|
* @since 2023-02-05 |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class ProjectApplicationServiceImpl extends ServiceImpl<ProjectApplicationMapper, ProjectApplication> implements IProjectApplicationService { |
|
|
|
@Slf4j |
|
|
|
@AllArgsConstructor |
|
|
|
public class ProjectApplicationServiceImpl extends ServiceImpl<ProjectApplicationMapper, ProjectApplication> |
|
|
|
implements IProjectApplicationService { |
|
|
|
|
|
|
|
private final IProjectApplicationService applicationService; |
|
|
|
|
|
|
|
private final IProjectCoreBusinessIndicatorsService projectCoreBusinessIndicatorsService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<ProjectApplication> getApplicationsByProject(Project project) { |
|
|
@@ -27,4 +40,34 @@ public class ProjectApplicationServiceImpl extends ServiceImpl<ProjectApplicatio |
|
|
|
.eq(ProjectApplication::getProjectCode, project.getProjectCode())); |
|
|
|
return apps; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void saveApplication(Project project,Project oldProject,Boolean isConstruct) { |
|
|
|
List<ProjectApplication> apps = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) |
|
|
|
.eq(ProjectApplication::getProjectCode, oldProject.getProjectCode()) |
|
|
|
.eq(ProjectApplication::getProjectVersion, oldProject.getVersion())); |
|
|
|
if(CollUtil.isNotEmpty(apps)){ |
|
|
|
apps.forEach(app -> { |
|
|
|
Long oldAppId = app.getId(); |
|
|
|
app.setProjectVersion(project.getVersion()); |
|
|
|
app.setProjectId(project.getId()); |
|
|
|
app.setId(null); |
|
|
|
if(Objects.nonNull(isConstruct)){ |
|
|
|
app.setIsConstruct(isConstruct); |
|
|
|
} |
|
|
|
applicationService.save(app); |
|
|
|
|
|
|
|
//核心业务 |
|
|
|
List<ProjectCoreBusinessIndicators> cores = projectCoreBusinessIndicatorsService.list(Wrappers.lambdaQuery(ProjectCoreBusinessIndicators.class) |
|
|
|
.eq(ProjectCoreBusinessIndicators::getApplicationId, oldAppId)); |
|
|
|
if(CollUtil.isNotEmpty(cores)){ |
|
|
|
cores.forEach(c -> { |
|
|
|
c.setId(null); |
|
|
|
c.setApplicationId(app.getId()); |
|
|
|
projectCoreBusinessIndicatorsService.save(c); |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |