perf: 参数支持devId

dev
huangfeng 1 year ago
parent 913227e50f
commit 38e4448e91

@ -23,6 +23,8 @@ public class ConditionModel {
private Date endTime;
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("装置ID")
private Integer devId;
@ApiModelProperty("页码")
Integer pageNum;
@ApiModelProperty("每页数量")

@ -121,11 +121,25 @@ public class NSensorServiceImpl implements NSensorService {
@Override
public SensorDetail<Map<String, Object>> getDetail(ConditionModel model) throws Exception {
Optional<NSensor> optional = repository.findById(model.getId());
if (!optional.isPresent()) {
throw new BusinessException("未找到该装置");
NSensor sensor;
if (model.getId() != null) {
Optional<NSensor> optional = repository.findById(model.getId());
if (!optional.isPresent()) {
throw new BusinessException("未找到该装置id=" + model.getId());
}
sensor = optional.get();
} else if (model.getDevId() != null) {
List<NSensor> list = repository.findByDevId(model.getDevId());
if (CollectionUtils.isEmpty(list)) {
throw new BusinessException("未找到该装置devId=" + model.getDevId());
} else if (list.size() > 1) {
throw new BusinessException("存在相同devId=" + model.getDevId() + "的多个装置,请先修正监测装置数据");
}
sensor = list.get(0);
} else {
throw new BusinessException("缺少id或者eqmid信息");
}
NSensor sensor = optional.get();
if (sensor.getTypeId() == null) {
throw new BusinessException("该装置缺少类型id信息");
}

Loading…
Cancel
Save