diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index 49c7113..e76d05d 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -172,6 +172,21 @@ public class FirePointController { if(firePointEntities == null || firePointEntities.size() == 0){ return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时没有火点数据",locale); } - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,firePointEntities,locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale); + } + + /** + * 查询近一个月的火点信息 + * @return + */ + @GetMapping("/selectFirePointByMonth") + public String selectFirePointByMonth() { + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + List firePointEntities = firePointService.selectFirePointByMonth(); + if(firePointEntities == null || firePointEntities.size() == 0){ + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时没有火点数据",locale); + } + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale); } } diff --git a/src/main/java/com/xkrs/service/FirePointService.java b/src/main/java/com/xkrs/service/FirePointService.java index f990db2..afb875f 100644 --- a/src/main/java/com/xkrs/service/FirePointService.java +++ b/src/main/java/com/xkrs/service/FirePointService.java @@ -71,4 +71,10 @@ public interface FirePointService { * @return */ List selectFirePointBetweenSeven(); + + /** + * 查询近一个月的火点信息 + * @return + */ + List selectFirePointByMonth(); } diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 7ea556a..823e999 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -238,4 +238,18 @@ public class FirePointServiceImpl implements FirePointService { String startTime = DateTimeUtil.dateTimeToString(localDateTime1); return query.selectFirePointBetweenThree(startTime, endTime); } + + /** + * 查询近一个月的火点信息 + * @return + */ + @Override + public List selectFirePointByMonth() { + LocalDateTime localDateTime = LocalDateTime.now(); + String endTime = DateTimeUtil.dateTimeToString(localDateTime); + // 当前时间减7 + LocalDateTime localDateTime1 = localDateTime.minusDays(30); + String startTime = DateTimeUtil.dateTimeToString(localDateTime1); + return query.selectFirePointByMonth(startTime,endTime); + } } diff --git a/src/main/java/com/xkrs/utils/Query.java b/src/main/java/com/xkrs/utils/Query.java index ec382e7..486b26b 100644 --- a/src/main/java/com/xkrs/utils/Query.java +++ b/src/main/java/com/xkrs/utils/Query.java @@ -80,5 +80,29 @@ public class Query { return firePointDao.findAll(specification); } + /** + * 查询近一个月的火点 + * @param startTime + * @param endTime + * @return + */ + public List selectFirePointByMonth(String startTime,String endTime) { + Specification specification = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List list = new ArrayList<>(); + if(startTime != null && !"".equals(startTime)){ + list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("addTime").as(String.class), startTime)); + } + if(endTime != null && !"".equals(endTime)){ + list.add(criteriaBuilder.lessThanOrEqualTo(root.get("addTime").as(String.class), endTime)); + } + Predicate[] predicates = new Predicate[list.size()]; + return criteriaBuilder.and(list.toArray(predicates)); + } + }; + return firePointDao.findAll(specification); + } + } \ No newline at end of file