StreamGPSSubscribeTask.java 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package com.genersoft.iot.vmp.service;
  2. import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
  3. import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
  4. import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.scheduling.annotation.Scheduled;
  7. import org.springframework.stereotype.Component;
  8. import java.util.List;
  9. /**
  10. * 定时查找redis中的GPS推送消息,并保存到对应的流中
  11. */
  12. @Component
  13. public class StreamGPSSubscribeTask {
  14. @Autowired
  15. private IRedisCatchStorage redisCatchStorage;
  16. @Autowired
  17. private IVideoManagerStorage storager;
  18. @Scheduled(fixedRate = 30 * 1000) //每30秒执行一次
  19. public void execute(){
  20. List<GPSMsgInfo> gpsMsgInfo = redisCatchStorage.getAllGpsMsgInfo();
  21. if (gpsMsgInfo.size() > 0) {
  22. storager.updateStreamGPS(gpsMsgInfo);
  23. for (GPSMsgInfo msgInfo : gpsMsgInfo) {
  24. msgInfo.setStored(true);
  25. redisCatchStorage.updateGpsMsgInfo(msgInfo);
  26. }
  27. }
  28. }
  29. }