定时任务支持并发控制

This commit is contained in:
RuoYi
2019-03-13 19:45:12 +08:00
parent 9fc42511c6
commit e34b4ea63d
24 changed files with 430 additions and 300 deletions

View File

@ -22,7 +22,7 @@ public class Global
/**
* 当前对象实例
*/
private static Global global = null;
private static Global global;
/**
* 保存全局属性值
@ -34,18 +34,13 @@ public class Global
}
/**
* 静态工厂方法 获取当前对象实例 多线程安全单例模式(使用双重同步锁)
* 静态工厂方法
*/
public static synchronized Global getInstance()
{
if (global == null)
{
synchronized (Global.class)
{
if (global == null)
global = new Global();
}
global = new Global();
}
return global;
}

View File

@ -7,9 +7,10 @@ package com.ruoyi.common.constant;
*/
public interface ScheduleConstants
{
public static final String TASK_CLASS_NAME = "__TASK_CLASS_NAME__";
public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME";
public static final String TASK_PROPERTIES = "__TASK_PROPERTIES__";
/** 执行目标key */
public static final String TASK_PROPERTIES = "TASK_PROPERTIES";
/** 默认 */
public static final String MISFIRE_DEFAULT = "0";

View File

@ -223,6 +223,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
{
return endArray(matcher.group(1), matcher.group(2), new EndArrayCallback<Object>()
{
@Override
public Object callback(JSONArray arr, int index)
{
return elementAt(arr, index);
@ -257,6 +258,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
{
endArray(matcher.group(1), matcher.group(2), new EndArrayCallback<Void>()
{
@Override
public Void callback(JSONArray arr, int index)
{
elementAt(arr, index, value);
@ -285,6 +287,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
{
return endArray(matcher.group(1), matcher.group(2), new EndArrayCallback<JSONObject>()
{
@Override
public JSONObject callback(JSONArray arr, int index)
{
return objAt(arr, index);

View File

@ -0,0 +1,41 @@
package com.ruoyi.common.utils;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.apache.commons.lang3.exception.ExceptionUtils;
/**
* 错误信息处理类。
*
* @author ruoyi
*/
public class ExceptionUtil
{
/**
* 获取exception的详细错误信息。
*/
public static String getExceptionMessage(Throwable e)
{
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw, true));
String str = sw.toString();
return str;
}
public static String getRootErrorMseeage(Exception e)
{
Throwable root = ExceptionUtils.getRootCause(e);
root = (root == null ? e : root);
if (root == null)
{
return "";
}
String msg = root.getMessage();
if (msg == null)
{
return "null";
}
return StringUtils.defaultString(msg);
}
}

View File

@ -40,7 +40,7 @@ public class YamlUtil
if (map != null && !map.isEmpty() && qualifiedKey != null)
{
String input = String.valueOf(qualifiedKey);
if (!input.equals(""))
if (!"".equals(input))
{
if (input.contains("."))
{

View File

@ -647,7 +647,9 @@ public class ExcelUtil<T>
{
tempClass = tempClass.getSuperclass();
if (tempClass != null)
{
tempFields.addAll(Arrays.asList(tempClass.getDeclaredFields()));
}
}
putToFields(tempFields);
}