|
|
@@ -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<Purchase> query, UserFullInfoDTO user) { |
|
|
|
boolean queryState = true; |
|
|
|
Optional<DataScopeDTO> 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<Long> childUnitIds = mhUnitCache.getViewChildIdsRecursion(user.getMhUnitId()); |
|
|
|
List<String> 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<Purchase> page = purchaseService.page(req.page(), query); |
|
|
@@ -714,62 +667,13 @@ public class PurchaseManage { |
|
|
|
Integer pageSize = req.getPageSize(); |
|
|
|
//手动添加的 |
|
|
|
List<XcfhxApplyListVO> manuals = xinchuangService.listXcfhxApplyListVO(req); |
|
|
|
//系统和大数据推送的 |
|
|
|
List<XcfhxApplyListVO> others = purchaseService.listXcfhxApplyListVO(req); |
|
|
|
|
|
|
|
LambdaQueryWrapper<Purchase> 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<Purchase> purchases = purchaseService.list(query); |
|
|
|
List<XcfhxApplyListVO> others = Lists.newArrayList(); |
|
|
|
if (CollUtil.isNotEmpty(purchases)) { |
|
|
|
Set<Long> projectIds = CollUtils.fieldSet(purchases, Purchase::getProjectId); |
|
|
|
List<Project> 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<Long, Project> projectMap = CollUtils.listToMap(projects, Project::getId); |
|
|
|
Map<Long, Contract> 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<XcfhxApplyListVO> 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) |
|
|
|