1、修改了用户注册功能模块

2、修改火点动态多条件查询功能模块,修改默认查询一个月火点信息
This commit is contained in:
XinYi Song 2021-12-01 14:13:05 +08:00
parent 2129b3d3fd
commit 5b02a11b0e
10 changed files with 99 additions and 23 deletions

View File

@ -60,6 +60,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers(HttpMethod.POST,"/insertFireTest").permitAll() .antMatchers(HttpMethod.POST,"/insertFireTest").permitAll()
.antMatchers(HttpMethod.POST,"/importCityExcel").permitAll() .antMatchers(HttpMethod.POST,"/importCityExcel").permitAll()
.antMatchers(HttpMethod.POST,"/deleteShuiTi").permitAll() .antMatchers(HttpMethod.POST,"/deleteShuiTi").permitAll()
.antMatchers(HttpMethod.GET,"/selectBeijing").permitAll()
// 所有其它请求需要身份认证 // 所有其它请求需要身份认证
.anyRequest().authenticated() .anyRequest().authenticated()
.and() .and()

View File

@ -339,4 +339,12 @@ public class FirePointController {
firePointDao.deleteByIdIn(integers); firePointDao.deleteByIdIn(integers);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"删除成功",locale); return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"删除成功",locale);
} }
@GetMapping("/selectBeijing")
public String selectBeijing(){
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
List<FirePointEntity> firePointEntities = firePointDao.selectBeijing();
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
}
} }

View File

@ -36,7 +36,7 @@ public interface CityDao extends JpaRepository<CityEntity,Long>, JpaSpecificatio
* @param cityCode * @param cityCode
* @return * @return
*/ */
List<CityEntity> findByCityCode(String cityCode); CityEntity findByCityCode(String cityCode);
/** /**
* 根据省编码查询信息 * 根据省编码查询信息

View File

@ -28,6 +28,8 @@ public interface CountyDao extends JpaRepository<CountyEntity,Long> {
*/ */
List<CountyEntity> findByCityCode(String cityCode); List<CountyEntity> findByCityCode(String cityCode);
List<CountyEntity> findByCityName(String cityName);
/** /**
* 根据countyCode查询信息 * 根据countyCode查询信息
* @param countyCode * @param countyCode

View File

@ -85,4 +85,11 @@ public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSp
*/ */
@Modifying(clearAutomatically=true) @Modifying(clearAutomatically=true)
void deleteByIdIn(List<Integer> id); void deleteByIdIn(List<Integer> id);
/**
* 查询北京的火点
* @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)
List<FirePointEntity> selectBeijing();
} }

View File

@ -11,6 +11,9 @@ import com.xkrs.service.FirePointService;
import com.xkrs.utils.*; import com.xkrs.utils.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cglib.beans.BeanCopier; import org.springframework.cglib.beans.BeanCopier;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -29,6 +32,7 @@ import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulat
/** /**
* @author XinYi Song * @author XinYi Song
*/ */
@CacheConfig(cacheNames = "FirePointServiceCache")
@Service @Service
public class FirePointServiceImpl implements FirePointService { public class FirePointServiceImpl implements FirePointService {
@ -75,11 +79,16 @@ public class FirePointServiceImpl implements FirePointService {
* @param firePointQo * @param firePointQo
* @return * @return
*/ */
@CacheEvict(value = "FirePointServiceCache",allEntries = true)
@Override @Override
public FirePointEntity insertFirePoint(FirePointQo firePointQo) { public FirePointEntity insertFirePoint(FirePointQo firePointQo) {
FirePointEntity firePointEntity = new FirePointEntity(); FirePointEntity firePointEntity = new FirePointEntity();
if(firePointQo.getLandtype().equals("水体")){ if(firePointQo.getLandtype().equals("水体")){
return null; return null;
}else if("Himawari 8".equals(firePointQo.getSatelliteType()) && "L".equals(firePointQo.getConfidence())){
return null;
}else if("Himawari 8".equals(firePointQo.getSatelliteType()) && "N".equals(firePointQo.getConfidence())){
return null;
}else { }else {
firePointEntity.setFireCode(firePointQo.getFireCode()); firePointEntity.setFireCode(firePointQo.getFireCode());
firePointEntity.setCountyCode(firePointQo.getCountyCode().toString()); firePointEntity.setCountyCode(firePointQo.getCountyCode().toString());
@ -121,6 +130,7 @@ public class FirePointServiceImpl implements FirePointService {
* @param * @param
* @return * @return
*/ */
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
@Override @Override
public List<FirePointEntity> selectTodayFirePoint(String countyCode) { public List<FirePointEntity> selectTodayFirePoint(String countyCode) {
String addTime = DateTimeUtil.dateToString(LocalDate.now()); String addTime = DateTimeUtil.dateToString(LocalDate.now());
@ -146,11 +156,16 @@ public class FirePointServiceImpl implements FirePointService {
* @param endTime * @param endTime
* @return * @return
*/ */
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
@Override @Override
public List<FirePointEntity> selectFirePoint(String proCode,String cityCode, String satelliteType, String landType, String startTime, String endTime) { public List<FirePointEntity> selectFirePoint(String proCode,String cityCode, String satelliteType, String landType, String startTime, String endTime) {
List<CityEntity> byProCode = cityDao.findByProCode(proCode); List<CityEntity> byProCode = cityDao.findByProCode(proCode);
String proName = byProCode.get(0).getProName(); String proName = byProCode.get(0).getProName();
return query.selectFirePointByPro(proName,cityCode, satelliteType, landType, startTime, endTime); LocalDate localDate = DateTimeUtil.stringToDate(endTime);
// 结束时间
LocalDate localDate1 = localDate.plusDays(1);
String dateToString = DateTimeUtil.dateToString(localDate1);
return query.selectFirePointByPro(proName,cityCode, satelliteType, landType, startTime, dateToString);
} }
/** /**
@ -163,12 +178,17 @@ public class FirePointServiceImpl implements FirePointService {
* @param endTime * @param endTime
* @return * @return
*/ */
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
@Override @Override
public List<FirePointEntity> selectFirePointByCity(String cityCodeOne, String cityCode, String satelliteType, String landType, String startTime, String endTime) { public List<FirePointEntity> selectFirePointByCity(String cityCodeOne, String cityCode, String satelliteType, String landType, String startTime, String endTime) {
//List<CityEntity> byCityCode = cityDao.findByCityCode(cityCodeOne.substring(0,3)); //List<CityEntity> byCityCode = cityDao.findByCityCode(cityCodeOne.substring(0,3));
List<CountyEntity> byCityCode = countyDao.findByCityCode(cityCodeOne); List<CountyEntity> byCityCode = countyDao.findByCityCode(cityCodeOne);
String cityName = byCityCode.get(0).getCityName(); String cityName = byCityCode.get(0).getCityName();
return query.selectFirePointByCity(cityName,cityCode,satelliteType,landType,startTime,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);
} }
/** /**
@ -180,9 +200,14 @@ public class FirePointServiceImpl implements FirePointService {
* @param endTime * @param endTime
* @return * @return
*/ */
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
@Override @Override
public List<FirePointEntity> selectFirePointByCounty(String cityCode, String satelliteType, String landType, String startTime, String endTime) { public List<FirePointEntity> selectFirePointByCounty(String cityCode, String satelliteType, String landType, String startTime, String endTime) {
return query.selectFirePointByCounty(cityCode,satelliteType,landType,startTime,endTime); LocalDate localDate = DateTimeUtil.stringToDate(endTime);
// 结束时间
LocalDate localDate1 = localDate.plusDays(1);
String dateToString = DateTimeUtil.dateToString(localDate1);
return query.selectFirePointByCounty(cityCode,satelliteType,landType,startTime,dateToString);
} }
/** /**
@ -305,6 +330,7 @@ public class FirePointServiceImpl implements FirePointService {
* 查询近一周的火点信息 * 查询近一周的火点信息
* @return * @return
*/ */
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
@Override @Override
public List<FirePointEntity> selectFirePointBetweenSeven() { public List<FirePointEntity> selectFirePointBetweenSeven() {
LocalDateTime localDateTime = LocalDateTime.now(); LocalDateTime localDateTime = LocalDateTime.now();
@ -320,6 +346,7 @@ public class FirePointServiceImpl implements FirePointService {
* 查询近一个月的火点信息 * 查询近一个月的火点信息
* @return * @return
*/ */
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
@Override @Override
public List<FirePointEntity> selectFirePointByMonth(String countyCode) { public List<FirePointEntity> selectFirePointByMonth(String countyCode) {
LocalDateTime localDateTime = LocalDateTime.now(); LocalDateTime localDateTime = LocalDateTime.now();
@ -345,6 +372,7 @@ public class FirePointServiceImpl implements FirePointService {
* 查询近一个月的火点数量 * 查询近一个月的火点数量
* @return * @return
*/ */
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
@Override @Override
public String selectFirePointNumMonth() { public String selectFirePointNumMonth() {
// 获取区域信息 // 获取区域信息
@ -370,6 +398,7 @@ public class FirePointServiceImpl implements FirePointService {
* 查询近一天的火点数量 * 查询近一天的火点数量
* @return * @return
*/ */
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
@Override @Override
public String selectFirePointNumDay() { public String selectFirePointNumDay() {
// 获取区域信息 // 获取区域信息
@ -395,6 +424,7 @@ public class FirePointServiceImpl implements FirePointService {
* 查询近一周的火点数量 * 查询近一周的火点数量
* @return * @return
*/ */
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
@Override @Override
public String selectFirePointNumWeek() { public String selectFirePointNumWeek() {
// 获取区域信息 // 获取区域信息

View File

@ -112,11 +112,11 @@ public class SysUserServiceImpl implements SysUserService {
sysUserEntity.setActiveFlag(1); sysUserEntity.setActiveFlag(1);
sysUserEntity.setAccountType("省级"); sysUserEntity.setAccountType("省级");
}else if("00".equals(sysUserQo.getCountyCode().substring(4)) && !"0000".equals(sysUserQo.getCountyCode().substring(2))){ }else if("00".equals(sysUserQo.getCountyCode().substring(4)) && !"0000".equals(sysUserQo.getCountyCode().substring(2))){
List<CityEntity> byCityCode = cityDao.findByCityCode(sysUserQo.getCountyCode()); List<CountyEntity> byCityCode = countyDao.findByCityCode(sysUserQo.getCountyCode());
if(byCityCode == null || byCityCode.size() == 0){ if(byCityCode == null || byCityCode.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"市编码不存在!",locale); return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"市编码不存在!",locale);
} }
List<CityEntity> byCityName = cityDao.findByCityName(sysUserQo.getCountyName()); List<CountyEntity> byCityName = countyDao.findByCityName(sysUserQo.getCountyName());
if(byCityName == null || byCityName.size() == 0){ if(byCityName == null || byCityName.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"您所选择的区域不存在!",locale); return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"您所选择的区域不存在!",locale);
} }

View File

@ -218,8 +218,11 @@ public class DateTimeUtil {
} }
public static void main(String[] args) { public static void main(String[] args) {
long l = dateToTimeMillis(LocalDateTime.now()); LocalDate now = LocalDate.now();
System.out.println("------"+l); LocalDate localDate = now.plusDays(1);
String s = dateToString(localDate);
LocalDate localDate1 = stringToDate(s);
System.out.println(localDate1);
} }
} }

View File

@ -10,6 +10,7 @@ import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -46,11 +47,19 @@ public class Query {
list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType)); list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
} }
if(startTime != null && !"".equals(startTime)){ if(startTime != null && !"".equals(startTime)){
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("addTime").as(String.class), 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)){ if(endTime != null && !"".equals(endTime)){
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("addTime").as(String.class), 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()]; Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates)); return criteriaBuilder.and(list.toArray(predicates));
} }
@ -81,11 +90,19 @@ public class Query {
list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType)); list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
} }
if(startTime != null && !"".equals(startTime)){ if(startTime != null && !"".equals(startTime)){
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("addTime").as(String.class), 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)){ if(endTime != null && !"".equals(endTime)){
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("addTime").as(String.class), 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()]; Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates)); return criteriaBuilder.and(list.toArray(predicates));
} }
@ -113,11 +130,19 @@ public class Query {
list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType)); list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
} }
if(startTime != null && !"".equals(startTime)){ if(startTime != null && !"".equals(startTime)){
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("addTime").as(String.class), 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)){ if(endTime != null && !"".equals(endTime)){
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("addTime").as(String.class), 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()]; Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates)); return criteriaBuilder.and(list.toArray(predicates));
} }
@ -137,10 +162,10 @@ public class Query {
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) { public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
List<Predicate> list = new ArrayList<>(); List<Predicate> list = new ArrayList<>();
if(startTime != null && !"".equals(startTime)){ if(startTime != null && !"".equals(startTime)){
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("addTime").as(String.class), startTime)); list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
} }
if(endTime != null && !"".equals(endTime)){ if(endTime != null && !"".equals(endTime)){
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("addTime").as(String.class), endTime)); list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
} }
Predicate[] predicates = new Predicate[list.size()]; Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates)); return criteriaBuilder.and(list.toArray(predicates));
@ -164,10 +189,10 @@ public class Query {
list.add(criteriaBuilder.like(root.get("firePointAddress").as(String.class), "%" + address + "%")); list.add(criteriaBuilder.like(root.get("firePointAddress").as(String.class), "%" + address + "%"));
} }
if(startTime != null && !"".equals(startTime)){ if(startTime != null && !"".equals(startTime)){
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("addTime").as(String.class), startTime)); list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
} }
if(endTime != null && !"".equals(endTime)){ if(endTime != null && !"".equals(endTime)){
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("addTime").as(String.class), endTime)); list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
} }
Predicate[] predicates = new Predicate[list.size()]; Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates)); return criteriaBuilder.and(list.toArray(predicates));
@ -192,10 +217,10 @@ public class Query {
list.add(criteriaBuilder.like(root.get("firePointAddress").as(String.class), "%" + address + "%")); list.add(criteriaBuilder.like(root.get("firePointAddress").as(String.class), "%" + address + "%"));
} }
if(startTime != null && !"".equals(startTime)){ if(startTime != null && !"".equals(startTime)){
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("addTime").as(String.class), startTime)); list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
} }
if(endTime != null && !"".equals(endTime)){ if(endTime != null && !"".equals(endTime)){
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("addTime").as(String.class), endTime)); list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
} }
Predicate[] predicates = new Predicate[list.size()]; Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates)); return criteriaBuilder.and(list.toArray(predicates));
@ -220,10 +245,10 @@ public class Query {
list.add(criteriaBuilder.like(root.get("countyCode").as(String.class), countyCode)); list.add(criteriaBuilder.like(root.get("countyCode").as(String.class), countyCode));
} }
if(startTime != null && !"".equals(startTime)){ if(startTime != null && !"".equals(startTime)){
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("addTime").as(String.class), startTime)); list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
} }
if(endTime != null && !"".equals(endTime)){ if(endTime != null && !"".equals(endTime)){
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("addTime").as(String.class), endTime)); list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
} }
Predicate[] predicates = new Predicate[list.size()]; Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates)); return criteriaBuilder.and(list.toArray(predicates));

View File

@ -35,7 +35,7 @@ spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
## Redis配置 ## Redis配置
spring.cache.type = redis spring.cache.type = redis
spring.redis.database = 8 spring.redis.database = 12
spring.redis.host = localhost spring.redis.host = localhost
spring.redis.port = 6379 spring.redis.port = 6379
spring.redis.password=sdust2020 spring.redis.password=sdust2020