From f47fdbe821df9d9666e86b6d45f439a7a2b742d8 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期三, 24 十一月 2021 10:07:51 +0800
Subject: [PATCH] 优化报表
---
service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java | 60 ++++++++++++++++++-----------
java110-utils/src/main/java/com/java110/utils/util/DateUtil.java | 5 ++
java110-core/src/main/java/com/java110/core/smo/IComputeFeeSMO.java | 5 ++
java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java | 34 ++++++++++-------
4 files changed, 67 insertions(+), 37 deletions(-)
diff --git a/java110-core/src/main/java/com/java110/core/smo/IComputeFeeSMO.java b/java110-core/src/main/java/com/java110/core/smo/IComputeFeeSMO.java
index 4054607..ddc6d0d 100755
--- a/java110-core/src/main/java/com/java110/core/smo/IComputeFeeSMO.java
+++ b/java110-core/src/main/java/com/java110/core/smo/IComputeFeeSMO.java
@@ -139,6 +139,11 @@
*/
double dayCompare(Date fromDate, Date toDate);
+ /**
+ 銆�銆� *瀛楃涓茬殑鏃ユ湡鏍煎紡鐨勮绠�
+ 銆�銆� */
+ long daysBetween(Date smdate,Date bdate) ;
+
double getReportFeePrice(ReportFeeDto tmpReportFeeDto, ReportRoomDto reportRoomDto, ReportCarDto reportCarDto);
void computeEveryOweFee(FeeDto tmpFeeDto);
diff --git a/java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java b/java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java
index 3824e54..aae9a18 100755
--- a/java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java
+++ b/java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java
@@ -5,11 +5,7 @@
import com.java110.dto.community.CommunityDto;
import com.java110.dto.contract.ContractDto;
import com.java110.dto.contractRoom.ContractRoomDto;
-import com.java110.dto.fee.BillDto;
-import com.java110.dto.fee.BillOweFeeDto;
-import com.java110.dto.fee.FeeAttrDto;
-import com.java110.dto.fee.FeeConfigDto;
-import com.java110.dto.fee.FeeDto;
+import com.java110.dto.fee.*;
import com.java110.dto.machine.CarInoutDetailDto;
import com.java110.dto.machine.CarInoutDto;
import com.java110.dto.owner.OwnerCarDto;
@@ -44,12 +40,7 @@
import javax.script.ScriptEngineManager;
import java.math.BigDecimal;
import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* 璐圭敤璁$畻 鏈嶅姟绫�
@@ -1531,6 +1522,21 @@
return resMonth;
}
+ /**
+ * 銆�銆� *瀛楃涓茬殑鏃ユ湡鏍煎紡鐨勮绠�
+ */
+ public long daysBetween(Date smdate, Date bdate) {
+ long between_days = 0;
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(smdate);
+ long time1 = cal.getTimeInMillis();
+ cal.setTime(bdate);
+ long time2 = cal.getTimeInMillis();
+ between_days = (time2 - time1) / (1000 * 3600 * 24);
+
+ return between_days;
+ }
+
@Override
public Date getTargetEndTime(double month, Date startDate) {
Calendar endDate = Calendar.getInstance();
@@ -1580,10 +1586,10 @@
ComputeFeeSMOImpl computeFeeSMO = new ComputeFeeSMOImpl();
try {
double month = computeFeeSMO.dayCompare(
- DateUtil.getDateFromString("2021-6-1 00:00:00", DateUtil.DATE_FORMATE_STRING_A),
- DateUtil.getDateFromString("2021-8-5 18:00:00", DateUtil.DATE_FORMATE_STRING_A)
+ DateUtil.getDateFromString("2021-09-30 14:20:02", DateUtil.DATE_FORMATE_STRING_A),
+ DateUtil.getDateFromString("2021-11-03 14:20:02", DateUtil.DATE_FORMATE_STRING_A)
);
- System.out.println(month);
+ System.out.println(Math.ceil(month));
} catch (ParseException e) {
e.printStackTrace();
}
diff --git a/java110-utils/src/main/java/com/java110/utils/util/DateUtil.java b/java110-utils/src/main/java/com/java110/utils/util/DateUtil.java
index af61457..788b7b0 100755
--- a/java110-utils/src/main/java/com/java110/utils/util/DateUtil.java
+++ b/java110-utils/src/main/java/com/java110/utils/util/DateUtil.java
@@ -369,6 +369,7 @@
return curDate;
}
+
public static String getNextMonthFirstDay(String fmt) {
String returndate = "";
Date date = getNextMonthFirstDate();
@@ -414,6 +415,10 @@
return maxDate;
}
+ public static void main(String[] args) {
+ System.out.println(getCurrentMonthDay());
+ }
+
/**
* 鍦ㄧ粰瀹氱殑鏃ユ湡鍔犱笂鎴栧噺鍘绘寚瀹氭湀浠藉悗鐨勬棩鏈�
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 af2ed7c..e43fe25 100755
--- 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
@@ -17,11 +17,7 @@
import com.java110.report.dao.IReportCommunityServiceDao;
import com.java110.report.dao.IReportFeeMonthStatisticsServiceDao;
import com.java110.report.dao.IReportFeeServiceDao;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.BeanConvertUtil;
-import com.java110.utils.util.DateUtil;
-import com.java110.utils.util.ListUtil;
-import com.java110.utils.util.StringUtil;
+import com.java110.utils.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,11 +26,7 @@
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* @ClassName GeneratorFeeMonthStatisticsInnerServiceSMOImpl
@@ -529,16 +521,34 @@
|| curDate.getTime() < tmpReportFeeDto.getEndTime().getTime()) {
return 0.0;
}
+
+ //杩欓噷闇�瑕佸垽鏂� 缁撴潫鏃堕棿 鏄惁 澶т簬浜嗗綋鏈堟渶鍚庝竴澶╋紝褰撴湀澶╂暟 * 姣忓ぉ閲戦
+ Calendar nextDateC = Calendar.getInstance();
+ nextDateC.setTime(curDate);
+ nextDateC.add(Calendar.MONTH, 1);
+ Date nextDate = nextDateC.getTime();
+
if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeFlag())) {
- month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), tmpReportFeeDto.getDeadlineTime());
- month = Math.ceil(month);
- if (month == 0) {
- return 0.0;
+ double allDays = computeFeeSMOImpl.daysBetween(tmpReportFeeDto.getEndTime(), tmpReportFeeDto.getDeadlineTime());
+ allDays = Math.ceil(allDays);
+ if (allDays == 0) { // 闃叉闄ゆ暟涓�0
+ return 0;
}
- double money = feePriceDec.divide(new BigDecimal(month), 2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
- return money;
+ BigDecimal moneyPreDay = feePriceDec.divide(new BigDecimal(allDays), 2, BigDecimal.ROUND_HALF_EVEN);
+ if (tmpReportFeeDto.getDeadlineTime().getTime() > nextDate.getTime()) {
+ int day = DateUtil.getCurrentMonthDay();
+ return moneyPreDay.multiply(new BigDecimal(day)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+ }
+ // 缁撴潫鏃堕棿 鍦ㄥ綋鏈堝唴
+ double hisDays = computeFeeSMOImpl.daysBetween(tmpReportFeeDto.getEndTime(), curDate);
+ BigDecimal hisDayDec = moneyPreDay.multiply(new BigDecimal(hisDays)).setScale(2, BigDecimal.ROUND_HALF_UP);
+ return feePriceDec.subtract(hisDayDec).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
- month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), curDate);
+
+ month = computeFeeSMOImpl.dayCompare(curDate, tmpReportFeeDto.getDeadlineTime());
+ if (month < 0) {
+ return 0;
+ }
if (month < 1) {
return feePriceDec.multiply(new BigDecimal(month)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
}
@@ -556,7 +566,7 @@
private double getHisOweAmount(ReportFeeDto tmpReportFeeDto) {
BigDecimal feePriceDec = new BigDecimal(tmpReportFeeDto.getFeePrice());
- Date curDate = DateUtil.getFirstDate();
+ Date curDate = DateUtil.getFirstDate();//11鏈�1鏃�
//璇存槑娌℃湁鍘嗗彶娆犺垂
if (curDate.getTime() < tmpReportFeeDto.getEndTime().getTime()) {
return 0.0;
@@ -567,13 +577,17 @@
if (tmpReportFeeDto.getDeadlineTime().getTime() < curDate.getTime()) {
return tmpReportFeeDto.getFeePrice();
}
- double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getDeadlineTime(), tmpReportFeeDto.getEndTime());
- month = Math.ceil(month);
- if(month == 0){ // 闃叉闄ゆ暟涓�0
+ double allDays = computeFeeSMOImpl.daysBetween(tmpReportFeeDto.getEndTime(), tmpReportFeeDto.getDeadlineTime());
+ allDays = Math.ceil(allDays);
+ if (allDays == 0) { // 闃叉闄ゆ暟涓�0
return 0;
}
- double money = feePriceDec.divide(new BigDecimal(month), 2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
- return money;
+ //杩欐槸姣忓ぉ鐨勯挶
+ BigDecimal moneyPreDay = feePriceDec.divide(new BigDecimal(allDays), 2, BigDecimal.ROUND_HALF_EVEN);
+
+ double hisDays = computeFeeSMOImpl.daysBetween(tmpReportFeeDto.getEndTime(), curDate);
+
+ return moneyPreDay.multiply(new BigDecimal(hisDays)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
double month = 0.0;
--
Gitblit v1.8.0