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; + } + /** * 发送短信消息 *