diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTransInit.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTransInit.java index 6fae111..8f1c396 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTransInit.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleTransInit.java @@ -11,12 +11,15 @@ import org.jeecg.modules.ocr.entity.OcrIdentify; import org.jeecg.modules.ocr.model.TaskModel; import org.jeecg.modules.ocr.service.IOcrIdentifyService; import org.jeecg.modules.ocr.service.impl.TaskService; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.Async; import javax.annotation.Resource; +import java.net.InetAddress; +import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -36,44 +39,47 @@ public class HandleTransInit implements ApplicationRunner { TaskService taskService; @Resource IOcrIdentifyService ocrIdentifyService; - + @Value("${enableHandleTask}") + private boolean enableHandleTask; public static void main(String[] args) { } /** - * 处理转账数据 * * @param args */ @Override @Async - public void run(ApplicationArguments args) { - try { - Thread.sleep(5000l); - } catch (InterruptedException e) { - e.printStackTrace(); - } - while (true) { + public void run(ApplicationArguments args) throws UnknownHostException { + if (enableHandleTask) { try { - Thread.sleep(10000l); + Thread.sleep(5000l); } catch (InterruptedException e) { e.printStackTrace(); } + while (true) { + try { + Thread.sleep(10000l); + } catch (InterruptedException e) { + e.printStackTrace(); + } - log.info("---------检测是否有任务..."); - List taskList = taskService.getTaskList(); - if (taskList.size()==0) { - continue; - } - for (TaskModel taskModel : taskList) { - //刷新redis,执行中 - flushTask(taskModel.getTaskId(), 1); - //执行 - executeTaskp(taskModel); - //刷新待运行任务 - log.error("任务已执行:"+taskModel.getTaskId()); + log.info("---------检测是否有任务..."); + List taskList = taskService.getTaskList(); + if (taskList.size()==0) { + continue; + } + for (TaskModel taskModel : taskList) { + //刷新redis,执行中 + flushTask(taskModel.getTaskId(), 1); + //执行 + executeTaskp(taskModel); + //刷新待运行任务 + log.error("任务已执行:"+taskModel.getTaskId()); + } } } + } /** diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/application.yml b/jeecg-module-system/jeecg-system-start/src/main/resources/application.yml index 678c3e7..3fb2774 100644 --- a/jeecg-module-system/jeecg-system-start/src/main/resources/application.yml +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/application.yml @@ -3,4 +3,5 @@ spring: name: jeecg-system profiles: # active: '@profile.name@' - active: dev \ No newline at end of file + active: dev +enableHandleTask: false \ No newline at end of file