|
|
|
@ -12,17 +12,16 @@ import org.springframework.data.domain.Page;
|
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public class IedDlRecordServiceImpl implements IedDlRecordService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@ -33,7 +32,7 @@ public class IedDlRecordServiceImpl implements IedDlRecordService {
|
|
|
|
|
SpectrogramHandler spectrogramHandler;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Page<IedDlRecord> list(Integer configId, Integer devId, int pageNum, int pageSize) throws Exception {
|
|
|
|
|
public Page<IedDlRecord> list(Integer configId, Integer devId, Date startTime, Date endTime, int pageNum, int pageSize) throws Exception {
|
|
|
|
|
PageRequest request = PageRequest.of(pageNum - 1, pageSize);
|
|
|
|
|
Specification<IedDlRecord> specification = (root, query, builder) -> {
|
|
|
|
|
Predicate predicate = builder.conjunction();
|
|
|
|
@ -46,6 +45,12 @@ public class IedDlRecordServiceImpl implements IedDlRecordService {
|
|
|
|
|
} else {
|
|
|
|
|
query.orderBy(builder.desc(root.get("id")));
|
|
|
|
|
}
|
|
|
|
|
if (startTime != null) {
|
|
|
|
|
predicate.getExpressions().add(builder.greaterThan(root.get("createTime"), startTime));
|
|
|
|
|
}
|
|
|
|
|
if (endTime != null) {
|
|
|
|
|
predicate.getExpressions().add(builder.lessThanOrEqualTo(root.get("createTime"), endTime));
|
|
|
|
|
}
|
|
|
|
|
return predicate;
|
|
|
|
|
};
|
|
|
|
|
Page<IedDlRecord> result = repository.findAll(specification, request);
|
|
|
|
|