ScheduleJob.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package com.fdkankan.scene.schedule;
  2. import com.fdkankan.redis.constant.RedisKey;
  3. import com.fdkankan.redis.constant.RedisLockKey;
  4. import com.fdkankan.redis.util.RedisLockUtil;
  5. import com.fdkankan.redis.util.RedisUtil;
  6. import com.fdkankan.scene.service.ISceneAsynOperLogService;
  7. import com.fdkankan.scene.service.ISceneCleanOrigService;
  8. import lombok.extern.log4j.Log4j2;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.cloud.context.config.annotation.RefreshScope;
  11. import org.springframework.scheduling.annotation.Scheduled;
  12. import org.springframework.stereotype.Component;
  13. import javax.annotation.PostConstruct;
  14. @RefreshScope
  15. @Log4j2
  16. @Component
  17. public class ScheduleJob {
  18. @Autowired
  19. private ISceneAsynOperLogService sceneAsynOperLogService;
  20. @Autowired
  21. private ISceneCleanOrigService sceneCleanOrigService;
  22. @Autowired
  23. private RedisLockUtil redisLockUtil;
  24. /**
  25. * 每天凌晨一点执行
  26. */
  27. @Scheduled(cron="0 0 1 * * ?")
  28. public void cleanDownloadPanorama() {
  29. log.info("定时清除全景图压缩包开始");
  30. sceneAsynOperLogService.cleanDownloadPanorama();
  31. log.info("定时清除全景图压缩包完毕");
  32. }
  33. /**
  34. * 删除场景原始资源
  35. * 每天凌晨执行
  36. */
  37. @Scheduled(cron="0 0 1 * * ?")
  38. public void cleanOssHomeV3() {
  39. log.info("删除v3场景原始资源开始");
  40. String lockKey = RedisLockKey.LOCK_CLEAN_SCENE_ORIG_V3;
  41. try {
  42. boolean lock = redisLockUtil.lock(lockKey, RedisKey.CAMERA_EXPIRE_7_TIME);
  43. if(!lock){
  44. return;
  45. }
  46. sceneCleanOrigService.cleanOrigV3();
  47. }finally {
  48. redisLockUtil.unlockLua(lockKey);
  49. }
  50. log.info("删除v3场景原始资源结束");
  51. }
  52. /**
  53. * 删除场景原始资源
  54. * 每天凌晨执行
  55. */
  56. @Scheduled(cron="0 0 1 * * ?")
  57. public void cleanOssHomeV4() {
  58. log.info("删除v4场景原始资源开始");
  59. String lockKey = RedisLockKey.LOCK_CLEAN_SCENE_ORIG_V4;
  60. try {
  61. boolean lock = redisLockUtil.lock(lockKey, RedisKey.CAMERA_EXPIRE_7_TIME);
  62. if(!lock){
  63. return;
  64. }
  65. sceneCleanOrigService.cleanOrigV4();
  66. }finally {
  67. redisLockUtil.unlockLua(lockKey);
  68. }
  69. log.info("删除v4场景原始资源结束");
  70. }
  71. }