diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectHelper.java
index c938cb0..0ce4d34 100644
--- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectHelper.java
+++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectHelper.java
@@ -1,5 +1,6 @@
package com.ningdatech.pmapi.projectlib.helper;
+import com.ningdatech.pmapi.performance.model.entity.ProjectCoreBusinessIndicators;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@@ -11,6 +12,9 @@ import com.ningdatech.pmapi.projectlib.model.vo.ProjectApplicationVO;
import cn.hutool.core.collection.CollUtil;
+import java.util.List;
+import java.util.Map;
+
/**
*
* ProjectHelper
@@ -65,6 +69,16 @@ public class ProjectHelper {
* @param app
* @return
*/
+ public static ProjectApplicationVO convertVOWithMap(ProjectApplication app,
+ Map> coreBizMap) {
+ ProjectApplicationVO appVo = new ProjectApplicationVO();
+ BeanUtils.copyProperties(app, appVo);
+ if(coreBizMap.containsKey(app.getId())){
+ List projectCoreBusinessIndicators = coreBizMap.get(app.getId());
+ appVo.setCoreBusinessList(projectCoreBusinessIndicators);
+ }
+ return appVo;
+ }
public static ProjectApplicationVO convertVO(ProjectApplication app) {
ProjectApplicationVO appVo = new ProjectApplicationVO();
BeanUtils.copyProperties(app, appVo);
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 38bf858..7188905 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
@@ -69,6 +69,7 @@ import com.ningdatech.pmapi.safety.service.ISupplierSafetyQualificationService;
import com.ningdatech.pmapi.todocenter.model.req.ProcessDetailReq;
import com.ningdatech.pmapi.todocenter.service.ITodoService;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
+import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import com.wflow.exception.BusinessException;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
@@ -260,9 +261,16 @@ public class ProjectLibManage {
.eq(ProjectApplication::getIsConstruct, projectInfo.getIsConstruct())
.eq(ProjectApplication::getProjectVersion, projectInfo.getVersion()));
+ List applicationIds = applications.stream().map(ProjectApplication::getId).collect(Collectors.toList());
+
+ //核心业务
+ List coreBizs = projectCoreBusinessIndicatorsService.list(Wrappers.lambdaQuery(ProjectCoreBusinessIndicators.class)
+ .in(ProjectCoreBusinessIndicators::getApplicationId, applicationIds));
+ Map> coreBizMap = coreBizs.stream().collect(Collectors.groupingBy(ProjectCoreBusinessIndicators::getApplicationId));
+
Optional.ofNullable(applications).ifPresent(apps ->
vo.setProjectApplications(CollUtils.convert(apps,
- ProjectHelper::convertVO)
+ app -> ProjectHelper.convertVOWithMap(app,coreBizMap))
));
List allVersionProjectId = projectService.getAllVersionProjectId(projectInfo);
@@ -373,9 +381,16 @@ public class ProjectLibManage {
.eq(ProjectApplication::getIsConstruct, projectInfo.getIsConstruct())
.eq(ProjectApplication::getProjectVersion, projectInfo.getVersion()));
+ List applicationIds = applications.stream().map(ProjectApplication::getId).collect(Collectors.toList());
+
+ //核心业务
+ List coreBizs = projectCoreBusinessIndicatorsService.list(Wrappers.lambdaQuery(ProjectCoreBusinessIndicators.class)
+ .in(ProjectCoreBusinessIndicators::getApplicationId, applicationIds));
+ Map> coreBizMap = coreBizs.stream().collect(Collectors.groupingBy(ProjectCoreBusinessIndicators::getApplicationId));
+
Optional.ofNullable(applications).ifPresent(apps ->
vo.setProjectApplications(CollUtils.convert(apps,
- ProjectHelper::convertVO)
+ app -> ProjectHelper.convertVOWithMap(app,coreBizMap))
));
//审批信息
@@ -1208,20 +1223,32 @@ public class ProjectLibManage {
.eq(ProjectApplication::getProjectCode, oldProject.getProjectCode())
.eq(ProjectApplication::getProjectVersion, oldProject.getVersion()));
if(CollUtil.isNotEmpty(apps)){
- apps = apps.stream().map(app -> {
+ 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);
}
- return app;
- }).collect(Collectors.toList());
- projectApplicationService.saveBatch(apps);
+ 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;
@@ -1233,9 +1260,6 @@ public class ProjectLibManage {
.eq(ProjectApplication::getProjectVersion, version));
if (CollUtil.isNotEmpty(applications)) {
projectApplicationService.removeBatchByIds(applications);
- List applicationIds = applications.stream().map(ProjectApplication::getId).collect(Collectors.toList());
- projectCoreBusinessIndicatorsService.remove(Wrappers.lambdaQuery(ProjectCoreBusinessIndicators.class)
- .in(ProjectCoreBusinessIndicators::getApplicationId, applicationIds));
}
if (isApp && CollUtil.isNotEmpty(projectDto.getApplicationList())) {
@@ -1262,7 +1286,9 @@ public class ProjectLibManage {
for (ProjectCoreBusinessDTO coreBusiness : coreBusinessList) {
ProjectCoreBusinessIndicators projectCoreBusinessIndicators = new ProjectCoreBusinessIndicators();
BeanUtils.copyProperties(coreBusiness, projectCoreBusinessIndicators);
- projectCoreBusinessIndicators.setApplicationId(application.getId());
+ projectCoreBusinessIndicators.setApplicationId(projectApplication.getId());
+ projectCoreBusinessIndicators.setCreateOn(LocalDateTime.now());
+ projectCoreBusinessIndicators.setCreateBy(user.getUsername());
projectCoreBusinessIndicatorsService.save(projectCoreBusinessIndicators);
}
}
diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectApplication.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectApplication.java
index f7f0a39..7ef8ca7 100644
--- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectApplication.java
+++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectApplication.java
@@ -187,4 +187,7 @@ public class ProjectApplication implements Serializable {
@ApiModelProperty("是否为建设方案申报")
private Boolean isConstruct;
+
+ @ApiModelProperty("应用核心业务")
+ private Boolean coreBusinessList;
}
diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectApplicationVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectApplicationVO.java
index 1aaa996..709544d 100644
--- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectApplicationVO.java
+++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectApplicationVO.java
@@ -1,11 +1,13 @@
package com.ningdatech.pmapi.projectlib.model.vo;
+import com.ningdatech.pmapi.performance.model.entity.ProjectCoreBusinessIndicators;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
+import java.util.List;
/**
*
@@ -177,8 +179,10 @@ public class ProjectApplicationVO implements Serializable {
@ApiModelProperty("项目版本")
private Integer projectVersion;
+ @ApiModelProperty("应用核心业务")
+ private List coreBusinessList;
+
private Long createBy;
private Long updateBy;
-
}