|
|
@@ -5,6 +5,7 @@ import com.xxl.job.admin.core.model.XxlJobGroup;
|
|
5
|
5
|
import com.xxl.job.admin.core.model.XxlJobInfo;
|
|
6
|
6
|
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum;
|
|
7
|
7
|
import com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler;
|
|
|
8
|
+import com.xxl.job.admin.core.util.I18nUtil;
|
|
8
|
9
|
import com.xxl.job.admin.dao.XxlJobGroupDao;
|
|
9
|
10
|
import com.xxl.job.admin.dao.XxlJobInfoDao;
|
|
10
|
11
|
import com.xxl.job.admin.dao.XxlJobLogDao;
|
|
|
@@ -71,31 +72,31 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
71
|
72
|
// valid
|
|
72
|
73
|
XxlJobGroup group = xxlJobGroupDao.load(jobInfo.getJobGroup());
|
|
73
|
74
|
if (group == null) {
|
|
74
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "请选择“执行器”");
|
|
|
75
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_choose")+I18nUtil.getString("jobinfo_field_jobgroup")) );
|
|
75
|
76
|
}
|
|
76
|
77
|
if (!CronExpression.isValidExpression(jobInfo.getJobCron())) {
|
|
77
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "请输入格式正确的“Cron”");
|
|
|
78
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid") );
|
|
78
|
79
|
}
|
|
79
|
80
|
if (StringUtils.isBlank(jobInfo.getJobDesc())) {
|
|
80
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "请输入“任务描述”");
|
|
|
81
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_jobdesc")) );
|
|
81
|
82
|
}
|
|
82
|
83
|
if (StringUtils.isBlank(jobInfo.getAuthor())) {
|
|
83
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "请输入“负责人”");
|
|
|
84
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_author")) );
|
|
84
|
85
|
}
|
|
85
|
86
|
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
|
|
86
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "路由策略非法");
|
|
|
87
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy")+I18nUtil.getString("system_unvalid")) );
|
|
87
|
88
|
}
|
|
88
|
89
|
if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) {
|
|
89
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "阻塞处理策略非法");
|
|
|
90
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy")+I18nUtil.getString("system_unvalid")) );
|
|
90
|
91
|
}
|
|
91
|
92
|
if (ExecutorFailStrategyEnum.match(jobInfo.getExecutorFailStrategy(), null) == null) {
|
|
92
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "失败处理策略非法");
|
|
|
93
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorFailStrategy")+I18nUtil.getString("system_unvalid")) );
|
|
93
|
94
|
}
|
|
94
|
95
|
if (GlueTypeEnum.match(jobInfo.getGlueType()) == null) {
|
|
95
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "运行模式非法非法");
|
|
|
96
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_gluetype")+I18nUtil.getString("system_unvalid")) );
|
|
96
|
97
|
}
|
|
97
|
98
|
if (GlueTypeEnum.BEAN==GlueTypeEnum.match(jobInfo.getGlueType()) && StringUtils.isBlank(jobInfo.getExecutorHandler())) {
|
|
98
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "请输入“JobHandler”");
|
|
|
99
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+"JobHandler") );
|
|
99
|
100
|
}
|
|
100
|
101
|
|
|
101
|
102
|
// fix "\r" in shell
|
|
|
@@ -110,10 +111,12 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
110
|
111
|
if (StringUtils.isNotBlank(childJobIdItem) && StringUtils.isNumeric(childJobIdItem)) {
|
|
111
|
112
|
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.valueOf(childJobIdItem));
|
|
112
|
113
|
if (childJobInfo==null) {
|
|
113
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format("子任务ID({0})无效", childJobIdItem));
|
|
|
114
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE,
|
|
|
115
|
+ MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem));
|
|
114
|
116
|
}
|
|
115
|
117
|
} else {
|
|
116
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format("子任务ID({0})格式错误", childJobIdItem));
|
|
|
118
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE,
|
|
|
119
|
+ MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_unvalid")), childJobIdItem));
|
|
117
|
120
|
}
|
|
118
|
121
|
}
|
|
119
|
122
|
jobInfo.setChildJobId(StringUtils.join(childJobIds, ","));
|
|
|
@@ -122,7 +125,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
122
|
125
|
// add in db
|
|
123
|
126
|
xxlJobInfoDao.save(jobInfo);
|
|
124
|
127
|
if (jobInfo.getId() < 1) {
|
|
125
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "新增任务失败");
|
|
|
128
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_add")+I18nUtil.getString("system_fail")) );
|
|
126
|
129
|
}
|
|
127
|
130
|
|
|
128
|
131
|
// add in quartz
|
|
|
@@ -140,7 +143,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
140
|
143
|
} catch (SchedulerException e1) {
|
|
141
|
144
|
logger.error(e.getMessage(), e1);
|
|
142
|
145
|
}
|
|
143
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "新增任务失败:" + e.getMessage());
|
|
|
146
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_add")+I18nUtil.getString("system_fail"))+":" + e.getMessage());
|
|
144
|
147
|
}
|
|
145
|
148
|
}
|
|
146
|
149
|
|
|
|
@@ -149,22 +152,22 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
149
|
152
|
|
|
150
|
153
|
// valid
|
|
151
|
154
|
if (!CronExpression.isValidExpression(jobInfo.getJobCron())) {
|
|
152
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "请输入格式正确的“Cron”");
|
|
|
155
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid") );
|
|
153
|
156
|
}
|
|
154
|
157
|
if (StringUtils.isBlank(jobInfo.getJobDesc())) {
|
|
155
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "请输入“任务描述”");
|
|
|
158
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_jobdesc")) );
|
|
156
|
159
|
}
|
|
157
|
160
|
if (StringUtils.isBlank(jobInfo.getAuthor())) {
|
|
158
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "请输入“负责人”");
|
|
|
161
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_author")) );
|
|
159
|
162
|
}
|
|
160
|
163
|
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
|
|
161
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "路由策略非法");
|
|
|
164
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy")+I18nUtil.getString("system_unvalid")) );
|
|
162
|
165
|
}
|
|
163
|
166
|
if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) {
|
|
164
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "阻塞处理策略非法");
|
|
|
167
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy")+I18nUtil.getString("system_unvalid")) );
|
|
165
|
168
|
}
|
|
166
|
169
|
if (ExecutorFailStrategyEnum.match(jobInfo.getExecutorFailStrategy(), null) == null) {
|
|
167
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "失败处理策略非法");
|
|
|
170
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorFailStrategy")+I18nUtil.getString("system_unvalid")));
|
|
168
|
171
|
}
|
|
169
|
172
|
|
|
170
|
173
|
// ChildJobId valid
|
|
|
@@ -174,14 +177,16 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
174
|
177
|
if (StringUtils.isNotBlank(childJobIdItem) && StringUtils.isNumeric(childJobIdItem)) {
|
|
175
|
178
|
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.valueOf(childJobIdItem));
|
|
176
|
179
|
if (childJobInfo==null) {
|
|
177
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format("子任务ID({0})无效", childJobIdItem));
|
|
|
180
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE,
|
|
|
181
|
+ MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem));
|
|
178
|
182
|
}
|
|
179
|
183
|
// avoid cycle relate
|
|
180
|
184
|
if (childJobInfo.getId() == jobInfo.getId()) {
|
|
181
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format("子任务ID({0})不可与父任务重复", childJobIdItem));
|
|
|
185
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format(I18nUtil.getString("jobinfo_field_childJobId_limit"), childJobIdItem));
|
|
182
|
186
|
}
|
|
183
|
187
|
} else {
|
|
184
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, MessageFormat.format("子任务ID({0})格式错误", childJobIdItem));
|
|
|
188
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE,
|
|
|
189
|
+ MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_unvalid")), childJobIdItem));
|
|
185
|
190
|
}
|
|
186
|
191
|
}
|
|
187
|
192
|
jobInfo.setChildJobId(StringUtils.join(childJobIds, ","));
|
|
|
@@ -190,7 +195,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
190
|
195
|
// stage job info
|
|
191
|
196
|
XxlJobInfo exists_jobInfo = xxlJobInfoDao.loadById(jobInfo.getId());
|
|
192
|
197
|
if (exists_jobInfo == null) {
|
|
193
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "参数异常");
|
|
|
198
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id")+I18nUtil.getString("system_not_found")) );
|
|
194
|
199
|
}
|
|
195
|
200
|
//String old_cron = exists_jobInfo.getJobCron();
|
|
196
|
201
|
|
|
|
@@ -271,7 +276,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
271
|
276
|
public ReturnT<String> triggerJob(int id) {
|
|
272
|
277
|
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
|
|
273
|
278
|
if (xxlJobInfo == null) {
|
|
274
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "任务ID非法");
|
|
|
279
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id")+I18nUtil.getString("system_unvalid")) );
|
|
275
|
280
|
}
|
|
276
|
281
|
|
|
277
|
282
|
String group = String.valueOf(xxlJobInfo.getJobGroup());
|