Browse Source

应用是否是 建设方案的

master
PoffyZhang 1 year ago
parent
commit
19e93deb0f
4 changed files with 67 additions and 20 deletions
  1. +14
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectHelper.java
  2. +45
    -19
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java
  3. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectApplication.java
  4. +5
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectApplicationVO.java

+ 14
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectHelper.java View File

@@ -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;

/**
* <p>
* ProjectHelper
@@ -65,6 +69,16 @@ public class ProjectHelper {
* @param app
* @return
*/
public static ProjectApplicationVO convertVOWithMap(ProjectApplication app,
Map<Long, List<ProjectCoreBusinessIndicators>> coreBizMap) {
ProjectApplicationVO appVo = new ProjectApplicationVO();
BeanUtils.copyProperties(app, appVo);
if(coreBizMap.containsKey(app.getId())){
List<ProjectCoreBusinessIndicators> projectCoreBusinessIndicators = coreBizMap.get(app.getId());
appVo.setCoreBusinessList(projectCoreBusinessIndicators);
}
return appVo;
}
public static ProjectApplicationVO convertVO(ProjectApplication app) {
ProjectApplicationVO appVo = new ProjectApplicationVO();
BeanUtils.copyProperties(app, appVo);


+ 45
- 19
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java View File

@@ -70,6 +70,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<Long> applicationIds = applications.stream().map(ProjectApplication::getId).collect(Collectors.toList());

//核心业务
List<ProjectCoreBusinessIndicators> coreBizs = projectCoreBusinessIndicatorsService.list(Wrappers.lambdaQuery(ProjectCoreBusinessIndicators.class)
.in(ProjectCoreBusinessIndicators::getApplicationId, applicationIds));
Map<Long,List<ProjectCoreBusinessIndicators>> 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<Long> allVersionProjectId = projectService.getAllVersionProjectId(projectInfo);
@@ -373,9 +381,16 @@ public class ProjectLibManage {
.eq(ProjectApplication::getIsConstruct, projectInfo.getIsConstruct())
.eq(ProjectApplication::getProjectVersion, projectInfo.getVersion()));

List<Long> applicationIds = applications.stream().map(ProjectApplication::getId).collect(Collectors.toList());

//核心业务
List<ProjectCoreBusinessIndicators> coreBizs = projectCoreBusinessIndicatorsService.list(Wrappers.lambdaQuery(ProjectCoreBusinessIndicators.class)
.in(ProjectCoreBusinessIndicators::getApplicationId, applicationIds));
Map<Long,List<ProjectCoreBusinessIndicators>> 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))
));

//审批信息
@@ -481,7 +496,7 @@ public class ProjectLibManage {
*/
public Project saveProjectInDeclared(ProjectDTO projectDto, String instanceId,
String employeeCode) {
Project project = saveProjectNewVersion(projectDto, instanceId, employeeCode);
Project project = saveProjectNewVersion(projectDto, instanceId, employeeCode,Boolean.FALSE);
//保存项目和实例的关系
ProjectInst projectInst = new ProjectInst();
projectInst.setProjectId(project.getId());
@@ -533,7 +548,7 @@ public class ProjectLibManage {
* @return
*/
public Project saveProjectNewVersion(ProjectDTO projectDto, String instanceId,
String employeeCode) {
String employeeCode,Boolean isContruct) {
//流程启动之后 入库项目 重要业务信息 用于列表查询 展示
try {
Project project = new Project();
@@ -553,7 +568,7 @@ public class ProjectLibManage {
}
} else {
//否则是重新提交的 新生成一个新版本的项目
project = newProjectWithVersion(projectDto);
project = newProjectWithVersion(projectDto,isContruct);
if (Objects.nonNull(project)) {
project.setInstCode(instanceId);
project.setSponsor(employeeCode);
@@ -606,7 +621,7 @@ public class ProjectLibManage {
project.setPrePlanProjectId(oldProject.getId());
}
if(projectService.save(project)){
saveApplication(projectDto,project,null);
saveApplication(projectDto,project,Boolean.TRUE);

// 将旧的项目版本置为不是最新
projectService.update(Wrappers.lambdaUpdate(Project.class)
@@ -617,7 +632,7 @@ public class ProjectLibManage {

} else {
//否则是被驳回,重新提交的 新生成一个新版本的项目
project = newProjectWithVersion(projectDto);
project = newProjectWithVersion(projectDto,Boolean.TRUE);
if (Objects.nonNull(project)) {
project.setInstCode(instanceId);
project.setSponsor(employeeCode);
@@ -638,10 +653,10 @@ public class ProjectLibManage {
* @param projectDto
* @return
*/
public Project reSaveProjectNewVersion(ProjectDTO projectDto) {
public Project reSaveProjectNewVersion(ProjectDTO projectDto,Boolean isContruct) {
//流程启动之后 入库项目 重要业务信息 用于列表查询 展示
try {
return newProjectWithVersion(projectDto);
return newProjectWithVersion(projectDto,isContruct);
} catch (Exception e) {
log.error("项目信息入库错误 " + e);
throw new BusinessException("项目信息入库错误 :" + e);
@@ -652,7 +667,7 @@ public class ProjectLibManage {
* 重新提交工作流时 舍弃在原有项目修改
* 新增一个新的项目 新的版本号
*/
public Project newProjectWithVersion(ProjectDTO projecDto) {
public Project newProjectWithVersion(ProjectDTO projecDto,Boolean isContruct) {
Project oldProject = projectService.getById(projecDto.getId());
Project project = new Project();
VUtils.isTrue(Objects.isNull(oldProject))
@@ -677,7 +692,7 @@ public class ProjectLibManage {
.ne(Project::getId, project.getId())
.eq(Project::getProjectCode, project.getProjectCode()));

saveApplication(projecDto,project,null);
saveApplication(projecDto,project,isContruct);

return project;
}
@@ -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<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);
});
}
});
}
}

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<Long> 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())) {
@@ -1263,7 +1287,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);
}
}


+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectApplication.java View File

@@ -187,4 +187,7 @@ public class ProjectApplication implements Serializable {

@ApiModelProperty("是否为建设方案申报")
private Boolean isConstruct;

@ApiModelProperty("应用核心业务")
private Boolean coreBusinessList;
}

+ 5
- 1
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectApplicationVO.java View File

@@ -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;

/**
* <p>
@@ -177,8 +179,10 @@ public class ProjectApplicationVO implements Serializable {
@ApiModelProperty("项目版本")
private Integer projectVersion;

@ApiModelProperty("应用核心业务")
private List<ProjectCoreBusinessIndicators> coreBusinessList;

private Long createBy;

private Long updateBy;

}

Loading…
Cancel
Save