| | |
| | | List<GasFlux> gasFluxes = gasFluxRepository.findAll(specification); |
| | | return gasFluxes; |
| | | } |
| | | |
| | | @Override |
| | | public List<GasFlux> listYesterdayTenAmToSixPm() { |
| | | // 获取昨天的上午十点 |
| | | LocalDateTime yesterdayStart = LocalDateTime.now() |
| | | .minusDays(1) // 减去一天,获取昨天的日期 |
| | | .with(LocalTime.of(10, 0)); // 设置时间为上午十点 |
| | | // 获取昨天的下午6点 |
| | | LocalDateTime yesterdayEnd = LocalDateTime.now() |
| | | .minusDays(1) // 减去一天,获取昨天的日期 |
| | | .with(LocalTime.of(18, 0)); // 设置时间为下午6点 |
| | | Specification<GasFlux> specification = new Specification<GasFlux>() { |
| | | @Override |
| | | public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) { |
| | | Set<Predicate> predicateList = new HashSet<>(); |
| | | predicateList.add(criteriaBuilder.between(root.get("time").as(LocalDateTime.class),yesterdayStart,yesterdayEnd)); |
| | | return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); |
| | | } |
| | | }; |
| | | List<GasFlux> gasFluxes = gasFluxRepository.findAll(specification); |
| | | return gasFluxes; |
| | | } |
| | | } |