diff --git a/pom.xml b/pom.xml
index b4cc137..f63154a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,6 +30,8 @@
5.0.0
5.0.0
4.5.2
+ 5.0.0
+ 5.0.0
@@ -178,6 +180,18 @@
httpclient
${httpclient.version}
+
+
+ org.apache.poi
+ poi
+ ${poi.version}
+
+
+
+ org.apache.poi
+ poi-ooxml
+ ${poi-ooxml.version}
+
diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java
index c8d9d0d..126e654 100644
--- a/src/main/java/com/xkrs/controller/FirePointController.java
+++ b/src/main/java/com/xkrs/controller/FirePointController.java
@@ -4,11 +4,13 @@ import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.common.tool.TokenUtil;
import com.xkrs.dao.FirePointDao;
import com.xkrs.dao.SysUserDao;
+import com.xkrs.model.entity.CountyEntity;
import com.xkrs.model.entity.FirePointEntity;
import com.xkrs.model.entity.SysUserEntity;
import com.xkrs.model.qo.FirePointQo;
import com.xkrs.model.vo.AppTaskBodyVo;
import com.xkrs.service.FirePointService;
+import com.xkrs.utils.ExcelImportUtil;
import com.xkrs.websocket.service.WebSocketServer;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -20,6 +22,8 @@ import java.io.IOException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
@@ -38,6 +42,7 @@ public class FirePointController {
@Resource
private FirePointDao firePointDao;
+
/**
* 添加火点数据
* @param firePointQo
@@ -75,7 +80,7 @@ public class FirePointController {
}
/**
- * 查询今天的好点信息
+ * 查询今天的火点信息
* @param token
* @return
*/
@@ -112,11 +117,31 @@ public class FirePointController {
String startTime = (String) map.get("startTime");
// 结束时间
String endTime = (String) map.get("endTime");
- List firePointEntities = firePointService.selectFirePoint(cityCode, satelliteType, landType, startTime, endTime);
- if(firePointEntities == null || firePointEntities.size() == 0){
- return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale);
+ // 验证token
+ String tokenUserName = TokenUtil.getTokenUserName(token);
+ SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
+ // 查询省
+ if(sysUserEntity.getCountyCode().substring(2).equals("0000")){
+ List firePointEntities = firePointService.selectFirePoint(sysUserEntity.getCountyCode(),cityCode, satelliteType, landType, startTime, endTime);
+ if(firePointEntities == null || firePointEntities.size() == 0){
+ return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale);
+ }
+ return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
+ // 查询市
+ }else if(sysUserEntity.getCountyCode().substring(4).equals("00") && !sysUserEntity.getCountyCode().substring(2).equals("0000")){
+ List firePointEntities = firePointService.selectFirePointByCity(sysUserEntity.getCountyCode(), cityCode, satelliteType, landType, startTime, endTime);
+ if(firePointEntities == null || firePointEntities.size() == 0){
+ return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale);
+ }
+ return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
+ // 查询县
+ }else {
+ List firePointEntities = firePointService.selectFirePointByCounty(cityCode, satelliteType, landType, startTime, endTime);
+ if(firePointEntities == null || firePointEntities.size() == 0){
+ return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale);
+ }
+ return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
}
- return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
}
/**
diff --git a/src/main/java/com/xkrs/dao/CountyDao.java b/src/main/java/com/xkrs/dao/CountyDao.java
new file mode 100644
index 0000000..d131465
--- /dev/null
+++ b/src/main/java/com/xkrs/dao/CountyDao.java
@@ -0,0 +1,12 @@
+package com.xkrs.dao;
+
+import com.xkrs.model.entity.CountyEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author XinYi Song
+ */
+@Component
+public interface CountyDao extends JpaRepository {
+}
diff --git a/src/main/java/com/xkrs/model/entity/CountyEntity.java b/src/main/java/com/xkrs/model/entity/CountyEntity.java
new file mode 100644
index 0000000..7f83c3c
--- /dev/null
+++ b/src/main/java/com/xkrs/model/entity/CountyEntity.java
@@ -0,0 +1,104 @@
+package com.xkrs.model.entity;
+
+import javax.persistence.*;
+
+/**
+ * @author XinYi Song
+ */
+@Entity
+@Table(name = "county")
+public class CountyEntity {
+ /**
+ * 主键id
+ */
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "city_seq_gen")
+ @SequenceGenerator(name = "city_seq_gen", sequenceName = "city_id_seq",allocationSize = 1)
+ private Integer id;
+
+ /**
+ * 区县编码
+ */
+ @Column(length = 65, columnDefinition = "varchar(65)")
+ private String countyCode;
+
+ /**
+ * 区县名称
+ */
+ @Column(length = 65, columnDefinition = "varchar(65)")
+ private String countyName;
+
+ /**
+ * 城市编码
+ */
+ @Column(length = 65, columnDefinition = "varchar(65)")
+ private String cityCode;
+
+ /**
+ * 城市名称
+ */
+ @Column(length = 65, columnDefinition = "varchar(65)")
+ private String cityName;
+
+ public CountyEntity() {
+ }
+
+ public CountyEntity(Integer id, String countyCode, String countyName, String cityCode, String cityName) {
+ this.id = id;
+ this.countyCode = countyCode;
+ this.countyName = countyName;
+ this.cityCode = cityCode;
+ this.cityName = cityName;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getCountyCode() {
+ return countyCode;
+ }
+
+ public void setCountyCode(String countyCode) {
+ this.countyCode = countyCode;
+ }
+
+ public String getCountyName() {
+ return countyName;
+ }
+
+ public void setCountyName(String countyName) {
+ this.countyName = countyName;
+ }
+
+ public String getCityCode() {
+ return cityCode;
+ }
+
+ public void setCityCode(String cityCode) {
+ this.cityCode = cityCode;
+ }
+
+ public String getCityName() {
+ return cityName;
+ }
+
+ public void setCityName(String cityName) {
+ this.cityName = cityName;
+ }
+
+ @Override
+ public String toString() {
+ return "CountyEntity{" +
+ "id=" + id +
+ ", countyCode='" + countyCode + '\'' +
+ ", countyName='" + countyName + '\'' +
+ ", cityCode='" + cityCode + '\'' +
+ ", cityName='" + cityName + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/com/xkrs/service/FirePointService.java b/src/main/java/com/xkrs/service/FirePointService.java
index d3b8ebc..df00f78 100644
--- a/src/main/java/com/xkrs/service/FirePointService.java
+++ b/src/main/java/com/xkrs/service/FirePointService.java
@@ -30,7 +30,8 @@ public interface FirePointService {
List selectTodayFirePoint();
/**
- * 动态多条件查询火点信息
+ * 动态多条件查询火点信息(省)
+ * @param proCode
* @param cityCode
* @param satelliteType
* @param landType
@@ -38,7 +39,31 @@ public interface FirePointService {
* @param endTime
* @return
*/
- List selectFirePoint(String cityCode,String satelliteType,String landType,String startTime,String endTime);
+ List selectFirePoint(String proCode,String cityCode,String satelliteType,String landType,String startTime,String endTime);
+
+
+ /**
+ * 动态多条件查询火点信息(市)
+ * @param cityCodeOne 市编码
+ * @param cityCode 县编码
+ * @param satelliteType
+ * @param landType
+ * @param startTime
+ * @param endTime
+ * @return
+ */
+ List selectFirePointByCity(String cityCodeOne,String cityCode,String satelliteType,String landType,String startTime,String endTime);
+
+ /**
+ * 动态多条件查询火点信息(县)
+ * @param cityCode 县编码
+ * @param satelliteType
+ * @param landType
+ * @param startTime
+ * @param endTime
+ * @return
+ */
+ List selectFirePointByCounty(String cityCode,String satelliteType,String landType,String startTime,String endTime);
/**
* 根据火点编码修改火点的状态(预警)
diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java
index fd9303c..7c9d71a 100644
--- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java
+++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java
@@ -1,6 +1,5 @@
package com.xkrs.service.impl;
-import com.alibaba.fastjson.JSON;
import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.common.tool.TokenUtil;
import com.xkrs.dao.*;
@@ -10,7 +9,6 @@ import com.xkrs.model.vo.AppPhotoVo;
import com.xkrs.model.vo.AppTaskBodyVo;
import com.xkrs.service.FirePointService;
import com.xkrs.utils.*;
-import com.xkrs.websocket.service.WebSocketServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cglib.beans.BeanCopier;
@@ -118,7 +116,7 @@ public class FirePointServiceImpl implements FirePointService {
}
/**
- * 动态多条件查询火点信息
+ * 动态多条件查询火点信息(省)
* @param cityCode
* @param satelliteType
* @param landType
@@ -127,8 +125,37 @@ public class FirePointServiceImpl implements FirePointService {
* @return
*/
@Override
- public List selectFirePoint(String cityCode, String satelliteType, String landType, String startTime, String endTime) {
- return query.selectFirePoint(cityCode, satelliteType, landType, startTime, endTime);
+ public List selectFirePoint(String proCode,String cityCode, String satelliteType, String landType, String startTime, String endTime) {
+ return query.selectFirePointByPro(proCode,cityCode, satelliteType, landType, startTime, endTime);
+ }
+
+ /**
+ * 动态多条件查询火点信息(市)
+ * @param cityCodeOne 市编码
+ * @param cityCode 县编码
+ * @param satelliteType
+ * @param landType
+ * @param startTime
+ * @param endTime
+ * @return
+ */
+ @Override
+ public List selectFirePointByCity(String cityCodeOne, String cityCode, String satelliteType, String landType, String startTime, String endTime) {
+ return query.selectFirePointByCity(cityCodeOne,cityCode,satelliteType,landType,startTime,endTime);
+ }
+
+ /**
+ * 动态多条件查询火点信息(县)
+ * @param cityCode 县编码
+ * @param satelliteType
+ * @param landType
+ * @param startTime
+ * @param endTime
+ * @return
+ */
+ @Override
+ public List selectFirePointByCounty(String cityCode, String satelliteType, String landType, String startTime, String endTime) {
+ return query.selectFirePointByCounty(cityCode,satelliteType,landType,startTime,endTime);
}
/**
diff --git a/src/main/java/com/xkrs/utils/Query.java b/src/main/java/com/xkrs/utils/Query.java
index dac4134..e858bfb 100644
--- a/src/main/java/com/xkrs/utils/Query.java
+++ b/src/main/java/com/xkrs/utils/Query.java
@@ -24,18 +24,89 @@ public class Query {
private FirePointDao firePointDao;
/**
- * 动态多条件查询项目信息
+ * 动态多条件查询项目信息(省)
* @param
* @return
*/
- public List selectFirePoint(String cityCode,String satelliteType,String landType,String startTime,String endTime) {
+ public List selectFirePointByPro(String proCode, String cityCode, String satelliteType, String landType, String startTime, String endTime) {
+ Specification specification = new Specification() {
+ @Override
+ public Predicate toPredicate(Root root, CriteriaQuery> criteriaQuery, CriteriaBuilder criteriaBuilder) {
+ List list = new ArrayList<>();
+ if(proCode != null && !"".equals(proCode)){
+ String substring = proCode.substring(0, 2);
+ list.add(criteriaBuilder.like(root.get("countyCode").as(String.class), "%" + substring + "%"));
+ }
+ if (cityCode != null && !"".equals(cityCode)) {
+ list.add(criteriaBuilder.like(root.get("countyCode").as(String.class), "%" + cityCode + "%"));
+ }
+ if (satelliteType != null && !"".equals(satelliteType)) {
+ list.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType));
+ }
+ if (landType != null && !"".equals(landType)) {
+ 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));
+ }
+ if(endTime != null && !"".equals(endTime)){
+ list.add(criteriaBuilder.lessThanOrEqualTo(root.get("addTime").as(String.class), endTime));
+ }
+ Predicate[] predicates = new Predicate[list.size()];
+ return criteriaBuilder.and(list.toArray(predicates));
+ }
+ };
+ return firePointDao.findAll(specification);
+ }
+
+ /**
+ * 动态多条件查询项目信息(市)
+ * @param
+ * @return
+ */
+ public List selectFirePointByCity(String cityCodeOne, String cityCode,String satelliteType,String landType,String startTime,String endTime) {
+ Specification specification = new Specification() {
+ @Override
+ public Predicate toPredicate(Root root, CriteriaQuery> criteriaQuery, CriteriaBuilder criteriaBuilder) {
+ List list = new ArrayList<>();
+ if(cityCodeOne != null && !"".equals(cityCodeOne)){
+ String substring = cityCodeOne.substring(0, 4);
+ list.add(criteriaBuilder.like(root.get("countyCode").as(String.class), "%" + substring + "%"));
+ }
+ if (cityCode != null && !"".equals(cityCode)) {
+ list.add(criteriaBuilder.equal(root.get("countyCode").as(String.class),cityCode));
+ }
+ if (satelliteType != null && !"".equals(satelliteType)) {
+ list.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType));
+ }
+ if (landType != null && !"".equals(landType)) {
+ 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));
+ }
+ if(endTime != null && !"".equals(endTime)){
+ list.add(criteriaBuilder.lessThanOrEqualTo(root.get("addTime").as(String.class), endTime));
+ }
+ Predicate[] predicates = new Predicate[list.size()];
+ return criteriaBuilder.and(list.toArray(predicates));
+ }
+ };
+ return firePointDao.findAll(specification);
+ }
+
+ /**
+ * 动态多条件查询项目信息(县)
+ * @param
+ * @return
+ */
+ public List selectFirePointByCounty(String cityCode,String satelliteType,String landType,String startTime,String endTime) {
Specification specification = new Specification() {
@Override
public Predicate toPredicate(Root root, CriteriaQuery> criteriaQuery, CriteriaBuilder criteriaBuilder) {
List list = new ArrayList<>();
if (cityCode != null && !"".equals(cityCode)) {
- //String substring = cityCode.substring(0, 4);
- list.add(criteriaBuilder.like(root.get("countyCode").as(String.class), "%" + cityCode + "%"));
+ list.add(criteriaBuilder.equal(root.get("countyCode").as(String.class),cityCode));
}
if (satelliteType != null && !"".equals(satelliteType)) {
list.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType));
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index f7f0d92..9f92cd9 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -24,7 +24,7 @@ spring.datasource.hikari.validation-timeout = 3000
## Spring Data JPA 配置
spring.jpa.database = POSTGRESQL
spring.jpa.database-platform = org.hibernate.dialect.PostgreSQLDialect
-spring.jpa.show-sql = false
+spring.jpa.show-sql = true
# 指定 ddl mode (none, validate, create, create-drop, update)
spring.jpa.hibernate.ddl-auto = update
# 命名策略