From d2ba8cc959c81573474d6572a4920dd6674a236b Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Tue, 23 Aug 2022 11:06:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=81=AB=E7=82=B9=E5=85=A5?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xkrs/controller/FirePointController.java | 16 +++--- .../com/xkrs/service/FirePointService.java | 4 +- .../service/impl/FirePointServiceImpl.java | 55 ++++++++----------- 3 files changed, 34 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index 4ab2c2e..ace51e5 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -87,11 +87,11 @@ public class FirePointController { */ @PostMapping("/insertFirePoint") public String insertFirePoint(@RequestBody FirePointQo firePointQo) { - FirePointEntity firePointEntity = firePointService.insertFirePoint(firePointQo); - if (firePointEntity == null) { - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "添加数据失败", locale); - } else { + boolean success = firePointService.insertFirePoint(firePointQo); + if (success) { return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale); + } else { + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "添加失败", locale); } } @@ -103,11 +103,11 @@ public class FirePointController { */ @PostMapping("/insertfirepointchanneltwo") public String insertFirePointChannelTwo(@RequestBody FirePointQo firePointQo) { - ShanDongFirePointEntity firePointEntity = firePointService.insertFirePointChannelTwo(firePointQo); - if (firePointEntity == null) { - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "添加数据失败", locale); - } else { + boolean success = firePointService.insertFirePointChannelTwo(firePointQo); + if (success) { return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale); + } else { + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "添加失败", locale); } } diff --git a/src/main/java/com/xkrs/service/FirePointService.java b/src/main/java/com/xkrs/service/FirePointService.java index 0f1e8a0..f5335de 100644 --- a/src/main/java/com/xkrs/service/FirePointService.java +++ b/src/main/java/com/xkrs/service/FirePointService.java @@ -22,7 +22,7 @@ public interface FirePointService { * @param firePointQo * @return */ - FirePointEntity insertFirePoint(FirePointQo firePointQo); + boolean insertFirePoint(FirePointQo firePointQo); /** * 添加火点信息 @@ -30,7 +30,7 @@ public interface FirePointService { * @param firePointQo * @return */ - ShanDongFirePointEntity insertFirePointChannelTwo(FirePointQo firePointQo); + boolean insertFirePointChannelTwo(FirePointQo firePointQo); /** * 查询今天的火点信息 diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 278e6da..4123640 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -95,21 +95,17 @@ public class FirePointServiceImpl implements FirePointService { /** * 添加火点信息 - * - * @param firePointQo - * @return */ @CacheEvict(value = "FirePointServiceCache", allEntries = true) @Override - public FirePointEntity insertFirePoint(FirePointQo firePointQo) { - if (firePointQo.getLandtype().equals("水体")) { - return null; + public boolean insertFirePoint(FirePointQo firePointQo) { + if ("水体".equals(firePointQo.getLandtype())) { + return false; } - if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "L".equals(firePointQo.getConfidence())) { - return null; - } - if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "N".equals(firePointQo.getConfidence())) { - return null; + if ("Himawari 8".equals(firePointQo.getSatelliteType())) { + if ("N".equals(firePointQo.getConfidence()) || "L".equals(firePointQo.getConfidence())) { + return false; + } } FirePointEntity firePointEntity = new FirePointEntity(); firePointEntity.setFireCode(firePointQo.getFireCode()); @@ -133,33 +129,30 @@ public class FirePointServiceImpl implements FirePointService { System.out.println("添加火点信息 逆地理编码请求街道编号失败:" + e.getMessage()); } if (firePointEntity.getCountyCode().startsWith("37")) { - return null; + return false; } FirePointEntity existFireCode = firePointDao.findByFireCode(firePointEntity.getFireCode()); if (existFireCode != null) { - return null; + return false; } log.info("-------发现新火点"); - return firePointDao.save(firePointEntity); + firePointDao.save(firePointEntity); + return true; } /** * 添加火点信息 - * - * @param firePointQo - * @return */ @CacheEvict(value = "FirePointServiceCache", allEntries = true) @Override - public ShanDongFirePointEntity insertFirePointChannelTwo(FirePointQo firePointQo) { - if (firePointQo.getLandtype().equals("水体")) { - return null; + public boolean insertFirePointChannelTwo(FirePointQo firePointQo) { + if ("水体".equals(firePointQo.getLandtype())) { + return false; } - if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "L".equals(firePointQo.getConfidence())) { - return null; - } - if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "N".equals(firePointQo.getConfidence())) { - return null; + if ("Himawari 8".equals(firePointQo.getSatelliteType())) { + if ("N".equals(firePointQo.getConfidence()) || "L".equals(firePointQo.getConfidence())) { + return false; + } } ShanDongFirePointEntity shanDongFirePoint = new ShanDongFirePointEntity(); shanDongFirePoint.setFireCode(firePointQo.getFireCode()); @@ -188,7 +181,7 @@ public class FirePointServiceImpl implements FirePointService { //如果开关已打开,就只将未审核的火点添加到山东临时表 if (shanDongFirePointDao.findByFireCode(shanDongFirePoint.getFireCode()) != null) { //山东临时表已经有编号相同的火点存在,返回添加失败 - return null; + return false; } log.info("-------发现新山东火点"); ShanDongFirePointEntity savedShanDongFirePoint = shanDongFirePointDao.save(shanDongFirePoint); @@ -198,16 +191,16 @@ public class FirePointServiceImpl implements FirePointService { } catch (Exception e) { e.printStackTrace(); } - return savedShanDongFirePoint; + return true; } else { //如果开关已关闭,就将火点添加到山东临时表,同时自动审核通过添加到全国火点表 if (shanDongFirePointDao.findByFireCode(shanDongFirePoint.getFireCode()) != null) { //山东临时表已经有编号相同的火点存在,返回添加失败 - return null; + return false; } if (firePointDao.findByFireCode(shanDongFirePoint.getFireCode()) != null) { //全国火点表已经有编号相同的火点存在,返回添加失败 - return null; + return false; } log.info("-------发现新火点"); shanDongFirePoint.setVerifyState("1"); @@ -218,10 +211,10 @@ public class FirePointServiceImpl implements FirePointService { firePointDao.save(firePoint); //发送消息通知 sendBroadcast(firePoint); - return savedShanDongFirePoint; + return true; } } - return null; + return false; } /**