SipDeviceRunner.java 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package com.genersoft.iot.vmp.conf.runner;
  2. import com.genersoft.iot.vmp.common.VideoManagerConstants;
  3. import com.genersoft.iot.vmp.conf.UserSetup;
  4. import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
  5. import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.boot.CommandLineRunner;
  8. import org.springframework.core.annotation.Order;
  9. import org.springframework.stereotype.Component;
  10. import java.util.List;
  11. /**
  12. * 系统启动时控制设备离线
  13. */
  14. @Component
  15. @Order(value=4)
  16. public class SipDeviceRunner implements CommandLineRunner {
  17. @Autowired
  18. private IVideoManagerStorager storager;
  19. @Autowired
  20. private IRedisCatchStorage redisCatchStorage;
  21. @Autowired
  22. private UserSetup userSetup;
  23. @Override
  24. public void run(String... args) throws Exception {
  25. // 读取redis没有心跳信息的则设置为离线,等收到下次心跳设置为在线
  26. // 设置所有设备离线
  27. storager.outlineForAll();
  28. List<String> onlineForAll = redisCatchStorage.getOnlineForAll();
  29. for (String deviceId : onlineForAll) {
  30. storager.online(deviceId);
  31. }
  32. // 重置cseq计数
  33. redisCatchStorage.resetAllCSEQ();
  34. // TODO 查询在线设备那些开启了订阅,为设备开启定时的目录订阅
  35. }
  36. }