|
|
@@ -13,9 +13,7 @@ import com.xxl.job.admin.service.XxlJobService;
|
|
13
|
13
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
14
|
14
|
import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
|
|
15
|
15
|
import com.xxl.job.core.glue.GlueTypeEnum;
|
|
16
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
17
|
|
-import org.apache.commons.lang3.time.DateUtils;
|
|
18
|
|
-import org.apache.commons.lang3.time.FastDateFormat;
|
|
|
16
|
+import com.xxl.job.core.util.DateUtil;
|
|
19
|
17
|
import org.quartz.CronExpression;
|
|
20
|
18
|
import org.quartz.SchedulerException;
|
|
21
|
19
|
import org.slf4j.Logger;
|
|
|
@@ -75,10 +73,10 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
75
|
73
|
if (!CronExpression.isValidExpression(jobInfo.getJobCron())) {
|
|
76
|
74
|
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid") );
|
|
77
|
75
|
}
|
|
78
|
|
- if (StringUtils.isBlank(jobInfo.getJobDesc())) {
|
|
|
76
|
+ if (jobInfo.getJobDesc()==null || jobInfo.getJobDesc().trim().length()==0) {
|
|
79
|
77
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_jobdesc")) );
|
|
80
|
78
|
}
|
|
81
|
|
- if (StringUtils.isBlank(jobInfo.getAuthor())) {
|
|
|
79
|
+ if (jobInfo.getAuthor()==null || jobInfo.getAuthor().trim().length()==0) {
|
|
82
|
80
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_author")) );
|
|
83
|
81
|
}
|
|
84
|
82
|
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
|
|
|
@@ -90,7 +88,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
90
|
88
|
if (GlueTypeEnum.match(jobInfo.getGlueType()) == null) {
|
|
91
|
89
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_gluetype")+I18nUtil.getString("system_unvalid")) );
|
|
92
|
90
|
}
|
|
93
|
|
- if (GlueTypeEnum.BEAN==GlueTypeEnum.match(jobInfo.getGlueType()) && StringUtils.isBlank(jobInfo.getExecutorHandler())) {
|
|
|
91
|
+ if (GlueTypeEnum.BEAN==GlueTypeEnum.match(jobInfo.getGlueType()) && (jobInfo.getExecutorHandler()==null || jobInfo.getExecutorHandler().trim().length()==0) ) {
|
|
94
|
92
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+"JobHandler") );
|
|
95
|
93
|
}
|
|
96
|
94
|
|
|
|
@@ -100,10 +98,10 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
100
|
98
|
}
|
|
101
|
99
|
|
|
102
|
100
|
// ChildJobId valid
|
|
103
|
|
- if (StringUtils.isNotBlank(jobInfo.getChildJobId())) {
|
|
104
|
|
- String[] childJobIds = StringUtils.split(jobInfo.getChildJobId(), ",");
|
|
|
101
|
+ if (jobInfo.getChildJobId()!=null && jobInfo.getChildJobId().trim().length()>0) {
|
|
|
102
|
+ String[] childJobIds = jobInfo.getChildJobId().split(",");
|
|
105
|
103
|
for (String childJobIdItem: childJobIds) {
|
|
106
|
|
- if (StringUtils.isNotBlank(childJobIdItem) && StringUtils.isNumeric(childJobIdItem)) {
|
|
|
104
|
+ if (childJobIdItem!=null && childJobIdItem.trim().length()>0 && isNumeric(childJobIdItem)) {
|
|
107
|
105
|
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.valueOf(childJobIdItem));
|
|
108
|
106
|
if (childJobInfo==null) {
|
|
109
|
107
|
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
|
|
@@ -114,7 +112,14 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
114
|
112
|
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_unvalid")), childJobIdItem));
|
|
115
|
113
|
}
|
|
116
|
114
|
}
|
|
117
|
|
- jobInfo.setChildJobId(StringUtils.join(childJobIds, ","));
|
|
|
115
|
+
|
|
|
116
|
+ String temp = ""; // join ,
|
|
|
117
|
+ for (String item:childJobIds) {
|
|
|
118
|
+ temp += item + ",";
|
|
|
119
|
+ }
|
|
|
120
|
+ temp = temp.substring(0, temp.length()-1);
|
|
|
121
|
+
|
|
|
122
|
+ jobInfo.setChildJobId(temp);
|
|
118
|
123
|
}
|
|
119
|
124
|
|
|
120
|
125
|
// add in db
|
|
|
@@ -126,6 +131,15 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
126
|
131
|
return new ReturnT<String>(String.valueOf(jobInfo.getId()));
|
|
127
|
132
|
}
|
|
128
|
133
|
|
|
|
134
|
+ private boolean isNumeric(String str){
|
|
|
135
|
+ try {
|
|
|
136
|
+ int result = Integer.valueOf(str);
|
|
|
137
|
+ return true;
|
|
|
138
|
+ } catch (NumberFormatException e) {
|
|
|
139
|
+ return false;
|
|
|
140
|
+ }
|
|
|
141
|
+ }
|
|
|
142
|
+
|
|
129
|
143
|
@Override
|
|
130
|
144
|
public ReturnT<String> update(XxlJobInfo jobInfo) {
|
|
131
|
145
|
|
|
|
@@ -133,10 +147,10 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
133
|
147
|
if (!CronExpression.isValidExpression(jobInfo.getJobCron())) {
|
|
134
|
148
|
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid") );
|
|
135
|
149
|
}
|
|
136
|
|
- if (StringUtils.isBlank(jobInfo.getJobDesc())) {
|
|
|
150
|
+ if (jobInfo.getJobDesc()==null || jobInfo.getJobDesc().trim().length()==0) {
|
|
137
|
151
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_jobdesc")) );
|
|
138
|
152
|
}
|
|
139
|
|
- if (StringUtils.isBlank(jobInfo.getAuthor())) {
|
|
|
153
|
+ if (jobInfo.getAuthor()==null || jobInfo.getAuthor().trim().length()==0) {
|
|
140
|
154
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_author")) );
|
|
141
|
155
|
}
|
|
142
|
156
|
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
|
|
|
@@ -147,10 +161,10 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
147
|
161
|
}
|
|
148
|
162
|
|
|
149
|
163
|
// ChildJobId valid
|
|
150
|
|
- if (StringUtils.isNotBlank(jobInfo.getChildJobId())) {
|
|
151
|
|
- String[] childJobIds = StringUtils.split(jobInfo.getChildJobId(), ",");
|
|
|
164
|
+ if (jobInfo.getChildJobId()!=null && jobInfo.getChildJobId().trim().length()>0) {
|
|
|
165
|
+ String[] childJobIds = jobInfo.getChildJobId().split(",");
|
|
152
|
166
|
for (String childJobIdItem: childJobIds) {
|
|
153
|
|
- if (StringUtils.isNotBlank(childJobIdItem) && StringUtils.isNumeric(childJobIdItem)) {
|
|
|
167
|
+ if (childJobIdItem!=null && childJobIdItem.trim().length()>0 && isNumeric(childJobIdItem)) {
|
|
154
|
168
|
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.valueOf(childJobIdItem));
|
|
155
|
169
|
if (childJobInfo==null) {
|
|
156
|
170
|
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
|
|
@@ -161,7 +175,14 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
161
|
175
|
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_unvalid")), childJobIdItem));
|
|
162
|
176
|
}
|
|
163
|
177
|
}
|
|
164
|
|
- jobInfo.setChildJobId(StringUtils.join(childJobIds, ","));
|
|
|
178
|
+
|
|
|
179
|
+ String temp = ""; // join ,
|
|
|
180
|
+ for (String item:childJobIds) {
|
|
|
181
|
+ temp += item + ",";
|
|
|
182
|
+ }
|
|
|
183
|
+ temp = temp.substring(0, temp.length()-1);
|
|
|
184
|
+
|
|
|
185
|
+ jobInfo.setChildJobId(temp);
|
|
165
|
186
|
}
|
|
166
|
187
|
|
|
167
|
188
|
// group valid
|
|
|
@@ -348,7 +369,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
348
|
369
|
}
|
|
349
|
370
|
} else {
|
|
350
|
371
|
for (int i = 4; i > -1; i--) {
|
|
351
|
|
- triggerDayList.add(FastDateFormat.getInstance("yyyy-MM-dd").format(DateUtils.addDays(new Date(), -i)));
|
|
|
372
|
+ triggerDayList.add(DateUtil.formatDate(DateUtil.addDays(new Date(), -i)));
|
|
352
|
373
|
triggerDayCountRunningList.add(0);
|
|
353
|
374
|
triggerDayCountSucList.add(0);
|
|
354
|
375
|
triggerDayCountFailList.add(0);
|