|
|
@@ -229,7 +229,7 @@ public class EnterpriseHealthComputer {
|
|
|
* 计算结果列表
|
|
|
*/
|
|
|
@Getter
|
|
|
- List<EnterpriseHealth> results;
|
|
|
+ List<EnterpriseHealth> results = new ArrayList<>();
|
|
|
|
|
|
/**
|
|
|
* 企业列表
|
|
|
@@ -284,6 +284,7 @@ public class EnterpriseHealthComputer {
|
|
|
*
|
|
|
* @param now 当前时间
|
|
|
*/
|
|
|
+ @SuppressWarnings("DuplicatedCode")
|
|
|
public void computeTaxRise(LocalDateTime now) {
|
|
|
//最近四个季节
|
|
|
List<Season> seasons = getLastFourSeason(now);
|
|
|
@@ -310,35 +311,6 @@ public class EnterpriseHealthComputer {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static BigDecimal checkAllRiseAndGetRiseRate(List<List<EnterpriseEconomic>> seasonEconomic, List<List<EnterpriseEconomic>> previousYearSeasonEconomic) {
|
|
|
- List<BigDecimal> seasonTax = seasonEconomic.stream().map(
|
|
|
- l->l.stream()
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .map(EnterpriseEconomic::getCApprovedTax)
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .reduce(BigDecimal.ZERO,BigDecimal::add)
|
|
|
- ).collect(Collectors.toList());
|
|
|
- //较旧四个季度的税收统计
|
|
|
- List<BigDecimal> previousYearSeasonTax = previousYearSeasonEconomic.stream().map(
|
|
|
- l->l.stream()
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .map(EnterpriseEconomic::getCApprovedTax)
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .reduce(BigDecimal.ZERO,BigDecimal::add)
|
|
|
- ).collect(Collectors.toList());
|
|
|
- //检查所有季度是否同比上升
|
|
|
- if (!isAllUpper(seasonTax, previousYearSeasonTax)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- //计算上升率
|
|
|
- BigDecimal divide = sumAndDivide(seasonTax, previousYearSeasonTax);
|
|
|
- if (divide == null) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- return divide;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 计算产出上升情况
|
|
|
*
|
|
|
@@ -346,7 +318,7 @@ public class EnterpriseHealthComputer {
|
|
|
*/
|
|
|
@SuppressWarnings("DuplicatedCode")
|
|
|
public void computeOutputRise(LocalDateTime now) {
|
|
|
-//最近四个季节
|
|
|
+ //最近四个季节
|
|
|
List<Season> seasons = getLastFourSeason(now);
|
|
|
//四个季节的上一年同季节
|
|
|
List<Season> previousYearSeasons = seasons.stream().map(s -> s.minusSeasons(4)).collect(Collectors.toList());
|
|
|
@@ -380,7 +352,34 @@ public class EnterpriseHealthComputer {
|
|
|
* @param now 当前时间
|
|
|
*/
|
|
|
public void computeTaxDive(LocalDateTime now) {
|
|
|
+ Season season = getLastSeason(now);
|
|
|
+ Season previousYearSeason = season.minusSeasons(4);
|
|
|
+ for (Enterprise enterprise : enterprises) {
|
|
|
+ List<EnterpriseEconomic> seasonEconomic = getEconomicBySeason(enterprise,season);
|
|
|
+ List<EnterpriseEconomic> previousYearSeasonEconomic = getEconomicBySeason(enterprise,previousYearSeason);
|
|
|
+ //今年数据必须完整,避免因数据缺失异常标记
|
|
|
+ if (seasonEconomic.stream().anyMatch(Objects::isNull)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ BigDecimal seasonTax = seasonEconomic.stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(EnterpriseEconomic::getCApprovedTax)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal previousYearSeasonTax = previousYearSeasonEconomic.stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(EnterpriseEconomic::getCApprovedTax)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ if (seasonTax.compareTo(previousYearSeasonTax) < 0) {
|
|
|
+ BigDecimal divide = seasonTax.divide(previousYearSeasonTax, RoundingMode.HALF_UP);
|
|
|
+ if (divide.compareTo(BigDecimal.valueOf(7,1))<0){
|
|
|
+ putResult(enterprise,HealthType.TAX_DIVE,now,season.getStartTime(),season.getEndTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// ==================== 私有方法 ====================
|
|
|
@@ -436,19 +435,24 @@ public class EnterpriseHealthComputer {
|
|
|
private List<List<EnterpriseEconomic>> getEconomicBySeasonList(Enterprise enterprise, List<Season> seasons) {
|
|
|
List<List<EnterpriseEconomic>> seasonEconomic = new ArrayList<>();
|
|
|
for (Season season : seasons) {
|
|
|
- //企业编码
|
|
|
- String enterpriseCode = enterprise.getCUnifiedSocialCreditCode();
|
|
|
- Map<YearMonth, EnterpriseEconomic> yearMonthEnterpriseEconomicMap = enterpriseEconomics.get(enterpriseCode);
|
|
|
- if (yearMonthEnterpriseEconomicMap == null) {
|
|
|
- yearMonthEnterpriseEconomicMap = Collections.emptyMap();
|
|
|
- }
|
|
|
- seasonEconomic.add(season.getYearMonths().stream()
|
|
|
- .map(yearMonthEnterpriseEconomicMap::get)
|
|
|
- .collect(Collectors.toList()));
|
|
|
+ List<EnterpriseEconomic> collect = getEconomicBySeason(enterprise, season);
|
|
|
+ seasonEconomic.add(collect);
|
|
|
}
|
|
|
return seasonEconomic;
|
|
|
}
|
|
|
|
|
|
+ private List<EnterpriseEconomic> getEconomicBySeason(Enterprise enterprise, Season season) {
|
|
|
+ //企业编码
|
|
|
+ String enterpriseCode = enterprise.getCUnifiedSocialCreditCode();
|
|
|
+ Map<YearMonth, EnterpriseEconomic> yearMonthEnterpriseEconomicMap = enterpriseEconomics.get(enterpriseCode);
|
|
|
+ if (yearMonthEnterpriseEconomicMap == null) {
|
|
|
+ yearMonthEnterpriseEconomicMap = Collections.emptyMap();
|
|
|
+ }
|
|
|
+ return season.getYearMonths().stream()
|
|
|
+ .map(yearMonthEnterpriseEconomicMap::get)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 获取以季节结束月为基准的连续月份
|
|
|
@@ -552,4 +556,39 @@ public class EnterpriseHealthComputer {
|
|
|
return IntStream.range(0, valueList1.size()).allMatch(index -> valueList1.get(index).compareTo(valueList2.get(index)) > 0
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算输入的连续两年的数据每个季节都同比上升,在这个基础上计算上升率
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private static BigDecimal checkAllRiseAndGetRiseRate(List<List<EnterpriseEconomic>> seasonEconomic, List<List<EnterpriseEconomic>> previousYearSeasonEconomic) {
|
|
|
+ List<BigDecimal> seasonTax = seasonEconomic.stream().map(
|
|
|
+ l->l.stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(EnterpriseEconomic::getCApprovedTax)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .reduce(BigDecimal.ZERO,BigDecimal::add)
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ //较旧四个季度的税收统计
|
|
|
+ List<BigDecimal> previousYearSeasonTax = previousYearSeasonEconomic.stream().map(
|
|
|
+ l->l.stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(EnterpriseEconomic::getCApprovedTax)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .reduce(BigDecimal.ZERO,BigDecimal::add)
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ //检查所有季度是否同比上升
|
|
|
+ if (!isAllUpper(seasonTax, previousYearSeasonTax)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ //计算上升率
|
|
|
+ BigDecimal divide = sumAndDivide(seasonTax, previousYearSeasonTax);
|
|
|
+ if (divide == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return divide;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|