Explorar el Código

移除重复的子任务ID拼接

Z-Beatles hace 5 años
padre
commit
34ff10b99e

+ 11 - 21
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java Ver fichero

@@ -91,11 +91,12 @@ public class XxlJobServiceImpl implements XxlJobService {
91 91
 		}
92 92
 
93 93
 		// ChildJobId valid
94
-		if (jobInfo.getChildJobId()!=null && jobInfo.getChildJobId().trim().length()>0) {
95
-			String[] childJobIds = jobInfo.getChildJobId().split(",");
94
+        String childJobId = jobInfo.getChildJobId();
95
+        if (childJobId !=null && childJobId.trim().length()>0) {
96
+			String[] childJobIds = childJobId.split(",");
96 97
 			for (String childJobIdItem: childJobIds) {
97 98
 				if (childJobIdItem!=null && childJobIdItem.trim().length()>0 && isNumeric(childJobIdItem)) {
98
-					XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.valueOf(childJobIdItem));
99
+					XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.parseInt(childJobIdItem));
99 100
 					if (childJobInfo==null) {
100 101
 						return new ReturnT<String>(ReturnT.FAIL_CODE,
101 102
 								MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem));
@@ -106,13 +107,7 @@ public class XxlJobServiceImpl implements XxlJobService {
106 107
 				}
107 108
 			}
108 109
 
109
-			String temp = "";	// join ,
110
-			for (String item:childJobIds) {
111
-				temp += item + ",";
112
-			}
113
-			temp = temp.substring(0, temp.length()-1);
114
-
115
-			jobInfo.setChildJobId(temp);
110
+			jobInfo.setChildJobId(childJobId);
116 111
 		}
117 112
 
118 113
 		// add in db
@@ -154,11 +149,12 @@ public class XxlJobServiceImpl implements XxlJobService {
154 149
 		}
155 150
 
156 151
 		// ChildJobId valid
157
-		if (jobInfo.getChildJobId()!=null && jobInfo.getChildJobId().trim().length()>0) {
158
-			String[] childJobIds = jobInfo.getChildJobId().split(",");
152
+        String childJobId = jobInfo.getChildJobId();
153
+        if (childJobId !=null && childJobId.trim().length()>0) {
154
+			String[] childJobIds = childJobId.split(",");
159 155
 			for (String childJobIdItem: childJobIds) {
160 156
 				if (childJobIdItem!=null && childJobIdItem.trim().length()>0 && isNumeric(childJobIdItem)) {
161
-					XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.valueOf(childJobIdItem));
157
+					XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.parseInt(childJobIdItem));
162 158
 					if (childJobInfo==null) {
163 159
 						return new ReturnT<String>(ReturnT.FAIL_CODE,
164 160
 								MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem));
@@ -169,13 +165,7 @@ public class XxlJobServiceImpl implements XxlJobService {
169 165
 				}
170 166
 			}
171 167
 
172
-			String temp = "";	// join ,
173
-			for (String item:childJobIds) {
174
-				temp += item + ",";
175
-			}
176
-			temp = temp.substring(0, temp.length()-1);
177
-
178
-			jobInfo.setChildJobId(temp);
168
+			jobInfo.setChildJobId(childJobId);
179 169
 		}
180 170
 
181 171
 		// group valid
@@ -216,7 +206,7 @@ public class XxlJobServiceImpl implements XxlJobService {
216 206
 		exists_jobInfo.setExecutorBlockStrategy(jobInfo.getExecutorBlockStrategy());
217 207
 		exists_jobInfo.setExecutorTimeout(jobInfo.getExecutorTimeout());
218 208
 		exists_jobInfo.setExecutorFailRetryCount(jobInfo.getExecutorFailRetryCount());
219
-		exists_jobInfo.setChildJobId(jobInfo.getChildJobId());
209
+		exists_jobInfo.setChildJobId(childJobId);
220 210
 		exists_jobInfo.setTriggerNextTime(nextTriggerTime);
221 211
         xxlJobInfoDao.update(exists_jobInfo);
222 212