|
@@ -2,38 +2,49 @@ package com.enteprise.growthRate.service.impl;
|
|
|
|
|
|
import com.enteprise.base_data_month.domain.EnterpriseBaseDataMonth;
|
|
|
import com.enteprise.base_data_month.mapper.EnterpriseBaseDataMonthMapper;
|
|
|
+import com.enteprise.base_data_year.domain.EnterpriseBaseDataYear;
|
|
|
+import com.enteprise.base_data_year.mapper.EnterpriseBaseDataYearMapper;
|
|
|
import com.enteprise.enterprise.domain.Enterprise;
|
|
|
import com.enteprise.enterprise.dto.EnterpriseDto;
|
|
|
import com.enteprise.enterprise.mapper.EnterpriseMapper;
|
|
|
import com.enteprise.growthRate.domain.GrowthRate;
|
|
|
import com.enteprise.growthRate.domain.dto.GrowthRateDto;
|
|
|
import com.enteprise.growthRate.service.IGrowthRateService;
|
|
|
+import com.enteprise.season.domain.EnterpriseBaseDataSeason;
|
|
|
+import com.enteprise.season.mapper.EnterpriseBaseDataSeasonMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
+@Service
|
|
|
public class GrowthRateServiceImpl implements IGrowthRateService {
|
|
|
@Autowired
|
|
|
private EnterpriseMapper enterpriseMapper;
|
|
|
@Autowired
|
|
|
private EnterpriseBaseDataMonthMapper enterpriseBaseDataMonthMapper;
|
|
|
+ @Autowired
|
|
|
+ private EnterpriseBaseDataSeasonMapper enterpriseBaseDataSeasonMapper;
|
|
|
+ @Autowired
|
|
|
+ private EnterpriseBaseDataYearMapper enterpriseBaseDataYearMapper;
|
|
|
@Override
|
|
|
public List<GrowthRateDto> analysisGrowthRate(GrowthRate growthRate) {
|
|
|
String analysisType = growthRate.getAnalysisType();
|
|
|
int startMonth = growthRate.getStartMonth();
|
|
|
int endMonth = growthRate.getEndMonth();
|
|
|
int year = growthRate.getYear();
|
|
|
+ int season = growthRate.getSeason();
|
|
|
+ //通过分类、行业代码过滤企业列表
|
|
|
+ Enterprise enterprise = new Enterprise();
|
|
|
+ enterprise.setCode(growthRate.getCode());
|
|
|
+ enterprise.setTypeNum(growthRate.getTypeNum());
|
|
|
+ List<EnterpriseDto> enterpriseDtos = enterpriseMapper.selectAllWithType(enterprise);
|
|
|
if (analysisType.isEmpty() || year == 0) {
|
|
|
return null;
|
|
|
} else {
|
|
|
ArrayList<GrowthRateDto> list = new ArrayList<>();
|
|
|
if (startMonth != 0 && endMonth != 0) {
|
|
|
- //通过分类、行业代码过滤企业列表
|
|
|
- Enterprise enterprise = new Enterprise();
|
|
|
- enterprise.setCode(growthRate.getCode());
|
|
|
- enterprise.setTypeNum(growthRate.getTypeNum());
|
|
|
- List<EnterpriseDto> enterpriseDtos = enterpriseMapper.selectAllWithType(enterprise);
|
|
|
//每个企业从开始月份循环相加到结束月份
|
|
|
List<Integer> monthRange = getMonthRange(startMonth, endMonth);
|
|
|
for (EnterpriseDto enterpriseDto : enterpriseDtos){
|
|
@@ -46,17 +57,15 @@ public class GrowthRateServiceImpl implements IGrowthRateService {
|
|
|
dataMonth.setMonth(String.valueOf(nowMonth));
|
|
|
dataMonth.setYear(String.valueOf(year));
|
|
|
List<EnterpriseBaseDataMonth> dataMonths = enterpriseBaseDataMonthMapper.selectEnterpriseBaseDataMonthList(dataMonth);
|
|
|
- //重复操作获取去年对应的月份数据
|
|
|
+ //月度指标获取
|
|
|
dataMonth.setYear(String.valueOf(year-1));
|
|
|
List<EnterpriseBaseDataMonth> oldDataMonths = enterpriseBaseDataMonthMapper.selectEnterpriseBaseDataMonthList(dataMonth);
|
|
|
- if (analysisType.equals("totalIndustrialValue")) {
|
|
|
+ if (analysisType.equals("totalIndustrialValue")&& !dataMonths.isEmpty() &&!oldDataMonths.isEmpty()) {
|
|
|
sum += dataMonths.get(0).getTotalIndustrialValue();
|
|
|
oldSum += oldDataMonths.get(0).getTotalIndustrialValue();
|
|
|
- }else if (analysisType.equals("powerConsume")){
|
|
|
+ }else if (analysisType.equals("powerConsume")&& !dataMonths.isEmpty() &&!oldDataMonths.isEmpty()){
|
|
|
sum += dataMonths.get(0).getPowerConsume();
|
|
|
oldSum += oldDataMonths.get(0).getPowerConsume();
|
|
|
- }else {
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
//计算同比增速:(今年-去年)/去年
|
|
@@ -68,14 +77,77 @@ public class GrowthRateServiceImpl implements IGrowthRateService {
|
|
|
growthRateDto.setLocation(enterpriseDto.getLocation());
|
|
|
list.add(growthRateDto);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ if (season != 0){
|
|
|
+ //循环企业列表计算季度指标
|
|
|
+ for (EnterpriseDto dto : enterpriseDtos){
|
|
|
+ EnterpriseBaseDataSeason dataSeason = new EnterpriseBaseDataSeason();
|
|
|
+ Long sum = 0L;
|
|
|
+ Long oldSum = 0L;
|
|
|
+ dataSeason.setEnterpriseName(dto.getEnterpriseName());
|
|
|
+ dataSeason.setSeason(String.valueOf(season));
|
|
|
+ dataSeason.setYear(String.valueOf(year));
|
|
|
+ //季度指标获取
|
|
|
+ List<EnterpriseBaseDataSeason> dataSeasons = enterpriseBaseDataSeasonMapper.selectEnterpriseBaseDataSeasonList(dataSeason);
|
|
|
+ dataSeason.setYear(String.valueOf(year - 1));
|
|
|
+ List<EnterpriseBaseDataSeason> oldDataSeasons = enterpriseBaseDataSeasonMapper.selectEnterpriseBaseDataSeasonList(dataSeason);
|
|
|
+ if (analysisType.equals("taxableIncome") && !dataSeasons.isEmpty() &&!oldDataSeasons.isEmpty()) {
|
|
|
+ sum = dataSeasons.get(0).getTaxableIncome();
|
|
|
+ oldSum = oldDataSeasons.get(0).getTaxableIncome();
|
|
|
+ }else if (analysisType.equals("paidTax") && !dataSeasons.isEmpty() &&!oldDataSeasons.isEmpty()){
|
|
|
+ sum = dataSeasons.get(0).getPaidTax();
|
|
|
+ oldSum = oldDataSeasons.get(0).getPaidTax();
|
|
|
+ }
|
|
|
+ //计算同比增速:(今年-去年)/去年
|
|
|
+ double rate = (double) (sum - oldSum) / oldSum;
|
|
|
+ //初始化企业并把该企业的同比增速和其他数据放入list中
|
|
|
+ GrowthRateDto growthRateDto = new GrowthRateDto();
|
|
|
+ growthRateDto.setRate(rate);
|
|
|
+ growthRateDto.setEnterpriseName(dto.getEnterpriseName());
|
|
|
+ growthRateDto.setLocation(dto.getLocation());
|
|
|
+ list.add(growthRateDto);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ //循环企业列表计算年度指标
|
|
|
+ for (EnterpriseDto dto : enterpriseDtos){
|
|
|
+ EnterpriseBaseDataYear dataYear = new EnterpriseBaseDataYear();
|
|
|
+ Long sum = 0L;
|
|
|
+ Long oldSum = 0L;
|
|
|
+ dataYear.setEnterpriseName(dto.getEnterpriseName());
|
|
|
+ dataYear.setYear(String.valueOf(year));
|
|
|
+ //季度指标获取
|
|
|
+ List<EnterpriseBaseDataYear> dataYears = enterpriseBaseDataYearMapper.selectEnterpriseBaseDataYearList(dataYear);
|
|
|
+ dataYear.setYear(String.valueOf(year - 1));
|
|
|
+ List<EnterpriseBaseDataYear> oldDataYears = enterpriseBaseDataYearMapper.selectEnterpriseBaseDataYearList(dataYear);
|
|
|
+ if (analysisType.equals("energyConsume") && !dataYears.isEmpty() &&!oldDataYears.isEmpty()) {
|
|
|
+ sum = dataYears.get(0).getEnergyConsume();
|
|
|
+ oldSum = oldDataYears.get(0).getEnergyConsume();
|
|
|
+ }else if (analysisType.equals("funding") && !dataYears.isEmpty() &&!oldDataYears.isEmpty()){
|
|
|
+ sum = dataYears.get(0).getFunding();
|
|
|
+ oldSum = oldDataYears.get(0).getFunding();
|
|
|
+ }
|
|
|
+ //计算同比增速:(今年-去年)/去年
|
|
|
+ double rate = (double) (sum - oldSum) / oldSum;
|
|
|
+ //初始化企业并把该企业的同比增速和其他数据放入list中
|
|
|
+ GrowthRateDto growthRateDto = new GrowthRateDto();
|
|
|
+ growthRateDto.setRate(rate);
|
|
|
+ growthRateDto.setEnterpriseName(dto.getEnterpriseName());
|
|
|
+ growthRateDto.setLocation(dto.getLocation());
|
|
|
+ list.add(growthRateDto);
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取两个月份之间的所有月份
|
|
|
+ * @param start
|
|
|
+ * @param end
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public static List<Integer> getMonthRange(int start, int end) {
|
|
|
// 创建一个列表以存储结果
|
|
|
List<Integer> months = new ArrayList<>();
|