diff --git a/src/main/java/com/xkrs/straw/service/impl/DispatchFirePointServiceImpl.java b/src/main/java/com/xkrs/straw/service/impl/DispatchFirePointServiceImpl.java index 11a8ad0..d2a801f 100644 --- a/src/main/java/com/xkrs/straw/service/impl/DispatchFirePointServiceImpl.java +++ b/src/main/java/com/xkrs/straw/service/impl/DispatchFirePointServiceImpl.java @@ -1,6 +1,8 @@ package com.xkrs.straw.service.impl; import com.xkrs.common.encapsulation.PromptMessageEnum; +import com.xkrs.dao.StreetDao; +import com.xkrs.model.entity.StreetEntity; import com.xkrs.straw.dao.FirePointChannelConfigDao; import com.xkrs.straw.dao.FirePointOrdinaryDao; import com.xkrs.straw.dao.FirePointPreciseDao; @@ -46,15 +48,18 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { @Resource private FirePointPreciseDao firePointPreciseDao; - @Resource - private SysUserDao sysUserDao; - @Resource private FirePointQueryManager firePointQueryManager; @Resource private FirePointPushManager firePointPushManager; + @Resource + private SysUserDao sysUserDao; + + @Resource + private StreetDao streetDao; + /** * 普通渠道推送火点到秸秆系统 */ @@ -74,8 +79,6 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { String messagePrecise = ""; String fireCode = firePointQo.getFireCode(); - Long countyCode = firePointQo.getCountyCode(); - String countyName = firePointQo.getCountyName(); Long satelliteTimeTs = firePointQo.getSatelliteTimeTs(); Double longitude = firePointQo.getLongitude(); Double latitude = firePointQo.getLatitude(); @@ -84,6 +87,8 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { 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)); @@ -91,28 +96,37 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { 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.setTownCode(townCode); - firePointOrdinaryEntity.setAddTime(addTime); - firePointOrdinaryEntity.setCountyCode(String.valueOf(countyCode)); - firePointOrdinaryEntity.setCountyName(countyName); - 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().substring(0, 2)); + firePointOrdinaryEntity.setProName(streetEntity.getProName()); + firePointOrdinaryEntity.setCityCode(streetEntity.getCityCode().substring(0, 4)); + 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); + } } List firePointChannelConfigEntityList = channelConfigDao.findAll(); boolean inPreciseTimeRange = FirePointDispatchUtils.ifInFireSeason(fireCode, satelliteLocalDateTime, firePointChannelConfigEntityList); @@ -128,10 +142,17 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { firePointPreciseEntity.setConfidence(confidence); firePointPreciseEntity.setFireImage(fireImage); firePointPreciseEntity.setSatelliteImage(satelliteImage); - firePointPreciseEntity.setTownCode(townCode); firePointPreciseEntity.setAddTime(addTime); - firePointPreciseEntity.setCountyCode(String.valueOf(countyCode)); + StreetEntity streetEntity = obtainInfoByCountyCode(countyCode); + if (streetEntity != null) { + firePointPreciseEntity.setProCode(streetEntity.getProCode().substring(0, 2)); + firePointPreciseEntity.setProName(streetEntity.getProName()); + firePointPreciseEntity.setCityCode(streetEntity.getCityCode().substring(0, 4)); + firePointPreciseEntity.setCityName(streetEntity.getCityName()); + } + firePointPreciseEntity.setCountyCode(countyCode); firePointPreciseEntity.setCountyName(countyName); + firePointPreciseEntity.setTownCode(townCode); bindFirePointAddress(firePointPreciseEntity); DataWrapper2 checkDuplicatedWrapper2 = FirePointFilterUtils.checkDuplicated(firePointPreciseDao, firePointPreciseEntity); if (checkDuplicatedWrapper2.getData1()) { @@ -145,6 +166,15 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { return outputEncapsulationObject(PromptMessageEnum.SUCCESS, messageOrdinary + messagePrecise, locale); } + private StreetEntity obtainInfoByCountyCode(String countyCode) { + try { + return streetDao.findByCountyCode(countyCode).get(0); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + /** * 精准渠道推送火点到秸秆系统 */ @@ -163,8 +193,6 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { String messagePrecise = ""; String fireCode = firePointQo.getFireCode(); - Long countyCode = firePointQo.getCountyCode(); - String countyName = firePointQo.getCountyName(); Long satelliteTimeTs = firePointQo.getSatelliteTimeTs(); Double longitude = firePointQo.getLongitude(); Double latitude = firePointQo.getLatitude(); @@ -173,6 +201,8 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { 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)); @@ -193,10 +223,17 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { firePointPreciseEntity.setConfidence(confidence); firePointPreciseEntity.setFireImage(fireImage); firePointPreciseEntity.setSatelliteImage(satelliteImage); - firePointPreciseEntity.setTownCode(townCode); firePointPreciseEntity.setAddTime(addTime); - firePointPreciseEntity.setCountyCode(String.valueOf(countyCode)); + StreetEntity streetEntity = obtainInfoByCountyCode(countyCode); + if (streetEntity != null) { + firePointPreciseEntity.setProCode(streetEntity.getProCode().substring(0, 2)); + firePointPreciseEntity.setProName(streetEntity.getProName()); + firePointPreciseEntity.setCityCode(streetEntity.getCityCode().substring(0, 4)); + firePointPreciseEntity.setCityName(streetEntity.getCityName()); + } + firePointPreciseEntity.setCountyCode(countyCode); firePointPreciseEntity.setCountyName(countyName); + firePointPreciseEntity.setTownCode(townCode); bindFirePointAddress(firePointPreciseEntity); DataWrapper2 checkDuplicatedWrapper2 = FirePointFilterUtils.checkDuplicated(firePointPreciseDao, firePointPreciseEntity); if (checkDuplicatedWrapper2.getData1()) {