From f6533f7b1993db71bbb2d37301397c545ddc38d8 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Thu, 18 Apr 2024 19:26:06 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=8B=E9=A1=B9=E5=A4=87=E6=A1=88=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projectlib/manage/DeclaredRecordManage.java | 102 ++++++++++----------- .../api/projectlib/service/IMhProjectService.java | 10 ++ 2 files changed, 57 insertions(+), 55 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/DeclaredRecordManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/DeclaredRecordManage.java index 1e33d7f..f7efb8c 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/DeclaredRecordManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/DeclaredRecordManage.java @@ -14,7 +14,6 @@ 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.TypeReferenceConst; -import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.datascope.model.DataScopeDTO; import com.hz.pm.api.datascope.utils.DataScopeUtil; import com.hz.pm.api.external.model.enumeration.MhUnitStripEnum; @@ -38,7 +37,10 @@ import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus; import com.hz.pm.api.projectlib.model.req.DeclaredProjectListReq; import com.hz.pm.api.projectlib.model.vo.DeclaredProjectListVO; import com.hz.pm.api.projectlib.model.vo.MhProjectBaseInfoVO; -import com.hz.pm.api.projectlib.service.*; +import com.hz.pm.api.projectlib.service.IMhProjectSchemaTargetDataService; +import com.hz.pm.api.projectlib.service.IMhProjectService; +import com.hz.pm.api.projectlib.service.IProjectGovSystemReplaceInfosService; +import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.staging.enums.MsgTypeEnum; import com.hz.pm.api.sys.manage.NoticeManage; import com.hz.pm.api.sys.manage.ProcessModelManage; @@ -98,22 +100,21 @@ public class DeclaredRecordManage { private final DeclaredProjectHelper declaredProjectHelper; private final ProcessInstanceService processInstanceService; private final ProjectLibManage projectLibManage; - private final IProjectStatusChangeService projectStatusChangeService; private final IProjectGovSystemReplaceInfosService systemReplaceInfosService; private final MHTodoClient mhTodoClient; - private LambdaQueryWrapper buildQuery(DeclaredProjectListReq req) { - LambdaQueryWrapper query = Wrappers.lambdaQuery(MhProject.class) - .like(StrUtil.isNotBlank(req.getProjectName()), MhProject::getProjectName, req.getProjectName()) - .like(StrUtil.isNotBlank(req.getDeclaredUnit()), MhProject::getUnitName, req.getDeclaredUnit()); + private LambdaQueryWrapper buildQuery(DeclaredProjectListReq req) { + LambdaQueryWrapper query = Wrappers.lambdaQuery(Project.class) + .like(StrUtil.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()) + .like(StrUtil.isNotBlank(req.getDeclaredUnit()), Project::getBuildOrgName, req.getDeclaredUnit()); if (req.getCreateDateMin() != null) { - query.ge(MhProject::getCreateTime, req.getCreateDateMin()); + query.ge(Project::getCreateOn, req.getCreateDateMin()); } if (req.getCreateDateMax() != null) { - query.lt(MhProject::getCreateTime, req.getCreateDateMax().minusDays(1)); + query.lt(Project::getCreateOn, req.getCreateDateMax().minusDays(1)); } if (req.getUnitStrip() != null) { - query.eq(MhProject::getUnitStrip, req.getUnitStrip()); + query.eq(Project::getUnitStrip, req.getUnitStrip()); } return query; } @@ -199,50 +200,40 @@ public class DeclaredRecordManage { } public PageVo pageDeclaredProject(DeclaredProjectListReq req) { - LambdaQueryWrapper query = buildQuery(req); + LambdaQueryWrapper query = buildQuery(req); UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); // 查询审核中、失败、待立项备案的项目信息 - LambdaQueryWrapper pQuery = Wrappers.lambdaQuery(Project.class) - .in(Project::getStatus, ProjectStatus.DECLARED_APPROVED_RECORD_FAILED.getCode(), + if (!buildProjectLibPermission(query, user)) { + return PageVo.empty(); + } + query.in(Project::getStatus, ProjectStatus.DECLARED_APPROVED_RECORD_FAILED.getCode(), ProjectStatus.DECLARED_APPROVED_TO_BE_RECORD.getCode(), ProjectStatus.DECLARED_APPROVED_RECORD_AUDITING.getCode()) .eq(Project::getNewest, Boolean.TRUE) - .select(Project::getId, Project::getProjectCode, Project::getStage, Project::getStatus, Project::getCreateOn); - if (!buildProjectLibPermission(pQuery, user)) { - return PageVo.empty(); - } - if (!buildMhProjectLibPermission(query, user, req.getDeclaredUnitId())) { - return PageVo.empty(); - } - List projects = projectService.list(pQuery); - Map projectMap = BizUtils.groupFirstMap(projects, Project::getProjectCode, - Comparator.comparing(Project::getCreateOn).thenComparing(Project::getNewest).reversed()); - query.and(q1 -> q1.isNull(MhProject::getProjectCode) - .or(!projects.isEmpty(), q2 -> q2.in(MhProject::getProjectCode, projectMap.keySet()))); - Page page = mhProjectService.page(req.page(), query); + .orderByDesc(Project::getUpdateOn); + Page page = projectService.page(req.page(), query); if (page.getTotal() == 0) { return PageVo.empty(); } - List records = page.getRecords(); - List data = records.stream().map(w -> { + List projCodes = CollUtils.fieldList(page.getRecords(), Project::getProjectCode); + List mhProjList = mhProjectService.listByProjectCode(projCodes); + Map mhProjMap = CollUtils.listToMap(mhProjList, MhProject::getProjectCode); + List data = page.getRecords().stream().map(w -> { DeclaredProjectListVO item = new DeclaredProjectListVO(); - item.setMhProjectId(w.getId()); - Project project = projectMap.get(w.getProjectCode()); - if (project == null) { - item.setStatus(ProjectStatus.DECLARED_APPROVED_TO_BE_RECORD.getCode()); - item.setStage(ProjectStatus.NOT_APPROVED.getCode()); - } else { - item.setStatus(project.getStatus()); - item.setStage(project.getStage()); - item.setProjectId(project.getId()); + MhProject mhProj = mhProjMap.get(w.getProjectCode()); + if (mhProj != null) { + item.setMhProjectId(mhProj.getId()); } + item.setStatus(w.getStatus()); + item.setStage(w.getStage()); + item.setProjectId(w.getId()); item.setUnitStrip(w.getUnitStrip()); item.setUnitStripName(MhUnitStripEnum.getVal(w.getUnitStrip())); - item.setDeclaredUnit(w.getUnitName()); + item.setDeclaredUnit(w.getBuildOrgName()); item.setProjectCode(w.getProjectCode()); item.setProjectName(w.getProjectName()); - item.setDeclaredAmount(w.getTotalMoney()); - item.setCreateTime(w.getCreateTime()); + item.setDeclaredAmount(w.getDeclareAmount()); + item.setCreateTime(w.getCreateOn()); return item; }).collect(Collectors.toList()); return PageVo.of(data, page.getTotal()); @@ -279,7 +270,6 @@ public class DeclaredRecordManage { @Transactional(rollbackFor = Exception.class) public synchronized void startDeclaredRecord(DefaultDeclaredDTO req) { ProjectDTO projectInfo = req.getProjectInfo(); - Assert.notNull(projectInfo.getMhProjectId(), "信产项目ID不能为空"); UserInfoDetails user = LoginUserUtil.loginUserDetail(); projectInfo.setBuildOrgCode(user.getMhUnitIdStr()); @@ -326,11 +316,13 @@ public class DeclaredRecordManage { //如果是草稿箱提交 删除对应的草稿箱 projectDraftService.removeById(projectInfo.getDraftId()); } - // 申报项目完成后 保存项目编码 - Wrapper update = Wrappers.lambdaUpdate(MhProject.class) - .set(MhProject::getProjectCode, newProj.getProjectCode()) - .eq(MhProject::getId, projectInfo.getMhProjectId()); - mhProjectService.update(update); + if (projectInfo.getMhProjectId() != null) { + // 申报项目完成后 保存项目编码 + Wrapper update = Wrappers.lambdaUpdate(MhProject.class) + .set(MhProject::getProjectCode, newProj.getProjectCode()) + .eq(MhProject::getId, projectInfo.getMhProjectId()); + mhProjectService.update(update); + } //发送给第一个审批人消息 noticeManage.sendFirstUser(newProj, model.getFormName(), instanceId, WorkNoticeConst.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); @@ -407,22 +399,22 @@ public class DeclaredRecordManage { if (mhProjects.isEmpty()) { return; } - for (MhProject mhProject : mhProjects) { - if (StrUtil.isNotBlank(mhProject.getProjectCode())) { + for (MhProject mhProj : mhProjects) { + if (StrUtil.isNotBlank(mhProj.getProjectCode())) { continue; } LocalDateTime now = LocalDateTime.now(); Project project = new Project(); - project.setProjectName(mhProject.getProjectName()); - project.setBuildOrgCode(String.valueOf(mhProject.getUnitId())); - project.setBuildOrgName(mhProject.getUnitName()); - project.setUnitStrip(mhProject.getUnitStrip()); + project.setProjectName(mhProj.getProjectName()); + project.setBuildOrgCode(String.valueOf(mhProj.getUnitId())); + project.setBuildOrgName(mhProj.getUnitName()); + project.setUnitStrip(mhProj.getUnitStrip()); project.setVersion(0); project.setNewest(Boolean.TRUE); project.setStatus(ProjectStatus.DECLARED_APPROVED_TO_BE_RECORD.getCode()); project.setStage(ProjectStatus.NOT_APPROVED.getCode()); - ProjectDTO tmpProject = BeanUtil.copyProperties(project, ProjectDTO.class); - String projectCode = projectCodeGenUtil.generateProjectCode(tmpProject); + ProjectDTO tmpProj = BeanUtil.copyProperties(project, ProjectDTO.class); + String projectCode = projectCodeGenUtil.generateProjectCode(tmpProj); project.setProjectCode(projectCode); project.setCreateOn(now); project.setCreateBy(0L); @@ -431,7 +423,7 @@ public class DeclaredRecordManage { projectService.save(project); mhProjectService.update(Wrappers.lambdaUpdate(MhProject.class) .set(MhProject::getProjectCode, projectCode) - .eq(MhProject::getId, mhProject.getId())); + .eq(MhProject::getId, mhProj.getId())); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IMhProjectService.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IMhProjectService.java index f611021..22a6788 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IMhProjectService.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IMhProjectService.java @@ -1,11 +1,14 @@ package com.hz.pm.api.projectlib.service; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.IService; import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.projectlib.model.entity.MhProject; +import java.util.Collection; +import java.util.List; import java.util.Optional; /** @@ -39,4 +42,11 @@ public interface IMhProjectService extends IService { return count(query) > 0; } + + default List listByProjectCode(Collection projectCodes) { + Wrapper query = Wrappers.lambdaQuery(MhProject.class) + .in(MhProject::getProjectCode, projectCodes); + return list(query); + } + }