From 0df516b440a3119df7f9913c47b598b9ab3c8338 Mon Sep 17 00:00:00 2001 From: Guoqs <123@jsowell.com> Date: Sat, 14 Dec 2024 19:55:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E6=B5=81=E7=AD=89=E4=BA=8E0=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E4=BF=9D=E5=AD=98=E5=88=B0redis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pile/service/impl/PileBasicInfoServiceImpl.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java index 9c9d312d5..09f4abbe5 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java @@ -633,6 +633,14 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService { if (StringUtils.equals(realTimeMonitorData.getTransactionCode(), Constants.ILLEGAL_TRANSACTION_CODE)) { return; } + + BigDecimal outputVoltage = new BigDecimal(realTimeMonitorData.getOutputVoltage()); + BigDecimal outputCurrent = new BigDecimal(realTimeMonitorData.getOutputCurrent()); + if (outputCurrent.compareTo(BigDecimal.ZERO) == 0) { + // 电流等于0,不保存到redis + return; + } + // 保存到redis String redisKey = CacheConstants.PILE_REAL_TIME_MONITOR_DATA + realTimeMonitorData.getPileConnectorCode() + "_" + realTimeMonitorData.getTransactionCode(); @@ -640,8 +648,7 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService { Date now = new Date(); realTimeMonitorData.setDateTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, now)); // 计算功率,后面查询要用 - String power = new BigDecimal(realTimeMonitorData.getOutputVoltage()) - .multiply(new BigDecimal(realTimeMonitorData.getOutputCurrent())).setScale(2, RoundingMode.HALF_UP).toString(); + String power = outputVoltage.multiply(outputCurrent).setScale(2, RoundingMode.HALF_UP).toString(); realTimeMonitorData.setOutputPower(power); // 保存json字符串 String jsonMsg = JSON.toJSONString(realTimeMonitorData);