diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectStateMachineBuilderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectStateMachineBuilderImpl.java
index f030f25..39ffb08 100644
--- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectStateMachineBuilderImpl.java
+++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectStateMachineBuilderImpl.java
@@ -115,7 +115,7 @@ public class ProjectStateMachineBuilderImpl implements BaseStateMachineBuilder
orgMap = declaredProjectHelper.buildOrgModelMap(user, project);
String instanceId = processInstanceService.startProcessLs(model, processParam, orgMap);
+ BeanUtils.copyProperties(reqProj, project);
+ projectStateMachineUtil.pass(project);
+ if (projectService.save(project)) {
+ projectSaveHelper.saveApplication(reqProj, project, null);
+ projectSaveHelper.savePaymentPlans(project, reqProj.getPaymentPlanList());
+ projectSaveHelper.saveGovSystemReplaceInfos(project.getId(), project.getProjectCode(), reqProj.getSystemReplaceInfos());
+ }
+
ProjectInst projectInst = new ProjectInst();
projectInst.setInstCode(instanceId);
projectInst.setInstType(ProjectProcessType.PROJECT_REVIEW);
- projectInst.setProjectId(req.getProjectId());
+ projectInst.setProjectId(reqProj.getId());
projectInstService.save(projectInst);
projectStateMachineUtil.pass(project);
projectService.updateById(project);
- ProjectReview projReview = projectReviewService.getOne(Wrappers
- .lambdaQuery(ProjectReview.class)
- .eq(ProjectReview::getProjectId, req.getProjectId())
- .orderByDesc(ProjectReview::getId)
- .last(BizConst.LIMIT_1));
- if (projReview == null) {
- projReview = new ProjectReview();
- projReview.setProjectCode(project.getProjectCode());
- }
- BeanUtil.copyProperties(req, projReview);
- projectReviewService.saveOrUpdate(projReview);
log.info("项目评审提交成功 【{}】", instanceId);
}
diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectChangeStopHelper.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectChangeStopHelper.java
index d02a649..e061045 100644
--- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectChangeStopHelper.java
+++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectChangeStopHelper.java
@@ -12,17 +12,12 @@ import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent;
import com.hz.pm.api.common.statemachine.event.TenderStateChangeEvent;
import com.hz.pm.api.common.util.BizUtils;
-import com.hz.pm.api.projectdeclared.model.entity.ProjectChangeHistory;
import com.hz.pm.api.projectdeclared.model.dto.*;
-import com.hz.pm.api.projectdeclared.model.entity.Contract;
-import com.hz.pm.api.projectdeclared.model.entity.Operation;
-import com.hz.pm.api.projectdeclared.model.entity.PreInsAcceptancePerson;
-import com.hz.pm.api.projectdeclared.model.entity.Purchase;
+import com.hz.pm.api.projectdeclared.model.entity.*;
import com.hz.pm.api.projectdeclared.model.vo.PreInsAcceptancePersonVO;
import com.hz.pm.api.projectdeclared.service.*;
import com.hz.pm.api.projectdeclared.utils.ProjectDetailDiffUtil.FieldDiff;
import com.hz.pm.api.projectlib.entity.PurchaseStatusChange;
-import com.hz.pm.api.projectlib.manage.ProjectLibManage;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange;
import com.hz.pm.api.projectlib.model.enumeration.status.*;
@@ -59,7 +54,7 @@ public class ProjectChangeStopHelper {
private final IOperationService operationService;
private final IContractService contractService;
private final IProjectService projectService;
- private final ProjectLibManage projectLibManage;
+ private final ProjectSaveHelper projectSaveHelper;
/**
* 根据状态变更记录重置项目、标段状态
@@ -230,7 +225,7 @@ public class ProjectChangeStopHelper {
FieldDiff systemReplaceInfos = CollUtil.findOne(projectDiffs,
w -> w.getFieldName().equals(EditProjectDTO.SYSTEM_REPLACE_INFOS));
if (systemReplaceInfos != null) {
- projectLibManage.saveGovSystemReplaceInfos(projectDetail.getId(),
+ projectSaveHelper.saveGovSystemReplaceInfos(projectDetail.getId(),
projectCode, projectDetail.getSystemReplaceInfos());
}
UpdateWrapper wrapper = buildWrapper(projectDiffs, Project.class);
diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectSaveHelper.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectSaveHelper.java
new file mode 100644
index 0000000..3342d77
--- /dev/null
+++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectSaveHelper.java
@@ -0,0 +1,168 @@
+package com.hz.pm.api.projectlib.helper;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ArrayUtil;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.hz.pm.api.common.enumeration.CommonEnum;
+import com.hz.pm.api.performance.model.dto.ProjectCoreBusinessDTO;
+import com.hz.pm.api.performance.model.entity.ProjectCoreBusinessIndicators;
+import com.hz.pm.api.performance.service.IProjectCoreBusinessIndicatorsService;
+import com.hz.pm.api.projectlib.entity.ProjectGovSystemReplaceInfos;
+import com.hz.pm.api.projectlib.model.dto.GovSystemReplaceInfoDTO;
+import com.hz.pm.api.projectlib.model.dto.ProjectDTO;
+import com.hz.pm.api.projectlib.model.dto.ProjectPaymentPlanDTO;
+import com.hz.pm.api.projectlib.model.entity.Project;
+import com.hz.pm.api.projectlib.model.entity.ProjectAnnualPaymentPlan;
+import com.hz.pm.api.projectlib.model.entity.ProjectApplication;
+import com.hz.pm.api.projectlib.service.IProjectAnnualPaymentPlanService;
+import com.hz.pm.api.projectlib.service.IProjectApplicationService;
+import com.hz.pm.api.projectlib.service.IProjectGovSystemReplaceInfosService;
+import com.hz.pm.api.user.security.model.UserInfoDetails;
+import com.hz.pm.api.user.util.LoginUserUtil;
+import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ *
+ * ProjectSaveHelper
+ *
+ *
+ * @author WendyYang
+ * @since 16:12 2024/9/26
+ */
+@Component
+@RequiredArgsConstructor
+public class ProjectSaveHelper {
+
+ private final IProjectApplicationService projectApplicationService;
+ private final IProjectGovSystemReplaceInfosService projectGovSystemReplaceInfosService;
+ private final IProjectCoreBusinessIndicatorsService projectCoreBusinessIndicatorsService;
+ private final IProjectAnnualPaymentPlanService projectAnnualPaymentPlanService;
+
+ public void savePaymentPlans(Project project, List paymentPlans) {
+ if (CollUtil.isEmpty(paymentPlans)) {
+ return;
+ }
+ Integer version = Objects.nonNull(project.getVersion()) ? project.getVersion() : 1;
+ projectAnnualPaymentPlanService.remove(project.getProjectCode(), version);
+ List plans = paymentPlans.stream().map(w -> {
+ ProjectAnnualPaymentPlan plan = BeanUtil.copyProperties(w, ProjectAnnualPaymentPlan.class);
+ plan.setProjectCode(project.getProjectCode());
+ plan.setProjectVersion(version);
+ return plan;
+ }).collect(Collectors.toList());
+ projectAnnualPaymentPlanService.saveBatch(plans);
+ }
+
+ public void saveApplication(Project project, Project oldProject, Boolean isConstruct) {
+ List apps = projectApplicationService.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);
+ }
+ projectApplicationService.save(app);
+
+ //核心业务
+ List 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);
+ });
+ }
+ });
+ }
+ }
+
+ public void saveApplication(ProjectDTO projectDto, Project project, Boolean isConstruct) {
+ UserInfoDetails user = LoginUserUtil.loginUserDetail();
+ //保存项目应用
+ boolean isApp = Objects.nonNull(projectDto.getIncludeApplication()) && CommonEnum.YES.getCode().equals(projectDto.getIncludeApplication())
+ ? Boolean.TRUE : Boolean.FALSE;
+ //采取批量删除 批量添加的方式
+ Integer version = Objects.nonNull(project.getVersion()) ? project.getVersion() : 1;
+ //删除当前版本的app 一般情况是没有 保险起见
+ projectApplicationService.remove(project.getProjectCode(), version);
+ if (isApp && CollUtil.isNotEmpty(projectDto.getApplicationList())) {
+ projectDto.getApplicationList().forEach(application -> {
+ ProjectApplication projectApplication = new ProjectApplication();
+ BeanUtils.copyProperties(application, projectApplication);
+ projectApplication.setId(null);
+ projectApplication.setProjectId(project.getId());
+ projectApplication.setProjectCode(project.getProjectCode());
+ projectApplication.setBuildOrgCode(project.getBuildOrgCode());
+ projectApplication.setBuildOrgName(project.getBuildOrgName());
+ projectApplication.setProjectVersion(version);
+ projectApplication.setIsConstruct(isConstruct);
+ if (StringUtils.isNotBlank(application.getRelatedExistsApplication())) {
+ projectApplication.setApplicationName(null);
+ }
+ 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.setId(null);
+ projectCoreBusinessIndicators.setApplicationId(projectApplication.getId());
+ projectCoreBusinessIndicators.setCreateOn(LocalDateTime.now());
+ projectCoreBusinessIndicators.setCreateBy(user.getUsername());
+ projectCoreBusinessIndicatorsService.save(projectCoreBusinessIndicators);
+ }
+ }
+ });
+ }
+ }
+
+
+ public void saveGovSystemReplaceInfos(Long projectId,
+ String projectCode,
+ List systemReplaceInfos) {
+ Wrapper delQuery = Wrappers.lambdaQuery(ProjectGovSystemReplaceInfos.class)
+ .eq(ProjectGovSystemReplaceInfos::getProjectCode, projectCode);
+ projectGovSystemReplaceInfosService.remove(delQuery);
+ if (CollUtil.isEmpty(systemReplaceInfos)) {
+ return;
+ }
+ List replaceInfos = new ArrayList<>();
+ for (int i = 0; i < systemReplaceInfos.size(); i++) {
+ GovSystemReplaceInfoDTO curr = systemReplaceInfos.get(i);
+ for (int i1 = 0; i1 < curr.getSourceSystemNames().size(); i1++) {
+ ProjectGovSystemReplaceInfos replaceInfo = new ProjectGovSystemReplaceInfos();
+ replaceInfo.setProjectId(projectId);
+ replaceInfo.setProjectCode(projectCode);
+ replaceInfo.setReplaceType(curr.getReplaceType());
+ replaceInfo.setSourceSystem(curr.getSourceSystemNames().get(i1));
+ replaceInfo.setTargetSystem(curr.getTargetSystemName());
+ replaceInfo.setBatchNo(i + 1);
+ if (ArrayUtil.isNotEmpty(curr.getSourceSystemIds())) {
+ replaceInfo.setSourceSystemId(curr.getSourceSystemIds().get(i1));
+ }
+ replaceInfos.add(replaceInfo);
+ }
+ }
+ projectGovSystemReplaceInfosService.saveBatch(replaceInfos);
+ }
+
+}
diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java
index 41049ac..81712e3 100644
--- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java
+++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java
@@ -18,7 +18,9 @@ import com.hz.pm.api.common.compare.CompareUtils;
import com.hz.pm.api.common.enumeration.CommonEnum;
import com.hz.pm.api.common.enumeration.ProjectProcessType;
import com.hz.pm.api.common.helper.UserInfoHelper;
+import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.model.constant.CommonConst;
+import com.hz.pm.api.common.model.constant.ExistsSqlConst;
import com.hz.pm.api.common.model.entity.ExcelExportWriter;
import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil;
import com.hz.pm.api.common.util.BizUtils;
@@ -31,7 +33,9 @@ import com.hz.pm.api.expert.model.enumeration.ReviewTemplateTypeEnum;
import com.hz.pm.api.expert.service.IExpertReviewService;
import com.hz.pm.api.filemanage.model.entity.ProjectApplyBorrow;
import com.hz.pm.api.filemanage.service.INdProjectApplyBorrowService;
+import com.hz.pm.api.meeting.entity.domain.MeetingInnerProject;
import com.hz.pm.api.meeting.entity.dto.ProjectReviewResultDTO;
+import com.hz.pm.api.meeting.service.IMeetingInnerProjectService;
import com.hz.pm.api.performance.model.dto.ProjectCoreBusinessDTO;
import com.hz.pm.api.performance.model.entity.ProjectCoreBusinessIndicators;
import com.hz.pm.api.performance.service.IProjectCoreBusinessIndicatorsService;
@@ -55,6 +59,7 @@ import com.hz.pm.api.projectdeclared.utils.ProjectIdCodeCacheUtil;
import com.hz.pm.api.projectlib.entity.ProjectGovSystemReplaceInfos;
import com.hz.pm.api.projectlib.handle.ProcessProgressHelper;
import com.hz.pm.api.projectlib.helper.ProjectManageUtil;
+import com.hz.pm.api.projectlib.helper.ProjectSaveHelper;
import com.hz.pm.api.projectlib.model.constant.ProjectConstant;
import com.hz.pm.api.projectlib.model.dto.GovSystemReplaceInfoDTO;
import com.hz.pm.api.projectlib.model.dto.ProjectDTO;
@@ -112,6 +117,7 @@ import java.util.stream.Collectors;
@Slf4j
public class ProjectLibManage {
+ private final ProjectSaveHelper projectSaveHelper;
private final IProjectService projectService;
private final IProjectApplicationService applicationService;
private final IProjectRenewalFundDeclarationService renewalFundDeclarationService;
@@ -140,6 +146,7 @@ public class ProjectLibManage {
private final IMhProjectSchemaTargetDataService projectSchemaTargetDataService;
private final IMhProjectService mhProjectService;
private final ProjectReviewManage projectReviewManage;
+ private final IMeetingInnerProjectService meetingInnerProjectService;
public PageVo projectLibList(ProjectListReq req) {
LambdaQueryWrapper query = ProjectManageUtil.projectQuery(req);
@@ -785,8 +792,13 @@ public class ProjectLibManage {
}
// 评审详情
- ProjectReviewResultDTO projectReviewDetail = projectReviewManage.projectReviewDetail(project.getId());
- retProjectDetail.setReviewDetail(projectReviewDetail);
+ Wrapper mipQuery = Wrappers.lambdaQuery(MeetingInnerProject.class)
+ .eq(MeetingInnerProject::getProjectCode, project.getProjectCode())
+ .notExists(ExistsSqlConst.MEETING_INNER_PROJECT_EXISTS_MEETING + "and m.status != 3")
+ .orderByDesc(MeetingInnerProject::getId)
+ .last(BizConst.LIMIT_1);
+ MeetingInnerProject mip = meetingInnerProjectService.getOne(mipQuery);
+ retProjectDetail.setReviewDetail(BeanUtil.copyProperties(mip, ProjectReviewResultDTO.class));
return retProjectDetail;
}
@@ -867,9 +879,9 @@ public class ProjectLibManage {
project.setNewest(Boolean.TRUE);
projectStateMachineUtil.pass(project);
if (projectService.save(project)) {
- saveApplication(projectDto, project, null);
- savePaymentPlans(project, projectDto.getPaymentPlanList());
- saveGovSystemReplaceInfos(project.getId(), project.getProjectCode(), projectDto.getSystemReplaceInfos());
+ projectSaveHelper.saveApplication(projectDto, project, null);
+ projectSaveHelper.savePaymentPlans(project, projectDto.getPaymentPlanList());
+ projectSaveHelper.saveGovSystemReplaceInfos(project.getId(), project.getProjectCode(), projectDto.getSystemReplaceInfos());
}
} else {
//否则是重新提交的 新生成一个新版本的项目
@@ -887,20 +899,6 @@ public class ProjectLibManage {
}
}
- private void savePaymentPlans(Project project, List paymentPlans) {
- if (CollUtil.isEmpty(paymentPlans)) {
- return;
- }
- Integer version = Objects.nonNull(project.getVersion()) ? project.getVersion() : 1;
- projectAnnualPaymentPlanService.remove(project.getProjectCode(), version);
- List plans = paymentPlans.stream().map(w -> {
- ProjectAnnualPaymentPlan plan = BeanUtil.copyProperties(w, ProjectAnnualPaymentPlan.class);
- plan.setProjectCode(project.getProjectCode());
- plan.setProjectVersion(version);
- return plan;
- }).collect(Collectors.toList());
- projectAnnualPaymentPlanService.saveBatch(plans);
- }
/**
* 在其它项目阶段 保存项目信息和其它相关联的信息
@@ -940,40 +938,12 @@ public class ProjectLibManage {
oldProj.setIsBackReject(Boolean.TRUE);
projectService.updateById(oldProj);
projectService.reverseNewest(newProj.getProjectCode(), newProj.getId());
- saveApplication(reqProj, newProj, isConstruct);
- savePaymentPlans(newProj, reqProj.getPaymentPlanList());
- saveGovSystemReplaceInfos(newProj.getId(), newProj.getProjectCode(), reqProj.getSystemReplaceInfos());
+ projectSaveHelper.saveApplication(reqProj, newProj, isConstruct);
+ projectSaveHelper.savePaymentPlans(newProj, reqProj.getPaymentPlanList());
+ projectSaveHelper.saveGovSystemReplaceInfos(newProj.getId(), newProj.getProjectCode(), reqProj.getSystemReplaceInfos());
return newProj;
}
- public void saveGovSystemReplaceInfos(Long projectId,
- String projectCode,
- List systemReplaceInfos) {
- Wrapper delQuery = Wrappers.lambdaQuery(ProjectGovSystemReplaceInfos.class)
- .eq(ProjectGovSystemReplaceInfos::getProjectCode, projectCode);
- projectGovSystemReplaceInfosService.remove(delQuery);
- if (CollUtil.isEmpty(systemReplaceInfos)) {
- return;
- }
- List replaceInfos = new ArrayList<>();
- for (int i = 0; i < systemReplaceInfos.size(); i++) {
- GovSystemReplaceInfoDTO curr = systemReplaceInfos.get(i);
- for (int i1 = 0; i1 < curr.getSourceSystemNames().size(); i1++) {
- ProjectGovSystemReplaceInfos replaceInfo = new ProjectGovSystemReplaceInfos();
- replaceInfo.setProjectId(projectId);
- replaceInfo.setProjectCode(projectCode);
- replaceInfo.setReplaceType(curr.getReplaceType());
- replaceInfo.setSourceSystem(curr.getSourceSystemNames().get(i1));
- replaceInfo.setTargetSystem(curr.getTargetSystemName());
- replaceInfo.setBatchNo(i + 1);
- if (ArrayUtil.isNotEmpty(curr.getSourceSystemIds())) {
- replaceInfo.setSourceSystemId(curr.getSourceSystemIds().get(i1));
- }
- replaceInfos.add(replaceInfo);
- }
- }
- projectGovSystemReplaceInfosService.saveBatch(replaceInfos);
- }
public Project saveProjectWithVersionAndStatus(ProjectDTO projectDto, Integer stageCode, Integer statusCode, Boolean isConstruct) {
Project oldProject = projectService.getNoNull(projectDto.getId());
@@ -1000,7 +970,7 @@ public class ProjectLibManage {
if (projectService.save(project)) {
projectService.reverseNewest(project.getProjectCode(), project.getId());
- saveApplication(projectDto, project, isConstruct);
+ projectSaveHelper.saveApplication(projectDto, project, isConstruct);
}
return project;
@@ -1031,7 +1001,7 @@ public class ProjectLibManage {
projectService.reverseNewest(project.getProjectCode(), project.getId());
//app
- saveApplication(projectDto, project, isConstruct);
+ projectSaveHelper.saveApplication(projectDto, project, isConstruct);
}
return project;
@@ -1055,10 +1025,8 @@ public class ProjectLibManage {
projectInst.setInstCode(instanceId);
projectInst.setInstType(instType);
projectInstService.save(projectInst);
-
projectService.reverseNewest(project.getProjectCode(), project.getId());
-
- saveApplication(project, oldProject, null);
+ projectSaveHelper.saveApplication(project, oldProject, null);
}
return project;
@@ -1096,7 +1064,7 @@ public class ProjectLibManage {
projectService.reverseNewest(project.getProjectCode(), project.getId());
//APP
- saveApplication(project, oldProject, Boolean.TRUE);
+ projectSaveHelper.saveApplication(project, oldProject, Boolean.TRUE);
}
return project;
@@ -1127,10 +1095,8 @@ public class ProjectLibManage {
projectInst.setInstCode(instanceId);
projectInst.setInstType(instType);
projectInstService.save(projectInst);
-
projectService.reverseNewest(project.getProjectCode(), project.getId());
-
- saveApplication(project, oldProject, Boolean.TRUE);
+ projectSaveHelper.saveApplication(project, oldProject, Boolean.TRUE);
}
return project;
}
@@ -1464,75 +1430,5 @@ public class ProjectLibManage {
return res;
}
- public void saveApplication(Project project, Project oldProject, Boolean isConstruct) {
- List apps = projectApplicationService.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);
- }
- projectApplicationService.save(app);
-
- //核心业务
- List 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);
- });
- }
- });
- }
- }
-
- private void saveApplication(ProjectDTO projectDto, Project project, Boolean isConstruct) {
- UserInfoDetails user = LoginUserUtil.loginUserDetail();
- //保存项目应用
- boolean isApp = Objects.nonNull(projectDto.getIncludeApplication()) && CommonEnum.YES.getCode().equals(projectDto.getIncludeApplication())
- ? Boolean.TRUE : Boolean.FALSE;
- //采取批量删除 批量添加的方式
- Integer version = Objects.nonNull(project.getVersion()) ? project.getVersion() : 1;
- //删除当前版本的app 一般情况是没有 保险起见
- projectApplicationService.remove(project.getProjectCode(), version);
- if (isApp && CollUtil.isNotEmpty(projectDto.getApplicationList())) {
- projectDto.getApplicationList().forEach(application -> {
- ProjectApplication projectApplication = new ProjectApplication();
- BeanUtils.copyProperties(application, projectApplication);
- projectApplication.setId(null);
- projectApplication.setProjectId(project.getId());
- projectApplication.setProjectCode(project.getProjectCode());
- projectApplication.setBuildOrgCode(project.getBuildOrgCode());
- projectApplication.setBuildOrgName(project.getBuildOrgName());
- projectApplication.setProjectVersion(version);
- projectApplication.setIsConstruct(isConstruct);
- if (StringUtils.isNotBlank(application.getRelatedExistsApplication())) {
- projectApplication.setApplicationName(null);
- }
- 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.setId(null);
- projectCoreBusinessIndicators.setApplicationId(projectApplication.getId());
- projectCoreBusinessIndicators.setCreateOn(LocalDateTime.now());
- projectCoreBusinessIndicators.setCreateBy(user.getUsername());
- projectCoreBusinessIndicatorsService.save(projectCoreBusinessIndicators);
- }
- }
- });
- }
- }
}