Java Code Examples for com.ruoyi.common.utils.ExceptionUtil

The following examples show how to use com.ruoyi.common.utils.ExceptionUtil. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: RuoYi   Source File: AbstractQuartzJob.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 执行后
 *
 * @param context        工作执行上下文对象
 */
protected void after(JobExecutionContext context, SysJob sysJob, Exception e) {
    Date startTime = threadLocal.get();
    threadLocal.remove();

    final SysJobLog sysJobLog = new SysJobLog();
    sysJobLog.setJobName(sysJob.getJobName());
    sysJobLog.setJobGroup(sysJob.getJobGroup());
    sysJobLog.setMethodName(sysJob.getMethodName());
    sysJobLog.setMethodParams(sysJob.getMethodParams());
    sysJobLog.setStartTime(startTime);
    sysJobLog.setEndTime(new Date());
    long runMs = sysJobLog.getEndTime().getTime() - sysJobLog.getStartTime().getTime();
    sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒");
    if (e != null) {
        sysJobLog.setStatus(Constants.FAIL);
        String errorMsg = StrUtil.sub(ExceptionUtil.getExceptionMessage(e), 0, 2000);
        sysJobLog.setExceptionInfo(errorMsg);
    } else {
        sysJobLog.setStatus(Constants.SUCCESS);
    }

    // 写入数据库当中
    SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog);
}
 
Example 2
Source Project: supplierShop   Source File: AbstractQuartzJob.java    License: MIT License 5 votes vote down vote up
/**
 * 执行后
 *
 * @param context 工作执行上下文对象
 * @param sysScheduleJob 系统计划任务
 */
protected void after(JobExecutionContext context, SysJob sysJob, Exception e)
{
    Date startTime = threadLocal.get();
    threadLocal.remove();

    final SysJobLog sysJobLog = new SysJobLog();
    sysJobLog.setJobName(sysJob.getJobName());
    sysJobLog.setJobGroup(sysJob.getJobGroup());
    sysJobLog.setInvokeTarget(sysJob.getInvokeTarget());
    sysJobLog.setStartTime(startTime);
    sysJobLog.setEndTime(new Date());
    long runMs = sysJobLog.getEndTime().getTime() - sysJobLog.getStartTime().getTime();
    sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒");
    if (e != null)
    {
        sysJobLog.setStatus(Constants.FAIL);
        String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000);
        sysJobLog.setExceptionInfo(errorMsg);
    }
    else
    {
        sysJobLog.setStatus(Constants.SUCCESS);
    }

    // 写入数据库当中
    SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog);
}
 
Example 3
Source Project: RuoYi-Vue   Source File: AbstractQuartzJob.java    License: MIT License 5 votes vote down vote up
/**
 * 执行后
 *
 * @param context 工作执行上下文对象
 * @param sysScheduleJob 系统计划任务
 */
protected void after(JobExecutionContext context, SysJob sysJob, Exception e)
{
    Date startTime = threadLocal.get();
    threadLocal.remove();

    final SysJobLog sysJobLog = new SysJobLog();
    sysJobLog.setJobName(sysJob.getJobName());
    sysJobLog.setJobGroup(sysJob.getJobGroup());
    sysJobLog.setInvokeTarget(sysJob.getInvokeTarget());
    sysJobLog.setStartTime(startTime);
    sysJobLog.setStopTime(new Date());
    long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime();
    sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒");
    if (e != null)
    {
        sysJobLog.setStatus(Constants.FAIL);
        String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000);
        sysJobLog.setExceptionInfo(errorMsg);
    }
    else
    {
        sysJobLog.setStatus(Constants.SUCCESS);
    }

    // 写入数据库当中
    SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog);
}