From ba22f1f25754858627c3491d0c2395790b3b9b53 Mon Sep 17 00:00:00 2001 From: lroyia Date: Fri, 3 Apr 2026 11:27:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=B9=B6=E5=8F=91=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schedule/CancelEntRemoveSchedule.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/chinaweal/aiccs/schedule/CancelEntRemoveSchedule.java b/src/main/java/com/chinaweal/aiccs/schedule/CancelEntRemoveSchedule.java index e28f622..8cab1b5 100644 --- a/src/main/java/com/chinaweal/aiccs/schedule/CancelEntRemoveSchedule.java +++ b/src/main/java/com/chinaweal/aiccs/schedule/CancelEntRemoveSchedule.java @@ -7,6 +7,8 @@ import com.chinaweal.aiccs.aicbizqy.entity.datamove.*; import com.chinaweal.aiccs.aicbizqy.mapper.datamove.*; import com.chinaweal.aiccs.aiccs.system.entity.TRBaseCode; import com.chinaweal.aiccs.aiccs.system.service.TRBaseCodeService; +import com.chinaweal.aiccs.common.util.StringUtils; +import com.chinaweal.aiccs.redis.RedisService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; @@ -48,17 +50,17 @@ public class CancelEntRemoveSchedule { @Autowired private CaseCreInformationDataMoveMapper caseCreInformationMapper; + @Autowired private TRBaseCodeService trBaseCodeService; + @Autowired + private RedisService redisService; + /** - * 移出原因码值 - 其他 + * LOCK_KEY */ - private static final String REMOVE_REASON_CODE = "08"; - /** - * 移出原因中文 - 主体注销,自动移出 - */ - private static final String REMOVE_REASON_CN = "主体注销,自动移出"; + private static final String REDIS_LOCK = "CANCEL_ENT_LOCK"; /** * 默认移出机关代码 */ @@ -74,9 +76,13 @@ public class CancelEntRemoveSchedule { @Scheduled(cron = "${scheduling.cron.cancelEntRemove:-}") @Transactional(rollbackFor = Exception.class) public void executeCancelEntRemove() { + if (redisService.exists(REDIS_LOCK)) { + log.info("其他节点已在执行注销主体自动移出任务,本次任务自动跳过"); + return; + } log.info("==========开始执行注销主体自动移出任务=========="); long startTime = System.currentTimeMillis(); - + redisService.set(REDIS_LOCK, StringUtils.EMPTY, 3600); try { // 获取当天日期 LocalDate today = LocalDate.now().minusDays(1); @@ -126,6 +132,8 @@ public class CancelEntRemoveSchedule { } catch (Exception e) { log.error("注销主体自动移出任务执行异常", e); throw e; + } finally { + redisService.remove(REDIS_LOCK); } }