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