From e5164f476698776730d2f51ec6cec73f2de800fb Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Fri, 3 Mar 2023 11:02:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xkrs/service/FirePointService.java | 4 +++ .../service/impl/FirePointServiceImpl.java | 32 +++++++++++++++++++ .../straw/controller/FirePointController.java | 8 ++--- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/xkrs/service/FirePointService.java b/src/main/java/com/xkrs/service/FirePointService.java index d3d527e..75f5eb2 100644 --- a/src/main/java/com/xkrs/service/FirePointService.java +++ b/src/main/java/com/xkrs/service/FirePointService.java @@ -38,4 +38,8 @@ public interface FirePointService { */ String selectTodayFirePoint(String token, String countyCode); + /** + * 根据火点编码查询火点信息 (Complete) + */ + String selectFirePointByCode(String fireCode); } diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 3d03251..1e9d019 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -10,11 +10,15 @@ import com.xkrs.model.qo.FirePointQo; import com.xkrs.model.vo.GaoDeIgGeocodeVo; import com.xkrs.service.FirePointService; import com.xkrs.service.StreetService; +import com.xkrs.straw.dao.FirePointOrdinaryDao; import com.xkrs.straw.dao.SysUserDao; import com.xkrs.straw.model.bean.FirePointQueryResultBean; +import com.xkrs.straw.model.entity.FirePointOrdinaryEntity; import com.xkrs.straw.model.entity.SysUserEntity; import com.xkrs.straw.model.helper.PushHelper; import com.xkrs.straw.model.helper.SMSHelper; +import com.xkrs.straw.model.vo.AllFirePointVo; +import com.xkrs.straw.utils.FirePointConvertUtils; import com.xkrs.straw.utils.FirePointQueryManager; import com.xkrs.utils.*; import org.apache.hc.core5.util.TextUtils; @@ -23,9 +27,12 @@ import org.slf4j.LoggerFactory; import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheEvict; import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.domain.Specification; 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; @@ -79,6 +86,8 @@ public class FirePointServiceImpl implements FirePointService { @Resource private FirePointQueryManager firePointQueryManager; + @Resource + private FirePointOrdinaryDao firePointOrdinaryDao; /** * 添加火点信息 @@ -335,4 +344,27 @@ public class FirePointServiceImpl implements FirePointService { } } + /** + * 根据火点编码查询火点信息 (Complete) + */ + @Override + public String selectFirePointByCode(String fireCode) { + if (TextUtils.isEmpty(fireCode)) { + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, null, locale); + } + Specification specification = (root, criteriaQuery, criteriaBuilder) -> { + //查询条件集合 + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.equal(root.get("fireCode").as(String.class), fireCode)); + Predicate[] predicateArray = new Predicate[predicateList.size()]; + return criteriaBuilder.and(predicateList.toArray(predicateArray)); + }; + List firePointOrdinaryList = firePointOrdinaryDao.findAll(specification, Sort.by(Sort.Direction.DESC, "satelliteTime")); + if (firePointOrdinaryList.size() == 1) { + AllFirePointVo firePointVo = FirePointConvertUtils.convert(firePointOrdinaryList.get(0)); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointVo, locale); + } + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, null, locale); + } + } diff --git a/src/main/java/com/xkrs/straw/controller/FirePointController.java b/src/main/java/com/xkrs/straw/controller/FirePointController.java index 1c95d1e..a3139b0 100644 --- a/src/main/java/com/xkrs/straw/controller/FirePointController.java +++ b/src/main/java/com/xkrs/straw/controller/FirePointController.java @@ -2,7 +2,6 @@ package com.xkrs.straw.controller; import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.dao.FirePointDao; -import com.xkrs.model.entity.FirePointEntity; import com.xkrs.model.qo.FirePointQo; import com.xkrs.service.FirePointService; import com.xkrs.service.StreetService; @@ -151,12 +150,11 @@ public class FirePointController { } /** - * 根据火点编码查询火点信息 + * 根据火点编码查询火点信息 (Complete) */ @GetMapping("/selectFirePointByCode") - public String selectFirePoint(@RequestParam("fireCode") String fireCode) { - FirePointEntity byFireCode = firePointDao.findByFireCode(fireCode); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFireCode, locale); + public String selectFirePointByCode(@RequestParam("fireCode") String fireCode) { + return firePointService.selectFirePointByCode(fireCode); } }