|
@@ -41,7 +41,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
@@ -224,7 +223,7 @@ public abstract class MqttBaseHandler {
|
|
|
if (null != elecMeterH) {
|
|
|
Price price = priceMap.computeIfAbsent(device.getAreaCode(),
|
|
|
k -> priceService.getElecHourPrice(device.getAreaCode(), date));
|
|
|
- completePrice(device, elecMeterH, price);
|
|
|
+ completePrice(elecMeterH, price);
|
|
|
meterHList.add(elecMeterH);
|
|
|
}
|
|
|
}
|
|
@@ -240,16 +239,6 @@ public abstract class MqttBaseHandler {
|
|
|
return cnt;
|
|
|
}
|
|
|
|
|
|
- private void completePrice(MeterDevice device, ElecMeterH elecMeterH, Price price) {
|
|
|
- if (null != price) {
|
|
|
- BigDecimal useQuantity = new BigDecimal(String.valueOf(elecMeterH.getElecQuantity()));
|
|
|
- BigDecimal cost = useQuantity.multiply(new BigDecimal(String.valueOf(price.getPriceValue())));
|
|
|
- elecMeterH.setMeterType(price.getMeterType());
|
|
|
- elecMeterH.setMeterUnitPrice(price.getPriceValue());
|
|
|
- elecMeterH.setUseElecCost(cost.doubleValue());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private ElecMeterH meterHourProdSub(MeterDevice device) {
|
|
|
ElecMeterH elecMeterH = null;
|
|
|
|
|
@@ -281,6 +270,13 @@ public abstract class MqttBaseHandler {
|
|
|
return elecMeterH;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 执行小时抄表计算
|
|
|
+ * @param device 设备信息
|
|
|
+ * @param lastMeterReading 上次抄表值
|
|
|
+ * @param newMeterReading 本次抄表值
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private ElecMeterH execHourMeter(MeterDevice device, String lastMeterReading, String newMeterReading) {
|
|
|
ElecMeterH elecMeterH = null;
|
|
|
BigDecimal lastEngValue = new BigDecimal(lastMeterReading);
|
|
@@ -305,8 +301,15 @@ public abstract class MqttBaseHandler {
|
|
|
return elecMeterH;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 封装计量对象
|
|
|
+ * @param device 设备信息
|
|
|
+ * @param newEngValue 最新电量值
|
|
|
+ * @param useQuantity 用量差值
|
|
|
+ * @return ElecMeterH 计量对象
|
|
|
+ */
|
|
|
private ElecMeterH buildElecMeterH(MeterDevice device, BigDecimal newEngValue, BigDecimal useQuantity) {
|
|
|
- Date date = new Date();
|
|
|
+ Date date = DateUtils.adjustHour(new Date(), -1);
|
|
|
ElecMeterH elecMeterH = new ElecMeterH();
|
|
|
elecMeterH.setAreaCode(device.getAreaCode());
|
|
|
elecMeterH.setDeviceCode(device.getDeviceCode());
|
|
@@ -320,8 +323,29 @@ public abstract class MqttBaseHandler {
|
|
|
return elecMeterH;
|
|
|
}
|
|
|
|
|
|
- private BigDecimal magnification(BigDecimal diff, Integer magnification) {
|
|
|
- return null != magnification ? diff.multiply(new BigDecimal(String.valueOf(magnification))) : diff;
|
|
|
+ /**
|
|
|
+ * 倍率计算
|
|
|
+ * @param quantity 原始用量
|
|
|
+ * @param magnification 倍率
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private BigDecimal magnification(BigDecimal quantity, Integer magnification) {
|
|
|
+ return null != magnification ? quantity.multiply(new BigDecimal(String.valueOf(magnification))) : quantity;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 完善价格信息
|
|
|
+ * @param elecMeterH 计量对象
|
|
|
+ * @param price 价格信息
|
|
|
+ */
|
|
|
+ private void completePrice(ElecMeterH elecMeterH, Price price) {
|
|
|
+ if (null != price) {
|
|
|
+ BigDecimal useQuantity = new BigDecimal(String.valueOf(elecMeterH.getElecQuantity()));
|
|
|
+ BigDecimal cost = useQuantity.multiply(new BigDecimal(String.valueOf(price.getPriceValue())));
|
|
|
+ elecMeterH.setMeterType(price.getMeterType());
|
|
|
+ elecMeterH.setMeterUnitPrice(price.getPriceValue());
|
|
|
+ elecMeterH.setUseElecCost(cost.doubleValue());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|