添加了查询近一周火点信息的接口

This commit is contained in:
DESKTOP-4U0TDEF\20371 2021-07-16 17:21:31 +08:00
parent 853aa0b81f
commit f6d5dfda34
5 changed files with 61 additions and 0 deletions

View File

@ -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()

View File

@ -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<FirePointEntity> firePointEntities = firePointService.selectFirePointBetweenSeven();
if(firePointEntities == null || firePointEntities.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时没有火点数据",locale);
}
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,firePointEntities,locale);
}
}

View File

@ -65,4 +65,10 @@ public interface FirePointService {
* @throws Exception
*/
String selectAppTask(String fireCode) throws Exception;
/**
* 查询近一周天的火点信息
* @return
*/
List<FirePointEntity> selectFirePointBetweenSeven();
}

View File

@ -223,4 +223,19 @@ public class FirePointServiceImpl implements FirePointService {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,appTaskBodyVo,locale);
}
/**
* 查询近一周的火点信息
* @return
*/
@Override
public List<FirePointEntity> 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);
}
}

View File

@ -56,5 +56,29 @@ public class Query {
return firePointDao.findAll(specification);
}
/**
* 查询近3天的火点
* @param startTime
* @param endTime
* @return
*/
public List<FirePointEntity> selectFirePointBetweenThree(String startTime,String endTime) {
Specification<FirePointEntity> specification = new Specification<FirePointEntity>() {
@Override
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
List<Predicate> 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);
}
}