diff --git a/pom.xml b/pom.xml index 9de937c..bf2bb2c 100644 --- a/pom.xml +++ b/pom.xml @@ -9,9 +9,9 @@ com.xkrs - fire_point + straw_fire_point 0.0.1 - fire_point + straw_fire_point 火点项目 5.19 diff --git a/src/main/java/com/xkrs/dao/FirePointDao.java b/src/main/java/com/xkrs/dao/FirePointDao.java deleted file mode 100644 index 9bc4e1c..0000000 --- a/src/main/java/com/xkrs/dao/FirePointDao.java +++ /dev/null @@ -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, JpaSpecificationExecutor { - - @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> downloadFirePointByVip(String yesterday); - -} diff --git a/src/main/java/com/xkrs/model/entity/FirePointEntity.java b/src/main/java/com/xkrs/model/entity/FirePointEntity.java deleted file mode 100644 index 66665e5..0000000 --- a/src/main/java/com/xkrs/model/entity/FirePointEntity.java +++ /dev/null @@ -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 + '\'' + - '}'; - } -} diff --git a/src/main/java/com/xkrs/service/FirePointService.java b/src/main/java/com/xkrs/service/FirePointService.java index 0a7f4e8..f339e43 100644 --- a/src/main/java/com/xkrs/service/FirePointService.java +++ b/src/main/java/com/xkrs/service/FirePointService.java @@ -1,19 +1,16 @@ package com.xkrs.service; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - /** * @author XinYi Song */ public interface FirePointService { - /** - * download vip user's fire point - */ - String downloadVipUserFilePoint(HttpServletRequest request, HttpServletResponse response); +// /** +// * download vip user's fire point +// */ +// String downloadVipUserFilePoint(HttpServletRequest request, HttpServletResponse response); - String downloadFirePoint(HttpServletRequest request, HttpServletResponse response, String ids); +// String downloadFirePoint(HttpServletRequest request, HttpServletResponse response, String ids); /** * (Complete) diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 9e4802a..cffbbc8 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -2,9 +2,7 @@ package com.xkrs.service.impl; import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.dao.CountyCodeWeiXinDao; -import com.xkrs.dao.FirePointDao; import com.xkrs.dao.StreetDao; -import com.xkrs.model.entity.FirePointEntity; import com.xkrs.service.FirePointService; import com.xkrs.service.StreetService; 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.FirePointQueryManager; import com.xkrs.utils.DateTimeUtils; -import com.xkrs.utils.FirePointQueryHelper; -import com.xkrs.utils.ListUtils; import com.xkrs.utils.TokenUtil; import org.apache.hc.core5.util.TextUtils; import org.slf4j.Logger; @@ -32,19 +28,12 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; 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.LocalTime; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; 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 @@ -57,9 +46,6 @@ public class FirePointServiceImpl implements FirePointService { private final Locale locale = LocaleContextHolder.getLocale(); - @Resource - private FirePointDao firePointDao; - @Resource private SysUserDao sysUserDao; @@ -69,9 +55,6 @@ public class FirePointServiceImpl implements FirePointService { @Resource private CountyCodeWeiXinDao countyCodeWeiXinDao; - @Resource - private FirePointQueryHelper firePointQueryHelper; - @Resource private StreetService streetService; @@ -87,63 +70,69 @@ public class FirePointServiceImpl implements FirePointService { @Resource private FirePointOrdinaryDao firePointOrdinaryDao; - /** - * 下载VIP用户火点数据 - */ - @Override - public String downloadVipUserFilePoint(HttpServletRequest request, HttpServletResponse response) { - LocalDate now = LocalDate.now(); - List> list = firePointDao.downloadFirePointByVip(dateTimeToString(LocalDateTime.of(now.minusDays(1), LocalTime.MIN))); - if (list.size() == 0) { - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "无数据!", locale); - } - int year = now.getYear(); - int month = now.getMonth().getValue(); - int day = now.getDayOfMonth(); - String fileName = String.format("%s_%s_%s_VIP用户火点信息列表.xlsx", year, month, day); - response.setContentType("application/octet-stream; charset=UTF8"); - response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8)); - 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); - } +// /** +// * 下载VIP用户火点数据 +// * +// * +// * +// @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> downloadFirePointByVip(String yesterday); +// +// */ +// @Override +// public String downloadVipUserFilePoint(HttpServletRequest request, HttpServletResponse response) { +// LocalDate now = LocalDate.now(); +// List> list = firePointDao.downloadFirePointByVip(dateTimeToString(LocalDateTime.of(now.minusDays(1), LocalTime.MIN))); +// if (list.size() == 0) { +// return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "无数据!", locale); +// } +// int year = now.getYear(); +// int month = now.getMonth().getValue(); +// int day = now.getDayOfMonth(); +// String fileName = String.format("%s_%s_%s_VIP用户火点信息列表.xlsx", year, month, day); +// response.setContentType("application/octet-stream; charset=UTF8"); +// response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8)); +// 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 - public String downloadFirePoint(HttpServletRequest request, HttpServletResponse response, String ids) { - - List idList = ListUtils.toStringList(ids, ","); - if (idList.isEmpty()) { - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "无数据!", locale); - } - List> list = new ArrayList<>(); - List sourceList = firePointDao.findAllById(ListUtils.stringListToLongList(idList)); - for (FirePointEntity source : sourceList) { - Map record = new HashMap<>(); - record.put("所在区县", source.getCountyName()); - record.put("所在街道", source.getStreetName()); - record.put("发现时间", source.getSatelliteTime()); - record.put("地物类型", source.getLandType()); - record.put("经度", String.valueOf(source.getLongitude())); - record.put("纬度", String.valueOf(source.getLatitude())); - record.put("详细地址", source.getFirePointAddress()); - list.add(record); - } - LocalDate now = LocalDate.now(); - String fileName = String.format("%s_%s_%s_火点信息列表.xlsx", now.getYear(), now.getMonth().getValue(), now.getDayOfMonth()); - response.setContentType("application/octet-stream; charset=UTF8"); - response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8)); - response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); - try { - downloadXlsx(list, response.getOutputStream()); - } catch (IOException e) { - log.error("download fire point fail: {}", e.getMessage()); - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale); - } +// @Override +// public String downloadFirePoint(HttpServletRequest request, HttpServletResponse response, String ids) { +// +// List idList = ListUtils.toStringList(ids, ","); +// if (idList.isEmpty()) { +// return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "无数据!", locale); +// } +// List> list = new ArrayList<>(); +// List sourceList = firePointDao.findAllById(ListUtils.stringListToLongList(idList)); +// for (FirePointEntity source : sourceList) { +// Map record = new HashMap<>(); +// record.put("所在区县", source.getCountyName()); +// record.put("所在街道", source.getStreetName()); +// record.put("发现时间", source.getSatelliteTime()); +// record.put("地物类型", source.getLandType()); +// record.put("经度", String.valueOf(source.getLongitude())); +// record.put("纬度", String.valueOf(source.getLatitude())); +// record.put("详细地址", source.getFirePointAddress()); +// list.add(record); +// } +// LocalDate now = LocalDate.now(); +// String fileName = String.format("%s_%s_%s_火点信息列表.xlsx", now.getYear(), now.getMonth().getValue(), now.getDayOfMonth()); +// response.setContentType("application/octet-stream; charset=UTF8"); +// response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8)); +// response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); +// try { +// downloadXlsx(list, response.getOutputStream()); +// } catch (IOException e) { +// log.error("download fire point fail: {}", e.getMessage()); +// } +// return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale); +// } /** * Complete diff --git a/src/main/java/com/xkrs/straw/controller/FirePointController.java b/src/main/java/com/xkrs/straw/controller/FirePointController.java index 0f3eb51..dca177b 100644 --- a/src/main/java/com/xkrs/straw/controller/FirePointController.java +++ b/src/main/java/com/xkrs/straw/controller/FirePointController.java @@ -1,21 +1,17 @@ package com.xkrs.straw.controller; import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.dao.FirePointDao; import com.xkrs.service.FirePointService; import com.xkrs.service.StreetService; import com.xkrs.service.impl.FirePointServiceImpl; import com.xkrs.straw.dao.SysUserDao; import com.xkrs.straw.utils.FirePointQueryManager; -import com.xkrs.utils.FirePointQueryHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -36,15 +32,9 @@ public class FirePointController { @Resource private SysUserDao sysUserDao; - @Resource - private FirePointDao firePointDao; - @Resource private StreetService streetService; - @Resource - private FirePointQueryHelper firePointQueryHelper; - @Resource private FirePointQueryManager firePointQueryManager; @@ -69,21 +59,21 @@ public class FirePointController { // return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointList, locale); // } - /** - * (Complete) - */ - @RequestMapping(value = "/download/vipuserfirepoint", method = RequestMethod.GET) - public String downloadVipUserFirePoint(HttpServletResponse response, HttpServletRequest request) { - return firePointService.downloadVipUserFilePoint(request, response); - } +// /** +// * (Complete) +// */ +// @RequestMapping(value = "/download/vipuserfirepoint", method = RequestMethod.GET) +// public String downloadVipUserFirePoint(HttpServletResponse response, HttpServletRequest request) { +// return firePointService.downloadVipUserFilePoint(request, response); +// } - /** - * (Complete) - */ - @RequestMapping(value = "/download/firepoint", method = RequestMethod.GET) - public String downloadFirePoint(HttpServletResponse response, HttpServletRequest request, @RequestParam(value = "ids") String ids) { - return firePointService.downloadFirePoint(request, response, ids); - } +// /** +// * (Complete) +// */ +// @RequestMapping(value = "/download/firepoint", method = RequestMethod.GET) +// public String downloadFirePoint(HttpServletResponse response, HttpServletRequest request, @RequestParam(value = "ids") String ids) { +// return firePointService.downloadFirePoint(request, response, ids); +// } /** * 动态多条件查询火点列表(Complete) diff --git a/src/main/java/com/xkrs/straw/model/helper/PushHelper.java b/src/main/java/com/xkrs/straw/model/helper/PushHelper.java index e846d4f..8991589 100644 --- a/src/main/java/com/xkrs/straw/model/helper/PushHelper.java +++ b/src/main/java/com/xkrs/straw/model/helper/PushHelper.java @@ -5,8 +5,8 @@ import com.xiaomi.xmpush.server.Constants; import com.xiaomi.xmpush.server.Message; import com.xiaomi.xmpush.server.Result; import com.xiaomi.xmpush.server.Sender; -import com.xkrs.model.entity.FirePointEntity; import com.xkrs.straw.model.entity.SysUserEntity; +import com.xkrs.straw.model.vo.AllFirePointVo; import org.springframework.stereotype.Component; import java.util.ArrayList; @@ -32,10 +32,10 @@ public class PushHelper { * 发起推送 * * @param userAccountList userAccount 非空白,不能包含逗号, 长度小于128 - * @param firePointEntity + * @param firePoint * @throws Exception */ - public void dispatchPushMessage(List userAccountList, FirePointEntity firePointEntity) throws Exception { + public void dispatchPushMessage(List userAccountList, AllFirePointVo firePoint) throws Exception { Constants.useOfficial(); Sender sender = new Sender("f6N7nchoqOWj3YyZiQPH2w=="); String messagePayload = "This is a message"; diff --git a/src/main/java/com/xkrs/utils/FirePointQueryHelper.java b/src/main/java/com/xkrs/utils/FirePointQueryHelper.java deleted file mode 100644 index 4a5f1a2..0000000 --- a/src/main/java/com/xkrs/utils/FirePointQueryHelper.java +++ /dev/null @@ -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 queryFirePoint(String code, String startTime, String endTime, String satelliteType, String landType) { - Specification specification = (root, criteriaQuery, criteriaBuilder) -> { - //查询条件集合 - List 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 queryZZHD(String code, String startTime, String endTime) { - Specification specification = (root, criteriaQuery, criteriaBuilder) -> { - //查询条件集合 - List 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")); - } - -} \ No newline at end of file diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml index 7f8bffc..51d8d6f 100644 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -8,10 +8,10 @@ - + - - + + @@ -29,7 +29,8 @@ - + @@ -43,7 +44,8 @@ - + @@ -57,7 +59,8 @@ - +