/* package com.sooka.sponest.event.utils; import com.ruoyi.common.core.utils.SpringUtils; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.redis.service.RedisService; import com.sooka.sponest.event.centereventteventcatalogue.service.ICentereventTEventcatalogueService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; */ /** * @Auther: mjq * @Date: 2023/9/12 - 09 - 12 - 10:08 * @Description: com.sooka.sponest.event.utils * @version: 1.0 *//* @Configuration @EnableScheduling //@RestController //@RequestMapping("/testload") public class ScheduleTaskUtil { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired private ICentereventTEventcatalogueService centereventTEventcatalogueService; static final String DOWN_LOCK = "downlod:lock"; static final String VALUE_LOCK = "valueLock"; @Scheduled(cron = "0 10 0 * * ?") //@GetMapping("/down") public void runTask() { long startMill = System.currentTimeMillis(); // 读取缓存 RedisService redis = SpringUtils.getBean(RedisService.class); String lock = redis.getCacheObject(DOWN_LOCK); if (StringUtils.isBlank(lock)) { redis.setCacheObject(DOWN_LOCK, VALUE_LOCK); Map params = new HashMap<>(); params.put("taskValue", "1"); centereventTEventcatalogueService.downloadsCommon(params); } redis.setCacheObject(DOWN_LOCK, (System.currentTimeMillis() - startMill), (long) 3600 * 12, TimeUnit.SECONDS); } } */