查询接口只返回山东省内的火点

This commit is contained in:
liuchengqian 2022-06-21 16:20:09 +08:00
parent d0b127f34b
commit e258f92e27
5 changed files with 115 additions and 0 deletions

View File

@ -0,0 +1,11 @@
package com.xkrs.dao;
import com.xkrs.model.entity.GlobalSettingEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Component;
@Component
public interface GlobalSettingDao extends JpaRepository<GlobalSettingEntity, Long>, JpaSpecificationExecutor<GlobalSettingEntity> {
}

View File

@ -0,0 +1,57 @@
package com.xkrs.model.entity;
import javax.persistence.*;
import java.io.Serializable;
/**
* 全局配置表
*/
@Entity
@Table(name = "global_setting")
public class GlobalSettingEntity implements Serializable {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "global_setting_seq_gen")
@SequenceGenerator(name = "global_setting_seq_gen", sequenceName = "global_setting_id_seq", allocationSize = 1)
private Long id;
/**
* 全局配置项的键
*/
private String key;
/**
* 全局配置项的值
*/
private Long value;
public GlobalSettingEntity() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public Long getValue() {
return value;
}
public void setValue(Long value) {
this.value = value;
}
}

View File

@ -0,0 +1,7 @@
package com.xkrs.service;
public interface GlobalSettingService {
boolean onlyShanDong();
}

View File

@ -0,0 +1,32 @@
package com.xkrs.service.impl;
import com.xkrs.dao.GlobalSettingDao;
import com.xkrs.model.entity.GlobalSettingEntity;
import com.xkrs.service.GlobalSettingService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class GlobalSettingServiceImpl implements GlobalSettingService {
@Resource
private GlobalSettingDao globalSettingDao;
@Override
public boolean onlyShanDong() {
try {
List<GlobalSettingEntity> globalSettingList = globalSettingDao.findAll();
for (GlobalSettingEntity globalSetting : globalSettingList) {
if (globalSetting.getKey().equalsIgnoreCase("OnlyShanDong")) {
return globalSetting.getValue() == 1L;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}

View File

@ -2,6 +2,7 @@ package com.xkrs.utils;
import com.xkrs.dao.FirePointDao;
import com.xkrs.model.entity.FirePointEntity;
import com.xkrs.service.GlobalSettingService;
import org.apache.hc.core5.util.TextUtils;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
@ -22,10 +23,17 @@ public class FirePointQueryHelper {
@Resource
private FirePointDao firePointDao;
@Resource
private GlobalSettingService globalSettingService;
public List<FirePointEntity> queryFirePoint(String code, String startTime, String endTime, String satelliteType, String landType) {
Specification<FirePointEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
//查询条件集合
List<Predicate> predicateList = new ArrayList<>();
if (globalSettingService.onlyShanDong()) {
predicateList.add(criteriaBuilder.like(root.get("countyCode").as(String.class), "37%"));
predicateList.add(criteriaBuilder.like(root.get("streetCode").as(String.class), "37%"));
}
//添加区划编码查询条件
if (!TextUtils.isEmpty(code)) {
try {