1、task异常处理

Former-commit-id: b5d574d05ae6f044dcd54815b49ebe96abe76db8
master
wangbing 4 years ago
parent b2c62e2c76
commit 4106552558

@ -525,7 +525,6 @@ public class SpringBootCallable implements Callable {
File exception = Tool.createPath(excel.getAbsolutePath(), "exception");
File excelstyle = Tool.createPath(excel.getAbsolutePath(), "style");
File schedule = Tool.createPath(root.getAbsolutePath(), "schedule");
File scheduleException = Tool.createPath(schedule.getAbsolutePath(), "exception");
File utils = Tool.createPath(root.getAbsolutePath(), "utils");
File validation = Tool.createPath(root.getAbsolutePath(), "validation");
@ -560,10 +559,6 @@ public class SpringBootCallable implements Callable {
for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/frame/schedule/")) {
freeMarkerManager.outputTemp(Tool.createFile(schedule.getAbsolutePath(), name), "SpringBoot/java/frame/schedule/" + name, ctx);
}
//scheduleException
for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/frame/schedule/exception/")) {
freeMarkerManager.outputTemp(Tool.createFile(scheduleException.getAbsolutePath(), name), "SpringBoot/java/frame/schedule/exception/" + name, ctx);
}
//utils
for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/frame/utils/")) {
@ -682,7 +677,7 @@ public class SpringBootCallable implements Callable {
// }
if (DataBase.SQLite.name().equals(project.getDatabase().name())) {
File dbFile = Tool.createFile(root.getAbsolutePath(), project.getProjectName() + ".db");
File dbFile = Tool.createFile(root.getAbsolutePath(), project.getProjectName() + ".db3");
Connection connection = null;
Statement statement = null;
try {

@ -17,7 +17,7 @@ public class SQLiteConfig {
@PostConstruct
public void generateDB() {
Pattern compile = Pattern.compile("jdbc:sqlite:(.*.db).*");
Pattern compile = Pattern.compile("jdbc:sqlite:(.*.db3).*");
Matcher matcher = compile.matcher(url);
if (matcher.find()) {
String group = matcher.group(1);
@ -25,7 +25,7 @@ public class SQLiteConfig {
if (!file.exists()) {
File path = file.getAbsoluteFile().getParentFile();
if (!path.exists()) path.mkdirs();
ResourceUtil.copyResource2File("${projectName}.db", file);
ResourceUtil.copyResource2File("${projectName}.db3", file);
}
}
}

@ -3,7 +3,6 @@ package ${basePackage}.frame.schedule;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.util.ErrorHandler;
import ${basePackage}.frame.auth.LocalData;
import ${basePackage}.frame.schedule.exception.TaskRunException;
import ${basePackage}.module.system.ent.Schedule;
import ${basePackage}.module.system.mgr.LogErrManager;
@ -12,6 +11,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ScheduledFuture;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Scheduler extends ThreadPoolTaskScheduler implements ErrorHandler {
@ -75,9 +76,15 @@ public class Scheduler extends ThreadPoolTaskScheduler implements ErrorHandler {
@Override
public void handleError(Throwable throwable) {
if (throwable instanceof TaskRunException) {
String message = throwable.getMessage();
Pattern compile = Pattern.compile("(\\[.*])执行异常任务ID(\\(.*\\))");
Matcher matcher = compile.matcher(message);
if (matcher.find()) {
String taskName = matcher.group(1);
String taskId = matcher.group(2);
LogErrManager logErrManager = LocalData.getBean(LogErrManager.class);
if (logErrManager != null) logErrManager.addErr("SYS_ERR", "任务执行错误", "");
if (logErrManager != null)
logErrManager.addErr("SYS_ERR", "任务" + taskName + "执行错误", "任务" + taskName + "执行错误" + "任务ID" + taskId);
}
}

@ -1,26 +0,0 @@
package ${basePackage}.frame.schedule.exception;
/**
*
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class TaskRunException extends RuntimeException {
private String taskId;
public TaskRunException(String s, String taskId) {
super(s);
this.taskId = taskId;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
}

@ -13,7 +13,6 @@ import ${basePackage}.frame.schedule.RunCronTask;
import ${basePackage}.frame.schedule.RunDelayRepeatTask;
import ${basePackage}.frame.schedule.RunFixRepeatTask;
import ${basePackage}.frame.schedule.Scheduler;
import ${basePackage}.frame.schedule.exception.TaskRunException;
import ${basePackage}.frame.utils.IDgenerator;
import ${basePackage}.frame.utils.MapperUtil;
import ${basePackage}.frame.utils.Message;
@ -258,7 +257,7 @@ public class TaskSqlManagerImpl implements TaskSqlManager {
try {
SqlUtil.exec(taskSql.getTaskSql());
} catch (Exception e) {
throw new TaskRunException("SQL任务执行异常", taskId());
throw new RuntimeException(String.format("[%s]执行异常任务ID(%s)", taskName(), taskId()));
}
}
});
@ -286,7 +285,7 @@ public class TaskSqlManagerImpl implements TaskSqlManager {
try {
SqlUtil.exec(taskSql.getTaskSql());
} catch (Exception e) {
throw new TaskRunException("SQL任务执行异常", taskId());
throw new RuntimeException(String.format("[%s]执行异常任务ID(%s)", taskName(), taskId()));
}
}
});
@ -314,7 +313,7 @@ public class TaskSqlManagerImpl implements TaskSqlManager {
try {
SqlUtil.exec(taskSql.getTaskSql());
} catch (Exception e) {
throw new TaskRunException("SQL任务执行异常", taskId());
throw new RuntimeException(String.format("[%s]执行异常任务ID(%s)", taskName(), taskId()));
}
}
});

@ -48,13 +48,13 @@ spring.datasource.two.password=123456
<#if dataBase == 'SQLite'>
# 主数据库
spring.datasource.main.driver-class-name=org.sqlite.JDBC
spring.datasource.main.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.main.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db3?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.main.username=test
spring.datasource.main.password=123456
# 副数据库
spring.datasource.two.driver-class-name=org.sqlite.JDBC
spring.datasource.two.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.two.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db3?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.two.username=test
spring.datasource.two.password=123456
</#if>
@ -75,9 +75,9 @@ spring.datasource.username=test
spring.datasource.password=123456
</#if>
<#if dataBase == 'SQLite'>
# SQLite spring.datasource.url=jdbc:sqlite::resource:example.db
# SQLite spring.datasource.url=jdbc:sqlite::resource:example.db3
spring.datasource.driver-class-name=org.sqlite.JDBC
spring.datasource.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db3?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.username=test
spring.datasource.password=123456
</#if>

@ -48,13 +48,13 @@ spring.datasource.two.password=123456
<#if dataBase == 'SQLite'>
# 主数据库
spring.datasource.main.driver-class-name=org.sqlite.JDBC
spring.datasource.main.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.main.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db3?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.main.username=test
spring.datasource.main.password=123456
# 副数据库
spring.datasource.two.driver-class-name=org.sqlite.JDBC
spring.datasource.two.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.two.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db3?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.two.username=test
spring.datasource.two.password=123456
</#if>
@ -75,9 +75,9 @@ spring.datasource.username=test
spring.datasource.password=123456
</#if>
<#if dataBase == 'SQLite'>
# SQLite spring.datasource.url=jdbc:sqlite::resource:example.db
# SQLite spring.datasource.url=jdbc:sqlite::resource:example.db3
spring.datasource.driver-class-name=org.sqlite.JDBC
spring.datasource.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db3?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.username=test
spring.datasource.password=123456
</#if>

@ -222,7 +222,7 @@
:custom-class="'dialog'"
:title="form.formTitle"
:close-on-click-modal="false"
:visible.sync="form.dialog">
:visible.sync="form.formShow">
<el-form class="form" :model="form" :inline="true" :rules="formRules" ref="form" label-position="right" label-width="90px">
<#list fields as item>
<#if !item.isSystem>

@ -65,11 +65,16 @@
<el-table-column
align="center"
prop="logErrType"
width="90"
label="错误类型">
<template slot-scope="scope">
<el-view-dict v-model="scope.row.logErrType" dict-name="LOG_ERR_TYPE"></el-view-dict>
</template>
</el-table-column>
<el-table-column
align="center"
prop="logTitle"
width="140"
label="错误标题">
</el-table-column>
<el-table-column
@ -80,7 +85,11 @@
<el-table-column
align="center"
prop="logErrResult"
width="80"
label="处理结果">
<template slot-scope="scope">
<el-view-dict v-model="scope.row.logErrResult" dict-name="LOG_ERR_RESULT"></el-view-dict>
</template>
</el-table-column>
<el-table-column
align="center"

@ -48,13 +48,13 @@ spring.datasource.two.password=123456
<#if dataBase == 'SQLite'>
# 主数据库
spring.datasource.main.driver-class-name=org.sqlite.JDBC
spring.datasource.main.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.main.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db3?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.main.username=test
spring.datasource.main.password=123456
# 副数据库
spring.datasource.two.driver-class-name=org.sqlite.JDBC
spring.datasource.two.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.two.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db3?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.two.username=test
spring.datasource.two.password=123456
</#if>
@ -75,9 +75,9 @@ spring.datasource.username=test
spring.datasource.password=123456
</#if>
<#if dataBase == 'SQLite'>
# SQLite spring.datasource.url=jdbc:sqlite::resource:example.db
# SQLite spring.datasource.url=jdbc:sqlite::resource:example.db3
spring.datasource.driver-class-name=org.sqlite.JDBC
spring.datasource.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db3?date_string_format=yyyy-MM-dd HH:mm:ss
spring.datasource.username=test
spring.datasource.password=123456
</#if>

Loading…
Cancel
Save

Powered by TurnKey Linux.