添加了全国省市区编码和名称,
修改了动态多条件查询火点信息,修改了了账号分为省市区三个级别账号的查询
This commit is contained in:
parent
5ea7f0263e
commit
475925322a
14
pom.xml
14
pom.xml
@ -30,6 +30,8 @@
|
||||
<poi.version>5.0.0</poi.version>
|
||||
<poi-ooxml.version>5.0.0</poi-ooxml.version>
|
||||
<httpclient.version>4.5.2</httpclient.version>
|
||||
<poi.version>5.0.0</poi.version>
|
||||
<poi-ooxml.version>5.0.0</poi-ooxml.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -178,6 +180,18 @@
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>${httpclient.version}</version>
|
||||
</dependency>
|
||||
<!--excel依赖-->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi-ooxml.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
@ -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<FirePointEntity> firePointEntities = firePointService.selectFirePoint(cityCode, satelliteType, landType, startTime, endTime);
|
||||
// 验证token
|
||||
String tokenUserName = TokenUtil.getTokenUserName(token);
|
||||
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
|
||||
// 查询省
|
||||
if(sysUserEntity.getCountyCode().substring(2).equals("0000")){
|
||||
List<FirePointEntity> 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<FirePointEntity> 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<FirePointEntity> 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
12
src/main/java/com/xkrs/dao/CountyDao.java
Normal file
12
src/main/java/com/xkrs/dao/CountyDao.java
Normal file
@ -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<CountyEntity,Long> {
|
||||
}
|
104
src/main/java/com/xkrs/model/entity/CountyEntity.java
Normal file
104
src/main/java/com/xkrs/model/entity/CountyEntity.java
Normal file
@ -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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -30,7 +30,8 @@ public interface FirePointService {
|
||||
List<FirePointEntity> selectTodayFirePoint();
|
||||
|
||||
/**
|
||||
* 动态多条件查询火点信息
|
||||
* 动态多条件查询火点信息(省)
|
||||
* @param proCode
|
||||
* @param cityCode
|
||||
* @param satelliteType
|
||||
* @param landType
|
||||
@ -38,7 +39,31 @@ public interface FirePointService {
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
List<FirePointEntity> selectFirePoint(String cityCode,String satelliteType,String landType,String startTime,String endTime);
|
||||
List<FirePointEntity> 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<FirePointEntity> 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<FirePointEntity> selectFirePointByCounty(String cityCode,String satelliteType,String landType,String startTime,String endTime);
|
||||
|
||||
/**
|
||||
* 根据火点编码修改火点的状态(预警)
|
||||
|
@ -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<FirePointEntity> selectFirePoint(String cityCode, String satelliteType, String landType, String startTime, String endTime) {
|
||||
return query.selectFirePoint(cityCode, satelliteType, landType, startTime, endTime);
|
||||
public List<FirePointEntity> 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<FirePointEntity> 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<FirePointEntity> selectFirePointByCounty(String cityCode, String satelliteType, String landType, String startTime, String endTime) {
|
||||
return query.selectFirePointByCounty(cityCode,satelliteType,landType,startTime,endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,18 +24,89 @@ public class Query {
|
||||
private FirePointDao firePointDao;
|
||||
|
||||
/**
|
||||
* 动态多条件查询项目信息
|
||||
* 动态多条件查询项目信息(省)
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public List<FirePointEntity> selectFirePoint(String cityCode,String satelliteType,String landType,String startTime,String endTime) {
|
||||
public List<FirePointEntity> selectFirePointByPro(String proCode, String cityCode, String satelliteType, String landType, String startTime, String endTime) {
|
||||
Specification<FirePointEntity> specification = new Specification<FirePointEntity>() {
|
||||
@Override
|
||||
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
||||
List<Predicate> 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<FirePointEntity> selectFirePointByCity(String cityCodeOne, String cityCode,String satelliteType,String landType,String startTime,String endTime) {
|
||||
Specification<FirePointEntity> specification = new Specification<FirePointEntity>() {
|
||||
@Override
|
||||
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
||||
List<Predicate> 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<FirePointEntity> selectFirePointByCounty(String cityCode,String satelliteType,String landType,String startTime,String endTime) {
|
||||
Specification<FirePointEntity> specification = new Specification<FirePointEntity>() {
|
||||
@Override
|
||||
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
||||
List<Predicate> 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));
|
||||
|
@ -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
|
||||
# 命名策略
|
||||
|
Loading…
Reference in New Issue
Block a user