添加了查询近一周火点信息的接口
This commit is contained in:
parent
853aa0b81f
commit
f6d5dfda34
@ -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()
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -65,4 +65,10 @@ public interface FirePointService {
|
||||
* @throws Exception
|
||||
*/
|
||||
String selectAppTask(String fireCode) throws Exception;
|
||||
|
||||
/**
|
||||
* 查询近一周天的火点信息
|
||||
* @return
|
||||
*/
|
||||
List<FirePointEntity> selectFirePointBetweenSeven();
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user