|
|
@ -35,22 +35,22 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(XxlJobServiceImpl.class);
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(XxlJobServiceImpl.class);
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private XxlJobGroupMapper xxlJobGroupDao;
|
|
|
|
private XxlJobGroupMapper xxlJobGroupMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private XxlJobInfoMapper xxlJobInfoDao;
|
|
|
|
private XxlJobInfoMapper xxlJobInfoMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
public XxlJobLogMapper xxlJobLogDao;
|
|
|
|
public XxlJobLogMapper xxlJobLogMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private XxlJobLogGlueMapper xxlJobLogGlueDao;
|
|
|
|
private XxlJobLogGlueMapper xxlJobLogGlueMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private XxlJobLogReportMapper xxlJobLogReportDao;
|
|
|
|
private XxlJobLogReportMapper xxlJobLogReportMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@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 = xxlJobInfoMapper.pageList(start, length, jobGroup, triggerStatus, jobDesc, executorHandler, author);
|
|
|
|
int list_count = xxlJobInfoDao.pageListCount(start, length, jobGroup, triggerStatus, jobDesc, executorHandler, author);
|
|
|
|
int list_count = xxlJobInfoMapper.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<String, Object>();
|
|
|
@ -64,7 +64,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
public ReturnT<String> add(XxlJobInfo jobInfo, XxlJobUser loginUser) {
|
|
|
|
public ReturnT<String> add(XxlJobInfo jobInfo, XxlJobUser loginUser) {
|
|
|
|
|
|
|
|
|
|
|
|
// valid base
|
|
|
|
// valid base
|
|
|
|
XxlJobGroup group = xxlJobGroupDao.load(jobInfo.getJobGroup());
|
|
|
|
XxlJobGroup group = xxlJobGroupMapper.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<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_choose")+I18nUtil.getString("jobinfo_field_jobgroup")) );
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -126,7 +126,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
String[] childJobIds = jobInfo.getChildJobId().split(",");
|
|
|
|
String[] childJobIds = jobInfo.getChildJobId().split(",");
|
|
|
|
for (String childJobIdItem: childJobIds) {
|
|
|
|
for (String childJobIdItem: childJobIds) {
|
|
|
|
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 = xxlJobInfoMapper.loadById(Integer.parseInt(childJobIdItem));
|
|
|
|
if (childJobInfo==null) {
|
|
|
|
if (childJobInfo==null) {
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
|
|
|
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem));
|
|
|
|
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem));
|
|
|
@ -157,7 +157,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
jobInfo.setGlueUpdatetime(new Date());
|
|
|
|
jobInfo.setGlueUpdatetime(new Date());
|
|
|
|
// remove the whitespace
|
|
|
|
// remove the whitespace
|
|
|
|
jobInfo.setExecutorHandler(jobInfo.getExecutorHandler().trim());
|
|
|
|
jobInfo.setExecutorHandler(jobInfo.getExecutorHandler().trim());
|
|
|
|
xxlJobInfoDao.save(jobInfo);
|
|
|
|
xxlJobInfoMapper.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<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_add")+I18nUtil.getString("system_fail")) );
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -231,7 +231,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// valid child
|
|
|
|
// valid child
|
|
|
|
XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(childJobId);
|
|
|
|
XxlJobInfo childJobInfo = xxlJobInfoMapper.loadById(childJobId);
|
|
|
|
if (childJobInfo==null) {
|
|
|
|
if (childJobInfo==null) {
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE,
|
|
|
|
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem));
|
|
|
|
MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem));
|
|
|
@ -257,13 +257,13 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// group valid
|
|
|
|
// group valid
|
|
|
|
XxlJobGroup jobGroup = xxlJobGroupDao.load(jobInfo.getJobGroup());
|
|
|
|
XxlJobGroup jobGroup = xxlJobGroupMapper.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<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_jobgroup")+I18nUtil.getString("system_unvalid")) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// stage job info
|
|
|
|
// stage job info
|
|
|
|
XxlJobInfo exists_jobInfo = xxlJobInfoDao.loadById(jobInfo.getId());
|
|
|
|
XxlJobInfo exists_jobInfo = xxlJobInfoMapper.loadById(jobInfo.getId());
|
|
|
|
if (exists_jobInfo == null) {
|
|
|
|
if (exists_jobInfo == null) {
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id")+I18nUtil.getString("system_not_found")) );
|
|
|
|
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id")+I18nUtil.getString("system_not_found")) );
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -302,7 +302,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
exists_jobInfo.setTriggerNextTime(nextTriggerTime);
|
|
|
|
exists_jobInfo.setTriggerNextTime(nextTriggerTime);
|
|
|
|
|
|
|
|
|
|
|
|
exists_jobInfo.setUpdateTime(new Date());
|
|
|
|
exists_jobInfo.setUpdateTime(new Date());
|
|
|
|
xxlJobInfoDao.update(exists_jobInfo);
|
|
|
|
xxlJobInfoMapper.update(exists_jobInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ReturnT.ofSuccess();
|
|
|
|
return ReturnT.ofSuccess();
|
|
|
@ -310,21 +310,21 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ReturnT<String> remove(int id) {
|
|
|
|
public ReturnT<String> remove(int id) {
|
|
|
|
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
|
|
|
|
XxlJobInfo xxlJobInfo = xxlJobInfoMapper.loadById(id);
|
|
|
|
if (xxlJobInfo == null) {
|
|
|
|
if (xxlJobInfo == null) {
|
|
|
|
return ReturnT.ofSuccess();
|
|
|
|
return ReturnT.ofSuccess();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
xxlJobInfoDao.delete(id);
|
|
|
|
xxlJobInfoMapper.delete(id);
|
|
|
|
xxlJobLogDao.delete(id);
|
|
|
|
xxlJobLogMapper.delete(id);
|
|
|
|
xxlJobLogGlueDao.deleteByJobId(id);
|
|
|
|
xxlJobLogGlueMapper.deleteByJobId(id);
|
|
|
|
return ReturnT.ofSuccess();
|
|
|
|
return ReturnT.ofSuccess();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ReturnT<String> start(int id) {
|
|
|
|
public ReturnT<String> start(int id) {
|
|
|
|
// load and valid
|
|
|
|
// load and valid
|
|
|
|
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
|
|
|
|
XxlJobInfo xxlJobInfo = xxlJobInfoMapper.loadById(id);
|
|
|
|
if (xxlJobInfo == null) {
|
|
|
|
if (xxlJobInfo == null) {
|
|
|
|
return ReturnT.ofFail(I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
|
|
|
|
return ReturnT.ofFail(I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -353,14 +353,14 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
xxlJobInfo.setTriggerNextTime(nextTriggerTime);
|
|
|
|
xxlJobInfo.setTriggerNextTime(nextTriggerTime);
|
|
|
|
|
|
|
|
|
|
|
|
xxlJobInfo.setUpdateTime(new Date());
|
|
|
|
xxlJobInfo.setUpdateTime(new Date());
|
|
|
|
xxlJobInfoDao.update(xxlJobInfo);
|
|
|
|
xxlJobInfoMapper.update(xxlJobInfo);
|
|
|
|
return ReturnT.ofSuccess();
|
|
|
|
return ReturnT.ofSuccess();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ReturnT<String> stop(int id) {
|
|
|
|
public ReturnT<String> stop(int id) {
|
|
|
|
// load and valid
|
|
|
|
// load and valid
|
|
|
|
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id);
|
|
|
|
XxlJobInfo xxlJobInfo = xxlJobInfoMapper.loadById(id);
|
|
|
|
if (xxlJobInfo == null) {
|
|
|
|
if (xxlJobInfo == null) {
|
|
|
|
return ReturnT.ofFail(I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
|
|
|
|
return ReturnT.ofFail(I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -371,7 +371,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
xxlJobInfo.setTriggerNextTime(0);
|
|
|
|
xxlJobInfo.setTriggerNextTime(0);
|
|
|
|
|
|
|
|
|
|
|
|
xxlJobInfo.setUpdateTime(new Date());
|
|
|
|
xxlJobInfo.setUpdateTime(new Date());
|
|
|
|
xxlJobInfoDao.update(xxlJobInfo);
|
|
|
|
xxlJobInfoMapper.update(xxlJobInfo);
|
|
|
|
return ReturnT.ofSuccess();
|
|
|
|
return ReturnT.ofSuccess();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -383,7 +383,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
if (loginUser == null) {
|
|
|
|
if (loginUser == null) {
|
|
|
|
return ReturnT.ofFail(I18nUtil.getString("system_permission_limit"));
|
|
|
|
return ReturnT.ofFail(I18nUtil.getString("system_permission_limit"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(jobId);
|
|
|
|
XxlJobInfo xxlJobInfo = xxlJobInfoMapper.loadById(jobId);
|
|
|
|
if (xxlJobInfo == null) {
|
|
|
|
if (xxlJobInfo == null) {
|
|
|
|
return ReturnT.ofFail(I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
|
|
|
|
return ReturnT.ofFail(I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -414,10 +414,10 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> dashboardInfo() {
|
|
|
|
public Map<String, Object> dashboardInfo() {
|
|
|
|
|
|
|
|
|
|
|
|
int jobInfoCount = xxlJobInfoDao.findAllCount();
|
|
|
|
int jobInfoCount = xxlJobInfoMapper.findAllCount();
|
|
|
|
int jobLogCount = 0;
|
|
|
|
int jobLogCount = 0;
|
|
|
|
int jobLogSuccessCount = 0;
|
|
|
|
int jobLogSuccessCount = 0;
|
|
|
|
XxlJobLogReport xxlJobLogReport = xxlJobLogReportDao.queryLogReportTotal();
|
|
|
|
XxlJobLogReport xxlJobLogReport = xxlJobLogReportMapper.queryLogReportTotal();
|
|
|
|
if (xxlJobLogReport != null) {
|
|
|
|
if (xxlJobLogReport != null) {
|
|
|
|
jobLogCount = xxlJobLogReport.getRunningCount() + xxlJobLogReport.getSucCount() + xxlJobLogReport.getFailCount();
|
|
|
|
jobLogCount = xxlJobLogReport.getRunningCount() + xxlJobLogReport.getSucCount() + xxlJobLogReport.getFailCount();
|
|
|
|
jobLogSuccessCount = xxlJobLogReport.getSucCount();
|
|
|
|
jobLogSuccessCount = xxlJobLogReport.getSucCount();
|
|
|
@ -425,7 +425,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
|
|
|
|
|
|
|
|
// executor count
|
|
|
|
// executor count
|
|
|
|
Set<String> executorAddressSet = new HashSet<String>();
|
|
|
|
Set<String> executorAddressSet = new HashSet<String>();
|
|
|
|
List<XxlJobGroup> groupList = xxlJobGroupDao.findAll();
|
|
|
|
List<XxlJobGroup> groupList = xxlJobGroupMapper.findAll();
|
|
|
|
|
|
|
|
|
|
|
|
if (groupList!=null && !groupList.isEmpty()) {
|
|
|
|
if (groupList!=null && !groupList.isEmpty()) {
|
|
|
|
for (XxlJobGroup group: groupList) {
|
|
|
|
for (XxlJobGroup group: groupList) {
|
|
|
@ -457,7 +457,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|
|
|
int triggerCountSucTotal = 0;
|
|
|
|
int triggerCountSucTotal = 0;
|
|
|
|
int triggerCountFailTotal = 0;
|
|
|
|
int triggerCountFailTotal = 0;
|
|
|
|
|
|
|
|
|
|
|
|
List<XxlJobLogReport> logReportList = xxlJobLogReportDao.queryLogReport(startDate, endDate);
|
|
|
|
List<XxlJobLogReport> logReportList = xxlJobLogReportMapper.queryLogReport(startDate, endDate);
|
|
|
|
|
|
|
|
|
|
|
|
if (logReportList!=null && logReportList.size()>0) {
|
|
|
|
if (logReportList!=null && logReportList.size()>0) {
|
|
|
|
for (XxlJobLogReport item: logReportList) {
|
|
|
|
for (XxlJobLogReport item: logReportList) {
|
|
|
|