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 8d35323..ad07ef5 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 @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.CollUtils; @@ -34,10 +35,24 @@ import com.ningdatech.pmapi.organization.service.IDingOrganizationService; import com.ningdatech.pmapi.performance.model.dto.ProjectCoreBusinessDTO; import com.ningdatech.pmapi.performance.model.entity.ProjectCoreBusinessIndicators; import com.ningdatech.pmapi.performance.service.IProjectCoreBusinessIndicatorsService; +import com.ningdatech.pmapi.portrait.model.entity.ProjectTag; +import com.ningdatech.pmapi.portrait.model.entity.Tag; +import com.ningdatech.pmapi.portrait.model.vo.TagVO; +import com.ningdatech.pmapi.portrait.service.IProjectTagService; +import com.ningdatech.pmapi.portrait.service.ITagService; import com.ningdatech.pmapi.projectdeclared.model.dto.DelayedApplyDTO; -import com.ningdatech.pmapi.projectdeclared.model.entity.*; -import com.ningdatech.pmapi.projectdeclared.model.vo.*; -import com.ningdatech.pmapi.projectdeclared.service.*; +import com.ningdatech.pmapi.projectdeclared.model.entity.Contract; +import com.ningdatech.pmapi.projectdeclared.model.entity.PaymentPlan; +import com.ningdatech.pmapi.projectdeclared.model.entity.PreInsAcceptancePerson; +import com.ningdatech.pmapi.projectdeclared.model.entity.Purchase; +import com.ningdatech.pmapi.projectdeclared.model.vo.ContractVO; +import com.ningdatech.pmapi.projectdeclared.model.vo.PaymentPlanVO; +import com.ningdatech.pmapi.projectdeclared.model.vo.PreInsAcceptancePersonVO; +import com.ningdatech.pmapi.projectdeclared.model.vo.PurchaseVO; +import com.ningdatech.pmapi.projectdeclared.service.IContractService; +import com.ningdatech.pmapi.projectdeclared.service.IPaymentPlanService; +import com.ningdatech.pmapi.projectdeclared.service.IPreInsAcceptancePersonService; +import com.ningdatech.pmapi.projectdeclared.service.IPurchaseService; import com.ningdatech.pmapi.projectdeclared.utils.GenerateProjectCodeUtil; import com.ningdatech.pmapi.projectlib.constant.ProjectConstant; import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; @@ -105,7 +120,8 @@ public class ProjectLibManage { private final ITodoService todoService; private final IProjectCoreBusinessIndicatorsService projectCoreBusinessIndicatorsService; - private final IOperationService operationService; + private final IProjectTagService projectTagService; + private final ITagService tagService; public PageVo projectLibList(ProjectListReq req) { LambdaQueryWrapper query = ProjectHelper.projectQuery(req); @@ -146,6 +162,24 @@ public class ProjectLibManage { return PageVo.empty(); } UserFullInfoDTO finalUser = user; + + Set projectCodes = page.getRecords().stream() + .map(Project::getProjectCode).collect(Collectors.toSet()); + List pts = projectTagService.list(Wrappers.lambdaQuery(ProjectTag.class) + .in(ProjectTag::getProjectCode, projectCodes)); + Map> tagMap = Maps.newHashMap(); + Map tagNameMap = Maps.newHashMap(); + if(CollUtil.isNotEmpty(pts)){ + tagMap = pts.stream().collect(Collectors.groupingBy(ProjectTag::getProjectCode)); + Set tagIds = pts.stream().map(ProjectTag::getTagId).collect(Collectors.toSet()); + List tags = tagService.list(Wrappers.lambdaQuery(Tag.class) + .in(Tag::getId, tagIds)); + if(CollUtil.isNotEmpty(tags)){ + tagNameMap = tags.stream().collect(Collectors.toMap(Tag::getId,Tag::getName)); + } + } + Map> finalTagMap = tagMap; + Map finalTagNameMap = tagNameMap; List records = CollUtils.convert(page.getRecords(), w -> { ProjectLibListItemVO item = new ProjectLibListItemVO(); item.setId(w.getId()); @@ -168,11 +202,28 @@ public class ProjectLibManage { item.setCanPreDeclared(Boolean.TRUE); } item.setPrePlanProjectId(w.getPrePlanProjectId()); + setTag(item,finalTagMap,finalTagNameMap); return item; }); return PageVo.of(records, total); } + private void setTag(ProjectLibListItemVO item, Map> finalTagMap, Map finalTagNameMap) { + if(finalTagMap.containsKey(item.getProjectCode())){ + List tags = Lists.newArrayList(); + List projectTags = finalTagMap.get(item.getProjectCode()); + for(ProjectTag pt :projectTags){ + if(finalTagNameMap.containsKey(pt.getTagId())){ + TagVO vo = new TagVO(); + vo.setId(pt.getTagId()); + vo.setName(finalTagNameMap.get(pt.getTagId())); + tags.add(vo); + } + } + item.setTags(tags); + } + } + public List projectList(ProjectListReq req) { LambdaQueryWrapper query = ProjectHelper.projectQuery(req); return projectService.list(query); @@ -255,9 +306,7 @@ public class ProjectLibManage { project.setSponsor(employeeCode); String projectCode = generateProjectCodeUtil.generateProjectCode(projectDto); project.setProjectCode(projectCode); - if(projectService.save(project)){ - saveApplication(projectDto,project,null); - } + projectService.save(project); } else { //否则是重新提交的 新生成一个新版本的项目 project = newProjectWithVersion(projectDto); @@ -267,6 +316,30 @@ public class ProjectLibManage { projectService.updateById(project); } } + + //保存项目应用 + 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; + projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class) + .eq(ProjectApplication::getProjectCode, project.getProjectCode()) + .eq(ProjectApplication::getProjectVersion, version)); + if (isApp && CollUtil.isNotEmpty(projectDto.getApplicationList())) { + Project finalProject = project; + List applications = projectDto.getApplicationList().stream().map(application -> { + ProjectApplication projectApplication = new ProjectApplication(); + BeanUtils.copyProperties(application, projectApplication); + projectApplication.setId(null); + projectApplication.setProjectId(finalProject.getId()); + projectApplication.setProjectCode(finalProject.getProjectCode()); + projectApplication.setBuildOrgCode(finalProject.getBuildOrgCode()); + projectApplication.setBuildOrgName(finalProject.getBuildOrgName()); + projectApplication.setProjectVersion(version); + return projectApplication; + }).collect(Collectors.toList()); + projectApplicationService.saveOrUpdateBatch(applications); + } return project; } catch (Exception e) { log.error("项目信息入库错误 " + e); @@ -311,16 +384,13 @@ public class ProjectLibManage { } else { project.setPrePlanProjectId(oldProject.getId()); } - if(projectService.save(project)){ - saveApplication(projectDto,project,null); - - // 将旧的项目版本置为不是最新 - projectService.update(Wrappers.lambdaUpdate(Project.class) - .set(Project::getNewest, Boolean.FALSE) - .ne(Project::getId, project.getId()) - .eq(Project::getProjectCode, project.getProjectCode())); - } + projectService.save(project); + // 将旧的项目版本置为不是最新 + projectService.update(Wrappers.lambdaUpdate(Project.class) + .set(Project::getNewest, Boolean.FALSE) + .ne(Project::getId, project.getId()) + .eq(Project::getProjectCode, project.getProjectCode())); } else { //否则是被驳回,重新提交的 新生成一个新版本的项目 project = newProjectWithVersion(projectDto); @@ -330,6 +400,49 @@ public class ProjectLibManage { projectService.updateById(project); } } + + //保存项目应用 + Boolean isApp = Objects.nonNull(projectDto.getIncludeApplication()) && CommonEnum.YES.getCode().equals(projectDto.getIncludeApplication()) + ? Boolean.TRUE : Boolean.FALSE; + //采取批量删除 批量添加的方式 批量删除建设方案申报后的应用信息及关联的核心业务 + List applications = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) + .eq(ProjectApplication::getProjectCode, project.getProjectCode()) + .eq(ProjectApplication::getProjectVersion, project.getVersion()) + .eq(ProjectApplication::getIsConstruct, Boolean.TRUE)); + 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())) { + Project finalProject = project; + List applicationList = projectDto.getApplicationList(); + for (ProjectApplicationDTO application : applicationList) { + ProjectApplication projectApplication = new ProjectApplication(); + BeanUtils.copyProperties(application, projectApplication); + projectApplication.setId(null); + projectApplication.setProjectId(finalProject.getId()); + projectApplication.setProjectCode(finalProject.getProjectCode()); + projectApplication.setBuildOrgCode(finalProject.getBuildOrgCode()); + projectApplication.setBuildOrgName(finalProject.getBuildOrgName()); + projectApplication.setIsConstruct(Boolean.TRUE); + projectApplication.setProjectVersion(finalProject.getVersion()); + 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.setApplicationId(application.getId()); + projectCoreBusinessIndicatorsService.save(projectCoreBusinessIndicators); + } + } + } + } return project; } catch (Exception e) { log.error("项目信息入库错误 " + e); @@ -347,7 +460,29 @@ public class ProjectLibManage { public Project reSaveProjectNewVersion(ProjectDTO projectDto) { //流程启动之后 入库项目 重要业务信息 用于列表查询 展示 try { - return newProjectWithVersion(projectDto); + Project project = newProjectWithVersion(projectDto); + + //保存项目应用 + Boolean isApp = Objects.nonNull(projectDto.getIncludeApplication()) && CommonEnum.YES.getCode().equals(projectDto.getIncludeApplication()) + ? Boolean.TRUE : Boolean.FALSE; + //采取批量删除 批量添加的方式 + projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class) + .eq(ProjectApplication::getProjectCode, project.getProjectCode()) + .eq(ProjectApplication::getProjectVersion, project.getVersion())); + if (isApp && CollUtil.isNotEmpty(projectDto.getApplicationList())) { + Project finalProject = project; + List applications = projectDto.getApplicationList().stream().map(application -> { + ProjectApplication projectApplication = new ProjectApplication(); + BeanUtils.copyProperties(application, projectApplication); + projectApplication.setId(null); + projectApplication.setProjectId(finalProject.getId()); + projectApplication.setProjectCode(finalProject.getProjectCode()); + projectApplication.setProjectVersion(finalProject.getVersion()); + return projectApplication; + }).collect(Collectors.toList()); + projectApplicationService.saveOrUpdateBatch(applications); + } + return project; } catch (Exception e) { log.error("项目信息入库错误 " + e); throw new BusinessException("项目信息入库错误 :" + e); @@ -379,8 +514,6 @@ public class ProjectLibManage { .ne(Project::getId, project.getId()) .eq(Project::getProjectCode, project.getProjectCode())); - saveApplication(projecDto,project,null); - return project; } @@ -410,14 +543,41 @@ public class ProjectLibManage { .ne(Project::getId, project.getId()) .eq(Project::getProjectCode, project.getProjectCode())); + //删除当前版本的app 一般情况是没有 保险起见 + List applications = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) + .eq(ProjectApplication::getProjectCode, project.getProjectCode()) + .eq(ProjectApplication::getProjectVersion, project.getVersion())); + 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)); + } + //app - saveApplication(projecDto,project,isConstruct); + List applicationList = projecDto.getApplicationList(); + if (CollUtil.isNotEmpty(applicationList)) { + List apps = applicationList.stream() + .map(a -> { + ProjectApplication app = BeanUtil.copyProperties(a, ProjectApplication.class); + app.setId(null); + app.setProjectId(project.getId()); + app.setProjectCode(project.getProjectCode()); + app.setBuildOrgName(project.getBuildOrgName()); + app.setBuildOrgCode(project.getBuildOrgCode()); + app.setIsConstruct(isConstruct); + app.setProjectVersion(project.getVersion()); + return app; + }) + .collect(Collectors.toList()); + projectApplicationService.saveBatch(apps); + } } return project; } - public Project saveProjectWithVersion(ProjectDTO projecDto, String instanceId, Integer instType,Boolean isConstruct) { + public Project saveProjectWithVersion(ProjectDTO projecDto, String instanceId, Integer instType) { Project oldProject = projectService.getById(projecDto.getId()); Project project = new Project(); VUtils.isTrue(Objects.isNull(oldProject)) @@ -448,7 +608,27 @@ public class ProjectLibManage { .eq(Project::getProjectCode, project.getProjectCode())); //app - saveApplication(projecDto,project,isConstruct); + //采取批量删除 批量添加的方式 + projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class) + .eq(ProjectApplication::getProjectCode, project.getProjectCode()) + .eq(ProjectApplication::getProjectVersion, project.getVersion())); + + List applicationList = projecDto.getApplicationList(); + if (CollUtil.isNotEmpty(applicationList)) { + List apps = applicationList.stream() + .map(a -> { + ProjectApplication app = BeanUtil.copyProperties(a, ProjectApplication.class); + app.setId(null); + app.setProjectId(project.getId()); + app.setProjectCode(project.getProjectCode()); + app.setBuildOrgName(project.getBuildOrgName()); + app.setBuildOrgCode(project.getBuildOrgCode()); + app.setProjectVersion(project.getVersion()); + return app; + }) + .collect(Collectors.toList()); + projectApplicationService.saveBatch(apps); + } } return project; @@ -481,7 +661,17 @@ public class ProjectLibManage { .ne(Project::getId, project.getId()) .eq(Project::getProjectCode, project.getProjectCode())); - saveApplication(project,oldProject,null); + List apps = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) + .eq(ProjectApplication::getProjectId, oldProject.getId())); + if(CollUtil.isNotEmpty(apps)){ + apps = apps.stream().map(app -> { + app.setProjectVersion(project.getVersion()); + app.setProjectId(project.getId()); + app.setId(null); + return app; + }).collect(Collectors.toList()); + projectApplicationService.saveBatch(apps); + } } return project; @@ -516,9 +706,6 @@ public class ProjectLibManage { .set(Project::getNewest, Boolean.FALSE) .ne(Project::getId, project.getId()) .eq(Project::getProjectCode, project.getProjectCode())); - - //APP - saveApplication(project,oldProject,null); } return project; @@ -553,8 +740,6 @@ public class ProjectLibManage { .set(Project::getNewest, Boolean.FALSE) .ne(Project::getId, project.getId()) .eq(Project::getProjectCode, project.getProjectCode())); - - saveApplication(project,oldProject,Boolean.TRUE); } return project; @@ -605,12 +790,6 @@ public class ProjectLibManage { contractVO.getTotalAmount())); } - //查询实施信息 - Operation operation = operationService.getOne(Wrappers.lambdaQuery(Operation.class) - .in(Operation::getProjectId, allVersionProjectId) - .orderByAsc(Operation::getCreateOn) - .last(BizConst.LIMIT_1)); - vo.setOperation(BeanUtil.copyProperties(operation, OperationVO.class)); //查询初验信息 List acceptancePersons = acceptancePersonService.list(Wrappers.lambdaQuery(PreInsAcceptancePerson.class) @@ -1075,68 +1254,4 @@ public class ProjectLibManage { res.put(ProjectConstant.ProjectLib.PROCESS_KEY, todoService.getProcessDetail(req)); return res; } - - private 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 = apps.stream().map(app -> { - 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); - } - } - - private void saveApplication(ProjectDTO projectDto,Project project,Boolean isConstruct) { - //保存项目应用 - 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 一般情况是没有 保险起见 - List applications = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) - .eq(ProjectApplication::getProjectCode, project.getProjectCode()) - .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())) { - Project finalProject = project; - projectDto.getApplicationList().forEach(application -> { - ProjectApplication projectApplication = new ProjectApplication(); - BeanUtils.copyProperties(application, projectApplication); - projectApplication.setId(null); - projectApplication.setProjectId(finalProject.getId()); - projectApplication.setProjectCode(finalProject.getProjectCode()); - projectApplication.setBuildOrgCode(finalProject.getBuildOrgCode()); - projectApplication.setBuildOrgName(finalProject.getBuildOrgName()); - projectApplication.setProjectVersion(version); - projectApplication.setIsConstruct(isConstruct); - - 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.setApplicationId(application.getId()); - projectCoreBusinessIndicatorsService.save(projectCoreBusinessIndicators); - } - } - }); - } - } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java index 5815201..06b5e94 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.annotation.JSONField; import com.fasterxml.jackson.annotation.JsonFormat; import com.ningdatech.basic.util.NdDateUtils; import com.ningdatech.pmapi.common.util.BizUtils; +import com.ningdatech.pmapi.portrait.model.vo.TagVO; import com.ningdatech.pmapi.projectdeclared.model.entity.Contract; import com.ningdatech.pmapi.projectdeclared.model.vo.ContractVO; import com.ningdatech.pmapi.projectdeclared.model.vo.OperationVO; @@ -400,6 +401,9 @@ public class ProjectDetailVO { @ApiModelProperty("审批详情") private ProcessProgressDetailVo process; + @ApiModelProperty("标签") + private List tags; + public String getVersionStr() { if (Objects.nonNull(this.newest) && this.newest) { this.versionStr = "当前版本"; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectLibListItemVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectLibListItemVO.java index 375dc13..408a2b4 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectLibListItemVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectLibListItemVO.java @@ -3,6 +3,7 @@ package com.ningdatech.pmapi.projectlib.model.vo; import com.alibaba.fastjson.annotation.JSONField; import com.fasterxml.jackson.annotation.JsonFormat; import com.ningdatech.pmapi.common.enumeration.CommonEnum; +import com.ningdatech.pmapi.portrait.model.vo.TagVO; import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; @@ -16,6 +17,7 @@ import lombok.experimental.Tolerate; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.List; import java.util.Objects; import java.util.Optional; @@ -142,6 +144,9 @@ public class ProjectLibListItemVO { @ApiModelProperty("初步方案项目ID") private Long prePlanProjectId; + @ApiModelProperty("标签") + private List tags; + //预审申报时候 需不需要上传上级条线意见文件 private Boolean needUploadSuperLineFile; public Boolean getNeedUploadSuperLineFile() {