From 241c5c5304e309b8f1351b627936c5b623af14e4 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Tue, 27 Aug 2024 14:16:42 +0800 Subject: [PATCH] =?UTF-8?q?modify:=201.=20=E9=A1=B9=E7=9B=AE=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E4=BF=AE=E6=94=B9=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PurchaseController.java | 9 +- .../api/projectdeclared/manage/PurchaseManage.java | 106 +++++++++++++++++---- .../model/vo/PurchaseProgressStatVO.java | 29 ++++++ .../api/projectlib/helper/ProjectManageUtil.java | 2 +- .../model/enumeration/status/TenderMainStatus.java | 1 + .../api/projectlib/model/req/ProjectListReq.java | 3 + 6 files changed, 130 insertions(+), 20 deletions(-) create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/vo/PurchaseProgressStatVO.java diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java index 7b5510e..0b736ab 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java @@ -37,8 +37,15 @@ import java.util.List; @Api(value = "PurchaseController", tags = "申报管理-采购结果备案") @RequiredArgsConstructor public class PurchaseController { + private final PurchaseManage purchaseManage; + @ApiOperation(value = "招标采购进度统计") + @GetMapping("/purchaseProgressStatistics") + public PurchaseProgressStatVO purchaseProgressStatistics(@ModelAttribute ProjectListReq req) { + return purchaseManage.purchaseProgressStatistics(req); + } + @ApiOperation(value = "待采购结果备案列表", notes = "待采购结果备案列表") @GetMapping("/project-list") public PageVo projectList(@ModelAttribute ProjectListReq req) { @@ -159,7 +166,7 @@ public class PurchaseController { @PostMapping("/orgConfirm") @ApiOperation("单位确认") @WebLog("单位确认") - public void orgConfirm(@RequestBody @Valid PurchaseOrgConfirmReq req){ + public void orgConfirm(@RequestBody @Valid PurchaseOrgConfirmReq req) { purchaseManage.purchaseOrgConfirm(req); } 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 4745084..647bdb8 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 @@ -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 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 projects = projectService.list(query); + if (projects.isEmpty()) { + return null; + } + List projectIds = CollUtils.fieldList(projects, Project::getId); + List purchases = purchaseService.list(Wrappers.lambdaQuery(Purchase.class) + .in(Purchase::getProjectId, projectIds) + .select(Purchase::getProjectId, Purchase::getStatus)); + Map> 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 page = projectService.page(req.page(), query); if (page.getTotal() == 0) { return PageVo.empty(); } - List projectIds = CollUtils.fieldList(page.getRecords(), Project::getId); - List purchases = purchaseService.listByProjectIds(projectIds); - Map> purchaseMap = CollUtils.group(purchases, Purchase::getProjectId); - Map contractAmountMap = contractService.listContractAmountByProjectIds(projectIds); + Map> purchaseMap; + Map contractAmountMap; + if (!ProjectStatus.TO_BE_PURCHASED.eq(req.getTabStatus())) { + List projectIds = CollUtils.fieldList(page.getRecords(), Project::getId); + LambdaQueryWrapper 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 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 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 currPurchases = purchaseMap.get(w.getId()); if (currPurchases != null) { - item.setTenders(CollUtils.convert(currPurchases, x -> { + List 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; }); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/vo/PurchaseProgressStatVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/vo/PurchaseProgressStatVO.java new file mode 100644 index 0000000..aded4da --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/vo/PurchaseProgressStatVO.java @@ -0,0 +1,29 @@ +package com.hz.pm.api.projectdeclared.model.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + *

+ * PurchaseProgressStatisticsVO + *

+ * + * @author WendyYang + * @since 11:58 2024/8/27 + */ +@Data +public class PurchaseProgressStatVO { + + @ApiModelProperty("总数量") + private Integer totalCount; + + @ApiModelProperty("待采购数量") + private Integer toBePurchaseCount; + + @ApiModelProperty("采购中数量") + private Integer onPurchaseCount; + + @ApiModelProperty("已采购数量") + private Integer purchaseFinishedCount; + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectManageUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectManageUtil.java index 14c3322..4f45701 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectManageUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectManageUtil.java @@ -96,7 +96,7 @@ public class ProjectManageUtil { public static void projectBaseQuery(LambdaQueryWrapper query) { query.select(Project::getId, Project::getStage, Project::getStatus, Project::getProjectCode, - Project::getBuildOrgCode, Project::getBuildOrgName, Project::getApprovalAmount, + Project::getBuildOrgCode, Project::getBuildOrgName, Project::getApprovalAmount, Project::getApprovalDate, Project::getCreateOn, Project::getProjectName, Project::getProjectYear, Project::getDeclareAmount, Project::getReviewAmount, Project::getUnitStrip); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderMainStatus.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderMainStatus.java index ccb33cc..7140a1e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderMainStatus.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderMainStatus.java @@ -25,6 +25,7 @@ import java.util.stream.Stream; public enum TenderMainStatus implements ITenderStatus { TO_BE_SUBMIT_PURCHASE_CONSTRUCTION_INFO(ProjectStatus.ON_PURCHASING, 101, "待填写采购&合同信息"), + PURCHASE_FINISHED(ProjectStatus.ON_PURCHASING, 106, "采购完成"), TO_BE_SUBMIT_OPERATION_PLAN(ProjectStatus.ON_ADAPTING, 103, "待填写实施计划"), // 衔接状态 WAIT_ORG_CONFIRM(ProjectStatus.ON_ADAPTING, 104, "待单位确认"), diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java index 72a10d6..b596e79 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java @@ -127,4 +127,7 @@ public class ProjectListReq extends PagePo { @ApiModelProperty("标项状态") private Integer bidStatus; + @ApiModelProperty("tab状态") + private Integer tabStatus; + }