diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java index 1450895..bd4b072 100644 --- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -44,6 +44,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers(HttpMethod.POST,"/insertFirePoint").permitAll() .antMatchers(HttpMethod.POST,"/insertAppTask").permitAll() .antMatchers(HttpMethod.GET,"/selectAppTask").permitAll() + .antMatchers(HttpMethod.GET,"/selectFirePointBetweenSeven").permitAll() // 所有其它请求需要身份认证 .anyRequest().authenticated() .and() diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index e4d6ebc..49c7113 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -159,4 +159,19 @@ public class FirePointController { public String selectAppTask(@RequestParam("fireCode") String fireCode) throws Exception { return firePointService.selectAppTask(fireCode); } + + /** + * 查询近一周的火点信息 + * @return + */ + @GetMapping("/selectFirePointBetweenSeven") + public String selectFirePointBetweenSeven(){ + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + List firePointEntities = firePointService.selectFirePointBetweenSeven(); + if(firePointEntities == null || firePointEntities.size() == 0){ + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时没有火点数据",locale); + } + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,firePointEntities,locale); + } } diff --git a/src/main/java/com/xkrs/service/FirePointService.java b/src/main/java/com/xkrs/service/FirePointService.java index 79c7289..f990db2 100644 --- a/src/main/java/com/xkrs/service/FirePointService.java +++ b/src/main/java/com/xkrs/service/FirePointService.java @@ -65,4 +65,10 @@ public interface FirePointService { * @throws Exception */ String selectAppTask(String fireCode) throws Exception; + + /** + * 查询近一周天的火点信息 + * @return + */ + List selectFirePointBetweenSeven(); } diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 611f5a0..7ea556a 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -223,4 +223,19 @@ public class FirePointServiceImpl implements FirePointService { return outputEncapsulationObject(PromptMessageEnum.SUCCESS,appTaskBodyVo,locale); } + + /** + * 查询近一周的火点信息 + * @return + */ + @Override + public List selectFirePointBetweenSeven() { + LocalDateTime localDateTime = LocalDateTime.now(); + String endTime = DateTimeUtil.dateTimeToString(localDateTime); + + // 当前时间减7 + LocalDateTime localDateTime1 = localDateTime.minusDays(7); + String startTime = DateTimeUtil.dateTimeToString(localDateTime1); + return query.selectFirePointBetweenThree(startTime, endTime); + } } diff --git a/src/main/java/com/xkrs/utils/Query.java b/src/main/java/com/xkrs/utils/Query.java index 3fd550f..032aa3c 100644 --- a/src/main/java/com/xkrs/utils/Query.java +++ b/src/main/java/com/xkrs/utils/Query.java @@ -56,5 +56,29 @@ public class Query { return firePointDao.findAll(specification); } + /** + * 查询近3天的火点 + * @param startTime + * @param endTime + * @return + */ + public List selectFirePointBetweenThree(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