From ea357838eef9e5f4e98c04a7e0bfd57e5726e849 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Tue, 26 Jul 2022 15:57:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E9=80=82=E9=85=8D=20?= =?UTF-8?q?=E5=BC=A0=E5=BA=84=20=E7=81=AB=E7=82=B9=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xkrs/common/config/WebSecurityConfig.java | 1 + .../xkrs/controller/FirePointController.java | 23 +++++++++++++++++ .../com/xkrs/utils/FirePointQueryHelper.java | 25 +++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java index 247ab1d..d4c3d80 100644 --- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -48,6 +48,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers(HttpMethod.POST, "/api/person-investigator/add").permitAll() .antMatchers("/ws/asset").permitAll() .antMatchers(HttpMethod.GET, "/api/user/booleanUserName").permitAll() + .antMatchers(HttpMethod.GET, "/queryzzhd").permitAll() .antMatchers(HttpMethod.POST, "/insertFirePoint").permitAll() .antMatchers(HttpMethod.POST, "/insertfirepointchanneltwo").permitAll() .antMatchers(HttpMethod.POST, "/insertAppTask").permitAll() diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index ba81a44..3ebccc9 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -59,6 +59,29 @@ public class FirePointController { @Resource private FirePointQueryHelper firePointQueryHelper; + @GetMapping("/queryzzhd") + public String queryzzhd() { + Locale locale = LocaleContextHolder.getLocale(); + + List firePointEntities1 = firePointQueryHelper.queryZZHD("371482", "2022-01-01 00:00:10", null); + List firePointEntities2 = firePointQueryHelper.queryZZHD("371403", "2022-01-01 00:00:10", null); + List firePointEntities3 = firePointQueryHelper.queryZZHD("371426", "2022-01-01 00:00:10", null); + List firePointEntities4 = firePointQueryHelper.queryZZHD("371424", "2022-01-01 00:00:10", null); + List firePointEntities5 = firePointQueryHelper.queryZZHD("371526", "2022-01-01 00:00:10", null); + List firePointEntities6 = firePointQueryHelper.queryZZHD("371425", "2022-01-01 00:00:10", null); + List firePointEntities7 = firePointQueryHelper.queryZZHD("371503", "2022-01-01 00:00:10", null); + + List firePointList = new ArrayList<>(); + firePointList.addAll(firePointEntities1); + firePointList.addAll(firePointEntities2); + firePointList.addAll(firePointEntities3); + firePointList.addAll(firePointEntities4); + firePointList.addAll(firePointEntities5); + firePointList.addAll(firePointEntities6); + firePointList.addAll(firePointEntities7); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointList, locale); + } + /** * 添加火点数据 * diff --git a/src/main/java/com/xkrs/utils/FirePointQueryHelper.java b/src/main/java/com/xkrs/utils/FirePointQueryHelper.java index b0ba661..dda71bc 100644 --- a/src/main/java/com/xkrs/utils/FirePointQueryHelper.java +++ b/src/main/java/com/xkrs/utils/FirePointQueryHelper.java @@ -70,4 +70,29 @@ public class FirePointQueryHelper { 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); + LocalDateTime endTime2 = LocalDateTime.of(endTime1.getYear(), endTime1.getMonth(), endTime1.getDayOfMonth() + 1, 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