From 2b666bc3fdd7171d3a0238308a5833ae5c5410d9 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 19 一月 2021 18:33:05 +0800
Subject: [PATCH] 优化上线 欠费报表处理
---
service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 163 insertions(+), 1 deletions(-)
diff --git a/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java b/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java
index 7b14302..22034ce 100644
--- a/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java
+++ b/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java
@@ -225,6 +225,8 @@
return;
}
double receivableAmount = getReceivableAmountByCar(tmpReportFeeDto, null, tmpReportCarDto); //搴旀敹
+
+ dealBeforeUploadCarFee(tmpReportFeeDto, tmpReportCarDto);
double oweAmount = getOweAmount(tmpReportFeeDto, receivableAmount, receivedAmount); //娆犺垂
FeeDto feeDto = BeanConvertUtil.covertBean(tmpReportFeeDto, FeeDto.class);
OwnerCarDto ownerCarDto = BeanConvertUtil.covertBean(tmpReportCarDto, OwnerCarDto.class);
@@ -278,6 +280,77 @@
}
/**
+ * 瑙e喅涓婄嚎鍓� 娆犺垂鏁版嵁
+ *
+ * @param tmpReportCarDto
+ * @param tmpReportFeeDto
+ */
+ private void dealBeforeUploadCarFee(ReportFeeDto tmpReportFeeDto, ReportCarDto tmpReportCarDto) {
+
+
+ Calendar preMonthDate = Calendar.getInstance();
+ preMonthDate.set(Calendar.DAY_OF_MONTH, 1);
+ preMonthDate.add(Calendar.DAY_OF_MONTH, -1);
+
+ //褰撴湀涓�鏃�
+ Calendar curMonthDate = Calendar.getInstance();
+ curMonthDate.set(Calendar.DAY_OF_MONTH, 1);
+ curMonthDate.set(Calendar.HOUR_OF_DAY, 0);
+ curMonthDate.set(Calendar.MINUTE, 0);
+ curMonthDate.set(Calendar.SECOND, 0);
+ if (tmpReportFeeDto.getEndTime().getTime() > curMonthDate.getTime().getTime()) { //璇存槑娌℃湁娆犺垂
+ return;
+ }
+
+ ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto = new ReportFeeMonthStatisticsDto();
+ reportFeeMonthStatisticsDto.setCommunityId(tmpReportCarDto.getCommunityId());
+ reportFeeMonthStatisticsDto.setConfigId(tmpReportFeeDto.getConfigId());
+ reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
+ reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
+ reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
+ reportFeeMonthStatisticsDto.setFeeYear(preMonthDate.get(Calendar.YEAR) + "");
+ reportFeeMonthStatisticsDto.setFeeMonth((preMonthDate.get(Calendar.MONTH) + 1) + "");
+ List<ReportFeeMonthStatisticsDto> statistics = BeanConvertUtil.covertBeanList(
+ reportFeeMonthStatisticsServiceDaoImpl.getReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsDto)),
+ ReportFeeMonthStatisticsDto.class);
+ //涓婁釜鏈堟湁鏁版嵁 涓嶅鐞�
+ if (statistics != null && statistics.size() > 1) {
+ return;
+ }
+ double receivableAmount = 0.0;
+ if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeFlag())) {
+ receivableAmount = tmpReportFeeDto.getFeePrice();
+ } else {
+ double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), curMonthDate.getTime());
+ BigDecimal curDegree = new BigDecimal(month);
+ receivableAmount = curDegree.multiply(new BigDecimal(tmpReportFeeDto.getFeePrice())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ }
+
+
+ ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
+ reportFeeMonthStatisticsPo.setDeadlineTime(DateUtil.getFormatTimeString(curMonthDate.getTime(), DateUtil.DATE_FORMATE_STRING_A));
+
+ reportFeeMonthStatisticsPo.setOweAmount(receivableAmount + "");
+ reportFeeMonthStatisticsPo.setReceivedAmount("0");
+ reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
+ reportFeeMonthStatisticsPo.setStatisticsId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_statisticsId));
+ reportFeeMonthStatisticsPo.setCommunityId(tmpReportFeeDto.getCommunityId());
+ reportFeeMonthStatisticsPo.setConfigId(tmpReportFeeDto.getConfigId());
+ reportFeeMonthStatisticsPo.setFeeCreateTime(DateUtil.getFormatTimeString(tmpReportFeeDto.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
+ reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
+ reportFeeMonthStatisticsPo.setFeeMonth((preMonthDate.get(Calendar.MONTH) + 1) + "");
+ reportFeeMonthStatisticsPo.setFeeYear(preMonthDate.get(Calendar.YEAR) + "");
+ reportFeeMonthStatisticsPo.setObjId(tmpReportCarDto.getCarId());
+ reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_CAR);
+ reportFeeMonthStatisticsPo.setFeeName(tmpReportFeeDto.getFeeName());
+ reportFeeMonthStatisticsPo.setObjName(tmpReportCarDto.getCarNum() + "(" + tmpReportCarDto.getAreaNum() + "鍋滆溅鍦�" + tmpReportCarDto.getNum() + "杞︿綅");
+ reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+ reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
+
+
+ }
+
+ /**
* 澶勭悊璐圭敤
*
* @param reportRoomDto
@@ -318,6 +391,7 @@
reportFeeMonthStatisticsServiceDaoImpl.getReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsDto)),
ReportFeeMonthStatisticsDto.class);
+
double receivedAmount = getReceivedAmount(tmpReportFeeDto); //瀹炴敹
//璐圭敤宸茬粡缁撴潫 骞朵笖褰撴湀瀹炴敹涓�0 閭e氨鏄� 涔嬪墠灏辩粨鏉熶簡 鏃犻渶澶勭悊 && ListUtil.isNull(statistics)
if (FeeDto.STATE_FINISH.equals(tmpReportFeeDto.getState())
@@ -325,6 +399,10 @@
return;
}
double receivableAmount = getReceivableAmount(tmpReportFeeDto, reportRoomDto, null); //搴旀敹
+
+ //瑙e喅涓婄嚎鏃� 涔嬪墠娆犺垂娌℃湁鍒峰叆瀵艰嚧璐圭敤閲戦瀵逛笉涓婇棶棰樺鐞�
+ dealBeforeUploadRoomFee(reportRoomDto, tmpReportFeeDto, receivableAmount);
+
double oweAmount = getOweAmount(tmpReportFeeDto, receivableAmount, receivedAmount); //娆犺垂
FeeDto feeDto = BeanConvertUtil.covertBean(tmpReportFeeDto, FeeDto.class);
Map<String, Object> targetEndDateAndOweMonth = computeFeeSMOImpl.getTargetEndDateAndOweMonth(feeDto, null);
@@ -359,7 +437,7 @@
if (RoomDto.ROOM_TYPE_ROOM.equals(reportRoomDto.getRoomType())) {
reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "鏍�" + reportRoomDto.getUnitNum() + "鍗曞厓" + reportRoomDto.getRoomNum() + "瀹�");
} else {
- reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "鏍�" + reportRoomDto.getRoomNum() + "瀹�");
+ reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "鏍�" + reportRoomDto.getRoomNum() + "瀹�");
}
reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
@@ -380,6 +458,88 @@
tmpReportFeeMonthStatisticsPo.setFeeMonth(month + "");
tmpReportFeeMonthStatisticsPo.setOweAmount("0");
reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsOwe(BeanConvertUtil.beanCovertMap(tmpReportFeeMonthStatisticsPo));
+ }
+
+ public static void main(String[] args) {
+ Calendar c = Calendar.getInstance();
+ c.set(Calendar.DAY_OF_MONTH, 1);
+ c.add(Calendar.DAY_OF_MONTH, -1);
+
+ System.out.println(DateUtil.getFormatTimeString(c.getTime(), DateUtil.DATE_FORMATE_STRING_A));
+ }
+
+ /**
+ * 瑙e喅涓婄嚎鍓� 娆犺垂鏁版嵁
+ *
+ * @param reportRoomDto
+ * @param tmpReportFeeDto
+ */
+ private void dealBeforeUploadRoomFee(ReportRoomDto reportRoomDto, ReportFeeDto tmpReportFeeDto, double curMonthReceivableAmount) {
+
+
+ Calendar preMonthDate = Calendar.getInstance();
+ preMonthDate.set(Calendar.DAY_OF_MONTH, 1);
+ preMonthDate.add(Calendar.DAY_OF_MONTH, -1);
+
+ //褰撴湀涓�鏃�
+ Calendar curMonthDate = Calendar.getInstance();
+ curMonthDate.set(Calendar.DAY_OF_MONTH, 1);
+ curMonthDate.set(Calendar.HOUR_OF_DAY, 0);
+ curMonthDate.set(Calendar.MINUTE, 0);
+ curMonthDate.set(Calendar.SECOND, 0);
+ if (tmpReportFeeDto.getEndTime().getTime() > curMonthDate.getTime().getTime()) { //璇存槑娌℃湁娆犺垂
+ return;
+ }
+
+ ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto = new ReportFeeMonthStatisticsDto();
+ reportFeeMonthStatisticsDto.setCommunityId(reportRoomDto.getCommunityId());
+ reportFeeMonthStatisticsDto.setConfigId(tmpReportFeeDto.getConfigId());
+ reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
+ reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
+ reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
+ reportFeeMonthStatisticsDto.setFeeYear(preMonthDate.get(Calendar.YEAR) + "");
+ reportFeeMonthStatisticsDto.setFeeMonth((preMonthDate.get(Calendar.MONTH) + 1) + "");
+ List<ReportFeeMonthStatisticsDto> statistics = BeanConvertUtil.covertBeanList(
+ reportFeeMonthStatisticsServiceDaoImpl.getReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsDto)),
+ ReportFeeMonthStatisticsDto.class);
+ //涓婁釜鏈堟湁鏁版嵁 涓嶅鐞�
+ if (statistics != null && statistics.size() > 1) {
+ return;
+ }
+
+ double receivableAmount = 0.0;
+ if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeFlag())) {
+ receivableAmount = tmpReportFeeDto.getFeePrice();
+ } else {
+ double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), curMonthDate.getTime());
+ BigDecimal curDegree = new BigDecimal(month);
+ receivableAmount = curDegree.multiply(new BigDecimal(tmpReportFeeDto.getFeePrice())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ }
+ ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
+ reportFeeMonthStatisticsPo.setDeadlineTime(DateUtil.getFormatTimeString(curMonthDate.getTime(), DateUtil.DATE_FORMATE_STRING_A));
+
+ reportFeeMonthStatisticsPo.setOweAmount(receivableAmount + "");
+ reportFeeMonthStatisticsPo.setReceivedAmount("0");
+ reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
+ reportFeeMonthStatisticsPo.setStatisticsId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_statisticsId));
+ reportFeeMonthStatisticsPo.setCommunityId(tmpReportFeeDto.getCommunityId());
+ reportFeeMonthStatisticsPo.setConfigId(tmpReportFeeDto.getConfigId());
+ reportFeeMonthStatisticsPo.setFeeCreateTime(DateUtil.getFormatTimeString(tmpReportFeeDto.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
+ reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
+ reportFeeMonthStatisticsPo.setFeeMonth((preMonthDate.get(Calendar.MONTH) + 1) + "");
+ reportFeeMonthStatisticsPo.setFeeYear(preMonthDate.get(Calendar.YEAR) + "");
+ reportFeeMonthStatisticsPo.setObjId(reportRoomDto.getRoomId());
+ reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
+ reportFeeMonthStatisticsPo.setFeeName(StringUtil.isEmpty(tmpReportFeeDto.getImportFeeName()) ? tmpReportFeeDto.getFeeName() : tmpReportFeeDto.getImportFeeName());
+ if (RoomDto.ROOM_TYPE_ROOM.equals(reportRoomDto.getRoomType())) {
+ reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "鏍�" + reportRoomDto.getUnitNum() + "鍗曞厓" + reportRoomDto.getRoomNum() + "瀹�");
+ } else {
+ reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "鏍�" + reportRoomDto.getRoomNum() + "瀹�");
+ }
+ reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+ reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
+
+
}
/**
@@ -422,6 +582,7 @@
private double getReceivableAmountByCar(ReportFeeDto tmpReportFeeDto, ReportRoomDto reportRoomDto, ReportCarDto reportCarDto) {
double feePrice = computeFeeSMOImpl.getReportFeePrice(tmpReportFeeDto, reportRoomDto, reportCarDto);
+ tmpReportFeeDto.setFeePrice(feePrice);
BigDecimal feePriceDec = new BigDecimal(feePrice);
if (DateUtil.getCurrentDate().getTime() < tmpReportFeeDto.getStartTime().getTime()) {
@@ -475,6 +636,7 @@
private double getReceivableAmount(ReportFeeDto tmpReportFeeDto, ReportRoomDto reportRoomDto, ReportCarDto reportCarDto) {
double feePrice = computeFeeSMOImpl.getReportFeePrice(tmpReportFeeDto, reportRoomDto, reportCarDto);
+ tmpReportFeeDto.setFeePrice(feePrice);
BigDecimal feePriceDec = new BigDecimal(feePrice);
if (DateUtil.getCurrentDate().getTime() < tmpReportFeeDto.getStartTime().getTime()) {
--
Gitblit v1.8.0