From 546be450f5b65230e7ab009ebbaba19401757057 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Wed, 6 Dec 2023 17:35:28 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=88=90=E6=9C=AC=20?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/common/model/entity/DataDTO.java | 7 +- .../dashboard/constant/DashboardConstant.java | 10 +- .../dashboard/controller/StatisticsController.java | 9 ++ .../manage/ProjectCostStatisticsManage.java | 102 +++++++++++++++++++++ .../pmapi/dashboard/model/vo/CostStatisticsVO.java | 31 +++++++ 5 files changed, 154 insertions(+), 5 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/ProjectCostStatisticsManage.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/CostStatisticsVO.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/model/entity/DataDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/model/entity/DataDTO.java index b5086fa..ef5838e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/model/entity/DataDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/model/entity/DataDTO.java @@ -26,8 +26,11 @@ public class DataDTO { private String name; @ApiModelProperty("数量") - private Integer num; + private Integer num = 0; + + @ApiModelProperty("金额") + private BigDecimal amount = BigDecimal.ZERO; @ApiModelProperty("比例") - private BigDecimal rate; + private BigDecimal rate = BigDecimal.ZERO; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/constant/DashboardConstant.java b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/constant/DashboardConstant.java index 95127f2..7a32a3c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/constant/DashboardConstant.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/constant/DashboardConstant.java @@ -1,5 +1,7 @@ package com.ningdatech.pmapi.dashboard.constant; +import java.math.BigDecimal; + /** * @author liuxinxin * @date 2023/8/2 下午2:46 @@ -7,7 +9,7 @@ package com.ningdatech.pmapi.dashboard.constant; public class DashboardConstant { - public class Protrait{ + public static class Protrait{ public static final String NONE = "暂无"; public static final String PLAN = "计划"; public static final String DECLARED = "申报"; @@ -26,13 +28,13 @@ public class DashboardConstant { } - public class CockpitStats{ + public static class CockpitStats{ //总数 public static final String TOTAL = "TOTAL"; public static final int NONE_YEAR = 0; } - public class Expert { + public static class Expert { public static final String ACCOUNT_STATUS_OK = "available"; public static final String DISTRIBUTION_SHENG = "省维度"; @@ -65,5 +67,7 @@ public class DashboardConstant { public static final String EXPERT_LEVEL_CHUJI = "900003"; public static final String EXPERT_LEVEL_NULL = "900004"; + + public static final BigDecimal REVIEW_AOUMT_EXPERT = BigDecimal.valueOf(0.05); } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/controller/StatisticsController.java b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/controller/StatisticsController.java index 72aaa14..678cbf1 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/controller/StatisticsController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/controller/StatisticsController.java @@ -3,6 +3,7 @@ package com.ningdatech.pmapi.dashboard.controller; import com.ningdatech.pmapi.dashboard.manage.ExpertStatisticsManage; import com.ningdatech.pmapi.dashboard.manage.FundStatisticsManage; import com.ningdatech.pmapi.dashboard.manage.MeetingStatisticsManage; +import com.ningdatech.pmapi.dashboard.manage.ProjectCostStatisticsManage; import com.ningdatech.pmapi.dashboard.model.vo.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -27,6 +28,8 @@ public class StatisticsController { private final MeetingStatisticsManage meetingStatisticsManage; + private final ProjectCostStatisticsManage costStatisticsManage; + @GetMapping("/fund") @ApiOperation("项目资金统计") public FundStatisticsVO fund(@RequestParam(required = false) Integer year) { @@ -44,4 +47,10 @@ public class StatisticsController { public MeetingStatisticsVO meeting(@RequestParam(required = false) Integer year) { return meetingStatisticsManage.statistics(year); } + + @GetMapping("/project-cost") + @ApiOperation("项目成本统计") + public CostStatisticsVO projectCost() { + return costStatisticsManage.statistics(); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/ProjectCostStatisticsManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/ProjectCostStatisticsManage.java new file mode 100644 index 0000000..2f0c5c8 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/ProjectCostStatisticsManage.java @@ -0,0 +1,102 @@ +package com.ningdatech.pmapi.dashboard.manage; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; +import com.ningdatech.pmapi.common.model.entity.DataDTO; +import com.ningdatech.pmapi.dashboard.constant.DashboardConstant; +import com.ningdatech.pmapi.dashboard.model.vo.CostStatisticsVO; +import com.ningdatech.pmapi.expert.service.IExpertReviewService; +import com.ningdatech.pmapi.meeting.entity.domain.Meeting; +import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; +import com.ningdatech.pmapi.meeting.service.IMeetingExpertService; +import com.ningdatech.pmapi.meeting.service.IMeetingService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @Classname ProjectCostStatisticsManage + * @Description + * @Date 2023/12/05 17:44 + * @Author PoffyZhang + */ +@Component +@RequiredArgsConstructor +@Slf4j +public class ProjectCostStatisticsManage { + + private final IExpertReviewService expertReviewService; + + private final IMeetingExpertService meetingExpertService; + + private final IMeetingService meetingService; + + List thisTwoYears = Lists.newArrayList(LocalDateTime.now().getYear() - 1 + ,LocalDateTime.now().getYear()); + + public CostStatisticsVO statistics() { + CostStatisticsVO res = new CostStatisticsVO(); + List meetings = meetingService.list(Wrappers.lambdaQuery(Meeting.class)); + List meetingIds = meetings.stream().map(Meeting::getId) + .collect(Collectors.toList()); + //算出所有的 同意的专家 + List meetingExperts = meetingExpertService.listAgreedExperts(meetingIds); + + //评审费 每人500 (0.05万) + BigDecimal reviewAoumtExpert = DashboardConstant.Expert.REVIEW_AOUMT_EXPERT; + + //计算累积 + res.setReviewAmount(reviewAoumtExpert.multiply(BigDecimal.valueOf(meetingExperts.size()))); + res.setPricingAmount(BigDecimal.ZERO); + + //近两年 + List twoYearsReviews = Lists.newArrayList(); + List twoYearsPricing = Lists.newArrayList(); + List twoYearsAvg = Lists.newArrayList(); + + DataDTO reviewAvg = new DataDTO(); + reviewAvg.setName("评审费"); + DataDTO pricingAvg = new DataDTO(); + pricingAvg.setName("核价费"); + BigDecimal reviewTwoYearTotal = BigDecimal.ZERO; + BigDecimal pricingTwoYearTotal = BigDecimal.ZERO; + for(Integer thisYear : thisTwoYears){ + DataDTO reviewData = new DataDTO(); + DataDTO pricingData = new DataDTO(); + //查出 年份的 会议数据 + List yearMeetings = meetings.stream().filter(m -> { + if(Objects.nonNull(m.getStartTime()) && + ( thisYear.equals(m.getStartTime().getYear()))){ + return Boolean.TRUE; + } + return Boolean.FALSE; + }).collect(Collectors.toList()); + List yearMeetingIds = yearMeetings.stream().map(Meeting::getId) + .collect(Collectors.toList()); + //算出所有的 同意的专家 + List yearMeetingExperts = meetingExpertService.listAgreedExperts(yearMeetingIds); + reviewData.setName(thisYear.toString()); + reviewData.setAmount(reviewAoumtExpert.multiply(BigDecimal + .valueOf(yearMeetingExperts.size()))); + pricingData.setName(thisYear.toString()); + twoYearsReviews.add(reviewData); + twoYearsPricing.add(pricingData); + + reviewTwoYearTotal = reviewTwoYearTotal.add(reviewAoumtExpert.multiply(BigDecimal + .valueOf(yearMeetingExperts.size()))); + } + reviewAvg.setAmount(reviewTwoYearTotal.divide(BigDecimal.valueOf(2))); + twoYearsAvg.add(reviewAvg); + twoYearsAvg.add(pricingAvg); + res.setTwoYearsReviews(twoYearsReviews); + res.setTwoYearsPricing(twoYearsPricing); + res.setTwoYearsAvg(twoYearsAvg); + return res; + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/CostStatisticsVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/CostStatisticsVO.java new file mode 100644 index 0000000..297da48 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/CostStatisticsVO.java @@ -0,0 +1,31 @@ +package com.ningdatech.pmapi.dashboard.model.vo; + +import com.ningdatech.pmapi.common.model.entity.DataDTO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +@Data +@ApiModel(value = "项目成本统计", description = "") +public class CostStatisticsVO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("累积专家评审费用") + private BigDecimal reviewAmount = BigDecimal.ZERO; + + @ApiModelProperty("累积专家核价费用") + private BigDecimal pricingAmount = BigDecimal.ZERO; + + @ApiModelProperty("市本级近两年人工核价费") + private List twoYearsPricing; + + @ApiModelProperty("市本级近两年人工评审费") + private List twoYearsReviews; + + @ApiModelProperty("市本级近两年平均专家评审/核价费") + private List twoYearsAvg; +} \ No newline at end of file