|
@@ -2,6 +2,7 @@ package com.hz.pm.api.projectdeclared.manage; |
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
|
import cn.hutool.core.util.NumberUtil; |
|
|
import com.alibaba.excel.EasyExcel; |
|
|
import com.alibaba.excel.EasyExcel; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
@@ -11,6 +12,8 @@ import com.google.common.collect.Lists; |
|
|
import com.hz.pm.api.common.enumeration.ProjectProcessType; |
|
|
import com.hz.pm.api.common.enumeration.ProjectProcessType; |
|
|
import com.hz.pm.api.common.helper.UserInfoHelper; |
|
|
import com.hz.pm.api.common.helper.UserInfoHelper; |
|
|
import com.hz.pm.api.common.model.constant.BizConst; |
|
|
import com.hz.pm.api.common.model.constant.BizConst; |
|
|
|
|
|
import com.hz.pm.api.common.model.constant.ExistsSqlConst; |
|
|
|
|
|
import com.hz.pm.api.common.statemachine.event.TenderStateChangeEvent; |
|
|
import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil; |
|
|
import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil; |
|
|
import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil; |
|
|
import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil; |
|
|
import com.hz.pm.api.common.statemachine.util.XcfhxStateMachineUtil; |
|
|
import com.hz.pm.api.common.statemachine.util.XcfhxStateMachineUtil; |
|
@@ -23,16 +26,14 @@ import com.hz.pm.api.projectdeclared.model.dto.PaymentPlanSupplementDTO; |
|
|
import com.hz.pm.api.projectdeclared.model.dto.PreInsSaveDTO; |
|
|
import com.hz.pm.api.projectdeclared.model.dto.PreInsSaveDTO; |
|
|
import com.hz.pm.api.projectdeclared.model.entity.*; |
|
|
import com.hz.pm.api.projectdeclared.model.entity.*; |
|
|
import com.hz.pm.api.projectdeclared.model.req.XcfhxApplyReq; |
|
|
import com.hz.pm.api.projectdeclared.model.req.XcfhxApplyReq; |
|
|
import com.hz.pm.api.projectdeclared.model.vo.ContractVO; |
|
|
|
|
|
import com.hz.pm.api.projectdeclared.model.vo.PreInsAcceptancePersonVO; |
|
|
|
|
|
import com.hz.pm.api.projectdeclared.model.vo.PreInsVO; |
|
|
|
|
|
import com.hz.pm.api.projectdeclared.model.vo.ProjectContractListVO; |
|
|
|
|
|
|
|
|
import com.hz.pm.api.projectdeclared.model.vo.*; |
|
|
import com.hz.pm.api.projectdeclared.service.*; |
|
|
import com.hz.pm.api.projectdeclared.service.*; |
|
|
import com.hz.pm.api.projectlib.helper.ProjectManageUtil; |
|
|
import com.hz.pm.api.projectlib.helper.ProjectManageUtil; |
|
|
import com.hz.pm.api.projectlib.model.entity.Project; |
|
|
import com.hz.pm.api.projectlib.model.entity.Project; |
|
|
import com.hz.pm.api.projectlib.model.entity.ProjectAnnualPaymentPlan; |
|
|
import com.hz.pm.api.projectlib.model.entity.ProjectAnnualPaymentPlan; |
|
|
import com.hz.pm.api.projectlib.model.entity.ProjectInst; |
|
|
import com.hz.pm.api.projectlib.model.entity.ProjectInst; |
|
|
import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; |
|
|
import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; |
|
|
|
|
|
import com.hz.pm.api.projectlib.model.enumeration.status.ITenderStatus; |
|
|
import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus; |
|
|
import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus; |
|
|
import com.hz.pm.api.projectlib.model.enumeration.status.TenderMainStatus; |
|
|
import com.hz.pm.api.projectlib.model.enumeration.status.TenderMainStatus; |
|
|
import com.hz.pm.api.projectlib.model.enumeration.status.TenderXcfhxApplyStatus; |
|
|
import com.hz.pm.api.projectlib.model.enumeration.status.TenderXcfhxApplyStatus; |
|
@@ -43,6 +44,8 @@ import com.hz.pm.api.projectlib.service.IProjectAnnualPaymentPlanService; |
|
|
import com.hz.pm.api.projectlib.service.IProjectInstService; |
|
|
import com.hz.pm.api.projectlib.service.IProjectInstService; |
|
|
import com.hz.pm.api.projectlib.service.IProjectService; |
|
|
import com.hz.pm.api.projectlib.service.IProjectService; |
|
|
import com.hz.pm.api.sys.manage.ProcessModelManage; |
|
|
import com.hz.pm.api.sys.manage.ProcessModelManage; |
|
|
|
|
|
import com.hz.pm.api.user.helper.MhUnitQueryHelper; |
|
|
|
|
|
import com.hz.pm.api.user.helper.MhUnitQueryHelper.UnitQueryState; |
|
|
import com.hz.pm.api.user.security.model.UserFullInfoDTO; |
|
|
import com.hz.pm.api.user.security.model.UserFullInfoDTO; |
|
|
import com.hz.pm.api.user.security.model.UserInfoDetails; |
|
|
import com.hz.pm.api.user.security.model.UserInfoDetails; |
|
|
import com.hz.pm.api.user.util.LoginUserUtil; |
|
|
import com.hz.pm.api.user.util.LoginUserUtil; |
|
@@ -69,6 +72,7 @@ import java.time.LocalDateTime; |
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
|
|
import java.util.function.BiFunction; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@@ -98,12 +102,12 @@ public class ConstructionManage { |
|
|
private final TenderStateMachineUtil tenderStateMachineUtil; |
|
|
private final TenderStateMachineUtil tenderStateMachineUtil; |
|
|
private final XcfhxStateMachineUtil xcfhxStateMachineUtil; |
|
|
private final XcfhxStateMachineUtil xcfhxStateMachineUtil; |
|
|
private final MhXchxFileHelper mhXchxFileHelper; |
|
|
private final MhXchxFileHelper mhXchxFileHelper; |
|
|
|
|
|
|
|
|
private final IXinchuangService xinchuangService; |
|
|
private final IXinchuangService xinchuangService; |
|
|
|
|
|
|
|
|
private final TaskService taskService; |
|
|
private final TaskService taskService; |
|
|
|
|
|
|
|
|
private final IXinchuangInstService xinchuangInstService; |
|
|
private final IXinchuangInstService xinchuangInstService; |
|
|
|
|
|
private final MhUnitQueryHelper mhUnitQueryHelper; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 待采购的-项目列表 |
|
|
* 待采购的-项目列表 |
|
@@ -293,6 +297,57 @@ public class ConstructionManage { |
|
|
PRE_INSPECTED_PURCHASE_STATUS.add(TenderMainStatus.TO_BE_SUBMIT_FIRST_INSPECTED_INFO); |
|
|
PRE_INSPECTED_PURCHASE_STATUS.add(TenderMainStatus.TO_BE_SUBMIT_FIRST_INSPECTED_INFO); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public FirstAcceptProgressStatisticsVO firstAcceptProgressStatistics(ProjectListReq req) { |
|
|
|
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
|
|
|
String buildOrgCode = req.clearBuildOrgCode(); |
|
|
|
|
|
Long buildOrgCodeNum = NumberUtil.parseLong(buildOrgCode, null); |
|
|
|
|
|
UnitQueryState queryState = mhUnitQueryHelper.listCanViewUnitIds(buildOrgCodeNum, user); |
|
|
|
|
|
if (!queryState.isState()) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
LambdaQueryWrapper<Project> query = ProjectManageUtil.projectQuery(req) |
|
|
|
|
|
.select(Project::getId) |
|
|
|
|
|
.eq(Project::getNewest, Boolean.TRUE) |
|
|
|
|
|
.ne(Project::getStage, ProjectStatus.STOPPED.getCode()) |
|
|
|
|
|
.and(q1 -> q1.exists(ExistsSqlConst.PROJECT_EXISTS_PURCHASE |
|
|
|
|
|
+ " and np.status = {0} ", TenderMainStatus.TO_BE_SUBMIT_FIRST_INSPECTED_INFO.getCode()) |
|
|
|
|
|
.or(q2 -> q2.exists(ExistsSqlConst.PROJECT_EXISTS_PURCHASE_STATUS_CHANGE |
|
|
|
|
|
+ " and npsc.event = {0}", TenderStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES))); |
|
|
|
|
|
if (CollUtil.isNotEmpty(queryState.getUnitIds())) { |
|
|
|
|
|
query.in(Project::getBuildOrgCode, CollUtils.convert(queryState.getUnitIds(), String::valueOf)); |
|
|
|
|
|
} |
|
|
|
|
|
List<Project> projects = projectService.list(query); |
|
|
|
|
|
if (projects.isEmpty()) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
List<Long> projectIds = CollUtils.fieldList(projects, Project::getId); |
|
|
|
|
|
LambdaQueryWrapper<Purchase> purchaseQuery = Wrappers.lambdaQuery(Purchase.class) |
|
|
|
|
|
.select(Purchase::getStatus, Purchase::getProjectId) |
|
|
|
|
|
.in(Purchase::getProjectId, projectIds) |
|
|
|
|
|
.and(q1 -> q1.eq(Purchase::getStatus, TenderMainStatus.TO_BE_SUBMIT_FIRST_INSPECTED_INFO.getCode()) |
|
|
|
|
|
.or(q2 -> q2.exists(ExistsSqlConst.PURCHASE_EXISTS_STATUS_CHANGE |
|
|
|
|
|
+ " and npsc.event = {0}", TenderStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES))); |
|
|
|
|
|
List<Purchase> purchases = purchaseService.list(purchaseQuery); |
|
|
|
|
|
Map<Long, List<ITenderStatus>> purchaseMap = purchases.stream() |
|
|
|
|
|
.collect(Collectors.groupingBy(Purchase::getProjectId, |
|
|
|
|
|
Collectors.mapping(w -> { |
|
|
|
|
|
if (TenderMainStatus.TO_BE_SUBMIT_FIRST_INSPECTED_INFO.eq(w.getStatus())) { |
|
|
|
|
|
return TenderMainStatus.TO_BE_SUBMIT_FIRST_INSPECTED_INFO; |
|
|
|
|
|
} else { |
|
|
|
|
|
return TenderMainStatus.SUBMITTED_FIRST_INSPECTED_INFO; |
|
|
|
|
|
} |
|
|
|
|
|
}, Collectors.toList()))); |
|
|
|
|
|
BiFunction<Map<Long, List<ITenderStatus>>, ITenderStatus, Integer> counter = (p, s) -> { |
|
|
|
|
|
Collection<List<ITenderStatus>> values = purchaseMap.values(); |
|
|
|
|
|
return CollUtil.count(values, x -> CollUtil.anyMatch(x, w -> w.eq(s))); |
|
|
|
|
|
}; |
|
|
|
|
|
FirstAcceptProgressStatisticsVO stat = new FirstAcceptProgressStatisticsVO(); |
|
|
|
|
|
stat.setTotalCount(projectIds.size()); |
|
|
|
|
|
stat.setPassedCount(counter.apply(purchaseMap, TenderMainStatus.SUBMITTED_FIRST_INSPECTED_INFO)); |
|
|
|
|
|
stat.setTodoCount(counter.apply(purchaseMap, TenderMainStatus.TO_BE_SUBMIT_FIRST_INSPECTED_INFO)); |
|
|
|
|
|
return stat; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 待初验项目列表 |
|
|
* 待初验项目列表 |
|
|
* |
|
|
* |
|
@@ -301,29 +356,54 @@ public class ConstructionManage { |
|
|
*/ |
|
|
*/ |
|
|
public PageVo<ProjectLibListItemVO> preProjectList(ProjectListReq req) { |
|
|
public PageVo<ProjectLibListItemVO> preProjectList(ProjectListReq req) { |
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
Set<Long> projectIds = purchaseService.listProjectIdByStatus(PRE_INSPECTED_PURCHASE_STATUS); |
|
|
|
|
|
if (projectIds.isEmpty()) { |
|
|
|
|
|
|
|
|
String buildOrgCode = req.clearBuildOrgCode(); |
|
|
|
|
|
Long buildOrgCodeNum = NumberUtil.parseLong(buildOrgCode, null); |
|
|
|
|
|
UnitQueryState queryState = mhUnitQueryHelper.listCanViewUnitIds(buildOrgCodeNum, user); |
|
|
|
|
|
if (!queryState.isState()) { |
|
|
return PageVo.empty(); |
|
|
return PageVo.empty(); |
|
|
} |
|
|
} |
|
|
LambdaQueryWrapper<Project> query = ProjectManageUtil.projectQuery(req); |
|
|
|
|
|
query.in(Project::getId, projectIds); |
|
|
|
|
|
query.eq(Project::getStage, ProjectStatus.PROJECT_APPROVED.getCode()); |
|
|
|
|
|
query.eq(Project::getNewest, Boolean.TRUE); |
|
|
|
|
|
//只能看自己单位的 |
|
|
|
|
|
if (!user.hasSuperAdmin()) { |
|
|
|
|
|
query.eq(Project::getBuildOrgCode, user.getMhUnitIdStr()); |
|
|
|
|
|
|
|
|
String existsSql = String.format(ExistsSqlConst.PROJECT_EXISTS_PURCHASE_STATUS_CHANGE |
|
|
|
|
|
+ " and npsc.event = '%s'", TenderStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES); |
|
|
|
|
|
LambdaQueryWrapper<Project> query = ProjectManageUtil.projectQuery(req) |
|
|
|
|
|
.ne(Project::getStage, ProjectStatus.STOPPED.getCode()) |
|
|
|
|
|
.eq(Project::getNewest, Boolean.TRUE) |
|
|
|
|
|
.orderByAsc(Project::getDeliveryTime); |
|
|
|
|
|
if (req.getTabStatus() != null) { |
|
|
|
|
|
if (TenderMainStatus.TO_BE_SUBMIT_FIRST_INSPECTED_INFO.eq(req.getTabStatus())) { |
|
|
|
|
|
query.exists(ExistsSqlConst.PROJECT_EXISTS_PURCHASE + " and np.status = {0} ", req.getTabStatus()); |
|
|
|
|
|
} else { |
|
|
|
|
|
query.exists(existsSql); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
query.and(q1 -> q1.exists(ExistsSqlConst.PROJECT_EXISTS_PURCHASE + |
|
|
|
|
|
" and np.status = {0} ", TenderMainStatus.TO_BE_SUBMIT_FIRST_INSPECTED_INFO.getCode()) |
|
|
|
|
|
.or(q2 -> q2.exists(existsSql))); |
|
|
|
|
|
} |
|
|
|
|
|
if (CollUtil.isNotEmpty(queryState.getUnitIds())) { |
|
|
|
|
|
query.in(Project::getBuildOrgCode, CollUtils.convert(queryState.getUnitIds(), String::valueOf)); |
|
|
} |
|
|
} |
|
|
query.orderByAsc(Project::getDeliveryTime); |
|
|
|
|
|
Page<Project> page = projectService.page(req.page(), query); |
|
|
Page<Project> page = projectService.page(req.page(), query); |
|
|
long total; |
|
|
|
|
|
if ((total = page.getTotal()) == 0) { |
|
|
|
|
|
|
|
|
if (page.getTotal() == 0) { |
|
|
return PageVo.empty(); |
|
|
return PageVo.empty(); |
|
|
} |
|
|
} |
|
|
List<Long> currPageProjectIds = CollUtils.fieldList(page.getRecords(), Project::getId); |
|
|
|
|
|
List<Purchase> purchases = purchaseService.listByProjectIds(currPageProjectIds); |
|
|
|
|
|
|
|
|
List<Long> projectIds = CollUtils.fieldList(page.getRecords(), Project::getId); |
|
|
|
|
|
LambdaQueryWrapper<Purchase> purchaseQuery = Wrappers.lambdaQuery(Purchase.class) |
|
|
|
|
|
.in(Purchase::getProjectId, projectIds); |
|
|
|
|
|
if (req.getTabStatus() != null) { |
|
|
|
|
|
if (TenderMainStatus.TO_BE_SUBMIT_FIRST_INSPECTED_INFO.eq(req.getTabStatus())) { |
|
|
|
|
|
purchaseQuery.eq(Purchase::getStatus, req.getTabStatus()); |
|
|
|
|
|
} else { |
|
|
|
|
|
purchaseQuery.exists(ExistsSqlConst.PURCHASE_EXISTS_STATUS_CHANGE |
|
|
|
|
|
+ " and npsc.event = {0}", TenderStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
purchaseQuery.and(q1 -> q1.eq(Purchase::getStatus, TenderMainStatus.TO_BE_SUBMIT_FIRST_INSPECTED_INFO.getCode()) |
|
|
|
|
|
.or(q2 -> q2.exists(ExistsSqlConst.PURCHASE_EXISTS_STATUS_CHANGE |
|
|
|
|
|
+ " and npsc.event = {0}", TenderStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES))); |
|
|
|
|
|
} |
|
|
|
|
|
List<Purchase> purchases = purchaseService.list(purchaseQuery); |
|
|
Map<Long, List<Purchase>> purchaseMap = CollUtils.group(purchases, Purchase::getProjectId); |
|
|
Map<Long, List<Purchase>> purchaseMap = CollUtils.group(purchases, Purchase::getProjectId); |
|
|
Map<Long, Contract> contractMap = contractService.listByProjectIds(projectIds); |
|
|
Map<Long, Contract> contractMap = contractService.listByProjectIds(projectIds); |
|
|
Map<Long, List<ProjectAnnualPaymentPlan>> paymentPlansMap = projectPaymentPlanService.listByProjectIds(projectIds); |
|
|
|
|
|
|
|
|
|
|
|
List<ProjectLibListItemVO> records = CollUtils.convert(page.getRecords(), w -> { |
|
|
List<ProjectLibListItemVO> records = CollUtils.convert(page.getRecords(), w -> { |
|
|
ProjectLibListItemVO item = new ProjectLibListItemVO(); |
|
|
ProjectLibListItemVO item = new ProjectLibListItemVO(); |
|
@@ -345,11 +425,6 @@ public class ConstructionManage { |
|
|
item.setApprovalDate(w.getApprovalDate()); |
|
|
item.setApprovalDate(w.getApprovalDate()); |
|
|
item.setDeliveryTime(w.getDeliveryTime()); |
|
|
item.setDeliveryTime(w.getDeliveryTime()); |
|
|
item.setContractAmount(w.getContractAmount()); |
|
|
item.setContractAmount(w.getContractAmount()); |
|
|
List<ProjectAnnualPaymentPlan> paymentPlans = paymentPlansMap.getOrDefault(w.getId(), Collections.emptyList()); |
|
|
|
|
|
BigDecimal totalAnnualAmount = paymentPlans.stream() |
|
|
|
|
|
.map(ProjectAnnualPaymentPlan::getAnnualPlanAmount) |
|
|
|
|
|
.reduce(BigDecimal::add).orElse(BigDecimal.ZERO); |
|
|
|
|
|
item.setAnnualPlanAmount(totalAnnualAmount); |
|
|
|
|
|
item.setTransactionTime(w.getTransactionTime()); |
|
|
item.setTransactionTime(w.getTransactionTime()); |
|
|
item.setTransactionAmount(w.getTransactionAmount()); |
|
|
item.setTransactionAmount(w.getTransactionAmount()); |
|
|
List<Purchase> currPurchases = purchaseMap.get(w.getId()); |
|
|
List<Purchase> currPurchases = purchaseMap.get(w.getId()); |
|
@@ -358,19 +433,24 @@ public class ConstructionManage { |
|
|
TenderListInfoVO tender = new TenderListInfoVO(); |
|
|
TenderListInfoVO tender = new TenderListInfoVO(); |
|
|
tender.setBidName(x.getBidName()); |
|
|
tender.setBidName(x.getBidName()); |
|
|
tender.setBidId(x.getId()); |
|
|
tender.setBidId(x.getId()); |
|
|
tender.setBidStatus(x.getStatus()); |
|
|
|
|
|
tender.setBidStatusName(TenderMainStatus.getDesc(x.getStatus())); |
|
|
|
|
|
Contract contract = contractMap.get(x.getId()); |
|
|
Contract contract = contractMap.get(x.getId()); |
|
|
if (contract != null) { |
|
|
if (contract != null) { |
|
|
tender.setConstructionAmount(contract.getTotalAmount()); |
|
|
tender.setConstructionAmount(contract.getTotalAmount()); |
|
|
} |
|
|
} |
|
|
|
|
|
if (!TenderMainStatus.TO_BE_SUBMIT_FIRST_INSPECTED_INFO.eq(x.getStatus())) { |
|
|
|
|
|
tender.setBidStatus(TenderMainStatus.SUBMITTED_FIRST_INSPECTED_INFO.getCode()); |
|
|
|
|
|
tender.setBidStatusName(TenderMainStatus.SUBMITTED_FIRST_INSPECTED_INFO.getDesc()); |
|
|
|
|
|
} else { |
|
|
|
|
|
tender.setBidStatus(x.getStatus()); |
|
|
|
|
|
tender.setBidStatusName(TenderMainStatus.getDesc(x.getStatus())); |
|
|
|
|
|
} |
|
|
return tender; |
|
|
return tender; |
|
|
}); |
|
|
}); |
|
|
item.setTenders(tmpPurchases); |
|
|
item.setTenders(tmpPurchases); |
|
|
} |
|
|
} |
|
|
return item; |
|
|
return item; |
|
|
}); |
|
|
}); |
|
|
return PageVo.of(records, total); |
|
|
|
|
|
|
|
|
return PageVo.of(records, page.getTotal()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void exportPreList(HttpServletResponse response, ProjectListReq param) { |
|
|
public void exportPreList(HttpServletResponse response, ProjectListReq param) { |
|
|