From 2d079ac843ebcb335f2ef7d6952f9700a16fddde Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期三, 05 五月 2021 14:11:00 +0800
Subject: [PATCH] 游湖阿底阿妈
---
java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java | 371 ++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 350 insertions(+), 21 deletions(-)
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
old mode 100644
new mode 100755
index b07ad0e..4d23398
--- 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
@@ -2,24 +2,29 @@
import com.java110.core.smo.IComputeFeeSMO;
import com.java110.dto.RoomDto;
-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.community.CommunityDto;
+import com.java110.dto.contract.ContractDto;
+import com.java110.dto.contractRoom.ContractRoomDto;
+import com.java110.dto.fee.*;
import com.java110.dto.owner.OwnerCarDto;
+import com.java110.dto.owner.OwnerDto;
import com.java110.dto.parking.ParkingSpaceDto;
import com.java110.dto.report.ReportCarDto;
import com.java110.dto.report.ReportFeeDto;
import com.java110.dto.report.ReportRoomDto;
+import com.java110.intf.community.ICommunityInnerServiceSMO;
import com.java110.intf.community.IParkingSpaceInnerServiceSMO;
import com.java110.intf.community.IRoomInnerServiceSMO;
import com.java110.intf.fee.IFeeInnerServiceSMO;
+import com.java110.intf.store.IContractInnerServiceSMO;
+import com.java110.intf.store.IContractRoomInnerServiceSMO;
import com.java110.intf.user.IOwnerCarInnerServiceSMO;
+import com.java110.intf.user.IOwnerInnerServiceSMO;
import com.java110.po.feeReceiptDetail.FeeReceiptDetailPo;
import com.java110.utils.constant.ResponseConstant;
import com.java110.utils.exception.ListenerExecuteException;
import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.DateUtil;
import com.java110.utils.util.StringUtil;
import org.slf4j.Logger;
@@ -27,14 +32,11 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import javax.script.ScriptEngine;
+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.*;
/**
* 璐圭敤璁$畻 鏈嶅姟绫�
@@ -60,6 +62,18 @@
@Autowired(required = false)
private IParkingSpaceInnerServiceSMO parkingSpaceInnerServiceSMOImpl;
+
+ @Autowired(required = false)
+ private ICommunityInnerServiceSMO communityInnerServiceSMOImpl;
+
+ @Autowired(required = false)
+ private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
+
+ @Autowired(required = false)
+ private IContractRoomInnerServiceSMO contractRoomInnerServiceSMOImpl;
+
+ @Autowired(required = false)
+ private IContractInnerServiceSMO contractInnerServiceSMOImpl;
@Override
public Date getFeeEndTime() {
@@ -125,6 +139,8 @@
computeFeePriceByRoom(feeDto, roomDto);
} else if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDto.getPayerObjType())) {//杞︿綅鐩稿叧
computeFeePriceByParkingSpace(feeDto);
+ }else if(FeeDto.PAYER_OBJ_TYPE_CONTRACT.equals(feeDto.getPayerObjType())) { //鎴垮眿鐩稿叧
+ computeFeePriceByContract(feeDto, roomDto);
}
}
@@ -132,12 +148,12 @@
Map<String, Object> targetEndDateAndOweMonth = getTargetEndDateAndOweMonth(feeDto);
Date targetEndDate = (Date) targetEndDateAndOweMonth.get("targetEndDate");
double oweMonth = (double) targetEndDateAndOweMonth.get("oweMonth");
- ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto();
- parkingSpaceDto.setCommunityId(feeDto.getCommunityId());
- parkingSpaceDto.setPsId(feeDto.getPayerObjId());
- List<ParkingSpaceDto> parkingSpaceDtos = parkingSpaceInnerServiceSMOImpl.queryParkingSpaces(parkingSpaceDto);
+ OwnerCarDto ownerCarDto = new OwnerCarDto();
+ ownerCarDto.setCommunityId(feeDto.getCommunityId());
+ ownerCarDto.setCarId(feeDto.getPayerObjId());
+ List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
- if (parkingSpaceDtos == null || parkingSpaceDtos.size() < 1) { //鏁版嵁鏈夐棶棰�
+ if (ownerCarDtos == null || ownerCarDtos.size() < 1) { //鏁版嵁鏈夐棶棰�
return;
}
@@ -145,7 +161,6 @@
double feePrice = getFeePrice(feeDto);
feeDto.setFeePrice(feePrice);
- double month = dayCompare(feeDto.getEndTime(), DateUtil.getCurrentDate());
BigDecimal price = new BigDecimal(feeDto.getFeePrice());
price = price.multiply(new BigDecimal(oweMonth));
feeDto.setFeePrice(price.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
@@ -170,7 +185,32 @@
double oweMonth = (double) targetEndDateAndOweMonth.get("oweMonth");
String computingFormula = feeDto.getComputingFormula();
- double feePrice = getFeePrice(feeDto,roomDto);
+ double feePrice = getFeePrice(feeDto, roomDto);
+ feeDto.setFeePrice(feePrice);
+ //double month = dayCompare(feeDto.getEndTime(), DateUtil.getCurrentDate());
+ BigDecimal price = new BigDecimal(feeDto.getFeePrice());
+ price = price.multiply(new BigDecimal(oweMonth));
+ feeDto.setFeePrice(price.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+ feeDto.setDeadlineTime(targetEndDate);
+
+ //鍔ㄦ�佽垂鐢�
+ if ("4004".equals(computingFormula) && !FeeDto.STATE_FINISH.equals(feeDto.getState())) {
+ feeDto.setAmountOwed(feeDto.getFeePrice() + "");
+ //feeDto.setDeadlineTime(DateUtil.getCurrentDate()); 娆犺垂鏃ユ湡涓嶅鍏堟敞閲�
+ }
+ }
+ /**
+ * 鏍规嵁鎴垮眿鏉ョ畻鍗曚环
+ *
+ * @param feeDto
+ */
+ private void computeFeePriceByContract(FeeDto feeDto, RoomDto roomDto) {
+ Map<String, Object> targetEndDateAndOweMonth = getTargetEndDateAndOweMonth(feeDto);
+ Date targetEndDate = (Date) targetEndDateAndOweMonth.get("targetEndDate");
+ double oweMonth = (double) targetEndDateAndOweMonth.get("oweMonth");
+
+ String computingFormula = feeDto.getComputingFormula();
+ double feePrice = getFeePrice(feeDto, roomDto);
feeDto.setFeePrice(feePrice);
//double month = dayCompare(feeDto.getEndTime(), DateUtil.getCurrentDate());
BigDecimal price = new BigDecimal(feeDto.getFeePrice());
@@ -229,6 +269,9 @@
}
feeReceiptDetailPo.setArea(value);
feeReceiptDetailPo.setSquarePrice(feeDto.getSquarePrice() + "/" + feeDto.getAdditionalAmount());
+ } else if ("7007".equals(computingFormula)) { //鑷畾涔夊叕寮�
+ feeReceiptDetailPo.setArea(roomDtos.get(0).getBuiltUpArea());
+ feeReceiptDetailPo.setSquarePrice(feeDto.getComputingFormulaText());
} else {
}
} else if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDto.getPayerObjType())) {//杞︿綅鐩稿叧
@@ -271,6 +314,16 @@
}
feeReceiptDetailPo.setArea(value);
feeReceiptDetailPo.setSquarePrice(feeDto.getSquarePrice() + "/" + feeDto.getAdditionalAmount());
+ } else if ("7007".equals(computingFormula)) { //鑷畾涔夊叕寮�
+ ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto();
+ parkingSpaceDto.setCommunityId(feeDto.getCommunityId());
+ parkingSpaceDto.setPsId(ownerCarDtos.get(0).getPsId());
+ List<ParkingSpaceDto> parkingSpaceDtos = parkingSpaceInnerServiceSMOImpl.queryParkingSpaces(parkingSpaceDto);
+ if (parkingSpaceDtos == null || parkingSpaceDtos.size() < 1) { //鏁版嵁鏈夐棶棰�
+ return;
+ }
+ feeReceiptDetailPo.setArea(parkingSpaceDtos.get(0).getArea());
+ feeReceiptDetailPo.setSquarePrice(feeDto.getComputingFormulaText());
} else {
}
}
@@ -320,6 +373,83 @@
objName = objName + "(" + parkingSpaceDtos.get(0).getAreaNum() + "鍋滆溅鍦�" + parkingSpaceDtos.get(0).getNum() + "杞︿綅)";
}
return objName;
+ }
+
+ @Override
+ public OwnerDto getFeeOwnerDto(FeeDto feeDto) {
+ OwnerDto ownerDto = getOwnerDtoByFeeAttr(feeDto);
+ if (ownerDto != null) {
+ return ownerDto;
+ }
+
+ if (FeeDto.PAYER_OBJ_TYPE_ROOM.equals(feeDto.getPayerObjType())) { //鎴垮眿鐩稿叧
+ ownerDto = new OwnerDto();
+ ownerDto.setRoomId(feeDto.getPayerObjId());
+ ownerDto.setCommunityId(feeDto.getCommunityId());
+ List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwners(ownerDto);
+ Assert.listOnlyOne(ownerDtos, "涓氫富涓嶅瓨鍦�");
+ return ownerDtos.get(0);
+ }
+
+ if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDto.getPayerObjType())) {
+ OwnerCarDto ownerCarDto = new OwnerCarDto();
+ ownerCarDto.setCarId(feeDto.getPayerObjId());
+ ownerCarDto.setCommunityId(feeDto.getCommunityId());
+ List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
+
+ Assert.listOnlyOne(ownerCarDtos, "杞﹁締涓嶅瓨鍦�");
+ ownerDto = new OwnerDto();
+ ownerDto.setOwnerId(ownerCarDtos.get(0).getOwnerId());
+ ownerDto.setCommunityId(feeDto.getCommunityId());
+ List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwners(ownerDto);
+ Assert.listOnlyOne(ownerDtos, "涓氫富涓嶅瓨鍦�");
+ return ownerDtos.get(0);
+ }
+
+ if (FeeDto.PAYER_OBJ_TYPE_CONTRACT.equals(feeDto.getPayerObjType())) {
+ ContractDto contractDto = new ContractDto();
+ contractDto.setContractId(feeDto.getPayerObjId());
+ contractDto.setCommunityId(feeDto.getCommunityId());
+ List<ContractDto> contractDtos = contractInnerServiceSMOImpl.queryContracts(contractDto);
+
+ Assert.listOnlyOne(contractDtos, "杞﹁締涓嶅瓨鍦�");
+ ownerDto = new OwnerDto();
+ ownerDto.setOwnerId(contractDtos.get(0).getObjId());
+ ownerDto.setCommunityId(feeDto.getCommunityId());
+ List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwners(ownerDto);
+ Assert.listOnlyOne(ownerDtos, "涓氫富涓嶅瓨鍦�");
+ return ownerDtos.get(0);
+ }
+ return null;
+ }
+
+ private OwnerDto getOwnerDtoByFeeAttr(FeeDto feeDto) {
+ List<FeeAttrDto> feeAttrDtos = feeDto.getFeeAttrDtos();
+
+ if (feeAttrDtos == null || feeAttrDtos.size() < 1) {
+ return null;
+ }
+
+ OwnerDto ownerDto = new OwnerDto();
+ for (FeeAttrDto feeAttrDto : feeAttrDtos) {
+ if (feeAttrDto.getSpecCd().equals(FeeAttrDto.SPEC_CD_OWNER_ID)) {
+ ownerDto.setOwnerId(feeAttrDto.getValue());
+ }
+
+ if (feeAttrDto.getSpecCd().equals(FeeAttrDto.SPEC_CD_OWNER_NAME)) {
+ ownerDto.setName(feeAttrDto.getValue());
+ }
+
+ if (feeAttrDto.getSpecCd().equals(FeeAttrDto.SPEC_CD_OWNER_LINK)) {
+ ownerDto.setLink(feeAttrDto.getValue());
+ }
+ }
+
+ if (StringUtil.isEmpty(ownerDto.getOwnerId())) {
+ return null;
+ }
+
+ return ownerDto;
}
@Override
@@ -490,7 +620,9 @@
int hours = new Double((cycle - Math.floor(cycle)) * futureDay * 24).intValue();
endCalender.add(Calendar.HOUR, hours);
if (FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) {
- if (!StringUtil.isEmpty(feeDto.getCurDegrees())) {
+ if (feeDto.getDeadlineTime() != null) {
+ endCalender.setTime(feeDto.getDeadlineTime());
+ } else if (!StringUtil.isEmpty(feeDto.getCurDegrees())) {
endCalender.setTime(feeDto.getCurReadingTime());
} else if (feeDto.getImportFeeEndTime() == null) {
endCalender.setTime(feeDto.getConfigEndTime());
@@ -545,6 +677,8 @@
}
} else if ("6006".equals(computingFormula)) {
feePrice = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getAmount()));
+ } else if ("7007".equals(computingFormula)) { //鑷畾涔夊叕寮�
+ feePrice = computeRoomCustomizeFormula(BeanConvertUtil.covertBean(tmpReportFeeDto, FeeDto.class), BeanConvertUtil.covertBean(reportRoomDto, RoomDto.class));
} else {
throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍏紡");
}
@@ -577,6 +711,8 @@
}
} else if ("6006".equals(computingFormula)) {
feePrice = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getAmount()));
+ } else if ("7007".equals(computingFormula)) { //鑷畾涔夊叕寮�
+ feePrice = computeCarCustomizeFormula(BeanConvertUtil.covertBean(tmpReportFeeDto, FeeDto.class), BeanConvertUtil.covertBean(reportCarDto, OwnerCarDto.class));
} else {
throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍏紡");
}
@@ -594,7 +730,7 @@
BigDecimal feePrice = new BigDecimal(0.0);
if (FeeDto.PAYER_OBJ_TYPE_ROOM.equals(feeDto.getPayerObjType())) { //鎴垮眿鐩稿叧
String computingFormula = feeDto.getComputingFormula();
- if(roomDto == null) {
+ if (roomDto == null) {
roomDto = new RoomDto();
roomDto.setRoomId(feeDto.getPayerObjId());
roomDto.setCommunityId(feeDto.getCommunityId());
@@ -630,6 +766,10 @@
.setScale(2, BigDecimal.ROUND_HALF_EVEN);
}
} else if ("6006".equals(computingFormula)) {
+ feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
+ } else if ("7007".equals(computingFormula)) { //鑷畾涔夊叕寮�
+ feePrice = computeRoomCustomizeFormula(feeDto, roomDto);
+ } else if ("8008".equals(computingFormula)) { //鎵嬪姩鍔ㄦ�佽垂鐢�
feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
} else {
throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍏紡");
@@ -675,11 +815,196 @@
}
} else if ("6006".equals(computingFormula)) {
feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
+ } else if ("7007".equals(computingFormula)) { //鑷畾涔夊叕寮�
+ feePrice = computeCarCustomizeFormula(feeDto, ownerCarDtos.get(0));
+ } else {
+ throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍏紡");
+ }
+ } else if (FeeDto.PAYER_OBJ_TYPE_CONTRACT.equals(feeDto.getPayerObjType())) { //鍚堝悓鐩稿叧
+ String computingFormula = feeDto.getComputingFormula();
+
+ //鏌ヨ鍚堝悓鍏宠仈鎴垮眿
+ ContractRoomDto contractRoomDto = new ContractRoomDto();
+ contractRoomDto.setContractId(feeDto.getPayerObjId());
+ contractRoomDto.setCommunityId(feeDto.getCommunityId());
+ List<ContractRoomDto> contractRoomDtos = contractRoomInnerServiceSMOImpl.queryContractRooms(contractRoomDto);
+
+ if ("1001".equals(computingFormula)) { //闈㈢Н*鍗曚环+闄勫姞璐�
+ //feePrice = Double.parseDouble(feeDto.getSquarePrice()) * Double.parseDouble(roomDtos.get(0).getBuiltUpArea()) + Double.parseDouble(feeDto.getAdditionalAmount());
+ BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
+ BigDecimal builtUpArea = new BigDecimal(0);
+ for (ContractRoomDto tmpContractRoomDto : contractRoomDtos) {
+ builtUpArea = builtUpArea.add(new BigDecimal(Double.parseDouble(tmpContractRoomDto.getBuiltUpArea())));
+ }
+ feeDto.setBuiltUpArea(builtUpArea.doubleValue() + "");
+ BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
+ feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(3, BigDecimal.ROUND_HALF_EVEN);
+ } else if ("2002".equals(computingFormula)) { // 鍥哄畾璐圭敤
+ //feePrice = Double.parseDouble(feeDto.getAdditionalAmount());
+ BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
+ BigDecimal roomDount = new BigDecimal(contractRoomDtos.size());
+ additionalAmount = additionalAmount.multiply(roomDount);
+ feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_EVEN);
+ } else if ("4004".equals(computingFormula)) { //鍔ㄦ�佽垂鐢�
+ feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
+ } else if ("5005".equals(computingFormula)) { //(鏈湡搴︽暟-涓婃湡搴︽暟)*鍗曚环+闄勫姞璐�
+ if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
+ //throw new IllegalArgumentException("鎶勮〃鏁版嵁寮傚父");
+ } else {
+ 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);
+ }
+ } else if ("6006".equals(computingFormula)) {
+ feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
+ } else if ("7007".equals(computingFormula)) { //鑷畾涔夊叕寮�
+ feePrice = computeContractCustomizeFormula(feeDto, contractRoomDtos);
+ } else if ("8008".equals(computingFormula)) { //鎵嬪姩鍔ㄦ�佽垂鐢�
+ feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
} else {
throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍏紡");
}
}
return feePrice.setScale(3, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ }
+
+ /**
+ * C 浠h〃鎴垮眿瀵瑰簲灏忓尯闈㈢Н
+ * <p>
+ * R 浠h〃鎴垮眿闈㈢Н
+ *
+ * @param feeDto
+ * @param ownerCarDto
+ * @return
+ */
+ private BigDecimal computeCarCustomizeFormula(FeeDto feeDto, OwnerCarDto ownerCarDto) {
+ String value = feeDto.getComputingFormulaText();
+ value = value.replace("\n", "")
+ .replace("\r", "")
+ .trim();
+
+ if (value.contains("C")) { //澶勭悊灏忓尯闈㈢Н
+ CommunityDto communityDto = new CommunityDto();
+ communityDto.setCommunityId(feeDto.getCommunityId());
+ List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
+ if (communityDtos == null || communityDtos.size() < 1) {
+ value = value.replace("C", "0");
+ } else {
+ value = value.replace("C", communityDtos.get(0).getCommunityArea());
+ }
+ } else if (value.contains("R")) { //澶勭悊 鎴垮眿闈㈢Н
+ ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto();
+ parkingSpaceDto.setCommunityId(feeDto.getCommunityId());
+ parkingSpaceDto.setPsId(ownerCarDto.getPsId());
+ List<ParkingSpaceDto> parkingSpaceDtos = parkingSpaceInnerServiceSMOImpl.queryParkingSpaces(parkingSpaceDto);
+ if (parkingSpaceDtos == null || parkingSpaceDtos.size() < 1) { //鏁版嵁鏈夐棶棰�
+ //throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "鏈煡鍒板仠杞︿綅淇℃伅锛屾煡璇㈠鏉℃暟鎹�");
+ value = value.replace("R", "0");
+ } else {
+ value = value.replace("R", parkingSpaceDtos.get(0).getArea());
+ }
+ }
+
+ ScriptEngineManager manager = new ScriptEngineManager();
+ ScriptEngine engine = manager.getEngineByName("JavaScript");
+ BigDecimal valueObj = null;
+ try {
+ value = engine.eval(value).toString();
+ valueObj = new BigDecimal(Double.parseDouble(value));
+ } catch (Exception e) {
+ //throw new IllegalArgumentException("鍏紡璁$畻寮傚父锛屽叕寮忎负銆�" + feeDto.getComputingFormulaText() + "銆�,璁$畻 銆�" + value + "銆戝紓甯�");
+ valueObj = new BigDecimal(0);
+ }
+
+ if (valueObj.doubleValue() < 0) {
+ return new BigDecimal(0);
+ }
+
+ return valueObj;
+ }
+
+ /**
+ * 鑷畾涔夊叕寮忚绠�
+ *
+ * @param feeDto
+ * @return C 浠h〃鎴垮眿瀵瑰簲灏忓尯闈㈢Н
+ * F 浠h〃鎴垮眿瀵瑰簲妤兼爧闈㈢Н
+ * U 浠h〃鎴垮眿瀵瑰簲鍗曞厓闈㈢Н
+ * R 浠h〃鎴垮眿闈㈢Н
+ * X 浠h〃鎴垮眿鏀惰垂绯绘暟锛堟埧灞嬬鐞嗕腑閰嶇疆锛�
+ * L 浠h〃鎴垮眿灞傛暟
+ */
+ private BigDecimal computeContractCustomizeFormula(FeeDto feeDto, List<ContractRoomDto> contractRoomDtos) {
+
+ BigDecimal total = new BigDecimal(0.0);
+ for (ContractRoomDto contractRoomDto : contractRoomDtos) {
+ total = total.add(computeRoomCustomizeFormula(feeDto, contractRoomDto));
+ }
+ return total;
+ }
+
+ /**
+ * 鑷畾涔夊叕寮忚绠�
+ *
+ * @param feeDto
+ * @param roomDto
+ * @return C 浠h〃鎴垮眿瀵瑰簲灏忓尯闈㈢Н
+ * F 浠h〃鎴垮眿瀵瑰簲妤兼爧闈㈢Н
+ * U 浠h〃鎴垮眿瀵瑰簲鍗曞厓闈㈢Н
+ * R 浠h〃鎴垮眿闈㈢Н
+ * X 浠h〃鎴垮眿鏀惰垂绯绘暟锛堟埧灞嬬鐞嗕腑閰嶇疆锛�
+ * L 浠h〃鎴垮眿灞傛暟
+ */
+ private BigDecimal computeRoomCustomizeFormula(FeeDto feeDto, RoomDto roomDto) {
+
+ String value = feeDto.getComputingFormulaText();
+ value = value.replace("\n", "")
+ .replace("\r", "")
+ .trim();
+
+ if (value.contains("C")) { //澶勭悊灏忓尯闈㈢Н
+ CommunityDto communityDto = new CommunityDto();
+ communityDto.setCommunityId(feeDto.getCommunityId());
+ List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
+ if (communityDtos == null || communityDtos.size() < 1) {
+ value = value.replace("C", "0");
+ } else {
+ value = value.replace("C", communityDtos.get(0).getCommunityArea());
+ }
+ } else if (value.contains("F")) { //澶勭悊妤兼爧
+ value = value.replace("F", roomDto.getFloorArea());
+ } else if (value.contains("U")) { //澶勭悊鍗曞厓
+ value = value.replace("U", roomDto.getUnitArea());
+ } else if (value.contains("R")) { //澶勭悊 鎴垮眿闈㈢Н
+ value = value.replace("R", roomDto.getBuiltUpArea());
+ } else if (value.contains("X")) {// 澶勭悊 鎴垮眿绯绘暟
+ value = value.replace("X", roomDto.getFeeCoefficient());
+ } else if (value.contains("L")) {//澶勭悊鎴垮眿灞傛暟
+ value = value.replace("L", roomDto.getLayer());
+ }
+
+ ScriptEngineManager manager = new ScriptEngineManager();
+ ScriptEngine engine = manager.getEngineByName("JavaScript");
+ BigDecimal valueObj = null;
+ try {
+ value = engine.eval(value).toString();
+ valueObj = new BigDecimal(Double.parseDouble(value));
+ } catch (Exception e) {
+ //throw new IllegalArgumentException("鍏紡璁$畻寮傚父锛屽叕寮忎负銆�" + feeDto.getComputingFormulaText() + "銆�,璁$畻 銆�" + value + "銆戝紓甯�");
+ valueObj = new BigDecimal(0);
+ }
+
+ if (valueObj.doubleValue() < 0) {
+ return new BigDecimal(0);
+ }
+
+ return valueObj;
+
}
public Map getTargetEndDateAndOweMonth(FeeDto feeDto, OwnerCarDto ownerCarDto) {
@@ -695,7 +1020,10 @@
return targetEndDateAndOweMonth;
}
if (FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) {
- if (!StringUtil.isEmpty(feeDto.getCurDegrees())) {
+ //鍏堝彇 deadlineTime
+ if (feeDto.getDeadlineTime() != null) {
+ targetEndDate = feeDto.getDeadlineTime();
+ } else if (!StringUtil.isEmpty(feeDto.getCurDegrees())) {
targetEndDate = feeDto.getCurReadingTime();
} else if (feeDto.getImportFeeEndTime() == null) {
targetEndDate = feeDto.getConfigEndTime();
@@ -765,6 +1093,7 @@
}
public Map getTargetEndDateAndOweMonth(FeeDto feeDto) {
+
if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDto.getPayerObjType())) {
OwnerCarDto ownerCarDto = new OwnerCarDto();
ownerCarDto.setCommunityId(feeDto.getCommunityId());
--
Gitblit v1.8.0