修改 动态多条件查询火点信息
This commit is contained in:
parent
d3ab960893
commit
4dc916fd88
@ -122,10 +122,8 @@ public class FirePointController {
|
|||||||
// 验证token
|
// 验证token
|
||||||
String tokenUserName = TokenUtil.getTokenUserName(token);
|
String tokenUserName = TokenUtil.getTokenUserName(token);
|
||||||
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
|
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
|
||||||
// 查询省
|
if (9 == sysUserEntity.getCountyCode().length()) {// 查询县
|
||||||
if (9 == sysUserEntity.getCountyCode().length()) {
|
List<FirePointEntity> firePointEntities = firePointService.selectFirePointByStreet(sysUserEntity.getCountyCode(), satelliteType, landType, startTime, endTime);
|
||||||
// 查询县
|
|
||||||
List<FirePointEntity> firePointEntities = firePointService.selectFirePointByCounty(sysUserEntity.getCountyCode(), satelliteType, landType, startTime, endTime);
|
|
||||||
if (firePointEntities == null || firePointEntities.size() == 0) {
|
if (firePointEntities == null || firePointEntities.size() == 0) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale);
|
||||||
}
|
}
|
||||||
|
@ -14,46 +14,62 @@ import java.util.Map;
|
|||||||
* @author XinYi Song
|
* @author XinYi Song
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSpecificationExecutor<FirePointEntity> {
|
public interface FirePointDao extends JpaRepository<FirePointEntity, Long>, JpaSpecificationExecutor<FirePointEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询今天的火点信息
|
* 查询今天的火点信息
|
||||||
|
*
|
||||||
* @param addTime
|
* @param addTime
|
||||||
* @param address
|
* @param address
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and fire_point_address like CONCAT('%',:address,'%')",nativeQuery = true)
|
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and fire_point_address like CONCAT('%',:address,'%')", nativeQuery = true)
|
||||||
List<FirePointEntity> selectTodayFirePoint(String addTime,String address);
|
List<FirePointEntity> selectTodayFirePoint(String addTime, String address);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*查询山东省今天火点信息
|
* 查询山东省今天火点信息
|
||||||
|
*
|
||||||
* @param addTime
|
* @param addTime
|
||||||
* @param address
|
* @param address
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and fire_point_address like CONCAT('%',:address,'%') and land_type != '耕地'",nativeQuery = true)
|
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and fire_point_address like CONCAT('%',:address,'%') and land_type != '耕地'", nativeQuery = true)
|
||||||
List<FirePointEntity> selectTodayFirePointShandong(String addTime,String address);
|
List<FirePointEntity> selectTodayFirePointShandong(String addTime, String address);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 区县条件查询今天火点信息
|
* 区县条件查询今天火点信息
|
||||||
|
*
|
||||||
* @param addTime
|
* @param addTime
|
||||||
* @param countyCode
|
* @param countyCode
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and county_code = :countyCode",nativeQuery = true)
|
@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);
|
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 addTime
|
||||||
* @param countyCode
|
* @param countyCode
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and county_code = :countyCode and land_type != '耕地'",nativeQuery = true)
|
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and county_code = :countyCode and land_type != '耕地'", nativeQuery = true)
|
||||||
List<FirePointEntity> selectTodayFirePointOneShandong(String addTime,String countyCode);
|
List<FirePointEntity> selectTodayFirePointOneShandong(String addTime, String countyCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据火点编码查询火点信息
|
* 根据火点编码查询火点信息
|
||||||
|
*
|
||||||
* @param fireCode
|
* @param fireCode
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -61,63 +77,66 @@ public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSp
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据火点编码修改火点状态
|
* 根据火点编码修改火点状态
|
||||||
|
*
|
||||||
* @param fireCode
|
* @param fireCode
|
||||||
* @param fireType
|
* @param fireType
|
||||||
*/
|
*/
|
||||||
@Modifying(clearAutomatically=true)
|
@Modifying(clearAutomatically = true)
|
||||||
@Query(value = "update fire_point set fire_type = ?2 where fire_code = ?1",nativeQuery = true)
|
@Query(value = "update fire_point set fire_type = ?2 where fire_code = ?1", nativeQuery = true)
|
||||||
void updateFireTypeByFireCode(String fireCode,String fireType);
|
void updateFireTypeByFireCode(String fireCode, String fireType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询时间段内各植被类型的火点数量
|
* 查询时间段内各植被类型的火点数量
|
||||||
|
*
|
||||||
* @param startTime
|
* @param startTime
|
||||||
* @param endTime
|
* @param endTime
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Query(value = "select la.land_name landname,count(fp.id) as num from land la left join fire_point fp " +
|
@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)
|
||||||
"on fp.land_type = la.land_name AND fp.add_time BETWEEN ?1 AND ?2 " +
|
List<Map<String, Object>> selectNumByLandType(String startTime, String endTime);
|
||||||
"group by la.land_name",nativeQuery = true)
|
|
||||||
List<Map<String,Object>> selectNumByLandType(String startTime,String endTime);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询时间段内各地区的火点数量
|
* 查询时间段内各地区的火点数量
|
||||||
|
*
|
||||||
* @param startTime
|
* @param startTime
|
||||||
* @param endTime
|
* @param endTime
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Query(value = "select ci.city_name cityname,count(fp.id) from city ci left join fire_point fp " +
|
@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)
|
||||||
"on fp.county_code like concat('%',ci.city_code,'%') AND fp.add_time BETWEEN ?1 AND ?2 " +
|
List<Map<String, Object>> selectNumByArea(String startTime, String endTime);
|
||||||
"group by ci.city_name",nativeQuery = true)
|
|
||||||
List<Map<String,Object>> selectNumByArea(String startTime,String endTime);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询水体类型的id
|
* 查询水体类型的id
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Query(value = "select id from fire_point where land_type = '水体'",nativeQuery = true)
|
@Query(value = "select id from fire_point where land_type = '水体'", nativeQuery = true)
|
||||||
List<Integer> selectId();
|
List<Integer> selectId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除水体
|
* 批量删除水体
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
@Modifying(clearAutomatically=true)
|
@Modifying(clearAutomatically = true)
|
||||||
void deleteByIdIn(List<Integer> id);
|
void deleteByIdIn(List<Integer> id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询北京的火点
|
* 查询北京的火点
|
||||||
|
*
|
||||||
* @return
|
* @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)
|
@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)
|
||||||
List<FirePointEntity> selectBeijing();
|
List<FirePointEntity> selectBeijing();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据火点编码,修改火点前后图片路径
|
* 根据火点编码,修改火点前后图片路径
|
||||||
|
*
|
||||||
* @param fireCode
|
* @param fireCode
|
||||||
* @param beforeFireImage
|
* @param beforeFireImage
|
||||||
* @param afterFireImage
|
* @param afterFireImage
|
||||||
*/
|
*/
|
||||||
@Modifying(clearAutomatically=true)
|
@Modifying(clearAutomatically = true)
|
||||||
@Query(value = "update fire_point set before_fire_image = ?2,after_fire_image = ?3 where fire_code = ?1",nativeQuery = true)
|
@Query(value = "update fire_point set before_fire_image = ?2,after_fire_image = ?3 where fire_code = ?1", nativeQuery = true)
|
||||||
void updateBeforeFireAndAfterFireImage(String fireCode, String beforeFireImage, String afterFireImage);
|
void updateBeforeFireAndAfterFireImage(String fireCode, String beforeFireImage, String afterFireImage);
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,19 @@ public interface FirePointService {
|
|||||||
*/
|
*/
|
||||||
List<FirePointEntity> selectFirePointByCounty(String cityCode, String satelliteType, String landType, String startTime, String endTime);
|
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) {
|
public List<FirePointEntity> selectTodayFirePoint(String countyCode) {
|
||||||
String addTime = DateTimeUtil.dateToString(LocalDate.now());
|
String addTime = DateTimeUtil.dateToString(LocalDate.now());
|
||||||
if (9 == countyCode.length()) {
|
if (9 == countyCode.length()) {
|
||||||
List<StreetEntity> byStreetCode = streetDao.findByStreetCode(countyCode);
|
return firePointDao.selectTodayFirePointOneStreet(addTime, countyCode);
|
||||||
String streetName = byStreetCode.get(0).getStreetName();
|
|
||||||
return firePointDao.selectTodayFirePoint(addTime, streetName);
|
|
||||||
} else if ("0000".equals(countyCode.substring(2))) {
|
} else if ("0000".equals(countyCode.substring(2))) {
|
||||||
List<CityEntity> byProCode = cityDao.findByProCode(countyCode);
|
List<CityEntity> byProCode = cityDao.findByProCode(countyCode);
|
||||||
String proName = byProCode.get(0).getProName();
|
String proName = byProCode.get(0).getProName();
|
||||||
@ -245,6 +243,18 @@ public class FirePointServiceImpl implements FirePointService {
|
|||||||
return query.selectFirePointByCounty(cityCode, satelliteType, landType, startTime, endTime);
|
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);
|
LocalDateTime localDateTime1 = localDateTime.minusDays(31);
|
||||||
String startTime = DateTimeUtil.dateTimeToString(localDateTime1);
|
String startTime = DateTimeUtil.dateTimeToString(localDateTime1);
|
||||||
if (9 == countyCode.length()) {
|
if (9 == countyCode.length()) {
|
||||||
return query.selectFirePointByMonthCounty(countyCode, startTime, endTime);
|
return query.selectFirePointByMonthStreet(countyCode, startTime, endTime);
|
||||||
} else if ("0000".equals(countyCode.substring(2))) {
|
} else if ("0000".equals(countyCode.substring(2))) {
|
||||||
List<CityEntity> byProCode = cityDao.findByProCode(countyCode);
|
List<CityEntity> byProCode = cityDao.findByProCode(countyCode);
|
||||||
String proName = byProCode.get(0).getProName();
|
String proName = byProCode.get(0).getProName();
|
||||||
|
@ -132,6 +132,41 @@ public class Query {
|
|||||||
return firePointDao.findAll(specification);
|
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);
|
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