瀏覽代碼

modify:

1. 终验列表查询修改;
tags/24090601
WendyYang 2 月之前
父節點
當前提交
de1b3bdcca
共有 3 個文件被更改,包括 130 次插入30 次删除
  1. +7
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/FinalAcceptanceController.java
  2. +89
    -30
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java
  3. +34
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/vo/FinalAcceptProgressStatisticsVO.java

+ 7
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/FinalAcceptanceController.java 查看文件

@@ -3,6 +3,7 @@ package com.hz.pm.api.projectdeclared.controller;
import com.hz.pm.api.common.util.ExcelDownUtil;
import com.hz.pm.api.projectdeclared.manage.FinalAcceptanceManage;
import com.hz.pm.api.projectdeclared.model.req.SubmitFinallyInspectedReq;
import com.hz.pm.api.projectdeclared.model.vo.FinalAcceptProgressStatisticsVO;
import com.hz.pm.api.projectdeclared.model.vo.FinalAcceptanceVO;
import com.hz.pm.api.projectlib.model.req.ProjectListReq;
import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO;
@@ -34,6 +35,12 @@ public class FinalAcceptanceController {

private final FinalAcceptanceManage finalAcceptanceManage;

@GetMapping("/progressStatistics")
@ApiOperation(value = "项目终验进度统计", notes = "项目终验进度统计")
public FinalAcceptProgressStatisticsVO progressStatistics(@ModelAttribute ProjectListReq req) {
return finalAcceptanceManage.finalAcceptProgressStatistics(req);
}

@ApiOperation(value = "待终验申报的项目列表", notes = "待终验申报的项目列表")
@GetMapping("/project-list")
public PageVo<ProjectLibListItemVO> projectlist(@ModelAttribute ProjectListReq req) {


+ 89
- 30
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java 查看文件

@@ -1,7 +1,10 @@
package com.hz.pm.api.projectdeclared.manage;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -18,24 +21,24 @@ 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.entity.PurchaseInst;
import com.hz.pm.api.projectdeclared.model.req.SubmitFinallyInspectedReq;
import com.hz.pm.api.projectdeclared.model.vo.FinalAcceptProgressStatisticsVO;
import com.hz.pm.api.projectdeclared.model.vo.FinalAcceptanceVO;
import com.hz.pm.api.projectdeclared.service.IContractService;
import com.hz.pm.api.projectdeclared.service.IPurchaseInstService;
import com.hz.pm.api.projectdeclared.service.IPurchaseService;
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.ProjectAnnualPaymentPlan;
import com.hz.pm.api.projectlib.model.entity.ProjectInst;
import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus;
import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum;
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.req.ProjectListReq;
import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO;
import com.hz.pm.api.projectlib.model.vo.TenderListInfoVO;
import com.hz.pm.api.projectlib.service.IProjectAnnualPaymentPlanService;
import com.hz.pm.api.projectlib.service.IProjectInstService;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.sys.manage.ProcessModelManage;
import com.hz.pm.api.user.helper.MhUnitQueryHelper;
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;
@@ -55,9 +58,13 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;

import static com.hz.pm.api.user.helper.MhUnitQueryHelper.*;

/**
* @Classname FinalAcceptanceManage
@@ -78,10 +85,10 @@ public class FinalAcceptanceManage {
private final ProcessInstanceService processInstanceService;
private final DeclaredProjectHelper declaredProjectManage;
private final IContractService contractService;
private final IProjectAnnualPaymentPlanService projectAnnualPaymentPlanService;
private final ProjectStateMachineUtil projectStateMachineUtil;
private final TenderStateMachineUtil tenderStateMachineUtil;
private final IProjectInstService projectInstService;
private final MhUnitQueryHelper mhUnitQueryHelper;

//==================================================================================================================

@@ -89,46 +96,104 @@ public class FinalAcceptanceManage {

static {
FINAL_INSPECTED_TENDER_STATUS = new ArrayList<>();
FINAL_INSPECTED_TENDER_STATUS.add(TenderMainStatus.FINALLY_INSPECTED_FAILED);
FINAL_INSPECTED_TENDER_STATUS.add(TenderMainStatus.TO_BE_SUBMIT_FINALLY_INSPECTED_APPLY);
FINAL_INSPECTED_TENDER_STATUS.add(TenderMainStatus.ON_FINALLY_INSPECTED_APPLY);
FINAL_INSPECTED_TENDER_STATUS.add(TenderMainStatus.FINALLY_INSPECTED_PASSED);
FINAL_INSPECTED_TENDER_STATUS.add(TenderMainStatus.FINALLY_INSPECTED_FAILED);
}


/**
* 待采购的-项目列表
*
* @param req \
* @return \
*/
public PageVo<ProjectLibListItemVO> projectLibList(ProjectListReq req) {

public FinalAcceptProgressStatisticsVO finalAcceptProgressStatistics(ProjectListReq req) {
LambdaQueryWrapper<Purchase> purchaseQuery = Wrappers.lambdaQuery(Purchase.class)
.select(Purchase::getProjectId, Purchase::getStatus)
.in(Purchase::getStatus, CollUtils.fieldList(FINAL_INSPECTED_TENDER_STATUS, TenderMainStatus::getCode));
List<Purchase> purchases = purchaseService.list(purchaseQuery);
if (purchases.isEmpty()) {
return null;
}
UserInfoDetails user = LoginUserUtil.loginUserDetail();
String buildOrgCode = req.getBuildOrgCode();
req.setBuildOrgCode(null);
LambdaQueryWrapper<Project> query = ProjectManageUtil.projectQuery(req);
//待终验 并且还未过期
//只能看自己单位的
Long buildOrgCodeNum = NumberUtil.parseLong(buildOrgCode, null);
UnitQueryState queryState = mhUnitQueryHelper.listCanViewUnitIds(buildOrgCodeNum, user);
if (!queryState.isState()) {
return null;
}
if (CollUtil.isNotEmpty(queryState.getUnitIds())) {
query.in(Project::getBuildOrgCode, CollUtils.convert(queryState.getUnitIds(), String::valueOf));
}
query.in(Project::getId, CollUtils.fieldList(purchases, Purchase::getProjectId))
.select(Project::getId)
.eq(Project::getNewest, Boolean.TRUE);
List<Project> projects = projectService.list(query);
List<Long> projectIds = CollUtils.fieldList(projects, Project::getId);
Map<Long, List<Integer>> purchaseStatusMap = purchases.stream()
.filter(purchase -> projectIds.contains(purchase.getProjectId()))
.collect(Collectors.groupingBy(Purchase::getProjectId,
Collectors.mapping(Purchase::getStatus, Collectors.toList())));
BiFunction<Map<Long, List<Integer>>, TenderMainStatus, Integer> counter = (statusMap, status) -> {
Set<Map.Entry<Long, List<Integer>>> entries = statusMap.entrySet();
return CollUtil.count(entries, entry -> entry.getValue().contains(status.getCode()));
};
return FinalAcceptProgressStatisticsVO.builder()
.totalCount(projects.size())
.auditCount(counter.apply(purchaseStatusMap, TenderMainStatus.ON_FINALLY_INSPECTED_APPLY))
.todoCount(counter.apply(purchaseStatusMap, TenderMainStatus.TO_BE_SUBMIT_FINALLY_INSPECTED_APPLY))
.failedCount(counter.apply(purchaseStatusMap, TenderMainStatus.FINALLY_INSPECTED_FAILED))
.passedCount(counter.apply(purchaseStatusMap, TenderMainStatus.FINALLY_INSPECTED_PASSED))
.build();
}

/**
* 待采购的-项目列表
*
* @param req \
* @return \
*/
public PageVo<ProjectLibListItemVO> projectLibList(ProjectListReq req) {
Set<Long> projectIds = purchaseService.listProjectIdByStatus(FINAL_INSPECTED_TENDER_STATUS);
if (projectIds.isEmpty()) {
return PageVo.empty();
}
if (!user.hasSuperAdmin()) {
query.eq(Project::getBuildOrgCode, user.getMhUnitIdStr());
UserInfoDetails user = LoginUserUtil.loginUserDetail();
String buildOrgCode = req.getBuildOrgCode();
req.setBuildOrgCode(null);
LambdaQueryWrapper<Project> query = ProjectManageUtil.projectQuery(req)
.in(Project::getId, projectIds)
.eq(Project::getNewest, Boolean.TRUE)
.orderByAsc(Project::getApprovalDate);
Long buildOrgCodeNum = NumberUtil.parseLong(buildOrgCode, null);
UnitQueryState queryState = mhUnitQueryHelper.listCanViewUnitIds(buildOrgCodeNum, user);
if (!queryState.isState()) {
return null;
}
if (CollUtil.isNotEmpty(queryState.getUnitIds())) {
query.in(Project::getBuildOrgCode, CollUtils.convert(queryState.getUnitIds(), String::valueOf));
}
query.in(Project::getId, projectIds);
query.eq(Project::getStage, ProjectStatus.PROJECT_APPROVED.getCode());
query.eq(Project::getNewest, Boolean.TRUE);
query.orderByAsc(Project::getApprovalDate);
Page<Project> page = projectService.page(req.page(), query);
if (page.getTotal() == 0) {
return PageVo.empty();
}

Set<Long> allProjectIds = CollUtils.fieldSet(page.getRecords(), Project::getId);
List<Purchase> purchases = purchaseService.listByProjectIds(allProjectIds);
Map<Long, List<Purchase>> purchaseMap = CollUtils.group(purchases, Purchase::getProjectId);
Map<Long, Contract> contractMap = contractService.listByProjectIds(projectIds);
Map<Long, List<ProjectAnnualPaymentPlan>> paymentPlansMap = projectAnnualPaymentPlanService.listByProjectIds(projectIds);

Wrapper<Purchase> purchaseQuery = Wrappers.lambdaQuery(Purchase.class)
.in(Purchase::getProjectId, allProjectIds)
.eq(Purchase::getStatus, req.getTabStatus());
List<Purchase> purchases = purchaseService.list(purchaseQuery);
Map<Long, List<Purchase>> purchaseMap;
Map<Long, Contract> contractMap;
if (!purchases.isEmpty()) {
purchaseMap = CollUtils.group(purchases, Purchase::getProjectId);
contractMap = contractService.listByProjectIds(projectIds);
} else {
purchaseMap = Collections.emptyMap();
contractMap = Collections.emptyMap();
}
List<ProjectLibListItemVO> records = CollUtils.convert(page.getRecords(), w -> {
ProjectLibListItemVO item = new ProjectLibListItemVO();
item.setId(w.getId());
@@ -147,13 +212,7 @@ public class FinalAcceptanceManage {
item.setReviewAmount(w.getReviewAmount());
item.setApprovedAmount(w.getApprovalAmount());
item.setApprovalDate(w.getApprovalDate());
item.setBuildCycle(StringUtils.isNotBlank(w.getBuildCycle()) ?
Integer.valueOf(w.getBuildCycle()) : null);
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.setBuildCycle(StrUtil.isNotBlank(w.getBuildCycle()) ? Integer.valueOf(w.getBuildCycle()) : null);
item.setPlanAcceptanceTime(w.getPlanAcceptanceTime());
List<Purchase> currPurchases = purchaseMap.get(w.getId());
if (currPurchases != null) {


+ 34
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/vo/FinalAcceptProgressStatisticsVO.java 查看文件

@@ -0,0 +1,34 @@
package com.hz.pm.api.projectdeclared.model.vo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;

/**
* <p>
* FinalAcceptProgressStatisticsVO
* </p>
*
* @author WendyYang
* @since 10:19 2024/9/3
*/
@Data
@Builder
public class FinalAcceptProgressStatisticsVO {

@ApiModelProperty("总数量")
private Integer totalCount;

@ApiModelProperty("审核中数量")
private Integer auditCount;

@ApiModelProperty("待终验申报数量")
private Integer todoCount;

@ApiModelProperty("已终验数量")
private Integer passedCount;

@ApiModelProperty("已终验数量")
private Integer failedCount;

}

Loading…
取消
儲存