diff --git a/src/main/java/com/xkrs/dao/GlobalSettingDao.java b/src/main/java/com/xkrs/dao/GlobalSettingDao.java new file mode 100644 index 0000000..5a71162 --- /dev/null +++ b/src/main/java/com/xkrs/dao/GlobalSettingDao.java @@ -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, JpaSpecificationExecutor { + +} diff --git a/src/main/java/com/xkrs/model/entity/GlobalSettingEntity.java b/src/main/java/com/xkrs/model/entity/GlobalSettingEntity.java new file mode 100644 index 0000000..2e25f27 --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/GlobalSettingEntity.java @@ -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; + } +} diff --git a/src/main/java/com/xkrs/service/GlobalSettingService.java b/src/main/java/com/xkrs/service/GlobalSettingService.java new file mode 100644 index 0000000..4a5bf72 --- /dev/null +++ b/src/main/java/com/xkrs/service/GlobalSettingService.java @@ -0,0 +1,7 @@ +package com.xkrs.service; + +public interface GlobalSettingService { + + boolean onlyShanDong(); + +} diff --git a/src/main/java/com/xkrs/service/impl/GlobalSettingServiceImpl.java b/src/main/java/com/xkrs/service/impl/GlobalSettingServiceImpl.java new file mode 100644 index 0000000..1d909d2 --- /dev/null +++ b/src/main/java/com/xkrs/service/impl/GlobalSettingServiceImpl.java @@ -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 globalSettingList = globalSettingDao.findAll(); + for (GlobalSettingEntity globalSetting : globalSettingList) { + if (globalSetting.getKey().equalsIgnoreCase("OnlyShanDong")) { + return globalSetting.getValue() == 1L; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + +} diff --git a/src/main/java/com/xkrs/utils/FirePointQueryHelper.java b/src/main/java/com/xkrs/utils/FirePointQueryHelper.java index d016690..908ab56 100644 --- a/src/main/java/com/xkrs/utils/FirePointQueryHelper.java +++ b/src/main/java/com/xkrs/utils/FirePointQueryHelper.java @@ -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 queryFirePoint(String code, String startTime, String endTime, String satelliteType, String landType) { Specification specification = (root, criteriaQuery, criteriaBuilder) -> { //查询条件集合 List 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 {