优化
This commit is contained in:
parent
07345a8652
commit
087118421b
4
pom.xml
4
pom.xml
@ -9,9 +9,9 @@
|
|||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.xkrs</groupId>
|
<groupId>com.xkrs</groupId>
|
||||||
<artifactId>fire_point</artifactId>
|
<artifactId>straw_fire_point</artifactId>
|
||||||
<version>0.0.1</version>
|
<version>0.0.1</version>
|
||||||
<name>fire_point</name>
|
<name>straw_fire_point</name>
|
||||||
<description>火点项目</description>
|
<description>火点项目</description>
|
||||||
<properties>
|
<properties>
|
||||||
<yauaa.version>5.19</yauaa.version>
|
<yauaa.version>5.19</yauaa.version>
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
package com.xkrs.dao;
|
|
||||||
|
|
||||||
import com.xkrs.model.entity.FirePointEntity;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public interface FirePointDao extends JpaRepository<FirePointEntity, Long>, JpaSpecificationExecutor<FirePointEntity> {
|
|
||||||
|
|
||||||
@Query(value = "select a.really_name 姓名, a.county_name 所在市, a.telephone 手机号, a.vip_level vip, b.satellite_time 扫描时间, " + "round(cast(b.longitude as numeric) ,6) 经度, round(cast(b.latitude as numeric) ,6) 纬度, b.fire_point_address 详细地址 from sys_user a left join fire_point b on " + "case when left(a.county_code, 4) = '0000' then left(b.county_code, 4) = left(a.county_code, 4) " + "when left(a.county_code, 2) = '00' then left(b.county_code, 2) = left(a.county_code, 2) " + "else left(b.county_code, 2) = left(a.county_code, 2) end where a.vip_level > 0 and satellite_time > ?1", nativeQuery = true)
|
|
||||||
List<Map<String, String>> downloadFirePointByVip(String yesterday);
|
|
||||||
|
|
||||||
}
|
|
@ -1,325 +0,0 @@
|
|||||||
package com.xkrs.model.entity;
|
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "fire_point")
|
|
||||||
public class FirePointEntity implements Serializable {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 指定主键,建立自增序列,主键值取自序列
|
|
||||||
*/
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fire_point_seq_gen")
|
|
||||||
@SequenceGenerator(name = "fire_point_seq_gen", sequenceName = "fire_point_id_seq", allocationSize = 1)
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 火点编码
|
|
||||||
*/
|
|
||||||
@Column(length = 32, unique = true, columnDefinition = "varchar(32)")
|
|
||||||
private String fireCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 省市区编码
|
|
||||||
*/
|
|
||||||
@Column(length = 32, columnDefinition = "varchar(32)")
|
|
||||||
private String countyCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 省市区名称
|
|
||||||
*/
|
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
|
||||||
private String countyName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 卫星监测的时间
|
|
||||||
*/
|
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
|
||||||
private String satelliteTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 经度
|
|
||||||
*/
|
|
||||||
private double longitude;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 纬度
|
|
||||||
*/
|
|
||||||
private double latitude;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 卫星的类型
|
|
||||||
*/
|
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
|
||||||
private String satelliteType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 植被类型
|
|
||||||
*/
|
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
|
||||||
private String landType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 置信度
|
|
||||||
*/
|
|
||||||
@Column(length = 32, columnDefinition = "varchar(32)")
|
|
||||||
private String confidence;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 当前火点的图片
|
|
||||||
*/
|
|
||||||
@Column(length = 255, columnDefinition = "varchar(255)")
|
|
||||||
private String fireImage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 卫星影像图片
|
|
||||||
*/
|
|
||||||
@Column(length = 255, columnDefinition = "varchar(255)")
|
|
||||||
private String satelliteImage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 街道编码
|
|
||||||
*/
|
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
|
||||||
private String streetCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 街道名称
|
|
||||||
*/
|
|
||||||
@Column(length = 85, columnDefinition = "varchar(85)")
|
|
||||||
private String streetName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加的时间
|
|
||||||
*/
|
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
|
||||||
private String addTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 详细地址
|
|
||||||
*/
|
|
||||||
@Column(length = 255, columnDefinition = "varchar(255)")
|
|
||||||
private String firePointAddress;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 火点状态
|
|
||||||
* 0:发现
|
|
||||||
* 1:预警
|
|
||||||
* 2:核查
|
|
||||||
* -1,3:结案
|
|
||||||
*/
|
|
||||||
@Column(length = 32, columnDefinition = "varchar(32)")
|
|
||||||
private String fireType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 审核火点状态
|
|
||||||
* 0:未审核
|
|
||||||
* 1:审核通过
|
|
||||||
* 2:审核未通过
|
|
||||||
*/
|
|
||||||
@Column(length = 65, columnDefinition = "varchar(32)")
|
|
||||||
private String auditFireType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 火点前的图片
|
|
||||||
*/
|
|
||||||
@Column(length = 255, columnDefinition = "varchar(255)")
|
|
||||||
private String beforeFireImage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 火点后的图片
|
|
||||||
*/
|
|
||||||
@Column(length = 255, columnDefinition = "varchar(255)")
|
|
||||||
private String afterFireImage;
|
|
||||||
|
|
||||||
public FirePointEntity() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Integer id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFireCode() {
|
|
||||||
return fireCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFireCode(String fireCode) {
|
|
||||||
this.fireCode = fireCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getLongitude() {
|
|
||||||
return longitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLongitude(double longitude) {
|
|
||||||
this.longitude = longitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getLatitude() {
|
|
||||||
return latitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLatitude(double latitude) {
|
|
||||||
this.latitude = latitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFirePointAddress() {
|
|
||||||
return firePointAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFirePointAddress(String firePointAddress) {
|
|
||||||
this.firePointAddress = firePointAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStreetCode() {
|
|
||||||
return streetCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStreetCode(String streetCode) {
|
|
||||||
this.streetCode = streetCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStreetName() {
|
|
||||||
return streetName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStreetName(String streetName) {
|
|
||||||
this.streetName = streetName;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 getSatelliteTime() {
|
|
||||||
return satelliteTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSatelliteTime(String satelliteTime) {
|
|
||||||
this.satelliteTime = satelliteTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSatelliteType() {
|
|
||||||
return satelliteType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSatelliteType(String satelliteType) {
|
|
||||||
this.satelliteType = satelliteType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLandType() {
|
|
||||||
return landType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLandType(String landType) {
|
|
||||||
this.landType = landType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAddTime() {
|
|
||||||
return addTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAddTime(String addTime) {
|
|
||||||
this.addTime = addTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getConfidence() {
|
|
||||||
return confidence;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConfidence(String confidence) {
|
|
||||||
this.confidence = confidence;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFireType() {
|
|
||||||
return fireType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFireType(String fireType) {
|
|
||||||
this.fireType = fireType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAuditFireType() {
|
|
||||||
return auditFireType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuditFireType(String auditFireType) {
|
|
||||||
this.auditFireType = auditFireType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFireImage() {
|
|
||||||
return fireImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFireImage(String fireImage) {
|
|
||||||
this.fireImage = fireImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSatelliteImage() {
|
|
||||||
return satelliteImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSatelliteImage(String satelliteImage) {
|
|
||||||
this.satelliteImage = satelliteImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBeforeFireImage() {
|
|
||||||
return beforeFireImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBeforeFireImage(String beforeFireImage) {
|
|
||||||
this.beforeFireImage = beforeFireImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAfterFireImage() {
|
|
||||||
return afterFireImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAfterFireImage(String afterFireImage) {
|
|
||||||
this.afterFireImage = afterFireImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "FirePointEntity{" +
|
|
||||||
"id=" + id +
|
|
||||||
", fireCode='" + fireCode + '\'' +
|
|
||||||
", longitude=" + longitude +
|
|
||||||
", latitude=" + latitude +
|
|
||||||
", firePointAddress='" + firePointAddress + '\'' +
|
|
||||||
", streetCode='" + streetCode + '\'' +
|
|
||||||
", streetName='" + streetName + '\'' +
|
|
||||||
", countyCode='" + countyCode + '\'' +
|
|
||||||
", countyName='" + countyName + '\'' +
|
|
||||||
", satelliteTime='" + satelliteTime + '\'' +
|
|
||||||
", satelliteType='" + satelliteType + '\'' +
|
|
||||||
", landType='" + landType + '\'' +
|
|
||||||
", addTime='" + addTime + '\'' +
|
|
||||||
", confidence='" + confidence + '\'' +
|
|
||||||
", fireType='" + fireType + '\'' +
|
|
||||||
", auditFireType='" + auditFireType + '\'' +
|
|
||||||
", fireImage='" + fireImage + '\'' +
|
|
||||||
", satelliteImage='" + satelliteImage + '\'' +
|
|
||||||
", beforeFireImage='" + beforeFireImage + '\'' +
|
|
||||||
", afterFireImage='" + afterFireImage + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +1,16 @@
|
|||||||
package com.xkrs.service;
|
package com.xkrs.service;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author XinYi Song
|
* @author XinYi Song
|
||||||
*/
|
*/
|
||||||
public interface FirePointService {
|
public interface FirePointService {
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* download vip user's fire point
|
// * download vip user's fire point
|
||||||
*/
|
// */
|
||||||
String downloadVipUserFilePoint(HttpServletRequest request, HttpServletResponse response);
|
// String downloadVipUserFilePoint(HttpServletRequest request, HttpServletResponse response);
|
||||||
|
|
||||||
String downloadFirePoint(HttpServletRequest request, HttpServletResponse response, String ids);
|
// String downloadFirePoint(HttpServletRequest request, HttpServletResponse response, String ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (Complete)
|
* (Complete)
|
||||||
|
@ -2,9 +2,7 @@ package com.xkrs.service.impl;
|
|||||||
|
|
||||||
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
||||||
import com.xkrs.dao.CountyCodeWeiXinDao;
|
import com.xkrs.dao.CountyCodeWeiXinDao;
|
||||||
import com.xkrs.dao.FirePointDao;
|
|
||||||
import com.xkrs.dao.StreetDao;
|
import com.xkrs.dao.StreetDao;
|
||||||
import com.xkrs.model.entity.FirePointEntity;
|
|
||||||
import com.xkrs.service.FirePointService;
|
import com.xkrs.service.FirePointService;
|
||||||
import com.xkrs.service.StreetService;
|
import com.xkrs.service.StreetService;
|
||||||
import com.xkrs.straw.dao.FirePointOrdinaryDao;
|
import com.xkrs.straw.dao.FirePointOrdinaryDao;
|
||||||
@ -18,8 +16,6 @@ import com.xkrs.straw.model.vo.AllFirePointVo;
|
|||||||
import com.xkrs.straw.utils.FirePointConvertUtils;
|
import com.xkrs.straw.utils.FirePointConvertUtils;
|
||||||
import com.xkrs.straw.utils.FirePointQueryManager;
|
import com.xkrs.straw.utils.FirePointQueryManager;
|
||||||
import com.xkrs.utils.DateTimeUtils;
|
import com.xkrs.utils.DateTimeUtils;
|
||||||
import com.xkrs.utils.FirePointQueryHelper;
|
|
||||||
import com.xkrs.utils.ListUtils;
|
|
||||||
import com.xkrs.utils.TokenUtil;
|
import com.xkrs.utils.TokenUtil;
|
||||||
import org.apache.hc.core5.util.TextUtils;
|
import org.apache.hc.core5.util.TextUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -32,19 +28,12 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.persistence.criteria.Predicate;
|
import javax.persistence.criteria.Predicate;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.util.ArrayList;
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||||
import static com.xkrs.utils.DateTimeUtil.dateTimeToString;
|
|
||||||
import static com.xkrs.utils.XlsxUtil.downloadXlsx;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author XinYi Song
|
* @author XinYi Song
|
||||||
@ -57,9 +46,6 @@ public class FirePointServiceImpl implements FirePointService {
|
|||||||
|
|
||||||
private final Locale locale = LocaleContextHolder.getLocale();
|
private final Locale locale = LocaleContextHolder.getLocale();
|
||||||
|
|
||||||
@Resource
|
|
||||||
private FirePointDao firePointDao;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SysUserDao sysUserDao;
|
private SysUserDao sysUserDao;
|
||||||
|
|
||||||
@ -69,9 +55,6 @@ public class FirePointServiceImpl implements FirePointService {
|
|||||||
@Resource
|
@Resource
|
||||||
private CountyCodeWeiXinDao countyCodeWeiXinDao;
|
private CountyCodeWeiXinDao countyCodeWeiXinDao;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private FirePointQueryHelper firePointQueryHelper;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private StreetService streetService;
|
private StreetService streetService;
|
||||||
|
|
||||||
@ -87,63 +70,69 @@ public class FirePointServiceImpl implements FirePointService {
|
|||||||
@Resource
|
@Resource
|
||||||
private FirePointOrdinaryDao firePointOrdinaryDao;
|
private FirePointOrdinaryDao firePointOrdinaryDao;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 下载VIP用户火点数据
|
// * 下载VIP用户火点数据
|
||||||
*/
|
// *
|
||||||
@Override
|
// *
|
||||||
public String downloadVipUserFilePoint(HttpServletRequest request, HttpServletResponse response) {
|
// *
|
||||||
LocalDate now = LocalDate.now();
|
// @Query(value = "select a.really_name 姓名, a.county_name 所在市, a.telephone 手机号, a.vip_level vip, b.satellite_time 扫描时间, " + "round(cast(b.longitude as numeric) ,6) 经度, round(cast(b.latitude as numeric) ,6) 纬度, b.fire_point_address 详细地址 from sys_user a left join fire_point b on " + "case when left(a.county_code, 4) = '0000' then left(b.county_code, 4) = left(a.county_code, 4) " + "when left(a.county_code, 2) = '00' then left(b.county_code, 2) = left(a.county_code, 2) " + "else left(b.county_code, 2) = left(a.county_code, 2) end where a.vip_level > 0 and satellite_time > ?1", nativeQuery = true)
|
||||||
List<Map<String, String>> list = firePointDao.downloadFirePointByVip(dateTimeToString(LocalDateTime.of(now.minusDays(1), LocalTime.MIN)));
|
// List<Map<String, String>> downloadFirePointByVip(String yesterday);
|
||||||
if (list.size() == 0) {
|
//
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "无数据!", locale);
|
// */
|
||||||
}
|
// @Override
|
||||||
int year = now.getYear();
|
// public String downloadVipUserFilePoint(HttpServletRequest request, HttpServletResponse response) {
|
||||||
int month = now.getMonth().getValue();
|
// LocalDate now = LocalDate.now();
|
||||||
int day = now.getDayOfMonth();
|
// List<Map<String, String>> list = firePointDao.downloadFirePointByVip(dateTimeToString(LocalDateTime.of(now.minusDays(1), LocalTime.MIN)));
|
||||||
String fileName = String.format("%s_%s_%s_VIP用户火点信息列表.xlsx", year, month, day);
|
// if (list.size() == 0) {
|
||||||
response.setContentType("application/octet-stream; charset=UTF8");
|
// return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "无数据!", locale);
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8));
|
// }
|
||||||
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
// int year = now.getYear();
|
||||||
try {
|
// int month = now.getMonth().getValue();
|
||||||
downloadXlsx(list, response.getOutputStream());
|
// int day = now.getDayOfMonth();
|
||||||
} catch (IOException e) {
|
// String fileName = String.format("%s_%s_%s_VIP用户火点信息列表.xlsx", year, month, day);
|
||||||
log.error("download vip user's fire point fail: {}", e.getMessage());
|
// response.setContentType("application/octet-stream; charset=UTF8");
|
||||||
}
|
// response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8));
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale);
|
// response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
}
|
// try {
|
||||||
|
// downloadXlsx(list, response.getOutputStream());
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// log.error("download vip user's fire point fail: {}", e.getMessage());
|
||||||
|
// }
|
||||||
|
// return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale);
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public String downloadFirePoint(HttpServletRequest request, HttpServletResponse response, String ids) {
|
// public String downloadFirePoint(HttpServletRequest request, HttpServletResponse response, String ids) {
|
||||||
|
//
|
||||||
List<String> idList = ListUtils.toStringList(ids, ",");
|
// List<String> idList = ListUtils.toStringList(ids, ",");
|
||||||
if (idList.isEmpty()) {
|
// if (idList.isEmpty()) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "无数据!", locale);
|
// return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "无数据!", locale);
|
||||||
}
|
// }
|
||||||
List<Map<String, String>> list = new ArrayList<>();
|
// List<Map<String, String>> list = new ArrayList<>();
|
||||||
List<FirePointEntity> sourceList = firePointDao.findAllById(ListUtils.stringListToLongList(idList));
|
// List<FirePointEntity> sourceList = firePointDao.findAllById(ListUtils.stringListToLongList(idList));
|
||||||
for (FirePointEntity source : sourceList) {
|
// for (FirePointEntity source : sourceList) {
|
||||||
Map<String, String> record = new HashMap<>();
|
// Map<String, String> record = new HashMap<>();
|
||||||
record.put("所在区县", source.getCountyName());
|
// record.put("所在区县", source.getCountyName());
|
||||||
record.put("所在街道", source.getStreetName());
|
// record.put("所在街道", source.getStreetName());
|
||||||
record.put("发现时间", source.getSatelliteTime());
|
// record.put("发现时间", source.getSatelliteTime());
|
||||||
record.put("地物类型", source.getLandType());
|
// record.put("地物类型", source.getLandType());
|
||||||
record.put("经度", String.valueOf(source.getLongitude()));
|
// record.put("经度", String.valueOf(source.getLongitude()));
|
||||||
record.put("纬度", String.valueOf(source.getLatitude()));
|
// record.put("纬度", String.valueOf(source.getLatitude()));
|
||||||
record.put("详细地址", source.getFirePointAddress());
|
// record.put("详细地址", source.getFirePointAddress());
|
||||||
list.add(record);
|
// list.add(record);
|
||||||
}
|
// }
|
||||||
LocalDate now = LocalDate.now();
|
// LocalDate now = LocalDate.now();
|
||||||
String fileName = String.format("%s_%s_%s_火点信息列表.xlsx", now.getYear(), now.getMonth().getValue(), now.getDayOfMonth());
|
// String fileName = String.format("%s_%s_%s_火点信息列表.xlsx", now.getYear(), now.getMonth().getValue(), now.getDayOfMonth());
|
||||||
response.setContentType("application/octet-stream; charset=UTF8");
|
// response.setContentType("application/octet-stream; charset=UTF8");
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8));
|
// response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8));
|
||||||
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
// response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
try {
|
// try {
|
||||||
downloadXlsx(list, response.getOutputStream());
|
// downloadXlsx(list, response.getOutputStream());
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
log.error("download fire point fail: {}", e.getMessage());
|
// log.error("download fire point fail: {}", e.getMessage());
|
||||||
}
|
// }
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale);
|
// return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete
|
* Complete
|
||||||
|
@ -1,21 +1,17 @@
|
|||||||
package com.xkrs.straw.controller;
|
package com.xkrs.straw.controller;
|
||||||
|
|
||||||
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
||||||
import com.xkrs.dao.FirePointDao;
|
|
||||||
import com.xkrs.service.FirePointService;
|
import com.xkrs.service.FirePointService;
|
||||||
import com.xkrs.service.StreetService;
|
import com.xkrs.service.StreetService;
|
||||||
import com.xkrs.service.impl.FirePointServiceImpl;
|
import com.xkrs.service.impl.FirePointServiceImpl;
|
||||||
import com.xkrs.straw.dao.SysUserDao;
|
import com.xkrs.straw.dao.SysUserDao;
|
||||||
import com.xkrs.straw.utils.FirePointQueryManager;
|
import com.xkrs.straw.utils.FirePointQueryManager;
|
||||||
import com.xkrs.utils.FirePointQueryHelper;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -36,15 +32,9 @@ public class FirePointController {
|
|||||||
@Resource
|
@Resource
|
||||||
private SysUserDao sysUserDao;
|
private SysUserDao sysUserDao;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private FirePointDao firePointDao;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private StreetService streetService;
|
private StreetService streetService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private FirePointQueryHelper firePointQueryHelper;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private FirePointQueryManager firePointQueryManager;
|
private FirePointQueryManager firePointQueryManager;
|
||||||
|
|
||||||
@ -69,21 +59,21 @@ public class FirePointController {
|
|||||||
// return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointList, locale);
|
// return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointList, locale);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* (Complete)
|
// * (Complete)
|
||||||
*/
|
// */
|
||||||
@RequestMapping(value = "/download/vipuserfirepoint", method = RequestMethod.GET)
|
// @RequestMapping(value = "/download/vipuserfirepoint", method = RequestMethod.GET)
|
||||||
public String downloadVipUserFirePoint(HttpServletResponse response, HttpServletRequest request) {
|
// public String downloadVipUserFirePoint(HttpServletResponse response, HttpServletRequest request) {
|
||||||
return firePointService.downloadVipUserFilePoint(request, response);
|
// return firePointService.downloadVipUserFilePoint(request, response);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* (Complete)
|
// * (Complete)
|
||||||
*/
|
// */
|
||||||
@RequestMapping(value = "/download/firepoint", method = RequestMethod.GET)
|
// @RequestMapping(value = "/download/firepoint", method = RequestMethod.GET)
|
||||||
public String downloadFirePoint(HttpServletResponse response, HttpServletRequest request, @RequestParam(value = "ids") String ids) {
|
// public String downloadFirePoint(HttpServletResponse response, HttpServletRequest request, @RequestParam(value = "ids") String ids) {
|
||||||
return firePointService.downloadFirePoint(request, response, ids);
|
// return firePointService.downloadFirePoint(request, response, ids);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 动态多条件查询火点列表(Complete)
|
* 动态多条件查询火点列表(Complete)
|
||||||
|
@ -5,8 +5,8 @@ import com.xiaomi.xmpush.server.Constants;
|
|||||||
import com.xiaomi.xmpush.server.Message;
|
import com.xiaomi.xmpush.server.Message;
|
||||||
import com.xiaomi.xmpush.server.Result;
|
import com.xiaomi.xmpush.server.Result;
|
||||||
import com.xiaomi.xmpush.server.Sender;
|
import com.xiaomi.xmpush.server.Sender;
|
||||||
import com.xkrs.model.entity.FirePointEntity;
|
|
||||||
import com.xkrs.straw.model.entity.SysUserEntity;
|
import com.xkrs.straw.model.entity.SysUserEntity;
|
||||||
|
import com.xkrs.straw.model.vo.AllFirePointVo;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -32,10 +32,10 @@ public class PushHelper {
|
|||||||
* 发起推送
|
* 发起推送
|
||||||
*
|
*
|
||||||
* @param userAccountList userAccount 非空白,不能包含逗号, 长度小于128
|
* @param userAccountList userAccount 非空白,不能包含逗号, 长度小于128
|
||||||
* @param firePointEntity
|
* @param firePoint
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void dispatchPushMessage(List<String> userAccountList, FirePointEntity firePointEntity) throws Exception {
|
public void dispatchPushMessage(List<String> userAccountList, AllFirePointVo firePoint) throws Exception {
|
||||||
Constants.useOfficial();
|
Constants.useOfficial();
|
||||||
Sender sender = new Sender("f6N7nchoqOWj3YyZiQPH2w==");
|
Sender sender = new Sender("f6N7nchoqOWj3YyZiQPH2w==");
|
||||||
String messagePayload = "This is a message";
|
String messagePayload = "This is a message";
|
||||||
|
@ -1,108 +0,0 @@
|
|||||||
package com.xkrs.utils;
|
|
||||||
|
|
||||||
import com.xkrs.dao.FirePointDao;
|
|
||||||
import com.xkrs.model.entity.FirePointEntity;
|
|
||||||
import org.apache.hc.core5.util.TextUtils;
|
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.persistence.criteria.Predicate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 火点查询工具类
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class FirePointQueryHelper {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private FirePointDao firePointDao;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 动态多条件查询火点列表
|
|
||||||
*
|
|
||||||
* @param code 区划编码,可以是省市区县街道任意编码,如果传需要至少两位。不传代表查询全国火点
|
|
||||||
* @param startTime 过滤火点开始卫星时间,不传代表不指定开始时间。后台会有限制。
|
|
||||||
* @param endTime 过滤火点结束卫星时间,不传代表不指定结束时间。
|
|
||||||
* @param satelliteType 过滤传感器类型,不传代表查询全部类型的传感器
|
|
||||||
* @param landType 过滤地物类型,不传代表查询全部地物类型
|
|
||||||
* @return 符合条件的火点列表
|
|
||||||
*/
|
|
||||||
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 (!TextUtils.isEmpty(code)) {
|
|
||||||
try {
|
|
||||||
String formatCutCode = FirePointCodeUtils.getFormatCutCode(code);
|
|
||||||
if (!TextUtils.isEmpty(formatCutCode)) {
|
|
||||||
predicateList.add(criteriaBuilder.like(root.get("streetCode").as(String.class), formatCutCode + "%"));
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//限制最早开始时间不得早于一个月
|
|
||||||
LocalDateTime lastMonth1 = LocalDateTime.now().minusDays(30);
|
|
||||||
LocalDateTime lastMonth2 = LocalDateTime.of(lastMonth1.getYear(), lastMonth1.getMonth(), lastMonth1.getDayOfMonth(), 0, 0, 0, 0);
|
|
||||||
String lastMonthString = DateTimeUtils.localDateTimeToString(lastMonth2);
|
|
||||||
// predicateList.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), lastMonthString));
|
|
||||||
//开始时间查询条件
|
|
||||||
if (!TextUtils.isEmpty(startTime)) {
|
|
||||||
LocalDateTime startTime1 = DateTimeUtils.stringToLocalDateTime(startTime);
|
|
||||||
LocalDateTime startTime2 = LocalDateTime.of(startTime1.getYear(), startTime1.getMonth(), startTime1.getDayOfMonth(), 0, 0, 0, 0);
|
|
||||||
String startTimeString = DateTimeUtils.localDateTimeToString(startTime2);
|
|
||||||
predicateList.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTimeString));
|
|
||||||
}
|
|
||||||
//结束时间查询条件
|
|
||||||
if (!TextUtils.isEmpty(endTime)) {
|
|
||||||
LocalDateTime endTime1 = DateTimeUtils.stringToLocalDateTime(endTime).plusDays(1);
|
|
||||||
LocalDateTime endTime2 = LocalDateTime.of(endTime1.getYear(), endTime1.getMonth(), endTime1.getDayOfMonth(), 0, 0, 0, 0);
|
|
||||||
String endTimeString = DateTimeUtils.localDateTimeToString(endTime2);
|
|
||||||
predicateList.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTimeString));
|
|
||||||
}
|
|
||||||
//卫星类型查询条件
|
|
||||||
if (!TextUtils.isEmpty(satelliteType)) {
|
|
||||||
predicateList.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType));
|
|
||||||
}
|
|
||||||
//地物类型查询条件
|
|
||||||
if (!TextUtils.isEmpty(landType)) {
|
|
||||||
predicateList.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
|
|
||||||
}
|
|
||||||
Predicate[] predicateArray = new Predicate[predicateList.size()];
|
|
||||||
return criteriaBuilder.and(predicateList.toArray(predicateArray));
|
|
||||||
};
|
|
||||||
return firePointDao.findAll(specification, Sort.by(Sort.Direction.DESC, "satelliteTime"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FirePointEntity> queryZZHD(String code, String startTime, String endTime) {
|
|
||||||
Specification<FirePointEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
|
|
||||||
//查询条件集合
|
|
||||||
List<Predicate> predicateList = new ArrayList<>();
|
|
||||||
predicateList.add(criteriaBuilder.equal(root.get("countyCode").as(String.class), code));
|
|
||||||
//开始时间查询条件
|
|
||||||
if (!TextUtils.isEmpty(startTime)) {
|
|
||||||
LocalDateTime startTime1 = DateTimeUtils.stringToLocalDateTime(startTime);
|
|
||||||
LocalDateTime startTime2 = LocalDateTime.of(startTime1.getYear(), startTime1.getMonth(), startTime1.getDayOfMonth(), 0, 0, 0, 0);
|
|
||||||
String startTimeString = DateTimeUtils.localDateTimeToString(startTime2);
|
|
||||||
predicateList.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTimeString));
|
|
||||||
}
|
|
||||||
//结束时间查询条件
|
|
||||||
if (!TextUtils.isEmpty(endTime)) {
|
|
||||||
LocalDateTime endTime1 = DateTimeUtils.stringToLocalDateTime(endTime).plusDays(1);
|
|
||||||
LocalDateTime endTime2 = LocalDateTime.of(endTime1.getYear(), endTime1.getMonth(), endTime1.getDayOfMonth(), 0, 0, 0, 0);
|
|
||||||
String endTimeString = DateTimeUtils.localDateTimeToString(endTime2);
|
|
||||||
predicateList.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTimeString));
|
|
||||||
}
|
|
||||||
Predicate[] predicateArray = new Predicate[predicateList.size()];
|
|
||||||
return criteriaBuilder.and(predicateList.toArray(predicateArray));
|
|
||||||
};
|
|
||||||
return firePointDao.findAll(specification, Sort.by(Sort.Direction.DESC, "satelliteTime"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -8,10 +8,10 @@
|
|||||||
<Properties>
|
<Properties>
|
||||||
<!-- 格式化输出:%date表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %msg:日志消息,%n是换行符-->
|
<!-- 格式化输出:%date表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %msg:日志消息,%n是换行符-->
|
||||||
<!-- %logger{36} 表示 Logger 名字最长36个字符 -->
|
<!-- %logger{36} 表示 Logger 名字最长36个字符 -->
|
||||||
<property name="LOG_PATTERN" value="%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n" />
|
<property name="LOG_PATTERN" value="%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"/>
|
||||||
<!-- 定义日志存储的路径 -->
|
<!-- 定义日志存储的路径 -->
|
||||||
<property name="FILE_PATH" value="/home/lcq/logs/fire_point" />
|
<property name="FILE_PATH" value="/home/lcq/logs/straw_fire_point"/>
|
||||||
<property name="FILE_NAME" value="fire_point" />
|
<property name="FILE_NAME" value="straw_fire_point"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
|
||||||
<appenders>
|
<appenders>
|
||||||
@ -29,7 +29,8 @@
|
|||||||
</File>
|
</File>
|
||||||
|
|
||||||
<!-- 这个会打印出所有的info及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
|
<!-- 这个会打印出所有的info及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
|
||||||
<RollingFile name="RollingFileInfo" fileName="${FILE_PATH}/info.log" filePattern="${FILE_PATH}/${FILE_NAME}-INFO-%d{yyyy-MM-dd}_%i.log.gz">
|
<RollingFile name="RollingFileInfo" fileName="${FILE_PATH}/info.log"
|
||||||
|
filePattern="${FILE_PATH}/${FILE_NAME}-INFO-%d{yyyy-MM-dd}_%i.log.gz">
|
||||||
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
||||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||||
@ -43,7 +44,8 @@
|
|||||||
</RollingFile>
|
</RollingFile>
|
||||||
|
|
||||||
<!-- 这个会打印出所有的warn及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
|
<!-- 这个会打印出所有的warn及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
|
||||||
<RollingFile name="RollingFileWarn" fileName="${FILE_PATH}/warn.log" filePattern="${FILE_PATH}/${FILE_NAME}-WARN-%d{yyyy-MM-dd}_%i.log.gz">
|
<RollingFile name="RollingFileWarn" fileName="${FILE_PATH}/warn.log"
|
||||||
|
filePattern="${FILE_PATH}/${FILE_NAME}-WARN-%d{yyyy-MM-dd}_%i.log.gz">
|
||||||
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
||||||
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||||
@ -57,7 +59,8 @@
|
|||||||
</RollingFile>
|
</RollingFile>
|
||||||
|
|
||||||
<!-- 这个会打印出所有的error及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
|
<!-- 这个会打印出所有的error及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
|
||||||
<RollingFile name="RollingFileError" fileName="${FILE_PATH}/error.log" filePattern="${FILE_PATH}/${FILE_NAME}-ERROR-%d{yyyy-MM-dd}_%i.log.gz">
|
<RollingFile name="RollingFileError" fileName="${FILE_PATH}/error.log"
|
||||||
|
filePattern="${FILE_PATH}/${FILE_NAME}-ERROR-%d{yyyy-MM-dd}_%i.log.gz">
|
||||||
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
||||||
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user