QueryWrapper<PatientDevice> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("patient_id", summaryReqest.getPatientId());
queryWrapper.eq("sn", summaryReqest.getSerialNumber());
queryWrapper.ge("pairing_date", startDate);
queryWrapper.and(tempWrapper -> tempWrapper.le("unpaired_date", endDate)
.or().isNull("unpaired_date"));
queryWrapper.orderByDesc("create_time");
List<PatientDevice> list = patientDeviceMapper.selectList(queryWrapper);
PatientDevice latest = CollectionUtils.isEmpty(list) ? null : list.get(0);