|
|
@@ -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<Integer> thisTwoYears = Lists.newArrayList(LocalDateTime.now().getYear() - 1 |
|
|
|
,LocalDateTime.now().getYear()); |
|
|
|
|
|
|
|
public CostStatisticsVO statistics() { |
|
|
|
CostStatisticsVO res = new CostStatisticsVO(); |
|
|
|
List<Meeting> meetings = meetingService.list(Wrappers.lambdaQuery(Meeting.class)); |
|
|
|
List<Long> meetingIds = meetings.stream().map(Meeting::getId) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
//算出所有的 同意的专家 |
|
|
|
List<MeetingExpert> 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<DataDTO> twoYearsReviews = Lists.newArrayList(); |
|
|
|
List<DataDTO> twoYearsPricing = Lists.newArrayList(); |
|
|
|
List<DataDTO> 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<Meeting> 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<Long> yearMeetingIds = yearMeetings.stream().map(Meeting::getId) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
//算出所有的 同意的专家 |
|
|
|
List<MeetingExpert> 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; |
|
|
|
} |
|
|
|
} |