1、修改了动态多条件查询功能模块,当山东省查询时,查询不包括耕地的火点信息。

2、修改了查询近一个月火点信息的功能模块。当查询山东省火点信息时,查询不包括耕地类型的火点信息。
This commit is contained in:
XinYi Song 2021-12-07 08:32:55 +08:00
parent 81725702d9
commit b8d8dee1b1
5 changed files with 91 additions and 14 deletions

View File

@ -50,7 +50,7 @@ public interface CityDao extends JpaRepository<CityEntity,Long>, JpaSpecificatio
* @param cityName
* @return
*/
List<CityEntity> findByCityName(String cityName);
//List<CityEntity> findByCityName(String cityName);
/**
* 根据省名称查询信息
@ -58,4 +58,11 @@ public interface CityDao extends JpaRepository<CityEntity,Long>, JpaSpecificatio
* @return
*/
List<CityEntity> findByProName(String proName);
/**
* 根据市名查询信息
* @param cityName
* @return
*/
CityEntity findByCityName(String cityName);
}

View File

@ -25,6 +25,15 @@ public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSp
@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);
/**
*查询山东省今天火点信息
* @param addTime
* @param address
* @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)
List<FirePointEntity> selectTodayFirePointShandong(String addTime,String address);
/**
* 区县条件查询今天火点信息
* @param addTime
@ -34,6 +43,15 @@ 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 countyCode
* @return
*/
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and county_code = :countyCode and and land_type != '耕地'",nativeQuery = true)
List<FirePointEntity> selectTodayFirePointOneShandong(String addTime,String countyCode);
/**
* 根据火点编码查询火点信息
* @param fireCode

View File

@ -137,12 +137,24 @@ public class FirePointServiceImpl implements FirePointService {
if("0000".equals(countyCode.substring(2))){
List<CityEntity> byProCode = cityDao.findByProCode(countyCode);
String proName = byProCode.get(0).getProName();
if(proName.equals("山东省")){
return firePointDao.selectTodayFirePointShandong(addTime,proName);
}
return firePointDao.selectTodayFirePoint(addTime,proName);
}else if("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))){
List<CountyEntity> byCityCode = countyDao.findByCityCode(countyCode);
String cityName = byCityCode.get(0).getCityName();
CityEntity byCityName = cityDao.findByCityName(cityName);
if(byCityName.getProName().equals("山东省")){
return firePointDao.selectTodayFirePointShandong(addTime,cityName);
}
return firePointDao.selectTodayFirePoint(addTime,cityName);
}else {
CountyEntity byCountyCode = countyDao.findByCountyCode(countyCode);
CityEntity byCityName = cityDao.findByCityName(byCountyCode.getCityName());
if(byCityName.getProName().equals("山东省")){
return firePointDao.selectTodayFirePointOneShandong(addTime,countyCode);
}
return firePointDao.selectTodayFirePointOne(addTime,countyCode);
}
}
@ -187,14 +199,16 @@ public class FirePointServiceImpl implements FirePointService {
//List<CityEntity> byCityCode = cityDao.findByCityCode(cityCodeOne.substring(0,3));
List<CountyEntity> byCityCode = countyDao.findByCityCode(cityCodeOne);
String cityName = byCityCode.get(0).getCityName();
CityEntity byCityCode1 = cityDao.findByCityName(cityName);
String proName = byCityCode1.getProName();
if(!"".equals(startTime) && !"".equals(endTime)){
LocalDate localDate = DateTimeUtil.stringToDate(endTime);
// 结束时间
LocalDate localDate1 = localDate.plusDays(1);
String dateToString = DateTimeUtil.dateToString(localDate1);
return query.selectFirePointByCity(cityName,cityCode,satelliteType,landType,startTime,dateToString);
return query.selectFirePointByCity(proName, cityName,cityCode,satelliteType,landType,startTime,dateToString);
}
return query.selectFirePointByCity(cityName,cityCode,satelliteType,landType,startTime,endTime);
return query.selectFirePointByCity(proName, cityName,cityCode,satelliteType,landType,startTime,endTime);
}
/**
@ -210,14 +224,17 @@ public class FirePointServiceImpl implements FirePointService {
@Override
public List<FirePointEntity> selectFirePointByCounty(String cityCode, String satelliteType, String landType, String startTime, String endTime) {
CountyEntity byCountyCode = countyDao.findByCountyCode(cityCode);
CityEntity byCityCode = cityDao.findByCityName(byCountyCode.getCityName());
String proName = byCityCode.getProName();
if(!"".equals(startTime) && !"".equals(endTime)){
LocalDate localDate = DateTimeUtil.stringToDate(endTime);
// 结束时间
LocalDate localDate1 = localDate.plusDays(1);
String dateToString = DateTimeUtil.dateToString(localDate1);
return query.selectFirePointByCounty(cityCode,satelliteType,landType,startTime,dateToString);
return query.selectFirePointByCounty(proName, cityCode,satelliteType,landType,startTime,dateToString);
}
return query.selectFirePointByCounty(cityCode,satelliteType,landType,startTime,endTime);
return query.selectFirePointByCounty(proName, cityCode,satelliteType,landType,startTime,endTime);
}
/**
@ -361,7 +378,7 @@ public class FirePointServiceImpl implements FirePointService {
public List<FirePointEntity> selectFirePointByMonth(String countyCode) {
LocalDateTime localDateTime = LocalDateTime.now();
String endTime = DateTimeUtil.dateTimeToString(localDateTime);
// 当前时间减7
// 当前时间减31
LocalDateTime localDateTime1 = localDateTime.minusDays(31);
String startTime = DateTimeUtil.dateTimeToString(localDateTime1);
if("0000".equals(countyCode.substring(2))){
@ -371,9 +388,14 @@ public class FirePointServiceImpl implements FirePointService {
}else if("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))){
List<CountyEntity> byCityCode = countyDao.findByCityCode(countyCode);
String cityName = byCityCode.get(0).getCityName();
return query.selectFirePointByMonthCity(cityName,startTime,endTime);
CityEntity byCityName = cityDao.findByCityName(cityName);
String proName = byCityName.getProName();
return query.selectFirePointByMonthCity(proName, cityName,startTime,endTime);
}else {
return query.selectFirePointByMonthCounty(countyCode,startTime,endTime);
CountyEntity byCountyCode = countyDao.findByCountyCode(countyCode);
CityEntity byCityName = cityDao.findByCityName(byCountyCode.getCityName());
String proName = byCityName.getProName();
return query.selectFirePointByMonthCounty(proName, countyCode,startTime,endTime);
}
}

View File

@ -44,7 +44,14 @@ public class Query {
list.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType));
}
if (landType != null && !"".equals(landType)) {
if(address.equals("山东省")){
list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
}
list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
}else {
if(address.equals("山东省")){
list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
}
}
if(startTime != null && !"".equals(startTime)){
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
@ -72,7 +79,7 @@ public class Query {
* @param
* @return
*/
public List<FirePointEntity> selectFirePointByCity(String address, String cityCode,String satelliteType,String landType,String startTime,String endTime) {
public List<FirePointEntity> selectFirePointByCity(String proName, String address, String cityCode,String satelliteType,String landType,String startTime,String endTime) {
Specification<FirePointEntity> specification = new Specification<FirePointEntity>() {
@Override
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
@ -87,7 +94,14 @@ public class Query {
list.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType));
}
if (landType != null && !"".equals(landType)) {
if(proName.equals("山东省")){
list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
}
list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
}else {
if(proName.equals("山东省")){
list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
}
}
if(startTime != null && !"".equals(startTime)){
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
@ -115,7 +129,7 @@ public class Query {
* @param
* @return
*/
public List<FirePointEntity> selectFirePointByCounty(String cityCode,String satelliteType,String landType,String startTime,String endTime) {
public List<FirePointEntity> selectFirePointByCounty(String proName, String cityCode,String satelliteType,String landType,String startTime,String endTime) {
Specification<FirePointEntity> specification = new Specification<FirePointEntity>() {
@Override
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
@ -127,7 +141,14 @@ public class Query {
list.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType));
}
if (landType != null && !"".equals(landType)) {
if(proName.equals("山东省")){
list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
}
list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
}else {
if(proName.equals("山东省")){
list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
}
}
if(startTime != null && !"".equals(startTime)){
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
@ -194,6 +215,9 @@ public class Query {
if(endTime != null && !"".equals(endTime)){
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
}
if(address.equals("山东省")){
list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
}
Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates));
}
@ -208,7 +232,7 @@ public class Query {
* @param endTime
* @return
*/
public List<FirePointEntity> selectFirePointByMonthCity(String address,String startTime,String endTime) {
public List<FirePointEntity> selectFirePointByMonthCity(String proName, String address,String startTime,String endTime) {
Specification<FirePointEntity> specification = new Specification<FirePointEntity>() {
@Override
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
@ -222,6 +246,9 @@ public class Query {
if(endTime != null && !"".equals(endTime)){
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
}
if(proName.equals("山东省")){
list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
}
Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates));
}
@ -236,7 +263,7 @@ public class Query {
* @param endTime
* @return
*/
public List<FirePointEntity> selectFirePointByMonthCounty(String countyCode,String startTime,String endTime) {
public List<FirePointEntity> selectFirePointByMonthCounty(String proName, String countyCode,String startTime,String endTime) {
Specification<FirePointEntity> specification = new Specification<FirePointEntity>() {
@Override
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
@ -250,6 +277,9 @@ public class Query {
if(endTime != null && !"".equals(endTime)){
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
}
if(proName.equals("山东省")){
list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
}
Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates));
}

View File

@ -35,10 +35,10 @@ spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
## Redis配置 12
spring.cache.type = redis
spring.redis.database = 8
spring.redis.database = 12
spring.redis.host = localhost
spring.redis.port = 6379
#spring.redis.password=sdust2020
spring.redis.password=sdust2020
spring.redis.timeout = 10000
spring.redis.lettuce.pool.max-active = 100
spring.redis.lettuce.pool.max-wait = 10000