diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java index 2b3a330..d1a6e25 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java @@ -54,6 +54,7 @@ import com.hz.pm.api.projectlib.service.IProjectInstService; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.projectlib.service.IPurchaseStatusChangeService; import com.hz.pm.api.sys.manage.ProcessModelManage; +import com.hz.pm.api.user.helper.MhUnitCache; import com.hz.pm.api.user.security.model.UserFullInfoDTO; import com.hz.pm.api.user.security.model.UserInfoDetails; import com.hz.pm.api.user.util.LoginUserUtil; @@ -101,6 +102,7 @@ import java.util.stream.Stream; @RequiredArgsConstructor public class PurchaseManage { + private final MhUnitCache mhUnitCache; private final IProjectService projectService; private final UserInfoHelper userInfoHelper; private final IContractService contractService; @@ -471,10 +473,6 @@ public class PurchaseManage { private PageVo queryData(PurchaseAdaptionListReq req) { LambdaQueryWrapper query = Wrappers.lambdaQuery(Purchase.class) - .like(StrUtil.isNotBlank(req.getBidName()), Purchase::getBidName, req.getBidName()) - .le(req.getCreateOnMax() != null, Purchase::getCreateOn, req.getCreateOnMax()) - .ge(req.getCreateOnMin() != null, Purchase::getCreateOn, req.getCreateOnMin()) - .eq(req.getStatus() != null, Purchase::getStatus, req.getStatus()) .eq(Purchase::getBidType, BidTypeEnum.BUILD_APP.getCode()) .notExists(ExistsSqlConst.PURCHASE_EXISTS_PROJECT + "and np.stage = {0}", ProjectStatus.STOPPED.getCode()) @@ -483,6 +481,17 @@ public class PurchaseManage { if (!purchaseService.buildPurchaseQueryPermission(query, user)) { return PageVo.empty(); } + if (req.hasProjectQuery()) { + List projectIds = filterProjectIdsForPurchase(req); + if (projectIds.isEmpty()) { + return PageVo.empty(); + } + query.in(Purchase::getProjectId, projectIds); + } + query.like(StrUtil.isNotBlank(req.getBidName()), Purchase::getBidName, req.getBidName()) + .le(req.getCreateOnMax() != null, Purchase::getCreateOn, req.getCreateOnMax()) + .ge(req.getCreateOnMin() != null, Purchase::getCreateOn, req.getCreateOnMin()) + .eq(req.getStatus() != null, Purchase::getStatus, req.getStatus()); Page page = purchaseService.page(req.page(), query); if (page.getTotal() == 0) { return PageVo.empty(); @@ -514,6 +523,19 @@ public class PurchaseManage { return PageVo.of(data, page.getTotal()); } + private List filterProjectIdsForPurchase(PurchaseAdaptionListReq req) { + LambdaQueryWrapper projQuery = Wrappers.lambdaQuery(Project.class) + .select(Project::getId) + .ne(Project::getStage, ProjectStatus.STOPPED.getCode()) + .eq(Project::getNewest, Boolean.TRUE) + .like(StrUtil.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()) + .like(StrUtil.isNotBlank(req.getBuildOrgName()), Project::getBuildOrgName, req.getBuildOrgName()) + .in(req.getBuildOrgCode() != null, Project::getBuildOrgCode, + mhUnitCache.getViewChildIdsRecursion(req.getBuildOrgCode())); + List projects = projectService.list(projQuery); + return CollUtils.fieldList(projects, Project::getId); + } + public PageVo adaptList(PurchaseAdaptionListReq req) { return queryData(req); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/PurchaseAdaptionListReq.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/PurchaseAdaptionListReq.java index f2b21d3..40e0299 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/PurchaseAdaptionListReq.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/PurchaseAdaptionListReq.java @@ -1,5 +1,6 @@ package com.hz.pm.api.projectdeclared.model.req; +import cn.hutool.core.util.StrUtil; import com.ningdatech.basic.model.PagePo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -22,6 +23,15 @@ public class PurchaseAdaptionListReq extends PagePo { private String bidName; + @ApiModelProperty("建设单位") + private String buildOrgName; + + @ApiModelProperty("项目名称") + private String projectName; + + @ApiModelProperty("建设单位编码") + private Long buildOrgCode; + @ApiModelProperty("标段状态") private Integer status; @@ -33,4 +43,10 @@ public class PurchaseAdaptionListReq extends PagePo { private Boolean display; + public boolean hasProjectQuery() { + return StrUtil.isNotBlank(this.buildOrgName) + || StrUtil.isNotBlank(this.projectName) + || this.buildOrgCode != null; + } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/impl/PurchaseServiceImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/impl/PurchaseServiceImpl.java index d7932a9..3c70f61 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/impl/PurchaseServiceImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/impl/PurchaseServiceImpl.java @@ -134,7 +134,7 @@ public class PurchaseServiceImpl extends ServiceImpl log.warn("没有取到权限信息 当前查询 没有权限条件"); queryState = false; } else { - final String existsSql = "select 1 from nd_project np where np.id = nd_purchase.project_id and np.build_org_code"; + final String existsSql = ExistsSqlConst.PURCHASE_EXISTS_PROJECT + " and np.build_org_code"; switch (datascope.get().getRole()) { case NORMAL_MEMBER: //普通用户 只能看到自己单位去申报的