From e29d94c83f62960bb1d6dacac4c978debc85c5ef Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期五, 22 七月 2022 16:02:14 +0800 Subject: [PATCH] 增加推流添加功能,修复级联目录推送 --- src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java | 54 ++++++++++++++++++++++++++++++------------------------ 1 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index 9d376fb..f719800 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd.CatalogResponseMessageHandler; import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; +import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask; import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask; @@ -56,6 +57,9 @@ private DeviceMapper deviceMapper; @Autowired + private IDeviceChannelService deviceChannelService; + + @Autowired private DeviceChannelMapper deviceChannelMapper; @Autowired @@ -82,10 +86,10 @@ redisCatchStorage.clearCatchByDeviceId(device.getDeviceId()); } device.setUpdateTime(now); - device.setOnline(1); - // 绗竴娆′笂绾� + // 绗竴娆′笂绾� 鎴栧垯璁惧涔嬪墠鏄绾跨姸鎬�--杩涜閫氶亾鍚屾鍜岃澶囦俊鎭煡璇� if (device.getCreateTime() == null) { + device.setOnline(1); device.setCreateTime(now); logger.info("[璁惧涓婄嚎,棣栨娉ㄥ唽]: {}锛屾煡璇㈣澶囦俊鎭互鍙婇�氶亾淇℃伅", device.getDeviceId()); deviceMapper.add(device); @@ -93,8 +97,19 @@ commander.deviceInfoQuery(device); sync(device); }else { - deviceMapper.update(device); - redisCatchStorage.updateDevice(device); + if(device.getOnline() == 0){ + device.setOnline(1); + device.setCreateTime(now); + logger.info("[璁惧涓婄嚎,绂荤嚎鐘舵�佷笅閲嶆柊娉ㄥ唽]: {}锛屾煡璇㈣澶囦俊鎭互鍙婇�氶亾淇℃伅", device.getDeviceId()); + deviceMapper.update(device); + redisCatchStorage.updateDevice(device); + commander.deviceInfoQuery(device); + sync(device); + }else { + deviceMapper.update(device); + redisCatchStorage.updateDevice(device); + } + } // 涓婄嚎娣诲姞璁㈤槄 @@ -121,6 +136,8 @@ device.setOnline(0); redisCatchStorage.updateDevice(device); deviceMapper.update(device); + //杩涜閫氶亾绂荤嚎 + deviceChannelMapper.offlineByDeviceId(deviceId); // 绂荤嚎閲婃斁鎵�鏈塻src List<SsrcTransaction> ssrcTransactions = streamSession.getSsrcTransactionForAll(deviceId, null, null, null); if (ssrcTransactions != null && ssrcTransactions.size() > 0) { @@ -324,23 +341,12 @@ private void updateDeviceChannelGeoCoordSys(Device device) { List<DeviceChannel> deviceChannels = deviceChannelMapper.getAllChannelWithCoordinate(device.getDeviceId()); if (deviceChannels.size() > 0) { + List<DeviceChannel> deviceChannelsForStore = new ArrayList<>(); for (DeviceChannel deviceChannel : deviceChannels) { - if ("WGS84".equals(device.getGeoCoordSys())) { - deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude()); - deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude()); - Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude()); - deviceChannel.setLongitudeGcj02(position[0]); - deviceChannel.setLatitudeGcj02(position[1]); - }else if ("GCJ02".equals(device.getGeoCoordSys())) { - deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude()); - deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude()); - Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude()); - deviceChannel.setLongitudeWgs84(position[0]); - deviceChannel.setLatitudeWgs84(position[1]); - } + deviceChannelsForStore.add(deviceChannelService.updateGps(deviceChannel, device)); } + deviceChannelService.updateChannels(device.getDeviceId(), deviceChannelsForStore); } - storage.updateChannels(device.getDeviceId(), deviceChannels); } @@ -352,11 +358,11 @@ } if (parentId == null || parentId.equals(deviceId)) { // 瀛楁牴鑺傜偣寮�濮嬫煡璇� - List<DeviceChannel> rootNodes = getRootNodes(deviceId, "CivilCode".equals(device.getTreeType()), true, !onlyCatalog); + List<DeviceChannel> rootNodes = getRootNodes(deviceId, TreeType.CIVIL_CODE.equals(device.getTreeType()), true, !onlyCatalog); return transportChannelsToTree(rootNodes, ""); } - if ("CivilCode".equals(device.getTreeType())) { + if (TreeType.CIVIL_CODE.equals(device.getTreeType())) { if (parentId.length()%2 != 0) { return null; } @@ -386,7 +392,7 @@ } // 浣跨敤涓氬姟鍒嗙粍灞曠ず鏍� - if ("BusinessGroup".equals(device.getTreeType())) { + if (TreeType.BUSINESS_GROUP.equals(device.getTreeType())) { if (parentId.length() < 14 ) { return null; } @@ -406,11 +412,11 @@ } if (parentId == null || parentId.equals(deviceId)) { // 瀛楁牴鑺傜偣寮�濮嬫煡璇� - List<DeviceChannel> rootNodes = getRootNodes(deviceId, "CivilCode".equals(device.getTreeType()), false, true); + List<DeviceChannel> rootNodes = getRootNodes(deviceId, TreeType.CIVIL_CODE.equals(device.getTreeType()), false, true); return rootNodes; } - if ("CivilCode".equals(device.getTreeType())) { + if (TreeType.CIVIL_CODE.equals(device.getTreeType())) { if (parentId.length()%2 != 0) { return null; } @@ -431,7 +437,7 @@ } // 浣跨敤涓氬姟鍒嗙粍灞曠ず鏍� - if ("BusinessGroup".equals(device.getTreeType())) { + if (TreeType.BUSINESS_GROUP.equals(device.getTreeType())) { if (parentId.length() < 14 ) { return null; } -- Gitblit v1.8.0