瀏覽代碼

修复NOTIFY消息中通道的状态变化

648540858 1 年之前
父節點
當前提交
43a2344ad0

+ 5 - 5
src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java

@@ -624,21 +624,21 @@ public interface DeviceChannelMapper {
             "DELETE FROM wvp_device_channel WHERE id=#{item.id}" +
             "</foreach>" +
             "</script>"})
-    int batchDel(@Param("deleteChannelList") List<DeviceChannel> deleteChannelList);
+    int batchDel(List<DeviceChannel> deleteChannelList);
 
     @Update({"<script>" +
             "<foreach collection='channels' item='item' separator=';'>" +
-            "UPDATE wvp_device_channel SET status='ON' WHERE id=#{item.id}" +
+            "UPDATE wvp_device_channel SET status='ON' WHERE device_id=#{item.deviceId}" +
             "</foreach>" +
             "</script>"})
-    int batchOnline(@Param("channels") List<DeviceChannel> channels);
+    int batchOnlineForNotify(List<DeviceChannel> channels);
 
     @Update({"<script>" +
             "<foreach collection='channels' item='item' separator=';'>" +
-            "UPDATE wvp_device_channel SET status='OFF' WHERE id=#{item.id}" +
+            "UPDATE wvp_device_channel SET status='OFF' WHERE device_id=#{item.deviceId}" +
             "</foreach>" +
             "</script>"})
-    int batchOffline(List<DeviceChannel> channels);
+    int batchOfflineForNotify(List<DeviceChannel> channels);
 
 
     @Select("select count(1) from wvp_device_channel where status = 'ON'")

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java

@@ -50,12 +50,12 @@ public interface IDeviceChannelService {
     /**
      * 批量上线
      */
-    int channelsOnline(List<DeviceChannel> channels);
+    int channelsOnlineForNotify(List<DeviceChannel> channels);
 
     /**
      * 批量下线
      */
-    int channelsOffline(List<DeviceChannel> channels);
+    int channelsOfflineForNotify(List<DeviceChannel> channels);
 
     /**
      *  获取一个通道

+ 4 - 4
src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java

@@ -198,8 +198,8 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
     }
 
     @Override
-    public int channelsOnline(List<DeviceChannel> channels) {
-        return channelMapper.batchOnline(channels);
+    public int channelsOnlineForNotify(List<DeviceChannel> channels) {
+        return channelMapper.batchOnlineForNotify(channels);
     }
 
     @Override
@@ -208,8 +208,8 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
     }
 
     @Override
-    public int channelsOffline(List<DeviceChannel> channels) {
-        return channelMapper.batchOffline(channels);
+    public int channelsOfflineForNotify(List<DeviceChannel> channels) {
+        return channelMapper.batchOfflineForNotify(channels);
     }
 
 

+ 3 - 7
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java

@@ -112,6 +112,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
 								log.info("[解析CatalogChannelEvent]成功:但是解析通道信息失败, 原文如下: \n{}", new String(evt.getRequest().getRawContent()));
 								continue;
 							}
+							catalogChannelEvent.getChannel().setDeviceDbId(device.getId());
                         } catch (InvocationTargetException | NoSuchMethodException | InstantiationException |
                                  IllegalAccessException e) {
                             log.error("[解析CatalogChannelEvent]失败,", e);
@@ -305,20 +306,15 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
 
 	private void executeSaveForOnline(){
 		if (!updateChannelOnlineList.isEmpty()) {
-			deviceChannelService.channelsOnline(updateChannelOnlineList);
+			deviceChannelService.channelsOnlineForNotify(updateChannelOnlineList);
 			updateChannelOnlineList.clear();
 		}
 	}
 
 	private void executeSaveForOffline(){
 		if (!updateChannelOfflineList.isEmpty()) {
-			deviceChannelService.channelsOffline(updateChannelOfflineList);
+			deviceChannelService.channelsOfflineForNotify(updateChannelOfflineList);
 			updateChannelOfflineList.clear();
 		}
 	}
-
-//	@Scheduled(fixedRate = 10000)   //每1秒执行一次
-//	public void execute(){
-//		logger.info("[待处理Notify-目录订阅消息数量]: {}", taskQueue.size());
-//	}
 }