修改 动态多条件查询火点信息
This commit is contained in:
parent
d3ab960893
commit
4dc916fd88
@ -122,10 +122,8 @@ public class FirePointController {
|
||||
// 验证token
|
||||
String tokenUserName = TokenUtil.getTokenUserName(token);
|
||||
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
|
||||
// 查询省
|
||||
if (9 == sysUserEntity.getCountyCode().length()) {
|
||||
// 查询县
|
||||
List<FirePointEntity> firePointEntities = firePointService.selectFirePointByCounty(sysUserEntity.getCountyCode(), satelliteType, landType, startTime, endTime);
|
||||
if (9 == sysUserEntity.getCountyCode().length()) {// 查询县
|
||||
List<FirePointEntity> firePointEntities = firePointService.selectFirePointByStreet(sysUserEntity.getCountyCode(), satelliteType, landType, startTime, endTime);
|
||||
if (firePointEntities == null || firePointEntities.size() == 0) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSp
|
||||
|
||||
/**
|
||||
* 查询今天的火点信息
|
||||
*
|
||||
* @param addTime
|
||||
* @param address
|
||||
* @return
|
||||
@ -27,6 +28,7 @@ public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSp
|
||||
|
||||
/**
|
||||
* 查询山东省今天火点信息
|
||||
*
|
||||
* @param addTime
|
||||
* @param address
|
||||
* @return
|
||||
@ -36,6 +38,7 @@ public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSp
|
||||
|
||||
/**
|
||||
* 区县条件查询今天火点信息
|
||||
*
|
||||
* @param addTime
|
||||
* @param countyCode
|
||||
* @return
|
||||
@ -43,8 +46,20 @@ public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSp
|
||||
@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);
|
||||
|
||||
/**
|
||||
* 街道条件查询今天火点信息
|
||||
*
|
||||
* @param addTime
|
||||
* @param streetCode
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and street_code = :streetCode", nativeQuery = true)
|
||||
List<FirePointEntity> selectTodayFirePointOneStreet(String addTime, String streetCode);
|
||||
|
||||
|
||||
/**
|
||||
* 查询山东省县的今天火点信息
|
||||
*
|
||||
* @param addTime
|
||||
* @param countyCode
|
||||
* @return
|
||||
@ -54,6 +69,7 @@ public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSp
|
||||
|
||||
/**
|
||||
* 根据火点编码查询火点信息
|
||||
*
|
||||
* @param fireCode
|
||||
* @return
|
||||
*/
|
||||
@ -61,6 +77,7 @@ public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSp
|
||||
|
||||
/**
|
||||
* 根据火点编码修改火点状态
|
||||
*
|
||||
* @param fireCode
|
||||
* @param fireType
|
||||
*/
|
||||
@ -70,28 +87,27 @@ public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSp
|
||||
|
||||
/**
|
||||
* 查询时间段内各植被类型的火点数量
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select la.land_name landname,count(fp.id) as num from land la left join fire_point fp " +
|
||||
"on fp.land_type = la.land_name AND fp.add_time BETWEEN ?1 AND ?2 " +
|
||||
"group by la.land_name",nativeQuery = true)
|
||||
@Query(value = "select la.land_name landname,count(fp.id) as num from land la left join fire_point fp " + "on fp.land_type = la.land_name AND fp.add_time BETWEEN ?1 AND ?2 " + "group by la.land_name", nativeQuery = true)
|
||||
List<Map<String, Object>> selectNumByLandType(String startTime, String endTime);
|
||||
|
||||
/**
|
||||
* 查询时间段内各地区的火点数量
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select ci.city_name cityname,count(fp.id) from city ci left join fire_point fp " +
|
||||
"on fp.county_code like concat('%',ci.city_code,'%') AND fp.add_time BETWEEN ?1 AND ?2 " +
|
||||
"group by ci.city_name",nativeQuery = true)
|
||||
@Query(value = "select ci.city_name cityname,count(fp.id) from city ci left join fire_point fp " + "on fp.county_code like concat('%',ci.city_code,'%') AND fp.add_time BETWEEN ?1 AND ?2 " + "group by ci.city_name", nativeQuery = true)
|
||||
List<Map<String, Object>> selectNumByArea(String startTime, String endTime);
|
||||
|
||||
/**
|
||||
* 查询水体类型的id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id from fire_point where land_type = '水体'", nativeQuery = true)
|
||||
@ -99,6 +115,7 @@ public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSp
|
||||
|
||||
/**
|
||||
* 批量删除水体
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@Modifying(clearAutomatically = true)
|
||||
@ -106,6 +123,7 @@ public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSp
|
||||
|
||||
/**
|
||||
* 查询北京的火点
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from fire_point fp where fp.fire_point_address like concat('%','北京市','%') and fp.add_time BETWEEN '2021-10-19' AND '2021-11-20'", nativeQuery = true)
|
||||
@ -113,6 +131,7 @@ public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSp
|
||||
|
||||
/**
|
||||
* 根据火点编码,修改火点前后图片路径
|
||||
*
|
||||
* @param fireCode
|
||||
* @param beforeFireImage
|
||||
* @param afterFireImage
|
||||
|
@ -70,6 +70,19 @@ public interface FirePointService {
|
||||
*/
|
||||
List<FirePointEntity> selectFirePointByCounty(String cityCode, String satelliteType, String landType, String startTime, String endTime);
|
||||
|
||||
/**
|
||||
* 动态多条件查询火点信息(街道)
|
||||
*
|
||||
* @param streetCode
|
||||
* @param satelliteType
|
||||
* @param landType
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
List<FirePointEntity> selectFirePointByStreet(String streetCode, String satelliteType, String landType, String startTime, String endTime);
|
||||
|
||||
|
||||
/**
|
||||
* 根据火点编码修改火点的状态(预警)
|
||||
*
|
||||
|
@ -155,9 +155,7 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
public List<FirePointEntity> selectTodayFirePoint(String countyCode) {
|
||||
String addTime = DateTimeUtil.dateToString(LocalDate.now());
|
||||
if (9 == countyCode.length()) {
|
||||
List<StreetEntity> byStreetCode = streetDao.findByStreetCode(countyCode);
|
||||
String streetName = byStreetCode.get(0).getStreetName();
|
||||
return firePointDao.selectTodayFirePoint(addTime, streetName);
|
||||
return firePointDao.selectTodayFirePointOneStreet(addTime, countyCode);
|
||||
} else if ("0000".equals(countyCode.substring(2))) {
|
||||
List<CityEntity> byProCode = cityDao.findByProCode(countyCode);
|
||||
String proName = byProCode.get(0).getProName();
|
||||
@ -245,6 +243,18 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
return query.selectFirePointByCounty(cityCode, satelliteType, landType, startTime, endTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FirePointEntity> selectFirePointByStreet(String streetCode, String satelliteType, String landType, String startTime, String endTime) {
|
||||
if (!"".equals(startTime) && !"".equals(endTime)) {
|
||||
LocalDate localDate = DateTimeUtil.stringToDate(endTime);
|
||||
// 结束时间
|
||||
LocalDate localDate1 = localDate.plusDays(1);
|
||||
String dateToString = DateTimeUtil.dateToString(localDate1);
|
||||
return query.selectFirePointByStreet(streetCode, satelliteType, landType, startTime, dateToString);
|
||||
}
|
||||
return query.selectFirePointByStreet(streetCode, satelliteType, landType, startTime, endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据火点编码修改火点的状态(预警)
|
||||
*
|
||||
@ -394,7 +404,7 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
LocalDateTime localDateTime1 = localDateTime.minusDays(31);
|
||||
String startTime = DateTimeUtil.dateTimeToString(localDateTime1);
|
||||
if (9 == countyCode.length()) {
|
||||
return query.selectFirePointByMonthCounty(countyCode, startTime, endTime);
|
||||
return query.selectFirePointByMonthStreet(countyCode, startTime, endTime);
|
||||
} else if ("0000".equals(countyCode.substring(2))) {
|
||||
List<CityEntity> byProCode = cityDao.findByProCode(countyCode);
|
||||
String proName = byProCode.get(0).getProName();
|
||||
|
@ -132,6 +132,41 @@ public class Query {
|
||||
return firePointDao.findAll(specification);
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态多条件查询项目信息(街道)
|
||||
*/
|
||||
public List<FirePointEntity> selectFirePointByStreet(String streetCode, String satelliteType, String landType, String startTime, String endTime) {
|
||||
Specification<FirePointEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
|
||||
List<Predicate> list = new ArrayList<>();
|
||||
if (streetCode != null && !"".equals(streetCode)) {
|
||||
list.add(criteriaBuilder.equal(root.get("streetCode").as(String.class), streetCode));
|
||||
}
|
||||
if (satelliteType != null && !"".equals(satelliteType)) {
|
||||
list.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType));
|
||||
}
|
||||
if (landType != null && !"".equals(landType)) {
|
||||
list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
|
||||
}
|
||||
if (startTime != null && !"".equals(startTime)) {
|
||||
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
|
||||
}
|
||||
LocalDateTime localDateTime = LocalDateTime.now();
|
||||
LocalDateTime localDateTime2 = localDateTime.plusDays(1);
|
||||
String endTimes = DateTimeUtil.dateTimeToString(localDateTime2);
|
||||
// 当前时间减30
|
||||
LocalDateTime localDateTime1 = localDateTime.minusDays(30);
|
||||
String startTimes = DateTimeUtil.dateTimeToString(localDateTime1);
|
||||
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTimes));
|
||||
if (endTime != null && !"".equals(endTime)) {
|
||||
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
|
||||
}
|
||||
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTimes));
|
||||
Predicate[] predicates = new Predicate[list.size()];
|
||||
return criteriaBuilder.and(list.toArray(predicates));
|
||||
};
|
||||
return firePointDao.findAll(specification);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询近一周的火点
|
||||
*/
|
||||
@ -213,5 +248,26 @@ public class Query {
|
||||
return firePointDao.findAll(specification);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询近一个月的火点信息(街道)
|
||||
*/
|
||||
public List<FirePointEntity> selectFirePointByMonthStreet(String streetCode, String startTime, String endTime) {
|
||||
Specification<FirePointEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
|
||||
List<Predicate> list = new ArrayList<>();
|
||||
if (streetCode != null && !"".equals(streetCode)) {
|
||||
list.add(criteriaBuilder.like(root.get("streetCode").as(String.class), streetCode));
|
||||
}
|
||||
if (startTime != null && !"".equals(startTime)) {
|
||||
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
|
||||
}
|
||||
if (endTime != null && !"".equals(endTime)) {
|
||||
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").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