From ac82dee75615f23ba1ca141314cc45b8a7170b00 Mon Sep 17 00:00:00 2001
From: xiaogang <905166056@qq.com>
Date: 星期四, 12 八月 2021 22:34:40 +0800
Subject: [PATCH] 优化字母车位费用问题
---
service-fee/src/main/java/com/java110/fee/bmo/impl/QueryOweFeeImpl.java | 128 ++++++++++++++++++++++++++++++++++--------
1 files changed, 103 insertions(+), 25 deletions(-)
diff --git a/service-fee/src/main/java/com/java110/fee/bmo/impl/QueryOweFeeImpl.java b/service-fee/src/main/java/com/java110/fee/bmo/impl/QueryOweFeeImpl.java
old mode 100644
new mode 100755
index 6ca9ca3..64d449a
--- a/service-fee/src/main/java/com/java110/fee/bmo/impl/QueryOweFeeImpl.java
+++ b/service-fee/src/main/java/com/java110/fee/bmo/impl/QueryOweFeeImpl.java
@@ -1,6 +1,7 @@
package com.java110.fee.bmo.impl;
import com.alibaba.fastjson.JSONArray;
+import com.java110.core.factory.Java110ThreadPoolFactory;
import com.java110.core.smo.IComputeFeeSMO;
import com.java110.dto.RoomDto;
import com.java110.dto.fee.FeeConfigDto;
@@ -135,6 +136,7 @@
} else if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDto.getPayerObjType())) {//杞︿綅鐩稿叧
OwnerCarDto ownerCarDto = new OwnerCarDto();
+ ownerCarDto.setCarTypeCd("1001"); //涓氫富杞﹁締
ownerCarDto.setCommunityId(feeDto.getCommunityId());
ownerCarDto.setCarId(feeDto.getPayerObjId());
List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
@@ -171,38 +173,71 @@
roomDto.setCommunityId(feeDto.getCommunityId());
roomDto.setRoomId(feeDto.getPayerObjId());
List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto);
+
+ if (roomDtos == null || roomDtos.size() < 1) {
+ return ResultVo.createResponseEntity(ResultVo.CODE_OK, "鎴愬姛", new JSONArray());
+ }
//鏌ヨ璐圭敤淇℃伅arrearsEndTime
- FeeDto tmpFeeDto = null;
List<RoomDto> tmpRoomDtos = new ArrayList<>();
- for (RoomDto tmpRoomDto : roomDtos) {
- tmpFeeDto = new FeeDto();
- tmpFeeDto.setArrearsEndTime(DateUtil.getCurrentDate());
- tmpFeeDto.setState(FeeDto.STATE_DOING);
- tmpFeeDto.setPayerObjId(tmpRoomDto.getRoomId());
- tmpFeeDto.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
- List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
+ List<RoomDto> tempRooms = new ArrayList<>();
+ int threadNum = Java110ThreadPoolFactory.JAVA110_DEFAULT_THREAD_NUM;
- if (feeDtos == null || feeDtos.size() < 1) {
- feeDtos = new ArrayList<>();
- return ResultVo.createResponseEntity(feeDtos);
- }
- List<FeeDto> tmpFeeDtos = new ArrayList<>();
- for (FeeDto tempFeeDto : feeDtos) {
- computeFeeSMOImpl.computeEveryOweFee(tempFeeDto);//璁$畻娆犺垂閲戦
- //濡傛灉閲戦涓�0 灏辨帓闄�
- if (tempFeeDto.getFeePrice() > 0 && tempFeeDto.getEndTime().getTime() <= DateUtil.getCurrentDate().getTime()) {
- tmpFeeDtos.add(tmpFeeDto);
- }
- }
-
- if (tmpFeeDtos.size() < 1) {
+ tempRooms.addAll(doGetTmpRoomDto(roomDtos, feeDto, threadNum));
+ for (RoomDto tmpRoomDto : tempRooms) {
+ if (tmpRoomDto == null) {
continue;
}
- tmpRoomDto.setFees(tmpFeeDtos);
tmpRoomDtos.add(tmpRoomDto);
}
return ResultVo.createResponseEntity(tmpRoomDtos);
+ }
+
+ private List<RoomDto> doGetTmpRoomDto(List<RoomDto> roomDtos, FeeDto feeDto, int threadNum) {
+ Java110ThreadPoolFactory java110ThreadPoolFactory = null;
+ try {
+ java110ThreadPoolFactory = Java110ThreadPoolFactory.getInstance().createThreadPool(threadNum);
+ for (RoomDto roomDto1 : roomDtos) {
+ java110ThreadPoolFactory.submit(() -> {
+ return getTmpRoomDtos(roomDto1, feeDto);
+ });
+ }
+ return java110ThreadPoolFactory.get();
+ } finally {
+ if (java110ThreadPoolFactory != null) {
+ java110ThreadPoolFactory.stop();
+ }
+ }
+ }
+
+ private RoomDto getTmpRoomDtos(RoomDto tmpRoomDto, FeeDto feeDto) {
+ FeeDto tmpFeeDto = null;
+ tmpFeeDto = new FeeDto();
+ tmpFeeDto.setArrearsEndTime(DateUtil.getCurrentDate());
+ tmpFeeDto.setState(FeeDto.STATE_DOING);
+ tmpFeeDto.setPayerObjId(tmpRoomDto.getRoomId());
+ tmpFeeDto.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
+ List<FeeDto> feeDtos = feeInnerServiceSMOImpl.querySimpleFees(tmpFeeDto);
+
+ if (feeDtos == null || feeDtos.size() < 1) {
+ return null;
+ }
+
+ List<FeeDto> tmpFeeDtos = new ArrayList<>();
+ for (FeeDto tempFeeDto : feeDtos) {
+
+ computeFeeSMOImpl.computeEveryOweFee(tempFeeDto, tmpRoomDto);//璁$畻娆犺垂閲戦
+ //濡傛灉閲戦涓�0 灏辨帓闄�
+ if (tempFeeDto.getFeePrice() > 0 && tempFeeDto.getEndTime().getTime() <= DateUtil.getCurrentDate().getTime()) {
+ tmpFeeDtos.add(tempFeeDto);
+ }
+ }
+
+ if (tmpFeeDtos.size() < 1) {
+ return null;
+ }
+ tmpRoomDto.setFees(tmpFeeDtos);
+ return tmpRoomDto;
}
private boolean freshFeeDtoParam(FeeDto feeDto) {
@@ -368,6 +403,10 @@
BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
feePrice = additionalAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ } else if ("3003".equals(computingFormula)) { // 鍥哄畾璐圭敤
+ feePrice = 0.0;
+ } else if ("1101".equals(computingFormula)) { // 绉熼噾
+ feePrice = 0.0;
} else if ("4004".equals(computingFormula)) {
feePrice = Double.parseDouble(feeDto.getAmount());
} else if ("5005".equals(computingFormula)) {
@@ -377,6 +416,19 @@
BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
+ BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
+ BigDecimal sub = curDegree.subtract(preDegree);
+ feePrice = sub.multiply(squarePrice)
+ .add(additionalAmount)
+ .setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ }
+ } else if ("9009".equals(computingFormula)) { //(鏈湡搴︽暟-涓婃湡搴︽暟)*鍔ㄦ�佸崟浠�+闄勫姞璐�
+ if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
+ feePrice = -1.00;
+ } else {
+ BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
+ BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
+ BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getMwPrice()));
BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
BigDecimal sub = curDegree.subtract(preDegree);
feePrice = sub.multiply(squarePrice)
@@ -394,7 +446,9 @@
feeDto.setAmountOwed(price.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue() + "");
feeDto.setDeadlineTime(targetEndDate);
//鍔ㄦ�佽垂鐢�
- if ("4004".equals(computingFormula)) {
+ if ("4004".equals(computingFormula)
+ && FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())
+ ) {
feeDto.setAmountOwed(feeDto.getFeePrice() + "");
feeDto.setDeadlineTime(DateUtil.getCurrentDate());
}
@@ -464,6 +518,14 @@
} else if ("2002".equals(computingFormula)) { // 鍥哄畾璐圭敤
BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
feePrice = additionalAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ } else if ("3003".equals(computingFormula)) { // 鍥哄畾璐圭敤
+ BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
+ BigDecimal builtUpArea = new BigDecimal(Double.parseDouble(tmpRoomDto.getRoomArea()));
+ BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
+ feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(3, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ } else if ("1101".equals(computingFormula)) { // 绉熼噾
+ BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(tmpRoomDto.getRoomRent()));
+ feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_EVEN).doubleValue();
} else if ("4004".equals(computingFormula)) {
feePrice = Double.parseDouble(feeDto.getAmount());
} else if ("5005".equals(computingFormula)) {
@@ -474,6 +536,20 @@
BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
+ BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
+ BigDecimal sub = curDegree.subtract(preDegree);
+ feePrice = sub.multiply(squarePrice)
+ .add(additionalAmount)
+ .setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ }
+ } else if ("9009".equals(computingFormula)) {
+
+ if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
+ feePrice = -1.00;
+ } else {
+ BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
+ BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
+ BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getMwPrice()));
BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
BigDecimal sub = curDegree.subtract(preDegree);
feePrice = sub.multiply(squarePrice)
@@ -540,7 +616,9 @@
return targetEndDateAndOweMonth;
}
if (FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) {
- if (!StringUtil.isEmpty(feeDto.getCurDegrees())) {
+ if (feeDto.getDeadlineTime() != null) {
+ targetEndDate = feeDto.getDeadlineTime();
+ } else if (!StringUtil.isEmpty(feeDto.getCurDegrees())) {
targetEndDate = feeDto.getCurReadingTime();
} else if (feeDto.getImportFeeEndTime() == null) {
targetEndDate = feeDto.getConfigEndTime();
--
Gitblit v1.8.0