diff --git a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java index 262910b0b..142b1f0d7 100644 --- a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java +++ b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java @@ -28,7 +28,7 @@ import java.util.Collections; @EnableCaching public class VManageBootstrap extends SpringBootServletInitializer { - private final static Logger logger = LoggerFactory.getLogger(VManageBootstrap.class); + private final static Logger loggerger = LoggerFactory.getLogger(VManageBootstrap.class); private static String[] args; private static ConfigurableApplicationContext context; diff --git a/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java b/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java index 8449ebb10..585834cbb 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java @@ -2,8 +2,7 @@ package com.genersoft.iot.vmp.conf; import com.genersoft.iot.vmp.common.CivilCodePo; import com.genersoft.iot.vmp.utils.CivilCodeUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.context.annotation.Configuration; @@ -23,12 +22,11 @@ import java.util.List; /** * 启动时读取行政区划表 */ +@Slf4j @Configuration @Order(value=14) public class CivilCodeFileConf implements CommandLineRunner { - private final static Logger logger = LoggerFactory.getLogger(CivilCodeFileConf.class); - @Autowired @Lazy private UserSetting userSetting; @@ -36,7 +34,7 @@ public class CivilCodeFileConf implements CommandLineRunner { @Override public void run(String... args) throws Exception { if (ObjectUtils.isEmpty(userSetting.getCivilCodeFile())) { - logger.warn("[行政区划] 文件未设置,可能造成目录刷新结果不完整"); + log.warn("[行政区划] 文件未设置,可能造成目录刷新结果不完整"); return; } InputStream inputStream; @@ -44,7 +42,7 @@ public class CivilCodeFileConf implements CommandLineRunner { String filePath = userSetting.getCivilCodeFile().substring("classpath:".length()); ClassPathResource civilCodeFile = new ClassPathResource(filePath); if (!civilCodeFile.exists()) { - logger.warn("[行政区划] 文件<{}>不存在,可能造成目录刷新结果不完整", userSetting.getCivilCodeFile()); + log.warn("[行政区划] 文件<{}>不存在,可能造成目录刷新结果不完整", userSetting.getCivilCodeFile()); return; } inputStream = civilCodeFile.getInputStream(); @@ -52,7 +50,7 @@ public class CivilCodeFileConf implements CommandLineRunner { }else { File civilCodeFile = new File(userSetting.getCivilCodeFile()); if (!civilCodeFile.exists()) { - logger.warn("[行政区划] 文件<{}>不存在,可能造成目录刷新结果不完整", userSetting.getCivilCodeFile()); + log.warn("[行政区划] 文件<{}>不存在,可能造成目录刷新结果不完整", userSetting.getCivilCodeFile()); return; } inputStream = Files.newInputStream(civilCodeFile.toPath()); @@ -75,9 +73,9 @@ public class CivilCodeFileConf implements CommandLineRunner { inputStreamReader.close(); inputStream.close(); if (civilCodePoList.isEmpty()) { - logger.warn("[行政区划] 文件内容为空,可能造成目录刷新结果不完整"); + log.warn("[行政区划] 文件内容为空,可能造成目录刷新结果不完整"); }else { - logger.info("[行政区划] 加载成功,共加载数据{}条", civilCodePoList.size()); + log.info("[行政区划] 加载成功,共加载数据{}条", civilCodePoList.size()); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/CloudRecordTimer.java b/src/main/java/com/genersoft/iot/vmp/conf/CloudRecordTimer.java index de87a9c62..652853bb0 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/CloudRecordTimer.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/CloudRecordTimer.java @@ -5,8 +5,7 @@ import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.service.bean.CloudRecordItem; import com.genersoft.iot.vmp.storager.dao.CloudRecordServiceMapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -19,11 +18,10 @@ import java.util.List; /** * 录像文件定时删除 */ +@Slf4j @Component public class CloudRecordTimer { - private final static Logger logger = LoggerFactory.getLogger(CloudRecordTimer.class); - @Autowired private IMediaServerService mediaServerService; @@ -36,7 +34,7 @@ public class CloudRecordTimer { // @Scheduled(fixedRate = 10000) //每五秒执行一次,方便测试 @Scheduled(cron = "0 0 0 * * ?") //每天的0点执行 public void execute(){ - logger.info("[录像文件定时清理] 开始清理过期录像文件"); + log.info("[录像文件定时清理] 开始清理过期录像文件"); // 获取配置了assist的流媒体节点 List mediaServerItemList = mediaServerService.getAllOnline(); if (mediaServerItemList.isEmpty()) { @@ -64,12 +62,12 @@ public class CloudRecordTimer { boolean deleteResult = mediaServerService.deleteRecordDirectory(mediaServerItem, cloudRecordItem.getApp(), cloudRecordItem.getStream(), date, cloudRecordItem.getFileName()); if (deleteResult) { - logger.warn("[录像文件定时清理] 删除磁盘文件成功: {}", cloudRecordItem.getFilePath()); + log.warn("[录像文件定时清理] 删除磁盘文件成功: {}", cloudRecordItem.getFilePath()); } } result += cloudRecordServiceMapper.deleteList(cloudRecordItemList); } } - logger.info("[录像文件定时清理] 共清理{}个过期录像文件", result); + log.info("[录像文件定时清理] 共清理{}个过期录像文件", result); } } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java b/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java index 0333e0dc3..3cbd52079 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java @@ -3,8 +3,7 @@ package com.genersoft.iot.vmp.conf; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.authentication.BadCredentialsException; @@ -16,11 +15,10 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; /** * 全局异常处理 */ +@Slf4j @RestControllerAdvice public class GlobalExceptionHandler { - private final static Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class); - /** * 默认异常处理 * @param e 异常 @@ -29,7 +27,7 @@ public class GlobalExceptionHandler { @ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public WVPResult exceptionHandler(Exception e) { - logger.error("[全局异常]: ", e); + log.error("[全局异常]: ", e); return WVPResult.fail(ErrorCode.ERROR500.getCode(), e.getMessage()); } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java index a9ea67f74..ef9669d5d 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java @@ -2,8 +2,7 @@ package com.genersoft.iot.vmp.conf; import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.utils.DateUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; @@ -13,13 +12,11 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.util.regex.Pattern; - +@Slf4j @Configuration("mediaConfig") @Order(0) public class MediaConfig{ - private final static Logger logger = LoggerFactory.getLogger(MediaConfig.class); - // 修改必须配置,不再支持自动获取 @Value("${media.id}") private String id; @@ -179,7 +176,7 @@ public class MediaConfig{ try { hostAddress = InetAddress.getByName(sdpIp).getHostAddress(); } catch (UnknownHostException e) { - logger.error("[获取SDP IP]: 域名解析失败"); + log.error("[获取SDP IP]: 域名解析失败"); } return hostAddress; } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java index 3948fdb64..ab9c2d458 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java @@ -2,18 +2,17 @@ package com.genersoft.iot.vmp.conf; import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.service.IMediaServerService; +import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; -import org.springframework.core.annotation.Order; import org.mitre.dsmiley.httpproxy.ProxyServlet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; import org.springframework.util.ObjectUtils; import javax.servlet.ServletException; @@ -28,10 +27,9 @@ import java.net.ConnectException; @SuppressWarnings(value = {"rawtypes", "unchecked"}) @Configuration @Order(1) +@Slf4j public class ProxyServletConfig { - private final static Logger logger = LoggerFactory.getLogger(ProxyServletConfig.class); - @Autowired private IMediaServerService mediaServerService; @@ -44,7 +42,7 @@ public class ProxyServletConfig { servletRegistrationBean.setName("zlm_Proxy"); servletRegistrationBean.addInitParameter("targetUri", "http://127.0.0.1:6080"); servletRegistrationBean.addUrlMappings(); - if (logger.isDebugEnabled()) { + if (log.isDebugEnabled()) { servletRegistrationBean.addInitParameter("log", "true"); } return servletRegistrationBean; @@ -85,15 +83,15 @@ public class ProxyServletConfig { try { super.handleRequestException(proxyRequest, proxyResonse, e); } catch (ServletException servletException) { - logger.error("zlm 代理失败: ", e); + log.error("zlm 代理失败: ", e); } catch (IOException ioException) { if (ioException instanceof ConnectException) { - logger.error("zlm 连接失败"); + log.error("zlm 连接失败"); } else { - logger.error("zlm 代理失败: ", e); + log.error("zlm 代理失败: ", e); } } catch (RuntimeException exception){ - logger.error("zlm 代理失败: ", e); + log.error("zlm 代理失败: ", e); } } @@ -154,7 +152,7 @@ public class ProxyServletConfig { MediaServer mediaInfo = getMediaInfoByUri(requestURI); String url = super.rewriteUrlFromRequest(servletRequest); if (mediaInfo == null) { - logger.error("[ZLM服务访问代理],错误:处理url信息时未找到流媒体信息=>{}", requestURI); + log.error("[ZLM服务访问代理],错误:处理url信息时未找到流媒体信息=>{}", requestURI); return url; } if (!ObjectUtils.isEmpty(mediaInfo.getId())) { @@ -170,7 +168,7 @@ public class ProxyServletConfig { servletRegistrationBean.setName("record_proxy"); servletRegistrationBean.addInitParameter("targetUri", "http://127.0.0.1:18081"); servletRegistrationBean.addUrlMappings(); - if (logger.isDebugEnabled()) { + if (log.isDebugEnabled()) { servletRegistrationBean.addInitParameter("log", "true"); } return servletRegistrationBean; @@ -214,10 +212,10 @@ public class ProxyServletConfig { try { super.handleRequestException(proxyRequest, proxyResponse, e); } catch (ServletException servletException) { - logger.error("录像服务 代理失败: ", e); + log.error("录像服务 代理失败: ", e); } catch (IOException ioException) { if (ioException instanceof ConnectException) { - logger.error("录像服务 连接失败"); + log.error("录像服务 连接失败"); // }else if (ioException instanceof ClientAbortException) { // /** // * TODO 使用这个代理库实现代理在遇到代理视频文件时,如果是206结果,会遇到报错蛋市目前功能正常, @@ -225,10 +223,10 @@ public class ProxyServletConfig { // */ }else { - logger.error("录像服务 代理失败: ", e); + log.error("录像服务 代理失败: ", e); } } catch (RuntimeException exception){ - logger.error("录像服务 代理失败: ", e); + log.error("录像服务 代理失败: ", e); } } @@ -290,7 +288,7 @@ public class ProxyServletConfig { MediaServer mediaInfo = getMediaInfoByUri(requestURI); String url = super.rewriteUrlFromRequest(servletRequest); if (mediaInfo == null) { - logger.error("[录像服务访问代理],错误:处理url信息时未找到流媒体信息=>{}", requestURI); + log.error("[录像服务访问代理],错误:处理url信息时未找到流媒体信息=>{}", requestURI); return url; } if (!ObjectUtils.isEmpty(mediaInfo.getId())) { diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java b/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java index 7760bddfa..87a26d114 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java @@ -4,11 +4,9 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.service.IPlatformService; -import com.genersoft.iot.vmp.service.impl.PlatformServiceImpl; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; @@ -20,6 +18,7 @@ import java.util.List; * 系统启动时控制上级平台重新注册 * @author lin */ +@Slf4j @Component @Order(value=13) public class SipPlatformRunner implements CommandLineRunner { @@ -36,8 +35,6 @@ public class SipPlatformRunner implements CommandLineRunner { @Autowired private ISIPCommanderForPlatform sipCommanderForPlatform; - private final static Logger logger = LoggerFactory.getLogger(PlatformServiceImpl.class); - @Override public void run(String... args) throws Exception { // 获取所有启用的平台 @@ -59,7 +56,7 @@ public class SipPlatformRunner implements CommandLineRunner { platformService.login(parentPlatform); }); } catch (Exception e) { - logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 注销: {}", e.getMessage()); platformService.offline(parentPlatform, true); continue; } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisRpcConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisRpcConfig.java index 3fcc40c0b..b762838c6 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisRpcConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisRpcConfig.java @@ -7,8 +7,7 @@ import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse; import com.genersoft.iot.vmp.service.redisMsg.control.RedisRpcController; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.redis.connection.Message; @@ -26,11 +25,10 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.SynchronousQueue; import java.util.concurrent.TimeUnit; +@Slf4j @Component public class RedisRpcConfig implements MessageListener { - private final static Logger logger = LoggerFactory.getLogger(RedisRpcConfig.class); - public final static String REDIS_REQUEST_CHANNEL_KEY = "WVP_REDIS_REQUEST_CHANNEL_KEY"; private final Random random = new Random(); @@ -65,10 +63,10 @@ public class RedisRpcConfig implements MessageListener { } else if (redisRpcMessage.getResponse() != null){ handlerResponse(redisRpcMessage.getResponse()); } else { - logger.error("[redis rpc 解析失败] {}", JSON.toJSONString(redisRpcMessage)); + log.error("[redis rpc 解析失败] {}", JSON.toJSONString(redisRpcMessage)); } } catch (Exception e) { - logger.error("[redis rpc 解析异常] ", e); + log.error("[redis rpc 解析异常] ", e); } } }); @@ -79,7 +77,7 @@ public class RedisRpcConfig implements MessageListener { if (userSetting.getServerId().equals(response.getToId())) { return; } - logger.info("[redis-rpc] << {}", response); + log.info("[redis-rpc] << {}", response); response(response); } @@ -88,7 +86,7 @@ public class RedisRpcConfig implements MessageListener { if (userSetting.getServerId().equals(request.getFromId())) { return; } - logger.info("[redis-rpc] << {}", request); + log.info("[redis-rpc] << {}", request); Method method = getMethod(request.getUri()); // 没有携带目标ID的可以理解为哪个wvp有结果就哪个回复,携带目标ID,但是如果是不存在的uri则直接回复404 if (userSetting.getServerId().equals(request.getToId())) { @@ -113,7 +111,7 @@ public class RedisRpcConfig implements MessageListener { } } }catch (InvocationTargetException | IllegalAccessException e) { - logger.error("[redis rpc ] 处理请求失败 ", e); + log.error("[redis rpc ] 处理请求失败 ", e); } } @@ -130,7 +128,7 @@ public class RedisRpcConfig implements MessageListener { } private void sendResponse(RedisRpcResponse response){ - logger.info("[redis-rpc] >> {}", response); + log.info("[redis-rpc] >> {}", response); response.setToId(userSetting.getServerId()); RedisRpcMessage message = new RedisRpcMessage(); message.setResponse(response); @@ -138,7 +136,7 @@ public class RedisRpcConfig implements MessageListener { } private void sendRequest(RedisRpcRequest request){ - logger.info("[redis-rpc] >> {}", request); + log.info("[redis-rpc] >> {}", request); RedisRpcMessage message = new RedisRpcMessage(); message.setRequest(request); redisTemplate.convertAndSend(REDIS_REQUEST_CHANNEL_KEY, message); @@ -156,7 +154,7 @@ public class RedisRpcConfig implements MessageListener { sendRequest(request); return subscribe.poll(timeOut, TimeUnit.SECONDS); } catch (InterruptedException e) { - logger.warn("[redis rpc timeout] uri: {}, sn: {}", request.getUri(), request.getSn(), e); + log.warn("[redis rpc timeout] uri: {}, sn: {}", request.getUri(), request.getSn(), e); } finally { this.unsubscribe(request.getSn()); } @@ -176,7 +174,7 @@ public class RedisRpcConfig implements MessageListener { try { return queue.offer(response, 2, TimeUnit.SECONDS); } catch (InterruptedException e) { - logger.error("{}", e.getMessage(), e); + log.error("{}", e.getMessage(), e); } }else if (callback != null) { callback.run(response); diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/DefaultUserDetailsServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/conf/security/DefaultUserDetailsServiceImpl.java index 0cda4a5cd..d21fdaaff 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/DefaultUserDetailsServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/DefaultUserDetailsServiceImpl.java @@ -4,8 +4,7 @@ import com.alibaba.excel.util.StringUtils; import com.genersoft.iot.vmp.conf.security.dto.LoginUser; import com.genersoft.iot.vmp.service.IUserService; import com.genersoft.iot.vmp.storager.dao.dto.User; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; @@ -17,25 +16,24 @@ import java.time.LocalDateTime; /** * 用户登录认证逻辑 */ +@Slf4j @Component public class DefaultUserDetailsServiceImpl implements UserDetailsService { - private final static Logger logger = LoggerFactory.getLogger(DefaultUserDetailsServiceImpl.class); - @Autowired private IUserService userService; @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { if (StringUtils.isBlank(username)) { - logger.info("登录用户:{} 不存在", username); + log.info("登录用户:{} 不存在", username); throw new UsernameNotFoundException("登录用户:" + username + " 不存在"); } // 查出密码 User user = userService.getUserByUsername(username); if (user == null) { - logger.info("登录用户:{} 不存在", username); + log.info("登录用户:{} 不存在", username); throw new UsernameNotFoundException("登录用户:" + username + " 不存在"); } String password = SecurityUtils.encryptPassword(user.getPassword()); diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/LogoutHandler.java b/src/main/java/com/genersoft/iot/vmp/conf/security/LogoutHandler.java index 790eab842..48b40cbec 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/LogoutHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/LogoutHandler.java @@ -1,7 +1,6 @@ package com.genersoft.iot.vmp.conf.security; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; import org.springframework.stereotype.Component; @@ -14,14 +13,13 @@ import java.io.IOException; /** * 退出登录成功 */ +@Slf4j @Component public class LogoutHandler implements LogoutSuccessHandler { - private final static Logger logger = LoggerFactory.getLogger(LogoutHandler.class); - @Override public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException { String username = request.getParameter("username"); - logger.info("[退出登录成功] - [{}]", username); + log.info("[退出登录成功] - [{}]", username); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java index fa93c53eb..0b898b408 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java @@ -202,6 +202,9 @@ public class CommonGBChannel { @Schema(description = "国标-国民经济行业分类代码(可选)") private String gbIndustrialClassification; + @Schema(description = "关联的国标设备数据库ID") + private Integer gbDeviceDbId; + @Schema(description = "关联的推流Id(流来源是推流时有效)") private Integer streamPushId; @@ -211,12 +214,12 @@ public class CommonGBChannel { public String encode(){ return encode(null); } - public String encode(CatalogEvent event){ + public String encode(String event){ String content; if (event == null) { return getFullContent(null); } - switch (event.getType()) { + switch (event) { case CatalogEvent.DEL: case CatalogEvent.DEFECT: case CatalogEvent.VLOST: @@ -234,7 +237,7 @@ public class CommonGBChannel { break; case CatalogEvent.ADD: case CatalogEvent.UPDATE: - content = getFullContent(event.getType()); + content = getFullContent(event); break; default: content = null; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java index a9752f127..9c34c63b1 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java @@ -2,14 +2,19 @@ package com.genersoft.iot.vmp.gb28181.bean; import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; /** * 国标设备/平台 * @author lin */ +@Data @Schema(description = "国标设备/平台") public class Device { + @Schema(description = "数据库自增ID") + private int id; + /** * 设备国标编号 */ @@ -190,273 +195,4 @@ public class Device { @Schema(description = "控制语音对讲流程,释放收到ACK后发流") private boolean broadcastPushAfterAck; - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getManufacturer() { - return manufacturer; - } - - public void setManufacturer(String manufacturer) { - this.manufacturer = manufacturer; - } - - public String getModel() { - return model; - } - - public void setModel(String model) { - this.model = model; - } - - public String getFirmware() { - return firmware; - } - - public void setFirmware(String firmware) { - this.firmware = firmware; - } - - public String getTransport() { - return transport; - } - - public void setTransport(String transport) { - this.transport = transport; - } - - public String getStreamMode() { - return streamMode; - } - - public Integer getStreamModeForParam() { - if (streamMode == null) { - return 0; - } - if (streamMode.equalsIgnoreCase("UDP")) { - return 0; - }else if (streamMode.equalsIgnoreCase("TCP-PASSIVE")) { - return 1; - }else if (streamMode.equalsIgnoreCase("TCP-ACTIVE")) { - return 2; - } - return 0; - } - - public void setStreamMode(String streamMode) { - this.streamMode = streamMode; - } - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getHostAddress() { - return hostAddress; - } - - public void setHostAddress(String hostAddress) { - this.hostAddress = hostAddress; - } - - public boolean isOnLine() { - return onLine; - } - - public void setOnLine(boolean onLine) { - this.onLine = onLine; - } - - public int getChannelCount() { - return channelCount; - } - - public void setChannelCount(int channelCount) { - this.channelCount = channelCount; - } - - public String getRegisterTime() { - return registerTime; - } - - public void setRegisterTime(String registerTime) { - this.registerTime = registerTime; - } - - public String getKeepaliveTime() { - return keepaliveTime; - } - - public void setKeepaliveTime(String keepaliveTime) { - this.keepaliveTime = keepaliveTime; - } - - public int getExpires() { - return expires; - } - - public void setExpires(int expires) { - this.expires = expires; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getMediaServerId() { - return mediaServerId; - } - - public void setMediaServerId(String mediaServerId) { - this.mediaServerId = mediaServerId; - } - - public String getCharset() { - return charset; - } - - public void setCharset(String charset) { - this.charset = charset; - } - - public int getSubscribeCycleForCatalog() { - return subscribeCycleForCatalog; - } - - public void setSubscribeCycleForCatalog(int subscribeCycleForCatalog) { - this.subscribeCycleForCatalog = subscribeCycleForCatalog; - } - - public int getSubscribeCycleForMobilePosition() { - return subscribeCycleForMobilePosition; - } - - public void setSubscribeCycleForMobilePosition(int subscribeCycleForMobilePosition) { - this.subscribeCycleForMobilePosition = subscribeCycleForMobilePosition; - } - - public int getMobilePositionSubmissionInterval() { - return mobilePositionSubmissionInterval; - } - - public void setMobilePositionSubmissionInterval(int mobilePositionSubmissionInterval) { - this.mobilePositionSubmissionInterval = mobilePositionSubmissionInterval; - } - - public int getSubscribeCycleForAlarm() { - return subscribeCycleForAlarm; - } - - public void setSubscribeCycleForAlarm(int subscribeCycleForAlarm) { - this.subscribeCycleForAlarm = subscribeCycleForAlarm; - } - - public boolean isSsrcCheck() { - return ssrcCheck; - } - - public void setSsrcCheck(boolean ssrcCheck) { - this.ssrcCheck = ssrcCheck; - } - - public String getGeoCoordSys() { - return geoCoordSys; - } - - public void setGeoCoordSys(String geoCoordSys) { - this.geoCoordSys = geoCoordSys; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getSdpIp() { - return sdpIp; - } - - public void setSdpIp(String sdpIp) { - this.sdpIp = sdpIp; - } - - public String getLocalIp() { - return localIp; - } - - public void setLocalIp(String localIp) { - this.localIp = localIp; - } - - public int getKeepaliveIntervalTime() { - return keepaliveIntervalTime; - } - - public void setKeepaliveIntervalTime(int keepaliveIntervalTime) { - this.keepaliveIntervalTime = keepaliveIntervalTime; - } - - public boolean isAsMessageChannel() { - return asMessageChannel; - } - - public void setAsMessageChannel(boolean asMessageChannel) { - this.asMessageChannel = asMessageChannel; - } - - public SipTransactionInfo getSipTransactionInfo() { - return sipTransactionInfo; - } - - public void setSipTransactionInfo(SipTransactionInfo sipTransactionInfo) { - this.sipTransactionInfo = sipTransactionInfo; - } - public boolean isBroadcastPushAfterAck() { - return broadcastPushAfterAck; - } - - public void setBroadcastPushAfterAck(boolean broadcastPushAfterAck) { - this.broadcastPushAfterAck = broadcastPushAfterAck; - } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java index 19000930c..8b08930ce 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java @@ -1,11 +1,14 @@ package com.genersoft.iot.vmp.gb28181.bean; +import lombok.Data; + /** * @description: 移动位置bean * @author: lawrencehj * @date: 2021年1月23日 */ +@Data public class MobilePosition { /** * 设备Id @@ -56,150 +59,8 @@ public class MobilePosition { * 位置信息上报来源(Mobile Position、GPS Alarm) */ private String reportSource; - - /** - * 国内坐标系:经度坐标 - */ - private double longitudeGcj02; - - /** - * 国内坐标系:纬度坐标 - */ - private double latitudeGcj02; - - /** - * 国内坐标系:经度坐标 - */ - private double longitudeWgs84; - - /** - * 国内坐标系:纬度坐标 - */ - private double latitudeWgs84; - /** * 创建时间 */ private String createTime; - - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getDeviceName() { - return deviceName; - } - - public void setDeviceName(String deviceName) { - this.deviceName = deviceName; - } - - public String getTime() { - return time; - } - - public void setTime(String time) { - this.time = time; - } - - public double getLongitude() { - return longitude; - } - - public void setLongitude(double longitude) { - this.longitude = longitude; - } - - public double getLatitude() { - return latitude; - } - - public void setLatitude(double latitude) { - this.latitude = latitude; - } - - public double getAltitude() { - return altitude; - } - - public void setAltitude(double altitude) { - this.altitude = altitude; - } - - public double getSpeed() { - return speed; - } - - public void setSpeed(double speed) { - this.speed = speed; - } - - public double getDirection() { - return direction; - } - - public void setDirection(double direction) { - this.direction = direction; - } - - public String getReportSource() { - return reportSource; - } - - public void setReportSource(String reportSource) { - this.reportSource = reportSource; - } - - public String getChannelId() { - return channelId; - } - - public void setChannelId(String channelId) { - this.channelId = channelId; - } - - public double getLongitudeGcj02() { - return longitudeGcj02; - } - - public void setLongitudeGcj02(double longitudeGcj02) { - this.longitudeGcj02 = longitudeGcj02; - } - - public double getLatitudeGcj02() { - return latitudeGcj02; - } - - public void setLatitudeGcj02(double latitudeGcj02) { - this.latitudeGcj02 = latitudeGcj02; - } - - public double getLongitudeWgs84() { - return longitudeWgs84; - } - - public void setLongitudeWgs84(double longitudeWgs84) { - this.longitudeWgs84 = longitudeWgs84; - } - - public double getLatitudeWgs84() { - return latitudeWgs84; - } - - public void setLatitudeWgs84(double latitudeWgs84) { - this.latitudeWgs84 = latitudeWgs84; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java index b87684a87..fadf73854 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java @@ -52,8 +52,8 @@ public class EventPublisher { } - public void catalogEventPublish(String platformId, DeviceChannel deviceChannel, String type) { - List deviceChannelList = new ArrayList<>(); + public void catalogEventPublish(String platformId, CommonGBChannel deviceChannel, String type) { + List deviceChannelList = new ArrayList<>(); deviceChannelList.add(deviceChannel); catalogEventPublish(platformId, deviceChannelList, type); } @@ -72,22 +72,22 @@ public class EventPublisher { * @param deviceChannels * @param type */ - public void catalogEventPublish(String platformId, List deviceChannels, String type) { + public void catalogEventPublish(String platformId, List deviceChannels, String type) { CatalogEvent outEvent = new CatalogEvent(this); - List channels = new ArrayList<>(); + List channels = new ArrayList<>(); if (deviceChannels.size() > 1) { // 数据去重 Set gbIdSet = new HashSet<>(); - for (DeviceChannel deviceChannel : deviceChannels) { - if (deviceChannel != null && deviceChannel.getChannelId() != null && !gbIdSet.contains(deviceChannel.getChannelId())) { - gbIdSet.add(deviceChannel.getChannelId()); + for (CommonGBChannel deviceChannel : deviceChannels) { + if (deviceChannel != null && deviceChannel.getGbDeviceId() != null && !gbIdSet.contains(deviceChannel.getGbDeviceId())) { + gbIdSet.add(deviceChannel.getGbDeviceId()); channels.add(deviceChannel); } } }else { channels = deviceChannels; } - outEvent.setDeviceChannels(channels); + outEvent.setChannels(channels); outEvent.setType(type); outEvent.setPlatformId(platformId); applicationEventPublisher.publishEvent(outEvent); @@ -100,22 +100,6 @@ public class EventPublisher { applicationEventPublisher.publishEvent(event); } - - public void catalogEventPublishForStream(String platformId, List gbStreams, String type) { - CatalogEvent outEvent = new CatalogEvent(this); - outEvent.setGbStreams(gbStreams); - outEvent.setType(type); - outEvent.setPlatformId(platformId); - applicationEventPublisher.publishEvent(outEvent); - } - - - public void catalogEventPublishForStream(String platformId, GbStream gbStream, String type) { - List gbStreamList = new ArrayList<>(); - gbStreamList.add(gbStream); - catalogEventPublishForStream(platformId, gbStreamList, type); - } - public void recordEndEventPush(RecordInfo recordInfo) { RecordEndEvent outEvent = new RecordEndEvent(this); outEvent.setRecordInfo(recordInfo); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java index e07761a91..ed78badd4 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java @@ -27,13 +27,13 @@ public class SipSubscribe { private final Logger logger = LoggerFactory.getLogger(SipSubscribe.class); - private Map errorSubscribes = new ConcurrentHashMap<>(); + private final Map errorSubscribes = new ConcurrentHashMap<>(); - private Map okSubscribes = new ConcurrentHashMap<>(); + private final Map okSubscribes = new ConcurrentHashMap<>(); - private Map okTimeSubscribes = new ConcurrentHashMap<>(); + private final Map okTimeSubscribes = new ConcurrentHashMap<>(); - private Map errorTimeSubscribes = new ConcurrentHashMap<>(); + private final Map errorTimeSubscribes = new ConcurrentHashMap<>(); // @Scheduled(cron="*/5 * * * * ?") //每五秒执行一次 // @Scheduled(fixedRate= 100 * 60 * 60 ) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java index e6cfac3d5..067c7f242 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java @@ -1,10 +1,7 @@ package com.genersoft.iot.vmp.gb28181.event.record; import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; -import com.genersoft.iot.vmp.utils.redis.RedisUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; +import lombok.extern.slf4j.Slf4j; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; @@ -16,12 +13,10 @@ import java.util.concurrent.ConcurrentHashMap; * @author: pan * @data: 2022-02-23 */ - +@Slf4j @Component public class RecordEndEventListener implements ApplicationListener { - private final static Logger logger = LoggerFactory.getLogger(RecordEndEventListener.class); - private Map handlerMap = new ConcurrentHashMap<>(); public interface RecordEndEventHandler{ void handler(RecordInfo recordInfo); @@ -33,11 +28,11 @@ public class RecordEndEventListener implements ApplicationListener deviceChannels; - private List gbStreams; + @Setter + @Getter + private List channels; + + @Setter + @Getter private String type; + + @Setter + @Getter private String platformId; - public List getDeviceChannels() { - return deviceChannels; - } - - public void setDeviceChannels(List deviceChannels) { - this.deviceChannels = deviceChannels; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getPlatformId() { - return platformId; - } - - public void setPlatformId(String platformId) { - this.platformId = platformId; - } - - public List getGbStreams() { - return gbStreams; - } - - public void setGbStreams(List gbStreams) { - this.gbStreams = gbStreams; - } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java index 9c65b873c..f8020b353 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java @@ -2,7 +2,7 @@ package com.genersoft.iot.vmp.gb28181.event.subscribe.catalog; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.service.IGbStreamService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import lombok.extern.slf4j.Slf4j; @@ -30,7 +30,7 @@ public class CatalogEventLister implements ApplicationListener { private IVideoManagerStorage storager; @Autowired - private SIPCommanderFroPlatform sipCommanderFroPlatform; + private ISIPCommanderForPlatform sipCommanderFroPlatform; @Autowired private IGbStreamService gbStreamService; @@ -47,7 +47,7 @@ public class CatalogEventLister implements ApplicationListener { ParentPlatform parentPlatform = null; Map> parentPlatformMap = new HashMap<>(); - Map channelMap = new HashMap<>(); + Map channelMap = new HashMap<>(); if (!ObjectUtils.isEmpty(event.getPlatformId())) { subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId()); if (subscribe == null) { @@ -61,22 +61,12 @@ public class CatalogEventLister implements ApplicationListener { }else { // 获取所用订阅 List platforms = subscribeHolder.getAllCatalogSubscribePlatform(); - if (event.getDeviceChannels() != null) { + if (event.getChannels() != null) { if (platforms.size() > 0) { - for (DeviceChannel deviceChannel : event.getDeviceChannels()) { - List parentPlatformsForGB = storager.queryPlatFormListForGBWithGBId(deviceChannel.getDeviceId(), platforms); - parentPlatformMap.put(deviceChannel.getDeviceId(), parentPlatformsForGB); - channelMap.put(deviceChannel.getDeviceId(), deviceChannel); - } - } - }else if (event.getGbStreams() != null) { - if (platforms.size() > 0) { - for (GbStream gbStream : event.getGbStreams()) { - if (gbStream == null || ObjectUtils.isEmpty(gbStream.getGbId())) { - continue; - } - List parentPlatformsForGB = storager.queryPlatFormListForStreamWithGBId(gbStream.getApp(),gbStream.getStream(), platforms); - parentPlatformMap.put(gbStream.getGbId(), parentPlatformsForGB); + for (CommonGBChannel deviceChannel : event.getChannels()) { + List parentPlatformsForGB = storager.queryPlatFormListForGBWithGBId(deviceChannel.getGbDeviceId(), platforms); + parentPlatformMap.put(deviceChannel.getGbDeviceId(), parentPlatformsForGB); + channelMap.put(deviceChannel.getGbDeviceId(), deviceChannel); } } } @@ -87,21 +77,9 @@ public class CatalogEventLister implements ApplicationListener { case CatalogEvent.DEL: if (parentPlatform != null || subscribe != null) { - List deviceChannelList = new ArrayList<>(); - if (event.getDeviceChannels() != null) { - deviceChannelList.addAll(event.getDeviceChannels()); - } - if (event.getGbStreams() != null && event.getGbStreams().size() > 0){ - for (GbStream gbStream : event.getGbStreams()) { - if (gbStream != null - && gbStream.getStreamType() != null - && gbStream.getStreamType().equals("push") - && !userSetting.isUsePushingAsStatus()) { - continue; - } - DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), parentPlatform); - deviceChannelList.add(deviceChannelByStream); - } + List deviceChannelList = new ArrayList<>(); + if (event.getChannels() != null) { + deviceChannelList.addAll(event.getChannels()); } if (deviceChannelList.size() > 0) { log.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), deviceChannelList.size()); @@ -122,9 +100,9 @@ public class CatalogEventLister implements ApplicationListener { continue; } log.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId); - List deviceChannelList = new ArrayList<>(); - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setDeviceId(gbId); + List deviceChannelList = new ArrayList<>(); + CommonGBChannel deviceChannel = new CommonGBChannel(); + deviceChannel.setGbDeviceId(gbId); deviceChannelList.add(deviceChannel); try { sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), platform, deviceChannelList, subscribeInfo, null); @@ -144,16 +122,10 @@ public class CatalogEventLister implements ApplicationListener { case CatalogEvent.ADD: case CatalogEvent.UPDATE: if (parentPlatform != null || subscribe != null) { - List deviceChannelList = new ArrayList<>(); - if (event.getDeviceChannels() != null) { - deviceChannelList.addAll(event.getDeviceChannels()); + List deviceChannelList = new ArrayList<>(); + if (event.getChannels() != null) { + deviceChannelList.addAll(event.getChannels()); } - if (event.getGbStreams() != null && !event.getGbStreams().isEmpty()){ - for (GbStream gbStream : event.getGbStreams()) { - deviceChannelList.add( - gbStreamService.getDeviceChannelListByStreamWithStatus(gbStream, gbStream.getCatalogId(), parentPlatform)); - } - } if (!deviceChannelList.isEmpty()) { log.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), deviceChannelList.size()); try { @@ -173,12 +145,12 @@ public class CatalogEventLister implements ApplicationListener { continue; } log.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId); - List deviceChannelList = new ArrayList<>(); - DeviceChannel deviceChannel = channelMap.get(gbId); + List deviceChannelList = new ArrayList<>(); + CommonGBChannel deviceChannel = channelMap.get(gbId); deviceChannelList.add(deviceChannel); GbStream gbStream = storager.queryStreamInParentPlatform(platform.getServerGBId(), gbId); if(gbStream != null){ - DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStreamWithStatus(gbStream, gbStream.getCatalogId(), platform); + CommonGBChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStreamWithStatus(gbStream, gbStream.getCatalogId(), platform); deviceChannelList.add(deviceChannelByStream); } try { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java index ddd051724..4007d19c3 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java @@ -27,4 +27,6 @@ public interface IGbChannelService { void batchAdd(List commonGBChannels); void updateStatus(List channelList); + + List queryByPlatformId(Integer platformId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java index adf5251c4..eb31b94ae 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java @@ -7,4 +7,6 @@ import org.springframework.stereotype.Service; @Slf4j @Service public class GbChannelServiceImpl implements IGbChannelService { + + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java index 38cdf7c45..e792cf0de 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java @@ -4,6 +4,7 @@ import com.genersoft.iot.vmp.gb28181.bean.CatalogData; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.SyncStatus; +import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; @@ -22,6 +23,9 @@ public class CatalogDataCatch { @Autowired private IVideoManagerStorage storager; + @Autowired + private IDeviceChannelService deviceChannelService; + public void addReady(Device device, int sn ) { CatalogData catalogData = data.get(device.getDeviceId()); if (catalogData == null || catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end)) { @@ -113,9 +117,9 @@ public class CatalogDataCatch { // 超过五秒收不到消息任务超时, 只更新这一部分数据, 收到数据与声明的总数一致,则重置通道数据,数据不全则只对收到的数据做更新操作 if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.runIng)) { if (catalogData.getTotal() == catalogData.getChannelList().size()) { - storager.resetChannels(catalogData.getDevice().getDeviceId(), catalogData.getChannelList()); + deviceChannelService.resetChannels(catalogData.getDevice().getDeviceId(), catalogData.getChannelList()); }else { - storager.updateChannels(catalogData.getDevice().getDeviceId(), catalogData.getChannelList()); + deviceChannelService.updateChannels(catalogData.getDevice().getDeviceId(), catalogData.getChannelList()); } String errorMsg = "更新成功,共" + catalogData.getTotal() + "条,已更新" + catalogData.getChannelList().size() + "条"; catalogData.setErrorMsg(errorMsg); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java index e2b2223fd..ce6985f51 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java @@ -1,18 +1,16 @@ package com.genersoft.iot.vmp.gb28181.task; -import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.media.bean.MediaServer; -import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.media.service.IMediaServerService; +import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IPlatformService; import com.genersoft.iot.vmp.service.impl.PlatformServiceImpl; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -36,18 +34,12 @@ import java.util.Map; @Order(value=14) public class SipRunner implements CommandLineRunner { - @Autowired - private IVideoManagerStorage storager; - @Autowired private IRedisCatchStorage redisCatchStorage; @Autowired private SSRCFactory ssrcFactory; - @Autowired - private UserSetting userSetting; - @Autowired private IDeviceService deviceService; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java index d9270bbf0..d4cef73b6 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java @@ -22,13 +22,13 @@ import java.text.ParseException; */ public class CatalogSubscribeTask implements ISubscribeTask { private final Logger logger = LoggerFactory.getLogger(CatalogSubscribeTask.class); - private Device device; + private final Device device; private final ISIPCommander sipCommander; private SIPRequest request; - private DynamicTask dynamicTask; + private final DynamicTask dynamicTask; - private String taskKey = "catalog-subscribe-timeout"; + private final String taskKey = "catalog-subscribe-timeout"; public CatalogSubscribeTask(Device device, ISIPCommander sipCommander, DynamicTask dynamicTask) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java index 9fed0793b..4120d0d4f 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java @@ -21,12 +21,12 @@ import java.text.ParseException; */ public class MobilePositionSubscribeTask implements ISubscribeTask { private final Logger logger = LoggerFactory.getLogger(MobilePositionSubscribeTask.class); - private Device device; - private ISIPCommander sipCommander; + private final Device device; + private final ISIPCommander sipCommander; private SIPRequest request; - private DynamicTask dynamicTask; - private String taskKey = "mobile-position-subscribe-timeout"; + private final DynamicTask dynamicTask; + private final String taskKey = "mobile-position-subscribe-timeout"; public MobilePositionSubscribeTask(Device device, ISIPCommander sipCommander, DynamicTask dynamicTask) { this.device = device; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java index 52356c1df..faf242328 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java @@ -5,18 +5,16 @@ import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; import com.genersoft.iot.vmp.gb28181.transmit.event.response.ISIPResponseProcessor; import com.genersoft.iot.vmp.gb28181.transmit.event.timeout.ITimeoutProcessor; -import gov.nist.javax.sip.message.SIPRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; import javax.sip.*; -import javax.sip.header.*; +import javax.sip.header.CSeqHeader; +import javax.sip.header.CallIdHeader; import javax.sip.message.Request; import javax.sip.message.Response; -import java.net.InetAddress; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -25,11 +23,10 @@ import java.util.concurrent.ConcurrentHashMap; * @author: panlinlin * @date: 2021年11月5日 下午15:32 */ +@Slf4j @Component public class SIPProcessorObserver implements ISIPProcessorObserver { - private final static Logger logger = LoggerFactory.getLogger(SIPProcessorObserver.class); - private static Map requestProcessorMap = new ConcurrentHashMap<>(); private static Map responseProcessorMap = new ConcurrentHashMap<>(); private static ITimeoutProcessor timeoutProcessor; @@ -76,7 +73,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { String method = requestEvent.getRequest().getMethod(); ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method); if (sipRequestProcessor == null) { - logger.warn("不支持方法{}的request", method); + log.warn("不支持方法{}的request", method); // TODO 回复错误玛 return; } @@ -116,7 +113,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { } else if ((status >= Response.TRYING) && (status < Response.OK)) { // 增加其它无需回复的响应,如101、180等 } else { - logger.warn("接收到失败的response响应!status:" + status + ",message:" + response.getReasonPhrase()); + log.warn("接收到失败的response响应!status:" + status + ",message:" + response.getReasonPhrase()); if (responseEvent.getResponse() != null && sipSubscribe.getErrorSubscribesSize() > 0 ) { CallIdHeader callIdHeader = (CallIdHeader)responseEvent.getResponse().getHeader(CallIdHeader.NAME); if (callIdHeader != null) { @@ -142,17 +139,17 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { */ @Override public void processTimeout(TimeoutEvent timeoutEvent) { - logger.info("[消息发送超时]"); + log.info("[消息发送超时]"); ClientTransaction clientTransaction = timeoutEvent.getClientTransaction(); if (clientTransaction != null) { - logger.info("[发送错误订阅] clientTransaction != null"); + log.info("[发送错误订阅] clientTransaction != null"); Request request = clientTransaction.getRequest(); if (request != null) { - logger.info("[发送错误订阅] request != null"); + log.info("[发送错误订阅] request != null"); CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME); if (callIdHeader != null) { - logger.info("[发送错误订阅]"); + log.info("[发送错误订阅]"); SipSubscribe.Event subscribe = sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()); SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(timeoutEvent); if (subscribe != null){ diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java index ce1074bd6..1dea88829 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java @@ -5,8 +5,7 @@ import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.utils.GitUtil; import gov.nist.javax.sip.SipProviderImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.ObjectUtils; @@ -24,11 +23,10 @@ import java.text.ParseException; * 发送SIP消息 * @author lin */ +@Slf4j @Component public class SIPSender { - private final Logger logger = LoggerFactory.getLogger(SIPSender.class); - @Autowired private SipLayer sipLayer; @@ -50,7 +48,7 @@ public class SIPSender { ViaHeader viaHeader = (ViaHeader)message.getHeader(ViaHeader.NAME); String transport = "UDP"; if (viaHeader == null) { - logger.warn("[消息头缺失]: ViaHeader, 使用默认的UDP方式处理数据"); + log.warn("[消息头缺失]: ViaHeader, 使用默认的UDP方式处理数据"); }else { transport = viaHeader.getTransport(); } @@ -58,7 +56,7 @@ public class SIPSender { try { message.addHeader(SipUtils.createUserAgentHeader(gitUtil)); } catch (ParseException e) { - logger.error("添加UserAgentHeader失败", e); + log.error("添加UserAgentHeader失败", e); } } @@ -82,7 +80,7 @@ public class SIPSender { if ("TCP".equals(transport)) { SipProviderImpl tcpSipProvider = sipLayer.getTcpSipProvider(ip); if (tcpSipProvider == null) { - logger.error("[发送信息失败] 未找到tcp://{}的监听信息", ip); + log.error("[发送信息失败] 未找到tcp://{}的监听信息", ip); return; } if (message instanceof Request) { @@ -94,7 +92,7 @@ public class SIPSender { } else if ("UDP".equals(transport)) { SipProviderImpl sipProvider = sipLayer.getUdpSipProvider(ip); if (sipProvider == null) { - logger.error("[发送信息失败] 未找到udp://{}的监听信息", ip); + log.error("[发送信息失败] 未找到udp://{}的监听信息", ip); return; } if (message instanceof Request) { @@ -125,7 +123,7 @@ public class SIPSender { if (sipProvider != null) { return sipProvider.getNewCallId(); }else { - logger.warn("[新建CallIdHeader失败], ip={}, transport={}", ip, transport); + log.warn("[新建CallIdHeader失败], ip={}, transport={}", ip, transport); return null; } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java index 8d0ed7fb4..61aaac4a0 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java @@ -68,12 +68,8 @@ public class DeferredResultHolder { } public void put(String key, String id, DeferredResult result) { - Map deferredResultMap = map.get(key); - if (deferredResultMap == null) { - deferredResultMap = new ConcurrentHashMap<>(); - map.put(key, deferredResultMap); - } - deferredResultMap.put(id, new DeferredResultEx(result)); + Map deferredResultMap = map.computeIfAbsent(key, k -> new ConcurrentHashMap<>()); + deferredResultMap.put(id, new DeferredResultEx(result)); } public DeferredResultEx get(String key, String id) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/RequestMessage.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/RequestMessage.java index f4e2d2013..5a22f6df9 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/RequestMessage.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/RequestMessage.java @@ -1,10 +1,13 @@ package com.genersoft.iot.vmp.gb28181.transmit.callback; -/** +import lombok.Data; + +/** * @description: 请求信息定义 * @author: swwheihei * @date: 2020年5月8日 下午1:09:18 */ +@Data public class RequestMessage { private String id; @@ -12,28 +15,4 @@ public class RequestMessage { private String key; private Object data; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public void setKey(String key) { - this.key = key; - } - - public String getKey() { - return key; - } - - public Object getData() { - return data; - } - - public void setData(Object data) { - this.data = data; - } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java index bc999f037..dbf800d8b 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java @@ -58,10 +58,10 @@ public interface ISIPCommanderForPlatform { * @param size * @return */ - void catalogQuery(DeviceChannel channel, ParentPlatform parentPlatform, String sn, String fromTag, int size) + void catalogQuery(CommonGBChannel channel, ParentPlatform parentPlatform, String sn, String fromTag, int size) throws SipException, InvalidArgumentException, ParseException; - void catalogQuery(List channels, ParentPlatform parentPlatform, String sn, String fromTag) + void catalogQuery(List channels, ParentPlatform parentPlatform, String sn, String fromTag) throws InvalidArgumentException, ParseException, SipException; /** @@ -110,7 +110,7 @@ public interface ISIPCommanderForPlatform { * @param parentPlatform * @param deviceChannels */ - void sendNotifyForCatalogAddOrUpdate(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException; + void sendNotifyForCatalogAddOrUpdate(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException; /** * 回复catalog事件-删除 @@ -118,7 +118,7 @@ public interface ISIPCommanderForPlatform { * @param parentPlatform * @param deviceChannels */ - void sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List deviceChannels, + void sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException; @@ -130,7 +130,7 @@ public interface ISIPCommanderForPlatform { * @param fromTag fromTag * @param recordInfo 录像信息 */ - void recordInfo(DeviceChannel deviceChannel, ParentPlatform parentPlatform, String fromTag, RecordInfo recordInfo) + void recordInfo(CommonGBChannel deviceChannel, ParentPlatform parentPlatform, String fromTag, RecordInfo recordInfo) throws SipException, InvalidArgumentException, ParseException; /** @@ -158,5 +158,5 @@ public interface ISIPCommanderForPlatform { SSRCInfo ssrcInfo, HookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws ParseException, SipException, InvalidArgumentException; - void broadcastResultCmd(ParentPlatform platform, DeviceChannel deviceChannel, String sn, boolean result, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; + void broadcastResultCmd(ParentPlatform platform, CommonGBChannel deviceChannel, String sn, boolean result, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index e27343ce5..2beb481de 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -14,17 +14,16 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider; import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; import com.genersoft.iot.vmp.gb28181.utils.SipUtils; +import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.event.hook.Hook; import com.genersoft.iot.vmp.media.event.hook.HookSubscribe; import com.genersoft.iot.vmp.media.event.hook.HookType; import com.genersoft.iot.vmp.media.service.IMediaServerService; -import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.service.bean.SSRCInfo; import com.genersoft.iot.vmp.utils.DateUtil; import gov.nist.javax.sip.message.SIPRequest; import gov.nist.javax.sip.message.SIPResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.DependsOn; import org.springframework.stereotype.Component; @@ -46,10 +45,9 @@ import java.util.List; */ @Component @DependsOn("sipLayer") +@Slf4j public class SIPCommander implements ISIPCommander { - private final Logger logger = LoggerFactory.getLogger(SIPCommander.class); - @Autowired private SipConfig sipConfig; @@ -273,7 +271,7 @@ public class SIPCommander implements ISIPCommander { return; } - logger.info("{} 分配的ZLM为: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getSdpIp(), ssrcInfo.getPort()); + log.info("{} 分配的ZLM为: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getSdpIp(), ssrcInfo.getPort()); Hook rtpHook = Hook.getInstance(HookType.on_media_arrival, "rtp", stream, mediaServerItem.getId()); subscribe.addSubscribe(rtpHook, (hookData) -> { if (event != null) { @@ -289,7 +287,7 @@ public class SIPCommander implements ISIPCommander { } StringBuffer content = new StringBuffer(200); content.append("v=0\r\n"); - content.append("o=" + channel.getChannelId() + " 0 0 IN IP4 " + sdpIp + "\r\n"); + content.append("o=" + channel.getDeviceId() + " 0 0 IN IP4 " + sdpIp + "\r\n"); content.append("s=Play\r\n"); content.append("c=IN IP4 " + sdpIp + "\r\n"); content.append("t=0 0\r\n"); @@ -350,16 +348,16 @@ public class SIPCommander implements ISIPCommander { - Request request = headerProvider.createInviteRequest(device, channel.getChannelId(), content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, ssrcInfo.getSsrc(),sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); + Request request = headerProvider.createInviteRequest(device, channel.getDeviceId(), content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, ssrcInfo.getSsrc(),sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, (e -> { - streamSession.remove(device.getDeviceId(), channel.getChannelId(), ssrcInfo.getStream()); + streamSession.remove(device.getDeviceId(), channel.getDeviceId(), ssrcInfo.getStream()); mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); errorEvent.response(e); }), e -> { ResponseEvent responseEvent = (ResponseEvent) e.event; SIPResponse response = (SIPResponse) responseEvent.getResponse(); String callId = response.getCallIdHeader().getCallId(); - streamSession.put(device.getDeviceId(), channel.getChannelId(), callId, stream, ssrcInfo.getSsrc(), mediaServerItem.getId(), response, + streamSession.put(device.getDeviceId(), channel.getDeviceId(), callId, stream, ssrcInfo.getSsrc(), mediaServerItem.getId(), response, InviteSessionType.PLAY); okEvent.response(e); }); @@ -379,7 +377,7 @@ public class SIPCommander implements ISIPCommander { SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { - logger.info("{} 分配的ZLM为: {} [{}:{}]", ssrcInfo.getStream(), mediaServerItem.getId(), mediaServerItem.getSdpIp(), ssrcInfo.getPort()); + log.info("{} 分配的ZLM为: {} [{}:{}]", ssrcInfo.getStream(), mediaServerItem.getId(), mediaServerItem.getSdpIp(), ssrcInfo.getPort()); String sdpIp; if (!ObjectUtils.isEmpty(device.getSdpIp())) { sdpIp = device.getSdpIp(); @@ -481,7 +479,7 @@ public class SIPCommander implements ISIPCommander { HookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { - logger.info("{} 分配的ZLM为: {} [{}:{}]", ssrcInfo.getStream(), mediaServerItem.getId(), mediaServerItem.getSdpIp(), ssrcInfo.getPort()); + log.info("{} 分配的ZLM为: {} [{}:{}]", ssrcInfo.getStream(), mediaServerItem.getId(), mediaServerItem.getSdpIp(), ssrcInfo.getPort()); String sdpIp; if (!ObjectUtils.isEmpty(device.getSdpIp())) { sdpIp = device.getSdpIp(); @@ -548,25 +546,25 @@ public class SIPCommander implements ISIPCommander { content.append("a=downloadspeed:" + downloadSpeed + "\r\n"); content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc - logger.debug("此时请求下载信令的ssrc===>{}",ssrcInfo.getSsrc()); + log.debug("此时请求下载信令的ssrc===>{}",ssrcInfo.getSsrc()); Hook rtpHook = Hook.getInstance(HookType.on_media_arrival, "rtp", ssrcInfo.getStream(), mediaServerItem.getId()); // 添加订阅 CallIdHeader newCallIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()), device.getTransport()); String callId= newCallIdHeader.getCallId(); subscribe.addSubscribe(rtpHook, (hookData) -> { - logger.debug("sipc 添加订阅===callId {}",callId); + log.debug("sipc 添加订阅===callId {}",callId); hookEvent.response(hookData); subscribe.removeSubscribe(rtpHook); // 添加流注销的订阅,注销了后向设备发送bye Hook departureHook = Hook.getInstance(HookType.on_media_departure, "rtp", ssrcInfo.getStream(), mediaServerItem.getId()); subscribe.addSubscribe(departureHook, (departureHookData) -> { - logger.info("[录像]下载结束, 发送BYE"); + log.info("[录像]下载结束, 发送BYE"); try { streamByeCmd(device, channelId, ssrcInfo.getStream(), callId); } catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) { - logger.error("[录像]下载结束, 发送BYE失败 {}", e.getMessage()); + log.error("[录像]下载结束, 发送BYE失败 {}", e.getMessage()); } }); }); @@ -593,11 +591,11 @@ public class SIPCommander implements ISIPCommander { } if (!mediaServerItem.isRtpEnable()) { // 单端口暂不支持语音喊话 - logger.info("[语音喊话] 单端口暂不支持此操作"); + log.info("[语音喊话] 单端口暂不支持此操作"); return; } - logger.info("[语音喊话] {} 分配的ZLM为: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getIp(), sendRtpItem.getPort()); + log.info("[语音喊话] {} 分配的ZLM为: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getIp(), sendRtpItem.getPort()); Hook hook = Hook.getInstance(HookType.on_media_arrival, "rtp", stream, mediaServerItem.getId()); subscribe.addSubscribe(hook, (hookData) -> { if (event != null) { @@ -661,17 +659,17 @@ public class SIPCommander implements ISIPCommander { @Override public void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException { if (device == null) { - logger.warn("[发送BYE] device为null"); + log.warn("[发送BYE] device为null"); return; } List ssrcTransactionList = streamSession.getSsrcTransactionForAll(device.getDeviceId(), channelId, callId, stream); if (ssrcTransactionList == null || ssrcTransactionList.isEmpty()) { - logger.info("[发送BYE] 未找到事务信息,设备: device: {}, channel: {}", device.getDeviceId(), channelId); + log.info("[发送BYE] 未找到事务信息,设备: device: {}, channel: {}", device.getDeviceId(), channelId); throw new SsrcTransactionNotFoundException(device.getDeviceId(), channelId, callId, stream); } for (SsrcTransaction ssrcTransaction : ssrcTransactionList) { - logger.info("[发送BYE] 设备: device: {}, channel: {}, callId: {}", device.getDeviceId(), channelId, ssrcTransaction.getCallId()); + log.info("[发送BYE] 设备: device: {}, channel: {}, callId: {}", device.getDeviceId(), channelId, ssrcTransaction.getCallId()); mediaServerService.releaseSsrc(ssrcTransaction.getMediaServerId(), ssrcTransaction.getSsrc()); mediaServerService.closeRTPServer(ssrcTransaction.getMediaServerId(), ssrcTransaction.getStream()); @@ -1339,7 +1337,7 @@ public class SIPCommander implements ISIPCommander { dragXml.append("\r\n"); Request request = headerProvider.createMessageRequest(device, dragXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - logger.debug("拉框信令: " + request.toString()); + log.debug("拉框信令: " + request.toString()); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); } @@ -1407,13 +1405,13 @@ public class SIPCommander implements ISIPCommander { SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(device.getDeviceId(), streamInfo.getChannelId(), null, streamInfo.getStream()); if (ssrcTransaction == null) { - logger.info("[回放控制]未找到视频流信息,设备:{}, 流ID: {}", device.getDeviceId(), streamInfo.getStream()); + log.info("[回放控制]未找到视频流信息,设备:{}, 流ID: {}", device.getDeviceId(), streamInfo.getStream()); return; } SIPRequest request = headerProvider.createInfoRequest(device, streamInfo.getChannelId(), content.toString(), ssrcTransaction.getSipTransactionInfo()); if (request == null) { - logger.info("[回放控制]构建Request信息失败,设备:{}, 流ID: {}", device.getDeviceId(), streamInfo.getStream()); + log.info("[回放控制]构建Request信息失败,设备:{}, 流ID: {}", device.getDeviceId(), streamInfo.getStream()); return; } @@ -1425,7 +1423,7 @@ public class SIPCommander implements ISIPCommander { if (device == null) { return; } - logger.info("[发送报警通知]设备: {}/{}->{},{}", device.getDeviceId(), deviceAlarm.getChannelId(), + log.info("[发送报警通知]设备: {}/{}->{},{}", device.getDeviceId(), deviceAlarm.getChannelId(), deviceAlarm.getLongitude(), deviceAlarm.getLatitude()); String characterSet = device.getCharset(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java index d42d4ddfb..5360e4037 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java @@ -180,12 +180,12 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { * @param parentPlatform 平台信息 */ @Override - public void catalogQuery(DeviceChannel channel, ParentPlatform parentPlatform, String sn, String fromTag, int size) throws SipException, InvalidArgumentException, ParseException { + public void catalogQuery(CommonGBChannel channel, ParentPlatform parentPlatform, String sn, String fromTag, int size) throws SipException, InvalidArgumentException, ParseException { if ( parentPlatform ==null) { return ; } - List channels = new ArrayList<>(); + List channels = new ArrayList<>(); if (channel != null) { channels.add(channel); } @@ -200,13 +200,13 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { } @Override - public void catalogQuery(List channels, ParentPlatform parentPlatform, String sn, String fromTag) throws InvalidArgumentException, ParseException, SipException { + public void catalogQuery(List channels, ParentPlatform parentPlatform, String sn, String fromTag) throws InvalidArgumentException, ParseException, SipException { if ( parentPlatform ==null) { return ; } sendCatalogResponse(channels, parentPlatform, sn, fromTag, 0, true); } - private String getCatalogXml(List channels, String sn, ParentPlatform parentPlatform, int size) { + private String getCatalogXml(List channels, String sn, ParentPlatform parentPlatform, int size) { String characterSet = parentPlatform.getCharacterSet(); StringBuffer catalogXml = new StringBuffer(600); catalogXml.append("\r\n") @@ -216,161 +216,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { .append("" + parentPlatform.getDeviceGBId() + "\r\n") .append("" + size + "\r\n") .append("\r\n"); - if (channels.size() > 0) { - for (DeviceChannel channel : channels) { - if (parentPlatform.getServerGBId().equals(channel.getParentId())) { - channel.setParentId(parentPlatform.getDeviceGBId()); - } - catalogXml.append("\r\n"); - // 行政区划分组只需要这两项就可以 - catalogXml.append("" + channel.getGbDeviceId() + "\r\n"); - catalogXml.append("" + channel.getName() + "\r\n"); - if (channel.getGbDeviceId().length() <= 8) { - catalogXml.append("\r\n"); - continue; - }else { - if (channel.getGbDeviceId().length() != 20) { - catalogXml.append("\r\n"); - logger.warn("[编号长度异常] {} 长度错误,请使用20位长度的国标编号,当前长度:{}", channel.getGbDeviceId(), channel.getChannelId().length()); - catalogXml.append("\r\n"); - continue; - } - switch (Integer.parseInt(channel.getGbDeviceId().substring(10, 13))){ - case 200: -// catalogXml.append("三永华通\r\n"); -// GitUtil gitUtil = SpringBeanFactory.getBean("gitUtil"); -// String model = (gitUtil == null || gitUtil.getBuildVersion() == null)?"1.0": gitUtil.getBuildVersion(); -// catalogXml.append("" + model + "\r\n"); -// catalogXml.append("三永华通\r\n"); - if (channel.getCivilCode() != null) { - catalogXml.append(""+channel.getCivilCode()+"\r\n"); - }else { - catalogXml.append("\r\n"); - } - - catalogXml.append("1\r\n"); - catalogXml.append("0\r\n"); - break; - case 215: - if (!ObjectUtils.isEmpty(channel.getParentId())) { - catalogXml.append("" + channel.getParentId() + "\r\n"); - } - - break; - case 216: - if (!ObjectUtils.isEmpty(channel.getParentId())) { - catalogXml.append("" + channel.getParentId() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getBusinessGroupId())) { - catalogXml.append("" + channel.getBusinessGroupId() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - break; - default: - // 通道项 - if (channel.getManufacturer() != null) { - catalogXml.append("" + channel.getManufacturer() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (channel.getSecrecy() != null) { - catalogXml.append("" + channel.getSecrecy() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - catalogXml.append("" + channel.getRegisterWay() + "\r\n"); - if (channel.getModel() != null) { - catalogXml.append("" + channel.getModel() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (channel.getOwner() != null) { - catalogXml.append("" + channel.getOwner()+ "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (channel.getCivilCode() != null) { - catalogXml.append("" + channel.getCivilCode() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (channel.getAddress() == null) { - catalogXml.append("
\r\n"); - }else { - catalogXml.append("
" + channel.getAddress() + "
\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getParentId())) { - catalogXml.append("" + channel.getParentId() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getBlock())) { - catalogXml.append("" + channel.getBlock() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getSafetyWay())) { - catalogXml.append("" + channel.getSafetyWay() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getCertNum())) { - catalogXml.append("" + channel.getCertNum() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getCertifiable())) { - catalogXml.append("" + channel.getCertifiable() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getErrCode())) { - catalogXml.append("" + channel.getErrCode() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getEndTime())) { - catalogXml.append("" + channel.getEndTime() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getSecrecy())) { - catalogXml.append("" + channel.getSecrecy() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getIpAddress())) { - catalogXml.append("" + channel.getIpAddress() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - catalogXml.append("" + channel.getPort() + "\r\n"); - if (!ObjectUtils.isEmpty(channel.getPassword())) { - catalogXml.append("" + channel.getPassword() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getPtzType())) { - catalogXml.append("" + channel.getPtzType() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - catalogXml.append("" + (channel.isStatus() ?"ON":"OFF") + "\r\n"); - - catalogXml.append("" + - (channel.getLongitudeWgs84() != 0? channel.getLongitudeWgs84():channel.getLongitude()) - + "\r\n"); - catalogXml.append("" + - (channel.getLatitudeWgs84() != 0? channel.getLatitudeWgs84():channel.getLatitude()) - + "\r\n"); - break; - - } - catalogXml.append("\r\n"); - } + if (!channels.isEmpty()) { + for (CommonGBChannel channel : channels) { + catalogXml.append(channel.encode()); } } @@ -379,11 +227,11 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { return catalogXml.toString(); } - private void sendCatalogResponse(List channels, ParentPlatform parentPlatform, String sn, String fromTag, int index, boolean sendAfterResponse) throws SipException, InvalidArgumentException, ParseException { + private void sendCatalogResponse(List channels, ParentPlatform parentPlatform, String sn, String fromTag, int index, boolean sendAfterResponse) throws SipException, InvalidArgumentException, ParseException { if (index >= channels.size()) { return; } - List deviceChannels; + List deviceChannels; if (index + parentPlatform.getCatalogGroup() < channels.size()) { deviceChannels = channels.subList(index, index + parentPlatform.getCatalogGroup()); }else { @@ -571,7 +419,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { } @Override - public void sendNotifyForCatalogAddOrUpdate(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException { + public void sendNotifyForCatalogAddOrUpdate(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException { if (parentPlatform == null || deviceChannels == null || deviceChannels.isEmpty() || subscribeInfo == null) { return; } @@ -581,7 +429,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { if (index >= deviceChannels.size()) { return; } - List channels; + List channels; if (index + parentPlatform.getCatalogGroup() < deviceChannels.size()) { channels = deviceChannels.subList(index, index + parentPlatform.getCatalogGroup()); }else { @@ -618,7 +466,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { sipSender.transmitRequest(parentPlatform.getDeviceIp(), notifyRequest, errorEvent, okEvent); } - private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, List channels, int sumNum, String type, SubscribeInfo subscribeInfo) { + private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, List channels, int sumNum, String type, SubscribeInfo subscribeInfo) { StringBuffer catalogXml = new StringBuffer(600); String characterSet = parentPlatform.getCharacterSet(); catalogXml.append("\r\n") @@ -629,44 +477,8 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { .append(""+ sumNum +"\r\n") .append("\r\n"); if (!channels.isEmpty()) { - for (DeviceChannel channel : channels) { - if (parentPlatform.getServerGBId().equals(channel.getParentId())) { - channel.setParentId(parentPlatform.getDeviceGBId()); - } - catalogXml.append("\r\n"); - // 行政区划分组只需要这两项就可以 - catalogXml.append("" + channel.getChannelId() + "\r\n"); - catalogXml.append("" + channel.getName() + "\r\n"); - if (channel.getParentId() != null) { - // 业务分组加上这一项即可,提高兼容性, - catalogXml.append("" + channel.getParentId() + "\r\n"); - } - if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) { - // 虚拟组织增加BusinessGroupID字段 - catalogXml.append("" + channel.getParentId() + "\r\n"); - } - catalogXml.append("" + channel.getParental() + "\r\n"); - if (channel.getParental() == 0) { - // 通道项 - catalogXml.append("" + channel.getManufacture() + "\r\n") - .append("" + channel.getSecrecy() + "\r\n") - .append("" + channel.getRegisterWay() + "\r\n") - .append("" + (channel.isStatus() ? "ON" : "OFF") + "\r\n"); - - if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性 - catalogXml.append("" + channel.getModel() + "\r\n") - .append(" " + channel.getOwner()+ "\r\n") - .append("" + channel.getCivilCode() + "\r\n") - .append("
" + channel.getAddress() + "
\r\n"); - catalogXml.append("" + channel.getLongitude() + "\r\n"); - catalogXml.append("" + channel.getLatitude() + "\r\n"); - } - if (!"presence".equals(subscribeInfo.getEventType())) { - catalogXml.append("" + type + "\r\n"); - } - - } - catalogXml.append("
\r\n"); + for (CommonGBChannel channel : channels) { + catalogXml.append(channel.encode(type)); } } catalogXml.append("
\r\n") @@ -675,7 +487,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { } @Override - public void sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List deviceChannels, + public void sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException { if (parentPlatform == null || deviceChannels == null @@ -691,7 +503,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { if (index >= deviceChannels.size()) { return; } - List channels; + List channels; if (index + parentPlatform.getCatalogGroup() < deviceChannels.size()) { channels = deviceChannels.subList(index, index + parentPlatform.getCatalogGroup()); }else { @@ -713,7 +525,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { }); } - private String getCatalogXmlContentForCatalogOther(ParentPlatform parentPlatform, List channels, String type) { + private String getCatalogXmlContentForCatalogOther(ParentPlatform parentPlatform, List channels, String type) { String characterSet = parentPlatform.getCharacterSet(); StringBuffer catalogXml = new StringBuffer(600); @@ -724,15 +536,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { .append("" + parentPlatform.getDeviceGBId() + "\r\n") .append("1\r\n") .append("\r\n"); - if (channels.size() > 0) { - for (DeviceChannel channel : channels) { - if (parentPlatform.getServerGBId().equals(channel.getParentId())) { - channel.setParentId(parentPlatform.getDeviceGBId()); - } - catalogXml.append("\r\n") - .append("" + channel.getChannelId() + "\r\n") - .append("" + type + "\r\n") - .append("\r\n"); + if (!channels.isEmpty()) { + for (CommonGBChannel channel : channels) { + catalogXml.append(channel.encode(type)); } } catalogXml.append("\r\n") @@ -740,7 +546,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { return catalogXml.toString(); } @Override - public void recordInfo(DeviceChannel deviceChannel, ParentPlatform parentPlatform, String fromTag, RecordInfo recordInfo) throws SipException, InvalidArgumentException, ParseException { + public void recordInfo(CommonGBChannel deviceChannel, ParentPlatform parentPlatform, String fromTag, RecordInfo recordInfo) throws SipException, InvalidArgumentException, ParseException { if ( parentPlatform ==null) { return ; } @@ -751,7 +557,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { .append("\r\n") .append("RecordInfo\r\n") .append("" +recordInfo.getSn() + "\r\n") - .append("" + deviceChannel.getChannelId() + "\r\n") + .append("" + deviceChannel.getGbDeviceId() + "\r\n") .append("" + recordInfo.getSumNum() + "\r\n"); if (recordInfo.getRecordList() == null ) { recordXml.append("\r\n"); @@ -761,7 +567,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { for (RecordItem recordItem : recordInfo.getRecordList()) { recordXml.append("\r\n"); if (deviceChannel != null) { - recordXml.append("" + deviceChannel.getChannelId() + "\r\n") + recordXml.append("" + deviceChannel.getGbDeviceId() + "\r\n") .append("" + recordItem.getName() + "\r\n") .append("" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(recordItem.getStartTime()) + "\r\n") .append("" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(recordItem.getEndTime()) + "\r\n") @@ -867,19 +673,19 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { } @Override - public void broadcastResultCmd(ParentPlatform platform, DeviceChannel deviceChannel, String sn, boolean result, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { + public void broadcastResultCmd(ParentPlatform platform, CommonGBChannel deviceChannel, String sn, boolean result, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { if (platform == null || deviceChannel == null) { return; } String characterSet = platform.getCharacterSet(); StringBuffer mediaStatusXml = new StringBuffer(200); - mediaStatusXml.append("\r\n"); - mediaStatusXml.append("\r\n"); - mediaStatusXml.append("Broadcast\r\n"); - mediaStatusXml.append("" + sn + "\r\n"); - mediaStatusXml.append("" + deviceChannel.getChannelId() + "\r\n"); - mediaStatusXml.append("" + (result?"OK":"ERROR") + "\r\n"); - mediaStatusXml.append("\r\n"); + mediaStatusXml.append("\r\n") + .append("\r\n") + .append("Broadcast\r\n") + .append("" + sn + "\r\n") + .append("" + deviceChannel.getGbDeviceId() + "\r\n") + .append("" + (result?"OK":"ERROR") + "\r\n") + .append("\r\n"); CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(platform.getDeviceIp(), platform.getTransport()); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java index f3f743172..4d9027e63 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java @@ -6,12 +6,11 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.google.common.primitives.Bytes; import gov.nist.javax.sip.message.SIPRequest; import gov.nist.javax.sip.message.SIPResponse; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import javax.sip.*; @@ -34,10 +33,9 @@ import java.util.List; * @author: songww * @date: 2020年5月3日 下午4:42:22 */ +@Slf4j public abstract class SIPRequestProcessorParent { - private final static Logger logger = LoggerFactory.getLogger(SIPRequestProcessorParent.class); - @Autowired private SIPSender sipSender; @@ -45,7 +43,7 @@ public abstract class SIPRequestProcessorParent { try { return SipFactory.getInstance().createHeaderFactory(); } catch (PeerUnavailableException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } return null; } @@ -54,7 +52,7 @@ public abstract class SIPRequestProcessorParent { try { return SipFactory.getInstance().createMessageFactory(); } catch (PeerUnavailableException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } return null; } @@ -94,7 +92,7 @@ public abstract class SIPRequestProcessorParent { if (responseAckExtraParam != null) { if (responseAckExtraParam.sipURI != null && sipRequest.getMethod().equals(Request.INVITE)) { - logger.debug("responseSdpAck SipURI: {}:{}", responseAckExtraParam.sipURI.getHost(), responseAckExtraParam.sipURI.getPort()); + log.debug("responseSdpAck SipURI: {}:{}", responseAckExtraParam.sipURI.getHost(), responseAckExtraParam.sipURI.getPort()); Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress( SipFactory.getInstance().createAddressFactory().createSipURI(responseAckExtraParam.sipURI.getUser(), responseAckExtraParam.sipURI.getHost()+":"+responseAckExtraParam.sipURI.getPort() )); @@ -106,7 +104,7 @@ public abstract class SIPRequestProcessorParent { if (sipRequest.getMethod().equals(Request.SUBSCRIBE)) { if (responseAckExtraParam.expires == -1) { - logger.error("[参数不全] 2xx的SUBSCRIBE回复,必须设置Expires header"); + log.error("[参数不全] 2xx的SUBSCRIBE回复,必须设置Expires header"); }else { ExpiresHeader expiresHeader = SipFactory.getInstance().createHeaderFactory().createExpiresHeader(responseAckExtraParam.expires); response.addHeader(expiresHeader); @@ -114,7 +112,7 @@ public abstract class SIPRequestProcessorParent { } }else { if (sipRequest.getMethod().equals(Request.SUBSCRIBE)) { - logger.error("[参数不全] 2xx的SUBSCRIBE回复,必须设置Expires header"); + log.error("[参数不全] 2xx的SUBSCRIBE回复,必须设置Expires header"); } } @@ -210,8 +208,8 @@ public abstract class SIPRequestProcessorParent { try { xml = reader.read(new ByteArrayInputStream(bytesResult)); }catch (DocumentException e) { - logger.warn("[xml解析异常]: 原文如下: \r\n{}", new String(bytesResult)); - logger.warn("[xml解析异常]: 原文如下: 尝试兼容性处理"); + log.warn("[xml解析异常]: 原文如下: \r\n{}", new String(bytesResult)); + log.warn("[xml解析异常]: 原文如下: 尝试兼容性处理"); String[] xmlLineArray = new String(bytesResult).split("\\r?\\n"); // 兼容海康的address字段带有<破换xml结构导致无法解析xml的问题 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java index d4df0ae5b..46c7a25ea 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java @@ -17,8 +17,7 @@ import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -34,10 +33,10 @@ import javax.sip.header.ToHeader; * SIP命令类型: ACK请求 * @author lin */ +@Slf4j @Component public class AckRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - private final Logger logger = LoggerFactory.getLogger(AckRequestProcessor.class); private final String method = "ACK"; @Autowired @@ -82,19 +81,19 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In dynamicTask.stop(callIdHeader.getCallId()); String fromUserId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(FromHeader.NAME)).getAddress().getURI()).getUser(); String toUserId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(ToHeader.NAME)).getAddress().getURI()).getUser(); - logger.info("[收到ACK]: 来自->{}", fromUserId); + log.info("[收到ACK]: 来自->{}", fromUserId); SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId()); if (sendRtpItem == null) { - logger.warn("[收到ACK]:未找到来自{},callId: {}", fromUserId, callIdHeader.getCallId()); + log.warn("[收到ACK]:未找到来自{},callId: {}", fromUserId, callIdHeader.getCallId()); return; } // tcp主动时,此时是级联下级平台,在回复200ok时,本地已经请求zlm开启监听,跳过下面步骤 if (sendRtpItem.isTcpActive()) { - logger.info("收到ACK,rtp/{} TCP主动方式后续处理", sendRtpItem.getStream()); + log.info("收到ACK,rtp/{} TCP主动方式后续处理", sendRtpItem.getStream()); return; } MediaServer mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); - logger.info("收到ACK,rtp/{}开始向上级推流, 目标={}:{},SSRC={}, 协议:{}", + log.info("收到ACK,rtp/{}开始向上级推流, 目标={}:{},SSRC={}, 协议:{}", sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort(), @@ -118,14 +117,14 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In } redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, parentPlatform); }catch (ControllerException e) { - logger.error("RTP推流失败: {}", e.getMessage()); + log.error("RTP推流失败: {}", e.getMessage()); playService.startSendRtpStreamFailHand(sendRtpItem, parentPlatform, callIdHeader); } } }else { Device device = deviceService.getDevice(fromUserId); if (device == null) { - logger.warn("[收到ACK]:来自{},目标为({})的推流信息为找到流体服务[{}]信息",fromUserId, toUserId, sendRtpItem.getMediaServerId()); + log.warn("[收到ACK]:来自{},目标为({})的推流信息为找到流体服务[{}]信息",fromUserId, toUserId, sendRtpItem.getMediaServerId()); return; } // 设置为收到ACK后发送语音的设备已经在发送200OK开始发流了 @@ -133,7 +132,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In return; } if (mediaInfo == null) { - logger.warn("[收到ACK]:来自{},目标为({})的推流信息为找到流体服务[{}]信息",fromUserId, toUserId, sendRtpItem.getMediaServerId()); + log.warn("[收到ACK]:来自{},目标为({})的推流信息为找到流体服务[{}]信息",fromUserId, toUserId, sendRtpItem.getMediaServerId()); return; } try { @@ -143,7 +142,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In mediaServerService.startSendRtp(mediaInfo, sendRtpItem); } }catch (ControllerException e) { - logger.error("RTP推流失败: {}", e.getMessage()); + log.error("RTP推流失败: {}", e.getMessage()); playService.startSendRtpStreamFailHand(sendRtpItem, null, callIdHeader); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java index 03f0f0342..66f228bdf 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java @@ -21,8 +21,7 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.streamPush.service.IStreamPushService; import gov.nist.javax.sip.message.SIPRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -37,10 +36,10 @@ import java.text.ParseException; /** * SIP命令类型: BYE请求 */ +@Slf4j @Component public class ByeRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - private final Logger logger = LoggerFactory.getLogger(ByeRequestProcessor.class); private final String method = "BYE"; @Autowired @@ -107,17 +106,17 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In try { responseAck(request, Response.OK); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[回复BYE信息失败],{}", e.getMessage()); + log.error("[回复BYE信息失败],{}", e.getMessage()); } CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId()); // 收流端发送的停止 if (sendRtpItem != null){ - logger.info("[收到bye] 来自{},停止通道:{}, 类型: {}, callId: {}", sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(), sendRtpItem.getPlayType(), callIdHeader.getCallId()); + log.info("[收到bye] 来自{},停止通道:{}, 类型: {}, callId: {}", sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(), sendRtpItem.getPlayType(), callIdHeader.getCallId()); String streamId = sendRtpItem.getStream(); - logger.info("[收到bye] 停止推流:{}, 媒体节点: {}", streamId, sendRtpItem.getMediaServerId()); + log.info("[收到bye] 停止推流:{}, 媒体节点: {}", streamId, sendRtpItem.getMediaServerId()); if (sendRtpItem.getPlayType().equals(InviteStreamType.PUSH)) { // 不是本平台的就发送redis消息让其他wvp停止发流 @@ -136,7 +135,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In } } }else { - logger.info("[上级平台停止观看] 未找到平台{}的信息,发送redis消息失败", sendRtpItem.getPlatformId()); + log.info("[上级平台停止观看] 未找到平台{}的信息,发送redis消息失败", sendRtpItem.getPlatformId()); } }else { MediaServer mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); @@ -152,72 +151,72 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); if (audioBroadcastCatch != null && audioBroadcastCatch.getSipTransactionInfo().getCallId().equals(callIdHeader.getCallId())) { // 来自上级平台的停止对讲 - logger.info("[停止对讲] 来自上级,平台:{}, 通道:{}", sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); + log.info("[停止对讲] 来自上级,平台:{}, 通道:{}", sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); audioBroadcastManager.del(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); } MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServer, sendRtpItem.getApp(), streamId); if (mediaInfo.getReaderCount() <= 0) { - logger.info("[收到bye] {} 无其它观看者,通知设备停止推流", streamId); + log.info("[收到bye] {} 无其它观看者,通知设备停止推流", streamId); if (sendRtpItem.getPlayType().equals(InviteStreamType.PLAY)) { Device device = deviceService.getDevice(sendRtpItem.getDeviceId()); if (device == null) { - logger.info("[收到bye] {} 通知设备停止推流时未找到设备信息", streamId); + log.info("[收到bye] {} 通知设备停止推流时未找到设备信息", streamId); } try { - logger.info("[停止点播] {}/{}", sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); + log.info("[停止点播] {}/{}", sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); cmder.streamByeCmd(device, sendRtpItem.getChannelId(), streamId, null); } catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) { - logger.error("[收到bye] {} 无其它观看者,通知设备停止推流, 发送BYE失败 {}",streamId, e.getMessage()); + log.error("[收到bye] {} 无其它观看者,通知设备停止推流, 发送BYE失败 {}",streamId, e.getMessage()); } } } } } - System.out.println(callIdHeader.getCallId()); // 可能是设备发送的停止 SsrcTransaction ssrcTransaction = streamSession.getSsrcTransactionByCallId(callIdHeader.getCallId()); if (ssrcTransaction == null) { return; } - logger.info("[收到bye] 来自设备:{}, 通道: {}, 类型: {}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getType()); + log.info("[收到bye] 来自设备:{}, 通道: {}, 类型: {}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getType()); ParentPlatform platform = platformService.queryPlatformByServerGBId(ssrcTransaction.getDeviceId()); if (platform != null ) { if (ssrcTransaction.getType().equals(InviteSessionType.BROADCAST)) { - logger.info("[收到bye] 上级停止语音对讲,来自:{}, 通道已停止推流: {}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); + log.info("[收到bye] 上级停止语音对讲,来自:{}, 通道已停止推流: {}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); DeviceChannel channel = storager.queryChannelInParentPlatform(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); if (channel == null) { - logger.info("[收到bye] 未找到通道,设备:{}, 通道:{}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); + log.info("[收到bye] 未找到通道,设备:{}, 通道:{}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); return; } String mediaServerId = ssrcTransaction.getMediaServerId(); platformService.stopBroadcast(platform, channel, ssrcTransaction.getStream(), false, mediaServerService.getOne(mediaServerId)); - playService.stopAudioBroadcast(channel.getDeviceId(), channel.getChannelId()); + playService.stopAudioBroadcast(ssrcTransaction.getDeviceId(), channel.getDeviceId()); } }else { Device device = deviceService.getDevice(ssrcTransaction.getDeviceId()); if (device == null) { - logger.info("[收到bye] 未找到设备:{} ", ssrcTransaction.getDeviceId()); + log.info("[收到bye] 未找到设备:{} ", ssrcTransaction.getDeviceId()); return; } DeviceChannel channel = channelService.getOne(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); if (channel == null) { - logger.info("[收到bye] 未找到通道,设备:{}, 通道:{}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); + log.info("[收到bye] 未找到通道,设备:{}, 通道:{}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); return; } switch (ssrcTransaction.getType()){ case PLAY: case PLAYBACK: case DOWNLOAD: - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId()); + InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, + device.getDeviceId(), channel.getDeviceId()); if (inviteInfo != null) { - storager.stopPlay(device.getDeviceId(), channel.getChannelId()); + storager.stopPlay(ssrcTransaction.getDeviceId(), channel.getDeviceId()); inviteStreamService.removeInviteInfo(inviteInfo); if (inviteInfo.getStreamInfo() != null) { mediaServerService.closeRTPServer(inviteInfo.getStreamInfo().getMediaServerId(), inviteInfo.getStreamInfo().getStream()); @@ -228,14 +227,14 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In case TALK: // 查找来源的对讲设备,发送停止 Device sourceDevice = storager.queryVideoDeviceByPlatformIdAndChannelId(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); - AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(ssrcTransaction.getDeviceId(), channel.getChannelId()); + AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(ssrcTransaction.getDeviceId(), channel.getDeviceId()); if (sourceDevice != null) { - playService.stopAudioBroadcast(sourceDevice.getDeviceId(), channel.getChannelId()); + playService.stopAudioBroadcast(sourceDevice.getDeviceId(), channel.getDeviceId()); } if (audioBroadcastCatch != null) { // 来自上级平台的停止对讲 - logger.info("[停止对讲] 来自上级,平台:{}, 通道:{}", ssrcTransaction.getDeviceId(), channel.getChannelId()); - audioBroadcastManager.del(ssrcTransaction.getDeviceId(), channel.getChannelId()); + log.info("[停止对讲] 来自上级,平台:{}, 通道:{}", ssrcTransaction.getDeviceId(), channel.getDeviceId()); + audioBroadcastManager.del(ssrcTransaction.getDeviceId(), channel.getDeviceId()); } break; @@ -246,7 +245,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In if (mediaServerItem != null) { mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc()); } - streamSession.removeByCallId(device.getDeviceId(), channel.getChannelId(), ssrcTransaction.getCallId()); + streamSession.removeByCallId(device.getDeviceId(), channel.getDeviceId(), ssrcTransaction.getCallId()); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index 531bf2dc5..17d18a8a3 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -46,6 +46,7 @@ import gov.nist.javax.sdp.fields.TimeField; import gov.nist.javax.sdp.fields.URIField; import gov.nist.javax.sip.message.SIPRequest; import gov.nist.javax.sip.message.SIPResponse; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -71,12 +72,11 @@ import java.util.*; /** * SIP命令类型: INVITE请求 */ +@Slf4j @SuppressWarnings("rawtypes") @Component public class InviteRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - private final static Logger logger = LoggerFactory.getLogger(InviteRequestProcessor.class); - private final String method = "INVITE"; @Autowired @@ -173,17 +173,17 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements String requesterId = SipUtils.getUserIdFromFromHeader(request); CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME); if (requesterId == null || channelId == null) { - logger.info("无法从请求中获取到平台id,返回400"); + log.info("无法从请求中获取到平台id,返回400"); // 参数不全, 发400,请求错误 try { responseAck(request, Response.BAD_REQUEST); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite BAD_REQUEST: {}", e.getMessage()); + log.error("[命令发送失败] invite BAD_REQUEST: {}", e.getMessage()); } return; } - logger.info("[INVITE] requesterId: {}, callId: {}, 来自:{}:{}", + log.info("[INVITE] requesterId: {}, callId: {}, 来自:{}:{}", requesterId, callIdHeader.getCallId(), request.getRemoteAddress(), request.getRemotePort()); // 查询请求是否来自上级平台\设备 @@ -206,7 +206,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements try { responseAck(request, Response.TRYING); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite TRYING: {}", e.getMessage()); + log.error("[命令发送失败] invite TRYING: {}", e.getMessage()); } } else if (channel == null && gbStream != null) { @@ -214,11 +214,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements mediaServerItem = mediaServerService.getOne(mediaServerId); if (mediaServerItem == null) { if ("proxy".equals(gbStream.getStreamType())) { - logger.info("[ app={}, stream={} ]找不到zlm {},返回410", gbStream.getApp(), gbStream.getStream(), mediaServerId); + log.info("[ app={}, stream={} ]找不到zlm {},返回410", gbStream.getApp(), gbStream.getStream(), mediaServerId); try { responseAck(request, Response.GONE); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite GONE: {}", e.getMessage()); + log.error("[命令发送失败] invite GONE: {}", e.getMessage()); } return; } else { @@ -234,22 +234,22 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements if ("push".equals(gbStream.getStreamType())) { streamPushItem = streamPushService.getPush(gbStream.getApp(), gbStream.getStream()); if (streamPushItem == null) { - logger.info("[ app={}, stream={} ]找不到zlm {},返回410", gbStream.getApp(), gbStream.getStream(), mediaServerId); + log.info("[ app={}, stream={} ]找不到zlm {},返回410", gbStream.getApp(), gbStream.getStream(), mediaServerId); try { responseAck(request, Response.GONE); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite GONE: {}", e.getMessage()); + log.error("[命令发送失败] invite GONE: {}", e.getMessage()); } return; } } else if ("proxy".equals(gbStream.getStreamType())) { proxyByAppAndStream = streamProxyService.getStreamProxyByAppAndStream(gbStream.getApp(), gbStream.getStream()); if (proxyByAppAndStream == null) { - logger.info("[ app={}, stream={} ]找不到zlm {},返回410", gbStream.getApp(), gbStream.getStream(), mediaServerId); + log.info("[ app={}, stream={} ]找不到zlm {},返回410", gbStream.getApp(), gbStream.getStream(), mediaServerId); try { responseAck(request, Response.GONE); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite GONE: {}", e.getMessage()); + log.error("[命令发送失败] invite GONE: {}", e.getMessage()); } return; } @@ -258,23 +258,23 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements try { responseAck(request, Response.CALL_IS_BEING_FORWARDED); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite CALL_IS_BEING_FORWARDED: {}", e.getMessage()); + log.error("[命令发送失败] invite CALL_IS_BEING_FORWARDED: {}", e.getMessage()); } } else if (catalog != null) { try { // 目录不支持点播 responseAck(request, Response.BAD_REQUEST, "catalog channel can not play"); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 目录不支持点播: {}", e.getMessage()); + log.error("[命令发送失败] invite 目录不支持点播: {}", e.getMessage()); } return; } else { - logger.info("通道不存在,返回404: {}", channelId); + log.info("通道不存在,返回404: {}", channelId); try { // 通道不存在,发404,资源不存在 responseAck(request, Response.NOT_FOUND); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 通道不存在: {}", e.getMessage()); + log.error("[命令发送失败] invite 通道不存在: {}", e.getMessage()); } return; } @@ -325,13 +325,13 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements } } if (port == -1) { - logger.info("不支持的媒体格式,返回415"); + log.info("不支持的媒体格式,返回415"); // 回复不支持的格式 try { // 不支持的格式,发415 responseAck(request, Response.UNSUPPORTED_MEDIA_TYPE); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 不支持的格式: {}", e.getMessage()); + log.error("[命令发送失败] invite 不支持的格式: {}", e.getMessage()); } return; } @@ -348,21 +348,21 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements if (channel != null) { device = storager.queryVideoDeviceByPlatformIdAndChannelId(requesterId, channelId); if (device == null) { - logger.warn("点播平台{}的通道{}时未找到设备信息", requesterId, channel); + log.warn("点播平台{}的通道{}时未找到设备信息", requesterId, channel); try { responseAck(request, Response.SERVER_INTERNAL_ERROR); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 未找到设备信息: {}", e.getMessage()); + log.error("[命令发送失败] invite 未找到设备信息: {}", e.getMessage()); } return; } mediaServerItem = playService.getNewMediaServerItem(device); if (mediaServerItem == null) { - logger.warn("未找到可用的zlm"); + log.warn("未找到可用的zlm"); try { responseAck(request, Response.BUSY_HERE); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite BUSY_HERE: {}", e.getMessage()); + log.error("[命令发送失败] invite BUSY_HERE: {}", e.getMessage()); } return; } @@ -384,7 +384,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements } else { streamTypeStr = "UDP"; } - logger.info("[上级Invite] {}, 平台:{}, 通道:{}, 收流地址:{}:{},收流方式:{}, ssrc:{}", + log.info("[上级Invite] {}, 平台:{}, 通道:{}, 收流地址:{}:{},收流方式:{}, ssrc:{}", sessionName, username, channelId, addressStr, port, streamTypeStr, ssrc); SendRtpItem sendRtpItem = mediaServerService.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, device.getDeviceId(), channelId, mediaTransmissionTCP, platform.isRtcp()); @@ -393,11 +393,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements sendRtpItem.setTcpActive(tcpActive); } if (sendRtpItem == null) { - logger.warn("服务器端口资源不足"); + log.warn("服务器端口资源不足"); try { responseAck(request, Response.BUSY_HERE); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); + log.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); } return; } @@ -409,7 +409,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements ErrorCallback hookEvent = (code, msg, data) -> { StreamInfo streamInfo = (StreamInfo)data; MediaServer mediaServerItemInUSe = mediaServerService.getOne(streamInfo.getMediaServerId()); - logger.info("[上级Invite]下级已经开始推流。 回复200OK(SDP), {}/{}", streamInfo.getApp(), streamInfo.getStream()); + log.info("[上级Invite]下级已经开始推流。 回复200OK(SDP), {}/{}", streamInfo.getApp(), streamInfo.getStream()); // * 0 等待设备推流上来 // * 1 下级已经推流,等待上级平台回复ack // * 2 推流中 @@ -453,13 +453,13 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements try { // 超时未收到Ack应该回复bye,当前等待时间为10秒 dynamicTask.startDelay(callIdHeader.getCallId(), () -> { - logger.info("Ack 等待超时"); + log.info("Ack 等待超时"); mediaServerService.releaseSsrc(mediaServerItemInUSe.getId(), sendRtpItem.getSsrc()); // 回复bye try { cmderFroPlatform.streamByeCmd(platform, callIdHeader.getCallId()); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); } }, 60 * 1000); responseSdpAck(request, content.toString(), platform); @@ -472,17 +472,17 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements }catch (ControllerException e) {} } } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 回复SdpAck", e); + log.error("[命令发送失败] 国标级联 回复SdpAck", e); } }; ErrorCallback errorEvent = ((statusCode, msg, data) -> { - logger.info("[上级Invite] {}, 失败, 平台:{}, 通道:{}, code: {}, msg;{}", sessionName, username, channelId, statusCode, msg); + log.info("[上级Invite] {}, 失败, 平台:{}, 通道:{}, code: {}, msg;{}", sessionName, username, channelId, statusCode, msg); // 未知错误。直接转发设备点播的错误 try { Response response = getMessageFactory().createResponse(statusCode, evt.getRequest()); sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); } catch (ParseException | SipException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } }); sendRtpItem.setApp("rtp"); @@ -491,7 +491,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements String startTimeStr = DateUtil.urlFormatter.format(start); String endTimeStr = DateUtil.urlFormatter.format(end); String stream = device.getDeviceId() + "_" + channelId + "_" + startTimeStr + "_" + endTimeStr; - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, stream, null, device.isSsrcCheck(), true, 0,false,!channel.getHasAudio(), false, device.getStreamModeForParam()); + SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, stream, null, device.isSsrcCheck(), true, 0,false,!channel.getHasAudio(), false, device.getStreamMode()); sendRtpItem.setStream(stream); // 写入redis, 超时时回复 redisCatchStorage.updateSendRTPSever(sendRtpItem); @@ -501,7 +501,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements if (code == InviteErrorCode.SUCCESS.getCode()) { hookEvent.run(code, msg, data); } else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()) { - logger.info("[录像回放]超时, 用户:{}, 通道:{}", username, channelId); + log.info("[录像回放]超时, 用户:{}, 通道:{}", username, channelId); redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null); errorEvent.run(code, msg, data); } else { @@ -521,7 +521,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements } sendRtpItem.setPlayType(InviteStreamType.DOWNLOAD); - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, null, device.isSsrcCheck(), true, 0, false,!channel.getHasAudio(), false, device.getStreamModeForParam()); + SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, null, device.isSsrcCheck(), true, 0, false,!channel.getHasAudio(), false, device.getStreamMode()); sendRtpItem.setStream(ssrcInfo.getStream()); // 写入redis, 超时时回复 redisCatchStorage.updateSendRTPSever(sendRtpItem); @@ -531,7 +531,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements if (code == InviteErrorCode.SUCCESS.getCode()) { hookEvent.run(code, msg, data); } else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()) { - logger.info("[录像下载]超时, 用户:{}, 通道:{}", username, channelId); + log.info("[录像下载]超时, 用户:{}, 通道:{}", username, channelId); redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null); errorEvent.run(code, msg, data); } else { @@ -547,7 +547,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements if (code == InviteErrorCode.SUCCESS.getCode()) { hookEvent.run(code, msg, data); } else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()) { - logger.info("[上级点播]超时, 用户:{}, 通道:{}", username, channelId); + log.info("[上级点播]超时, 用户:{}, 通道:{}", username, channelId); redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null); errorEvent.run(code, msg, data); } else { @@ -606,10 +606,10 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements if (!platform.isStartOfflinePush()) { // 平台设置中关闭了拉起离线的推流则直接回复 try { - logger.info("[上级点播] 失败,推流设备未推流,channel: {}, app: {}, stream: {}", sendRtpItem.getChannelId(), sendRtpItem.getApp(), sendRtpItem.getStream()); + log.info("[上级点播] 失败,推流设备未推流,channel: {}, app: {}, stream: {}", sendRtpItem.getChannelId(), sendRtpItem.getApp(), sendRtpItem.getStream()); responseAck(request, Response.TEMPORARILY_UNAVAILABLE, "channel stream not pushing"); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 通道未推流: {}", e.getMessage()); + log.error("[命令发送失败] invite 通道未推流: {}", e.getMessage()); } return; } @@ -636,21 +636,21 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements } } } catch (SdpParseException e) { - logger.error("sdp解析错误", e); + log.error("sdp解析错误", e); } catch (SdpException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } } private void startSendRtpStreamHand(RequestEvent evt, SendRtpItem sendRtpItem, ParentPlatform parentPlatform, JSONObject jsonObject, Map param, CallIdHeader callIdHeader) { if (jsonObject == null) { - logger.error("下级TCP被动启动监听失败: 请检查ZLM服务"); + log.error("下级TCP被动启动监听失败: 请检查ZLM服务"); } else if (jsonObject.getInteger("code") == 0) { - logger.info("调用ZLM-TCP被动推流接口, 结果: {}", jsonObject); - logger.info("启动监听TCP被动推流成功[ {}/{} ],{}->{}:{}, " ,param.get("app"), param.get("stream"), jsonObject.getString("local_port"), param.get("dst_url"), param.get("dst_port")); + log.info("调用ZLM-TCP被动推流接口, 结果: {}", jsonObject); + log.info("启动监听TCP被动推流成功[ {}/{} ],{}->{}:{}, " ,param.get("app"), param.get("stream"), jsonObject.getString("local_port"), param.get("dst_url"), param.get("dst_port")); } else { - logger.error("启动监听TCP被动推流失败: {}, 参数:{}",jsonObject.getString("msg"), JSON.toJSONString(param)); + log.error("启动监听TCP被动推流失败: {}, 参数:{}",jsonObject.getString("msg"), JSON.toJSONString(param)); } } @@ -665,11 +665,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements // 自平台内容 int localPort = sendRtpPortManager.getNextPort(mediaServerItem); if (localPort == 0) { - logger.warn("服务器端口资源不足"); + log.warn("服务器端口资源不足"); try { responseAck(request, Response.BUSY_HERE); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); + log.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); } return; } @@ -694,11 +694,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements // 自平台内容 int localPort = sendRtpPortManager.getNextPort(mediaServerItem); if (localPort == 0) { - logger.warn("服务器端口资源不足"); + log.warn("服务器端口资源不足"); try { responseAck(request, Response.BUSY_HERE); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); + log.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); } return; } @@ -729,16 +729,16 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements */ private void notifyProxyStreamOnline(SendRtpItem sendRtpItem, MediaServer mediaServerItem, ParentPlatform platform, SIPRequest request) { // TODO 控制启用以使设备上线 - logger.info("[ app={}, stream={} ]通道未推流,启用流后开始推流", sendRtpItem.getApp(), sendRtpItem.getStream()); + log.info("[ app={}, stream={} ]通道未推流,启用流后开始推流", sendRtpItem.getApp(), sendRtpItem.getStream()); // 监听流上线 Hook hook = Hook.getInstance(HookType.on_media_arrival, sendRtpItem.getApp(), sendRtpItem.getStream(), mediaServerItem.getId()); hookSubscribe.addSubscribe(hook, (hookData)->{ - logger.info("[上级点播]拉流代理已经就绪, {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream()); + log.info("[上级点播]拉流代理已经就绪, {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream()); dynamicTask.stop(sendRtpItem.getCallId()); sendProxyStream(sendRtpItem, mediaServerItem, platform, request); }); dynamicTask.startDelay(sendRtpItem.getCallId(), () -> { - logger.info("[ app={}, stream={} ] 等待拉流代理流超时", sendRtpItem.getApp(), sendRtpItem.getStream()); + log.info("[ app={}, stream={} ] 等待拉流代理流超时", sendRtpItem.getApp(), sendRtpItem.getStream()); hookSubscribe.removeSubscribe(hook); }, userSetting.getPlatformPlayTimeout()); boolean start = streamProxyService.start(sendRtpItem.getApp(), sendRtpItem.getStream()); @@ -746,7 +746,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements try { responseAck(request, Response.BUSY_HERE, "channel [" + sendRtpItem.getChannelId() + "] offline"); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 通道未推流: {}", e.getMessage()); + log.error("[命令发送失败] invite 通道未推流: {}", e.getMessage()); } hookSubscribe.removeSubscribe(hook); dynamicTask.stop(sendRtpItem.getCallId()); @@ -758,7 +758,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements */ private void notifyPushStreamOnline(SendRtpItem sendRtpItem, MediaServer mediaServerItem, ParentPlatform platform, SIPRequest request) { // 发送redis消息以使设备上线,流上线后被 - logger.info("[ app={}, stream={} ]通道未推流,发送redis信息控制设备开始推流", sendRtpItem.getApp(), sendRtpItem.getStream()); + log.info("[ app={}, stream={} ]通道未推流,发送redis信息控制设备开始推流", sendRtpItem.getApp(), sendRtpItem.getStream()); MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(1, sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getChannelId(), sendRtpItem.getPlatformId(), platform.getName(), userSetting.getServerId(), sendRtpItem.getMediaServerId()); @@ -766,44 +766,44 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements // 设置超时 dynamicTask.startDelay(sendRtpItem.getCallId(), () -> { redisRpcService.stopWaitePushStreamOnline(sendRtpItem); - logger.info("[ app={}, stream={} ] 等待设备开始推流超时", sendRtpItem.getApp(), sendRtpItem.getStream()); + log.info("[ app={}, stream={} ] 等待设备开始推流超时", sendRtpItem.getApp(), sendRtpItem.getStream()); try { responseAck(request, Response.REQUEST_TIMEOUT); // 超时 } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } }, userSetting.getPlatformPlayTimeout()); // long key = redisRpcService.waitePushStreamOnline(sendRtpItem, (sendRtpItemKey) -> { dynamicTask.stop(sendRtpItem.getCallId()); if (sendRtpItemKey == null) { - logger.warn("[级联点播] 等待推流得到结果未空: {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream()); + log.warn("[级联点播] 等待推流得到结果未空: {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream()); try { responseAck(request, Response.BUSY_HERE); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } return; } SendRtpItem sendRtpItemFromRedis = (SendRtpItem)redisTemplate.opsForValue().get(sendRtpItemKey); if (sendRtpItemFromRedis == null) { - logger.warn("[级联点播] 等待推流, 未找到redis中缓存的发流信息: {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream()); + log.warn("[级联点播] 等待推流, 未找到redis中缓存的发流信息: {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream()); try { responseAck(request, Response.BUSY_HERE); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } return; } if (sendRtpItemFromRedis.getServerId().equals(userSetting.getServerId())) { - logger.info("[级联点播] 等待的推流在本平台上线 {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream()); + log.info("[级联点播] 等待的推流在本平台上线 {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream()); int localPort = sendRtpPortManager.getNextPort(mediaServerItem); if (localPort == 0) { - logger.warn("上级点时创建sendRTPItem失败,可能是服务器端口资源不足"); + log.warn("上级点时创建sendRTPItem失败,可能是服务器端口资源不足"); try { responseAck(request, Response.BUSY_HERE); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } return; } @@ -834,7 +834,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements try { responseAck(request, Response.TEMPORARILY_UNAVAILABLE, response.getMsg()); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 点播回复: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 点播回复: {}", e.getMessage()); } } }); @@ -846,7 +846,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements * 来自其他wvp的推流 */ private void otherWvpPushStream(SendRtpItem sendRtpItem, SIPRequest request, ParentPlatform platform) { - logger.info("[级联点播] 来自其他wvp的推流 {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream()); + log.info("[级联点播] 来自其他wvp的推流 {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream()); sendRtpItem = redisRpcService.getSendRtpItem(sendRtpItem.getRedisKey()); if (sendRtpItem == null) { return; @@ -894,7 +894,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements try { return responseSdpAck(request, content.toString(), platform); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } return null; } @@ -922,27 +922,27 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements } if (device == null) { - logger.warn("来自设备的Invite请求,无法从请求信息中确定所属设备,已忽略,requesterId: {}/{}", requesterId, channelId); + log.warn("来自设备的Invite请求,无法从请求信息中确定所属设备,已忽略,requesterId: {}/{}", requesterId, channelId); try { responseAck(request, Response.FORBIDDEN); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 来自设备的Invite请求,无法从请求信息中确定所属设备 FORBIDDEN: {}", e.getMessage()); + log.error("[命令发送失败] 来自设备的Invite请求,无法从请求信息中确定所属设备 FORBIDDEN: {}", e.getMessage()); } return; } AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(device.getDeviceId(), realChannelId); if (broadcastCatch == null) { - logger.warn("来自设备的Invite请求非语音广播,已忽略,requesterId: {}/{}", requesterId, channelId); + log.warn("来自设备的Invite请求非语音广播,已忽略,requesterId: {}/{}", requesterId, channelId); try { responseAck(request, Response.FORBIDDEN); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 来自设备的Invite请求非语音广播 FORBIDDEN: {}", e.getMessage()); + log.error("[命令发送失败] 来自设备的Invite请求非语音广播 FORBIDDEN: {}", e.getMessage()); } return; } if (device != null) { - logger.info("收到设备" + requesterId + "的语音广播Invite请求"); + log.info("收到设备" + requesterId + "的语音广播Invite请求"); String key = VideoManagerConstants.BROADCAST_WAITE_INVITE + device.getDeviceId(); if (!SipUtils.isFrontEnd(device.getDeviceId())) { key += broadcastCatch.getChannelId(); @@ -951,7 +951,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements try { responseAck(request, Response.TRYING); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite BAD_REQUEST: {}", e.getMessage()); + log.error("[命令发送失败] invite BAD_REQUEST: {}", e.getMessage()); playService.stopAudioBroadcast(device.getDeviceId(), broadcastCatch.getChannelId()); return; } @@ -991,33 +991,33 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements // } } if (port == -1) { - logger.info("不支持的媒体格式,返回415"); + log.info("不支持的媒体格式,返回415"); // 回复不支持的格式 try { responseAck(request, Response.UNSUPPORTED_MEDIA_TYPE); // 不支持的格式,发415 } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 不支持的媒体格式: {}", e.getMessage()); + log.error("[命令发送失败] invite 不支持的媒体格式: {}", e.getMessage()); playService.stopAudioBroadcast(device.getDeviceId(), broadcastCatch.getChannelId()); return; } return; } String addressStr = sdp.getOrigin().getAddress(); - logger.info("设备{}请求语音流,地址:{}:{},ssrc:{}, {}", requesterId, addressStr, port, gb28181Sdp.getSsrc(), + log.info("设备{}请求语音流,地址:{}:{},ssrc:{}, {}", requesterId, addressStr, port, gb28181Sdp.getSsrc(), mediaTransmissionTCP ? (tcpActive ? "TCP主动" : "TCP被动") : "UDP"); MediaServer mediaServerItem = broadcastCatch.getMediaServerItem(); if (mediaServerItem == null) { - logger.warn("未找到语音喊话使用的zlm"); + log.warn("未找到语音喊话使用的zlm"); try { responseAck(request, Response.BUSY_HERE); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 未找到可用的zlm: {}", e.getMessage()); + log.error("[命令发送失败] invite 未找到可用的zlm: {}", e.getMessage()); playService.stopAudioBroadcast(device.getDeviceId(), broadcastCatch.getChannelId()); } return; } - logger.info("设备{}请求语音流, 收流地址:{}:{},ssrc:{}, {}, 对讲方式:{}", requesterId, addressStr, port, gb28181Sdp.getSsrc(), + log.info("设备{}请求语音流, 收流地址:{}:{},ssrc:{}, {}, 对讲方式:{}", requesterId, addressStr, port, gb28181Sdp.getSsrc(), mediaTransmissionTCP ? (tcpActive ? "TCP主动" : "TCP被动") : "UDP", sdp.getSessionName().getValue()); CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME); @@ -1026,11 +1026,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements mediaTransmissionTCP, false); if (sendRtpItem == null) { - logger.warn("服务器端口资源不足"); + log.warn("服务器端口资源不足"); try { responseAck(request, Response.BUSY_HERE); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); + log.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); playService.stopAudioBroadcast(device.getDeviceId(), broadcastCatch.getChannelId()); return; } @@ -1059,26 +1059,26 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements if (streamReady) { sendOk(device, sendRtpItem, sdp, request, mediaServerItem, mediaTransmissionTCP, gb28181Sdp.getSsrc()); } else { - logger.warn("[语音通话], 未发现待推送的流,app={},stream={}", broadcastCatch.getApp(), broadcastCatch.getStream()); + log.warn("[语音通话], 未发现待推送的流,app={},stream={}", broadcastCatch.getApp(), broadcastCatch.getStream()); try { responseAck(request, Response.GONE); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 语音通话 回复410失败, {}", e.getMessage()); + log.error("[命令发送失败] 语音通话 回复410失败, {}", e.getMessage()); return; } playService.stopAudioBroadcast(device.getDeviceId(), broadcastCatch.getChannelId()); } } catch (SdpException e) { - logger.error("[SDP解析异常]", e); + log.error("[SDP解析异常]", e); playService.stopAudioBroadcast(device.getDeviceId(), broadcastCatch.getChannelId()); } } else { - logger.warn("来自无效设备/平台的请求"); + log.warn("来自无效设备/平台的请求"); try { responseAck(request, Response.BAD_REQUEST); ; // 不支持的格式,发415 } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 来自无效设备/平台的请求, {}", e.getMessage()); + log.error("[命令发送失败] invite 来自无效设备/平台的请求, {}", e.getMessage()); } } } @@ -1130,12 +1130,12 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements streamSession.put(device.getDeviceId(), sendRtpItem.getChannelId(), request.getCallIdHeader().getCallId(), sendRtpItem.getStream(), sendRtpItem.getSsrc(), sendRtpItem.getMediaServerId(), sipResponse, InviteSessionType.BROADCAST); // 开启发流,大华在收到200OK后就会开始建立连接 if (!device.isBroadcastPushAfterAck()) { - logger.info("[语音喊话] 回复200OK后发现 BroadcastPushAfterAck为False,现在开始推流"); + log.info("[语音喊话] 回复200OK后发现 BroadcastPushAfterAck为False,现在开始推流"); playService.startPushStream(sendRtpItem, sipResponse, parentPlatform, request.getCallIdHeader()); } } catch (SipException | InvalidArgumentException | ParseException | SdpParseException e) { - logger.error("[命令发送失败] 语音喊话 回复200OK(SDP): {}", e.getMessage()); + log.error("[命令发送失败] 语音喊话 回复200OK(SDP): {}", e.getMessage()); } return sipResponse; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java index 37587b2dc..ce90b8dfd 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java @@ -1,7 +1,5 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.CatalogChannelEvent; import com.genersoft.iot.vmp.gb28181.bean.Device; @@ -62,11 +60,6 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent @Autowired private IDeviceChannelService deviceChannelService; - @Autowired - private DynamicTask dynamicTask; - - @Autowired - private SipConfig sipConfig; @Transactional public void process(RequestEvent evt) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForMobilePositionProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForMobilePositionProcessor.java index 9c414a855..526b2b1e3 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForMobilePositionProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForMobilePositionProcessor.java @@ -14,10 +14,9 @@ import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IMobilePositionService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.utils.DateUtil; +import lombok.extern.slf4j.Slf4j; import org.dom4j.DocumentException; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -31,12 +30,10 @@ import java.util.concurrent.ConcurrentLinkedQueue; /** * SIP命令类型: NOTIFY请求中的移动位置请求处理 */ +@Slf4j @Component public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessorParent { - - private final static Logger logger = LoggerFactory.getLogger(NotifyRequestForMobilePositionProcessor.class); - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); @Autowired @@ -57,7 +54,7 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor public void process(RequestEvent evt) { if (taskQueue.size() >= userSetting.getMaxNotifyCountQueue()) { - logger.error("[notify-移动位置] 待处理消息队列已满 {},返回486 BUSY_HERE,消息不做处理", userSetting.getMaxNotifyCountQueue()); + log.error("[notify-移动位置] 待处理消息队列已满 {},返回486 BUSY_HERE,消息不做处理", userSetting.getMaxNotifyCountQueue()); return; } taskQueue.offer(new HandlerCatchData(evt, null, null)); @@ -80,12 +77,12 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor // 回复 200 OK Element rootElement = getRootElement(evt); if (rootElement == null) { - logger.error("处理MobilePosition移动位置Notify时未获取到消息体,{}", evt.getRequest()); + log.error("处理MobilePosition移动位置Notify时未获取到消息体,{}", evt.getRequest()); return; } Device device = redisCatchStorage.getDevice(deviceId); if (device == null) { - logger.error("处理MobilePosition移动位置Notify时未获取到device,{}", deviceId); + log.error("处理MobilePosition移动位置Notify时未获取到device,{}", deviceId); return; } MobilePosition mobilePosition = new MobilePosition(); @@ -143,7 +140,7 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor } } - logger.debug("[收到移动位置订阅通知]:{}/{}->{}.{}, 时间: {}", mobilePosition.getDeviceId(), mobilePosition.getChannelId(), + log.debug("[收到移动位置订阅通知]:{}/{}->{}.{}, 时间: {}", mobilePosition.getDeviceId(), mobilePosition.getChannelId(), mobilePosition.getLongitude(), mobilePosition.getLatitude(), System.currentTimeMillis() - startTime); mobilePosition.setReportSource("Mobile Position"); @@ -152,7 +149,7 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor try { eventPublisher.mobilePositionEventPublish(mobilePosition); }catch (Exception e) { - logger.error("[向上级转发移动位置失败] ", e); + log.error("[向上级转发移动位置失败] ", e); } if (mobilePosition.getChannelId() == null || mobilePosition.getChannelId().equals(mobilePosition.getDeviceId())) { List channels = deviceChannelService.queryChaneListByDeviceId(mobilePosition.getDeviceId()); @@ -161,7 +158,7 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor JSONObject jsonObject = new JSONObject(); jsonObject.put("time", DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(mobilePosition.getTime())); jsonObject.put("serial", channel.getDeviceId()); - jsonObject.put("code", channel.getChannelId()); + jsonObject.put("code", channel.getDeviceId()); jsonObject.put("longitude", mobilePosition.getLongitude()); jsonObject.put("latitude", mobilePosition.getLatitude()); jsonObject.put("altitude", mobilePosition.getAltitude()); @@ -183,7 +180,7 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor redisCatchStorage.sendMobilePositionMsg(jsonObject); } } catch (DocumentException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } } taskQueue.clear(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java index 8da07a15c..e06d0b473 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java @@ -13,10 +13,9 @@ import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.utils.DateUtil; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.DocumentException; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -31,12 +30,10 @@ import java.text.ParseException; /** * SIP命令类型: NOTIFY请求,这是作为上级发送订阅请求后,设备才会响应的 */ +@Slf4j @Component public class NotifyRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - - private final static Logger logger = LoggerFactory.getLogger(NotifyRequestProcessor.class); - @Autowired private SipConfig sipConfig; @@ -72,7 +69,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements responseAck((SIPRequest) evt.getRequest(), Response.OK, null, null); Element rootElement = getRootElement(evt); if (rootElement == null) { - logger.error("处理NOTIFY消息时未获取到消息体,{}", evt.getRequest()); + log.error("处理NOTIFY消息时未获取到消息体,{}", evt.getRequest()); responseAck((SIPRequest) evt.getRequest(), Response.OK, null, null); return; } @@ -85,10 +82,10 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements } else if (CmdType.MOBILE_POSITION.equals(cmd)) { notifyRequestForMobilePositionProcessor.process(evt); } else { - logger.info("接收到消息:" + cmd); + log.info("接收到消息:" + cmd); } } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } catch (DocumentException e) { throw new RuntimeException(e); } @@ -107,7 +104,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements Element rootElement = getRootElement(evt); if (rootElement == null) { - logger.error("处理alarm设备报警Notify时未获取到消息体{}", evt.getRequest()); + log.error("处理alarm设备报警Notify时未获取到消息体{}", evt.getRequest()); return; } Element deviceIdElement = rootElement.element("DeviceID"); @@ -115,12 +112,12 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements Device device = redisCatchStorage.getDevice(deviceId); if (device == null) { - logger.warn("[ NotifyAlarm ] 未找到设备:{}", deviceId); + log.warn("[ NotifyAlarm ] 未找到设备:{}", deviceId); return; } rootElement = getRootElement(evt, device.getCharset()); if (rootElement == null) { - logger.warn("[ NotifyAlarm ] content cannot be null, {}", evt.getRequest()); + log.warn("[ NotifyAlarm ] content cannot be null, {}", evt.getRequest()); return; } DeviceAlarm deviceAlarm = new DeviceAlarm(); @@ -129,7 +126,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements deviceAlarm.setAlarmMethod(XmlUtil.getText(rootElement, "AlarmMethod")); String alarmTime = XmlUtil.getText(rootElement, "AlarmTime"); if (alarmTime == null) { - logger.warn("[ NotifyAlarm ] AlarmTime cannot be null"); + log.warn("[ NotifyAlarm ] AlarmTime cannot be null"); return; } deviceAlarm.setAlarmTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(alarmTime)); @@ -148,7 +145,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements } else { deviceAlarm.setLatitude(0.00); } - logger.info("[收到Notify-Alarm]:{}/{}", device.getDeviceId(), deviceAlarm.getChannelId()); + log.info("[收到Notify-Alarm]:{}/{}", device.getDeviceId(), deviceAlarm.getChannelId()); if ("4".equals(deviceAlarm.getAlarmMethod())) { MobilePosition mobilePosition = new MobilePosition(); mobilePosition.setChannelId(channelId); @@ -161,19 +158,12 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements // 更新device channel 的经纬度 DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setDeviceId(device.getDeviceId()); - deviceChannel.setChannelId(channelId); + deviceChannel.setGbDeviceDbId(device.getId()); + deviceChannel.setDeviceId(channelId); deviceChannel.setLongitude(mobilePosition.getLongitude()); deviceChannel.setLatitude(mobilePosition.getLatitude()); deviceChannel.setGpsTime(mobilePosition.getTime()); - deviceChannel = deviceChannelService.updateGps(deviceChannel, device); - - mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84()); - mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84()); - mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02()); - mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02()); - deviceChannelService.updateChannelGPS(device, deviceChannel, mobilePosition); } @@ -182,7 +172,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements publisher.deviceAlarmEventPublish(deviceAlarm); } } catch (DocumentException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java index 1f0ba5393..f6132b78d 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java @@ -4,9 +4,9 @@ import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper; import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.bean.GbSipDate; import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo; import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; -import com.genersoft.iot.vmp.gb28181.bean.GbSipDate; import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; @@ -20,16 +20,12 @@ import gov.nist.javax.sip.address.SipUri; import gov.nist.javax.sip.header.SIPDateHeader; import gov.nist.javax.sip.message.SIPRequest; import gov.nist.javax.sip.message.SIPResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.ObjectUtils; -import javax.sip.*; -import javax.sip.header.*; -import javax.sip.message.Request; import javax.sip.RequestEvent; import javax.sip.SipException; import javax.sip.header.AuthorizationHeader; @@ -46,11 +42,10 @@ import java.util.Locale; /** * SIP命令类型: REGISTER请求 */ +@Slf4j @Component public class RegisterRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - private final Logger logger = LoggerFactory.getLogger(RegisterRequestProcessor.class); - public final String method = "REGISTER"; @Autowired @@ -104,11 +99,11 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen userSetting.getSipUseSourceIpAsRemoteAddress()); String requestAddress = remoteAddressInfo.getIp() + ":" + remoteAddressInfo.getPort(); String title = registerFlag ? "[注册请求]": "[注销请求]"; - logger.info(title + "设备:{}, 开始处理: {}", deviceId, requestAddress); + log.info(title + "设备:{}, 开始处理: {}", deviceId, requestAddress); if (device != null && device.getSipTransactionInfo() != null && request.getCallIdHeader().getCallId().equals(device.getSipTransactionInfo().getCallId())) { - logger.info(title + "设备:{}, 注册续订: {}",device.getDeviceId(), device.getDeviceId()); + log.info(title + "设备:{}, 注册续订: {}",device.getDeviceId(), device.getDeviceId()); if (registerFlag) { device.setExpires(request.getExpires().getExpires()); device.setIp(remoteAddressInfo.getIp()); @@ -133,7 +128,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen String password = (device != null && !ObjectUtils.isEmpty(device.getPassword()))? device.getPassword() : sipConfig.getPassword(); AuthorizationHeader authHead = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); if (authHead == null && !ObjectUtils.isEmpty(password)) { - logger.info(title + " 设备:{}, 回复401: {}",deviceId, requestAddress); + log.info(title + " 设备:{}, 回复401: {}",deviceId, requestAddress); response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request); new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain()); sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); @@ -148,7 +143,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen // 注册失败 response = getMessageFactory().createResponse(Response.FORBIDDEN, request); response.setReasonPhrase("wrong password"); - logger.info(title + " 设备:{}, 密码/SIP服务器ID错误, 回复403: {}", deviceId, requestAddress); + log.info(title + " 设备:{}, 密码/SIP服务器ID错误, 回复403: {}", deviceId, requestAddress); sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); return; } @@ -212,16 +207,16 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen // 注册成功 // 保存到redis if (registerFlag) { - logger.info("[注册成功] deviceId: {}->{}", deviceId, requestAddress); + log.info("[注册成功] deviceId: {}->{}", deviceId, requestAddress); device.setRegisterTime(DateUtil.getNow()); SipTransactionInfo sipTransactionInfo = new SipTransactionInfo((SIPResponse)response); deviceService.online(device, sipTransactionInfo); } else { - logger.info("[注销成功] deviceId: {}->{}" ,deviceId, requestAddress); + log.info("[注销成功] deviceId: {}->{}" ,deviceId, requestAddress); deviceService.offline(deviceId, "主动注销"); } } catch (SipException | NoSuchAlgorithmException | ParseException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java index c392a129d..aaf19524f 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java @@ -1,8 +1,5 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.CmdType; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; @@ -17,10 +14,9 @@ import com.genersoft.iot.vmp.service.IPlatformService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; import gov.nist.javax.sip.message.SIPResponse; +import lombok.extern.slf4j.Slf4j; import org.dom4j.DocumentException; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -36,10 +32,10 @@ import java.text.ParseException; * SIP命令类型: SUBSCRIBE请求 * @author lin */ +@Slf4j @Component public class SubscribeRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - private final Logger logger = LoggerFactory.getLogger(SubscribeRequestProcessor.class); private final String method = "SUBSCRIBE"; @Autowired @@ -75,7 +71,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme try { Element rootElement = getRootElement(evt); if (rootElement == null) { - logger.error("处理SUBSCRIBE请求 未获取到消息体{}", evt.getRequest()); + log.error("处理SUBSCRIBE请求 未获取到消息体{}", evt.getRequest()); return; } String cmd = XmlUtil.getText(rootElement, "CmdType"); @@ -87,18 +83,18 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme } else if (CmdType.CATALOG.equals(cmd)) { processNotifyCatalogList(request, rootElement); } else { - logger.info("接收到消息:" + cmd); + log.info("接收到消息:" + cmd); Response response = getMessageFactory().createResponse(200, request); if (response != null) { ExpiresHeader expireHeader = getHeaderFactory().createExpiresHeader(30); response.setExpires(expireHeader); } - logger.info("response : " + response); + log.info("response : " + response); sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); } } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } } @@ -119,7 +115,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme } String sn = XmlUtil.getText(rootElement, "SN"); - logger.info("[回复上级的移动位置订阅请求]: {}", platformId); + log.info("[回复上级的移动位置订阅请求]: {}", platformId); StringBuilder resultXml = new StringBuilder(200); resultXml.append("\r\n") .append("\r\n") @@ -153,7 +149,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme } } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } } @@ -174,7 +170,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme SubscribeInfo subscribeInfo = new SubscribeInfo(request, platformId); String sn = XmlUtil.getText(rootElement, "SN"); - logger.info("[回复上级的目录订阅请求]: {}/{}", platformId, deviceId); + log.info("[回复上级的目录订阅请求]: {}/{}", platformId, deviceId); StringBuilder resultXml = new StringBuilder(200); resultXml.append("\r\n") .append("\r\n") @@ -199,7 +195,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme subscribeHolder.putCatalogSubscribe(platformId, subscribeInfo); } } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } if (subscribeHolder.getCatalogSubscribe(platformId) == null && platform.isAutoPushChannel()) { platformService.addSimulatedSubscribeInfo(platform); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java index 92175ac29..9b85e7186 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java @@ -14,8 +14,7 @@ import com.genersoft.iot.vmp.service.IInviteStreamService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -28,11 +27,10 @@ import javax.sip.header.ContentTypeHeader; import javax.sip.message.Response; import java.text.ParseException; +@Slf4j @Component public class InfoRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - private final static Logger logger = LoggerFactory.getLogger(InfoRequestProcessor.class); - private final String method = "INFO"; @Autowired @@ -67,7 +65,7 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I @Override public void process(RequestEvent evt) { - logger.debug("接收到消息:" + evt.getRequest()); + log.debug("接收到消息:" + evt.getRequest()); SIPRequest request = (SIPRequest) evt.getRequest(); String deviceId = SipUtils.getUserIdFromFromHeader(request); CallIdHeader callIdHeader = request.getCallIdHeader(); @@ -84,7 +82,7 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(deviceId); try { if (device != null && parentPlatform != null) { - logger.warn("[重复]平台与设备编号重复:{}", deviceId); + log.warn("[重复]平台与设备编号重复:{}", deviceId); String hostAddress = request.getRemoteAddress().getHostAddress(); int remotePort = request.getRemotePort(); if (device.getHostAddress().equals(hostAddress + ":" + remotePort)) { @@ -96,7 +94,7 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I if (device == null && parentPlatform == null) { // 不存在则回复404 responseAck(request, Response.NOT_FOUND, "device "+ deviceId +" not found"); - logger.warn("[设备未找到 ]: {}", deviceId); + log.warn("[设备未找到 ]: {}", deviceId); if (sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()) != null){ DeviceNotFoundEvent deviceNotFoundEvent = new DeviceNotFoundEvent(evt.getDialog()); deviceNotFoundEvent.setCallId(callIdHeader.getCallId()); @@ -122,14 +120,14 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I try { responseAck(request, eventResult.statusCode, eventResult.msg); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 录像控制: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 录像控制: {}", e.getMessage()); } }, eventResult -> { // 成功的回复 try { responseAck(request, eventResult.statusCode); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 录像控制: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 录像控制: {}", e.getMessage()); } }); } @@ -137,11 +135,11 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I } } } catch (SipException e) { - logger.warn("SIP 回复错误", e); + log.warn("SIP 回复错误", e); } catch (InvalidArgumentException e) { - logger.warn("参数无效", e); + log.warn("参数无效", e); } catch (ParseException e) { - logger.warn("SIP回复时解析异常", e); + log.warn("SIP回复时解析异常", e); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java index 855395c0b..fecf6dade 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java @@ -6,9 +6,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorP import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd.CatalogQueryMessageHandler; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import javax.sip.InvalidArgumentException; @@ -21,10 +20,9 @@ import java.util.concurrent.ConcurrentHashMap; import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; +@Slf4j public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent implements IMessageHandler{ - private Logger logger = LoggerFactory.getLogger(MessageHandlerAbstract.class); - public Map messageHandlerMap = new ConcurrentHashMap<>(); @Autowired @@ -41,7 +39,7 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i try { responseAck((SIPRequest) evt.getRequest(), Response.OK); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 回复200 OK: {}", e.getMessage()); + log.error("[命令发送失败] 回复200 OK: {}", e.getMessage()); } return; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java index 34d7077e8..a95939dfa 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java @@ -13,10 +13,9 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.DocumentException; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -30,11 +29,10 @@ import java.text.ParseException; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +@Slf4j @Component public class MessageRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - private final static Logger logger = LoggerFactory.getLogger(MessageRequestProcessor.class); - private final String method = "MESSAGE"; private static final Map messageHandlerMap = new ConcurrentHashMap<>(); @@ -94,7 +92,7 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement if (device == null && parentPlatform == null) { // 不存在则回复404 responseAck(request, Response.NOT_FOUND, "device "+ deviceId +" not found"); - logger.warn("[设备未找到 ]deviceId: {}, callId: {}", deviceId, callIdHeader.getCallId()); + log.warn("[设备未找到 ]deviceId: {}, callId: {}", deviceId, callIdHeader.getCallId()); if (sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()) != null){ DeviceNotFoundEvent deviceNotFoundEvent = new DeviceNotFoundEvent(evt.getDialog()); deviceNotFoundEvent.setCallId(callIdHeader.getCallId()); @@ -106,7 +104,7 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement try { rootElement = getRootElement(evt); if (rootElement == null) { - logger.error("处理MESSAGE请求 未获取到消息体{}", evt.getRequest()); + log.error("处理MESSAGE请求 未获取到消息体{}", evt.getRequest()); responseAck(request, Response.BAD_REQUEST, "content is null"); return; } @@ -124,17 +122,17 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement responseAck(request, Response.UNSUPPORTED_MEDIA_TYPE, "Unsupported message type, must Control/Notify/Query/Response"); } } catch (DocumentException e) { - logger.warn("解析XML消息内容异常", e); + log.warn("解析XML消息内容异常", e); // 不存在则回复404 responseAck(request, Response.BAD_REQUEST, e.getMessage()); } } } catch (SipException e) { - logger.warn("SIP 回复错误", e); + log.warn("SIP 回复错误", e); } catch (InvalidArgumentException e) { - logger.warn("参数无效", e); + log.warn("参数无效", e); } catch (ParseException e) { - logger.warn("SIP回复时解析异常", e); + log.warn("SIP回复时解析异常", e); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java index 23adac13e..d2b6c449e 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java @@ -7,34 +7,33 @@ import com.genersoft.iot.vmp.gb28181.bean.HomePositionRequest; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.control.ControlMessageHandler; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; import org.springframework.util.ObjectUtils; -import javax.sip.*; +import javax.sip.InvalidArgumentException; +import javax.sip.RequestEvent; +import javax.sip.SipException; import javax.sip.address.SipURI; import javax.sip.message.Response; import java.text.ParseException; import java.util.List; -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.*; +import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; +import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.loadElement; +@Slf4j @Component public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(DeviceControlQueryMessageHandler.class); private final String cmdType = "DeviceControl"; @Autowired @@ -46,13 +45,6 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent @Autowired private SIPCommander cmder; - @Autowired - private SIPCommanderFroPlatform cmderFroPlatform; - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - @Override public void afterPropertiesSet() throws Exception { controlMessageHandler.addHandler(cmdType, this); @@ -74,7 +66,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent // 远程启动功能 if (!ObjectUtils.isEmpty(getText(rootElement, "TeleBoot"))) { // TODO 拒绝远程启动命令 - logger.warn("[国标级联]收到平台的远程启动命令, 不处理"); + log.warn("[国标级联]收到平台的远程启动命令, 不处理"); // if (parentPlatform.getServerGBId().equals(targetGBId)) { // // 远程启动本平台:需要在重新启动程序后先对SipStack解绑 @@ -107,7 +99,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent // } } DeviceControlType deviceControlType = DeviceControlType.typeOf(rootElement); - logger.info("[接受deviceControl命令] 命令: {}", deviceControlType); + log.info("[接受deviceControl命令] 命令: {}", deviceControlType); if (!ObjectUtils.isEmpty(deviceControlType) && !parentPlatform.getServerGBId().equals(targetGBId)) { //判断是否存在该通道 Device deviceForPlatform = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); @@ -115,7 +107,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent try { responseAck(request, Response.NOT_FOUND); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 错误信息: {}", e.getMessage()); + log.error("[命令发送失败] 错误信息: {}", e.getMessage()); } return; } @@ -168,7 +160,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent errorResult -> onError(request, errorResult), okResult -> onOk(request, okResult)); } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 云台/前端: {}", e.getMessage()); + log.error("[命令发送失败] 云台/前端: {}", e.getMessage()); } } @@ -183,7 +175,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent cmder.iFrameCmd(device, channelId); responseAck(request, Response.OK); } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 强制关键帧: {}", e.getMessage()); + log.error("[命令发送失败] 强制关键帧: {}", e.getMessage()); } } @@ -197,7 +189,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent cmder.teleBootCmd(device); responseAck(request, Response.OK); } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 重启: {}", e.getMessage()); + log.error("[命令发送失败] 重启: {}", e.getMessage()); } } @@ -229,7 +221,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent cmder.dragZoomCmd(device, channelId, cmdXml.toString()); responseAck(request, Response.OK); } catch (Exception e) { - logger.error("[命令发送失败] 拉框控制: {}", e.getMessage()); + log.error("[命令发送失败] 拉框控制: {}", e.getMessage()); } } @@ -252,7 +244,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent errorResult -> onError(request, errorResult), okResult -> onOk(request, okResult)); } catch (Exception e) { - logger.error("[命令发送失败] 看守位设置: {}", e.getMessage()); + log.error("[命令发送失败] 看守位设置: {}", e.getMessage()); } } @@ -280,7 +272,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent errorResult -> onError(request, errorResult), okResult -> onOk(request, okResult)); } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 告警消息: {}", e.getMessage()); + log.error("[命令发送失败] 告警消息: {}", e.getMessage()); } } @@ -301,7 +293,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent errorResult -> onError(request, errorResult), okResult -> onOk(request, okResult)); } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 录像控制: {}", e.getMessage()); + log.error("[命令发送失败] 录像控制: {}", e.getMessage()); } } @@ -321,7 +313,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent errorResult -> onError(request, errorResult), okResult -> onOk(request, okResult)); } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 布防/撤防命令: {}", e.getMessage()); + log.error("[命令发送失败] 布防/撤防命令: {}", e.getMessage()); } } @@ -337,7 +329,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent try { responseAck(request, eventResult.statusCode, eventResult.msg); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 回复: {}", e.getMessage()); + log.error("[命令发送失败] 回复: {}", e.getMessage()); } } @@ -352,7 +344,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent try { responseAck(request, eventResult.statusCode); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 回复: {}", e.getMessage()); + log.error("[命令发送失败] 回复: {}", e.getMessage()); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java index ec4a3993f..1b300ee1d 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java @@ -148,19 +148,14 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme // 更新device channel 的经纬度 DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setDeviceId(sipMsgInfo.getDevice().getDeviceId()); - deviceChannel.setChannelId(channelId); + deviceChannel.setGbDeviceDbId(sipMsgInfo.getDevice().getId()); + deviceChannel.setDeviceId(channelId); deviceChannel.setLongitude(mobilePosition.getLongitude()); deviceChannel.setLatitude(mobilePosition.getLatitude()); deviceChannel.setGpsTime(mobilePosition.getTime()); deviceChannel = deviceChannelService.updateGps(deviceChannel, sipMsgInfo.getDevice()); - mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84()); - mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84()); - mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02()); - mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02()); - deviceChannelService.updateChannelGPS(device, deviceChannel, mobilePosition); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/BroadcastNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/BroadcastNotifyMessageHandler.java index bb1b37926..f0ee287b7 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/BroadcastNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/BroadcastNotifyMessageHandler.java @@ -15,9 +15,8 @@ import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -31,10 +30,10 @@ import java.text.ParseException; /** * 状态信息(心跳)报送 */ +@Slf4j @Component public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(BroadcastNotifyMessageHandler.class); private final static String cmdType = "Broadcast"; @Autowired @@ -93,11 +92,11 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp String targetId = targetIDElement.getText(); - logger.info("[国标级联 语音喊话] platform: {}, channel: {}", platform.getServerGBId(), targetId); + log.info("[国标级联 语音喊话] platform: {}, channel: {}", platform.getServerGBId(), targetId); DeviceChannel deviceChannel = storage.queryChannelInParentPlatform(platform.getServerGBId(), targetId); if (deviceChannel == null) { - logger.warn("[国标级联 语音喊话] 未找到通道 platform: {}, channel: {}", platform.getServerGBId(), targetId); + log.warn("[国标级联 语音喊话] 未找到通道 platform: {}, channel: {}", platform.getServerGBId(), targetId); responseAck(request, Response.NOT_FOUND, "TargetID not found"); return; } @@ -117,18 +116,18 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp MediaServer mediaServerForMinimumLoad = mediaServerService.getMediaServerForMinimumLoad(null); commanderForPlatform.broadcastResultCmd(platform, deviceChannel, sn, true, eventResult->{ - logger.info("[国标级联] 语音喊话 回复失败 platform: {}, 错误:{}/{}", platform.getServerGBId(), eventResult.statusCode, eventResult.msg); + log.info("[国标级联] 语音喊话 回复失败 platform: {}, 错误:{}/{}", platform.getServerGBId(), eventResult.statusCode, eventResult.msg); }, eventResult->{ // 消息发送成功, 向上级发送invite,获取推流 try { - platformService.broadcastInvite(platform, deviceChannel.getChannelId(), mediaServerForMinimumLoad, (hookData)->{ + platformService.broadcastInvite(platform, deviceChannel.getDeviceId(), mediaServerForMinimumLoad, (hookData)->{ // 上级平台推流成功 AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(device.getDeviceId(), targetId); if (broadcastCatch != null ) { if (playService.audioBroadcastInUse(device, targetId)) { - logger.info("[国标级联] 语音喊话 设备正在使用中 platform: {}, channel: {}", - platform.getServerGBId(), deviceChannel.getChannelId()); + log.info("[国标级联] 语音喊话 设备正在使用中 platform: {}, channel: {}", + platform.getServerGBId(), deviceChannel.getDeviceId()); // 查看语音通道已经建立且已经占用 回复BYE platformService.stopBroadcast(platform, deviceChannel, hookData.getStream(), true, hookData.getMediaServer()); }else { @@ -140,51 +139,51 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp // 推流到设备 SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, targetId, hookData.getStream(), null); if (sendRtpItem == null) { - logger.warn("[国标级联] 语音喊话 异常,未找到发流信息, channelId: {}, stream: {}", targetId, hookData.getStream()); - logger.info("[国标级联] 语音喊话 重新开始,channelId: {}, stream: {}", targetId, hookData.getStream()); + log.warn("[国标级联] 语音喊话 异常,未找到发流信息, channelId: {}, stream: {}", targetId, hookData.getStream()); + log.info("[国标级联] 语音喊话 重新开始,channelId: {}, stream: {}", targetId, hookData.getStream()); try { playService.audioBroadcastCmd(device, targetId, hookData.getMediaServer(), hookData.getApp(), hookData.getStream(), 60, true, msg -> { - logger.info("[语音喊话] 通道建立成功, device: {}, channel: {}", device.getDeviceId(), targetId); + log.info("[语音喊话] 通道建立成功, device: {}, channel: {}", device.getDeviceId(), targetId); }); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.info("[消息发送失败] 国标级联 语音喊话 platform: {}", platform.getServerGBId()); + log.info("[消息发送失败] 国标级联 语音喊话 platform: {}", platform.getServerGBId()); } }else { // 发流 try { mediaServerService.startSendRtp(hookData.getMediaServer(), sendRtpItem); }catch (ControllerException e) { - logger.info("[语音喊话] 推流失败, 结果: {}", e.getMessage()); + log.info("[语音喊话] 推流失败, 结果: {}", e.getMessage()); return; } - logger.info("[语音喊话] 自动推流成功, device: {}, channel: {}", device.getDeviceId(), targetId); + log.info("[语音喊话] 自动推流成功, device: {}, channel: {}", device.getDeviceId(), targetId); } } }else { try { playService.audioBroadcastCmd(device, targetId, hookData.getMediaServer(), hookData.getApp(), hookData.getStream(), 60, true, msg -> { - logger.info("[语音喊话] 通道建立成功, device: {}, channel: {}", device.getDeviceId(), targetId); + log.info("[语音喊话] 通道建立成功, device: {}, channel: {}", device.getDeviceId(), targetId); }); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.info("[消息发送失败] 国标级联 语音喊话 platform: {}", platform.getServerGBId()); + log.info("[消息发送失败] 国标级联 语音喊话 platform: {}", platform.getServerGBId()); } } }, eventResultForBroadcastInvite -> { // 收到错误 - logger.info("[国标级联-语音喊话] 与下级通道建立失败 device: {}, channel: {}, 错误:{}/{}", device.getDeviceId(), + log.info("[国标级联-语音喊话] 与下级通道建立失败 device: {}, channel: {}, 错误:{}/{}", device.getDeviceId(), targetId, eventResultForBroadcastInvite.statusCode, eventResultForBroadcastInvite.msg); }, (code, msg)->{ // 超时 - logger.info("[国标级联-语音喊话] 与下级通道建立超时 device: {}, channel: {}, 错误:{}/{}", device.getDeviceId(), + log.info("[国标级联-语音喊话] 与下级通道建立超时 device: {}, channel: {}, 错误:{}/{}", device.getDeviceId(), targetId, code, msg); }); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.info("[消息发送失败] 国标级联 语音喊话 invite消息 platform: {}", platform.getServerGBId()); + log.info("[消息发送失败] 国标级联 语音喊话 invite消息 platform: {}", platform.getServerGBId()); } }); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.info("[消息发送失败] 国标级联 语音喊话 platform: {}", platform.getServerGBId()); + log.info("[消息发送失败] 国标级联 语音喊话 platform: {}", platform.getServerGBId()); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java index 85f2da747..bf4559e69 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java @@ -13,10 +13,9 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.utils.DateUtil; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -30,11 +29,11 @@ import java.text.ParseException; /** * 状态信息(心跳)报送 */ +@Slf4j @Component public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private final Logger logger = LoggerFactory.getLogger(KeepaliveNotifyMessageHandler.class); private final static String cmdType = "Keepalive"; @Autowired @@ -61,25 +60,25 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp return; } SIPRequest request = (SIPRequest) evt.getRequest(); - logger.info("[收到心跳] device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId()); + log.info("[收到心跳] device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId()); if (userSetting.getGbDeviceOnline() == 0 && !device.isOnLine()) { - logger.warn("[收到心跳] 设备离线,心跳不进行回复, device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId()); + log.warn("[收到心跳] 设备离线,心跳不进行回复, device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId()); return; } // 回复200 OK try { responseAck(request, Response.OK); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 心跳回复: {}", e.getMessage()); + log.error("[命令发送失败] 心跳回复: {}", e.getMessage()); } if (!ObjectUtils.isEmpty(device.getKeepaliveTime()) && DateUtil.getDifferenceForNow(device.getKeepaliveTime()) <= 3000L) { - logger.info("[收到心跳] 心跳发送过于频繁,已忽略 device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId()); + log.info("[收到心跳] 心跳发送过于频繁,已忽略 device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId()); return; } RemoteAddressInfo remoteAddressInfo = SipUtils.getRemoteAddressFromRequest(request, userSetting.getSipUseSourceIpAsRemoteAddress()); if (!device.getIp().equalsIgnoreCase(remoteAddressInfo.getIp()) || device.getPort() != remoteAddressInfo.getPort() || !request.getRemoteAddress().getHostAddress().equals(device.getLocalIp())) { - logger.info("[收到心跳] 设备{}地址变化, 远程地址为: {}:{}", device.getDeviceId(), remoteAddressInfo.getIp(), remoteAddressInfo.getPort()); + log.info("[收到心跳] 设备{}地址变化, 远程地址为: {}:{}", device.getDeviceId(), remoteAddressInfo.getIp(), remoteAddressInfo.getPort()); device.setPort(remoteAddressInfo.getPort()); device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort()))); device.setIp(remoteAddressInfo.getIp()); @@ -125,7 +124,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp try { responseAck((SIPRequest) evt.getRequest(), Response.OK); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 心跳回复: {}", e.getMessage()); + log.error("[命令发送失败] 心跳回复: {}", e.getMessage()); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java index f8ff69cf1..8574770dc 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java @@ -20,9 +20,8 @@ import com.genersoft.iot.vmp.service.IInviteStreamService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -39,10 +38,10 @@ import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; /** * 媒体通知 */ +@Slf4j @Component public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(MediaStatusNotifyMessageHandler.class); private final String cmdType = "MediaStatus"; @Autowired @@ -84,16 +83,16 @@ public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent i try { responseAck((SIPRequest) evt.getRequest(), Response.OK); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 录像流推送完毕,回复200OK: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 录像流推送完毕,回复200OK: {}", e.getMessage()); } CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); String NotifyType =getText(rootElement, "NotifyType"); if ("121".equals(NotifyType)){ - logger.info("[录像流]推送完毕,收到关流通知"); + log.info("[录像流]推送完毕,收到关流通知"); SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(null, null, callIdHeader.getCallId(), null); if (ssrcTransaction != null) { - logger.info("[录像流]推送完毕,关流通知, device: {}, channelId: {}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); + log.info("[录像流]推送完毕,关流通知, device: {}, channelId: {}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); InviteInfo inviteInfo = inviteStreamService.getInviteInfo(InviteSessionType.DOWNLOAD, ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream()); if (inviteInfo.getStreamInfo() != null) { inviteInfo.getStreamInfo().setProgress(1); @@ -103,7 +102,7 @@ public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent i try { cmder.streamByeCmd(device, ssrcTransaction.getChannelId(), null, callIdHeader.getCallId()); } catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) { - logger.error("[录像流]推送完毕,收到关流通知, 发送BYE失败 {}", e.getMessage()); + log.error("[录像流]推送完毕,收到关流通知, 发送BYE失败 {}", e.getMessage()); } // 去除监听流注销自动停止下载的监听 Hook hook = Hook.getInstance(HookType.on_media_arrival, "rtp", ssrcTransaction.getStream(), ssrcTransaction.getMediaServerId()); @@ -113,17 +112,17 @@ public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent i if (sendRtpItem != null) { ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(sendRtpItem.getPlatformId()); if (parentPlatform == null) { - logger.warn("[级联消息发送]:发送MediaStatus发现上级平台{}不存在", sendRtpItem.getPlatformId()); + log.warn("[级联消息发送]:发送MediaStatus发现上级平台{}不存在", sendRtpItem.getPlatformId()); return; } try { sipCommanderFroPlatform.sendMediaStatusNotify(parentPlatform, sendRtpItem); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 录像播放完毕: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 录像播放完毕: {}", e.getMessage()); } } }else { - logger.info("[录像流]推送完毕,关流通知, 但是未找到对应的下载信息"); + log.info("[录像流]推送完毕,关流通知, 但是未找到对应的下载信息"); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java index bc588c95b..d1650d4f1 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java @@ -128,18 +128,12 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen // 更新device channel 的经纬度 DeviceChannel deviceChannel = new DeviceChannel(); deviceChannel.setDeviceId(sipMsgInfo.getDevice().getDeviceId()); - deviceChannel.setChannelId(mobilePosition.getChannelId()); + deviceChannel.setDeviceId(mobilePosition.getChannelId()); deviceChannel.setLongitude(mobilePosition.getLongitude()); deviceChannel.setLatitude(mobilePosition.getLatitude()); deviceChannel.setGpsTime(mobilePosition.getTime()); deviceChannel = deviceChannelService.updateGps(deviceChannel, sipMsgInfo.getDevice()); - - mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84()); - mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84()); - mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02()); - mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02()); - deviceChannelService.updateChannelGPS(device, deviceChannel, mobilePosition); } catch (DocumentException e) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java index ce8c9397a..3f22851b6 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java @@ -1,18 +1,13 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd; -import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -23,27 +18,15 @@ import javax.sip.SipException; import javax.sip.message.Response; import java.text.ParseException; +@Slf4j @Component public class AlarmQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(AlarmQueryMessageHandler.class); private final String cmdType = "Alarm"; @Autowired private QueryMessageHandler queryMessageHandler; - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private SIPCommanderFroPlatform cmderFroPlatform; - - @Autowired - private SipConfig config; - - @Autowired - private EventPublisher publisher; - @Override public void afterPropertiesSet() throws Exception { queryMessageHandler.addHandler(cmdType, this); @@ -57,11 +40,11 @@ public class AlarmQueryMessageHandler extends SIPRequestProcessorParent implemen @Override public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - logger.info("不支持alarm查询"); + log.info("不支持alarm查询"); try { responseAck((SIPRequest) evt.getRequest(), Response.NOT_FOUND, "not support alarm query"); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 alarm查询回复200OK: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 alarm查询回复200OK: {}", e.getMessage()); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java index 25a3df375..fb8828f03 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java @@ -1,19 +1,19 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd; import com.genersoft.iot.vmp.conf.SipConfig; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; +import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -24,20 +24,19 @@ import javax.sip.SipException; import javax.sip.header.FromHeader; import javax.sip.message.Response; import java.text.ParseException; -import java.util.ArrayList; import java.util.List; +@Slf4j @Component public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(CatalogQueryMessageHandler.class); private final String cmdType = "Catalog"; @Autowired private QueryMessageHandler queryMessageHandler; @Autowired - private IVideoManagerStorage storager; + private IGbChannelService channelService; @Autowired private SIPCommanderFroPlatform cmderFroPlatform; @@ -69,62 +68,24 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem // 回复200 OK responseAck((SIPRequest) evt.getRequest(), Response.OK); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 目录查询回复200OK: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 目录查询回复200OK: {}", e.getMessage()); } Element snElement = rootElement.element("SN"); String sn = snElement.getText(); - // 准备回复通道信息 - List deviceChannelInPlatforms = storager.queryChannelWithCatalog(parentPlatform.getServerGBId()); - // 查询关联的直播通道 - List gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); - // 回复目录信息 - List catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId()); + List channelList = channelService.queryByPlatformId(parentPlatform.getId()); - List allChannels = new ArrayList<>(); + // TODO 是否包含平台信息,做成一个策略 - // 回复平台 -// DeviceChannel deviceChannel = getChannelForPlatform(parentPlatform); -// allChannels.add(deviceChannel); - - // 回复目录 - if (catalogs.size() > 0) { - allChannels.addAll(catalogs); - } - // 回复级联的通道 - if (deviceChannelInPlatforms.size() > 0) { - allChannels.addAll(deviceChannelInPlatforms); - } - // 回复直播的通道 - if (gbStreams.size() > 0) { - allChannels.addAll(gbStreams); - } try { - if (allChannels.size() > 0) { - cmderFroPlatform.catalogQuery(allChannels, parentPlatform, sn, fromHeader.getTag()); + if (!channelList.isEmpty()) { + cmderFroPlatform.catalogQuery(channelList, parentPlatform, sn, fromHeader.getTag()); }else { // 回复无通道 cmderFroPlatform.catalogQuery(null, parentPlatform, sn, fromHeader.getTag(), 0); } } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 目录查询回复: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 目录查询回复: {}", e.getMessage()); } - - - } - - private DeviceChannel getChannelForPlatform(ParentPlatform platform) { - DeviceChannel deviceChannel = new DeviceChannel(); - - deviceChannel.setChannelId(platform.getDeviceGBId()); - deviceChannel.setName(platform.getName()); - deviceChannel.setManufacture("wvp-pro"); - deviceChannel.setOwner("wvp-pro"); - deviceChannel.setCivilCode(platform.getAdministrativeDivision()); - deviceChannel.setAddress("wvp-pro"); - deviceChannel.setRegisterWay(0); - deviceChannel.setSecrecy("0"); - - return deviceChannel; } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java index 8b774e100..95f855502 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java @@ -8,9 +8,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessag import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -24,10 +23,10 @@ import java.text.ParseException; import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; +@Slf4j @Component public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(DeviceInfoQueryMessageHandler.class); private final String cmdType = "DeviceInfo"; @Autowired @@ -50,13 +49,13 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp @Override public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - logger.info("[DeviceInfo查询]消息"); + log.info("[DeviceInfo查询]消息"); FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); try { // 回复200 OK responseAck((SIPRequest) evt.getRequest(), Response.OK); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] DeviceInfo查询回复: {}", e.getMessage()); + log.error("[命令发送失败] DeviceInfo查询回复: {}", e.getMessage()); return; } String sn = rootElement.element("SN").getText(); @@ -72,14 +71,14 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp if (!parentPlatform.getDeviceGBId().equals(channelId)) { device = storager.queryDeviceInfoByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); if (device ==null){ - logger.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId); + log.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId); return; } } try { cmderFroPlatform.deviceInfoResponse(parentPlatform, device, sn, fromHeader.getTag()); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 DeviceInfo查询回复: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 DeviceInfo查询回复: {}", e.getMessage()); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java index f9edfb396..7953068e5 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java @@ -1,19 +1,16 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd; -import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -27,10 +24,10 @@ import java.text.ParseException; import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; +@Slf4j @Component public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(DeviceStatusQueryMessageHandler.class); private final String cmdType = "DeviceStatus"; @Autowired @@ -40,13 +37,7 @@ public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent i private IVideoManagerStorage storager; @Autowired - private SIPCommanderFroPlatform cmderFroPlatform; - - @Autowired - private SipConfig config; - - @Autowired - private EventPublisher publisher; + private ISIPCommanderForPlatform cmderFroPlatform; @Override public void afterPropertiesSet() throws Exception { @@ -61,25 +52,25 @@ public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent i @Override public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - logger.info("接收到DeviceStatus查询消息"); + log.info("接收到DeviceStatus查询消息"); FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); // 回复200 OK try { responseAck((SIPRequest) evt.getRequest(), Response.OK); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 DeviceStatus查询回复200OK: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 DeviceStatus查询回复200OK: {}", e.getMessage()); } String sn = rootElement.element("SN").getText(); String channelId = getText(rootElement, "DeviceID"); DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(parentPlatform.getServerGBId(), channelId); if (deviceChannel ==null){ - logger.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId); + log.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId); return; } try { - cmderFroPlatform.deviceStatusResponse(parentPlatform,channelId, sn, fromHeader.getTag(),deviceChannel.isStatus()); + cmderFroPlatform.deviceStatusResponse(parentPlatform,channelId, sn, fromHeader.getTag(), "ON".equalsIgnoreCase(deviceChannel.getStatus())); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 DeviceStatus查询回复: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 DeviceStatus查询回复: {}", e.getMessage()); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java index e2f9cda9e..cf294e784 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java @@ -1,21 +1,20 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd; -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; +import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; +import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEventListener; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; -import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; +import com.genersoft.iot.vmp.utils.DateUtil; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -27,10 +26,10 @@ import javax.sip.message.Response; import java.text.ParseException; import java.util.List; +@Slf4j @Component public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(RecordInfoQueryMessageHandler.class); private final String cmdType = "RecordInfo"; @Autowired @@ -48,12 +47,6 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp @Autowired private RecordEndEventListener recordEndEventListener; - @Autowired - private SipConfig config; - - @Autowired - private EventPublisher publisher; - @Override public void afterPropertiesSet() throws Exception { queryMessageHandler.addHandler(cmdType, this); @@ -102,10 +95,10 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp // 接收录像数据 recordEndEventListener.addEndEventHandler(deviceChannel.getDeviceId(), channelId, (recordInfo)->{ try { - logger.info("[国标级联] 录像查询收到数据, 通道: {},准备转发===", channelId); + log.info("[国标级联] 录像查询收到数据, 通道: {},准备转发===", channelId); cmderFroPlatform.recordInfo(deviceChannel, parentPlatform, request.getFromTag(), recordInfo); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 回复录像数据: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 回复录像数据: {}", e.getMessage()); } }); try { @@ -115,18 +108,18 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp try { responseAck(request, Response.OK); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 录像查询回复: {}", e.getMessage()); + log.error("[命令发送失败] 录像查询回复: {}", e.getMessage()); } }),(eventResult -> { // 查询失败 try { responseAck(request, eventResult.statusCode, eventResult.msg); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 录像查询回复: {}", e.getMessage()); + log.error("[命令发送失败] 录像查询回复: {}", e.getMessage()); } })); } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[命令发送失败] 录像查询: {}", e.getMessage()); + log.error("[命令发送失败] 录像查询: {}", e.getMessage()); } }else if (channelSources.get(1).getCount() > 0) { // 直播流 @@ -134,13 +127,13 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp try { responseAck(request, Response.NOT_IMPLEMENTED); // 回复未实现 } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 录像查询: {}", e.getMessage()); + log.error("[命令发送失败] 录像查询: {}", e.getMessage()); } }else { // 错误的请求 try { responseAck(request, Response.BAD_REQUEST); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 录像查询: {}", e.getMessage()); + log.error("[命令发送失败] 录像查询: {}", e.getMessage()); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/AlarmResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/AlarmResponseMessageHandler.java index 3edf02fea..e03634c19 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/AlarmResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/AlarmResponseMessageHandler.java @@ -9,19 +9,18 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorP import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.sip.RequestEvent; +@Slf4j @Component public class AlarmResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(AlarmResponseMessageHandler.class); private final String cmdType = "Alarm"; @Autowired @@ -42,8 +41,8 @@ public class AlarmResponseMessageHandler extends SIPRequestProcessorParent imple String key = DeferredResultHolder.CALLBACK_CMD_ALARM + device.getDeviceId() + channelId; JSONObject json = new JSONObject(); XmlUtil.node2Json(rootElement, json); - if (logger.isDebugEnabled()) { - logger.debug(json.toJSONString()); + if (log.isDebugEnabled()) { + log.debug(json.toJSONString()); } RequestMessage msg = new RequestMessage(); msg.setKey(key); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java index c910451df..43d875872 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java @@ -11,9 +11,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessag import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; import com.genersoft.iot.vmp.service.IPlayService; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -26,10 +25,10 @@ import java.text.ParseException; import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; +@Slf4j @Component public class BroadcastResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(BroadcastResponseMessageHandler.class); private final String cmdType = "Broadcast"; @Autowired @@ -66,7 +65,7 @@ public class BroadcastResponseMessageHandler extends SIPRequestProcessorParent i if (infoElement != null) { reason = getText(infoElement, "Reason"); } - logger.info("[语音广播]回复:{}, {}/{}", reason == null? result : result + ": " + reason, device.getDeviceId(), channelId ); + log.info("[语音广播]回复:{}, {}/{}", reason == null? result : result + ": " + reason, device.getDeviceId(), channelId ); // 回复200 OK responseAck(request, Response.OK); @@ -78,7 +77,7 @@ public class BroadcastResponseMessageHandler extends SIPRequestProcessorParent i playService.stopAudioBroadcast(device.getDeviceId(), channelId); } } catch (ParseException | SipException | InvalidArgumentException e) { - logger.error("[命令发送失败] 国标级联 语音喊话: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 语音喊话: {}", e.getMessage()); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java index c2b0b2def..4a2150943 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java @@ -6,13 +6,12 @@ import com.genersoft.iot.vmp.gb28181.session.CatalogDataCatch; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; +import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.DocumentException; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -33,11 +32,10 @@ import java.util.concurrent.atomic.AtomicBoolean; /** * 目录查询的回复 */ +@Slf4j @Component public class CatalogResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(CatalogResponseMessageHandler.class); - private final String cmdType = "Catalog"; @Autowired @@ -48,6 +46,9 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp @Autowired private IVideoManagerStorage storager; + @Autowired + private IDeviceChannelService deviceChannelService; + @Autowired private CatalogDataCatch catalogDataCatch; @@ -71,7 +72,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp try { responseAck((SIPRequest) evt.getRequest(), Response.OK); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 目录查询回复: {}", e.getMessage()); + log.error("[命令发送失败] 目录查询回复: {}", e.getMessage()); } // 已经开启消息处理则跳过 if (processing.compareAndSet(false, true)) { @@ -84,11 +85,11 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp try { rootElement = getRootElement(take.getEvt(), take.getDevice().getCharset()); } catch (DocumentException e) { - logger.error("[xml解析] 失败: ", e); + log.error("[xml解析] 失败: ", e); continue; } if (rootElement == null) { - logger.warn("[ 收到通道 ] content cannot be null, {}", evt.getRequest()); + log.warn("[ 收到通道 ] content cannot be null, {}", evt.getRequest()); continue; } Element deviceListElement = rootElement.element("DeviceList"); @@ -97,9 +98,9 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp int sumNum = Integer.parseInt(sumNumElement.getText()); if (sumNum == 0) { - logger.info("[收到通道]设备:{}的: 0个", take.getDevice().getDeviceId()); + log.info("[收到通道]设备:{}的: 0个", take.getDevice().getDeviceId()); // 数据已经完整接收 - storager.cleanChannelsForDevice(take.getDevice().getDeviceId()); + deviceChannelService.cleanChannelsForDevice(take.getDevice().getDeviceId()); catalogDataCatch.setChannelSyncEnd(take.getDevice().getDeviceId(), null); } else { Iterator deviceListIterator = deviceListElement.elementIterator(); @@ -116,24 +117,23 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp DeviceChannel channel = DeviceChannel.decode(itemDevice); // DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, null); if (channel == null || channel.getDeviceId() == null) { - logger.info("[收到目录订阅]:但是解析失败 {}", new String(evt.getRequest().getRawContent())); + log.info("[收到目录订阅]:但是解析失败 {}", new String(evt.getRequest().getRawContent())); continue; } if (channel.getParentId() != null && channel.getParentId().equals(sipConfig.getId())) { channel.setParentId(null); } - SipUtils.updateGps(channel, device.getGeoCoordSys()); channel.setDeviceId(take.getDevice().getDeviceId()); channelList.add(channel); } int sn = Integer.parseInt(snElement.getText()); catalogDataCatch.put(take.getDevice().getDeviceId(), sn, sumNum, take.getDevice(), channelList); - logger.info("[收到通道]设备: {} -> {}个,{}/{}", take.getDevice().getDeviceId(), channelList.size(), catalogDataCatch.get(take.getDevice().getDeviceId()) == null ? 0 : catalogDataCatch.get(take.getDevice().getDeviceId()).size(), sumNum); + log.info("[收到通道]设备: {} -> {}个,{}/{}", take.getDevice().getDeviceId(), channelList.size(), catalogDataCatch.get(take.getDevice().getDeviceId()) == null ? 0 : catalogDataCatch.get(take.getDevice().getDeviceId()).size(), sumNum); if (catalogDataCatch.get(take.getDevice().getDeviceId()).size() == sumNum) { // 数据已经完整接收, 此时可能存在某个设备离线变上线的情况,但是考虑到性能,此处不做处理, // 目前支持设备通道上线通知时和设备上线时向上级通知 - boolean resetChannelsResult = storager.resetChannels(take.getDevice().getDeviceId(), catalogDataCatch.get(take.getDevice().getDeviceId())); + boolean resetChannelsResult = deviceChannelService.resetChannels(take.getDevice().getDeviceId(), catalogDataCatch.get(take.getDevice().getDeviceId())); if (!resetChannelsResult) { String errorMsg = "接收成功,写入失败,共" + sumNum + "条,已接收" + catalogDataCatch.get(take.getDevice().getDeviceId()).size() + "条"; catalogDataCatch.setChannelSyncEnd(take.getDevice().getDeviceId(), errorMsg); @@ -145,8 +145,8 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp } } catch (Exception e) { - logger.warn("[收到通道] 发现未处理的异常, \r\n{}", evt.getRequest()); - logger.error("[收到通道] 异常内容: ", e); + log.warn("[收到通道] 发现未处理的异常, \r\n{}", evt.getRequest()); + log.error("[收到通道] 异常内容: ", e); } } processing.set(false); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/ConfigDownloadResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/ConfigDownloadResponseMessageHandler.java index 47ae1a9c1..f0181059d 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/ConfigDownloadResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/ConfigDownloadResponseMessageHandler.java @@ -3,7 +3,6 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.respon import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; @@ -11,9 +10,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessag import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -26,18 +24,15 @@ import java.text.ParseException; import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; +@Slf4j @Component public class ConfigDownloadResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(ConfigDownloadResponseMessageHandler.class); private final String cmdType = "ConfigDownload"; @Autowired private ResponseMessageHandler responseMessageHandler; - @Autowired - private EventPublisher publisher; - @Autowired private DeferredResultHolder deferredResultHolder; @@ -55,13 +50,13 @@ public class ConfigDownloadResponseMessageHandler extends SIPRequestProcessorPar // 回复200 OK responseAck((SIPRequest) evt.getRequest(), Response.OK); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 设备配置查询: {}", e.getMessage()); + log.error("[命令发送失败] 设备配置查询: {}", e.getMessage()); } // 此处是对本平台发出DeviceControl指令的应答 JSONObject json = new JSONObject(); XmlUtil.node2Json(element, json); - if (logger.isDebugEnabled()) { - logger.debug(json.toJSONString()); + if (log.isDebugEnabled()) { + log.debug(json.toJSONString()); } RequestMessage msg = new RequestMessage(); msg.setKey(key); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceConfigResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceConfigResponseMessageHandler.java index b18a87b29..1334d9ff3 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceConfigResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceConfigResponseMessageHandler.java @@ -9,9 +9,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorP import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -20,10 +19,10 @@ import javax.sip.RequestEvent; import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; +@Slf4j @Component public class DeviceConfigResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(DeviceConfigResponseMessageHandler.class); private final String cmdType = "DeviceConfig"; @Autowired @@ -42,8 +41,8 @@ public class DeviceConfigResponseMessageHandler extends SIPRequestProcessorParen JSONObject json = new JSONObject(); XmlUtil.node2Json(element, json); String channelId = getText(element, "DeviceID"); - if (logger.isDebugEnabled()) { - logger.debug(json.toJSONString()); + if (log.isDebugEnabled()) { + log.debug(json.toJSONString()); } String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONFIG + device.getDeviceId() + channelId; RequestMessage msg = new RequestMessage(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceControlResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceControlResponseMessageHandler.java index af08e13ba..fb6c1aa6f 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceControlResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceControlResponseMessageHandler.java @@ -10,9 +10,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessag import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -21,15 +20,14 @@ import javax.sip.InvalidArgumentException; import javax.sip.RequestEvent; import javax.sip.SipException; import javax.sip.message.Response; - import java.text.ParseException; import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; +@Slf4j @Component public class DeviceControlResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(DeviceControlResponseMessageHandler.class); private final String cmdType = "DeviceControl"; @Autowired @@ -49,13 +47,13 @@ public class DeviceControlResponseMessageHandler extends SIPRequestProcessorPare try { responseAck((SIPRequest) evt.getRequest(), Response.OK); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 设备控制: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 设备控制: {}", e.getMessage()); } JSONObject json = new JSONObject(); String channelId = getText(element, "DeviceID"); XmlUtil.node2Json(element, json); - if (logger.isDebugEnabled()) { - logger.debug(json.toJSONString()); + if (log.isDebugEnabled()) { + log.debug(json.toJSONString()); } RequestMessage msg = new RequestMessage(); String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + device.getDeviceId() + channelId; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java index 849be81f0..6ba5ad2f7 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java @@ -9,10 +9,9 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessag import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; import com.genersoft.iot.vmp.service.IDeviceService; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.DocumentException; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -29,10 +28,10 @@ import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; /** * @author lin */ +@Slf4j @Component public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(DeviceInfoResponseMessageHandler.class); private final String cmdType = "DeviceInfo"; @Autowired @@ -52,10 +51,10 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent @Override public void handForDevice(RequestEvent evt, Device device, Element rootElement) { - logger.debug("接收到DeviceInfo应答消息"); + log.debug("接收到DeviceInfo应答消息"); // 检查设备是否存在, 不存在则不回复 if (device == null || !device.isOnLine()) { - logger.warn("[接收到DeviceInfo应答消息,但是设备已经离线]:" + (device != null ? device.getDeviceId():"" )); + log.warn("[接收到DeviceInfo应答消息,但是设备已经离线]:" + (device != null ? device.getDeviceId():"" )); return; } SIPRequest request = (SIPRequest) evt.getRequest(); @@ -63,11 +62,11 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent rootElement = getRootElement(evt, device.getCharset()); if (rootElement == null) { - logger.warn("[ 接收到DeviceInfo应答消息 ] content cannot be null, {}", evt.getRequest()); + log.warn("[ 接收到DeviceInfo应答消息 ] content cannot be null, {}", evt.getRequest()); try { responseAck((SIPRequest) evt.getRequest(), Response.BAD_REQUEST); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] DeviceInfo应答消息 BAD_REQUEST: {}", e.getMessage()); + log.error("[命令发送失败] DeviceInfo应答消息 BAD_REQUEST: {}", e.getMessage()); } return; } @@ -95,7 +94,7 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent // 回复200 OK responseAck(request, Response.OK); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] DeviceInfo应答消息 200: {}", e.getMessage()); + log.error("[命令发送失败] DeviceInfo应答消息 200: {}", e.getMessage()); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java index da4743f68..44caef923 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java @@ -12,9 +12,8 @@ import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -25,10 +24,10 @@ import javax.sip.SipException; import javax.sip.message.Response; import java.text.ParseException; +@Slf4j @Component public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(DeviceStatusResponseMessageHandler.class); private final String cmdType = "DeviceStatus"; @Autowired @@ -50,7 +49,7 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen @Override public void handForDevice(RequestEvent evt, Device device, Element element) { - logger.info("接收到DeviceStatus应答消息"); + log.info("接收到DeviceStatus应答消息"); // 检查设备是否存在, 不存在则不回复 if (device == null) { return; @@ -59,15 +58,15 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen try { responseAck((SIPRequest) evt.getRequest(), Response.OK); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 设备状态应答回复200OK: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 设备状态应答回复200OK: {}", e.getMessage()); } Element deviceIdElement = element.element("DeviceID"); Element onlineElement = element.element("Online"); String channelId = deviceIdElement.getText(); JSONObject json = new JSONObject(); XmlUtil.node2Json(element, json); - if (logger.isDebugEnabled()) { - logger.debug(json.toJSONString()); + if (log.isDebugEnabled()) { + log.debug(json.toJSONString()); } String text = onlineElement.getText(); if ("ONLINE".equalsIgnoreCase(text.trim())) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java index 5c3d6d66c..f68a5cfcb 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; -import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; @@ -13,14 +12,11 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.respons import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.service.IDeviceChannelService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.DateUtil; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.DocumentException; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -38,24 +34,15 @@ import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; * 移动设备位置数据查询回复 * @author lin */ +@Slf4j @Component public class MobilePositionResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(MobilePositionResponseMessageHandler.class); private final String cmdType = "MobilePosition"; @Autowired private ResponseMessageHandler responseMessageHandler; - @Autowired - private UserSetting userSetting; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - @Autowired private IDeviceChannelService deviceChannelService; @@ -74,11 +61,11 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar try { rootElement = getRootElement(evt, device.getCharset()); if (rootElement == null) { - logger.warn("[ 移动设备位置数据查询回复 ] content cannot be null, {}", evt.getRequest()); + log.warn("[ 移动设备位置数据查询回复 ] content cannot be null, {}", evt.getRequest()); try { responseAck(request, Response.BAD_REQUEST); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 移动设备位置数据查询 BAD_REQUEST: {}", e.getMessage()); + log.error("[命令发送失败] 移动设备位置数据查询 BAD_REQUEST: {}", e.getMessage()); } return; } @@ -117,19 +104,12 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar // 更新device channel 的经纬度 DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setDeviceId(device.getDeviceId()); - deviceChannel.setChannelId(mobilePosition.getChannelId()); + deviceChannel.setGbDeviceDbId(device.getId()); + deviceChannel.setDeviceId(mobilePosition.getChannelId()); deviceChannel.setLongitude(mobilePosition.getLongitude()); deviceChannel.setLatitude(mobilePosition.getLatitude()); deviceChannel.setGpsTime(mobilePosition.getTime()); - deviceChannel = deviceChannelService.updateGps(deviceChannel, device); - - mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84()); - mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84()); - mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02()); - mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02()); - deviceChannelService.updateChannelGPS(device, deviceChannel, mobilePosition); String key = DeferredResultHolder.CALLBACK_CMD_MOBILE_POSITION + device.getDeviceId(); @@ -142,11 +122,11 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar try { responseAck(request, Response.OK); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 移动设备位置数据查询 200: {}", e.getMessage()); + log.error("[命令发送失败] 移动设备位置数据查询 200: {}", e.getMessage()); } } catch (DocumentException e) { - logger.error("未处理的异常 ", e); + log.error("未处理的异常 ", e); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java index 862a8eea2..b9d539a51 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java @@ -1,17 +1,17 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; +import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.PresetQuerySipReq; -import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.DocumentException; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -30,10 +30,10 @@ import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; /** * 设备预置位查询应答 */ +@Slf4j @Component public class PresetQueryResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(PresetQueryResponseMessageHandler.class); private final String cmdType = "PresetQuery"; @Autowired @@ -57,11 +57,11 @@ public class PresetQueryResponseMessageHandler extends SIPRequestProcessorParent Element rootElement = getRootElement(evt, device.getCharset()); if (rootElement == null) { - logger.warn("[ 设备预置位查询应答 ] content cannot be null, {}", evt.getRequest()); + log.warn("[ 设备预置位查询应答 ] content cannot be null, {}", evt.getRequest()); try { responseAck(request, Response.BAD_REQUEST); } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[命令发送失败] 设备预置位查询应答处理: {}", e.getMessage()); + log.error("[命令发送失败] 设备预置位查询应答处理: {}", e.getMessage()); } return; } @@ -74,7 +74,7 @@ public class PresetQueryResponseMessageHandler extends SIPRequestProcessorParent try { responseAck(request, Response.BAD_REQUEST, "xml error"); } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[命令发送失败] 设备预置位查询应答处理: {}", e.getMessage()); + log.error("[命令发送失败] 设备预置位查询应答处理: {}", e.getMessage()); } return; } @@ -105,10 +105,10 @@ public class PresetQueryResponseMessageHandler extends SIPRequestProcessorParent try { responseAck(request, Response.OK); } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[命令发送失败] 设备预置位查询应答处理: {}", e.getMessage()); + log.error("[命令发送失败] 设备预置位查询应答处理: {}", e.getMessage()); } } catch (DocumentException e) { - logger.error("[解析xml]失败: ", e); + log.error("[解析xml]失败: ", e); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java index fc0fda8d6..2ab92b56c 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java @@ -1,7 +1,10 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.gb28181.bean.*; +import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; +import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; +import com.genersoft.iot.vmp.gb28181.bean.RecordItem; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; @@ -11,9 +14,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.respons import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.UJson; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -28,7 +30,6 @@ import javax.sip.SipException; import javax.sip.message.Response; import java.text.ParseException; import java.util.*; -import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -37,14 +38,12 @@ import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; /** * @author lin */ +@Slf4j @Component public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private final Logger logger = LoggerFactory.getLogger(RecordInfoResponseMessageHandler.class); private final String cmdType = "RecordInfo"; - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); - @Autowired private ResponseMessageHandler responseMessageHandler; @@ -74,7 +73,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent // 回复200 OK responseAck((SIPRequest) evt.getRequest(), Response.OK); }catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 国标录像: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 国标录像: {}", e.getMessage()); } taskExecutor.execute(()->{ try { @@ -93,7 +92,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent recordInfo.setSumNum(sumNum); Element recordListElement = rootElement.element("RecordList"); if (recordListElement == null || sumNum == 0) { - logger.info("无录像数据"); + log.info("无录像数据"); recordInfo.setCount(sumNum); eventPublisher.recordEndEventPush(recordInfo); releaseRequest(device.getDeviceId(), sn,recordInfo); @@ -106,7 +105,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent Element itemRecord = recordListIterator.next(); Element recordElement = itemRecord.element("DeviceID"); if (recordElement == null) { - logger.info("记录为空,下一个..."); + log.info("记录为空,下一个..."); continue; } RecordItem record = new RecordItem(); @@ -154,8 +153,8 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent } } } catch (Exception e) { - logger.error("[国标录像] 发现未处理的异常, \r\n{}", evt.getRequest()); - logger.error("[国标录像] 异常内容: ", e); + log.error("[国标录像] 发现未处理的异常, \r\n{}", evt.getRequest()); + log.error("[国标录像] 异常内容: ", e); } }); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/ByeResponseProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/ByeResponseProcessor.java index ff63fad04..17c928df7 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/ByeResponseProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/ByeResponseProcessor.java @@ -1,7 +1,5 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.response.impl; -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.gb28181.SipLayer; import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; import com.genersoft.iot.vmp.gb28181.transmit.event.response.SIPResponseProcessorAbstract; import org.springframework.beans.factory.annotation.Autowired; @@ -19,13 +17,6 @@ public class ByeResponseProcessor extends SIPResponseProcessorAbstract { private final String method = "BYE"; - @Autowired - private SipLayer sipLayer; - - @Autowired - private SipConfig config; - - @Autowired private SIPProcessorObserver sipProcessorObserver; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/CancelResponseProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/CancelResponseProcessor.java index 775beeb6d..a5f80d875 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/CancelResponseProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/CancelResponseProcessor.java @@ -1,7 +1,5 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.response.impl; -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.gb28181.SipLayer; import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; import com.genersoft.iot.vmp.gb28181.transmit.event.response.SIPResponseProcessorAbstract; import org.springframework.beans.factory.annotation.Autowired; @@ -19,12 +17,6 @@ public class CancelResponseProcessor extends SIPResponseProcessorAbstract { private final String method = "CANCEL"; - @Autowired - private SipLayer sipLayer; - - @Autowired - private SipConfig config; - @Autowired private SIPProcessorObserver sipProcessorObserver; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java index d29affcdc..86a62443d 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.response.impl; -import com.genersoft.iot.vmp.gb28181.SipLayer; import com.genersoft.iot.vmp.gb28181.bean.Gb28181Sdp; import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; @@ -9,8 +8,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.response.SIPResponseProcesso import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import gov.nist.javax.sip.ResponseEventExt; import gov.nist.javax.sip.message.SIPResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -19,9 +17,6 @@ import javax.sdp.SessionDescription; import javax.sip.InvalidArgumentException; import javax.sip.ResponseEvent; import javax.sip.SipException; -import javax.sip.InvalidArgumentException; -import javax.sip.ResponseEvent; -import javax.sip.SipException; import javax.sip.SipFactory; import javax.sip.address.SipURI; import javax.sip.message.Request; @@ -34,19 +29,16 @@ import java.text.ParseException; * @author: panlinlin * @date: 2021年11月5日 16:40 */ +@Slf4j @Component public class InviteResponseProcessor extends SIPResponseProcessorAbstract { - private final static Logger logger = LoggerFactory.getLogger(InviteResponseProcessor.class); private final String method = "INVITE"; @Autowired private SIPProcessorObserver sipProcessorObserver; - @Autowired - private SipLayer sipLayer; - @Autowired private SIPSender sipSender; @@ -70,7 +62,7 @@ public class InviteResponseProcessor extends SIPResponseProcessorAbstract { */ @Override public void process(ResponseEvent evt ){ - logger.debug("接收到消息:" + evt.getResponse()); + log.debug("接收到消息:" + evt.getResponse()); try { SIPResponse response = (SIPResponse)evt.getResponse(); int statusCode = response.getStatusCode(); @@ -88,11 +80,11 @@ public class InviteResponseProcessor extends SIPResponseProcessorAbstract { SipURI requestUri = SipFactory.getInstance().createAddressFactory().createSipURI(sdp.getOrigin().getUsername(), event.getRemoteIpAddress() + ":" + event.getRemotePort()); Request reqAck = headerProvider.createAckRequest(response.getLocalAddress().getHostAddress(), requestUri, response); - logger.info("[回复ack] {}-> {}:{} ", sdp.getOrigin().getUsername(), event.getRemoteIpAddress(), event.getRemotePort()); + log.info("[回复ack] {}-> {}:{} ", sdp.getOrigin().getUsername(), event.getRemoteIpAddress(), event.getRemotePort()); sipSender.transmitRequest( response.getLocalAddress().getHostAddress(), reqAck); } } catch (InvalidArgumentException | ParseException | SipException | SdpParseException e) { - logger.info("[点播回复ACK],异常:", e ); + log.info("[点播回复ACK],异常:", e ); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java index edf2c6807..7fa7c1ea4 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java @@ -3,17 +3,14 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.response.impl; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; -import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.response.SIPResponseProcessorAbstract; import com.genersoft.iot.vmp.service.IPlatformService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo; import gov.nist.javax.sip.message.SIPResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -29,27 +26,21 @@ import java.text.ParseException; * @author: swwheihei * @date: 2020年5月3日 下午5:32:23 */ +@Slf4j @Component public class RegisterResponseProcessor extends SIPResponseProcessorAbstract { - private final Logger logger = LoggerFactory.getLogger(RegisterResponseProcessor.class); private final String method = "REGISTER"; @Autowired private ISIPCommanderForPlatform sipCommanderForPlatform; - @Autowired - private IVideoManagerStorage storager; - @Autowired private IRedisCatchStorage redisCatchStorage; @Autowired private SIPProcessorObserver sipProcessorObserver; - @Autowired - private SubscribeHolder subscribeHolder; - @Autowired private IPlatformService platformService; @@ -70,21 +61,21 @@ public class RegisterResponseProcessor extends SIPResponseProcessorAbstract { String callId = response.getCallIdHeader().getCallId(); PlatformRegisterInfo platformRegisterInfo = redisCatchStorage.queryPlatformRegisterInfo(callId); if (platformRegisterInfo == null) { - logger.info(String.format("[国标级联]未找到callId: %s 的注册/注销平台id", callId )); + log.info(String.format("[国标级联]未找到callId: %s 的注册/注销平台id", callId )); return; } ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(platformRegisterInfo.getPlatformId()); if (parentPlatformCatch == null) { - logger.warn(String.format("[国标级联]收到注册/注销%S请求,平台:%s,但是平台缓存信息未查询到!!!", response.getStatusCode(),platformRegisterInfo.getPlatformId())); + log.warn(String.format("[国标级联]收到注册/注销%S请求,平台:%s,但是平台缓存信息未查询到!!!", response.getStatusCode(),platformRegisterInfo.getPlatformId())); return; } String action = platformRegisterInfo.isRegister() ? "注册" : "注销"; - logger.info(String.format("[国标级联]%s %S响应,%s ", action, response.getStatusCode(), platformRegisterInfo.getPlatformId() )); + log.info(String.format("[国标级联]%s %S响应,%s ", action, response.getStatusCode(), platformRegisterInfo.getPlatformId() )); ParentPlatform parentPlatform = parentPlatformCatch.getParentPlatform(); if (parentPlatform == null) { - logger.warn(String.format("[国标级联]收到 %s %s的%S请求, 但是平台信息未查询到!!!", platformRegisterInfo.getPlatformId(), action, response.getStatusCode())); + log.warn(String.format("[国标级联]收到 %s %s的%S请求, 但是平台信息未查询到!!!", platformRegisterInfo.getPlatformId(), action, response.getStatusCode())); return; } @@ -94,7 +85,7 @@ public class RegisterResponseProcessor extends SIPResponseProcessorAbstract { try { sipCommanderForPlatform.register(parentPlatform, sipTransactionInfo, www, null, null, platformRegisterInfo.isRegister()); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 再次注册: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 再次注册: {}", e.getMessage()); } }else if (response.getStatusCode() == Response.OK){ diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/timeout/impl/TimeoutProcessorImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/timeout/impl/TimeoutProcessorImpl.java index 531505d28..f1e5352fe 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/timeout/impl/TimeoutProcessorImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/timeout/impl/TimeoutProcessorImpl.java @@ -1,11 +1,9 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.timeout.impl; -import com.genersoft.iot.vmp.conf.SystemInfoTimerTask; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; import com.genersoft.iot.vmp.gb28181.transmit.event.timeout.ITimeoutProcessor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -13,11 +11,10 @@ import org.springframework.stereotype.Component; import javax.sip.TimeoutEvent; import javax.sip.header.CallIdHeader; +@Slf4j @Component public class TimeoutProcessorImpl implements InitializingBean, ITimeoutProcessor { - private Logger logger = LoggerFactory.getLogger(TimeoutProcessorImpl.class); - @Autowired private SIPProcessorObserver processorObserver; @@ -41,7 +38,7 @@ public class TimeoutProcessorImpl implements InitializingBean, ITimeoutProcessor sipSubscribe.removeErrorSubscribe(callId); sipSubscribe.removeOkSubscribe(callId); } catch (Exception e) { - logger.error("[超时事件失败]: {}", e.getMessage()); + log.error("[超时事件失败]: {}", e.getMessage()); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java index d990db93e..f2b84b2c5 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java @@ -1,17 +1,11 @@ package com.genersoft.iot.vmp.gb28181.utils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * 数值格式判断和处理 * @author lawrencehj * @date 2021年1月27日 */ public class NumericUtil { - - private static Logger logger = LoggerFactory.getLogger(NumericUtil.class); - /** * 判断是否Double格式 * @param str diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java index c64605883..70c8fa722 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.gb28181.utils; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.Gb28181Sdp; import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo; import com.genersoft.iot.vmp.utils.DateUtil; @@ -9,9 +8,8 @@ import gov.nist.javax.sip.address.AddressImpl; import gov.nist.javax.sip.address.SipUri; import gov.nist.javax.sip.header.Subject; import gov.nist.javax.sip.message.SIPRequest; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.RandomStringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.util.ObjectUtils; import javax.sdp.SdpFactory; @@ -36,10 +34,9 @@ import java.util.UUID; * @description JAIN SIP的工具类 * @createTime 2021年09月27日 15:12:00 */ +@Slf4j public class SipUtils { - private final static Logger logger = LoggerFactory.getLogger(SipUtils.class); - public static String getUserIdFromFromHeader(Request request) { FromHeader fromHeader = (FromHeader)request.getHeader(FromHeader.NAME); return getUserIdFromFromHeader(fromHeader); @@ -189,39 +186,6 @@ public class SipUtils { return new RemoteAddressInfo(remoteAddress, remotePort); } - public static DeviceChannel updateGps(DeviceChannel deviceChannel, String geoCoordSys) { - if (deviceChannel.getLongitude()*deviceChannel.getLatitude() > 0) { - - if (geoCoordSys == null) { - geoCoordSys = "WGS84"; - } - if ("WGS84".equals(geoCoordSys)) { - 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(geoCoordSys)) { - deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude()); - deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude()); - Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude()); - deviceChannel.setLongitudeWgs84(position[0]); - deviceChannel.setLatitudeWgs84(position[1]); - }else { - deviceChannel.setLongitudeGcj02(0.00); - deviceChannel.setLatitudeGcj02(0.00); - deviceChannel.setLongitudeWgs84(0.00); - deviceChannel.setLatitudeWgs84(0.00); - } - }else { - deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude()); - deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude()); - deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude()); - deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude()); - } - return deviceChannel; - } - public static Gb28181Sdp parseSDP(String sdpStr) throws SdpParseException { // jainSip不支持y= f=字段, 移除以解析。 @@ -277,7 +241,7 @@ public class SipUtils { try { localDateTime = LocalDateTime.parse(timeStr, DateUtil.formatterISO8601); }catch (DateTimeParseException e2) { - logger.error("[格式化时间] 无法格式化时间: {}", timeStr); + log.error("[格式化时间] 无法格式化时间: {}", timeStr); return null; } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java index 46e924803..bdfa73021 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java @@ -2,14 +2,13 @@ package com.genersoft.iot.vmp.gb28181.utils; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.math.NumberUtils; import org.dom4j.Attribute; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; @@ -25,21 +24,12 @@ import java.util.*; /** * 基于dom4j的工具包 - * - * */ +@Slf4j public class XmlUtil { - /** - * 日志服务 - */ - private static Logger logger = LoggerFactory.getLogger(XmlUtil.class); /** * 解析XML为Document对象 - * - * @param xml 被解析的XMl - * - * @return Document */ public static Element parseXml(String xml) { Document document = null; @@ -49,7 +39,7 @@ public class XmlUtil { try { document = saxReader.read(sr); } catch (DocumentException e) { - logger.error("解析失败", e); + log.error("解析失败", e); } return null == document ? null : document.getRootElement(); } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/codec/decode/Jt808Decoder.java b/src/main/java/com/genersoft/iot/vmp/jt1078/codec/decode/Jt808Decoder.java index 4817c665f..f35f86736 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/codec/decode/Jt808Decoder.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/codec/decode/Jt808Decoder.java @@ -23,7 +23,7 @@ import java.util.List; * @email qingtaij@163.com */ public class Jt808Decoder extends ByteToMessageDecoder { - private final static Logger log = LoggerFactory.getLogger(Jt808Decoder.class); + private final static Logger logger = LoggerFactory.getLogger(Jt808Decoder.class); @Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/codec/encode/Jt808Encoder.java b/src/main/java/com/genersoft/iot/vmp/jt1078/codec/encode/Jt808Encoder.java index afb1a7973..252688808 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/codec/encode/Jt808Encoder.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/codec/encode/Jt808Encoder.java @@ -16,7 +16,7 @@ import org.slf4j.LoggerFactory; * @email qingtaij@163.com */ public class Jt808Encoder extends MessageToByteEncoder { - private final static Logger log = LoggerFactory.getLogger(Jt808Encoder.class); + private final static Logger logger = LoggerFactory.getLogger(Jt808Encoder.class); @Override protected void encode(ChannelHandlerContext ctx, Rs msg, ByteBuf out) throws Exception { diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/codec/encode/Jt808EncoderCmd.java b/src/main/java/com/genersoft/iot/vmp/jt1078/codec/encode/Jt808EncoderCmd.java index 0e9e11f6f..8508f4bd0 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/codec/encode/Jt808EncoderCmd.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/codec/encode/Jt808EncoderCmd.java @@ -25,7 +25,7 @@ import java.util.LinkedList; * @email qingtaij@163.com */ public class Jt808EncoderCmd extends MessageToByteEncoder { - private final static Logger log = LoggerFactory.getLogger(Jt808EncoderCmd.class); + private final static Logger logger = LoggerFactory.getLogger(Jt808EncoderCmd.class); @Override protected void encode(ChannelHandlerContext ctx, Cmd cmd, ByteBuf out) throws Exception { diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/codec/netty/Jt808Handler.java b/src/main/java/com/genersoft/iot/vmp/jt1078/codec/netty/Jt808Handler.java index fd5030272..f1a603d68 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/codec/netty/Jt808Handler.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/codec/netty/Jt808Handler.java @@ -18,7 +18,7 @@ import org.slf4j.LoggerFactory; */ public class Jt808Handler extends ChannelInboundHandlerAdapter { - private final static Logger log = LoggerFactory.getLogger(Jt808Handler.class); + private final static Logger logger = LoggerFactory.getLogger(Jt808Handler.class); @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/codec/netty/TcpServer.java b/src/main/java/com/genersoft/iot/vmp/jt1078/codec/netty/TcpServer.java index a7e4df826..efbbe5060 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/codec/netty/TcpServer.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/codec/netty/TcpServer.java @@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit; */ public class TcpServer { - private final static Logger log = LoggerFactory.getLogger(TcpServer.class); + private final static Logger logger = LoggerFactory.getLogger(TcpServer.class); private final Integer port; private boolean isRunning = false; diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/factory/CodecFactory.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/factory/CodecFactory.java index 45d5fc71f..3f8fecfd5 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/factory/CodecFactory.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/factory/CodecFactory.java @@ -17,7 +17,7 @@ import java.util.Map; */ public class CodecFactory { - private final static Logger log = LoggerFactory.getLogger(CodecFactory.class); + private final static Logger logger = LoggerFactory.getLogger(CodecFactory.class); private static Map> protocolHash; diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/Re.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/Re.java index 0a24ad274..28c8e7211 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/Re.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/Re.java @@ -14,7 +14,7 @@ import org.springframework.util.StringUtils; * @email qingtaij@163.com */ public abstract class Re { - private final static Logger log = LoggerFactory.getLogger(Re.class); + private final static Logger logger = LoggerFactory.getLogger(Re.class); protected abstract Rs decode0(ByteBuf buf, Header header, Session session); diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/session/Session.java b/src/main/java/com/genersoft/iot/vmp/jt1078/session/Session.java index f7df8de0d..8cdfef745 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/session/Session.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/session/Session.java @@ -14,7 +14,7 @@ import java.util.concurrent.atomic.AtomicInteger; * @email qingtaij@163.com */ public class Session { - private final static Logger log = LoggerFactory.getLogger(Session.class); + private final static Logger logger = LoggerFactory.getLogger(Session.class); public static final AttributeKey KEY = AttributeKey.newInstance(Session.class.getName()); diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/session/SessionManager.java b/src/main/java/com/genersoft/iot/vmp/jt1078/session/SessionManager.java index c2876e561..970328cb2 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/session/SessionManager.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/session/SessionManager.java @@ -18,7 +18,7 @@ import java.util.concurrent.TimeUnit; */ public enum SessionManager { INSTANCE; - private final static Logger log = LoggerFactory.getLogger(SessionManager.class); + private final static Logger logger = LoggerFactory.getLogger(SessionManager.class); // 用与消息的缓存 private final Map> topicSubscribers = new ConcurrentHashMap<>(); diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/SendRtpPortManager.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/SendRtpPortManager.java index f799a9301..74ad7af18 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/SendRtpPortManager.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/SendRtpPortManager.java @@ -5,9 +5,8 @@ import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.utils.redis.RedisUtil; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.math.NumberUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.support.atomic.RedisAtomicInteger; @@ -17,11 +16,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +@Slf4j @Component public class SendRtpPortManager { - private final static Logger logger = LoggerFactory.getLogger(SendRtpPortManager.class); - @Autowired private UserSetting userSetting; @@ -32,7 +30,7 @@ public class SendRtpPortManager { public synchronized int getNextPort(MediaServer mediaServer) { if (mediaServer == null) { - logger.warn("[发送端口管理] 参数错误,mediaServer为NULL"); + log.warn("[发送端口管理] 参数错误,mediaServer为NULL"); return -1; } String sendIndexKey = KEY + userSetting.getServerId() + "_" + mediaServer.getId(); @@ -53,12 +51,12 @@ public class SendRtpPortManager { if (sendRtpPortRange != null) { String[] portArray = sendRtpPortRange.split(","); if (portArray.length != 2 || !NumberUtils.isParsable(portArray[0]) || !NumberUtils.isParsable(portArray[1])) { - logger.warn("{}发送端口配置格式错误,自动使用50000-60000作为端口范围", mediaServer.getId()); + log.warn("{}发送端口配置格式错误,自动使用50000-60000作为端口范围", mediaServer.getId()); startPort = 50000; endPort = 60000; }else { if ( Integer.parseInt(portArray[1]) - Integer.parseInt(portArray[0]) < 1) { - logger.warn("{}发送端口配置错误,结束端口至少比开始端口大一,自动使用50000-60000作为端口范围", mediaServer.getId()); + log.warn("{}发送端口配置错误,结束端口至少比开始端口大一,自动使用50000-60000作为端口范围", mediaServer.getId()); startPort = 50000; endPort = 60000; }else { @@ -67,12 +65,12 @@ public class SendRtpPortManager { } } }else { - logger.warn("{}未设置发送端口默认值,自动使用50000-60000作为端口范围", mediaServer.getId()); + log.warn("{}未设置发送端口默认值,自动使用50000-60000作为端口范围", mediaServer.getId()); startPort = 50000; endPort = 60000; } if (redisTemplate == null || redisTemplate.getConnectionFactory() == null) { - logger.warn("{}获取redis连接信息失败", mediaServer.getId()); + log.warn("{}获取redis连接信息失败", mediaServer.getId()); return -1; } // RedisAtomicInteger redisAtomicInteger = new RedisAtomicInteger(sendIndexKey , redisTemplate.getConnectionFactory()); diff --git a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java index 3ea8e5fc7..366f053ba 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java @@ -108,4 +108,8 @@ public interface IDeviceChannelService { void offline(DeviceChannel channel); void delete(DeviceChannel channel); + + void cleanChannelsForDevice(String deviceId); + + boolean resetChannels(String deviceId, List deviceChannels); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java index 75cfb1251..921b65fda 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java @@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; +import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IInviteStreamService; @@ -23,12 +24,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import org.springframework.util.ObjectUtils; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; /** @@ -426,4 +428,147 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { // } deviceMobilePositionMapper.batchadd(mobilePositions); } + + @Override + public void cleanChannelsForDevice(String deviceId) { + channelMapper.cleanChannelsByDeviceId(deviceId); + } + + @Override + public boolean resetChannels(String deviceId, List deviceChannelList) { + if (CollectionUtils.isEmpty(deviceChannelList)) { + return false; + } + List allChannels = channelMapper.queryAllChannels(deviceId); + Map allChannelMap = new ConcurrentHashMap<>(); + if (allChannels.size() > 0) { + for (DeviceChannel deviceChannel : allChannels) { + allChannelMap.put(deviceChannel.getChannelId(), deviceChannel); + } + } + TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); + // 数据去重 + List channels = new ArrayList<>(); + + List updateChannels = new ArrayList<>(); + List addChannels = new ArrayList<>(); + List deleteChannels = new ArrayList<>(); + StringBuilder stringBuilder = new StringBuilder(); + Map subContMap = new HashMap<>(); + + // 数据去重 + Set gbIdSet = new HashSet<>(); + for (DeviceChannel deviceChannel : deviceChannelList) { + if (gbIdSet.contains(deviceChannel.getChannelId())) { + stringBuilder.append(deviceChannel.getChannelId()).append(","); + continue; + } + gbIdSet.add(deviceChannel.getChannelId()); + if (allChannelMap.containsKey(deviceChannel.getChannelId())) { + deviceChannel.setStreamId(allChannelMap.get(deviceChannel.getChannelId()).getStreamId()); + deviceChannel.setHasAudio(allChannelMap.get(deviceChannel.getChannelId()).getHasAudio()); + if (allChannelMap.get(deviceChannel.getChannelId()).isStatus() !=deviceChannel.isStatus()){ + List strings = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getChannelId()); + if (!CollectionUtils.isEmpty(strings)){ + strings.forEach(platformId->{ + eventPublisher.catalogEventPublish(platformId, deviceChannel, deviceChannel.isStatus()? CatalogEvent.ON:CatalogEvent.OFF); + }); + } + + } + deviceChannel.setUpdateTime(DateUtil.getNow()); + updateChannels.add(deviceChannel); + }else { + deviceChannel.setCreateTime(DateUtil.getNow()); + deviceChannel.setUpdateTime(DateUtil.getNow()); + addChannels.add(deviceChannel); + } + allChannelMap.remove(deviceChannel.getChannelId()); + channels.add(deviceChannel); + if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) { + if (subContMap.get(deviceChannel.getParentId()) == null) { + subContMap.put(deviceChannel.getParentId(), 1); + }else { + Integer count = subContMap.get(deviceChannel.getParentId()); + subContMap.put(deviceChannel.getParentId(), count++); + } + } + } + deleteChannels.addAll(allChannelMap.values()); + if (!channels.isEmpty()) { + for (DeviceChannel channel : channels) { + if (subContMap.get(channel.getChannelId()) != null){ + Integer count = subContMap.get(channel.getChannelId()); + if (count > 0) { + channel.setSubCount(count); + channel.setParental(1); + } + } + } + } + + if (stringBuilder.length() > 0) { + logger.info("[目录查询]收到的数据存在重复: {}" , stringBuilder); + } + if(CollectionUtils.isEmpty(channels)){ + logger.info("通道重设,数据为空={}" , deviceChannelList); + return false; + } + try { + int limitCount = 50; + boolean result = false; + if (!result && !addChannels.isEmpty()) { + if (addChannels.size() > limitCount) { + for (int i = 0; i < addChannels.size(); i += limitCount) { + int toIndex = i + limitCount; + if (i + limitCount > addChannels.size()) { + toIndex = addChannels.size(); + } + result = result || channelMapper.batchAdd(addChannels.subList(i, toIndex)) < 0; + } + }else { + result = result || channelMapper.batchAdd(addChannels) < 0; + } + } + if (!result && !updateChannels.isEmpty()) { + if (updateChannels.size() > limitCount) { + for (int i = 0; i < updateChannels.size(); i += limitCount) { + int toIndex = i + limitCount; + if (i + limitCount > updateChannels.size()) { + toIndex = updateChannels.size(); + } + result = result || channelMapper.batchUpdate(updateChannels.subList(i, toIndex)) < 0; + } + }else { + result = result || channelMapper.batchUpdate(updateChannels) < 0; + } + } + if (!result && !deleteChannels.isEmpty()) { + System.out.println("删除: " + deleteChannels.size()); + if (deleteChannels.size() > limitCount) { + for (int i = 0; i < deleteChannels.size(); i += limitCount) { + int toIndex = i + limitCount; + if (i + limitCount > deleteChannels.size()) { + toIndex = deleteChannels.size(); + } + result = result || channelMapper.batchDel(deleteChannels.subList(i, toIndex)) < 0; + } + }else { + result = result || channelMapper.batchDel(deleteChannels) < 0; + } + } + + if (result) { + //事务回滚 + dataSourceTransactionManager.rollback(transactionStatus); + } + dataSourceTransactionManager.commit(transactionStatus); //手动提交 + return true; + }catch (Exception e) { + logger.error("未处理的异常 ", e); + dataSourceTransactionManager.rollback(transactionStatus); + return false; + } + + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java index 35028dff4..c10e4b1d9 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java @@ -124,8 +124,8 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { return allCount; } - private List getDeviceChannelListByChannelReduceList(List channelReduces, String catalogId, ParentPlatform platform) { - List deviceChannelList = new ArrayList<>(); + private List getDeviceChannelListByChannelReduceList(List channelReduces, String catalogId, ParentPlatform platform) { + List deviceChannelList = new ArrayList<>(); if (channelReduces.size() > 0){ PlatformCatalog catalog = catalogManager.selectByPlatFormAndCatalogId(platform.getServerGBId(),catalogId); if (catalog == null && catalogId.equals(platform.getDeviceGBId())) { diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java index 194e90fb9..e1a67f347 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java @@ -2,13 +2,15 @@ package com.genersoft.iot.vmp.service.redisMsg; import com.alibaba.fastjson2.JSON; import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.*; +import com.genersoft.iot.vmp.gb28181.bean.AlarmChannelMessage; +import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; +import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.DateUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.redis.connection.Message; @@ -24,12 +26,10 @@ import java.text.ParseException; import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; - +@Slf4j @Component public class RedisAlarmMsgListener implements MessageListener { - private final static Logger logger = LoggerFactory.getLogger(RedisAlarmMsgListener.class); - @Autowired private ISIPCommander commander; @@ -51,7 +51,7 @@ public class RedisAlarmMsgListener implements MessageListener { @Override public void onMessage(@NotNull Message message, byte[] bytes) { // 消息示例: PUBLISH alarm_receive '{ "gbId": "", "alarmSn": 1, "alarmType": "111", "alarmDescription": "222", }' - logger.info("收到来自REDIS的ALARM通知: {}", new String(message.getBody())); + log.info("收到来自REDIS的ALARM通知: {}", new String(message.getBody())); boolean isEmpty = taskQueue.isEmpty(); taskQueue.offer(message); if (isEmpty) { @@ -62,7 +62,7 @@ public class RedisAlarmMsgListener implements MessageListener { try { AlarmChannelMessage alarmChannelMessage = JSON.parseObject(msg.getBody(), AlarmChannelMessage.class); if (alarmChannelMessage == null) { - logger.warn("[REDIS的ALARM通知]消息解析失败"); + log.warn("[REDIS的ALARM通知]消息解析失败"); continue; } String gbId = alarmChannelMessage.getGbId(); @@ -88,7 +88,7 @@ public class RedisAlarmMsgListener implements MessageListener { deviceAlarm.setChannelId(parentPlatform.getDeviceGBId()); commanderForPlatform.sendAlarmMessage(parentPlatform, deviceAlarm); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 发送报警: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 发送报警: {}", e.getMessage()); } } } @@ -101,7 +101,7 @@ public class RedisAlarmMsgListener implements MessageListener { deviceAlarm.setChannelId(parentPlatform.getDeviceGBId()); commanderForPlatform.sendAlarmMessage(parentPlatform, deviceAlarm); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 发送报警: {}", e.getMessage()); + log.error("[命令发送失败] 国标级联 发送报警: {}", e.getMessage()); } } } @@ -115,7 +115,7 @@ public class RedisAlarmMsgListener implements MessageListener { deviceAlarm.setChannelId(device.getDeviceId()); commander.sendAlarmMessage(device, deviceAlarm); } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 发送报警: {}", e.getMessage()); + log.error("[命令发送失败] 发送报警: {}", e.getMessage()); } } } @@ -127,21 +127,21 @@ public class RedisAlarmMsgListener implements MessageListener { try { commander.sendAlarmMessage(device, deviceAlarm); } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 发送报警: {}", e.getMessage()); + log.error("[命令发送失败] 发送报警: {}", e.getMessage()); } }else if (device == null && platform != null){ try { commanderForPlatform.sendAlarmMessage(platform, deviceAlarm); } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 发送报警: {}", e.getMessage()); + log.error("[命令发送失败] 发送报警: {}", e.getMessage()); } }else { - logger.warn("无法确定" + gbId + "是平台还是设备"); + log.warn("无法确定" + gbId + "是平台还是设备"); } } }catch (Exception e) { - logger.error("未处理的异常 ", e); - logger.warn("[REDIS的ALARM通知] 发现未处理的异常, {}",e.getMessage()); + log.error("未处理的异常 ", e); + log.warn("[REDIS的ALARM通知] 发现未处理的异常, {}",e.getMessage()); } } }); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java index cea39b4c0..5564b12b6 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java @@ -4,9 +4,8 @@ import com.alibaba.fastjson2.JSON; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.redis.connection.Message; @@ -22,11 +21,10 @@ import java.util.concurrent.ConcurrentLinkedQueue; * 接收来自redis的GPS更新通知 * @author lin */ +@Slf4j @Component public class RedisGpsMsgListener implements MessageListener { - private final static Logger logger = LoggerFactory.getLogger(RedisGpsMsgListener.class); - @Autowired private IRedisCatchStorage redisCatchStorage; @@ -50,12 +48,12 @@ public class RedisGpsMsgListener implements MessageListener { Message msg = taskQueue.poll(); try { GPSMsgInfo gpsMsgInfo = JSON.parseObject(msg.getBody(), GPSMsgInfo.class); - logger.info("[REDIS的位置变化通知], {}", JSON.toJSONString(gpsMsgInfo)); + log.info("[REDIS的位置变化通知], {}", JSON.toJSONString(gpsMsgInfo)); // 只是放入redis缓存起来 redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo); }catch (Exception e) { - logger.warn("[REDIS的位置变化通知] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); - logger.error("[REDIS的位置变化通知] 异常内容: ", e); + log.warn("[REDIS的位置变化通知] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); + log.error("[REDIS的位置变化通知] 异常内容: ", e); } } }); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamResponseListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamResponseListener.java index c90771be8..dc18f0d84 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamResponseListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamResponseListener.java @@ -2,8 +2,7 @@ package com.genersoft.iot.vmp.service.redisMsg; import com.alibaba.fastjson2.JSON; import com.genersoft.iot.vmp.service.bean.MessageForPushChannelResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.redis.connection.Message; @@ -20,11 +19,10 @@ import java.util.concurrent.ConcurrentLinkedQueue; * 接收redis返回的推流结果 * @author lin */ +@Slf4j @Component public class RedisPushStreamResponseListener implements MessageListener { - private final static Logger logger = LoggerFactory.getLogger(RedisPushStreamResponseListener.class); - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); @Qualifier("taskExecutor") @@ -40,7 +38,7 @@ public class RedisPushStreamResponseListener implements MessageListener { @Override public void onMessage(Message message, byte[] bytes) { - logger.info("[REDIS消息-请求推流结果]: {}", new String(message.getBody())); + log.info("[REDIS消息-请求推流结果]: {}", new String(message.getBody())); boolean isEmpty = taskQueue.isEmpty(); taskQueue.offer(message); if (isEmpty) { @@ -50,7 +48,7 @@ public class RedisPushStreamResponseListener implements MessageListener { try { MessageForPushChannelResponse response = JSON.parseObject(new String(msg.getBody()), MessageForPushChannelResponse.class); if (response == null || ObjectUtils.isEmpty(response.getApp()) || ObjectUtils.isEmpty(response.getStream())){ - logger.info("[REDIS消息-请求推流结果]:参数不全"); + log.info("[REDIS消息-请求推流结果]:参数不全"); continue; } // 查看正在等待的invite消息 @@ -58,8 +56,8 @@ public class RedisPushStreamResponseListener implements MessageListener { responseEvents.get(response.getApp() + response.getStream()).run(response); } }catch (Exception e) { - logger.warn("[REDIS消息-请求推流结果] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); - logger.error("[REDIS消息-请求推流结果] 异常内容: ", e); + log.warn("[REDIS消息-请求推流结果] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); + log.error("[REDIS消息-请求推流结果] 异常内容: ", e); } } }); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java index 6b92fc4bc..65594af93 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java @@ -3,12 +3,11 @@ package com.genersoft.iot.vmp.service.redisMsg; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.media.service.IMediaServerService; -import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import com.genersoft.iot.vmp.service.IGbStreamService; +import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import com.genersoft.iot.vmp.streamPush.service.IStreamPushService; import com.genersoft.iot.vmp.utils.DateUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.redis.connection.Message; @@ -27,10 +26,10 @@ import java.util.concurrent.ConcurrentLinkedQueue; * @Date: 2022/8/16 11:32 * @Description: 接收redis发送的推流设备列表更新通知 */ +@Slf4j @Component public class RedisPushStreamStatusListMsgListener implements MessageListener { - private final static Logger logger = LoggerFactory.getLogger(RedisPushStreamStatusListMsgListener.class); @Resource private IMediaServerService mediaServerService; @@ -48,7 +47,7 @@ public class RedisPushStreamStatusListMsgListener implements MessageListener { @Override public void onMessage(Message message, byte[] bytes) { - logger.info("[REDIS消息-推流设备列表更新]: {}", new String(message.getBody())); + log.info("[REDIS消息-推流设备列表更新]: {}", new String(message.getBody())); boolean isEmpty = taskQueue.isEmpty(); taskQueue.offer(message); if (isEmpty) { @@ -74,7 +73,7 @@ public class RedisPushStreamStatusListMsgListener implements MessageListener { if (!contains) { if (allGBId.containsKey(streamPush.getGbDeviceId())) { StreamPush streamPushInDb = allGBId.get(streamPush.getGbDeviceId()); - logger.warn("[REDIS消息-推流设备列表更新-INSERT] 国标编号重复: {}, 已分配给{}/{}", + log.warn("[REDIS消息-推流设备列表更新-INSERT] 国标编号重复: {}, 已分配给{}/{}", streamPushInDb.getGbDeviceId(), streamPushInDb.getApp(), streamPushInDb.getStream()); continue; } @@ -87,7 +86,7 @@ public class RedisPushStreamStatusListMsgListener implements MessageListener { && (!allGBId.get(streamPush.getGbDeviceId()).getApp().equals(streamPush.getApp()) || !allGBId.get(streamPush.getGbDeviceId()).getStream().equals(streamPush.getStream()))) { StreamPush streamPushInDb = allGBId.get(streamPush.getGbDeviceId()); - logger.warn("[REDIS消息-推流设备列表更新-UPDATE] 国标编号重复: {}, 已分配给{}/{}", + log.warn("[REDIS消息-推流设备列表更新-UPDATE] 国标编号重复: {}, 已分配给{}/{}", streamPush.getGbDeviceId(), streamPushInDb.getApp(), streamPushInDb.getStream()); continue; } @@ -96,19 +95,19 @@ public class RedisPushStreamStatusListMsgListener implements MessageListener { } } if (!streamPushItemForSave.isEmpty()) { - logger.info("添加{}条",streamPushItemForSave.size()); - logger.info(JSONObject.toJSONString(streamPushItemForSave)); + log.info("添加{}条",streamPushItemForSave.size()); + log.info(JSONObject.toJSONString(streamPushItemForSave)); streamPushService.batchAdd(streamPushItemForSave); } if(!streamPushItemForUpdate.isEmpty()){ - logger.info("修改{}条",streamPushItemForUpdate.size()); - logger.info(JSONObject.toJSONString(streamPushItemForUpdate)); + log.info("修改{}条",streamPushItemForUpdate.size()); + log.info(JSONObject.toJSONString(streamPushItemForUpdate)); gbStreamService.updateGbIdOrName(streamPushItemForUpdate); } }catch (Exception e) { - logger.warn("[REDIS消息-推流设备列表更新] 发现未处理的异常, \r\n{}", new String(message.getBody())); - logger.error("[REDIS消息-推流设备列表更新] 异常内容: ", e); + log.warn("[REDIS消息-推流设备列表更新] 发现未处理的异常, \r\n{}", new String(message.getBody())); + log.error("[REDIS消息-推流设备列表更新] 异常内容: ", e); } } }); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java index 2d3aa8b0a..f95bc9ffa 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java @@ -4,11 +4,10 @@ import com.alibaba.fastjson2.JSON; import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.streamPush.service.IStreamPushService; import com.genersoft.iot.vmp.service.bean.PushStreamStatusChangeFromRedisDto; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.genersoft.iot.vmp.streamPush.service.IStreamPushService; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.ApplicationArguments; @@ -25,11 +24,10 @@ import java.util.concurrent.ConcurrentLinkedQueue; * 接收redis发送的推流设备上线下线通知 * @author lin */ +@Slf4j @Component public class RedisPushStreamStatusMsgListener implements MessageListener, ApplicationRunner { - private final static Logger logger = LoggerFactory.getLogger(RedisPushStreamStatusMsgListener.class); - @Autowired private IRedisCatchStorage redisCatchStorage; @@ -53,7 +51,7 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic @Override public void onMessage(Message message, byte[] bytes) { boolean isEmpty = taskQueue.isEmpty(); - logger.warn("[REDIS消息-推流设备状态变化]: {}", new String(message.getBody())); + log.warn("[REDIS消息-推流设备状态变化]: {}", new String(message.getBody())); taskQueue.offer(message); if (isEmpty) { @@ -63,7 +61,7 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic try { PushStreamStatusChangeFromRedisDto statusChangeFromPushStream = JSON.parseObject(msg.getBody(), PushStreamStatusChangeFromRedisDto.class); if (statusChangeFromPushStream == null) { - logger.warn("[REDIS消息]推流设备状态变化消息解析失败"); + log.warn("[REDIS消息]推流设备状态变化消息解析失败"); continue; } // 取消定时任务 @@ -83,8 +81,8 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic streamPushService.online(statusChangeFromPushStream.getOnlineStreams()); } }catch (Exception e) { - logger.warn("[REDIS消息-推流设备状态变化] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); - logger.error("[REDIS消息-推流设备状态变化] 异常内容: ", e); + log.warn("[REDIS消息-推流设备状态变化] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); + log.error("[REDIS消息-推流设备状态变化] 异常内容: ", e); } } }); @@ -97,7 +95,7 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic // 启动时设置所有推流通道离线,发起查询请求 redisCatchStorage.sendStreamPushRequestedMsgForStatus(); dynamicTask.startDelay(VideoManagerConstants.VM_MSG_GET_ALL_ONLINE_REQUESTED, ()->{ - logger.info("[REDIS消息]未收到redis回复推流设备状态,执行推流设备离线"); + log.info("[REDIS消息]未收到redis回复推流设备状态,执行推流设备离线"); // 五秒收不到请求就设置通道离线,然后通知上级离线 streamPushService.allOffline(); }, 5000); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcController.java index adb23186e..3ba96e371 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcController.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcController.java @@ -22,8 +22,7 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; @@ -35,11 +34,10 @@ import java.text.ParseException; /** * 其他wvp发起的rpc调用,这里的方法被 RedisRpcConfig 通过反射寻找对应的方法名称调用 */ +@Slf4j @Component public class RedisRpcController { - private final static Logger logger = LoggerFactory.getLogger(RedisRpcController.class); - @Autowired private SSRCFactory ssrcFactory; @@ -77,12 +75,12 @@ public class RedisRpcController { String sendRtpItemKey = request.getParam().toString(); SendRtpItem sendRtpItem = (SendRtpItem) redisTemplate.opsForValue().get(sendRtpItemKey); if (sendRtpItem == null) { - logger.info("[redis-rpc] 获取发流的信息, 未找到redis中的发流信息, key:{}", sendRtpItemKey); + log.info("[redis-rpc] 获取发流的信息, 未找到redis中的发流信息, key:{}", sendRtpItemKey); RedisRpcResponse response = request.getResponse(); response.setStatusCode(200); return response; } - logger.info("[redis-rpc] 获取发流的信息: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); + log.info("[redis-rpc] 获取发流的信息: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); // 查询本级是否有这个流 MediaServer mediaServerItem = mediaServerService.getMediaServerByAppAndStream(sendRtpItem.getApp(), sendRtpItem.getStream()); if (mediaServerItem == null) { @@ -92,7 +90,7 @@ public class RedisRpcController { // 自平台内容 int localPort = sendRtpPortManager.getNextPort(mediaServerItem); if (localPort == 0) { - logger.info("[redis-rpc] getSendRtpItem->服务器端口资源不足" ); + log.info("[redis-rpc] getSendRtpItem->服务器端口资源不足" ); RedisRpcResponse response = request.getResponse(); response.setStatusCode(200); } @@ -118,11 +116,11 @@ public class RedisRpcController { */ public RedisRpcResponse waitePushStreamOnline(RedisRpcRequest request) { SendRtpItem sendRtpItem = JSONObject.parseObject(request.getParam().toString(), SendRtpItem.class); - logger.info("[redis-rpc] 监听流上线: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); + log.info("[redis-rpc] 监听流上线: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); // 查询本级是否有这个流 MediaServer mediaServer = mediaServerService.getMediaServerByAppAndStream(sendRtpItem.getApp(), sendRtpItem.getStream()); if (mediaServer != null) { - logger.info("[redis-rpc] 监听流上线时发现流已存在直接返回: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() ); + log.info("[redis-rpc] 监听流上线时发现流已存在直接返回: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() ); // 读取redis中的上级点播信息,生成sendRtpItm发送出去 if (sendRtpItem.getSsrc() == null) { // 上级平台点播时不使用上级平台指定的ssrc,使用自定义的ssrc,参考国标文档-点播外域设备媒体流SSRC处理方式 @@ -141,7 +139,7 @@ public class RedisRpcController { // 监听流上线。 流上线直接发送sendRtpItem消息给实际的信令处理者 Hook hook = Hook.getInstance(HookType.on_media_arrival, sendRtpItem.getApp(), sendRtpItem.getStream(), null); hookSubscribe.addSubscribe(hook, (hookData) -> { - logger.info("[redis-rpc] 监听流上线,流已上线: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); + log.info("[redis-rpc] 监听流上线,流已上线: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); // 读取redis中的上级点播信息,生成sendRtpItm发送出去 if (sendRtpItem.getSsrc() == null) { // 上级平台点播时不使用上级平台指定的ssrc,使用自定义的ssrc,参考国标文档-点播外域设备媒体流SSRC处理方式 @@ -169,7 +167,7 @@ public class RedisRpcController { */ public RedisRpcResponse stopWaitePushStreamOnline(RedisRpcRequest request) { SendRtpItem sendRtpItem = JSONObject.parseObject(request.getParam().toString(), SendRtpItem.class); - logger.info("[redis-rpc] 停止监听流上线: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() ); + log.info("[redis-rpc] 停止监听流上线: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() ); // 监听流上线。 流上线直接发送sendRtpItem消息给实际的信令处理者 Hook hook = Hook.getInstance(HookType.on_media_arrival, sendRtpItem.getApp(), sendRtpItem.getStream(), null); hookSubscribe.removeSubscribe(hook); @@ -188,22 +186,22 @@ public class RedisRpcController { RedisRpcResponse response = request.getResponse(); response.setStatusCode(200); if (sendRtpItem == null) { - logger.info("[redis-rpc] 开始发流, 未找到redis中的发流信息, key:{}", sendRtpItemKey); + log.info("[redis-rpc] 开始发流, 未找到redis中的发流信息, key:{}", sendRtpItemKey); WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到redis中的发流信息"); response.setBody(wvpResult); return response; } - logger.info("[redis-rpc] 开始发流: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); + log.info("[redis-rpc] 开始发流: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); MediaServer mediaServer = mediaServerService.getOne(sendRtpItem.getMediaServerId()); if (mediaServer == null) { - logger.info("[redis-rpc] startSendRtp->未找到MediaServer: {}", sendRtpItem.getMediaServerId() ); + log.info("[redis-rpc] startSendRtp->未找到MediaServer: {}", sendRtpItem.getMediaServerId() ); WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到MediaServer"); response.setBody(wvpResult); return response; } MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServer, sendRtpItem.getApp(), sendRtpItem.getStream()); if (mediaInfo != null) { - logger.info("[redis-rpc] startSendRtp->流不在线: {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream() ); + log.info("[redis-rpc] startSendRtp->流不在线: {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream() ); WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "流不在线"); response.setBody(wvpResult); return response; @@ -211,12 +209,12 @@ public class RedisRpcController { try { mediaServerService.startSendRtp(mediaServer, sendRtpItem); }catch (ControllerException exception) { - logger.info("[redis-rpc] 发流失败: {}/{}, 目标地址: {}:{}, {}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort(), exception.getMsg()); + log.info("[redis-rpc] 发流失败: {}/{}, 目标地址: {}:{}, {}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort(), exception.getMsg()); WVPResult wvpResult = WVPResult.fail(exception.getCode(), exception.getMsg()); response.setBody(wvpResult); return response; } - logger.info("[redis-rpc] 发流成功: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); + log.info("[redis-rpc] 发流成功: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); WVPResult wvpResult = WVPResult.success(); response.setBody(wvpResult); return response; @@ -231,15 +229,15 @@ public class RedisRpcController { RedisRpcResponse response = request.getResponse(); response.setStatusCode(200); if (sendRtpItem == null) { - logger.info("[redis-rpc] 停止推流, 未找到redis中的发流信息, key:{}", sendRtpItemKey); + log.info("[redis-rpc] 停止推流, 未找到redis中的发流信息, key:{}", sendRtpItemKey); WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到redis中的发流信息"); response.setBody(wvpResult); return response; } - logger.info("[redis-rpc] 停止推流: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() ); + log.info("[redis-rpc] 停止推流: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() ); MediaServer mediaServer = mediaServerService.getOne(sendRtpItem.getMediaServerId()); if (mediaServer == null) { - logger.info("[redis-rpc] stopSendRtp->未找到MediaServer: {}", sendRtpItem.getMediaServerId() ); + log.info("[redis-rpc] stopSendRtp->未找到MediaServer: {}", sendRtpItem.getMediaServerId() ); WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到MediaServer"); response.setBody(wvpResult); return response; @@ -247,12 +245,12 @@ public class RedisRpcController { try { mediaServerService.stopSendRtp(mediaServer, sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getSsrc()); }catch (ControllerException exception) { - logger.info("[redis-rpc] 停止推流失败: {}/{}, 目标地址: {}:{}, code: {}, msg: {}", sendRtpItem.getApp(), + log.info("[redis-rpc] 停止推流失败: {}/{}, 目标地址: {}:{}, code: {}, msg: {}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort(), exception.getCode(), exception.getMsg() ); response.setBody(WVPResult.fail(exception.getCode(), exception.getMsg())); return response; } - logger.info("[redis-rpc] 停止推流成功: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() ); + log.info("[redis-rpc] 停止推流成功: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() ); response.setBody(WVPResult.success()); return response; } @@ -266,10 +264,10 @@ public class RedisRpcController { RedisRpcResponse response = request.getResponse(); response.setStatusCode(200); if (sendRtpItem == null) { - logger.info("[redis-rpc] 推流已经停止, 未找到redis中的发流信息, key:{}", sendRtpItemKey); + log.info("[redis-rpc] 推流已经停止, 未找到redis中的发流信息, key:{}", sendRtpItemKey); return response; } - logger.info("[redis-rpc] 推流已经停止: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() ); + log.info("[redis-rpc] 推流已经停止: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() ); String platformId = sendRtpItem.getPlatformId(); ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); if (platform == null) { @@ -281,13 +279,13 @@ public class RedisRpcController { sendRtpItem.getCallId(), sendRtpItem.getStream()); redisCatchStorage.sendPlatformStopPlayMsg(sendRtpItem, platform); } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 发送BYE: {}", e.getMessage()); + log.error("[命令发送失败] 发送BYE: {}", e.getMessage()); } return response; } private void sendResponse(RedisRpcResponse response){ - logger.info("[redis-rpc] >> {}", response); + log.info("[redis-rpc] >> {}", response); response.setToId(userSetting.getServerId()); RedisRpcMessage message = new RedisRpcMessage(); message.setResponse(response); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java index 5b4901565..7e077f3c8 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java @@ -1,7 +1,6 @@ package com.genersoft.iot.vmp.storager; import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; @@ -58,18 +57,6 @@ public interface IVideoManagerStorage { * @return */ public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count); - - public List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List channelIds, String query, Boolean hasSubChannel, Boolean online, int start, int limit); - - - /** - * 获取某个设备的通道列表 - * - * @param deviceId 设备ID - * @return - */ - public List queryChannelsByDeviceId(String deviceId,Boolean online,List channelIds); - public List queryOnlineChannelsByDeviceId(String deviceId); /** * 获取某个设备的通道 @@ -78,13 +65,6 @@ public interface IVideoManagerStorage { */ public DeviceChannel queryChannel(String deviceId, String channelId); - /** - * 删除通道 - * @param deviceId 设备ID - * @param channelId 通道ID - */ - public int delChannel(String deviceId, String channelId); - /** * 获取多个设备 * @param page 当前页数 @@ -113,27 +93,12 @@ public interface IVideoManagerStorage { */ PageInfo querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, Boolean online, int page, int count); - - /** - * 清空通道 - * @param deviceId - */ - void cleanChannelsForDevice(String deviceId); - - /** * 更新上级平台 * @param parentPlatform */ boolean updateParentPlatform(ParentPlatform parentPlatform); - - /** - * 添加上级平台 - * @param parentPlatform - */ - boolean addParentPlatform(ParentPlatform parentPlatform); - /** * 删除上级平台 * @param parentPlatform @@ -153,22 +118,11 @@ public interface IVideoManagerStorage { */ ParentPlatform queryParentPlatByServerGBId(String platformGbId); - /** - * 所有平台离线 - */ - void outlineForAllParentPlatform(); - /** * 查询通道信息,不区分设备(已关联平台或全部) */ PageInfo queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId); - /** - * 查询设备的通道信息 - */ - List queryChannelListInParentPlatform(String platformId); - - /** * 移除上级平台的通道信息 @@ -181,9 +135,6 @@ public interface IVideoManagerStorage { DeviceChannel queryChannelInParentPlatform(String platformId, String channelId); - List queryChannelInParentPlatformAndCatalog(String platformId, String catalogId); - List queryStreamInParentPlatformAndCatalog(String platformId, String catalogId); - Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); /** @@ -193,12 +144,6 @@ public interface IVideoManagerStorage { * @return 设备信息 */ Device queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId); - /** - * 添加Mobile Position设备移动位置 - * @param mobilePosition - * @return - */ - public boolean insertMobilePosition(MobilePosition mobilePosition); /** * 查询移动位置轨迹 @@ -214,43 +159,6 @@ public interface IVideoManagerStorage { */ public MobilePosition queryLatestPosition(String deviceId); - /** - * 删除指定设备的所有移动位置 - * @param deviceId - */ - public int clearMobilePositionsByDeviceId(String deviceId); - - /** - * 移除代理流 - * @param app - * @param stream - * @return - */ - public int deleteStreamProxy(String app, String stream); - - /** - * 按照是否启用获取代理流 - * @param enable - * @return - */ - public List getStreamProxyListForEnable(boolean enable); - - /** - * 按照是app和stream获取代理流 - * @param app - * @param stream - * @return - */ - public StreamProxy queryStreamProxy(String app, String stream); - - /** - * 获取代理流 - * @param page - * @param count - * @return - */ - PageInfo queryStreamProxyList(Integer page, Integer count); - /** * 根据国标ID获取平台关联的直播流 * @param platformId @@ -259,43 +167,6 @@ public interface IVideoManagerStorage { */ GbStream queryStreamInParentPlatform(String platformId, String channelId); - /** - * 获取平台关联的直播流 - * @param platformId - * @return - */ - List queryGbStreamListInPlatform(String platformId); - - /** - * 移除单个推流 - * @param app - * @param stream - */ - int removeMedia(String app, String stream); - - /** - * 设置流离线 - */ - int mediaOffline(String app, String streamId); - - /** - * 设置流上线 - */ - int mediaOnline(String app, String streamId); - - /** - * 设置平台在线/离线 - */ - void updateParentPlatformStatus(String platformGbID, boolean online); - - /** - * 根据媒体ID获取启用/不启用的代理列表 - * @param id 媒体ID - * @param enable 启用/不启用 - * @return - */ - List getStreamProxyListForEnableInMediaServer(String id, boolean enable); - /** * 根据通道ID获取其所在设备 * @param channelId 通道ID @@ -303,35 +174,6 @@ public interface IVideoManagerStorage { */ Device queryVideoDeviceByChannelId(String channelId); - /** - * 通道上线 - * @param channelId 通道ID - */ - void deviceChannelOnline(String deviceId, String channelId); - - /** - * 通道离线 - * @param channelId 通道ID - */ - void deviceChannelOffline(String deviceId, String channelId); - - /** - * 通过app与stream获取StreamProxy - * @param app - * @param streamId - * @return - */ - StreamProxy getStreamProxyByAppAndStream(String app, String streamId); - - /** - * catlog查询结束后完全重写通道信息 - * @param deviceId - * @param deviceChannelList - */ - boolean resetChannels(String deviceId, List deviceChannelList); - - boolean updateChannels(String deviceId, List deviceChannelList); - /** * 获取目录信息 * @param platformId @@ -350,18 +192,12 @@ public interface IVideoManagerStorage { int setDefaultCatalog(String platformId, String catalogId); - List queryCatalogInPlatform(String serverGBId); - int delRelation(PlatformCatalog platformCatalog); int updateStreamGPS(List gpsMsgInfo); List queryPlatFormListForGBWithGBId(String channelId, List platforms); - List queryPlatFormListForStreamWithGBId(String app, String stream, List platforms); - - GbStream getGbStream(String app, String streamId); - void delCatalogByPlatformId(String serverGBId); void delRelationByPlatformId(String serverGBId); @@ -370,12 +206,6 @@ public interface IVideoManagerStorage { List getChannelSource(String platformId, String gbId); - void updateChannelPosition(DeviceChannel deviceChannel); - - void cleanContentForPlatform(String serverGBId); - - List queryChannelWithCatalog(String serverGBId); - List queryChannelsByDeviceId(String serial, List channelIds, Boolean online); List queryEnablePlatformListWithAsMessageChannel(); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index c081b0d9c..c0f7edf19 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -6,7 +6,6 @@ import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; -import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; @@ -25,13 +24,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.stereotype.Component; import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; -import org.springframework.util.ObjectUtils; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; +import java.util.ArrayList; +import java.util.List; /** * 视频设备数据存储-jdbc实现 @@ -108,269 +104,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return deviceMapper.getDeviceByDeviceId(deviceId) != null; } - @Override - public boolean resetChannels(String deviceId, List deviceChannelList) { - if (CollectionUtils.isEmpty(deviceChannelList)) { - return false; - } - List allChannels = deviceChannelMapper.queryAllChannels(deviceId); - Map allChannelMap = new ConcurrentHashMap<>(); - if (allChannels.size() > 0) { - for (DeviceChannel deviceChannel : allChannels) { - allChannelMap.put(deviceChannel.getChannelId(), deviceChannel); - } - } - TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); - // 数据去重 - List channels = new ArrayList<>(); - - List updateChannels = new ArrayList<>(); - List addChannels = new ArrayList<>(); - List deleteChannels = new ArrayList<>(); - StringBuilder stringBuilder = new StringBuilder(); - Map subContMap = new HashMap<>(); - - // 数据去重 - Set gbIdSet = new HashSet<>(); - for (DeviceChannel deviceChannel : deviceChannelList) { - if (gbIdSet.contains(deviceChannel.getChannelId())) { - stringBuilder.append(deviceChannel.getChannelId()).append(","); - continue; - } - gbIdSet.add(deviceChannel.getChannelId()); - if (allChannelMap.containsKey(deviceChannel.getChannelId())) { - deviceChannel.setStreamId(allChannelMap.get(deviceChannel.getChannelId()).getStreamId()); - deviceChannel.setHasAudio(allChannelMap.get(deviceChannel.getChannelId()).getHasAudio()); - if (allChannelMap.get(deviceChannel.getChannelId()).isStatus() !=deviceChannel.isStatus()){ - List strings = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getChannelId()); - if (!CollectionUtils.isEmpty(strings)){ - strings.forEach(platformId->{ - eventPublisher.catalogEventPublish(platformId, deviceChannel, deviceChannel.isStatus()?CatalogEvent.ON:CatalogEvent.OFF); - }); - } - - } - deviceChannel.setUpdateTime(DateUtil.getNow()); - updateChannels.add(deviceChannel); - }else { - deviceChannel.setCreateTime(DateUtil.getNow()); - deviceChannel.setUpdateTime(DateUtil.getNow()); - addChannels.add(deviceChannel); - } - allChannelMap.remove(deviceChannel.getChannelId()); - channels.add(deviceChannel); - if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) { - if (subContMap.get(deviceChannel.getParentId()) == null) { - subContMap.put(deviceChannel.getParentId(), 1); - }else { - Integer count = subContMap.get(deviceChannel.getParentId()); - subContMap.put(deviceChannel.getParentId(), count++); - } - } - } - deleteChannels.addAll(allChannelMap.values()); - if (!channels.isEmpty()) { - for (DeviceChannel channel : channels) { - if (subContMap.get(channel.getChannelId()) != null){ - Integer count = subContMap.get(channel.getChannelId()); - if (count > 0) { - channel.setSubCount(count); - channel.setParental(1); - } - } - } - } - - if (stringBuilder.length() > 0) { - logger.info("[目录查询]收到的数据存在重复: {}" , stringBuilder); - } - if(CollectionUtils.isEmpty(channels)){ - logger.info("通道重设,数据为空={}" , deviceChannelList); - return false; - } - try { - int limitCount = 50; - boolean result = false; - if (!result && !addChannels.isEmpty()) { - if (addChannels.size() > limitCount) { - for (int i = 0; i < addChannels.size(); i += limitCount) { - int toIndex = i + limitCount; - if (i + limitCount > addChannels.size()) { - toIndex = addChannels.size(); - } - result = result || deviceChannelMapper.batchAdd(addChannels.subList(i, toIndex)) < 0; - } - }else { - result = result || deviceChannelMapper.batchAdd(addChannels) < 0; - } - } - if (!result && !updateChannels.isEmpty()) { - if (updateChannels.size() > limitCount) { - for (int i = 0; i < updateChannels.size(); i += limitCount) { - int toIndex = i + limitCount; - if (i + limitCount > updateChannels.size()) { - toIndex = updateChannels.size(); - } - result = result || deviceChannelMapper.batchUpdate(updateChannels.subList(i, toIndex)) < 0; - } - }else { - result = result || deviceChannelMapper.batchUpdate(updateChannels) < 0; - } - } - if (!result && !deleteChannels.isEmpty()) { - System.out.println("删除: " + deleteChannels.size()); - if (deleteChannels.size() > limitCount) { - for (int i = 0; i < deleteChannels.size(); i += limitCount) { - int toIndex = i + limitCount; - if (i + limitCount > deleteChannels.size()) { - toIndex = deleteChannels.size(); - } - result = result || deviceChannelMapper.batchDel(deleteChannels.subList(i, toIndex)) < 0; - } - }else { - result = result || deviceChannelMapper.batchDel(deleteChannels) < 0; - } - } - - if (result) { - //事务回滚 - dataSourceTransactionManager.rollback(transactionStatus); - } - dataSourceTransactionManager.commit(transactionStatus); //手动提交 - return true; - }catch (Exception e) { - logger.error("未处理的异常 ", e); - dataSourceTransactionManager.rollback(transactionStatus); - return false; - } - - } - - - @Override - public boolean updateChannels(String deviceId, List deviceChannelList) { - if (CollectionUtils.isEmpty(deviceChannelList)) { - return false; - } - List allChannels = deviceChannelMapper.queryAllChannels(deviceId); - Map allChannelMap = new ConcurrentHashMap<>(); - if (allChannels.size() > 0) { - for (DeviceChannel deviceChannel : allChannels) { - allChannelMap.put(deviceChannel.getChannelId(), deviceChannel); - } - } - TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); - // 数据去重 - List channels = new ArrayList<>(); - - List updateChannels = new ArrayList<>(); - List addChannels = new ArrayList<>(); - StringBuilder stringBuilder = new StringBuilder(); - Map subContMap = new HashMap<>(); - if (deviceChannelList.size() > 0) { - // 数据去重 - Set gbIdSet = new HashSet<>(); - for (DeviceChannel deviceChannel : deviceChannelList) { - if (!gbIdSet.contains(deviceChannel.getChannelId())) { - gbIdSet.add(deviceChannel.getChannelId()); - deviceChannel.setUpdateTime(DateUtil.getNow()); - if (allChannelMap.containsKey(deviceChannel.getChannelId())) { - deviceChannel.setStreamId(allChannelMap.get(deviceChannel.getChannelId()).getStreamId()); - deviceChannel.setHasAudio(allChannelMap.get(deviceChannel.getChannelId()).getHasAudio()); - if (allChannelMap.get(deviceChannel.getChannelId()).isStatus() !=deviceChannel.isStatus()){ - List strings = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getChannelId()); - if (!CollectionUtils.isEmpty(strings)){ - strings.forEach(platformId->{ - eventPublisher.catalogEventPublish(platformId, deviceChannel, deviceChannel.isStatus()?CatalogEvent.ON:CatalogEvent.OFF); - }); - } - } - updateChannels.add(deviceChannel); - }else { - deviceChannel.setCreateTime(DateUtil.getNow()); - addChannels.add(deviceChannel); - } - channels.add(deviceChannel); - if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) { - if (subContMap.get(deviceChannel.getParentId()) == null) { - subContMap.put(deviceChannel.getParentId(), 1); - }else { - Integer count = subContMap.get(deviceChannel.getParentId()); - subContMap.put(deviceChannel.getParentId(), count++); - } - } - }else { - stringBuilder.append(deviceChannel.getChannelId()).append(","); - } - } - if (channels.size() > 0) { - for (DeviceChannel channel : channels) { - if (subContMap.get(channel.getChannelId()) != null){ - channel.setSubCount(subContMap.get(channel.getChannelId())); - } - } - } - - } - if (stringBuilder.length() > 0) { - logger.info("[目录查询]收到的数据存在重复: {}" , stringBuilder); - } - if(CollectionUtils.isEmpty(channels)){ - logger.info("通道重设,数据为空={}" , deviceChannelList); - return false; - } - try { - int limitCount = 50; - boolean result = false; - if (addChannels.size() > 0) { - if (addChannels.size() > limitCount) { - for (int i = 0; i < addChannels.size(); i += limitCount) { - int toIndex = i + limitCount; - if (i + limitCount > addChannels.size()) { - toIndex = addChannels.size(); - } - result = result || deviceChannelMapper.batchAdd(addChannels.subList(i, toIndex)) < 0; - } - }else { - result = result || deviceChannelMapper.batchAdd(addChannels) < 0; - } - } - if (updateChannels.size() > 0) { - if (updateChannels.size() > limitCount) { - for (int i = 0; i < updateChannels.size(); i += limitCount) { - int toIndex = i + limitCount; - if (i + limitCount > updateChannels.size()) { - toIndex = updateChannels.size(); - } - result = result || deviceChannelMapper.batchUpdate(updateChannels.subList(i, toIndex)) < 0; - } - }else { - result = result || deviceChannelMapper.batchUpdate(updateChannels) < 0; - } - } - - if (result) { - //事务回滚 - dataSourceTransactionManager.rollback(transactionStatus); - } - dataSourceTransactionManager.commit(transactionStatus); //手动提交 - return true; - }catch (Exception e) { - logger.error("未处理的异常 ", e); - dataSourceTransactionManager.rollback(transactionStatus); - return false; - } - } - - @Override - public void deviceChannelOnline(String deviceId, String channelId) { - deviceChannelMapper.online(deviceId, channelId); - } - - @Override - public void deviceChannelOffline(String deviceId, String channelId) { - deviceChannelMapper.offline(deviceId, channelId); - } @Override public void startPlay(String deviceId, String channelId, String streamId) { @@ -409,17 +142,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return new PageInfo<>(all); } - @Override - public List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List channelIds, String query, Boolean hasSubChannel, Boolean online, int start, int limit) { - return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, channelIds, null, query, hasSubChannel, online, start, limit); - } - - - @Override - public List queryChannelsByDeviceId(String deviceId,Boolean online,List channelIds) { - return deviceChannelMapper.queryChannels(deviceId, null,null, null, online,channelIds); - } - @Override public List queryChannelsByDeviceId(String deviceId, List channelIds, Boolean online) { return deviceChannelMapper.queryChannelsWithDeviceInfo(deviceId, null,null, null, online,channelIds); @@ -438,11 +160,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { } - @Override - public int delChannel(String deviceId, String channelId) { - return deviceChannelMapper.del(deviceId, channelId); - } - /** * 获取多个设备 * @@ -469,23 +186,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return deviceList; } - /** - * 清空通道 - * @param deviceId - */ - @Override - public void cleanChannelsForDevice(String deviceId) { - deviceChannelMapper.cleanChannelsByDeviceId(deviceId); - } - - /** - * 添加Mobile Position设备移动位置 - * @param mobilePosition - */ - @Override - public synchronized boolean insertMobilePosition(MobilePosition mobilePosition) { - return deviceMobilePositionMapper.insertNewPosition(mobilePosition) > 0; - } /** * 查询移动位置轨迹 @@ -498,15 +198,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return deviceMobilePositionMapper.queryPositionByDeviceIdAndTime(deviceId, channelId, startTime, endTime); } - @Override - public boolean addParentPlatform(ParentPlatform parentPlatform) { - if (parentPlatform.getCatalogId() == null) { - parentPlatform.setCatalogId(parentPlatform.getServerGBId()); - } - int result = platformMapper.addParentPlatform(parentPlatform); - return result > 0; - } - @Override public boolean updateParentPlatform(ParentPlatform parentPlatform) { int result = 0; @@ -574,11 +265,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return deviceMapper.queryDeviceWithAsMessageChannel(); } - @Override - public void outlineForAllParentPlatform() { - platformMapper.outlineForAllParentPlatform(); - } - @Override public PageInfo queryAllChannelList(int page, int count, String query, Boolean online, @@ -588,21 +274,15 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return new PageInfo<>(all); } - @Override - public List queryChannelListInParentPlatform(String platformId) { - - return deviceChannelMapper.queryChannelByPlatformId(platformId); - } - @Override public int delChannelForGB(String platformId, List channelReduces) { int result = platformChannelMapper.delChannelForGB(platformId, channelReduces); - List deviceChannelList = new ArrayList<>(); + List deviceChannelList = new ArrayList<>(); for (ChannelReduce channelReduce : channelReduces) { - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(channelReduce.getChannelId()); + CommonGBChannel deviceChannel = new CommonGBChannel(); + deviceChannel.setGbDeviceId(channelReduce.getChannelId()); deviceChannelList.add(deviceChannel); } eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); @@ -623,18 +303,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { } } - @Override - public List queryChannelInParentPlatformAndCatalog(String platformId, String catalogId) { - List catalogs = platformChannelMapper.queryChannelInParentPlatformAndCatalog(platformId, catalogId); - return catalogs; - } - - @Override - public List queryStreamInParentPlatformAndCatalog(String platformId, String catalogId) { - List catalogs = platformGbStreamMapper.queryChannelInParentPlatformAndCatalogForCatalog(platformId, catalogId); - return catalogs; - } - @Override public Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId) { List devices = platformChannelMapper.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId); @@ -674,50 +342,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return deviceMobilePositionMapper.queryLatestPositionByDevice(deviceId); } - /** - * 删除指定设备的所有移动位置 - * @param deviceId - */ - @Override - public int clearMobilePositionsByDeviceId(String deviceId) { - return deviceMobilePositionMapper.clearMobilePositionsByDeviceId(deviceId); - } - - - /** - * 移除代理流 - * @param app - * @param stream - * @return - */ - @Override - public int deleteStreamProxy(String app, String stream) { - return streamProxyMapper.del(app, stream); - } - - /** - * 根据是否启用获取代理流列表 - * @param enable - * @return - */ - @Override - public List getStreamProxyListForEnable(boolean enable) { - return streamProxyMapper.selectForEnable(enable); - } - - /** - * 分页查询代理流列表 - * @param page - * @param count - * @return - */ - @Override - public PageInfo queryStreamProxyList(Integer page, Integer count) { - PageHelper.startPage(page, count); - List all = streamProxyMapper.selectAll(); - return new PageInfo<>(all); - } - /** * 根据国标ID获取平台关联的直播流 * @param platformId @@ -729,66 +353,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return gbStreamMapper.queryStreamInPlatform(platformId, gbId); } - /** - * 获取平台关联的直播流 - * @param platformId - * @return - */ - @Override - public List queryGbStreamListInPlatform(String platformId) { - return gbStreamMapper.queryGbStreamListInPlatform(platformId, userSetting.isUsePushingAsStatus()); - } - - /** - * 按照是app和stream获取代理流 - * @param app - * @param stream - * @return - */ - @Override - public StreamProxy queryStreamProxy(String app, String stream){ - return streamProxyMapper.selectOne(app, stream); - } - - @Override - public int removeMedia(String app, String stream) { - return streamPushMapper.del(app, stream); - } - - @Override - public int mediaOffline(String app, String stream) { - GbStream gbStream = gbStreamMapper.selectOne(app, stream); - int result; - if ("proxy".equals(gbStream.getStreamType())) { - result = streamProxyMapper.updateStatus(app, stream, false); - }else { - result = streamPushMapper.updatePushStatus(app, stream, false); - } - return result; - } - - @Override - public int mediaOnline(String app, String stream) { - GbStream gbStream = gbStreamMapper.selectOne(app, stream); - int result; - if ("proxy".equals(gbStream.getStreamType())) { - result = streamProxyMapper.updateStatus(app, stream, true); - }else { - result = streamPushMapper.updatePushStatus(app, stream, true); - } - return result; - } - - @Override - public void updateParentPlatformStatus(String platformGbID, boolean online) { - platformMapper.updateParentPlatformStatus(platformGbID, online); - } - - @Override - public List getStreamProxyListForEnableInMediaServer(String id, boolean enable) { - return streamProxyMapper.selectForEnableInMediaServer(id, enable); - } - @Override public Device queryVideoDeviceByChannelId( String channelId) { @@ -800,11 +364,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return result; } - @Override - public StreamProxy getStreamProxyByAppAndStream(String app, String streamId) { - return streamProxyMapper.selectOne(app, streamId); - } - @Override public List getChildrenCatalogByPlatform(String platformId, String parentId) { return catalogMapper.selectByParentId(platformId, parentId); @@ -889,27 +448,27 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { int delresult = catalogMapper.del(platformId, id); DeviceChannel deviceChannelForCatalog = new DeviceChannel(); if (delresult > 0){ - deviceChannelForCatalog.setChannelId(id); + deviceChannelForCatalog.setDeviceId(id); eventPublisher.catalogEventPublish(platformId, deviceChannelForCatalog, CatalogEvent.DEL); } List gbStreams = platformGbStreamMapper.queryChannelInParentPlatformAndCatalog(platformId, id); - if (gbStreams.size() > 0){ - List deviceChannelList = new ArrayList<>(); + if (!gbStreams.isEmpty()){ + List deviceChannelList = new ArrayList<>(); for (GbStream gbStream : gbStreams) { - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(gbStream.getGbId()); + CommonGBChannel deviceChannel = new CommonGBChannel(); + deviceChannel.setGbDeviceId(gbStream.getGbId()); deviceChannelList.add(deviceChannel); } eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); } int delStreamresult = platformGbStreamMapper.delByPlatformAndCatalogId(platformId,id); List platformCatalogs = platformChannelMapper.queryChannelInParentPlatformAndCatalog(platformId, id); - if (platformCatalogs.size() > 0){ - List deviceChannelList = new ArrayList<>(); + if (!platformCatalogs.isEmpty()){ + List deviceChannelList = new ArrayList<>(); for (PlatformCatalog platformCatalog : platformCatalogs) { - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(platformCatalog.getId()); + CommonGBChannel deviceChannel = new CommonGBChannel(); + deviceChannel.setGbDeviceId(platformCatalog.getId()); deviceChannelList.add(deviceChannel); } eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); @@ -968,24 +527,19 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return platformMapper.setDefaultCatalog(platformId, catalogId, DateUtil.getNow()); } - @Override - public List queryCatalogInPlatform(String platformId) { - return catalogMapper.queryCatalogInPlatform(platformId); - } - @Override public int delRelation(PlatformCatalog platformCatalog) { if (platformCatalog.getType() == 1) { - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(platformCatalog.getId()); + CommonGBChannel deviceChannel = new CommonGBChannel(); + deviceChannel.setGbDeviceId(platformCatalog.getId()); eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.DEL); return platformChannelMapper.delByCatalogIdAndChannelIdAndPlatformId(platformCatalog); }else if (platformCatalog.getType() == 2) { List gbStreams = platformGbStreamMapper.queryChannelInParentPlatformAndCatalog(platformCatalog.getPlatformId(), platformCatalog.getParentId()); for (GbStream gbStream : gbStreams) { if (gbStream.getGbId().equals(platformCatalog.getId())) { - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(gbStream.getGbId()); + CommonGBChannel deviceChannel = new CommonGBChannel(); + deviceChannel.setGbDeviceId(gbStream.getGbId()); eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.DEL); return platformGbStreamMapper.delByAppAndStream(gbStream.getApp(), gbStream.getStream()); } @@ -1003,11 +557,11 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { private DeviceChannel getDeviceChannelByCatalog(PlatformCatalog catalog) { ParentPlatform platform = platformMapper.getParentPlatByServerGBId(catalog.getPlatformId()); DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(catalog.getId()); + deviceChannel.setDeviceId(catalog.getId()); deviceChannel.setName(catalog.getName()); deviceChannel.setDeviceId(platform.getDeviceGBId()); - deviceChannel.setManufacture("wvp-pro"); - deviceChannel.setStatus(true); + deviceChannel.setManufacturer("wvp-pro"); + deviceChannel.setStatus("ON"); deviceChannel.setParental(1); deviceChannel.setRegisterWay(1); @@ -1016,33 +570,15 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { deviceChannel.setModel("live"); deviceChannel.setOwner("wvp-pro"); - deviceChannel.setSecrecy("0"); + deviceChannel.setSecrecy(0); return deviceChannel; } - @Override - public List queryOnlineChannelsByDeviceId(String deviceId) { - return deviceChannelMapper.queryOnlineChannelsByDeviceId(deviceId); - } - @Override public List queryPlatFormListForGBWithGBId(String channelId, List platforms) { return platformChannelMapper.queryPlatFormListForGBWithGBId(channelId, platforms); } - @Override - public List queryPlatFormListForStreamWithGBId(String app, String stream, List platforms) { - if (platforms == null || platforms.size() == 0) { - return new ArrayList<>(); - } - return platformGbStreamMapper.queryPlatFormListForGBWithGBId(app, stream, platforms); - } - - @Override - public GbStream getGbStream(String app, String streamId) { - return gbStreamMapper.selectOne(app, streamId); - } - @Override public void delCatalogByPlatformId(String serverGBId) { catalogMapper.delByPlatformId(serverGBId); @@ -1063,39 +599,4 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { public List getChannelSource(String platformId, String gbId) { return platformMapper.getChannelSource(platformId, gbId); } - - @Override - public void updateChannelPosition(DeviceChannel deviceChannel) { - if (deviceChannel.getChannelId().equals(deviceChannel.getDeviceId())) { - deviceChannel.setChannelId(null); - } - if (deviceChannel.getGpsTime() == null) { - deviceChannel.setGpsTime(DateUtil.getNow()); - } - - deviceChannelMapper.updatePosition(deviceChannel); - } - - @Override - public void cleanContentForPlatform(String serverGBId) { -// List catalogList = catalogMapper.selectByPlatForm(serverGBId); -// if (catalogList.size() > 0) { -// int result = catalogMapper.delByPlatformId(serverGBId); -// if (result > 0) { -// List deviceChannels = new ArrayList<>(); -// for (PlatformCatalog catalog : catalogList) { -// deviceChannels.add(getDeviceChannelByCatalog(catalog)); -// } -// eventPublisher.catalogEventPublish(serverGBId, deviceChannels, CatalogEvent.DEL); -// } -// } - catalogMapper.delByPlatformId(serverGBId); - platformChannelMapper.delByPlatformId(serverGBId); - platformGbStreamMapper.delByPlatformId(serverGBId); - } - - @Override - public List queryChannelWithCatalog(String serverGBId) { - return deviceChannelMapper.queryChannelWithCatalog(serverGBId); - } } diff --git a/src/main/java/com/genersoft/iot/vmp/utils/CivilCodeUtil.java b/src/main/java/com/genersoft/iot/vmp/utils/CivilCodeUtil.java index ba23ab2e0..3ca0cd69f 100644 --- a/src/main/java/com/genersoft/iot/vmp/utils/CivilCodeUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/utils/CivilCodeUtil.java @@ -11,7 +11,7 @@ import java.util.concurrent.ConcurrentHashMap; public enum CivilCodeUtil { INSTANCE; - private final static Logger log = LoggerFactory.getLogger(CivilCodeUtil.class); + private final static Logger logger = LoggerFactory.getLogger(CivilCodeUtil.class); // 用与消息的缓存 private final Map civilCodeMap = new ConcurrentHashMap<>();