|
|
@@ -4,14 +4,14 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.skyversation.xjcy.bean.Enterprise;
|
|
|
import com.skyversation.xjcy.bean.EnterpriseEconomic;
|
|
|
import com.skyversation.xjcy.bean.EnterpriseHealth;
|
|
|
+import com.skyversation.xjcy.bean.LeaseDetail;
|
|
|
import lombok.Getter;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.rmi.dgc.Lease;
|
|
|
import java.text.DecimalFormat;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.MonthDay;
|
|
|
-import java.time.YearMonth;
|
|
|
+import java.time.*;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
@@ -241,6 +241,11 @@ public class EnterpriseHealthComputer {
|
|
|
*/
|
|
|
Map<String, Map<YearMonth, EnterpriseEconomic>> enterpriseEconomics;
|
|
|
|
|
|
+ /**
|
|
|
+ * 企业租赁数据映射:企业ID->租赁数据list
|
|
|
+ */
|
|
|
+ Map<String, List<LeaseDetail>> enterpriseLeases;
|
|
|
+
|
|
|
// ==================== 构造方法 ====================
|
|
|
|
|
|
/**
|
|
|
@@ -274,20 +279,35 @@ public class EnterpriseHealthComputer {
|
|
|
EnterpriseEconomic::getCEnterpriseId,
|
|
|
Collectors.toMap(
|
|
|
enterpriseEconomic -> YearMonth.parse(enterpriseEconomic.getCYearMonth(), economicYearMonthFormat),
|
|
|
- Function.identity()
|
|
|
+ Function.identity(),
|
|
|
+ (a,b)->a
|
|
|
)
|
|
|
));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加企业租赁数据
|
|
|
+ *
|
|
|
+ * @param leases 企业租赁数据集合
|
|
|
+ */
|
|
|
+ public void putLease(Collection<LeaseDetail> leases) {
|
|
|
+ enterpriseLeases = leases.stream().collect(Collectors.groupingBy(
|
|
|
+ LeaseDetail::getCEnterpriseCode,
|
|
|
+ Collectors.toList()
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ // ================ 计算方法 ================
|
|
|
+
|
|
|
/**
|
|
|
* 计算税收上升情况
|
|
|
*
|
|
|
- * @param now 当前时间
|
|
|
+ * @param time 当前时间
|
|
|
*/
|
|
|
@SuppressWarnings("DuplicatedCode")
|
|
|
- public void computeTaxRise(LocalDateTime now) {
|
|
|
+ public void computeTaxRise(LocalDateTime time) {
|
|
|
//最近四个季节
|
|
|
- List<Season> seasons = getLastFourSeason(now);
|
|
|
+ List<Season> seasons = getLastFourSeason(time);
|
|
|
//四个季节的上一年同季节
|
|
|
List<Season> previousYearSeasons = seasons.stream().map(s -> s.minusSeasons(4)).collect(Collectors.toList());
|
|
|
for (Enterprise enterprise : enterprises) {
|
|
|
@@ -306,7 +326,7 @@ public class EnterpriseHealthComputer {
|
|
|
HealthType.TAX_RISE.getDefaultName()+simpleDecimalFormat.format(riseRate.subtract(BigDecimal.ONE)),
|
|
|
HealthType.TAX_RISE.getDefaultDescribe(),
|
|
|
HealthType.TAX_RISE,
|
|
|
- now, seasons.get(0).getStartTime(), seasons.get(seasons.size() - 1).getEndTime());
|
|
|
+ time, seasons.get(0).getStartTime(), seasons.get(seasons.size() - 1).getEndTime());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -314,12 +334,12 @@ public class EnterpriseHealthComputer {
|
|
|
/**
|
|
|
* 计算产出上升情况
|
|
|
*
|
|
|
- * @param now 当前时间
|
|
|
+ * @param time 当前时间
|
|
|
*/
|
|
|
@SuppressWarnings("DuplicatedCode")
|
|
|
- public void computeOutputRise(LocalDateTime now) {
|
|
|
+ public void computeOutputRise(LocalDateTime time) {
|
|
|
//最近四个季节
|
|
|
- List<Season> seasons = getLastFourSeason(now);
|
|
|
+ List<Season> seasons = getLastFourSeason(time);
|
|
|
//四个季节的上一年同季节
|
|
|
List<Season> previousYearSeasons = seasons.stream().map(s -> s.minusSeasons(4)).collect(Collectors.toList());
|
|
|
for (Enterprise enterprise : enterprises) {
|
|
|
@@ -340,7 +360,7 @@ public class EnterpriseHealthComputer {
|
|
|
HealthType.OUTPUT_RISE.getDefaultName()+simpleDecimalFormat.format(riseRate.subtract(BigDecimal.ONE)),
|
|
|
HealthType.OUTPUT_RISE.getDefaultDescribe(),
|
|
|
HealthType.OUTPUT_RISE,
|
|
|
- now, seasons.get(0).getStartTime(), seasons.get(seasons.size() - 1).getEndTime());
|
|
|
+ time, seasons.get(0).getStartTime(), seasons.get(seasons.size() - 1).getEndTime());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -349,10 +369,10 @@ public class EnterpriseHealthComputer {
|
|
|
/**
|
|
|
* 计算税收跳水情况
|
|
|
*
|
|
|
- * @param now 当前时间
|
|
|
+ * @param time 当前时间
|
|
|
*/
|
|
|
- public void computeTaxDive(LocalDateTime now) {
|
|
|
- Season season = getLastSeason(now);
|
|
|
+ public void computeTaxDive(LocalDateTime time) {
|
|
|
+ Season season = getLastSeason(time);
|
|
|
Season previousYearSeason = season.minusSeasons(4);
|
|
|
for (Enterprise enterprise : enterprises) {
|
|
|
List<EnterpriseEconomic> seasonEconomic = getEconomicBySeason(enterprise,season);
|
|
|
@@ -374,7 +394,7 @@ public class EnterpriseHealthComputer {
|
|
|
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());
|
|
|
+ putResult(enterprise,HealthType.TAX_DIVE,time,season.getStartTime(),season.getEndTime());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -382,6 +402,31 @@ public class EnterpriseHealthComputer {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 计算租赁即将过期情况
|
|
|
+ *
|
|
|
+ * @param time 当前时间
|
|
|
+ */
|
|
|
+ public void computeLeaseOutDate(LocalDateTime time) {
|
|
|
+ LocalDate nowDate = time.toLocalDate();
|
|
|
+ for (Enterprise enterprise : enterprises) {
|
|
|
+ String enterpriseCode = enterprise.getCUnifiedSocialCreditCode();
|
|
|
+ if (enterpriseCode==null || enterpriseCode.isEmpty()) continue;
|
|
|
+ List<LeaseDetail> leases =enterpriseLeases.get(enterpriseCode);
|
|
|
+ if (leases==null) continue;
|
|
|
+ boolean leasesAlmostOutDate = leases.stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .filter(leaseDetail -> !leaseDetail.getStartDate().isAfter(nowDate))
|
|
|
+ .map(LeaseDetail::getCEndDate)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .filter(t-> !t.isBefore(nowDate))
|
|
|
+ .anyMatch(t-> Duration.between(nowDate.atStartOfDay(),t.atStartOfDay()).toDays()<30);
|
|
|
+ if (leasesAlmostOutDate) {
|
|
|
+ putResult(enterprise,HealthType.LEASE_EXPIRY,time,nowDate.atStartOfDay(),nowDate.plusDays(1).atStartOfDay());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// ==================== 私有方法 ====================
|
|
|
|
|
|
/**
|
|
|
@@ -394,14 +439,12 @@ public class EnterpriseHealthComputer {
|
|
|
* @param computeTime 计算时间
|
|
|
* @param healthStart 健康开始时间
|
|
|
* @param healthEnd 健康结束时间
|
|
|
- * @return 企业健康对象
|
|
|
*/
|
|
|
- private EnterpriseHealth putResult(Enterprise enterprise, String title, String describe, HealthType type, LocalDateTime computeTime,
|
|
|
- LocalDateTime healthStart, LocalDateTime healthEnd) {
|
|
|
+ private void putResult(Enterprise enterprise, String title, String describe, HealthType type, LocalDateTime computeTime,
|
|
|
+ LocalDateTime healthStart, LocalDateTime healthEnd) {
|
|
|
EnterpriseHealth result = new EnterpriseHealth(title, describe, type.value, computeTime,
|
|
|
healthStart, healthEnd, enterprise.getCUnifiedSocialCreditCode());
|
|
|
results.add(result);
|
|
|
- return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -412,14 +455,12 @@ public class EnterpriseHealthComputer {
|
|
|
* @param computeTime 计算时间
|
|
|
* @param healthStart 健康开始时间
|
|
|
* @param healthEnd 健康结束时间
|
|
|
- * @return 企业健康对象
|
|
|
*/
|
|
|
- private EnterpriseHealth putResult(Enterprise enterprise, HealthType type, LocalDateTime computeTime,
|
|
|
- LocalDateTime healthStart, LocalDateTime healthEnd) {
|
|
|
+ private void putResult(Enterprise enterprise, HealthType type, LocalDateTime computeTime,
|
|
|
+ LocalDateTime healthStart, LocalDateTime healthEnd) {
|
|
|
EnterpriseHealth result = new EnterpriseHealth(type.defaultName, type.defaultDescribe, type.value, computeTime,
|
|
|
healthStart, healthEnd, enterprise.getCUnifiedSocialCreditCode());
|
|
|
results.add(result);
|
|
|
- return result;
|
|
|
}
|
|
|
|
|
|
/**
|