|
|
|
@ -35,16 +35,20 @@ public class WarnRuleServiceImpl implements WarnRuleService {
|
|
|
|
|
DataService dataService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<WarnRule> listAll() throws Exception {
|
|
|
|
|
List<WarnRule> list = repository.findAll();
|
|
|
|
|
public List<WarnRule> listAll(Integer sensorId) throws Exception {
|
|
|
|
|
List<WarnRule> list;
|
|
|
|
|
if (sensorId != null) {
|
|
|
|
|
list = repository.findBySensorId(sensorId);
|
|
|
|
|
} else {
|
|
|
|
|
list = repository.findAll();
|
|
|
|
|
}
|
|
|
|
|
for (WarnRule item : list) {
|
|
|
|
|
NSensor sensor = sensorService.detail(item.getSensorId());
|
|
|
|
|
item.setNSensor(sensor);
|
|
|
|
|
Optional<ModevTypePoint> optionalModevTypePoint = typePointRepository.findById(item.getModevtypePointId());
|
|
|
|
|
if (!optionalModevTypePoint.isPresent()) {
|
|
|
|
|
throw new BusinessException("未找到该监测装置属性点" + item.getModevtypePointId());
|
|
|
|
|
if (optionalModevTypePoint.isPresent()) {
|
|
|
|
|
item.setTypePoint(optionalModevTypePoint.get());
|
|
|
|
|
}
|
|
|
|
|
item.setTypePoint(optionalModevTypePoint.get());
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
@ -56,7 +60,7 @@ public class WarnRuleServiceImpl implements WarnRuleService {
|
|
|
|
|
NSensor sensor = sensorService.detail(item.getSensorId());
|
|
|
|
|
Optional<ModevTypePoint> optionalModevTypePoint = typePointRepository.findById(item.getModevtypePointId());
|
|
|
|
|
if (!optionalModevTypePoint.isPresent()) {
|
|
|
|
|
throw new BusinessException("未找到该监测装置属性点" + item.getModevtypePointId());
|
|
|
|
|
throw new BusinessException("未找到该监测装置类型(" + sensor.getTypeName() + ")的属性点" + item.getModevtypePointId());
|
|
|
|
|
}
|
|
|
|
|
ModevTypePoint typePoint = optionalModevTypePoint.get();
|
|
|
|
|
Map<String, Object> map = dataService.getLastOneData(sensor, typePoint);
|
|
|
|
|