【fix sonar】 XxlJobServiceImpl.java文件
This commit is contained in:
+80
-73
@@ -40,18 +40,25 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
private XxlJobLogGlueDao xxlJobLogGlueDao;
|
private XxlJobLogGlueDao xxlJobLogGlueDao;
|
||||||
@Resource
|
@Resource
|
||||||
private XxlJobLogReportDao xxlJobLogReportDao;
|
private XxlJobLogReportDao xxlJobLogReportDao;
|
||||||
|
|
||||||
|
private String jobinfoFieldCronUnvalid ="jobinfo_field_cron_unvalid";
|
||||||
|
private String systemPleaseInput ="system_please_input";
|
||||||
|
private String jobinfoFieldChildJobId ="jobinfo_field_childJobId";
|
||||||
|
private String systemUnvalid ="system_unvalid";
|
||||||
|
private String systemNotFound ="system_not_found";
|
||||||
|
private String zero ="({0})";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> pageList(int start, int length, int jobGroup, int triggerStatus, String jobDesc, String executorHandler, String author) {
|
public Map<String, Object> pageList(int start, int length, int jobGroup, int triggerStatus, String jobDesc, String executorHandler, String author) {
|
||||||
|
|
||||||
// page list
|
// page list
|
||||||
List<XxlJobInfo> list = xxlJobInfoDao.pageList(start, length, jobGroup, triggerStatus, jobDesc, executorHandler, author);
|
List<XxlJobInfo> list = xxlJobInfoDao.pageList(start, length, jobGroup, triggerStatus, jobDesc, executorHandler, author);
|
||||||
int list_count = xxlJobInfoDao.pageListCount(start, length, jobGroup, triggerStatus, jobDesc, executorHandler, author);
|
int listCount = xxlJobInfoDao.pageListCount(start, length, jobGroup, triggerStatus, jobDesc, executorHandler, author);
|
||||||
|
|
||||||
// package result
|
// package result
|
||||||
Map<String, Object> maps = new HashMap<String, Object>();
|
Map<String, Object> maps = new HashMap<>();
|
||||||
maps.put("recordsTotal", list_count); // 总记录数
|
maps.put("recordsTotal", listCount); // 总记录数
|
||||||
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
|
maps.put("recordsFiltered", listCount); // 过滤后的总记录数
|
||||||
maps.put("data", list); // 分页列表
|
maps.put("data", list); // 分页列表
|
||||||
return maps;
|
return maps;
|
||||||
}
|
}
|
||||||
@@ -61,33 +68,33 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
// valid
|
// valid
|
||||||
XxlJobGroup group = xxlJobGroupDao.load(jobInfo.getJobGroup());
|
XxlJobGroup group = xxlJobGroupDao.load(jobInfo.getJobGroup());
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_choose")+I18nUtil.getString("jobinfo_field_jobgroup")) );
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_choose")+I18nUtil.getString("jobinfo_field_jobgroup")) );
|
||||||
}
|
}
|
||||||
if (!CronExpression.isValidExpression(jobInfo.getJobCron())) {
|
if (!CronExpression.isValidExpression(jobInfo.getJobCron())) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid") );
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString(jobinfoFieldCronUnvalid) );
|
||||||
}
|
}
|
||||||
if (jobInfo.getJobDesc()==null || jobInfo.getJobDesc().trim().length()==0) {
|
if (jobInfo.getJobDesc()==null || jobInfo.getJobDesc().trim().length()==0) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_jobdesc")) );
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString(systemPleaseInput)+I18nUtil.getString("jobinfo_field_jobdesc")) );
|
||||||
}
|
}
|
||||||
if (jobInfo.getAuthor()==null || jobInfo.getAuthor().trim().length()==0) {
|
if (jobInfo.getAuthor()==null || jobInfo.getAuthor().trim().length()==0) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_author")) );
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString(systemPleaseInput)+I18nUtil.getString("jobinfo_field_author")) );
|
||||||
}
|
}
|
||||||
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
|
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy")+I18nUtil.getString("system_unvalid")) );
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy")+I18nUtil.getString(systemUnvalid)) );
|
||||||
}
|
}
|
||||||
if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) {
|
if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy")+I18nUtil.getString("system_unvalid")) );
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy")+I18nUtil.getString(systemUnvalid)) );
|
||||||
}
|
}
|
||||||
if (GlueTypeEnum.match(jobInfo.getGlueType()) == null) {
|
if (GlueTypeEnum.match(jobInfo.getGlueType()) == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_gluetype")+I18nUtil.getString("system_unvalid")) );
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_gluetype")+I18nUtil.getString(systemUnvalid)) );
|
||||||
}
|
}
|
||||||
if (GlueTypeEnum.BEAN==GlueTypeEnum.match(jobInfo.getGlueType()) && (jobInfo.getExecutorHandler()==null || jobInfo.getExecutorHandler().trim().length()==0) ) {
|
if (GlueTypeEnum.BEAN==GlueTypeEnum.match(jobInfo.getGlueType()) && (jobInfo.getExecutorHandler()==null || jobInfo.getExecutorHandler().trim().length()==0) ) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+"JobHandler") );
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString(systemPleaseInput)+"JobHandler") );
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix "\r" in shell
|
// fix "\r" in shell
|
||||||
if (GlueTypeEnum.GLUE_SHELL==GlueTypeEnum.match(jobInfo.getGlueType()) && jobInfo.getGlueSource()!=null) {
|
if (GlueTypeEnum.GLUE_SHELL==GlueTypeEnum.match(jobInfo.getGlueType()) && jobInfo.getGlueSource()!=null) {
|
||||||
jobInfo.setGlueSource(jobInfo.getGlueSource().replaceAll("\r", ""));
|
jobInfo.setGlueSource(jobInfo.getGlueSource().replace("\r", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChildJobId valid
|
// ChildJobId valid
|
||||||
@@ -97,23 +104,23 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
if (childJobIdItem!=null && childJobIdItem.trim().length()>0 && isNumeric(childJobIdItem)) {
|
if (childJobIdItem!=null && childJobIdItem.trim().length()>0 && isNumeric(childJobIdItem)) {
|
||||||
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.parseInt(childJobIdItem));
|
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.parseInt(childJobIdItem));
|
||||||
if (childJobInfo==null) {
|
if (childJobInfo==null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
return new ReturnT<>(ReturnT.FAIL_CODE,
|
||||||
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem));
|
MessageFormat.format((I18nUtil.getString(jobinfoFieldChildJobId)+zero+I18nUtil.getString(systemNotFound)), childJobIdItem));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
return new ReturnT<>(ReturnT.FAIL_CODE,
|
||||||
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_unvalid")), childJobIdItem));
|
MessageFormat.format((I18nUtil.getString(jobinfoFieldChildJobId)+zero+I18nUtil.getString(systemUnvalid)), childJobIdItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// join , avoid "xxx,,"
|
// join , avoid "xxx,,"
|
||||||
String temp = "";
|
StringBuilder temp = new StringBuilder();
|
||||||
for (String item:childJobIds) {
|
for (String item:childJobIds) {
|
||||||
temp += item + ",";
|
temp.append(item).append(",");
|
||||||
}
|
}
|
||||||
temp = temp.substring(0, temp.length()-1);
|
temp = new StringBuilder(temp.substring(0, temp.length() - 1));
|
||||||
|
|
||||||
jobInfo.setChildJobId(temp);
|
jobInfo.setChildJobId(temp.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// add in db
|
// add in db
|
||||||
@@ -122,15 +129,15 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
jobInfo.setGlueUpdatetime(new Date());
|
jobInfo.setGlueUpdatetime(new Date());
|
||||||
xxlJobInfoDao.save(jobInfo);
|
xxlJobInfoDao.save(jobInfo);
|
||||||
if (jobInfo.getId() < 1) {
|
if (jobInfo.getId() < 1) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_add")+I18nUtil.getString("system_fail")) );
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_add")+I18nUtil.getString("system_fail")) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ReturnT<String>(String.valueOf(jobInfo.getId()));
|
return new ReturnT<>(String.valueOf(jobInfo.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNumeric(String str){
|
private boolean isNumeric(String str){
|
||||||
try {
|
try {
|
||||||
int result = Integer.valueOf(str);
|
Integer.valueOf(str);
|
||||||
return true;
|
return true;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
return false;
|
return false;
|
||||||
@@ -142,19 +149,19 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
|
|
||||||
// valid
|
// valid
|
||||||
if (!CronExpression.isValidExpression(jobInfo.getJobCron())) {
|
if (!CronExpression.isValidExpression(jobInfo.getJobCron())) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid") );
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString(jobinfoFieldCronUnvalid) );
|
||||||
}
|
}
|
||||||
if (jobInfo.getJobDesc()==null || jobInfo.getJobDesc().trim().length()==0) {
|
if (jobInfo.getJobDesc()==null || jobInfo.getJobDesc().trim().length()==0) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_jobdesc")) );
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString(systemPleaseInput)+I18nUtil.getString("jobinfo_field_jobdesc")) );
|
||||||
}
|
}
|
||||||
if (jobInfo.getAuthor()==null || jobInfo.getAuthor().trim().length()==0) {
|
if (jobInfo.getAuthor()==null || jobInfo.getAuthor().trim().length()==0) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_author")) );
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString(systemPleaseInput)+I18nUtil.getString("jobinfo_field_author")) );
|
||||||
}
|
}
|
||||||
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
|
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy")+I18nUtil.getString("system_unvalid")) );
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy")+I18nUtil.getString(systemUnvalid)) );
|
||||||
}
|
}
|
||||||
if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) {
|
if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy")+I18nUtil.getString("system_unvalid")) );
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy")+I18nUtil.getString(systemUnvalid)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChildJobId valid
|
// ChildJobId valid
|
||||||
@@ -164,68 +171,68 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
if (childJobIdItem!=null && childJobIdItem.trim().length()>0 && isNumeric(childJobIdItem)) {
|
if (childJobIdItem!=null && childJobIdItem.trim().length()>0 && isNumeric(childJobIdItem)) {
|
||||||
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.parseInt(childJobIdItem));
|
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.parseInt(childJobIdItem));
|
||||||
if (childJobInfo==null) {
|
if (childJobInfo==null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
return new ReturnT<>(ReturnT.FAIL_CODE,
|
||||||
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem));
|
MessageFormat.format((I18nUtil.getString(jobinfoFieldChildJobId)+zero+I18nUtil.getString(systemNotFound)), childJobIdItem));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
return new ReturnT<>(ReturnT.FAIL_CODE,
|
||||||
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_unvalid")), childJobIdItem));
|
MessageFormat.format((I18nUtil.getString(jobinfoFieldChildJobId)+zero+I18nUtil.getString(systemUnvalid)), childJobIdItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// join , avoid "xxx,,"
|
// join , avoid "xxx,,"
|
||||||
String temp = "";
|
StringBuilder temp = new StringBuilder();
|
||||||
for (String item:childJobIds) {
|
for (String item:childJobIds) {
|
||||||
temp += item + ",";
|
temp.append(item).append(",");
|
||||||
}
|
}
|
||||||
temp = temp.substring(0, temp.length()-1);
|
temp = new StringBuilder(temp.substring(0, temp.length() - 1));
|
||||||
|
|
||||||
jobInfo.setChildJobId(temp);
|
jobInfo.setChildJobId(temp.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// group valid
|
// group valid
|
||||||
XxlJobGroup jobGroup = xxlJobGroupDao.load(jobInfo.getJobGroup());
|
XxlJobGroup jobGroup = xxlJobGroupDao.load(jobInfo.getJobGroup());
|
||||||
if (jobGroup == null) {
|
if (jobGroup == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_jobgroup")+I18nUtil.getString("system_unvalid")) );
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_jobgroup")+I18nUtil.getString(systemUnvalid)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// stage job info
|
// stage job info
|
||||||
XxlJobInfo exists_jobInfo = xxlJobInfoDao.loadById(jobInfo.getId());
|
XxlJobInfo existsJobInfo = xxlJobInfoDao.loadById(jobInfo.getId());
|
||||||
if (exists_jobInfo == null) {
|
if (existsJobInfo == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id")+I18nUtil.getString("system_not_found")) );
|
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id")+I18nUtil.getString(systemNotFound)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// next trigger time (5s后生效,避开预读周期)
|
// next trigger time (5s后生效,避开预读周期)
|
||||||
long nextTriggerTime = exists_jobInfo.getTriggerNextTime();
|
long nextTriggerTime = existsJobInfo.getTriggerNextTime();
|
||||||
if (exists_jobInfo.getTriggerStatus() == 1 && !jobInfo.getJobCron().equals(exists_jobInfo.getJobCron()) ) {
|
if (existsJobInfo.getTriggerStatus() == 1 && !jobInfo.getJobCron().equals(existsJobInfo.getJobCron()) ) {
|
||||||
try {
|
try {
|
||||||
Date nextValidTime = new CronExpression(jobInfo.getJobCron()).getNextValidTimeAfter(new Date(System.currentTimeMillis() + JobScheduleHelper.PRE_READ_MS));
|
Date nextValidTime = new CronExpression(jobInfo.getJobCron()).getNextValidTimeAfter(new Date(System.currentTimeMillis() + JobScheduleHelper.PRE_READ_MS));
|
||||||
if (nextValidTime == null) {
|
if (nextValidTime == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_never_fire"));
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_never_fire"));
|
||||||
}
|
}
|
||||||
nextTriggerTime = nextValidTime.getTime();
|
nextTriggerTime = nextValidTime.getTime();
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid")+" | "+ e.getMessage());
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString(jobinfoFieldCronUnvalid)+" | "+ e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exists_jobInfo.setJobGroup(jobInfo.getJobGroup());
|
existsJobInfo.setJobGroup(jobInfo.getJobGroup());
|
||||||
exists_jobInfo.setJobCron(jobInfo.getJobCron());
|
existsJobInfo.setJobCron(jobInfo.getJobCron());
|
||||||
exists_jobInfo.setJobDesc(jobInfo.getJobDesc());
|
existsJobInfo.setJobDesc(jobInfo.getJobDesc());
|
||||||
exists_jobInfo.setAuthor(jobInfo.getAuthor());
|
existsJobInfo.setAuthor(jobInfo.getAuthor());
|
||||||
exists_jobInfo.setAlarmEmail(jobInfo.getAlarmEmail());
|
existsJobInfo.setAlarmEmail(jobInfo.getAlarmEmail());
|
||||||
exists_jobInfo.setExecutorRouteStrategy(jobInfo.getExecutorRouteStrategy());
|
existsJobInfo.setExecutorRouteStrategy(jobInfo.getExecutorRouteStrategy());
|
||||||
exists_jobInfo.setExecutorHandler(jobInfo.getExecutorHandler());
|
existsJobInfo.setExecutorHandler(jobInfo.getExecutorHandler());
|
||||||
exists_jobInfo.setExecutorParam(jobInfo.getExecutorParam());
|
existsJobInfo.setExecutorParam(jobInfo.getExecutorParam());
|
||||||
exists_jobInfo.setExecutorBlockStrategy(jobInfo.getExecutorBlockStrategy());
|
existsJobInfo.setExecutorBlockStrategy(jobInfo.getExecutorBlockStrategy());
|
||||||
exists_jobInfo.setExecutorTimeout(jobInfo.getExecutorTimeout());
|
existsJobInfo.setExecutorTimeout(jobInfo.getExecutorTimeout());
|
||||||
exists_jobInfo.setExecutorFailRetryCount(jobInfo.getExecutorFailRetryCount());
|
existsJobInfo.setExecutorFailRetryCount(jobInfo.getExecutorFailRetryCount());
|
||||||
exists_jobInfo.setChildJobId(jobInfo.getChildJobId());
|
existsJobInfo.setChildJobId(jobInfo.getChildJobId());
|
||||||
exists_jobInfo.setTriggerNextTime(nextTriggerTime);
|
existsJobInfo.setTriggerNextTime(nextTriggerTime);
|
||||||
|
|
||||||
exists_jobInfo.setUpdateTime(new Date());
|
existsJobInfo.setUpdateTime(new Date());
|
||||||
xxlJobInfoDao.update(exists_jobInfo);
|
xxlJobInfoDao.update(existsJobInfo);
|
||||||
|
|
||||||
|
|
||||||
return ReturnT.SUCCESS;
|
return ReturnT.SUCCESS;
|
||||||
@@ -253,12 +260,12 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
try {
|
try {
|
||||||
Date nextValidTime = new CronExpression(xxlJobInfo.getJobCron()).getNextValidTimeAfter(new Date(System.currentTimeMillis() + JobScheduleHelper.PRE_READ_MS));
|
Date nextValidTime = new CronExpression(xxlJobInfo.getJobCron()).getNextValidTimeAfter(new Date(System.currentTimeMillis() + JobScheduleHelper.PRE_READ_MS));
|
||||||
if (nextValidTime == null) {
|
if (nextValidTime == null) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_never_fire"));
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_never_fire"));
|
||||||
}
|
}
|
||||||
nextTriggerTime = nextValidTime.getTime();
|
nextTriggerTime = nextValidTime.getTime();
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid")+" | "+ e.getMessage());
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString(jobinfoFieldCronUnvalid)+" | "+ e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
xxlJobInfo.setTriggerStatus(1);
|
xxlJobInfo.setTriggerStatus(1);
|
||||||
@@ -296,7 +303,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// executor count
|
// executor count
|
||||||
Set<String> executorAddressSet = new HashSet<String>();
|
Set<String> executorAddressSet = new HashSet<>();
|
||||||
List<XxlJobGroup> groupList = xxlJobGroupDao.findAll();
|
List<XxlJobGroup> groupList = xxlJobGroupDao.findAll();
|
||||||
|
|
||||||
if (groupList!=null && !groupList.isEmpty()) {
|
if (groupList!=null && !groupList.isEmpty()) {
|
||||||
@@ -309,7 +316,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
|
|
||||||
int executorCount = executorAddressSet.size();
|
int executorCount = executorAddressSet.size();
|
||||||
|
|
||||||
Map<String, Object> dashboardMap = new HashMap<String, Object>();
|
Map<String, Object> dashboardMap = new HashMap<>();
|
||||||
dashboardMap.put("jobInfoCount", jobInfoCount);
|
dashboardMap.put("jobInfoCount", jobInfoCount);
|
||||||
dashboardMap.put("jobLogCount", jobLogCount);
|
dashboardMap.put("jobLogCount", jobLogCount);
|
||||||
dashboardMap.put("jobLogSuccessCount", jobLogSuccessCount);
|
dashboardMap.put("jobLogSuccessCount", jobLogSuccessCount);
|
||||||
@@ -321,17 +328,17 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
public ReturnT<Map<String, Object>> chartInfo(Date startDate, Date endDate) {
|
public ReturnT<Map<String, Object>> chartInfo(Date startDate, Date endDate) {
|
||||||
|
|
||||||
// process
|
// process
|
||||||
List<String> triggerDayList = new ArrayList<String>();
|
List<String> triggerDayList = new ArrayList<>();
|
||||||
List<Integer> triggerDayCountRunningList = new ArrayList<Integer>();
|
List<Integer> triggerDayCountRunningList = new ArrayList<>();
|
||||||
List<Integer> triggerDayCountSucList = new ArrayList<Integer>();
|
List<Integer> triggerDayCountSucList = new ArrayList<>();
|
||||||
List<Integer> triggerDayCountFailList = new ArrayList<Integer>();
|
List<Integer> triggerDayCountFailList = new ArrayList<>();
|
||||||
int triggerCountRunningTotal = 0;
|
int triggerCountRunningTotal = 0;
|
||||||
int triggerCountSucTotal = 0;
|
int triggerCountSucTotal = 0;
|
||||||
int triggerCountFailTotal = 0;
|
int triggerCountFailTotal = 0;
|
||||||
|
|
||||||
List<XxlJobLogReport> logReportList = xxlJobLogReportDao.queryLogReport(startDate, endDate);
|
List<XxlJobLogReport> logReportList = xxlJobLogReportDao.queryLogReport(startDate, endDate);
|
||||||
|
|
||||||
if (logReportList!=null && logReportList.size()>0) {
|
if (logReportList!=null && !logReportList.isEmpty()) {
|
||||||
for (XxlJobLogReport item: logReportList) {
|
for (XxlJobLogReport item: logReportList) {
|
||||||
String day = DateUtil.formatDate(item.getTriggerDay());
|
String day = DateUtil.formatDate(item.getTriggerDay());
|
||||||
int triggerDayCountRunning = item.getRunningCount();
|
int triggerDayCountRunning = item.getRunningCount();
|
||||||
@@ -356,7 +363,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<String, Object>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
result.put("triggerDayList", triggerDayList);
|
result.put("triggerDayList", triggerDayList);
|
||||||
result.put("triggerDayCountRunningList", triggerDayCountRunningList);
|
result.put("triggerDayCountRunningList", triggerDayCountRunningList);
|
||||||
result.put("triggerDayCountSucList", triggerDayCountSucList);
|
result.put("triggerDayCountSucList", triggerDayCountSucList);
|
||||||
@@ -366,7 +373,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
result.put("triggerCountSucTotal", triggerCountSucTotal);
|
result.put("triggerCountSucTotal", triggerCountSucTotal);
|
||||||
result.put("triggerCountFailTotal", triggerCountFailTotal);
|
result.put("triggerCountFailTotal", triggerCountFailTotal);
|
||||||
|
|
||||||
return new ReturnT<Map<String, Object>>(result);
|
return new ReturnT<>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user