From db14f311bfa3daba9e43fcad895048cbe2576c04 Mon Sep 17 00:00:00 2001 From: cy <1664593601@qq.com> Date: 星期二, 22 十一月 2022 17:40:05 +0800 Subject: [PATCH] fix(quartz): 调整定时任务判断逻辑 --- src/main/java/com/integrated/zyyt/ZyytQuartz.java | 52 +++++----------------------------------------------- 1 files changed, 5 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/integrated/zyyt/ZyytQuartz.java b/src/main/java/com/integrated/zyyt/ZyytQuartz.java index a55a22f..8aa5dcd 100644 --- a/src/main/java/com/integrated/zyyt/ZyytQuartz.java +++ b/src/main/java/com/integrated/zyyt/ZyytQuartz.java @@ -1,7 +1,7 @@ package com.integrated.zyyt; -import cn.hutool.core.convert.Convert; import com.integrated.zyyt.service.ZyytService; +import com.integrated.zyyt.util.ZyytUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.core.JdbcTemplate; @@ -10,7 +10,6 @@ import javax.annotation.Resource; import java.time.LocalDate; import java.time.temporal.ChronoUnit; -import java.util.Map; /** * @ClassName ZyytQuartz @@ -31,7 +30,7 @@ @Scheduled(cron = "0 0/30 * * * ?") private void stationInfoTask() { LocalDate yestDay = LocalDate.now().minus(1, ChronoUnit.DAYS); - if (canGetAgain("STATIONINFO", yestDay)) { + if (ZyytUtil.canGetAgain("STATIONINFO", yestDay)) { log.info("鎵цstationInfoTask--{}", yestDay); zyytService.stationInfoTasks(); } else { @@ -43,7 +42,7 @@ @Scheduled(cron = "0 3/30 * * * ?") private void shkdrbTasks() { LocalDate yestDay = LocalDate.now().minus(1, ChronoUnit.DAYS); - if (canGetAgain("YYZT_T_SHKDRB", yestDay)) { + if (ZyytUtil.canGetAgain("YYZT_T_SHKDRB", yestDay)) { log.info("鎵цshkdrbTasks--{}", yestDay); zyytService.shkdrbTasks(yestDay); } else { @@ -51,55 +50,14 @@ } } - @Scheduled(cron = "0 5/30 * * * ?") + @Scheduled(cron = "0 7/30 * * * ?") private void djtjbTasks() { LocalDate yestDay = LocalDate.now().minus(1, ChronoUnit.DAYS); - if (!canGetAgain("YYZT_T_DJTJB", yestDay)) { + if (!ZyytUtil.canGetAgain("YYZT_T_DJTJB", yestDay)) { log.info("鏀惧純鎵цdjtjbTasks--{}", yestDay); } log.info("鎵цdjtjbTasks--{}", yestDay); zyytService.djtjbTasks(yestDay); } - /** - * 鍒ゆ柇鎸囧畾鏃ユ湡鏄惁闇�瑕侀噸鏂版墽琛� - * - * @param tableName - * @param date - * @return true 闇�瑕佹墽琛岋紝false 涓嶉渶瑕� - */ - private boolean canGetAgain(String tableName, LocalDate date) { - String sql = "SELECT*FROM (SELECT*FROM ZYYT_RECORD WHERE BATCH_NO='" + ZyytConstant.batchNoPrefix + date + "' AND TABLE_NAME='" + tableName + "' ORDER BY START_TIME DESC) tmp WHERE ROWNUM<=1"; - Map<String, Object> map = null; - try { - map = jdbcTemplate.queryForMap(sql); - } catch (Exception e) { - log.info("sql=={}娌℃湁鏌ヨ鍒版暟鎹�", sql); - } - if (map != null) { - String isFinish = Convert.toStr(map.get("IS_FINISH")); - if (!"1".equals(isFinish)) { - return false; - } - //涓嬮潰 isFinish閮芥槸1 - String isError = Convert.toStr(map.get("IS_ERROR")); - if ("1".equals(isError)) { - // 鎵ц鏈夎 - return true; - } - - // 鎴愬姛鎵ц娌℃湁閿� - String countNum = Convert.toStr(map.get("COUNT_NUM")); - if ("0".equals(countNum)) { - //娌℃湁鎷夊彇鍒版暟鎹� - log.info("stationInfoTask"); - return true; - } - } else { - // 璇ユ壒娆℃湭鎵ц - log.info("stationInfoTask"); - return true; - } - return false; - } } -- Gitblit v1.9.1