Browse Source

系统:定时任务

4.0
郑根木 2 years ago
parent
commit
713d022078
3 changed files with 18 additions and 0 deletions
  1. +3
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/BpmStartedListener.java
  2. +14
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/job/TestJob.java
  3. +1
    -0
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/systask/SingleRequestHelper.java

+ 3
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/BpmStartedListener.java View File

@@ -9,6 +9,7 @@ import cc.smtweb.framework.core.mvc.controller.IStartListener;
import cc.smtweb.framework.core.mvc.service.TreeHelper; import cc.smtweb.framework.core.mvc.service.TreeHelper;
import cc.smtweb.framework.core.systask.SysServiceFactory; import cc.smtweb.framework.core.systask.SysServiceFactory;
import cc.smtweb.system.bpm.web.design.db.ModelCatalogTreeHelper; import cc.smtweb.system.bpm.web.design.db.ModelCatalogTreeHelper;
import cc.smtweb.system.bpm.web.sys.base.job.JobUtils;
import cc.smtweb.system.bpm.web.sys.oneTimeService.OneTimeServiceFactory; import cc.smtweb.system.bpm.web.sys.oneTimeService.OneTimeServiceFactory;
import cc.smtweb.system.bpm.web.sys.oneTimeService.OneTimeTaskCleanService; import cc.smtweb.system.bpm.web.sys.oneTimeService.OneTimeTaskCleanService;


@@ -36,10 +37,12 @@ public class BpmStartedListener implements IStartListener {
//初始化缓存 //初始化缓存
CacheManager.getIntance().init(); CacheManager.getIntance().init();
OneTimeServiceFactory.getInstance().start(); OneTimeServiceFactory.getInstance().start();
JobUtils.getInstance().start();
} }


@Override @Override
public void close() { public void close() {
OneTimeServiceFactory.getInstance().stop(); OneTimeServiceFactory.getInstance().stop();
JobUtils.getInstance().stop();
} }
} }

+ 14
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/job/TestJob.java View File

@@ -0,0 +1,14 @@
package cc.smtweb.system.bpm.web.sys.base.job;

import cc.smtweb.framework.core.util.DateUtil;

/**
* Created by Akmm at 2022-09-14 10:32
*/
public class TestJob extends BaseJob {
@Override
protected String work() {
System.out.println("执行了" + DateUtil.nowDateTimeString());
return "哈哈,成功了";
}
}

+ 1
- 0
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/systask/SingleRequestHelper.java View File

@@ -5,6 +5,7 @@ import cc.smtweb.framework.core.exception.SwException;
import cc.smtweb.framework.core.util.DateUtil; import cc.smtweb.framework.core.util.DateUtil;
import cc.smtweb.framework.core.util.StringUtil; import cc.smtweb.framework.core.util.StringUtil;


//redis控制的互斥执行,一般用于定时任务,避免多服务器重复执行
public class SingleRequestHelper { public class SingleRequestHelper {


public static interface ISingleWork { public static interface ISingleWork {


Loading…
Cancel
Save