@ -4,7 +4,8 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe ;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe ;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform ;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform ;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager ;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager ;
import lombok.extern.slf4j.Slf4j ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.context.ApplicationListener ;
import org.springframework.context.ApplicationListener ;
import org.springframework.stereotype.Component ;
import org.springframework.stereotype.Component ;
@ -12,9 +13,11 @@ import org.springframework.stereotype.Component;
import java.util.Timer ;
import java.util.Timer ;
import java.util.TimerTask ;
import java.util.TimerTask ;
@Slf4j
@Component
@Component
public class PlatformCycleRegisterEventLister implements ApplicationListener < PlatformCycleRegisterEvent > {
public class PlatformCycleRegisterEventLister implements ApplicationListener < PlatformCycleRegisterEvent > {
private final static Logger logger = LoggerFactory . getLogger ( PlatformCycleRegisterEventLister . class ) ;
@Autowired
@Autowired
private IVideoManagerStorager storager ;
private IVideoManagerStorager storager ;
@Autowired
@Autowired
@ -22,10 +25,10 @@ public class PlatformCycleRegisterEventLister implements ApplicationListener<Pla
@Override
@Override
public void onApplicationEvent ( PlatformCycleRegisterEvent event ) {
public void onApplicationEvent ( PlatformCycleRegisterEvent event ) {
log . info ( "上级平台周期注册事件" ) ;
logger . info ( "上级平台周期注册事件" ) ;
ParentPlatform parentPlatform = storager . queryParentPlatByServerGBId ( event . getPlatformGbID ( ) ) ;
ParentPlatform parentPlatform = storager . queryParentPlatByServerGBId ( event . getPlatformGbID ( ) ) ;
if ( parentPlatform = = null ) {
if ( parentPlatform = = null ) {
log . info ( "[ 平台未注册事件 ] 平台已经删除!!! 平台国标ID:" + event . getPlatformGbID ( ) ) ;
logger . info ( "[ 平台未注册事件 ] 平台已经删除!!! 平台国标ID:" + event . getPlatformGbID ( ) ) ;
return ;
return ;
}
}
Timer timer = new Timer ( ) ;
Timer timer = new Timer ( ) ;
@ -36,7 +39,7 @@ public class PlatformCycleRegisterEventLister implements ApplicationListener<Pla
timer . schedule ( new TimerTask ( ) {
timer . schedule ( new TimerTask ( ) {
@Override
@Override
public void run ( ) {
public void run ( ) {
log . info ( "[平台注册]再次向平台注册,平台国标ID:" + event . getPlatformGbID ( ) ) ;
logger . info ( "[平台注册]再次向平台注册,平台国标ID:" + event . getPlatformGbID ( ) ) ;
sipCommanderFroPlatform . register ( parentPlatform , null , okEvent ) ;
sipCommanderFroPlatform . register ( parentPlatform , null , okEvent ) ;
}
}
} , 15 * 1000 , Long . parseLong ( parentPlatform . getExpires ( ) ) * 1000 ) ;
} , 15 * 1000 , Long . parseLong ( parentPlatform . getExpires ( ) ) * 1000 ) ;