|
@@ -1,5 +1,7 @@
|
|
|
package com.enteprise.industry_oveview.service.impl;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -48,10 +50,43 @@ public class IndustryOverviewServiceImpl implements IIndustryOverviewService
|
|
|
@Override
|
|
|
public List<IndustryOverview> selectIndustryOverviewList(IndustryOverview industryOverview)
|
|
|
{
|
|
|
- List<IndustryOverview> list;
|
|
|
+ List<IndustryOverview> list = new ArrayList<>();;
|
|
|
if (industryOverview.getYear() == 0){
|
|
|
//求总和
|
|
|
- list = industryOverviewMapper.countAllIndustryOverview().stream().limit(1).collect(Collectors.toList());
|
|
|
+ IndustryOverview latestData = null;
|
|
|
+ List<Integer> years = new ArrayList<>();;
|
|
|
+ long sumPowerConsume = 0L;
|
|
|
+ long sumEnergyConsume = 0L;
|
|
|
+ long sumFunding = 0L;
|
|
|
+ long sumTotalIndustrialValue = 0L;
|
|
|
+ long sumTaxableIncome = 0L;
|
|
|
+ long sumPaidTax = 0L;
|
|
|
+ List<IndustryOverview> industryOverviews = industryOverviewMapper.selectIndustryOverviewList(industryOverview);
|
|
|
+ for (IndustryOverview item : industryOverviews){
|
|
|
+ //获取最新年份实体
|
|
|
+ if (latestData == null || item.getYear() > latestData .getYear()){
|
|
|
+ latestData = item;
|
|
|
+ }
|
|
|
+ //统计数据
|
|
|
+ sumPowerConsume += item.getPowerConsumeSum();
|
|
|
+ sumEnergyConsume += item.getEnergyConsumeSum();
|
|
|
+ sumFunding += item.getFundingSum();
|
|
|
+ sumTotalIndustrialValue += item.getTotalIndustrialValueSum();
|
|
|
+ sumTaxableIncome += item.getTaxableIncomeSum();
|
|
|
+ sumPaidTax += item.getPaidTaxSum();
|
|
|
+ years.add(item.getYear());
|
|
|
+ // 替换最新数据
|
|
|
+ if (latestData != null) {
|
|
|
+ latestData.setYears(years);
|
|
|
+ latestData.setPowerConsumeSum(sumPowerConsume);
|
|
|
+ latestData.setEnergyConsumeSum(sumEnergyConsume);
|
|
|
+ latestData.setFundingSum(sumFunding);
|
|
|
+ latestData.setTotalIndustrialValueSum(sumTotalIndustrialValue);
|
|
|
+ latestData.setTaxableIncomeSum(sumTaxableIncome);
|
|
|
+ latestData.setPaidTaxSum(sumPaidTax);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list.add(latestData);
|
|
|
}else {
|
|
|
//求某年
|
|
|
list = industryOverviewMapper.selectIndustryOverviewList(industryOverview);
|
|
@@ -77,7 +112,10 @@ public class IndustryOverviewServiceImpl implements IIndustryOverviewService
|
|
|
|
|
|
@Override
|
|
|
public List<IndustryCount> countAllIndustries() {
|
|
|
- return industryOverviewMapper.selectIndustryCount();
|
|
|
+ List<IndustryCount> industryCounts = industryOverviewMapper.selectIndustryCount();
|
|
|
+ //数量从小到大排
|
|
|
+ return industryCounts.stream().sorted(Comparator.comparingInt(IndustryCount::getNumber))
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
/**
|