From 68b514d815ecb166199cf94be131ed78b759723e Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Fri, 3 Jun 2022 15:21:57 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E5=BE=AE=E4=BF=A1=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E6=96=87=E6=A1=88=202.=E6=8C=89=E7=85=A7=E5=8D=AB?= =?UTF-8?q?=E6=98=9F=E6=97=B6=E9=97=B4=E5=80=92=E5=BA=8F=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=81=AB=E7=82=B9=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xkrs/controller/FirePointController.java | 5 ++- .../service/impl/FirePointServiceImpl.java | 40 +++++++++++-------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index 53a7aec..3e15102 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -18,6 +18,7 @@ import com.xkrs.service.FirePointService; import com.xkrs.service.StreetService; import com.xkrs.websocket.service.WebSocketServer; import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -104,7 +105,7 @@ public class FirePointController { @GetMapping("/queryshandongfirepointlist") public String queryShanDongFirePointList() { Locale locale = LocaleContextHolder.getLocale(); - List shanDongFirePointList = shanDongFirePointDao.findAll(); + List shanDongFirePointList = shanDongFirePointDao.findAll(Sort.by(Sort.Direction.DESC, "satelliteTime")); if (shanDongFirePointList.isEmpty()) { return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale); } @@ -155,7 +156,7 @@ public class FirePointController { Predicate[] predicates = new Predicate[list.size()]; return criteriaBuilder.and(list.toArray(predicates)); }; - List shanDongFirePointList = shanDongFirePointDao.findAll(specification); + List shanDongFirePointList = shanDongFirePointDao.findAll(specification, Sort.by(Sort.Direction.DESC, "satelliteTime")); if (shanDongFirePointList.isEmpty()) { return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale); } diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 710ddf6..3b6f415 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -203,16 +203,8 @@ public class FirePointServiceImpl implements FirePointService { log.info("-------发现新山东火点"); ShanDongFirePointEntity savedFirePointEntity = shanDongFirePointDao.save(firePointEntity); try {//微信消息通知工作组 - java.text.DecimalFormat decimalFormat = new DecimalFormat("#.000000"); - String formatLongitude = decimalFormat.format(firePointEntity.getLongitude()); - String formatLatitude = decimalFormat.format(firePointEntity.getLatitude()); - String countyName = firePointEntity.getCountyName(); - String content = firePointEntity.getSatelliteType() + "发现1个火点。\nlongitude:" + formatLongitude + ";\nlatitude:" + formatLatitude + ";\ncountyName:" + countyName; - try { - WDWxSendMsgUtil.sendMsg("18447024917@chatroom", content, 0); - } catch (Exception e) { - e.printStackTrace(); - } + String messageContent = getMessageContent(firePointEntity); + WDWxSendMsgUtil.sendMsg("18447024917@chatroom", messageContent, 0); } catch (Exception e) { e.printStackTrace(); } @@ -350,14 +342,10 @@ public class FirePointServiceImpl implements FirePointService { } } if (weixinIdList.size() > 0) { - java.text.DecimalFormat decimalFormat = new DecimalFormat("#.000000"); - String formatLongitude = decimalFormat.format(firePointEntity.getLongitude()); - String formatLatitude = decimalFormat.format(firePointEntity.getLatitude()); - String countyName = firePointEntity.getCountyName(); - String content = firePointEntity.getSatelliteType() + "发现1个火点。\nlongitude:" + formatLongitude + ";\nlatitude:" + formatLatitude + ";\ncountyName:" + countyName; + String messageContent = getMessageContent(firePointEntity); for (String weixinId : weixinIdList) { try { - WDWxSendMsgUtil.sendMsg(weixinId, content, 0); + WDWxSendMsgUtil.sendMsg(weixinId, messageContent, 0); } catch (Exception e) { e.printStackTrace(); } @@ -365,6 +353,26 @@ public class FirePointServiceImpl implements FirePointService { } } + private String getMessageContent(FirePointEntity firePointEntity) { + java.text.DecimalFormat decimalFormat = new DecimalFormat("#.000000"); + String satelliteTime = firePointEntity.getSatelliteTime(); + String formatLongitude = decimalFormat.format(firePointEntity.getLongitude()); + String formatLatitude = decimalFormat.format(firePointEntity.getLatitude()); + String countyName = firePointEntity.getCountyName(); + String content = firePointEntity.getSatelliteType() + "发现1个火点。\n卫星时间:" + satelliteTime + ";\nlongitude:" + formatLongitude + ";\nlatitude:" + formatLatitude + ";\ncountyName:" + countyName; + return content; + } + + private String getMessageContent(ShanDongFirePointEntity firePointEntity) { + java.text.DecimalFormat decimalFormat = new DecimalFormat("#.000000"); + String satelliteTime = firePointEntity.getSatelliteTime(); + String formatLongitude = decimalFormat.format(firePointEntity.getLongitude()); + String formatLatitude = decimalFormat.format(firePointEntity.getLatitude()); + String countyName = firePointEntity.getCountyName(); + String content = firePointEntity.getSatelliteType() + "发现1个待审核火点。\n卫星时间:" + satelliteTime + ";\nlongitude:" + formatLongitude + ";\nlatitude:" + formatLatitude + ";\ncountyName:" + countyName; + return content; + } + /** * 发送短信消息 *