From ba1c0ad6cffaa8a6288a4e66d0598d16f1cccc10 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期三, 13 十月 2021 11:00:35 +0800
Subject: [PATCH] 优化代码
---
service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java | 81 ++++++++++++++++++++++++++--------------
1 files changed, 52 insertions(+), 29 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
old mode 100644
new mode 100755
index 844832e..c9d28e5
--- 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
@@ -1,5 +1,6 @@
package com.java110.report.smo.impl;
+import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.core.smo.IComputeFeeSMO;
@@ -196,7 +197,7 @@
ReportFeeDto reportFeeDto = new ReportFeeDto();
reportFeeDto.setPayerObjId(tmpReportCarDto.getCarId());
reportFeeDto.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_CAR);
- reportFeeDto.setState(FeeDto.STATE_DOING);
+ //reportFeeDto.setState(FeeDto.STATE_DOING);
List<ReportFeeDto> feeDtos = reportFeeServiceDaoImpl.getFees(reportFeeDto);
if (feeDtos == null || feeDtos.size() < 1) {
@@ -207,18 +208,23 @@
try {
doDealCarFee(tmpReportCarDto, tmpReportFeeDto);
} catch (Exception e) {
- logger.error("澶勭悊鎴垮眿璐圭敤澶辫触" + JSONObject.toJSONString(tmpReportFeeDto), e);
+ logger.error("澶勭悊杞﹁締璐圭敤澶辫触" + JSONObject.toJSONString(tmpReportFeeDto), e);
}
}
}
private void doDealCarFee(ReportCarDto tmpReportCarDto, ReportFeeDto tmpReportFeeDto) {
+ //璐圭敤宸茬粡缁撴潫 骞朵笖褰撴湀瀹炴敹涓�0 閭e氨鏄� 涔嬪墠灏辩粨鏉熶簡 鏃犻渶澶勭悊 && ListUtil.isNull(statistics)
+ if (FeeDto.STATE_FINISH.equals(tmpReportFeeDto.getState())
+ && getCurFeeReceivedAmount(tmpReportFeeDto) == 0) {
+ return;
+ }
ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto = new ReportFeeMonthStatisticsDto();
reportFeeMonthStatisticsDto.setCommunityId(tmpReportCarDto.getCommunityId());
reportFeeMonthStatisticsDto.setConfigId(tmpReportFeeDto.getConfigId());
reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
- reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
+ //reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
reportFeeMonthStatisticsDto.setFeeYear(DateUtil.getYear() + "");
reportFeeMonthStatisticsDto.setFeeMonth(DateUtil.getMonth() + "");
@@ -227,11 +233,7 @@
ReportFeeMonthStatisticsDto.class);
double receivedAmount = getReceivedAmount(tmpReportFeeDto); //瀹炴敹
- //璐圭敤宸茬粡缁撴潫 骞朵笖褰撴湀瀹炴敹涓�0 閭e氨鏄� 涔嬪墠灏辩粨鏉熶簡 鏃犻渶澶勭悊 && ListUtil.isNull(statistics)
- if (FeeDto.STATE_FINISH.equals(tmpReportFeeDto.getState())
- && receivedAmount == 0) {
- return;
- }
+
FeeDto feeDto = BeanConvertUtil.covertBean(tmpReportFeeDto, FeeDto.class);
OwnerCarDto ownerCarDto = BeanConvertUtil.covertBean(tmpReportCarDto, OwnerCarDto.class);
Map<String, Object> targetEndDateAndOweMonth = computeFeeSMOImpl.getTargetEndDateAndOweMonth(feeDto, ownerCarDto);
@@ -265,6 +267,7 @@
reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
reportFeeMonthStatisticsPo.setFeeMonth(DateUtil.getMonth() + "");
reportFeeMonthStatisticsPo.setFeeYear(DateUtil.getYear() + "");
+ reportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getNextMonthFirstDay(DateUtil.DATE_FORMATE_STRING_A));
reportFeeMonthStatisticsPo.setObjId(tmpReportCarDto.getCarId());
reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_CAR);
reportFeeMonthStatisticsPo.setFeeName(tmpReportFeeDto.getFeeName());
@@ -283,8 +286,7 @@
ReportFeeMonthStatisticsPo tmpReportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
tmpReportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
- tmpReportFeeMonthStatisticsPo.setFeeYear(year + "");
- tmpReportFeeMonthStatisticsPo.setFeeMonth(month + "");
+ tmpReportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(endTime,DateUtil.DATE_FORMATE_STRING_A));
tmpReportFeeMonthStatisticsPo.setOweAmount("0");
reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsOwe(BeanConvertUtil.beanCovertMap(tmpReportFeeMonthStatisticsPo));
}
@@ -355,6 +357,7 @@
reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
reportFeeMonthStatisticsPo.setFeeMonth((preMonthDate.get(Calendar.MONTH) + 1) + "");
reportFeeMonthStatisticsPo.setFeeYear(preMonthDate.get(Calendar.YEAR) + "");
+ reportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(DateUtil.getFirstDate(),DateUtil.DATE_FORMATE_STRING_A));
reportFeeMonthStatisticsPo.setObjId(tmpReportCarDto.getCarId());
reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_CAR);
reportFeeMonthStatisticsPo.setFeeName(tmpReportFeeDto.getFeeName());
@@ -374,7 +377,7 @@
ReportFeeDto reportFeeDto = new ReportFeeDto();
reportFeeDto.setPayerObjId(reportRoomDto.getRoomId());
reportFeeDto.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
- reportFeeDto.setState(FeeDto.STATE_DOING);
+ //reportFeeDto.setState(FeeDto.STATE_DOING);
List<ReportFeeDto> feeDtos = reportFeeServiceDaoImpl.getFees(reportFeeDto);
if (feeDtos == null || feeDtos.size() < 1) {
@@ -385,6 +388,7 @@
try {
doDealRoomFee(reportRoomDto, tmpReportFeeDto);
} catch (Exception e) {
+ e.printStackTrace();
logger.error("澶勭悊鎴垮眿璐圭敤澶辫触" + JSONObject.toJSONString(tmpReportFeeDto), e);
}
}
@@ -394,11 +398,17 @@
private void doDealRoomFee(ReportRoomDto reportRoomDto, ReportFeeDto tmpReportFeeDto) {
+ //璐圭敤宸茬粡缁撴潫 骞朵笖褰撴湀瀹炴敹涓�0 閭e氨鏄� 涔嬪墠灏辩粨鏉熶簡 鏃犻渶澶勭悊 && ListUtil.isNull(statistics)
+ if (FeeDto.STATE_FINISH.equals(tmpReportFeeDto.getState())
+ && getCurFeeReceivedAmount(tmpReportFeeDto) == 0) {
+ return;
+ }
+
ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto = new ReportFeeMonthStatisticsDto();
reportFeeMonthStatisticsDto.setCommunityId(reportRoomDto.getCommunityId());
reportFeeMonthStatisticsDto.setConfigId(tmpReportFeeDto.getConfigId());
reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
- reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
+ //reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
reportFeeMonthStatisticsDto.setFeeYear(DateUtil.getYear() + "");
reportFeeMonthStatisticsDto.setFeeMonth(DateUtil.getMonth() + "");
@@ -408,11 +418,7 @@
double receivedAmount = getReceivedAmount(tmpReportFeeDto); //瀹炴敹
- //璐圭敤宸茬粡缁撴潫 骞朵笖褰撴湀瀹炴敹涓�0 閭e氨鏄� 涔嬪墠灏辩粨鏉熶簡 鏃犻渶澶勭悊 && ListUtil.isNull(statistics)
- if (FeeDto.STATE_FINISH.equals(tmpReportFeeDto.getState())
- && receivedAmount == 0) {
- return;
- }
+
FeeDto feeDto = BeanConvertUtil.covertBean(tmpReportFeeDto, FeeDto.class);
Map<String, Object> targetEndDateAndOweMonth = computeFeeSMOImpl.getTargetEndDateAndOweMonth(feeDto, null);
@@ -434,6 +440,7 @@
//reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
reportFeeMonthStatisticsPo.setReceivedAmount(receivedAmount + "");
reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
+ reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
reportFeeMonthStatisticsPo.setFeeName(StringUtil.isEmpty(tmpReportFeeDto.getImportFeeName()) ? tmpReportFeeDto.getFeeName() : tmpReportFeeDto.getImportFeeName());
reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
@@ -448,6 +455,7 @@
reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
reportFeeMonthStatisticsPo.setFeeMonth(DateUtil.getMonth() + "");
reportFeeMonthStatisticsPo.setFeeYear(DateUtil.getYear() + "");
+ reportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getNextMonthFirstDay(DateUtil.DATE_FORMATE_STRING_A));
reportFeeMonthStatisticsPo.setObjId(reportRoomDto.getRoomId());
reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
reportFeeMonthStatisticsPo.setFeeName(StringUtil.isEmpty(tmpReportFeeDto.getImportFeeName()) ? tmpReportFeeDto.getFeeName() : tmpReportFeeDto.getImportFeeName());
@@ -464,25 +472,19 @@
//灏嗙即璐� 鍒版湡鏃堕棿涔嬪墠寰楁瑺璐瑰埛涓�0
Date endTime = tmpReportFeeDto.getEndTime();
- Calendar calender = Calendar.getInstance();
- calender.setTime(endTime);
- int year = calender.get(Calendar.YEAR);
- int month = calender.get(Calendar.MONTH);
-
ReportFeeMonthStatisticsPo tmpReportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
tmpReportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
- tmpReportFeeMonthStatisticsPo.setFeeYear(year + "");
- tmpReportFeeMonthStatisticsPo.setFeeMonth(month + "");
+ tmpReportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(endTime,DateUtil.DATE_FORMATE_STRING_A));
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);
+ ReportFeeDetailDto feeDetailDto = new ReportFeeDetailDto();
+ feeDetailDto.setStartTime(DateUtil.getFormatTimeString(DateUtil.getFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
+ feeDetailDto.setEndTime(DateUtil.getFormatTimeString(DateUtil.getNextMonthFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
- System.out.println(DateUtil.getFormatTimeString(c.getTime(), DateUtil.DATE_FORMATE_STRING_A));
+ System.out.println(JSONObject.toJSONString(feeDetailDto));
}
/**
@@ -549,6 +551,8 @@
reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
reportFeeMonthStatisticsPo.setFeeMonth((preMonthDate.get(Calendar.MONTH) + 1) + "");
reportFeeMonthStatisticsPo.setFeeYear(preMonthDate.get(Calendar.YEAR) + "");
+ reportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(DateUtil.getFirstDate(),DateUtil.DATE_FORMATE_STRING_A));
+
reportFeeMonthStatisticsPo.setObjId(reportRoomDto.getRoomId());
reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
reportFeeMonthStatisticsPo.setFeeName(StringUtil.isEmpty(tmpReportFeeDto.getImportFeeName()) ? tmpReportFeeDto.getFeeName() : tmpReportFeeDto.getImportFeeName());
@@ -586,11 +590,30 @@
* @param tmpReportFeeDto
* @return
*/
- private double getReceivedAmount(ReportFeeDto tmpReportFeeDto) {
+ private double getCurFeeReceivedAmount(ReportFeeDto tmpReportFeeDto) {
ReportFeeDetailDto feeDetailDto = new ReportFeeDetailDto();
feeDetailDto.setStartTime(DateUtil.getFormatTimeString(DateUtil.getFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
feeDetailDto.setEndTime(DateUtil.getFormatTimeString(DateUtil.getNextMonthFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
feeDetailDto.setFeeId(tmpReportFeeDto.getFeeId());
+
+ double receivedAmount = reportFeeServiceDaoImpl.getFeeReceivedAmount(feeDetailDto);
+
+ return receivedAmount;
+ }
+
+ /**
+ * 鑾峰彇褰撴湀瀹炴敹
+ *
+ * @param tmpReportFeeDto
+ * @return
+ */
+ private double getReceivedAmount(ReportFeeDto tmpReportFeeDto) {
+ ReportFeeDetailDto feeDetailDto = new ReportFeeDetailDto();
+ feeDetailDto.setStartTime(DateUtil.getFormatTimeString(DateUtil.getFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
+ feeDetailDto.setEndTime(DateUtil.getFormatTimeString(DateUtil.getNextMonthFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
+ feeDetailDto.setConfigId(tmpReportFeeDto.getConfigId());
+ feeDetailDto.setPayerObjId(tmpReportFeeDto.getPayerObjId());
+
double receivedAmount = reportFeeServiceDaoImpl.getFeeReceivedAmount(feeDetailDto);
return receivedAmount;
--
Gitblit v1.8.0