修改了查询今天的火点信息,分为省市区三级查询

This commit is contained in:
DESKTOP-G8BCEP0\HP 2021-08-02 14:56:25 +08:00
parent fec2659d46
commit 52fe47e483
4 changed files with 22 additions and 7 deletions

View File

@ -86,10 +86,10 @@ public class FirePointController {
*/ */
@GetMapping("/selectTodayFirePoint") @GetMapping("/selectTodayFirePoint")
@PreAuthorize("hasAnyAuthority('auth_general_user')") @PreAuthorize("hasAnyAuthority('auth_general_user')")
public String selectTodayFirePoint(@RequestHeader(value="Authorization") String token){ public String selectTodayFirePoint(@RequestParam("countyCode") String countyCode,@RequestHeader(value="Authorization") String token){
// 获取区域信息 // 获取区域信息
Locale locale = LocaleContextHolder.getLocale(); Locale locale = LocaleContextHolder.getLocale();
List<FirePointEntity> firePointEntities = firePointService.selectTodayFirePoint(); List<FirePointEntity> firePointEntities = firePointService.selectTodayFirePoint(countyCode);
if(firePointEntities == null || firePointEntities.size() == 0){ if(firePointEntities == null || firePointEntities.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale); return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale);
} }

View File

@ -19,10 +19,20 @@ public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSp
/** /**
* 查询今天的火点信息 * 查询今天的火点信息
* @param addTime * @param addTime
* @param countyCode
* @return * @return
*/ */
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%')",nativeQuery = true) @Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and county_code like CONCAT('%',:countyCode,'%')",nativeQuery = true)
List<FirePointEntity> selectTodayFirePoint(String addTime); List<FirePointEntity> selectTodayFirePoint(String addTime,String countyCode);
/**
* 区县条件查询今天火点信息
* @param addTime
* @param countyCode
* @return
*/
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and county_code = :countyCode",nativeQuery = true)
List<FirePointEntity> selectTodayFirePointOne(String addTime,String countyCode);
/** /**
* 根据火点编码查询火点信息 * 根据火点编码查询火点信息

View File

@ -27,7 +27,7 @@ public interface FirePointService {
* @param * @param
* @return * @return
*/ */
List<FirePointEntity> selectTodayFirePoint(); List<FirePointEntity> selectTodayFirePoint(String countyCode);
/** /**
* 动态多条件查询火点信息() * 动态多条件查询火点信息()

View File

@ -110,9 +110,14 @@ public class FirePointServiceImpl implements FirePointService {
* @return * @return
*/ */
@Override @Override
public List<FirePointEntity> selectTodayFirePoint() { public List<FirePointEntity> selectTodayFirePoint(String countyCode) {
String addTime = DateTimeUtil.dateToString(LocalDate.now()); String addTime = DateTimeUtil.dateToString(LocalDate.now());
return firePointDao.selectTodayFirePoint(addTime); if(countyCode.substring(2).equals("0000")){
return firePointDao.selectTodayFirePoint(addTime,countyCode.substring(0,2));
}else if(countyCode.substring(4).equals("00") && !countyCode.substring(2).equals("0000")){
return firePointDao.selectTodayFirePoint(addTime,countyCode.substring(0,4));
}
return firePointDao.selectTodayFirePointOne(addTime,countyCode);
} }
/** /**