From affcfbc474db9c5743e1abb9253ccb8f60d0068e Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Wed, 29 Mar 2023 10:42:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=81=AB=E7=82=B9=E9=87=8D=E6=9E=84-=E6=99=AE?= =?UTF-8?q?=E9=80=9A=E7=81=AB=E7=82=B9=E5=85=A8=E9=83=A8=E5=85=A5=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DispatchFirePointServiceImpl.java | 194 +++--------------- 1 file changed, 27 insertions(+), 167 deletions(-) diff --git a/src/main/java/com/xkrs/service/impl/DispatchFirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/DispatchFirePointServiceImpl.java index 46d8de0..9c8c608 100644 --- a/src/main/java/com/xkrs/service/impl/DispatchFirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/DispatchFirePointServiceImpl.java @@ -6,14 +6,11 @@ import com.xkrs.helper.FirePointPushManager; import com.xkrs.helper.FirePointQueryManager; import com.xkrs.helper.GeoCodeHelper; import com.xkrs.model.bean.DataWrapper2; -import com.xkrs.model.entity.FirePointChannelConfigEntity; import com.xkrs.model.entity.FirePointOrdinaryEntity; -import com.xkrs.model.entity.FirePointPreciseEntity; import com.xkrs.model.entity.StreetEntity; import com.xkrs.model.qo.AllFirePointQo; import com.xkrs.service.DispatchFirePointService; import com.xkrs.utilsnew.DateTimeUtils; -import com.xkrs.utilsnew.FirePointDispatchUtils; import com.xkrs.utilsnew.FirePointFilterUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,7 +20,6 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.ZoneOffset; -import java.util.List; import java.util.Locale; import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; @@ -71,8 +67,6 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { } log.info("insertFirePointChannelOrdinary 接收到火点信息:" + firePointQo.toString()); - String messageOrdinary = ""; - String messagePrecise = ""; String fireCode = firePointQo.getFireCode(); Long satelliteTimeTs = firePointQo.getSatelliteTimeTs(); @@ -91,75 +85,34 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { String satelliteTime = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime);//卫星时间 String addTime = DateTimeUtils.localDateTimeToString(LocalDateTime.now());//添加时间 - //普通渠道来的火点直接入库普通火点库 - { - FirePointOrdinaryEntity firePointOrdinaryEntity = new FirePointOrdinaryEntity(); - firePointOrdinaryEntity.setFireCode(fireCode); - firePointOrdinaryEntity.setSatelliteTime(satelliteTime); - firePointOrdinaryEntity.setLongitude(longitude); - firePointOrdinaryEntity.setLatitude(latitude); - firePointOrdinaryEntity.setSatelliteType(satelliteType); - firePointOrdinaryEntity.setLandType(landType); - firePointOrdinaryEntity.setConfidence(confidence); - firePointOrdinaryEntity.setFireImage(fireImage); - firePointOrdinaryEntity.setSatelliteImage(satelliteImage); - firePointOrdinaryEntity.setAddTime(addTime); - StreetEntity streetEntity = obtainInfoByCountyCode(countyCode); - if (streetEntity != null) { - firePointOrdinaryEntity.setProCode(streetEntity.getProCode()); - firePointOrdinaryEntity.setProName(streetEntity.getProName()); - firePointOrdinaryEntity.setCityCode(streetEntity.getCityCode()); - firePointOrdinaryEntity.setCityName(streetEntity.getCityName()); - } - firePointOrdinaryEntity.setCountyCode(countyCode); - firePointOrdinaryEntity.setCountyName(countyName); - firePointOrdinaryEntity.setTownCode(townCode); - bindFirePointAddress(firePointOrdinaryEntity); - DataWrapper2 checkDuplicatedWrapper1 = FirePointFilterUtils.checkDuplicated(firePointOrdinaryDao, firePointOrdinaryEntity); - if (checkDuplicatedWrapper1.getData1()) { - messageOrdinary = checkDuplicatedWrapper1.getData2(); - } else { - messageOrdinary = "普通火点添加成功"; - firePointOrdinaryDao.save(firePointOrdinaryEntity); -// firePointPushManager.pushNotification(firePointOrdinaryEntity); - } + FirePointOrdinaryEntity firePointOrdinaryEntity = new FirePointOrdinaryEntity(); + firePointOrdinaryEntity.setFireCode(fireCode); + firePointOrdinaryEntity.setSatelliteTime(satelliteTime); + firePointOrdinaryEntity.setLongitude(longitude); + firePointOrdinaryEntity.setLatitude(latitude); + firePointOrdinaryEntity.setSatelliteType(satelliteType); + firePointOrdinaryEntity.setLandType(landType); + firePointOrdinaryEntity.setConfidence(confidence); + firePointOrdinaryEntity.setFireImage(fireImage); + firePointOrdinaryEntity.setSatelliteImage(satelliteImage); + firePointOrdinaryEntity.setAddTime(addTime); + StreetEntity streetEntity = obtainInfoByCountyCode(countyCode); + if (streetEntity != null) { + firePointOrdinaryEntity.setProCode(streetEntity.getProCode()); + firePointOrdinaryEntity.setProName(streetEntity.getProName()); + firePointOrdinaryEntity.setCityCode(streetEntity.getCityCode()); + firePointOrdinaryEntity.setCityName(streetEntity.getCityName()); } - List firePointChannelConfigEntityList = channelConfigDao.findAll(); - boolean inPreciseTimeRange = FirePointDispatchUtils.ifInFireSeason(fireCode, satelliteLocalDateTime, firePointChannelConfigEntityList); - //如果现在不属于精准渠道的时间范围,那么普通渠道来的火点就入库精准火点库 - if (!inPreciseTimeRange) { - FirePointPreciseEntity firePointPreciseEntity = new FirePointPreciseEntity(); - firePointPreciseEntity.setFireCode(fireCode); - firePointPreciseEntity.setSatelliteTime(satelliteTime); - firePointPreciseEntity.setLongitude(longitude); - firePointPreciseEntity.setLatitude(latitude); - firePointPreciseEntity.setSatelliteType(satelliteType); - firePointPreciseEntity.setLandType(landType); - firePointPreciseEntity.setConfidence(confidence); - firePointPreciseEntity.setFireImage(fireImage); - firePointPreciseEntity.setSatelliteImage(satelliteImage); - firePointPreciseEntity.setAddTime(addTime); - StreetEntity streetEntity = obtainInfoByCountyCode(countyCode); - if (streetEntity != null) { - firePointPreciseEntity.setProCode(streetEntity.getProCode()); - firePointPreciseEntity.setProName(streetEntity.getProName()); - firePointPreciseEntity.setCityCode(streetEntity.getCityCode()); - firePointPreciseEntity.setCityName(streetEntity.getCityName()); - } - firePointPreciseEntity.setCountyCode(countyCode); - firePointPreciseEntity.setCountyName(countyName); - firePointPreciseEntity.setTownCode(townCode); - bindFirePointAddress(firePointPreciseEntity); - DataWrapper2 checkDuplicatedWrapper2 = FirePointFilterUtils.checkDuplicated(firePointPreciseDao, firePointPreciseEntity); - if (checkDuplicatedWrapper2.getData1()) { - messagePrecise = checkDuplicatedWrapper2.getData2(); - } else { - messagePrecise = "审核火点添加成功"; - firePointPreciseDao.save(firePointPreciseEntity); - firePointPushManager.pushNotification(firePointPreciseEntity); - } + firePointOrdinaryEntity.setCountyCode(countyCode); + firePointOrdinaryEntity.setCountyName(countyName); + firePointOrdinaryEntity.setTownCode(townCode); + bindFirePointAddress(firePointOrdinaryEntity); + DataWrapper2 checkDuplicatedWrapper1 = FirePointFilterUtils.checkDuplicated(firePointOrdinaryDao, firePointOrdinaryEntity); + if (checkDuplicatedWrapper1.getData1()) { + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, checkDuplicatedWrapper1.getData2(), locale); } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, messageOrdinary + messagePrecise, locale); + firePointOrdinaryDao.save(firePointOrdinaryEntity); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale); } private StreetEntity obtainInfoByCountyCode(String countyCode) { @@ -176,100 +129,7 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { */ @Override public String insertFirePointChannelPrecise(AllFirePointQo firePointQo) { - DataWrapper2 checkLandTypeWrapper = FirePointFilterUtils.checkLandType(firePointQo.getLandtype()); - if (!checkLandTypeWrapper.getData1()) { - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, checkLandTypeWrapper.getData2(), locale); - } - DataWrapper2 checkSatelliteTypeWrapper = FirePointFilterUtils.checkSatelliteType(firePointQo.getSatelliteType(), firePointQo.getConfidence()); - if (!checkSatelliteTypeWrapper.getData1()) { - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, checkSatelliteTypeWrapper.getData2(), locale); - } - - log.info("insertFirePointChannelPrecise 接收到火点信息:" + firePointQo.toString()); - String messagePrecise = ""; - - String fireCode = firePointQo.getFireCode(); - Long satelliteTimeTs = firePointQo.getSatelliteTimeTs(); - Double longitude = firePointQo.getLongitude(); - Double latitude = firePointQo.getLatitude(); - String satelliteType = firePointQo.getSatelliteType(); - String landType = firePointQo.getLandtype(); - String confidence = firePointQo.getConfidence(); - String fireImage = firePointQo.getFireImage(); - String satelliteImage = firePointQo.getSatelliteImage(); - String countyCode = String.valueOf(firePointQo.getCountyCode()); - String countyName = firePointQo.getCountyName(); - String townCode = firePointQo.getTowncode(); - - LocalDateTime satelliteLocalDateTime = LocalDateTime.ofEpochSecond(satelliteTimeTs, 0, ZoneOffset.ofHours(8)); - String satelliteTime = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime);//卫星时间 - String addTime = DateTimeUtils.localDateTimeToString(LocalDateTime.now());//添加时间 - - List firePointChannelConfigEntityList = channelConfigDao.findAll(); - boolean inPreciseTimeRange = FirePointDispatchUtils.ifInFireSeason(fireCode, satelliteLocalDateTime, firePointChannelConfigEntityList); - //如果现在属于精准渠道的时间范围,那么精准渠道来的火点就入库精准火点库 - if (inPreciseTimeRange) { - FirePointPreciseEntity firePointPreciseEntity = new FirePointPreciseEntity(); - firePointPreciseEntity.setFireCode(fireCode); - firePointPreciseEntity.setSatelliteTime(satelliteTime); - firePointPreciseEntity.setLongitude(longitude); - firePointPreciseEntity.setLatitude(latitude); - firePointPreciseEntity.setSatelliteType(satelliteType); - firePointPreciseEntity.setLandType(landType); - firePointPreciseEntity.setConfidence(confidence); - firePointPreciseEntity.setFireImage(fireImage); - firePointPreciseEntity.setSatelliteImage(satelliteImage); - firePointPreciseEntity.setAddTime(addTime); - StreetEntity streetEntity = obtainInfoByCountyCode(countyCode); - if (streetEntity != null) { - firePointPreciseEntity.setProCode(streetEntity.getProCode()); - firePointPreciseEntity.setProName(streetEntity.getProName()); - firePointPreciseEntity.setCityCode(streetEntity.getCityCode()); - firePointPreciseEntity.setCityName(streetEntity.getCityName()); - } - firePointPreciseEntity.setCountyCode(countyCode); - firePointPreciseEntity.setCountyName(countyName); - firePointPreciseEntity.setTownCode(townCode); - bindFirePointAddress(firePointPreciseEntity); - DataWrapper2 checkDuplicatedWrapper2 = FirePointFilterUtils.checkDuplicated(firePointPreciseDao, firePointPreciseEntity); - if (checkDuplicatedWrapper2.getData1()) { - messagePrecise = checkDuplicatedWrapper2.getData2(); - } else { - messagePrecise = "审核火点添加成功"; - firePointPreciseDao.save(firePointPreciseEntity); - firePointPushManager.pushNotification(firePointPreciseEntity); - } - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, messagePrecise, locale); - } - - /** - * 绑定火点位置 - * 如果能接收到TownCode(山东省内),会判断CountyCode、CountyName、TownCode, - * 如果不能接收到TownCode(其他省份),会判断CountyCode、CountyName, - *

- * 如果根据经纬度反算出来的变量都一致,就更新TownCode、TownName、FirePointAddress,无备注。 - * 如果不一致,就只更新FirePointAddress,备注存储差异信息 - */ - private void bindFirePointAddress(FirePointPreciseEntity firePointPreciseEntity) { - String countyCode = firePointPreciseEntity.getCountyCode(); - String countyName = firePointPreciseEntity.getCountyName(); - String townCode = firePointPreciseEntity.getTownCode(); - GeoCodeHelper geoCodeHelper = new GeoCodeHelper(); - geoCodeHelper.doGeoCode(firePointPreciseEntity.getLongitude(), firePointPreciseEntity.getLatitude()); - boolean geoCodeResult = geoCodeHelper.checkGeoCodeResult(countyCode, countyName, townCode); - if (geoCodeResult) { - firePointPreciseEntity.setTownCode(geoCodeHelper.getCalTownCode()); - firePointPreciseEntity.setTownName(geoCodeHelper.getCalTownName()); - firePointPreciseEntity.setFirePointAddress(geoCodeHelper.getCalFirePointAddress()); - firePointPreciseEntity.setRemark(""); - } else { - firePointPreciseEntity.setTownCode(geoCodeHelper.getCalTownCode()); - firePointPreciseEntity.setTownName(geoCodeHelper.getCalTownName()); - firePointPreciseEntity.setFirePointAddress(geoCodeHelper.getCalFirePointAddress()); - String remark = "接收到的countyCode=" + countyCode + ",计算得到的countyCode=" + geoCodeHelper.getCalCountyCode() + "。接收到的countyName=" + countyName + ",计算得到的countyName=" + geoCodeHelper.getCalCountyName() + "。接收到的townCode=" + townCode + ",计算得到的townCode=" + geoCodeHelper.getCalTownCode() + "。"; - firePointPreciseEntity.setRemark(remark); - } + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale); } /**