【fix sonar】 JobLogController.java文件
This commit is contained in:
+18
-18
@@ -50,11 +50,11 @@ public class JobLogController {
|
|||||||
public String index(HttpServletRequest request, Model model, @RequestParam(required = false, defaultValue = "0") Integer jobId) {
|
public String index(HttpServletRequest request, Model model, @RequestParam(required = false, defaultValue = "0") Integer jobId) {
|
||||||
|
|
||||||
// 执行器列表
|
// 执行器列表
|
||||||
List<XxlJobGroup> jobGroupList_all = xxlJobGroupDao.findAll();
|
List<XxlJobGroup> jobGroupListAll = xxlJobGroupDao.findAll();
|
||||||
|
|
||||||
// filter group
|
// filter group
|
||||||
List<XxlJobGroup> jobGroupList = JobInfoController.filterJobGroupByRole(request, jobGroupList_all);
|
List<XxlJobGroup> jobGroupList = JobInfoController.filterJobGroupByRole(request, jobGroupListAll);
|
||||||
if (jobGroupList==null || jobGroupList.size()==0) {
|
if (jobGroupList==null || jobGroupList.isEmpty()) {
|
||||||
throw new XxlJobException(I18nUtil.getString("jobgroup_empty"));
|
throw new XxlJobException(I18nUtil.getString("jobgroup_empty"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ public class JobLogController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ReturnT<List<XxlJobInfo>> getJobsByGroup(int jobGroup){
|
public ReturnT<List<XxlJobInfo>> getJobsByGroup(int jobGroup){
|
||||||
List<XxlJobInfo> list = xxlJobInfoDao.getJobsByGroup(jobGroup);
|
List<XxlJobInfo> list = xxlJobInfoDao.getJobsByGroup(jobGroup);
|
||||||
return new ReturnT<List<XxlJobInfo>>(list);
|
return new ReturnT<>(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/pageList")
|
@RequestMapping("/pageList")
|
||||||
@@ -106,12 +106,12 @@ public class JobLogController {
|
|||||||
|
|
||||||
// page query
|
// page query
|
||||||
List<XxlJobLog> list = xxlJobLogDao.pageList(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
|
List<XxlJobLog> list = xxlJobLogDao.pageList(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
|
||||||
int list_count = xxlJobLogDao.pageListCount(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
|
int listCount = xxlJobLogDao.pageListCount(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
|
||||||
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ public class JobLogController {
|
|||||||
public String logDetailPage(int id, Model model){
|
public String logDetailPage(int id, Model model){
|
||||||
|
|
||||||
// base check
|
// base check
|
||||||
ReturnT<String> logStatue = ReturnT.SUCCESS;
|
// ReturnT<String> logStatue = ReturnT.SUCCESS;
|
||||||
XxlJobLog jobLog = xxlJobLogDao.load(id);
|
XxlJobLog jobLog = xxlJobLogDao.load(id);
|
||||||
if (jobLog == null) {
|
if (jobLog == null) {
|
||||||
throw new RuntimeException(I18nUtil.getString("joblog_logid_unvalid"));
|
throw new RuntimeException(I18nUtil.getString("joblog_logid_unvalid"));
|
||||||
@@ -152,7 +152,7 @@ public class JobLogController {
|
|||||||
return logResult;
|
return logResult;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return new ReturnT<LogResult>(ReturnT.FAIL_CODE, e.getMessage());
|
return new ReturnT<>(ReturnT.FAIL_CODE, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,10 +163,10 @@ public class JobLogController {
|
|||||||
XxlJobLog log = xxlJobLogDao.load(id);
|
XxlJobLog log = xxlJobLogDao.load(id);
|
||||||
XxlJobInfo jobInfo = xxlJobInfoDao.loadById(log.getJobId());
|
XxlJobInfo jobInfo = xxlJobInfoDao.loadById(log.getJobId());
|
||||||
if (jobInfo==null) {
|
if (jobInfo==null) {
|
||||||
return new ReturnT<String>(500, I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
|
return new ReturnT<>(500, I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
|
||||||
}
|
}
|
||||||
if (ReturnT.SUCCESS_CODE != log.getTriggerCode()) {
|
if (ReturnT.SUCCESS_CODE != log.getTriggerCode()) {
|
||||||
return new ReturnT<String>(500, I18nUtil.getString("joblog_kill_log_limit"));
|
return new ReturnT<>(500, I18nUtil.getString("joblog_kill_log_limit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// request of kill
|
// request of kill
|
||||||
@@ -176,7 +176,7 @@ public class JobLogController {
|
|||||||
runResult = executorBiz.kill(new KillParam(jobInfo.getId()));
|
runResult = executorBiz.kill(new KillParam(jobInfo.getId()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
runResult = new ReturnT<String>(500, e.getMessage());
|
runResult = new ReturnT<>(500, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ReturnT.SUCCESS_CODE == runResult.getCode()) {
|
if (ReturnT.SUCCESS_CODE == runResult.getCode()) {
|
||||||
@@ -184,9 +184,9 @@ public class JobLogController {
|
|||||||
log.setHandleMsg( I18nUtil.getString("joblog_kill_log_byman")+":" + (runResult.getMsg()!=null?runResult.getMsg():""));
|
log.setHandleMsg( I18nUtil.getString("joblog_kill_log_byman")+":" + (runResult.getMsg()!=null?runResult.getMsg():""));
|
||||||
log.setHandleTime(new Date());
|
log.setHandleTime(new Date());
|
||||||
xxlJobLogDao.updateHandleInfo(log);
|
xxlJobLogDao.updateHandleInfo(log);
|
||||||
return new ReturnT<String>(runResult.getMsg());
|
return new ReturnT<>(runResult.getMsg());
|
||||||
} else {
|
} else {
|
||||||
return new ReturnT<String>(500, runResult.getMsg());
|
return new ReturnT<>(500, runResult.getMsg());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,16 +215,16 @@ public class JobLogController {
|
|||||||
} else if (type == 9) {
|
} else if (type == 9) {
|
||||||
clearBeforeNum = 0; // 清理所有日志数据
|
clearBeforeNum = 0; // 清理所有日志数据
|
||||||
} else {
|
} else {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("joblog_clean_type_unvalid"));
|
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("joblog_clean_type_unvalid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Long> logIds = null;
|
List<Long> logIds = null;
|
||||||
do {
|
do {
|
||||||
logIds = xxlJobLogDao.findClearLogIds(jobGroup, jobId, clearBeforeTime, clearBeforeNum, 1000);
|
logIds = xxlJobLogDao.findClearLogIds(jobGroup, jobId, clearBeforeTime, clearBeforeNum, 1000);
|
||||||
if (logIds!=null && logIds.size()>0) {
|
if (logIds!=null && !logIds.isEmpty()) {
|
||||||
xxlJobLogDao.clearLog(logIds);
|
xxlJobLogDao.clearLog(logIds);
|
||||||
}
|
}
|
||||||
} while (logIds!=null && logIds.size()>0);
|
} while (logIds!=null && !logIds.isEmpty());
|
||||||
|
|
||||||
return ReturnT.SUCCESS;
|
return ReturnT.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user