123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package com.fdkankan.scene.schedule;
- import com.fdkankan.redis.constant.RedisKey;
- import com.fdkankan.redis.constant.RedisLockKey;
- import com.fdkankan.redis.util.RedisLockUtil;
- import com.fdkankan.redis.util.RedisUtil;
- import com.fdkankan.scene.service.ISceneAsynOperLogService;
- import com.fdkankan.scene.service.ISceneCleanOrigService;
- import lombok.extern.log4j.Log4j2;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.cloud.context.config.annotation.RefreshScope;
- import org.springframework.scheduling.annotation.Scheduled;
- import org.springframework.stereotype.Component;
- import javax.annotation.PostConstruct;
- @RefreshScope
- @Log4j2
- @Component
- public class ScheduleJob {
- @Autowired
- private ISceneAsynOperLogService sceneAsynOperLogService;
- @Autowired
- private ISceneCleanOrigService sceneCleanOrigService;
- @Autowired
- private RedisLockUtil redisLockUtil;
- /**
- * 每天凌晨一点执行
- */
- @Scheduled(cron="0 0 1 * * ?")
- public void cleanDownloadPanorama() {
- log.info("定时清除全景图压缩包开始");
- sceneAsynOperLogService.cleanDownloadPanorama();
- log.info("定时清除全景图压缩包完毕");
- }
- /**
- * 删除场景原始资源
- * 每天凌晨执行
- */
- @Scheduled(cron="0 0 1 * * ?")
- public void cleanOssHomeV3() {
- log.info("删除v3场景原始资源开始");
- String lockKey = RedisLockKey.LOCK_CLEAN_SCENE_ORIG_V3;
- try {
- boolean lock = redisLockUtil.lock(lockKey, RedisKey.CAMERA_EXPIRE_7_TIME);
- if(!lock){
- return;
- }
- sceneCleanOrigService.cleanOrigV3();
- }finally {
- redisLockUtil.unlockLua(lockKey);
- }
- log.info("删除v3场景原始资源结束");
- }
- /**
- * 删除场景原始资源
- * 每天凌晨执行
- */
- @Scheduled(cron="0 0 1 * * ?")
- public void cleanOssHomeV4() {
- log.info("删除v4场景原始资源开始");
- String lockKey = RedisLockKey.LOCK_CLEAN_SCENE_ORIG_V4;
- try {
- boolean lock = redisLockUtil.lock(lockKey, RedisKey.CAMERA_EXPIRE_7_TIME);
- if(!lock){
- return;
- }
- sceneCleanOrigService.cleanOrigV4();
- }finally {
- redisLockUtil.unlockLua(lockKey);
- }
- log.info("删除v4场景原始资源结束");
- }
- }
|