1、修改了用户注册功能模块
2、修改火点动态多条件查询功能模块,修改默认查询一个月火点信息
This commit is contained in:
parent
2129b3d3fd
commit
5b02a11b0e
@ -60,6 +60,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers(HttpMethod.POST,"/insertFireTest").permitAll()
|
||||
.antMatchers(HttpMethod.POST,"/importCityExcel").permitAll()
|
||||
.antMatchers(HttpMethod.POST,"/deleteShuiTi").permitAll()
|
||||
.antMatchers(HttpMethod.GET,"/selectBeijing").permitAll()
|
||||
// 所有其它请求需要身份认证
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
|
@ -339,4 +339,12 @@ public class FirePointController {
|
||||
firePointDao.deleteByIdIn(integers);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public interface CityDao extends JpaRepository<CityEntity,Long>, JpaSpecificatio
|
||||
* @param cityCode
|
||||
* @return
|
||||
*/
|
||||
List<CityEntity> findByCityCode(String cityCode);
|
||||
CityEntity findByCityCode(String cityCode);
|
||||
|
||||
/**
|
||||
* 根据省编码查询信息
|
||||
|
@ -28,6 +28,8 @@ public interface CountyDao extends JpaRepository<CountyEntity,Long> {
|
||||
*/
|
||||
List<CountyEntity> findByCityCode(String cityCode);
|
||||
|
||||
List<CountyEntity> findByCityName(String cityName);
|
||||
|
||||
/**
|
||||
* 根据countyCode查询信息
|
||||
* @param countyCode
|
||||
|
@ -85,4 +85,11 @@ public interface FirePointDao extends JpaRepository<FirePointEntity,Long>, JpaSp
|
||||
*/
|
||||
@Modifying(clearAutomatically=true)
|
||||
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();
|
||||
}
|
||||
|
@ -11,6 +11,9 @@ import com.xkrs.service.FirePointService;
|
||||
import com.xkrs.utils.*;
|
||||
import org.slf4j.Logger;
|
||||
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.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -29,6 +32,7 @@ import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulat
|
||||
/**
|
||||
* @author XinYi Song
|
||||
*/
|
||||
@CacheConfig(cacheNames = "FirePointServiceCache")
|
||||
@Service
|
||||
public class FirePointServiceImpl implements FirePointService {
|
||||
|
||||
@ -75,11 +79,16 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
* @param firePointQo
|
||||
* @return
|
||||
*/
|
||||
@CacheEvict(value = "FirePointServiceCache",allEntries = true)
|
||||
@Override
|
||||
public FirePointEntity insertFirePoint(FirePointQo firePointQo) {
|
||||
FirePointEntity firePointEntity = new FirePointEntity();
|
||||
if(firePointQo.getLandtype().equals("水体")){
|
||||
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 {
|
||||
firePointEntity.setFireCode(firePointQo.getFireCode());
|
||||
firePointEntity.setCountyCode(firePointQo.getCountyCode().toString());
|
||||
@ -121,6 +130,7 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
|
||||
@Override
|
||||
public List<FirePointEntity> selectTodayFirePoint(String countyCode) {
|
||||
String addTime = DateTimeUtil.dateToString(LocalDate.now());
|
||||
@ -146,11 +156,16 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
|
||||
@Override
|
||||
public List<FirePointEntity> selectFirePoint(String proCode,String cityCode, String satelliteType, String landType, String startTime, String endTime) {
|
||||
List<CityEntity> byProCode = cityDao.findByProCode(proCode);
|
||||
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
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
|
||||
@Override
|
||||
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<CountyEntity> byCityCode = countyDao.findByCityCode(cityCodeOne);
|
||||
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
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
|
||||
@Override
|
||||
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
|
||||
*/
|
||||
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
|
||||
@Override
|
||||
public List<FirePointEntity> selectFirePointBetweenSeven() {
|
||||
LocalDateTime localDateTime = LocalDateTime.now();
|
||||
@ -320,6 +346,7 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
* 查询近一个月的火点信息
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
|
||||
@Override
|
||||
public List<FirePointEntity> selectFirePointByMonth(String countyCode) {
|
||||
LocalDateTime localDateTime = LocalDateTime.now();
|
||||
@ -345,6 +372,7 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
* 查询近一个月的火点数量
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
|
||||
@Override
|
||||
public String selectFirePointNumMonth() {
|
||||
// 获取区域信息
|
||||
@ -370,6 +398,7 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
* 查询近一天的火点数量
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
|
||||
@Override
|
||||
public String selectFirePointNumDay() {
|
||||
// 获取区域信息
|
||||
@ -395,6 +424,7 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
* 查询近一周的火点数量
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
|
||||
@Override
|
||||
public String selectFirePointNumWeek() {
|
||||
// 获取区域信息
|
||||
|
@ -112,11 +112,11 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
sysUserEntity.setActiveFlag(1);
|
||||
sysUserEntity.setAccountType("省级");
|
||||
}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){
|
||||
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){
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"您所选择的区域不存在!",locale);
|
||||
}
|
||||
|
@ -218,8 +218,11 @@ public class DateTimeUtil {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
long l = dateToTimeMillis(LocalDateTime.now());
|
||||
System.out.println("------"+l);
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalDate localDate = now.plusDays(1);
|
||||
String s = dateToString(localDate);
|
||||
LocalDate localDate1 = stringToDate(s);
|
||||
System.out.println(localDate1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -46,11 +47,19 @@ public class Query {
|
||||
list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
|
||||
}
|
||||
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)){
|
||||
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()];
|
||||
return criteriaBuilder.and(list.toArray(predicates));
|
||||
}
|
||||
@ -81,11 +90,19 @@ public class Query {
|
||||
list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
|
||||
}
|
||||
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)){
|
||||
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()];
|
||||
return criteriaBuilder.and(list.toArray(predicates));
|
||||
}
|
||||
@ -113,11 +130,19 @@ public class Query {
|
||||
list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
|
||||
}
|
||||
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)){
|
||||
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()];
|
||||
return criteriaBuilder.and(list.toArray(predicates));
|
||||
}
|
||||
@ -137,10 +162,10 @@ public class Query {
|
||||
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
||||
List<Predicate> list = new ArrayList<>();
|
||||
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)){
|
||||
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()];
|
||||
return criteriaBuilder.and(list.toArray(predicates));
|
||||
@ -164,10 +189,10 @@ public class Query {
|
||||
list.add(criteriaBuilder.like(root.get("firePointAddress").as(String.class), "%" + address + "%"));
|
||||
}
|
||||
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)){
|
||||
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()];
|
||||
return criteriaBuilder.and(list.toArray(predicates));
|
||||
@ -192,10 +217,10 @@ public class Query {
|
||||
list.add(criteriaBuilder.like(root.get("firePointAddress").as(String.class), "%" + address + "%"));
|
||||
}
|
||||
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)){
|
||||
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()];
|
||||
return criteriaBuilder.and(list.toArray(predicates));
|
||||
@ -220,10 +245,10 @@ public class Query {
|
||||
list.add(criteriaBuilder.like(root.get("countyCode").as(String.class), countyCode));
|
||||
}
|
||||
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)){
|
||||
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()];
|
||||
return criteriaBuilder.and(list.toArray(predicates));
|
||||
|
@ -35,7 +35,7 @@ spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
|
||||
|
||||
## Redis配置
|
||||
spring.cache.type = redis
|
||||
spring.redis.database = 8
|
||||
spring.redis.database = 12
|
||||
spring.redis.host = localhost
|
||||
spring.redis.port = 6379
|
||||
spring.redis.password=sdust2020
|
||||
|
Loading…
Reference in New Issue
Block a user