|
@@ -38,7 +38,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
-import java.lang.reflect.InvocationTargetException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.MathContext;
|
|
|
import java.math.RoundingMode;
|
|
@@ -339,17 +338,14 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
|
|
|
// 1-实际面积 2-半层起定 3-不可预定 4-一层起订
|
|
|
|
|
|
- Integer haveFloorNum = 0;// 一层的数量
|
|
|
- Integer halfHaveFloorNum = 0;// 半层的数量
|
|
|
+ int haveFloorNum = 0;// 一层的数量
|
|
|
+ int halfHaveFloorNum = 0;// 半层的数量
|
|
|
applyArea = "";
|
|
|
- String current_floorId = "";
|
|
|
+ StringBuilder current_floorId = new StringBuilder();
|
|
|
if (priceType == 1) { // 平米每小时
|
|
|
- Iterator it = floorSumAreaMap.keySet().iterator();
|
|
|
- while (it.hasNext()) {
|
|
|
-
|
|
|
- Integer floorId = (Integer) it.next();
|
|
|
+ for (Integer floorId : floorSumAreaMap.keySet()) {
|
|
|
|
|
|
- current_floorId = current_floorId + floorId.toString() + ";";
|
|
|
+ current_floorId.append(floorId.toString()).append(";");
|
|
|
|
|
|
boolean isHalfHaveFloor = false;// 是否有半层起
|
|
|
boolean isHaveFloor = false;// 是否有一层起
|
|
@@ -361,7 +357,7 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
}
|
|
|
|
|
|
|
|
|
- BigDecimal sumArea = (BigDecimal) floorSumAreaMap.get(floorId);// 当层申请合计面积
|
|
|
+ BigDecimal sumArea = floorSumAreaMap.get(floorId);// 当层申请合计面积
|
|
|
BigDecimal floorSumArea = roomInfoManager.getSumArueByFloorId(floorId);// 整层合计面积
|
|
|
if (null == floorSumArea) {
|
|
|
floorSumArea = BigDecimal.ZERO;
|
|
@@ -384,12 +380,9 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
applyArea = calcapplyArea.toString() + "m²";
|
|
|
} else if (priceType == 2) { // 层(半层)每小时
|
|
|
|
|
|
- Iterator it = floorSumAreaMap.keySet().iterator();
|
|
|
- while (it.hasNext()) {
|
|
|
-
|
|
|
- Integer floorId = (Integer) it.next();
|
|
|
+ for (Integer floorId : floorSumAreaMap.keySet()) {
|
|
|
|
|
|
- current_floorId = current_floorId + floorId.toString() + ";";
|
|
|
+ current_floorId.append(floorId.toString()).append(";");
|
|
|
|
|
|
boolean isHalfHaveFloor = false;// 是否有半层起
|
|
|
boolean isHaveFloor = false;// 是否有一层起
|
|
@@ -428,16 +421,16 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
}
|
|
|
// applyArea = calcapplyArea.toString();
|
|
|
if (haveFloorNum > 0) {
|
|
|
- applyArea = "层*" + haveFloorNum.toString();
|
|
|
+ applyArea = "层*" + haveFloorNum;
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(applyArea) && halfHaveFloorNum > 0) {
|
|
|
- applyArea = applyArea + "," + "半层*" + halfHaveFloorNum.toString();
|
|
|
+ applyArea = applyArea + "," + "半层*" + halfHaveFloorNum;
|
|
|
} else if (halfHaveFloorNum > 0) {
|
|
|
- applyArea = "半层*" + halfHaveFloorNum.toString();
|
|
|
+ applyArea = "半层*" + halfHaveFloorNum;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- airConditionerAddTime.setFloorId(current_floorId.replaceAll("[;]$", ""));
|
|
|
+ airConditionerAddTime.setFloorId(current_floorId.toString().replaceAll("[;]$", ""));
|
|
|
airConditionerAddTime.setApplyArea(applyArea);
|
|
|
airConditionerAddTime.setUseStartTime(minDate);
|
|
|
airConditionerAddTime.setUseEndTime(maxDate);
|
|
@@ -447,12 +440,13 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
floorPriceHour = airRule.getFloorPriceHour();// 每层多少钱/每小时
|
|
|
halfFloorPriceHour = airRule.getHalfFloorPriceHour();// 每半层多少钱/每小时
|
|
|
|
|
|
+ // deprecated
|
|
|
// 空调加时最低申请1小时,半小时按1小时收取费用
|
|
|
- BigDecimal UseLengthTime = DateUtils.compareStringTimesToHour(airConditionerAddTime.getUseStartTime(), airConditionerAddTime.getUseEndTime());
|
|
|
- // if (UseLengthTime.compareTo(new BigDecimal("1")) == -1) {
|
|
|
- // return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "最低申请1小时,请重新选择时间");
|
|
|
- //}
|
|
|
- UseLengthTime = UseLengthTime.setScale(0, BigDecimal.ROUND_UP);// 向上取整
|
|
|
+ // BigDecimal UseLengthTime = DateUtils.compareStringTimesToHour(airConditionerAddTime.getUseStartTime(), airConditionerAddTime.getUseEndTime());
|
|
|
+ // UseLengthTime = UseLengthTime.setScale(0, BigDecimal.ROUND_UP);// 向上取整
|
|
|
+
|
|
|
+ // 20231201 空调加时最低申请半小时,不满半小时按半小时收取费用
|
|
|
+ BigDecimal UseLengthTime = DateUtils.calculateUsageDuration(airConditionerAddTime.getUseStartTime(), airConditionerAddTime.getUseEndTime());
|
|
|
|
|
|
airConditionerAddTime.setUseLengthTime(UseLengthTime);// 使用时长
|
|
|
|
|
@@ -462,73 +456,58 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
boolean isCalcHouse = true;// 是否按面积来计算
|
|
|
|
|
|
|
|
|
- BigDecimal calcFee = BigDecimal.ZERO.setScale(2);// 费用
|
|
|
+ BigDecimal calcFee = BigDecimal.ZERO.setScale(2, RoundingMode.UNNECESSARY);// 费用
|
|
|
String freeDetail = "";// 费用明细
|
|
|
// 小时*1层*每层300元/小时
|
|
|
// 1小时*半层*每半层200元/小时
|
|
|
- if (false) {// 按户计算
|
|
|
-
|
|
|
- // priceDisplay="每户350元/每小时";
|
|
|
- priceDisplay = "每户" + df4.format(priceHu.setScale(2)) + "元/每小时";
|
|
|
-
|
|
|
- // 费用明细:2小时*2户*每户350元/每小时=1400.00元
|
|
|
- calcFee = UseLengthTime.multiply(new BigDecimal(houseNo)).multiply(priceHu).setScale(2, 4);
|
|
|
- freeDetail = UseLengthTime.toPlainString() + "小时*" + houseNo + "户*" + priceDisplay;
|
|
|
- airConditionerAddTime.setUseAreaOrTime(2);// 使用 1面积 2 时间
|
|
|
-
|
|
|
-
|
|
|
- } else {// 用面积计算
|
|
|
-
|
|
|
+ // 用面积计算
|
|
|
+ if (priceType == 1) {
|
|
|
|
|
|
- if (priceType == 1) {
|
|
|
+ String calc_applyArea = applyArea.replace("m²", "");
|
|
|
|
|
|
- String calc_applyArea = applyArea.replace("m²", "");
|
|
|
+ // priceDisplay="每平米0.15元/小时";
|
|
|
+ priceDisplay = "每平米" + df4.format(priceHour.setScale(2)) + "元/小时";
|
|
|
|
|
|
- // priceDisplay="每平米0.15元/小时";
|
|
|
- priceDisplay = "每平米" + df4.format(priceHour.setScale(2)) + "元/小时";
|
|
|
|
|
|
+ // 费用明细:2小时*2平米*每平米0.15元/小时=1400.00元
|
|
|
+ calcFee = UseLengthTime.multiply(new BigDecimal(calc_applyArea)).multiply(priceHour).setScale(2, 4);
|
|
|
+ freeDetail = UseLengthTime.toPlainString() + "小时*" + calc_applyArea + "平米*" + priceDisplay;
|
|
|
+ airConditionerAddTime.setUseAreaOrTime(1);// 使用 1面积 2 时间
|
|
|
+ } else if (priceType == 2) {
|
|
|
|
|
|
- // 费用明细:2小时*2平米*每平米0.15元/小时=1400.00元
|
|
|
- calcFee = UseLengthTime.multiply(new BigDecimal(calc_applyArea)).multiply(priceHour).setScale(2, 4);
|
|
|
- freeDetail = UseLengthTime.toPlainString() + "小时*" + calc_applyArea + "平米*" + priceDisplay;
|
|
|
- airConditionerAddTime.setUseAreaOrTime(1);// 使用 1面积 2 时间
|
|
|
- } else if (priceType == 2) {
|
|
|
+ // 每层300元/小时、每半层200元/小时
|
|
|
+ priceDisplay = "每层" + df4.format(floorPriceHour.setScale(2)) + "元/小时、" + "每半层" + df4.format(halfFloorPriceHour.setScale(2)) + "元/小时";
|
|
|
|
|
|
- // 每层300元/小时、每半层200元/小时
|
|
|
- priceDisplay = "每层" + df4.format(floorPriceHour.setScale(2)) + "元/小时、" + "每半层" + df4.format(halfFloorPriceHour.setScale(2)) + "元/小时";
|
|
|
+ // 1小时*1层*每层300元/小时-1小时*半层*每半层200元/小时
|
|
|
+ // haveFloorNum 多少一层
|
|
|
+ if (haveFloorNum > 0) {
|
|
|
+ calcFee = UseLengthTime.multiply(BigDecimal.valueOf(haveFloorNum)).multiply(floorPriceHour).setScale(2, 4);
|
|
|
+ // 1小时*1层*每层300元/小时
|
|
|
+ freeDetail = UseLengthTime.toPlainString() + "小时*" + haveFloorNum + "层*每层" + floorPriceHour + "元/小时";
|
|
|
+ }
|
|
|
+ if (halfHaveFloorNum > 0) {
|
|
|
+ calcFee = calcFee.add(UseLengthTime.multiply(BigDecimal.valueOf(halfHaveFloorNum)).multiply(halfFloorPriceHour).setScale(2, 4));
|
|
|
|
|
|
- // 1小时*1层*每层300元/小时-1小时*半层*每半层200元/小时
|
|
|
- // haveFloorNum 多少一层
|
|
|
- if (haveFloorNum > 0) {
|
|
|
- calcFee = UseLengthTime.multiply(BigDecimal.valueOf(haveFloorNum)).multiply(floorPriceHour).setScale(2, 4);
|
|
|
- // 1小时*1层*每层300元/小时
|
|
|
- freeDetail = UseLengthTime.toPlainString() + "小时*" + haveFloorNum + "层*每层" + floorPriceHour + "元/小时";
|
|
|
- }
|
|
|
- if (halfHaveFloorNum > 0) {
|
|
|
- calcFee = calcFee.add(UseLengthTime.multiply(BigDecimal.valueOf(halfHaveFloorNum)).multiply(halfFloorPriceHour).setScale(2, 4));
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(freeDetail)) {
|
|
|
- // 1小时*半层*每半层200元/小时
|
|
|
- freeDetail = freeDetail + "," + UseLengthTime.toPlainString() + "小时*" + "半层*" + halfHaveFloorNum + "*每半层" + halfFloorPriceHour + "元/小时";
|
|
|
- } else {
|
|
|
- freeDetail = UseLengthTime.toPlainString() + "小时*" + "半层*" + halfHaveFloorNum + "*每半层" + halfFloorPriceHour + "元/小时";
|
|
|
- }
|
|
|
+ if (StringUtils.isNotBlank(freeDetail)) {
|
|
|
+ // 1小时*半层*每半层200元/小时
|
|
|
+ freeDetail = freeDetail + "," + UseLengthTime.toPlainString() + "小时*" + "半层*" + halfHaveFloorNum + "*每半层" + halfFloorPriceHour + "元/小时";
|
|
|
+ } else {
|
|
|
+ freeDetail = UseLengthTime.toPlainString() + "小时*" + "半层*" + halfHaveFloorNum + "*每半层" + halfFloorPriceHour + "元/小时";
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+
|
|
|
airConditionerAddTime.setPriceDisplay(priceDisplay);// 单价:每户350元/每小时
|
|
|
// 工作日2018-09-18 07:00~21:00
|
|
|
// 工作日根据时间获取
|
|
|
String dataTypeStr = "工作日";
|
|
|
- if (dataType == GoodsCodeConstants.DATATYPE_WORKINGDAY) {// 工作日
|
|
|
+ if (Objects.equals(dataType, GoodsCodeConstants.DATATYPE_WORKINGDAY)) {// 工作日
|
|
|
dataTypeStr = "工作日";
|
|
|
- } else if (dataType == GoodsCodeConstants.DATATYPE_RESTDAY) {// 休息日
|
|
|
+ } else if (Objects.equals(dataType, GoodsCodeConstants.DATATYPE_RESTDAY)) {// 休息日
|
|
|
dataTypeStr = "休息日";
|
|
|
- } else if (dataType == GoodsCodeConstants.DATATYPE_VACATIONS) {// 节假日
|
|
|
+ } else if (Objects.equals(dataType, GoodsCodeConstants.DATATYPE_VACATIONS)) {// 节假日
|
|
|
dataTypeStr = "节假日";
|
|
|
}
|
|
|
|
|
@@ -555,7 +534,7 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
|
|
|
String types = "5,6";// 空调加时
|
|
|
List<Map<String, Object>> list = enterprisePermissionDao.getGoodsConfig(airConditionerAddTime.getOrganizationId().longValue(), types, "");
|
|
|
- if (list != null && list.size() > 0) {
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
if (null != virPermId && virPermId.equals((Integer) list.get(0).get("roleId"))) {
|
|
|
|
|
|
if (list.size() >= 2) {
|
|
@@ -658,14 +637,8 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
|
|
|
return AppResultUtil.createSuccesDto(convert(bill));
|
|
|
|
|
|
- } catch (IllegalAccessException e) {
|
|
|
- e.printStackTrace();
|
|
|
- return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "空调加时申请失败:" + LogExceptionStackUtil.LogExceptionStack(e));
|
|
|
- } catch (InvocationTargetException e) {
|
|
|
- e.printStackTrace();
|
|
|
- return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "空调加时申请失败:" + LogExceptionStackUtil.LogExceptionStack(e));
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("空调加时申请失败:{}", LogExceptionStackUtil.LogExceptionStack(e));
|
|
|
return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "空调加时申请失败:" + LogExceptionStackUtil.LogExceptionStack(e));
|
|
|
}
|
|
|
|
|
@@ -2607,13 +2580,11 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/*
|
|
|
- * 使用时长
|
|
|
- * 空调加时最低申请1小时,半小时按1小时收取费用
|
|
|
+ * 使用时长
|
|
|
+ * 空调加时最低申请半小时,不到半小时按半小时收取费用
|
|
|
*/
|
|
|
- BigDecimal useLengthTime = DateUtils.compareStringTimesToHour(minDate, maxDate);
|
|
|
- useLengthTime = useLengthTime.setScale(0, RoundingMode.UP);// 向上取整
|
|
|
+ BigDecimal useLengthTime = DateUtils.calculateUsageDuration(airConditionerAddTime.getUseStartTime(), airConditionerAddTime.getUseEndTime());
|
|
|
|
|
|
airConditionerAddTime.setUseLengthTime(useLengthTime);
|
|
|
|