From 229f100b14deaa853393d4d6f807eadcc9662b84 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Wed, 3 Jul 2024 17:34:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=A1=E5=88=9B=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E5=88=97=E8=A1=A8=20=E9=87=91=E9=A2=9D=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/projectdeclared/manage/PurchaseManage.java | 104 +--------------- .../projectdeclared/service/IPurchaseService.java | 15 ++- .../service/impl/PurchaseServiceImpl.java | 137 +++++++++++++++++++++ 3 files changed, 152 insertions(+), 104 deletions(-) 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 e4c9fc8..778ea12 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 @@ -1,7 +1,6 @@ package com.hz.pm.api.projectdeclared.manage; import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.io.FileUtil; @@ -16,7 +15,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import com.hz.pm.api.common.enumeration.ProjectProcessType; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.statemachine.event.AbstractStateChangeEvent; @@ -25,8 +23,6 @@ import com.hz.pm.api.common.statemachine.event.SelfTestStateChangeEvent; import com.hz.pm.api.common.statemachine.event.TestValidStateChangeEvent; import com.hz.pm.api.common.statemachine.util.*; import com.hz.pm.api.common.util.*; -import com.hz.pm.api.datascope.model.DataScopeDTO; -import com.hz.pm.api.datascope.utils.DataScopeUtil; import com.hz.pm.api.external.MhApiClient; import com.hz.pm.api.external.MhFileClient; import com.hz.pm.api.external.model.dto.MhPurchaseIntentionDTO; @@ -60,13 +56,11 @@ 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; import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.function.VUtils; -import com.ningdatech.basic.model.ApiResponse; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.CollUtils; import com.ningdatech.basic.util.NdDateUtils; @@ -79,16 +73,11 @@ import com.wflow.workflow.bean.vo.ProcessStartParamsVo; import com.wflow.workflow.service.ProcessInstanceService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; -import org.springframework.mock.web.MockMultipartFile; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; - import javax.servlet.http.HttpServletResponse; -import java.io.FileInputStream; import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; @@ -121,7 +110,6 @@ public class PurchaseManage { private final MhApiClient mhApiClient; private final MhFileClient mhFileClient; private final FileService fileService; - private final MhUnitCache mhUnitCache; private final IOperationService operationService; private final ProcessModelManage processModelManage; private final DeclaredProjectHelper declaredProjectManage; @@ -138,41 +126,6 @@ public class PurchaseManage { private final MhXchxFileHelper mhXchxFileHelper; - private boolean buildPurchaseQueryPermission(LambdaQueryWrapper query, UserFullInfoDTO user) { - boolean queryState = true; - Optional datascope = DataScopeUtil.getCurrentUserDataScopeHasUserId(user); - if (!datascope.isPresent()) { - 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"; - switch (datascope.get().getRole()) { - case NORMAL_MEMBER: - //普通用户 只能看到自己单位去申报的 - query.exists(String.format("%s = '%s'", existsSql, user.getMhUnitIdStr())); - break; - case COMPANY_MANAGER: - List childUnitIds = mhUnitCache.getViewChildIdsRecursion(user.getMhUnitId()); - List viewUnitIdList = CollUtils.convert(childUnitIds, String::valueOf); - query.exists(String.format("%s in %s", existsSql, BizUtils.inSqlJoin(viewUnitIdList))); - break; - case SUPER_ADMIN: - // 超级管理员 看到全市的 并且也要判断他 同时是不是单位管理员 - break; - case VISITOR: - //访客可以看全市的 - break; - case DASHBOARD: - break; - default: - //没有权限的话 就让它查不到 - queryState = false; - break; - } - } - return queryState; - } - /** * 待采购的-项目列表 * @@ -479,7 +432,7 @@ public class PurchaseManage { query.ne(Purchase::getBidType, BidTypeEnum.BUILD_APP.getCode()).notExists(existsSql); } UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - if (!buildPurchaseQueryPermission(query, user)) { + if (!purchaseService.buildPurchaseQueryPermission(query, user)) { return PageVo.empty(); } Page page = purchaseService.page(req.page(), query); @@ -714,62 +667,13 @@ public class PurchaseManage { Integer pageSize = req.getPageSize(); //手动添加的 List manuals = xinchuangService.listXcfhxApplyListVO(req); + //系统和大数据推送的 + List others = purchaseService.listXcfhxApplyListVO(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::getXcfhxApplyStatus, req.getStatus()) - .eq(req.getSourceType() != null,Purchase::getSourceType,req.getSourceType()) - .ge(Objects.nonNull(req.getAmountStart()),Purchase::getTransactionAmount,req.getAmountStart()) - .le(Objects.nonNull(req.getAmountEnd()),Purchase::getTransactionAmount,req.getAmountEnd()) - .orderByDesc(Purchase::getCreateOn); - - if (Boolean.TRUE.equals(req.getFinished())) { - query.eq(Purchase::getXcfhxApplyStatus, TenderXcfhxApplyStatus.XCFHX_APPLY_PASSED.getCode()); - } else if (Boolean.FALSE.equals(req.getFinished())){ - query.ne(Purchase::getXcfhxApplyStatus, TenderXcfhxApplyStatus.XCFHX_APPLY_PASSED.getCode()); - } - UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - if (!buildPurchaseQueryPermission(query, user)) { - return PageVo.empty(); - } - List purchases = purchaseService.list(query); - List others = Lists.newArrayList(); - if (CollUtil.isNotEmpty(purchases)) { - Set projectIds = CollUtils.fieldSet(purchases, Purchase::getProjectId); - List projects = projectIds.isEmpty() ? Lists.newArrayList() : projectService.list(Wrappers.lambdaQuery(Project.class) - .in(Project::getId,projectIds) - .like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName())); - Map projectMap = CollUtils.listToMap(projects, Project::getId); - Map contractMap = projectIds.isEmpty() ? Maps.newHashMap() - : contractService.listByProjectIds(projectIds); - others = purchases.stream().filter(w -> projectMap.containsKey(w.getProjectId())) - .map(w -> { - XcfhxApplyListVO item = XcfhxApplyListVO.builder() - .bidId(w.getId()) - .bizName(w.getBidName()) - .status(w.getXcfhxApplyStatus()) - .projectId(w.getProjectId()) - .createOn(w.getCreateOn()) - .sourceType(w.getSourceType()) - .build(); - Project project = projectMap.get(w.getProjectId()); - item.setProjectCode(project.getProjectCode()); - item.setProjectName(project.getProjectName()); - item.setBuildOrgCode(project.getBuildOrgCode()); - item.setBuildOrgName(project.getBuildOrgName()); - - Contract contract = contractMap.get(w.getId()); - if (contract != null) { - item.setContractAmount(contract.getTotalAmount()); - } - return item; - }).collect(Collectors.toList()); - } //合并 List merge = Stream.of(manuals, others) .flatMap(List::stream) + .filter(Objects::nonNull) .collect(Collectors.toList()); return PageVo.of(merge.stream().sorted(Comparator.comparing(XcfhxApplyListVO::getCreateOn).reversed()) .skip((long) (pageNumber - 1) * pageSize) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/IPurchaseService.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/IPurchaseService.java index 7ff86b7..350fe02 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/IPurchaseService.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/IPurchaseService.java @@ -4,14 +4,18 @@ import cn.hutool.core.collection.CollUtil; 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.util.BizUtils; +import com.hz.pm.api.datascope.model.DataScopeDTO; +import com.hz.pm.api.datascope.utils.DataScopeUtil; import com.hz.pm.api.projectdeclared.model.entity.Purchase; +import com.hz.pm.api.projectdeclared.model.req.XcfhxListReq; +import com.hz.pm.api.projectdeclared.model.vo.XcfhxApplyListVO; import com.hz.pm.api.projectlib.model.enumeration.status.TenderStatus; +import com.hz.pm.api.user.security.model.UserFullInfoDTO; import com.ningdatech.basic.util.CollUtils; +import lombok.extern.slf4j.Slf4j; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; /** @@ -49,4 +53,7 @@ public interface IPurchaseService extends IService { return CollUtils.fieldSet(list(query), Purchase::getProjectId); } + boolean buildPurchaseQueryPermission(LambdaQueryWrapper query, UserFullInfoDTO user); + + List listXcfhxApplyListVO(XcfhxListReq req); } 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 51b1bf8..5edaec3 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 @@ -1,11 +1,39 @@ package com.hz.pm.api.projectdeclared.service.impl; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.hz.pm.api.common.helper.UserInfoHelper; +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.projectdeclared.mapper.PurchaseMapper; +import com.hz.pm.api.projectdeclared.model.entity.Contract; import com.hz.pm.api.projectdeclared.model.entity.Purchase; +import com.hz.pm.api.projectdeclared.model.req.XcfhxListReq; +import com.hz.pm.api.projectdeclared.model.vo.XcfhxApplyListVO; +import com.hz.pm.api.projectdeclared.service.IContractService; import com.hz.pm.api.projectdeclared.service.IPurchaseService; +import com.hz.pm.api.projectlib.model.entity.Project; +import com.hz.pm.api.projectlib.model.enumeration.status.TenderXcfhxApplyStatus; +import com.hz.pm.api.projectlib.service.IProjectService; +import com.hz.pm.api.user.helper.MhUnitCache; +import com.hz.pm.api.user.security.model.UserFullInfoDTO; +import com.hz.pm.api.user.util.LoginUserUtil; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.CollUtils; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import java.util.*; +import java.util.stream.Collectors; + /** *

* 服务实现类 @@ -15,7 +43,116 @@ import org.springframework.stereotype.Service; * @since 2023-02-05 */ @Service +@RequiredArgsConstructor +@Slf4j public class PurchaseServiceImpl extends ServiceImpl implements IPurchaseService { + private final UserInfoHelper userInfoHelper; + + private final IProjectService projectService; + + private final IContractService contractService; + + private final MhUnitCache mhUnitCache; + + @Override + public List listXcfhxApplyListVO(XcfhxListReq 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::getXcfhxApplyStatus, req.getStatus()) + .eq(req.getSourceType() != null,Purchase::getSourceType,req.getSourceType()) + .ge(Objects.nonNull(req.getAmountStart()),Purchase::getTransactionAmount,req.getAmountStart()) + .le(Objects.nonNull(req.getAmountEnd()),Purchase::getTransactionAmount,req.getAmountEnd()) + .orderByDesc(Purchase::getCreateOn); + + if (Boolean.TRUE.equals(req.getFinished())) { + query.eq(Purchase::getXcfhxApplyStatus, TenderXcfhxApplyStatus.XCFHX_APPLY_PASSED.getCode()); + } else if (Boolean.FALSE.equals(req.getFinished())){ + query.ne(Purchase::getXcfhxApplyStatus, TenderXcfhxApplyStatus.XCFHX_APPLY_PASSED.getCode()); + } + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); + List others = Lists.newArrayList(); + if (!buildPurchaseQueryPermission(query, user)) { + return others; + } + List purchases = list(query); + if (CollUtil.isNotEmpty(purchases)) { + Set projectIds = CollUtils.fieldSet(purchases, Purchase::getProjectId); + List projects = projectIds.isEmpty() ? Lists.newArrayList() : projectService.list(Wrappers.lambdaQuery(Project.class) + .in(Project::getId,projectIds) + .like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName())); + Map projectMap = CollUtils.listToMap(projects, Project::getId); + Map contractMap = projectIds.isEmpty() ? Maps.newHashMap() + : contractService.listByProjectIds(projectIds); + others = purchases.stream().filter(w -> projectMap.containsKey(w.getProjectId())) + .map(w -> { + XcfhxApplyListVO item = XcfhxApplyListVO.builder() + .bidId(w.getId()) + .bizName(w.getBidName()) + .status(w.getXcfhxApplyStatus()) + .projectId(w.getProjectId()) + .createOn(w.getCreateOn()) + .sourceType(w.getSourceType()) + .build(); + Project project = projectMap.get(w.getProjectId()); + item.setProjectCode(project.getProjectCode()); + item.setProjectName(project.getProjectName()); + item.setBuildOrgCode(project.getBuildOrgCode()); + item.setBuildOrgName(project.getBuildOrgName()); + + Contract contract = contractMap.get(w.getId()); + if (contract != null) { + if(Objects.nonNull(req.getAmountStart()) && Objects.nonNull(contract.getTotalAmount()) + && req.getAmountStart().compareTo(contract.getTotalAmount()) > 0){ + return null; + } + if(Objects.nonNull(req.getAmountEnd()) && Objects.nonNull(contract.getTotalAmount()) + && req.getAmountEnd().compareTo(contract.getTotalAmount()) < 0){ + return null; + } + item.setContractAmount(contract.getTotalAmount()); + } + return item; + }).collect(Collectors.toList()); + } + return others; + } + + public boolean buildPurchaseQueryPermission(LambdaQueryWrapper query, UserFullInfoDTO user) { + boolean queryState = true; + Optional datascope = DataScopeUtil.getCurrentUserDataScopeHasUserId(user); + if (!datascope.isPresent()) { + 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"; + switch (datascope.get().getRole()) { + case NORMAL_MEMBER: + //普通用户 只能看到自己单位去申报的 + query.exists(String.format("%s = '%s'", existsSql, user.getMhUnitIdStr())); + break; + case COMPANY_MANAGER: + List childUnitIds = mhUnitCache.getViewChildIdsRecursion(user.getMhUnitId()); + List viewUnitIdList = CollUtils.convert(childUnitIds, String::valueOf); + query.exists(String.format("%s in %s", existsSql, BizUtils.inSqlJoin(viewUnitIdList))); + break; + case SUPER_ADMIN: + // 超级管理员 看到全市的 并且也要判断他 同时是不是单位管理员 + break; + case VISITOR: + //访客可以看全市的 + break; + case DASHBOARD: + break; + default: + //没有权限的话 就让它查不到 + queryState = false; + break; + } + } + return queryState; + } } From 26258827b2f1a3fdefb79f63931a486a64e98f95 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Wed, 3 Jul 2024 17:47:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=A1=E5=88=9B=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E5=88=97=E8=A1=A8=20=E9=87=91=E9=A2=9D=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hz/pm/api/projectdeclared/service/impl/PurchaseServiceImpl.java | 6 ++++-- .../main/java/com/hz/pm/api/todocenter/handle/WithDrawHandle.java | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) 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 5edaec3..3b8c783 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 @@ -64,8 +64,6 @@ public class PurchaseServiceImpl extends ServiceImpl .ge(req.getCreateOnMin() != null, Purchase::getCreateOn, req.getCreateOnMin()) .eq(req.getStatus() != null, Purchase::getXcfhxApplyStatus, req.getStatus()) .eq(req.getSourceType() != null,Purchase::getSourceType,req.getSourceType()) - .ge(Objects.nonNull(req.getAmountStart()),Purchase::getTransactionAmount,req.getAmountStart()) - .le(Objects.nonNull(req.getAmountEnd()),Purchase::getTransactionAmount,req.getAmountEnd()) .orderByDesc(Purchase::getCreateOn); if (Boolean.TRUE.equals(req.getFinished())) { @@ -114,6 +112,10 @@ public class PurchaseServiceImpl extends ServiceImpl return null; } item.setContractAmount(contract.getTotalAmount()); + }else{ + if(Objects.nonNull(req.getAmountStart()) || Objects.nonNull(req.getAmountEnd())){ + return null; + } } return item; }).collect(Collectors.toList()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/handle/WithDrawHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/handle/WithDrawHandle.java index f6d1d11..68425f7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/handle/WithDrawHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/handle/WithDrawHandle.java @@ -15,6 +15,7 @@ import com.hz.pm.api.todocenter.constant.TodoCenterConst; 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; +import com.ningdatech.basic.function.VUtils; import com.wflow.contants.HisProInsEndActId; import com.wflow.workflow.bean.dto.ReqProcessHandlerDTO; import com.wflow.workflow.bean.process.ProgressNode; @@ -350,6 +351,9 @@ public class WithDrawHandle { .select(XinchuangInst::getInstType) .eq(XinchuangInst::getInstCode, instance.getId()); XinchuangInst xinchuangInst = xinchuangInstService.getOne(piQuery); + if(Objects.isNull(xinchuangInst)) { + return Boolean.FALSE; + } Integer instType = xinchuangInst.getInstType(); if (InstTypeEnum.APPLY_DELAY.eq(instType) || InstTypeEnum.APPLY_BORROW.eq(instType) ||