From ce85cf0b42af120e1d41b8dec6fe7f1d38e62b28 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Wed, 29 Mar 2023 10:56:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=81=AB=E7=82=B9=E9=87=8D=E6=9E=84-=E5=B0=BD?= =?UTF-8?q?=E6=97=A9=E6=A3=80=E6=9F=A5=E9=87=8D=E5=A4=8D=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E5=87=8F=E5=B0=91=E4=B8=8D=E5=BF=85=E8=A6=81=E6=93=8D?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DispatchFirePointServiceImpl.java | 7 ++--- .../xkrs/utilsnew/FirePointFilterUtils.java | 31 ++----------------- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/xkrs/service/impl/DispatchFirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/DispatchFirePointServiceImpl.java index 9c8c608..31fdb76 100644 --- a/src/main/java/com/xkrs/service/impl/DispatchFirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/DispatchFirePointServiceImpl.java @@ -96,6 +96,9 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { firePointOrdinaryEntity.setFireImage(fireImage); firePointOrdinaryEntity.setSatelliteImage(satelliteImage); firePointOrdinaryEntity.setAddTime(addTime); + if (FirePointFilterUtils.checkDuplicated(firePointOrdinaryDao, firePointOrdinaryEntity)) { + return outputEncapsulationObject(PromptMessageEnum.DATA_EXIT, "该火点和历史火点重复", locale); + } StreetEntity streetEntity = obtainInfoByCountyCode(countyCode); if (streetEntity != null) { firePointOrdinaryEntity.setProCode(streetEntity.getProCode()); @@ -107,10 +110,6 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { firePointOrdinaryEntity.setCountyName(countyName); firePointOrdinaryEntity.setTownCode(townCode); bindFirePointAddress(firePointOrdinaryEntity); - DataWrapper2 checkDuplicatedWrapper1 = FirePointFilterUtils.checkDuplicated(firePointOrdinaryDao, firePointOrdinaryEntity); - if (checkDuplicatedWrapper1.getData1()) { - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, checkDuplicatedWrapper1.getData2(), locale); - } firePointOrdinaryDao.save(firePointOrdinaryEntity); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale); } diff --git a/src/main/java/com/xkrs/utilsnew/FirePointFilterUtils.java b/src/main/java/com/xkrs/utilsnew/FirePointFilterUtils.java index f7951cc..bacd354 100644 --- a/src/main/java/com/xkrs/utilsnew/FirePointFilterUtils.java +++ b/src/main/java/com/xkrs/utilsnew/FirePointFilterUtils.java @@ -1,10 +1,8 @@ package com.xkrs.utilsnew; import com.xkrs.dao.FirePointOrdinaryDao; -import com.xkrs.dao.FirePointPreciseDao; import com.xkrs.model.bean.DataWrapper2; import com.xkrs.model.entity.FirePointOrdinaryEntity; -import com.xkrs.model.entity.FirePointPreciseEntity; import org.springframework.data.jpa.domain.Specification; import javax.persistence.criteria.Predicate; @@ -32,43 +30,18 @@ public class FirePointFilterUtils { return new DataWrapper2<>(Boolean.TRUE, ""); } - public static DataWrapper2 checkDuplicated(FirePointOrdinaryDao firePointDao, FirePointOrdinaryEntity firePointEntity) { + public static boolean checkDuplicated(FirePointOrdinaryDao firePointDao, FirePointOrdinaryEntity firePointEntity) { Specification specification = (root, criteriaQuery, criteriaBuilder) -> { List predicateList = new ArrayList<>(); predicateList.add(criteriaBuilder.equal(root.get("longitude").as(Double.class), firePointEntity.getLongitude())); predicateList.add(criteriaBuilder.equal(root.get("latitude").as(Double.class), firePointEntity.getLatitude())); - predicateList.add(criteriaBuilder.equal(root.get("countyCode").as(String.class), firePointEntity.getCountyCode())); - predicateList.add(criteriaBuilder.equal(root.get("countyName").as(String.class), firePointEntity.getCountyName())); - predicateList.add(criteriaBuilder.equal(root.get("townCode").as(String.class), firePointEntity.getTownCode())); predicateList.add(criteriaBuilder.equal(root.get("satelliteTime").as(String.class), firePointEntity.getSatelliteTime())); predicateList.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), firePointEntity.getSatelliteType())); predicateList.add(criteriaBuilder.equal(root.get("landType").as(String.class), firePointEntity.getLandType())); return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); }; List list = firePointDao.findAll(specification); - if (list.size() > 0) { - return new DataWrapper2<>(Boolean.TRUE, "该火点和历史火点重复,不入库"); - } - return new DataWrapper2<>(Boolean.FALSE, ""); + return list.size() > 0; } - public static DataWrapper2 checkDuplicated(FirePointPreciseDao firePointDao, FirePointPreciseEntity firePointEntity) { - Specification specification = (root, criteriaQuery, criteriaBuilder) -> { - List predicateList = new ArrayList<>(); - predicateList.add(criteriaBuilder.equal(root.get("longitude").as(Double.class), firePointEntity.getLongitude())); - predicateList.add(criteriaBuilder.equal(root.get("latitude").as(Double.class), firePointEntity.getLatitude())); - predicateList.add(criteriaBuilder.equal(root.get("countyCode").as(String.class), firePointEntity.getCountyCode())); - predicateList.add(criteriaBuilder.equal(root.get("countyName").as(String.class), firePointEntity.getCountyName())); - predicateList.add(criteriaBuilder.equal(root.get("townCode").as(String.class), firePointEntity.getTownCode())); - predicateList.add(criteriaBuilder.equal(root.get("satelliteTime").as(String.class), firePointEntity.getSatelliteTime())); - predicateList.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), firePointEntity.getSatelliteType())); - predicateList.add(criteriaBuilder.equal(root.get("landType").as(String.class), firePointEntity.getLandType())); - return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); - }; - List list = firePointDao.findAll(specification); - if (list.size() > 0) { - return new DataWrapper2<>(Boolean.TRUE, "该火点和历史火点重复,不入库"); - } - return new DataWrapper2<>(Boolean.FALSE, ""); - } }