diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index dcf2760..66418fa 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -110,33 +110,17 @@ public class FirePointServiceImpl implements FirePointService { firePointEntity.setFireImage(firePointQo.getFireImage()); firePointEntity.setSatelliteImage(firePointQo.getSatelliteImage()); try { - bindStreetCode(firePointEntity); + bindStreetCodeName(firePointEntity); } catch (Exception e) { e.printStackTrace(); System.out.println("添加火点信息 逆地理编码请求街道编号失败:" + e.getMessage()); } log.info("-------发现新火点"); - /*log.info("---------------开始进行实时通讯,将检测到的火点传给前端"); - Map map = new HashMap(3); - map.put("countyCode",firePointQo.getCountyCode()); - map.put("countyName",firePointQo.getCountyName()); - map.put("fireCode",firePointQo.getFireCode()); - map.put("latitude",firePointQo.getLatitude()); - map.put("longitude",firePointQo.getLongitude()); - map.put("satelliteTime",DateTimeUtil.timeMillisToString(firePointQo.getSatelliteTimeTs().longValue())); - map.put("satelliteType",firePointQo.getSatelliteType()); - map.put("addTime",DateTimeUtil.dateTimeToString(LocalDateTime.now())); - map.put("detailedAddress",AddressUtils.getLatAndLng(firePointQo.getLatitude().toString(),firePointQo.getLongitude().toString())); - Map map1 = new HashMap(3); - map1.put("fire",map); - String websocket = JSON.toJSONString(map1); - // 将监测到的火点信息返给前端 - WebSocketServer.broadInfo(websocket);*/ return firePointDao.save(firePointEntity); } } - private void bindStreetCode(FirePointEntity firePointEntity) throws Exception { + private void bindStreetCodeName(FirePointEntity firePointEntity) throws Exception { List locationList = new ArrayList<>(); locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude()); GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList); @@ -145,6 +129,10 @@ public class FirePointServiceImpl implements FirePointService { townCode = townCode.substring(0, 9); } firePointEntity.setStreetCode(townCode); + List byStreetCode = streetDao.findByStreetCode(townCode); + if (byStreetCode != null && byStreetCode.size() > 0) { + firePointEntity.setStreetName(byStreetCode.get(0).getStreetName()); + } }