|
|
@@ -18,6 +18,7 @@ import com.google.common.collect.Lists; |
|
|
|
import com.hz.pm.api.common.enumeration.ProjectProcessType; |
|
|
|
import com.hz.pm.api.common.helper.UserInfoHelper; |
|
|
|
import com.hz.pm.api.common.model.constant.ExistsSqlConst; |
|
|
|
import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; |
|
|
|
import com.hz.pm.api.common.statemachine.event.TenderStateChangeEvent; |
|
|
|
import com.hz.pm.api.common.statemachine.util.*; |
|
|
|
import com.hz.pm.api.common.util.*; |
|
|
@@ -124,6 +125,38 @@ public class PurchaseManage { |
|
|
|
private final MhXchxFileHelper mhXchxFileHelper; |
|
|
|
private final IPurchaseStatusChangeService purchaseStatusChangeService; |
|
|
|
|
|
|
|
public PurchaseProgressStatVO purchaseProgressStatistics(ProjectListReq req) { |
|
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
|
LambdaQueryWrapper<Project> query = ProjectManageUtil.projectQuery(req); |
|
|
|
//数据权限 |
|
|
|
permission(query, user); |
|
|
|
//待采购状态 |
|
|
|
query.notIn(Project::getStage, ProjectStatus.STOPPED.getCode(), ProjectStatus.CHANGE.getCode()) |
|
|
|
.eq(Project::getStage, ProjectStatus.PROJECT_APPROVED.getCode()) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE) |
|
|
|
.exists(ExistsSqlConst.PROJECT_EXISTS_STATUS_CHANGE + |
|
|
|
" and npsc.event = {0}", ProjectStateChangeEvent.DECLARED_RECORD_PASS) |
|
|
|
.select(Project::getId); |
|
|
|
List<Project> projects = projectService.list(query); |
|
|
|
if (projects.isEmpty()) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
List<Long> projectIds = CollUtils.fieldList(projects, Project::getId); |
|
|
|
List<Purchase> purchases = purchaseService.list(Wrappers.lambdaQuery(Purchase.class) |
|
|
|
.in(Purchase::getProjectId, projectIds) |
|
|
|
.select(Purchase::getProjectId, Purchase::getStatus)); |
|
|
|
Map<Long, Collection<Purchase>> projectPurchaseMap = CollUtils.listToMap(projects, Project::getId, |
|
|
|
w -> CollUtil.filterNew(purchases, x -> x.getProjectId().equals(w.getId()))); |
|
|
|
PurchaseProgressStatVO stat = new PurchaseProgressStatVO(); |
|
|
|
stat.setOnPurchaseCount(CollUtil.count(projectPurchaseMap.values(), |
|
|
|
w -> CollUtil.anyMatch(w, x -> TenderMainStatus.TO_BE_SUBMIT_PURCHASE_CONSTRUCTION_INFO.eq(x.getStatus())))); |
|
|
|
stat.setToBePurchaseCount(CollUtil.count(projectPurchaseMap.values(), Collection::isEmpty)); |
|
|
|
stat.setPurchaseFinishedCount(CollUtil.count(projectPurchaseMap.values(), |
|
|
|
w -> CollUtil.anyMatch(w, x -> !TenderMainStatus.TO_BE_SUBMIT_PURCHASE_CONSTRUCTION_INFO.eq(x.getStatus())))); |
|
|
|
stat.setTotalCount(projects.size()); |
|
|
|
return stat; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 待采购的-项目列表 |
|
|
|
* |
|
|
@@ -137,23 +170,56 @@ public class PurchaseManage { |
|
|
|
//数据权限 |
|
|
|
permission(query, user); |
|
|
|
//待采购状态 |
|
|
|
query.in(Project::getStatus, Lists.newArrayList(ProjectStatus.TO_BE_PURCHASED.getCode(), |
|
|
|
ProjectStatus.ON_PURCHASING.getCode())); |
|
|
|
query.notIn(Project::getStage, ProjectStatus.STOPPED.getCode(), ProjectStatus.CHANGE.getCode()); |
|
|
|
query.eq(Project::getStage, ProjectStatus.PROJECT_APPROVED.getCode()); |
|
|
|
query.eq(Project::getNewest, Boolean.TRUE); |
|
|
|
query.orderByAsc(Project::getApprovalDate); |
|
|
|
if (req.getBidStatus() != null) { |
|
|
|
query.exists(ExistsSqlConst.PROJECT_EXISTS_PURCHASE + |
|
|
|
"and (np.status = {0} or np.xcfhx_apply_status = {0})", req.getBidStatus()); |
|
|
|
ProjectManageUtil.projectBaseQuery(query); |
|
|
|
if (req.getTabStatus() != null) { |
|
|
|
if (TenderMainStatus.TO_BE_SUBMIT_PURCHASE_CONSTRUCTION_INFO.eq(req.getTabStatus())) { |
|
|
|
query.exists(ExistsSqlConst.PROJECT_EXISTS_PURCHASE + |
|
|
|
" and np.status = '{0}' ", req.getTabStatus()); |
|
|
|
} else if (TenderMainStatus.PURCHASE_FINISHED.eq(req.getTabStatus())) { |
|
|
|
query.exists(ExistsSqlConst.PROJECT_EXISTS_PURCHASE_STATUS_CHANGE + |
|
|
|
" and npsc.event = {0} ", TenderStateChangeEvent.SUBMIT_PURCHASE_CONSTRUCTION_INFO); |
|
|
|
} else if (ProjectStatus.TO_BE_PURCHASED.eq(req.getTabStatus())) { |
|
|
|
query.eq(Project::getStatus, ProjectStatus.TO_BE_PURCHASED); |
|
|
|
} else { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
query.exists(ExistsSqlConst.PROJECT_EXISTS_STATUS_CHANGE + |
|
|
|
" and npsc.event = {0}", ProjectStateChangeEvent.DECLARED_RECORD_PASS); |
|
|
|
} |
|
|
|
Page<Project> page = projectService.page(req.page(), query); |
|
|
|
if (page.getTotal() == 0) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
List<Long> projectIds = CollUtils.fieldList(page.getRecords(), Project::getId); |
|
|
|
List<Purchase> purchases = purchaseService.listByProjectIds(projectIds); |
|
|
|
Map<Long, List<Purchase>> purchaseMap = CollUtils.group(purchases, Purchase::getProjectId); |
|
|
|
Map<Long, BigDecimal> contractAmountMap = contractService.listContractAmountByProjectIds(projectIds); |
|
|
|
Map<Long, List<Purchase>> purchaseMap; |
|
|
|
Map<Long, BigDecimal> contractAmountMap; |
|
|
|
if (!ProjectStatus.TO_BE_PURCHASED.eq(req.getTabStatus())) { |
|
|
|
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_PURCHASE_CONSTRUCTION_INFO.eq(req.getTabStatus())) { |
|
|
|
purchaseQuery.eq(Purchase::getStatus, req.getStatus()); |
|
|
|
} else if (TenderMainStatus.PURCHASE_FINISHED.eq(req.getTabStatus())) { |
|
|
|
purchaseQuery.exists(ExistsSqlConst.PURCHASE_EXISTS_PURCHASE_STATUS_CHANGE + |
|
|
|
" and npsc.event = {0} ", TenderStateChangeEvent.SUBMIT_PURCHASE_CONSTRUCTION_INFO); |
|
|
|
} |
|
|
|
} |
|
|
|
List<Purchase> purchases = purchaseService.list(purchaseQuery); |
|
|
|
purchaseMap = CollUtils.group(purchases, Purchase::getProjectId); |
|
|
|
if (purchaseMap.isEmpty()) { |
|
|
|
contractAmountMap = Collections.emptyMap(); |
|
|
|
} else { |
|
|
|
contractAmountMap = contractService.listContractAmountByProjectIds(projectIds); |
|
|
|
} |
|
|
|
} else { |
|
|
|
purchaseMap = Collections.emptyMap(); |
|
|
|
contractAmountMap = Collections.emptyMap(); |
|
|
|
} |
|
|
|
List<ProjectLibListItemVO> records = CollUtils.convert(page.getRecords(), w -> { |
|
|
|
ProjectLibListItemVO item = new ProjectLibListItemVO(); |
|
|
|
item.setId(w.getId()); |
|
|
@@ -165,24 +231,28 @@ public class PurchaseManage { |
|
|
|
item.setProjectType(w.getProjectType()); |
|
|
|
item.setProjectYear(w.getProjectYear()); |
|
|
|
item.setBuildOrg(w.getBuildOrgName()); |
|
|
|
item.setBizDomain(w.getBizDomain()); |
|
|
|
item.setProcessStatus(w.getProcessStatus()); |
|
|
|
item.setInstCode(w.getInstCode()); |
|
|
|
item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); |
|
|
|
item.setApprovedAmount(w.getApprovalAmount()); |
|
|
|
item.setReviewAmount(w.getReviewAmount()); |
|
|
|
item.setApprovalDate(w.getApprovalDate()); |
|
|
|
List<Purchase> currPurchases = purchaseMap.get(w.getId()); |
|
|
|
if (currPurchases != null) { |
|
|
|
item.setTenders(CollUtils.convert(currPurchases, x -> { |
|
|
|
List<TenderListInfoVO> tenders = new ArrayList<>(); |
|
|
|
for (Purchase x : currPurchases) { |
|
|
|
TenderMainStatus tenderMainStatus; |
|
|
|
if (!TenderMainStatus.TO_BE_SUBMIT_PURCHASE_CONSTRUCTION_INFO.eq(x.getStatus())) { |
|
|
|
tenderMainStatus = TenderMainStatus.PURCHASE_FINISHED; |
|
|
|
} else { |
|
|
|
tenderMainStatus = TenderMainStatus.TO_BE_SUBMIT_PURCHASE_CONSTRUCTION_INFO; |
|
|
|
} |
|
|
|
TenderListInfoVO tender = new TenderListInfoVO(); |
|
|
|
tender.setBidName(x.getBidName()); |
|
|
|
tender.setBidId(x.getId()); |
|
|
|
tender.setBidStatus(x.getStatus()); |
|
|
|
tender.setBidStatusName(TenderMainStatus.getDesc(x.getStatus())); |
|
|
|
tender.setBidStatus(tenderMainStatus.getCode()); |
|
|
|
tender.setBidStatusName(tenderMainStatus.getDesc()); |
|
|
|
tender.setConstructionAmount(contractAmountMap.get(x.getId())); |
|
|
|
return tender; |
|
|
|
})); |
|
|
|
tenders.add(tender); |
|
|
|
item.setTenders(tenders); |
|
|
|
} |
|
|
|
} |
|
|
|
return item; |
|
|
|
}); |
|
|
|