SipPlatformRunner.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package com.genersoft.iot.vmp.conf;
  2. import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
  3. import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
  4. import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
  5. import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
  6. import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.boot.CommandLineRunner;
  9. import org.springframework.core.annotation.Order;
  10. import org.springframework.stereotype.Component;
  11. import java.util.List;
  12. /**
  13. * 系统启动时控制上级平台重新注册
  14. */
  15. @Component
  16. @Order(value=3)
  17. public class SipPlatformRunner implements CommandLineRunner {
  18. @Autowired
  19. private IVideoManagerStorager storager;
  20. @Autowired
  21. private IRedisCatchStorage redisCatchStorage;
  22. @Autowired
  23. private EventPublisher publisher;
  24. @Override
  25. public void run(String... args) throws Exception {
  26. // 设置所有平台离线
  27. storager.outlineForAllParentPlatform();
  28. // 清理所有平台注册缓存
  29. redisCatchStorage.cleanPlatformRegisterInfos();
  30. List<ParentPlatform> parentPlatforms = storager.queryEnableParentPlatformList(true);
  31. for (ParentPlatform parentPlatform : parentPlatforms) {
  32. redisCatchStorage.updatePlatformRegister(parentPlatform);
  33. redisCatchStorage.updatePlatformKeepalive(parentPlatform);
  34. ParentPlatformCatch parentPlatformCatch = new ParentPlatformCatch();
  35. parentPlatformCatch.setParentPlatform(parentPlatform);
  36. parentPlatformCatch.setId(parentPlatform.getServerGBId());
  37. redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
  38. // 发送平台未注册消息
  39. publisher.platformNotRegisterEventPublish(parentPlatform.getServerGBId());
  40. }
  41. }
  42. }