fix: 调整规则的装置不存在的异常处理

dev
huangfeng 1 year ago
parent 8e5f7a751d
commit 052ba1fa6e

@ -111,7 +111,7 @@ public class WarnRule {
} }
public boolean canDo() { public boolean canDo() {
if (active != null && active.intValue() == 1 && actualComp != null) { if (active != null && active.intValue() == 1 && actualComp != null && nSensor != null) {
return true; return true;
} }
return false; return false;

@ -152,7 +152,7 @@ public class NSensorServiceImpl implements NSensorService {
public NSensor detail(Integer id) throws Exception { public NSensor detail(Integer id) throws Exception {
Optional<NSensor> optional = repository.findById(id); Optional<NSensor> optional = repository.findById(id);
if (!optional.isPresent()) { if (!optional.isPresent()) {
throw new BusinessException("未找到该装置id=" + id); return null;
} }
NSensor sensor = optional.get(); NSensor sensor = optional.get();
this.fillOtherName(sensor); this.fillOtherName(sensor);

@ -58,6 +58,9 @@ public class WarnRuleServiceImpl implements WarnRuleService {
item.setId(null); item.setId(null);
item.setLastDTime(null); item.setLastDTime(null);
NSensor sensor = sensorService.detail(item.getSensorId()); NSensor sensor = sensorService.detail(item.getSensorId());
if (sensor == null){
throw new BusinessException("未找到该装置id=" + item.getSensorId());
}
Optional<ModevTypePoint> optionalModevTypePoint = typePointRepository.findById(item.getModevtypePointId()); Optional<ModevTypePoint> optionalModevTypePoint = typePointRepository.findById(item.getModevtypePointId());
if (!optionalModevTypePoint.isPresent()) { if (!optionalModevTypePoint.isPresent()) {
throw new BusinessException("未找到该监测装置类型(" + sensor.getTypeName() + ")的属性点" + item.getModevtypePointId()); throw new BusinessException("未找到该监测装置类型(" + sensor.getTypeName() + ")的属性点" + item.getModevtypePointId());

Loading…
Cancel
Save