From 052ba1fa6e8b7d1a171e58ab5d7dee0b90a6553b Mon Sep 17 00:00:00 2001 From: huangfeng Date: Tue, 18 Jun 2024 09:50:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E8=A7=84=E5=88=99?= =?UTF-8?q?=E7=9A=84=E8=A3=85=E7=BD=AE=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/xydl/cac/entity/WarnRule.java | 2 +- .../java/com/xydl/cac/service/impl/NSensorServiceImpl.java | 2 +- .../java/com/xydl/cac/service/impl/WarnRuleServiceImpl.java | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/xydl/cac/entity/WarnRule.java b/src/main/java/com/xydl/cac/entity/WarnRule.java index bb47808..220424c 100644 --- a/src/main/java/com/xydl/cac/entity/WarnRule.java +++ b/src/main/java/com/xydl/cac/entity/WarnRule.java @@ -111,7 +111,7 @@ public class WarnRule { } public boolean canDo() { - if (active != null && active.intValue() == 1 && actualComp != null) { + if (active != null && active.intValue() == 1 && actualComp != null && nSensor != null) { return true; } return false; diff --git a/src/main/java/com/xydl/cac/service/impl/NSensorServiceImpl.java b/src/main/java/com/xydl/cac/service/impl/NSensorServiceImpl.java index 17a5bcf..1bd7f17 100644 --- a/src/main/java/com/xydl/cac/service/impl/NSensorServiceImpl.java +++ b/src/main/java/com/xydl/cac/service/impl/NSensorServiceImpl.java @@ -152,7 +152,7 @@ public class NSensorServiceImpl implements NSensorService { public NSensor detail(Integer id) throws Exception { Optional optional = repository.findById(id); if (!optional.isPresent()) { - throw new BusinessException("未找到该装置id=" + id); + return null; } NSensor sensor = optional.get(); this.fillOtherName(sensor); diff --git a/src/main/java/com/xydl/cac/service/impl/WarnRuleServiceImpl.java b/src/main/java/com/xydl/cac/service/impl/WarnRuleServiceImpl.java index ad75300..5ba5090 100644 --- a/src/main/java/com/xydl/cac/service/impl/WarnRuleServiceImpl.java +++ b/src/main/java/com/xydl/cac/service/impl/WarnRuleServiceImpl.java @@ -58,6 +58,9 @@ public class WarnRuleServiceImpl implements WarnRuleService { item.setId(null); item.setLastDTime(null); NSensor sensor = sensorService.detail(item.getSensorId()); + if (sensor == null){ + throw new BusinessException("未找到该装置id=" + item.getSensorId()); + } Optional optionalModevTypePoint = typePointRepository.findById(item.getModevtypePointId()); if (!optionalModevTypePoint.isPresent()) { throw new BusinessException("未找到该监测装置类型(" + sensor.getTypeName() + ")的属性点" + item.getModevtypePointId());