diff --git a/pom.xml b/pom.xml index a534272c..f28b0545 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ 5.8.1 3.17.0 2.2.1 - 2.3.0 + 2.3.1 2.0.9 3.0.3 1.30.0 diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/XxlJobAdminApplication.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/XxlJobAdminApplication.java index fce10a81..95ec1c41 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/XxlJobAdminApplication.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/XxlJobAdminApplication.java @@ -9,8 +9,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class XxlJobAdminApplication { - public static void main(String[] args) { + public static void main(String[] args) { SpringApplication.run(XxlJobAdminApplication.class, args); - } + } -} \ No newline at end of file +} diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/IndexController.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/IndexController.java index eb63f0bd..bbb25077 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/IndexController.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/IndexController.java @@ -24,73 +24,74 @@ import java.util.Map; /** * index controller + * * @author xuxueli 2015-12-19 16:13:16 */ @Controller public class IndexController { - @Resource - private XxlJobService xxlJobService; - @Resource - private LoginService loginService; + @Resource + private XxlJobService xxlJobService; + @Resource + private LoginService loginService; - @RequestMapping("/") - public String index(Model model) { + @RequestMapping("/") + public String index(Model model) { - Map dashboardMap = xxlJobService.dashboardInfo(); - model.addAllAttributes(dashboardMap); + Map dashboardMap = xxlJobService.dashboardInfo(); + model.addAllAttributes(dashboardMap); - return "index"; - } + return "index"; + } @RequestMapping("/chartInfo") - @ResponseBody - public ReturnT> chartInfo(Date startDate, Date endDate) { + @ResponseBody + public ReturnT> chartInfo(Date startDate, Date endDate) { ReturnT> chartInfo = xxlJobService.chartInfo(startDate, endDate); return chartInfo; } - - @RequestMapping("/toLogin") - @PermissionLimit(limit=false) - public ModelAndView toLogin(HttpServletRequest request, HttpServletResponse response,ModelAndView modelAndView) { - if (loginService.ifLogin(request, response) != null) { - modelAndView.setView(new RedirectView("/",true,false)); - return modelAndView; - } - return new ModelAndView("login"); - } - - @RequestMapping(value="login", method=RequestMethod.POST) - @ResponseBody - @PermissionLimit(limit=false) - public ReturnT loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember){ - boolean ifRem = (ifRemember!=null && ifRemember.trim().length()>0 && "on".equals(ifRemember))?true:false; - return loginService.login(request, response, userName, password, ifRem); - } - - @RequestMapping(value="logout", method=RequestMethod.POST) - @ResponseBody - @PermissionLimit(limit=false) - public ReturnT logout(HttpServletRequest request, HttpServletResponse response){ - return loginService.logout(request, response); - } - - @RequestMapping("/help") - public String help() { - /*if (!PermissionInterceptor.ifLogin(request)) { - return "redirect:/toLogin"; - }*/ + @RequestMapping("/toLogin") + @PermissionLimit(limit = false) + public ModelAndView toLogin(HttpServletRequest request, HttpServletResponse response, ModelAndView modelAndView) { + if (loginService.ifLogin(request, response) != null) { + modelAndView.setView(new RedirectView("/", true, false)); + return modelAndView; + } + return new ModelAndView("login"); + } - return "help"; - } + @RequestMapping(value = "login", method = RequestMethod.POST) + @ResponseBody + @PermissionLimit(limit = false) + public ReturnT loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember) { + boolean ifRem = (ifRemember != null && ifRemember.trim().length() > 0 && "on".equals(ifRemember)) ? true : false; + return loginService.login(request, response, userName, password, ifRem); + } + + @RequestMapping(value = "logout", method = RequestMethod.POST) + @ResponseBody + @PermissionLimit(limit = false) + public ReturnT logout(HttpServletRequest request, HttpServletResponse response) { + return loginService.logout(request, response); + } + + @RequestMapping("/help") + public String help() { + + /*if (!PermissionInterceptor.ifLogin(request)) { + return "redirect:/toLogin"; + }*/ + + return "help"; + } + + @InitBinder + public void initBinder(WebDataBinder binder) { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + dateFormat.setLenient(false); + binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); + } - @InitBinder - public void initBinder(WebDataBinder binder) { - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - dateFormat.setLenient(false); - binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); - } - } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java index aa51e739..f4a37a71 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java @@ -37,19 +37,19 @@ public class JobApiController { */ @RequestMapping("/{uri}") @ResponseBody - @PermissionLimit(limit=false) + @PermissionLimit(limit = false) public ReturnT api(HttpServletRequest request, @PathVariable("uri") String uri, @RequestBody(required = false) String data) { // valid if (!"POST".equalsIgnoreCase(request.getMethod())) { return new ReturnT(ReturnT.FAIL_CODE, "invalid request, HttpMethod not support."); } - if (uri==null || uri.trim().length()==0) { + if (uri == null || uri.trim().length() == 0) { return new ReturnT(ReturnT.FAIL_CODE, "invalid request, uri-mapping empty."); } - if (XxlJobAdminConfig.getAdminConfig().getAccessToken()!=null - && XxlJobAdminConfig.getAdminConfig().getAccessToken().trim().length()>0 - && !XxlJobAdminConfig.getAdminConfig().getAccessToken().equals(request.getHeader(XxlJobRemotingUtil.XXL_JOB_ACCESS_TOKEN))) { + if (XxlJobAdminConfig.getAdminConfig().getAccessToken() != null + && XxlJobAdminConfig.getAdminConfig().getAccessToken().trim().length() > 0 + && !XxlJobAdminConfig.getAdminConfig().getAccessToken().equals(request.getHeader(XxlJobRemotingUtil.XXL_JOB_ACCESS_TOKEN))) { return new ReturnT(ReturnT.FAIL_CODE, "The access token is wrong."); } @@ -64,7 +64,7 @@ public class JobApiController { RegistryParam registryParam = GsonTool.fromJson(data, RegistryParam.class); return adminBiz.registryRemove(registryParam); } else { - return new ReturnT(ReturnT.FAIL_CODE, "invalid request, uri-mapping("+ uri +") not found."); + return new ReturnT(ReturnT.FAIL_CODE, "invalid request, uri-mapping(" + uri + ") not found."); } } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobCodeController.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobCodeController.java index fe4a0e84..9185f86b 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobCodeController.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobCodeController.java @@ -19,78 +19,79 @@ import java.util.List; /** * job code controller + * * @author xuxueli 2015-12-19 16:13:16 */ @Controller @RequestMapping("/jobcode") public class JobCodeController { - - @Resource - private XxlJobInfoDao xxlJobInfoDao; - @Resource - private XxlJobLogGlueDao xxlJobLogGlueDao; - @RequestMapping - public String index(HttpServletRequest request, Model model, int jobId) { - XxlJobInfo jobInfo = xxlJobInfoDao.loadById(jobId); - List jobLogGlues = xxlJobLogGlueDao.findByJobId(jobId); + @Resource + private XxlJobInfoDao xxlJobInfoDao; + @Resource + private XxlJobLogGlueDao xxlJobLogGlueDao; - if (jobInfo == null) { - throw new RuntimeException(I18nUtil.getString("jobinfo_glue_jobid_unvalid")); - } - if (GlueTypeEnum.BEAN == GlueTypeEnum.match(jobInfo.getGlueType())) { - throw new RuntimeException(I18nUtil.getString("jobinfo_glue_gluetype_unvalid")); - } + @RequestMapping + public String index(HttpServletRequest request, Model model, int jobId) { + XxlJobInfo jobInfo = xxlJobInfoDao.loadById(jobId); + List jobLogGlues = xxlJobLogGlueDao.findByJobId(jobId); - // valid permission - JobInfoController.validPermission(request, jobInfo.getJobGroup()); + if (jobInfo == null) { + throw new RuntimeException(I18nUtil.getString("jobinfo_glue_jobid_unvalid")); + } + if (GlueTypeEnum.BEAN == GlueTypeEnum.match(jobInfo.getGlueType())) { + throw new RuntimeException(I18nUtil.getString("jobinfo_glue_gluetype_unvalid")); + } - // Glue类型-字典 - model.addAttribute("GlueTypeEnum", GlueTypeEnum.values()); + // valid permission + JobInfoController.validPermission(request, jobInfo.getJobGroup()); - model.addAttribute("jobInfo", jobInfo); - model.addAttribute("jobLogGlues", jobLogGlues); - return "jobcode/jobcode.index"; - } - - @RequestMapping("/save") - @ResponseBody - public ReturnT save(Model model, int id, String glueSource, String glueRemark) { - // valid - if (glueRemark==null) { - return new ReturnT(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_glue_remark")) ); - } - if (glueRemark.length()<4 || glueRemark.length()>100) { - return new ReturnT(500, I18nUtil.getString("jobinfo_glue_remark_limit")); - } - XxlJobInfo exists_jobInfo = xxlJobInfoDao.loadById(id); - if (exists_jobInfo == null) { - return new ReturnT(500, I18nUtil.getString("jobinfo_glue_jobid_unvalid")); - } - - // update new code - exists_jobInfo.setGlueSource(glueSource); - exists_jobInfo.setGlueRemark(glueRemark); - exists_jobInfo.setGlueUpdatetime(new Date()); + // Glue类型-字典 + model.addAttribute("GlueTypeEnum", GlueTypeEnum.values()); - exists_jobInfo.setUpdateTime(new Date()); - xxlJobInfoDao.update(exists_jobInfo); + model.addAttribute("jobInfo", jobInfo); + model.addAttribute("jobLogGlues", jobLogGlues); + return "jobcode/jobcode.index"; + } - // log old code - XxlJobLogGlue xxlJobLogGlue = new XxlJobLogGlue(); - xxlJobLogGlue.setJobId(exists_jobInfo.getId()); - xxlJobLogGlue.setGlueType(exists_jobInfo.getGlueType()); - xxlJobLogGlue.setGlueSource(glueSource); - xxlJobLogGlue.setGlueRemark(glueRemark); + @RequestMapping("/save") + @ResponseBody + public ReturnT save(Model model, int id, String glueSource, String glueRemark) { + // valid + if (glueRemark == null) { + return new ReturnT(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_glue_remark"))); + } + if (glueRemark.length() < 4 || glueRemark.length() > 100) { + return new ReturnT(500, I18nUtil.getString("jobinfo_glue_remark_limit")); + } + XxlJobInfo exists_jobInfo = xxlJobInfoDao.loadById(id); + if (exists_jobInfo == null) { + return new ReturnT(500, I18nUtil.getString("jobinfo_glue_jobid_unvalid")); + } - xxlJobLogGlue.setAddTime(new Date()); - xxlJobLogGlue.setUpdateTime(new Date()); - xxlJobLogGlueDao.save(xxlJobLogGlue); + // update new code + exists_jobInfo.setGlueSource(glueSource); + exists_jobInfo.setGlueRemark(glueRemark); + exists_jobInfo.setGlueUpdatetime(new Date()); - // remove code backup more than 30 - xxlJobLogGlueDao.removeOld(exists_jobInfo.getId(), 30); + exists_jobInfo.setUpdateTime(new Date()); + xxlJobInfoDao.update(exists_jobInfo); + + // log old code + XxlJobLogGlue xxlJobLogGlue = new XxlJobLogGlue(); + xxlJobLogGlue.setJobId(exists_jobInfo.getId()); + xxlJobLogGlue.setGlueType(exists_jobInfo.getGlueType()); + xxlJobLogGlue.setGlueSource(glueSource); + xxlJobLogGlue.setGlueRemark(glueRemark); + + xxlJobLogGlue.setAddTime(new Date()); + xxlJobLogGlue.setUpdateTime(new Date()); + xxlJobLogGlueDao.save(xxlJobLogGlue); + + // remove code backup more than 30 + xxlJobLogGlueDao.removeOld(exists_jobInfo.getId(), 30); + + return ReturnT.SUCCESS; + } - return ReturnT.SUCCESS; - } - } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobGroupController.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobGroupController.java index 4bb4b90a..82ec2dee 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobGroupController.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobGroupController.java @@ -20,178 +20,179 @@ import java.util.*; /** * job group controller + * * @author xuxueli 2016-10-02 20:52:56 */ @Controller @RequestMapping("/jobgroup") public class JobGroupController { - @Resource - public XxlJobInfoDao xxlJobInfoDao; - @Resource - public XxlJobGroupDao xxlJobGroupDao; - @Resource - private XxlJobRegistryDao xxlJobRegistryDao; + @Resource + public XxlJobInfoDao xxlJobInfoDao; + @Resource + public XxlJobGroupDao xxlJobGroupDao; + @Resource + private XxlJobRegistryDao xxlJobRegistryDao; - @RequestMapping - public String index(Model model) { - return "jobgroup/jobgroup.index"; - } + @RequestMapping + public String index(Model model) { + return "jobgroup/jobgroup.index"; + } - @RequestMapping("/pageList") - @ResponseBody - public Map pageList(HttpServletRequest request, - @RequestParam(required = false, defaultValue = "0") int start, - @RequestParam(required = false, defaultValue = "10") int length, - String appname, String title) { + @RequestMapping("/pageList") + @ResponseBody + public Map pageList(HttpServletRequest request, + @RequestParam(required = false, defaultValue = "0") int start, + @RequestParam(required = false, defaultValue = "10") int length, + String appname, String title) { - // page query - List list = xxlJobGroupDao.pageList(start, length, appname, title); - int list_count = xxlJobGroupDao.pageListCount(start, length, appname, title); + // page query + List list = xxlJobGroupDao.pageList(start, length, appname, title); + int list_count = xxlJobGroupDao.pageListCount(start, length, appname, title); - // package result - Map maps = new HashMap(); - maps.put("recordsTotal", list_count); // 总记录数 - maps.put("recordsFiltered", list_count); // 过滤后的总记录数 - maps.put("data", list); // 分页列表 - return maps; - } + // package result + Map maps = new HashMap(); + maps.put("recordsTotal", list_count); // 总记录数 + maps.put("recordsFiltered", list_count); // 过滤后的总记录数 + maps.put("data", list); // 分页列表 + return maps; + } - @RequestMapping("/save") - @ResponseBody - public ReturnT save(XxlJobGroup xxlJobGroup){ + @RequestMapping("/save") + @ResponseBody + public ReturnT save(XxlJobGroup xxlJobGroup) { - // valid - if (xxlJobGroup.getAppname()==null || xxlJobGroup.getAppname().trim().length()==0) { - return new ReturnT(500, (I18nUtil.getString("system_please_input")+"AppName") ); - } - if (xxlJobGroup.getAppname().length()<4 || xxlJobGroup.getAppname().length()>64) { - return new ReturnT(500, I18nUtil.getString("jobgroup_field_appname_length") ); - } - if (xxlJobGroup.getAppname().contains(">") || xxlJobGroup.getAppname().contains("<")) { - return new ReturnT(500, "AppName"+I18nUtil.getString("system_unvalid") ); - } - if (xxlJobGroup.getTitle()==null || xxlJobGroup.getTitle().trim().length()==0) { - return new ReturnT(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobgroup_field_title")) ); - } - if (xxlJobGroup.getTitle().contains(">") || xxlJobGroup.getTitle().contains("<")) { - return new ReturnT(500, I18nUtil.getString("jobgroup_field_title")+I18nUtil.getString("system_unvalid") ); - } - if (xxlJobGroup.getAddressType()!=0) { - if (xxlJobGroup.getAddressList()==null || xxlJobGroup.getAddressList().trim().length()==0) { - return new ReturnT(500, I18nUtil.getString("jobgroup_field_addressType_limit") ); - } - if (xxlJobGroup.getAddressList().contains(">") || xxlJobGroup.getAddressList().contains("<")) { - return new ReturnT(500, I18nUtil.getString("jobgroup_field_registryList")+I18nUtil.getString("system_unvalid") ); - } + // valid + if (xxlJobGroup.getAppname() == null || xxlJobGroup.getAppname().trim().length() == 0) { + return new ReturnT(500, (I18nUtil.getString("system_please_input") + "AppName")); + } + if (xxlJobGroup.getAppname().length() < 4 || xxlJobGroup.getAppname().length() > 64) { + return new ReturnT(500, I18nUtil.getString("jobgroup_field_appname_length")); + } + if (xxlJobGroup.getAppname().contains(">") || xxlJobGroup.getAppname().contains("<")) { + return new ReturnT(500, "AppName" + I18nUtil.getString("system_unvalid")); + } + if (xxlJobGroup.getTitle() == null || xxlJobGroup.getTitle().trim().length() == 0) { + return new ReturnT(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobgroup_field_title"))); + } + if (xxlJobGroup.getTitle().contains(">") || xxlJobGroup.getTitle().contains("<")) { + return new ReturnT(500, I18nUtil.getString("jobgroup_field_title") + I18nUtil.getString("system_unvalid")); + } + if (xxlJobGroup.getAddressType() != 0) { + if (xxlJobGroup.getAddressList() == null || xxlJobGroup.getAddressList().trim().length() == 0) { + return new ReturnT(500, I18nUtil.getString("jobgroup_field_addressType_limit")); + } + if (xxlJobGroup.getAddressList().contains(">") || xxlJobGroup.getAddressList().contains("<")) { + return new ReturnT(500, I18nUtil.getString("jobgroup_field_registryList") + I18nUtil.getString("system_unvalid")); + } - String[] addresss = xxlJobGroup.getAddressList().split(","); - for (String item: addresss) { - if (item==null || item.trim().length()==0) { - return new ReturnT(500, I18nUtil.getString("jobgroup_field_registryList_unvalid") ); - } - } - } + String[] addresss = xxlJobGroup.getAddressList().split(","); + for (String item : addresss) { + if (item == null || item.trim().length() == 0) { + return new ReturnT(500, I18nUtil.getString("jobgroup_field_registryList_unvalid")); + } + } + } - // process - xxlJobGroup.setUpdateTime(new Date()); + // process + xxlJobGroup.setUpdateTime(new Date()); - int ret = xxlJobGroupDao.save(xxlJobGroup); - return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL; - } + int ret = xxlJobGroupDao.save(xxlJobGroup); + return (ret > 0) ? ReturnT.SUCCESS : ReturnT.FAIL; + } - @RequestMapping("/update") - @ResponseBody - public ReturnT update(XxlJobGroup xxlJobGroup){ - // valid - if (xxlJobGroup.getAppname()==null || xxlJobGroup.getAppname().trim().length()==0) { - return new ReturnT(500, (I18nUtil.getString("system_please_input")+"AppName") ); - } - if (xxlJobGroup.getAppname().length()<4 || xxlJobGroup.getAppname().length()>64) { - return new ReturnT(500, I18nUtil.getString("jobgroup_field_appname_length") ); - } - if (xxlJobGroup.getTitle()==null || xxlJobGroup.getTitle().trim().length()==0) { - return new ReturnT(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobgroup_field_title")) ); - } - if (xxlJobGroup.getAddressType() == 0) { - // 0=自动注册 - List registryList = findRegistryByAppName(xxlJobGroup.getAppname()); - String addressListStr = null; - if (registryList!=null && !registryList.isEmpty()) { - Collections.sort(registryList); - addressListStr = ""; - for (String item:registryList) { - addressListStr += item + ","; - } - addressListStr = addressListStr.substring(0, addressListStr.length()-1); - } - xxlJobGroup.setAddressList(addressListStr); - } else { - // 1=手动录入 - if (xxlJobGroup.getAddressList()==null || xxlJobGroup.getAddressList().trim().length()==0) { - return new ReturnT(500, I18nUtil.getString("jobgroup_field_addressType_limit") ); - } - String[] addresss = xxlJobGroup.getAddressList().split(","); - for (String item: addresss) { - if (item==null || item.trim().length()==0) { - return new ReturnT(500, I18nUtil.getString("jobgroup_field_registryList_unvalid") ); - } - } - } + @RequestMapping("/update") + @ResponseBody + public ReturnT update(XxlJobGroup xxlJobGroup) { + // valid + if (xxlJobGroup.getAppname() == null || xxlJobGroup.getAppname().trim().length() == 0) { + return new ReturnT(500, (I18nUtil.getString("system_please_input") + "AppName")); + } + if (xxlJobGroup.getAppname().length() < 4 || xxlJobGroup.getAppname().length() > 64) { + return new ReturnT(500, I18nUtil.getString("jobgroup_field_appname_length")); + } + if (xxlJobGroup.getTitle() == null || xxlJobGroup.getTitle().trim().length() == 0) { + return new ReturnT(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobgroup_field_title"))); + } + if (xxlJobGroup.getAddressType() == 0) { + // 0=自动注册 + List registryList = findRegistryByAppName(xxlJobGroup.getAppname()); + String addressListStr = null; + if (registryList != null && !registryList.isEmpty()) { + Collections.sort(registryList); + addressListStr = ""; + for (String item : registryList) { + addressListStr += item + ","; + } + addressListStr = addressListStr.substring(0, addressListStr.length() - 1); + } + xxlJobGroup.setAddressList(addressListStr); + } else { + // 1=手动录入 + if (xxlJobGroup.getAddressList() == null || xxlJobGroup.getAddressList().trim().length() == 0) { + return new ReturnT(500, I18nUtil.getString("jobgroup_field_addressType_limit")); + } + String[] addresss = xxlJobGroup.getAddressList().split(","); + for (String item : addresss) { + if (item == null || item.trim().length() == 0) { + return new ReturnT(500, I18nUtil.getString("jobgroup_field_registryList_unvalid")); + } + } + } - // process - xxlJobGroup.setUpdateTime(new Date()); + // process + xxlJobGroup.setUpdateTime(new Date()); - int ret = xxlJobGroupDao.update(xxlJobGroup); - return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL; - } + int ret = xxlJobGroupDao.update(xxlJobGroup); + return (ret > 0) ? ReturnT.SUCCESS : ReturnT.FAIL; + } - private List findRegistryByAppName(String appnameParam){ - HashMap> appAddressMap = new HashMap>(); - List list = xxlJobRegistryDao.findAll(RegistryConfig.DEAD_TIMEOUT, new Date()); - if (list != null) { - for (XxlJobRegistry item: list) { - if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) { - String appname = item.getRegistryKey(); - List registryList = appAddressMap.get(appname); - if (registryList == null) { - registryList = new ArrayList(); - } + private List findRegistryByAppName(String appnameParam) { + HashMap> appAddressMap = new HashMap>(); + List list = xxlJobRegistryDao.findAll(RegistryConfig.DEAD_TIMEOUT, new Date()); + if (list != null) { + for (XxlJobRegistry item : list) { + if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) { + String appname = item.getRegistryKey(); + List registryList = appAddressMap.get(appname); + if (registryList == null) { + registryList = new ArrayList(); + } - if (!registryList.contains(item.getRegistryValue())) { - registryList.add(item.getRegistryValue()); - } - appAddressMap.put(appname, registryList); - } - } - } - return appAddressMap.get(appnameParam); - } + if (!registryList.contains(item.getRegistryValue())) { + registryList.add(item.getRegistryValue()); + } + appAddressMap.put(appname, registryList); + } + } + } + return appAddressMap.get(appnameParam); + } - @RequestMapping("/remove") - @ResponseBody - public ReturnT remove(int id){ + @RequestMapping("/remove") + @ResponseBody + public ReturnT remove(int id) { - // valid - int count = xxlJobInfoDao.pageListCount(0, 10, id, -1, null, null, null); - if (count > 0) { - return new ReturnT(500, I18nUtil.getString("jobgroup_del_limit_0") ); - } + // valid + int count = xxlJobInfoDao.pageListCount(0, 10, id, -1, null, null, null); + if (count > 0) { + return new ReturnT(500, I18nUtil.getString("jobgroup_del_limit_0")); + } - List allList = xxlJobGroupDao.findAll(); - if (allList.size() == 1) { - return new ReturnT(500, I18nUtil.getString("jobgroup_del_limit_1") ); - } + List allList = xxlJobGroupDao.findAll(); + if (allList.size() == 1) { + return new ReturnT(500, I18nUtil.getString("jobgroup_del_limit_1")); + } - int ret = xxlJobGroupDao.remove(id); - return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL; - } + int ret = xxlJobGroupDao.remove(id); + return (ret > 0) ? ReturnT.SUCCESS : ReturnT.FAIL; + } - @RequestMapping("/loadById") - @ResponseBody - public ReturnT loadById(int id){ - XxlJobGroup jobGroup = xxlJobGroupDao.load(id); - return jobGroup!=null?new ReturnT(jobGroup):new ReturnT(ReturnT.FAIL_CODE, null); - } + @RequestMapping("/loadById") + @ResponseBody + public ReturnT loadById(int id) { + XxlJobGroup jobGroup = xxlJobGroupDao.load(id); + return jobGroup != null ? new ReturnT(jobGroup) : new ReturnT(ReturnT.FAIL_CODE, null); + } } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobInfoController.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobInfoController.java index ea314b32..157c60ba 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobInfoController.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobInfoController.java @@ -1,6 +1,5 @@ package com.xxl.job.admin.controller; -import com.xxl.job.admin.core.cron.CronExpression; import com.xxl.job.admin.core.exception.XxlJobException; import com.xxl.job.admin.core.model.XxlJobGroup; import com.xxl.job.admin.core.model.XxlJobInfo; @@ -29,152 +28,153 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.text.ParseException; import java.util.*; /** * index controller + * * @author xuxueli 2015-12-19 16:13:16 */ @Controller @RequestMapping("/jobinfo") public class JobInfoController { - private static Logger logger = LoggerFactory.getLogger(JobInfoController.class); + private static Logger logger = LoggerFactory.getLogger(JobInfoController.class); - @Resource - private XxlJobGroupDao xxlJobGroupDao; - @Resource - private XxlJobService xxlJobService; - - @RequestMapping - public String index(HttpServletRequest request, Model model, @RequestParam(required = false, defaultValue = "-1") int jobGroup) { + @Resource + private XxlJobGroupDao xxlJobGroupDao; + @Resource + private XxlJobService xxlJobService; - // 枚举-字典 - model.addAttribute("ExecutorRouteStrategyEnum", ExecutorRouteStrategyEnum.values()); // 路由策略-列表 - model.addAttribute("GlueTypeEnum", GlueTypeEnum.values()); // Glue类型-字典 - model.addAttribute("ExecutorBlockStrategyEnum", ExecutorBlockStrategyEnum.values()); // 阻塞处理策略-字典 - model.addAttribute("ScheduleTypeEnum", ScheduleTypeEnum.values()); // 调度类型 - model.addAttribute("MisfireStrategyEnum", MisfireStrategyEnum.values()); // 调度过期策略 + @RequestMapping + public String index(HttpServletRequest request, Model model, @RequestParam(required = false, defaultValue = "-1") int jobGroup) { - // 执行器列表 - List jobGroupList_all = xxlJobGroupDao.findAll(); + // 枚举-字典 + model.addAttribute("ExecutorRouteStrategyEnum", ExecutorRouteStrategyEnum.values()); // 路由策略-列表 + model.addAttribute("GlueTypeEnum", GlueTypeEnum.values()); // Glue类型-字典 + model.addAttribute("ExecutorBlockStrategyEnum", ExecutorBlockStrategyEnum.values()); // 阻塞处理策略-字典 + model.addAttribute("ScheduleTypeEnum", ScheduleTypeEnum.values()); // 调度类型 + model.addAttribute("MisfireStrategyEnum", MisfireStrategyEnum.values()); // 调度过期策略 - // filter group - List jobGroupList = filterJobGroupByRole(request, jobGroupList_all); - if (jobGroupList==null || jobGroupList.size()==0) { - throw new XxlJobException(I18nUtil.getString("jobgroup_empty")); - } + // 执行器列表 + List jobGroupList_all = xxlJobGroupDao.findAll(); - model.addAttribute("JobGroupList", jobGroupList); - model.addAttribute("jobGroup", jobGroup); + // filter group + List jobGroupList = filterJobGroupByRole(request, jobGroupList_all); + if (jobGroupList == null || jobGroupList.size() == 0) { + throw new XxlJobException(I18nUtil.getString("jobgroup_empty")); + } - return "jobinfo/jobinfo.index"; - } + model.addAttribute("JobGroupList", jobGroupList); + model.addAttribute("jobGroup", jobGroup); - public static List filterJobGroupByRole(HttpServletRequest request, List jobGroupList_all){ - List jobGroupList = new ArrayList<>(); - if (jobGroupList_all!=null && jobGroupList_all.size()>0) { - XxlJobUser loginUser = (XxlJobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY); - if (loginUser.getRole() == 1) { - jobGroupList = jobGroupList_all; - } else { - List groupIdStrs = new ArrayList<>(); - if (loginUser.getPermission()!=null && loginUser.getPermission().trim().length()>0) { - groupIdStrs = Arrays.asList(loginUser.getPermission().trim().split(",")); - } - for (XxlJobGroup groupItem:jobGroupList_all) { - if (groupIdStrs.contains(String.valueOf(groupItem.getId()))) { - jobGroupList.add(groupItem); - } - } - } - } - return jobGroupList; - } - public static void validPermission(HttpServletRequest request, int jobGroup) { - XxlJobUser loginUser = (XxlJobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY); - if (!loginUser.validPermission(jobGroup)) { - throw new RuntimeException(I18nUtil.getString("system_permission_limit") + "[username="+ loginUser.getUsername() +"]"); - } - } - - @RequestMapping("/pageList") - @ResponseBody - public Map pageList(@RequestParam(required = false, defaultValue = "0") int start, - @RequestParam(required = false, defaultValue = "10") int length, - int jobGroup, int triggerStatus, String jobDesc, String executorHandler, String author) { - - return xxlJobService.pageList(start, length, jobGroup, triggerStatus, jobDesc, executorHandler, author); - } - - @RequestMapping("/add") - @ResponseBody - public ReturnT add(XxlJobInfo jobInfo) { - return xxlJobService.add(jobInfo); - } - - @RequestMapping("/update") - @ResponseBody - public ReturnT update(XxlJobInfo jobInfo) { - return xxlJobService.update(jobInfo); - } - - @RequestMapping("/remove") - @ResponseBody - public ReturnT remove(int id) { - return xxlJobService.remove(id); - } - - @RequestMapping("/stop") - @ResponseBody - public ReturnT pause(int id) { - return xxlJobService.stop(id); - } - - @RequestMapping("/start") - @ResponseBody - public ReturnT start(int id) { - return xxlJobService.start(id); - } - - @RequestMapping("/trigger") - @ResponseBody - //@PermissionLimit(limit = false) - public ReturnT triggerJob(int id, String executorParam, String addressList) { - // force cover job param - if (executorParam == null) { - executorParam = ""; - } + return "jobinfo/jobinfo.index"; + } - JobTriggerPoolHelper.trigger(id, TriggerTypeEnum.MANUAL, -1, null, executorParam, addressList); - return ReturnT.SUCCESS; - } + public static List filterJobGroupByRole(HttpServletRequest request, List jobGroupList_all) { + List jobGroupList = new ArrayList<>(); + if (jobGroupList_all != null && jobGroupList_all.size() > 0) { + XxlJobUser loginUser = (XxlJobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY); + if (loginUser.getRole() == 1) { + jobGroupList = jobGroupList_all; + } else { + List groupIdStrs = new ArrayList<>(); + if (loginUser.getPermission() != null && loginUser.getPermission().trim().length() > 0) { + groupIdStrs = Arrays.asList(loginUser.getPermission().trim().split(",")); + } + for (XxlJobGroup groupItem : jobGroupList_all) { + if (groupIdStrs.contains(String.valueOf(groupItem.getId()))) { + jobGroupList.add(groupItem); + } + } + } + } + return jobGroupList; + } - @RequestMapping("/nextTriggerTime") - @ResponseBody - public ReturnT> nextTriggerTime(String scheduleType, String scheduleConf) { + public static void validPermission(HttpServletRequest request, int jobGroup) { + XxlJobUser loginUser = (XxlJobUser) request.getAttribute(LoginService.LOGIN_IDENTITY_KEY); + if (!loginUser.validPermission(jobGroup)) { + throw new RuntimeException(I18nUtil.getString("system_permission_limit") + "[username=" + loginUser.getUsername() + "]"); + } + } - XxlJobInfo paramXxlJobInfo = new XxlJobInfo(); - paramXxlJobInfo.setScheduleType(scheduleType); - paramXxlJobInfo.setScheduleConf(scheduleConf); + @RequestMapping("/pageList") + @ResponseBody + public Map pageList(@RequestParam(required = false, defaultValue = "0") int start, + @RequestParam(required = false, defaultValue = "10") int length, + int jobGroup, int triggerStatus, String jobDesc, String executorHandler, String author) { - List result = new ArrayList<>(); - try { - Date lastTime = new Date(); - for (int i = 0; i < 5; i++) { - lastTime = JobScheduleHelper.generateNextValidTime(paramXxlJobInfo, lastTime); - if (lastTime != null) { - result.add(DateUtil.formatDateTime(lastTime)); - } else { - break; - } - } - } catch (Exception e) { - logger.error(e.getMessage(), e); - return new ReturnT>(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type")+I18nUtil.getString("system_unvalid")) + e.getMessage()); - } - return new ReturnT>(result); + return xxlJobService.pageList(start, length, jobGroup, triggerStatus, jobDesc, executorHandler, author); + } + + @RequestMapping("/add") + @ResponseBody + public ReturnT add(XxlJobInfo jobInfo) { + return xxlJobService.add(jobInfo); + } + + @RequestMapping("/update") + @ResponseBody + public ReturnT update(XxlJobInfo jobInfo) { + return xxlJobService.update(jobInfo); + } + + @RequestMapping("/remove") + @ResponseBody + public ReturnT remove(int id) { + return xxlJobService.remove(id); + } + + @RequestMapping("/stop") + @ResponseBody + public ReturnT pause(int id) { + return xxlJobService.stop(id); + } + + @RequestMapping("/start") + @ResponseBody + public ReturnT start(int id) { + return xxlJobService.start(id); + } + + @RequestMapping("/trigger") + @ResponseBody + //@PermissionLimit(limit = false) + public ReturnT triggerJob(int id, String executorParam, String addressList) { + // force cover job param + if (executorParam == null) { + executorParam = ""; + } + + JobTriggerPoolHelper.trigger(id, TriggerTypeEnum.MANUAL, -1, null, executorParam, addressList); + return ReturnT.SUCCESS; + } + + @RequestMapping("/nextTriggerTime") + @ResponseBody + public ReturnT> nextTriggerTime(String scheduleType, String scheduleConf) { + + XxlJobInfo paramXxlJobInfo = new XxlJobInfo(); + paramXxlJobInfo.setScheduleType(scheduleType); + paramXxlJobInfo.setScheduleConf(scheduleConf); + + List result = new ArrayList<>(); + try { + Date lastTime = new Date(); + for (int i = 0; i < 5; i++) { + lastTime = JobScheduleHelper.generateNextValidTime(paramXxlJobInfo, lastTime); + if (lastTime != null) { + result.add(DateUtil.formatDateTime(lastTime)); + } else { + break; + } + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + return new ReturnT>(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type") + I18nUtil.getString("system_unvalid")) + e.getMessage()); + } + return new ReturnT>(result); + + } - } - } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java index c64049d5..16b62399 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java @@ -1,7 +1,7 @@ package com.xxl.job.admin.controller; -import com.xxl.job.admin.core.exception.XxlJobException; import com.xxl.job.admin.core.complete.XxlJobCompleter; +import com.xxl.job.admin.core.exception.XxlJobException; import com.xxl.job.admin.core.model.XxlJobGroup; import com.xxl.job.admin.core.model.XxlJobInfo; import com.xxl.job.admin.core.model.XxlJobLog; @@ -33,201 +33,202 @@ import java.util.Map; /** * index controller + * * @author xuxueli 2015-12-19 16:13:16 */ @Controller @RequestMapping("/joblog") public class JobLogController { - private static Logger logger = LoggerFactory.getLogger(JobLogController.class); + private static Logger logger = LoggerFactory.getLogger(JobLogController.class); - @Resource - private XxlJobGroupDao xxlJobGroupDao; - @Resource - public XxlJobInfoDao xxlJobInfoDao; - @Resource - public XxlJobLogDao xxlJobLogDao; + @Resource + private XxlJobGroupDao xxlJobGroupDao; + @Resource + public XxlJobInfoDao xxlJobInfoDao; + @Resource + public XxlJobLogDao xxlJobLogDao; - @RequestMapping - public String index(HttpServletRequest request, Model model, @RequestParam(required = false, defaultValue = "0") Integer jobId) { + @RequestMapping + public String index(HttpServletRequest request, Model model, @RequestParam(required = false, defaultValue = "0") Integer jobId) { - // 执行器列表 - List jobGroupList_all = xxlJobGroupDao.findAll(); + // 执行器列表 + List jobGroupList_all = xxlJobGroupDao.findAll(); - // filter group - List jobGroupList = JobInfoController.filterJobGroupByRole(request, jobGroupList_all); - if (jobGroupList==null || jobGroupList.size()==0) { - throw new XxlJobException(I18nUtil.getString("jobgroup_empty")); - } + // filter group + List jobGroupList = JobInfoController.filterJobGroupByRole(request, jobGroupList_all); + if (jobGroupList == null || jobGroupList.size() == 0) { + throw new XxlJobException(I18nUtil.getString("jobgroup_empty")); + } - model.addAttribute("JobGroupList", jobGroupList); + model.addAttribute("JobGroupList", jobGroupList); - // 任务 - if (jobId > 0) { - XxlJobInfo jobInfo = xxlJobInfoDao.loadById(jobId); - if (jobInfo == null) { - throw new RuntimeException(I18nUtil.getString("jobinfo_field_id") + I18nUtil.getString("system_unvalid")); - } + // 任务 + if (jobId > 0) { + XxlJobInfo jobInfo = xxlJobInfoDao.loadById(jobId); + if (jobInfo == null) { + throw new RuntimeException(I18nUtil.getString("jobinfo_field_id") + I18nUtil.getString("system_unvalid")); + } - model.addAttribute("jobInfo", jobInfo); + model.addAttribute("jobInfo", jobInfo); - // valid permission - JobInfoController.validPermission(request, jobInfo.getJobGroup()); - } + // valid permission + JobInfoController.validPermission(request, jobInfo.getJobGroup()); + } - return "joblog/joblog.index"; - } + return "joblog/joblog.index"; + } - @RequestMapping("/getJobsByGroup") - @ResponseBody - public ReturnT> getJobsByGroup(int jobGroup){ - List list = xxlJobInfoDao.getJobsByGroup(jobGroup); - return new ReturnT>(list); - } - - @RequestMapping("/pageList") - @ResponseBody - public Map pageList(HttpServletRequest request, - @RequestParam(required = false, defaultValue = "0") int start, - @RequestParam(required = false, defaultValue = "10") int length, - int jobGroup, int jobId, int logStatus, String filterTime) { + @RequestMapping("/getJobsByGroup") + @ResponseBody + public ReturnT> getJobsByGroup(int jobGroup) { + List list = xxlJobInfoDao.getJobsByGroup(jobGroup); + return new ReturnT>(list); + } - // valid permission - JobInfoController.validPermission(request, jobGroup); // 仅管理员支持查询全部;普通用户仅支持查询有权限的 jobGroup - - // parse param - Date triggerTimeStart = null; - Date triggerTimeEnd = null; - if (filterTime!=null && filterTime.trim().length()>0) { - String[] temp = filterTime.split(" - "); - if (temp.length == 2) { - triggerTimeStart = DateUtil.parseDateTime(temp[0]); - triggerTimeEnd = DateUtil.parseDateTime(temp[1]); - } - } - - // page query - List list = xxlJobLogDao.pageList(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus); - int list_count = xxlJobLogDao.pageListCount(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus); - - // package result - Map maps = new HashMap(); - maps.put("recordsTotal", list_count); // 总记录数 - maps.put("recordsFiltered", list_count); // 过滤后的总记录数 - maps.put("data", list); // 分页列表 - return maps; - } + @RequestMapping("/pageList") + @ResponseBody + public Map pageList(HttpServletRequest request, + @RequestParam(required = false, defaultValue = "0") int start, + @RequestParam(required = false, defaultValue = "10") int length, + int jobGroup, int jobId, int logStatus, String filterTime) { - @RequestMapping("/logDetailPage") - public String logDetailPage(int id, Model model){ + // valid permission + JobInfoController.validPermission(request, jobGroup); // 仅管理员支持查询全部;普通用户仅支持查询有权限的 jobGroup - // base check - ReturnT logStatue = ReturnT.SUCCESS; - XxlJobLog jobLog = xxlJobLogDao.load(id); - if (jobLog == null) { + // parse param + Date triggerTimeStart = null; + Date triggerTimeEnd = null; + if (filterTime != null && filterTime.trim().length() > 0) { + String[] temp = filterTime.split(" - "); + if (temp.length == 2) { + triggerTimeStart = DateUtil.parseDateTime(temp[0]); + triggerTimeEnd = DateUtil.parseDateTime(temp[1]); + } + } + + // page query + List list = xxlJobLogDao.pageList(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus); + int list_count = xxlJobLogDao.pageListCount(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus); + + // package result + Map maps = new HashMap(); + maps.put("recordsTotal", list_count); // 总记录数 + maps.put("recordsFiltered", list_count); // 过滤后的总记录数 + maps.put("data", list); // 分页列表 + return maps; + } + + @RequestMapping("/logDetailPage") + public String logDetailPage(int id, Model model) { + + // base check + ReturnT logStatue = ReturnT.SUCCESS; + XxlJobLog jobLog = xxlJobLogDao.load(id); + if (jobLog == null) { throw new RuntimeException(I18nUtil.getString("joblog_logid_unvalid")); - } + } model.addAttribute("triggerCode", jobLog.getTriggerCode()); model.addAttribute("handleCode", jobLog.getHandleCode()); model.addAttribute("executorAddress", jobLog.getExecutorAddress()); model.addAttribute("triggerTime", jobLog.getTriggerTime().getTime()); model.addAttribute("logId", jobLog.getId()); - return "joblog/joblog.detail"; - } + return "joblog/joblog.detail"; + } - @RequestMapping("/logDetailCat") - @ResponseBody - public ReturnT logDetailCat(String executorAddress, long triggerTime, long logId, int fromLineNum){ - try { - ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(executorAddress); - ReturnT logResult = executorBiz.log(new LogParam(triggerTime, logId, fromLineNum)); + @RequestMapping("/logDetailCat") + @ResponseBody + public ReturnT logDetailCat(String executorAddress, long triggerTime, long logId, int fromLineNum) { + try { + ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(executorAddress); + ReturnT logResult = executorBiz.log(new LogParam(triggerTime, logId, fromLineNum)); - // is end - if (logResult.getContent()!=null && logResult.getContent().getFromLineNum() > logResult.getContent().getToLineNum()) { + // is end + if (logResult.getContent() != null && logResult.getContent().getFromLineNum() > logResult.getContent().getToLineNum()) { XxlJobLog jobLog = xxlJobLogDao.load(logId); if (jobLog.getHandleCode() > 0) { logResult.getContent().setEnd(true); } } - return logResult; - } catch (Exception e) { - logger.error(e.getMessage(), e); - return new ReturnT(ReturnT.FAIL_CODE, e.getMessage()); - } - } + return logResult; + } catch (Exception e) { + logger.error(e.getMessage(), e); + return new ReturnT(ReturnT.FAIL_CODE, e.getMessage()); + } + } - @RequestMapping("/logKill") - @ResponseBody - public ReturnT logKill(int id){ - // base check - XxlJobLog log = xxlJobLogDao.load(id); - XxlJobInfo jobInfo = xxlJobInfoDao.loadById(log.getJobId()); - if (jobInfo==null) { - return new ReturnT(500, I18nUtil.getString("jobinfo_glue_jobid_unvalid")); - } - if (ReturnT.SUCCESS_CODE != log.getTriggerCode()) { - return new ReturnT(500, I18nUtil.getString("joblog_kill_log_limit")); - } + @RequestMapping("/logKill") + @ResponseBody + public ReturnT logKill(int id) { + // base check + XxlJobLog log = xxlJobLogDao.load(id); + XxlJobInfo jobInfo = xxlJobInfoDao.loadById(log.getJobId()); + if (jobInfo == null) { + return new ReturnT(500, I18nUtil.getString("jobinfo_glue_jobid_unvalid")); + } + if (ReturnT.SUCCESS_CODE != log.getTriggerCode()) { + return new ReturnT(500, I18nUtil.getString("joblog_kill_log_limit")); + } - // request of kill - ReturnT runResult = null; - try { - ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(log.getExecutorAddress()); - runResult = executorBiz.kill(new KillParam(jobInfo.getId())); - } catch (Exception e) { - logger.error(e.getMessage(), e); - runResult = new ReturnT(500, e.getMessage()); - } + // request of kill + ReturnT runResult = null; + try { + ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(log.getExecutorAddress()); + runResult = executorBiz.kill(new KillParam(jobInfo.getId())); + } catch (Exception e) { + logger.error(e.getMessage(), e); + runResult = new ReturnT(500, e.getMessage()); + } - if (ReturnT.SUCCESS_CODE == runResult.getCode()) { - log.setHandleCode(ReturnT.FAIL_CODE); - log.setHandleMsg( I18nUtil.getString("joblog_kill_log_byman")+":" + (runResult.getMsg()!=null?runResult.getMsg():"")); - log.setHandleTime(new Date()); - XxlJobCompleter.updateHandleInfoAndFinish(log); - return new ReturnT(runResult.getMsg()); - } else { - return new ReturnT(500, runResult.getMsg()); - } - } + if (ReturnT.SUCCESS_CODE == runResult.getCode()) { + log.setHandleCode(ReturnT.FAIL_CODE); + log.setHandleMsg(I18nUtil.getString("joblog_kill_log_byman") + ":" + (runResult.getMsg() != null ? runResult.getMsg() : "")); + log.setHandleTime(new Date()); + XxlJobCompleter.updateHandleInfoAndFinish(log); + return new ReturnT(runResult.getMsg()); + } else { + return new ReturnT(500, runResult.getMsg()); + } + } - @RequestMapping("/clearLog") - @ResponseBody - public ReturnT clearLog(int jobGroup, int jobId, int type){ + @RequestMapping("/clearLog") + @ResponseBody + public ReturnT clearLog(int jobGroup, int jobId, int type) { - Date clearBeforeTime = null; - int clearBeforeNum = 0; - if (type == 1) { - clearBeforeTime = DateUtil.addMonths(new Date(), -1); // 清理一个月之前日志数据 - } else if (type == 2) { - clearBeforeTime = DateUtil.addMonths(new Date(), -3); // 清理三个月之前日志数据 - } else if (type == 3) { - clearBeforeTime = DateUtil.addMonths(new Date(), -6); // 清理六个月之前日志数据 - } else if (type == 4) { - clearBeforeTime = DateUtil.addYears(new Date(), -1); // 清理一年之前日志数据 - } else if (type == 5) { - clearBeforeNum = 1000; // 清理一千条以前日志数据 - } else if (type == 6) { - clearBeforeNum = 10000; // 清理一万条以前日志数据 - } else if (type == 7) { - clearBeforeNum = 30000; // 清理三万条以前日志数据 - } else if (type == 8) { - clearBeforeNum = 100000; // 清理十万条以前日志数据 - } else if (type == 9) { - clearBeforeNum = 0; // 清理所有日志数据 - } else { - return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("joblog_clean_type_unvalid")); - } + Date clearBeforeTime = null; + int clearBeforeNum = 0; + if (type == 1) { + clearBeforeTime = DateUtil.addMonths(new Date(), -1); // 清理一个月之前日志数据 + } else if (type == 2) { + clearBeforeTime = DateUtil.addMonths(new Date(), -3); // 清理三个月之前日志数据 + } else if (type == 3) { + clearBeforeTime = DateUtil.addMonths(new Date(), -6); // 清理六个月之前日志数据 + } else if (type == 4) { + clearBeforeTime = DateUtil.addYears(new Date(), -1); // 清理一年之前日志数据 + } else if (type == 5) { + clearBeforeNum = 1000; // 清理一千条以前日志数据 + } else if (type == 6) { + clearBeforeNum = 10000; // 清理一万条以前日志数据 + } else if (type == 7) { + clearBeforeNum = 30000; // 清理三万条以前日志数据 + } else if (type == 8) { + clearBeforeNum = 100000; // 清理十万条以前日志数据 + } else if (type == 9) { + clearBeforeNum = 0; // 清理所有日志数据 + } else { + return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("joblog_clean_type_unvalid")); + } - List logIds = null; - do { - logIds = xxlJobLogDao.findClearLogIds(jobGroup, jobId, clearBeforeTime, clearBeforeNum, 1000); - if (logIds!=null && logIds.size()>0) { - xxlJobLogDao.clearLog(logIds); - } - } while (logIds!=null && logIds.size()>0); + List logIds = null; + do { + logIds = xxlJobLogDao.findClearLogIds(jobGroup, jobId, clearBeforeTime, clearBeforeNum, 1000); + if (logIds != null && logIds.size() > 0) { + xxlJobLogDao.clearLog(logIds); + } + } while (logIds != null && logIds.size() > 0); - return ReturnT.SUCCESS; - } + return ReturnT.SUCCESS; + } } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/UserController.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/UserController.java index 3f4c7559..878998d3 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/UserController.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/UserController.java @@ -57,17 +57,17 @@ public class UserController { int list_count = xxlJobUserDao.pageListCount(start, length, username, role); // filter - if (list!=null && list.size()>0) { - for (XxlJobUser item: list) { + if (list != null && list.size() > 0) { + for (XxlJobUser item : list) { item.setPassword(null); } } // package result Map maps = new HashMap(); - maps.put("recordsTotal", list_count); // 总记录数 - maps.put("recordsFiltered", list_count); // 过滤后的总记录数 - maps.put("data", list); // 分页列表 + maps.put("recordsTotal", list_count); // 总记录数 + maps.put("recordsFiltered", list_count); // 过滤后的总记录数 + maps.put("data", list); // 分页列表 return maps; } @@ -78,19 +78,19 @@ public class UserController { // valid username if (!StringUtils.hasText(xxlJobUser.getUsername())) { - return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input")+I18nUtil.getString("user_username") ); + return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input") + I18nUtil.getString("user_username")); } xxlJobUser.setUsername(xxlJobUser.getUsername().trim()); - if (!(xxlJobUser.getUsername().length()>=4 && xxlJobUser.getUsername().length()<=20)) { - return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit")+"[4-20]" ); + if (!(xxlJobUser.getUsername().length() >= 4 && xxlJobUser.getUsername().length() <= 20)) { + return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit") + "[4-20]"); } // valid password if (!StringUtils.hasText(xxlJobUser.getPassword())) { - return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input")+I18nUtil.getString("user_password") ); + return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input") + I18nUtil.getString("user_password")); } xxlJobUser.setPassword(xxlJobUser.getPassword().trim()); - if (!(xxlJobUser.getPassword().length()>=4 && xxlJobUser.getPassword().length()<=20)) { - return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit")+"[4-20]" ); + if (!(xxlJobUser.getPassword().length() >= 4 && xxlJobUser.getPassword().length() <= 20)) { + return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit") + "[4-20]"); } // md5 password xxlJobUser.setPassword(DigestUtils.md5DigestAsHex(xxlJobUser.getPassword().getBytes())); @@ -98,7 +98,7 @@ public class UserController { // check repeat XxlJobUser existUser = xxlJobUserDao.loadByUserName(xxlJobUser.getUsername()); if (existUser != null) { - return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("user_username_repeat") ); + return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("user_username_repeat")); } // write @@ -120,8 +120,8 @@ public class UserController { // valid password if (StringUtils.hasText(xxlJobUser.getPassword())) { xxlJobUser.setPassword(xxlJobUser.getPassword().trim()); - if (!(xxlJobUser.getPassword().length()>=4 && xxlJobUser.getPassword().length()<=20)) { - return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit")+"[4-20]" ); + if (!(xxlJobUser.getPassword().length() >= 4 && xxlJobUser.getPassword().length() <= 20)) { + return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit") + "[4-20]"); } // md5 password xxlJobUser.setPassword(DigestUtils.md5DigestAsHex(xxlJobUser.getPassword().getBytes())); @@ -151,15 +151,15 @@ public class UserController { @RequestMapping("/updatePwd") @ResponseBody - public ReturnT updatePwd(HttpServletRequest request, String password){ + public ReturnT updatePwd(HttpServletRequest request, String password) { // valid password - if (password==null || password.trim().length()==0){ + if (password == null || password.trim().length() == 0) { return new ReturnT(ReturnT.FAIL.getCode(), "密码不可为空"); } password = password.trim(); - if (!(password.length()>=4 && password.length()<=20)) { - return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit")+"[4-20]" ); + if (!(password.length() >= 4 && password.length() <= 20)) { + return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit") + "[4-20]"); } // md5 password diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/annotation/PermissionLimit.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/annotation/PermissionLimit.java index 379efd46..054d6ef5 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/annotation/PermissionLimit.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/annotation/PermissionLimit.java @@ -8,22 +8,23 @@ import java.lang.annotation.Target; /** * 权限限制 + * * @author xuxueli 2015-12-12 18:29:02 */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface PermissionLimit { - - /** - * 登录拦截 (默认拦截) - */ - boolean limit() default true; - /** - * 要求管理员权限 - * - * @return - */ - boolean adminuser() default false; + /** + * 登录拦截 (默认拦截) + */ + boolean limit() default true; -} \ No newline at end of file + /** + * 要求管理员权限 + * + * @return + */ + boolean adminuser() default false; + +} diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/CookieInterceptor.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/CookieInterceptor.java index e55b890f..22838499 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/CookieInterceptor.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/CookieInterceptor.java @@ -19,25 +19,24 @@ import java.util.HashMap; @Component public class CookieInterceptor implements AsyncHandlerInterceptor { - @Override - public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, - ModelAndView modelAndView) throws Exception { + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, + ModelAndView modelAndView) throws Exception { - // cookie - if (modelAndView!=null && request.getCookies()!=null && request.getCookies().length>0) { - HashMap cookieMap = new HashMap(); - for (Cookie ck : request.getCookies()) { - cookieMap.put(ck.getName(), ck); - } - modelAndView.addObject("cookieMap", cookieMap); - } + // cookie + if (modelAndView != null && request.getCookies() != null && request.getCookies().length > 0) { + HashMap cookieMap = new HashMap(); + for (Cookie ck : request.getCookies()) { + cookieMap.put(ck.getName(), ck); + } + modelAndView.addObject("cookieMap", cookieMap); + } - // static method - if (modelAndView != null) { - modelAndView.addObject("I18nUtil", FtlUtil.generateStaticModel(I18nUtil.class.getName())); - } + // static method + if (modelAndView != null) { + modelAndView.addObject("I18nUtil", FtlUtil.generateStaticModel(I18nUtil.class.getName())); + } - AsyncHandlerInterceptor.super.postHandle(request, response, handler, modelAndView); - } + } } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/PermissionInterceptor.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/PermissionInterceptor.java index 19eac735..13e53b2f 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/PermissionInterceptor.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/PermissionInterceptor.java @@ -20,40 +20,40 @@ import javax.servlet.http.HttpServletResponse; @Component public class PermissionInterceptor implements AsyncHandlerInterceptor { - @Resource - private LoginService loginService; + @Resource + private LoginService loginService; - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - if (!(handler instanceof HandlerMethod)) { - return AsyncHandlerInterceptor.super.preHandle(request, response, handler); - } + if (!(handler instanceof HandlerMethod)) { + return true; // proceed with the next interceptor + } - // if need login - boolean needLogin = true; - boolean needAdminuser = false; - HandlerMethod method = (HandlerMethod)handler; - PermissionLimit permission = method.getMethodAnnotation(PermissionLimit.class); - if (permission!=null) { - needLogin = permission.limit(); - needAdminuser = permission.adminuser(); - } + // if need login + boolean needLogin = true; + boolean needAdminuser = false; + HandlerMethod method = (HandlerMethod) handler; + PermissionLimit permission = method.getMethodAnnotation(PermissionLimit.class); + if (permission != null) { + needLogin = permission.limit(); + needAdminuser = permission.adminuser(); + } - if (needLogin) { - XxlJobUser loginUser = loginService.ifLogin(request, response); - if (loginUser == null) { - response.setStatus(302); - response.setHeader("location", request.getContextPath()+"/toLogin"); - return false; - } - if (needAdminuser && loginUser.getRole()!=1) { - throw new RuntimeException(I18nUtil.getString("system_permission_limit")); - } - request.setAttribute(LoginService.LOGIN_IDENTITY_KEY, loginUser); - } + if (needLogin) { + XxlJobUser loginUser = loginService.ifLogin(request, response); + if (loginUser == null) { + response.setStatus(302); + response.setHeader("location", request.getContextPath() + "/toLogin"); + return false; + } + if (needAdminuser && loginUser.getRole() != 1) { + throw new RuntimeException(I18nUtil.getString("system_permission_limit")); + } + request.setAttribute(LoginService.LOGIN_IDENTITY_KEY, loginUser); + } - return AsyncHandlerInterceptor.super.preHandle(request, response, handler); - } + return true; // proceed with the next interceptor + } } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/resolver/WebExceptionResolver.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/resolver/WebExceptionResolver.java index 114407b6..47839211 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/resolver/WebExceptionResolver.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/controller/resolver/WebExceptionResolver.java @@ -1,8 +1,8 @@ package com.xxl.job.admin.controller.resolver; import com.xxl.job.admin.core.exception.XxlJobException; -import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.admin.core.util.JacksonUtil; +import com.xxl.job.core.biz.model.ReturnT; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -22,45 +22,45 @@ import java.io.IOException; */ @Component public class WebExceptionResolver implements HandlerExceptionResolver { - private static transient Logger logger = LoggerFactory.getLogger(WebExceptionResolver.class); + private static transient Logger logger = LoggerFactory.getLogger(WebExceptionResolver.class); - @Override - public ModelAndView resolveException(HttpServletRequest request, - HttpServletResponse response, Object handler, Exception ex) { + @Override + public ModelAndView resolveException(HttpServletRequest request, + HttpServletResponse response, Object handler, Exception ex) { - if (!(ex instanceof XxlJobException)) { - logger.error("WebExceptionResolver:{}", ex); - } + if (!(ex instanceof XxlJobException)) { + logger.error("WebExceptionResolver:{}", ex); + } - // if json - boolean isJson = false; - if (handler instanceof HandlerMethod) { - HandlerMethod method = (HandlerMethod)handler; - ResponseBody responseBody = method.getMethodAnnotation(ResponseBody.class); - if (responseBody != null) { - isJson = true; - } - } + // if json + boolean isJson = false; + if (handler instanceof HandlerMethod) { + HandlerMethod method = (HandlerMethod) handler; + ResponseBody responseBody = method.getMethodAnnotation(ResponseBody.class); + if (responseBody != null) { + isJson = true; + } + } - // error result - ReturnT errorResult = new ReturnT(ReturnT.FAIL_CODE, ex.toString().replaceAll("\n", "
")); + // error result + ReturnT errorResult = new ReturnT(ReturnT.FAIL_CODE, ex.toString().replaceAll("\n", "
")); - // response - ModelAndView mv = new ModelAndView(); - if (isJson) { - try { - response.setContentType("application/json;charset=utf-8"); - response.getWriter().print(JacksonUtil.writeValueAsString(errorResult)); - } catch (IOException e) { - logger.error(e.getMessage(), e); - } - return mv; - } else { + // response + ModelAndView mv = new ModelAndView(); + if (isJson) { + try { + response.setContentType("application/json;charset=utf-8"); + response.getWriter().print(JacksonUtil.writeValueAsString(errorResult)); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return mv; + } else { - mv.addObject("exceptionMsg", errorResult.getMsg()); - mv.setViewName("/common/common.exception"); - return mv; - } - } - -} \ No newline at end of file + mv.addObject("exceptionMsg", errorResult.getMsg()); + mv.setViewName("/common/common.exception"); + return mv; + } + } + +} diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/alarm/JobAlarmer.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/alarm/JobAlarmer.java index 797dc900..62dac9d2 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/alarm/JobAlarmer.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/alarm/JobAlarmer.java @@ -44,9 +44,9 @@ public class JobAlarmer implements ApplicationContextAware, InitializingBean { public boolean alarm(XxlJobInfo info, XxlJobLog jobLog) { boolean result = false; - if (jobAlarmList!=null && jobAlarmList.size()>0) { + if (jobAlarmList != null && jobAlarmList.size() > 0) { result = true; // success means all-success - for (JobAlarm alarm: jobAlarmList) { + for (JobAlarm alarm : jobAlarmList) { boolean resultItem = false; try { resultItem = alarm.doAlarm(info, jobLog); diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/alarm/impl/EmailJobAlarm.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/alarm/impl/EmailJobAlarm.java index e7290d76..6ad1c0b1 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/alarm/impl/EmailJobAlarm.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/alarm/impl/EmailJobAlarm.java @@ -32,18 +32,19 @@ public class EmailJobAlarm implements JobAlarm { * * @param jobLog */ - public boolean doAlarm(XxlJobInfo info, XxlJobLog jobLog){ + @Override + public boolean doAlarm(XxlJobInfo info, XxlJobLog jobLog) { boolean alarmResult = true; // send monitor email - if (info!=null && info.getAlarmEmail()!=null && info.getAlarmEmail().trim().length()>0) { + if (info != null && info.getAlarmEmail() != null && info.getAlarmEmail().trim().length() > 0) { // alarmContent String alarmContent = "Alarm Job LogId=" + jobLog.getId(); if (jobLog.getTriggerCode() != ReturnT.SUCCESS_CODE) { alarmContent += "
TriggerMsg=
" + jobLog.getTriggerMsg(); } - if (jobLog.getHandleCode()>0 && jobLog.getHandleCode() != ReturnT.SUCCESS_CODE) { + if (jobLog.getHandleCode() > 0 && jobLog.getHandleCode() != ReturnT.SUCCESS_CODE) { alarmContent += "
HandleCode=" + jobLog.getHandleMsg(); } @@ -52,13 +53,13 @@ public class EmailJobAlarm implements JobAlarm { String personal = I18nUtil.getString("admin_name_full"); String title = I18nUtil.getString("jobconf_monitor"); String content = MessageFormat.format(loadEmailJobAlarmTemplate(), - group!=null?group.getTitle():"null", - info.getId(), - info.getJobDesc(), - alarmContent); + group != null ? group.getTitle() : "null", + info.getId(), + info.getJobDesc(), + alarmContent); Set emailSet = new HashSet(Arrays.asList(info.getAlarmEmail().split(","))); - for (String email: emailSet) { + for (String email : emailSet) { // make mail try { @@ -88,28 +89,28 @@ public class EmailJobAlarm implements JobAlarm { * * @return */ - private static final String loadEmailJobAlarmTemplate(){ + private static final String loadEmailJobAlarmTemplate() { String mailBodyTemplate = "
" + I18nUtil.getString("jobconf_monitor_detail") + ":" + - "\n" + - " " + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
"+ I18nUtil.getString("jobinfo_field_jobgroup") +""+ I18nUtil.getString("jobinfo_field_id") +""+ I18nUtil.getString("jobinfo_field_jobdesc") +""+ I18nUtil.getString("jobconf_monitor_alarm_title") +""+ I18nUtil.getString("jobconf_monitor_alarm_content") +"
{0}{1}{2}"+ I18nUtil.getString("jobconf_monitor_alarm_type") +"{3}
"; + "\n" + + " " + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "
" + I18nUtil.getString("jobinfo_field_jobgroup") + "" + I18nUtil.getString("jobinfo_field_id") + "" + I18nUtil.getString("jobinfo_field_jobdesc") + "" + I18nUtil.getString("jobconf_monitor_alarm_title") + "" + I18nUtil.getString("jobconf_monitor_alarm_content") + "
{0}{1}{2}" + I18nUtil.getString("jobconf_monitor_alarm_type") + "{3}
"; return mailBodyTemplate; } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/complete/XxlJobCompleter.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/complete/XxlJobCompleter.java index b9ac59a3..83399336 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/complete/XxlJobCompleter.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/complete/XxlJobCompleter.java @@ -32,7 +32,7 @@ public class XxlJobCompleter { // text最大64kb 避免长度过长 if (xxlJobLog.getHandleMsg().length() > 15000) { - xxlJobLog.setHandleMsg( xxlJobLog.getHandleMsg().substring(0, 15000) ); + xxlJobLog.setHandleMsg(xxlJobLog.getHandleMsg().substring(0, 15000)); } // fresh handle @@ -43,18 +43,18 @@ public class XxlJobCompleter { /** * do somethind to finish job */ - private static void finishJob(XxlJobLog xxlJobLog){ + private static void finishJob(XxlJobLog xxlJobLog) { // 1、handle success, to trigger child job String triggerChildMsg = null; - if (XxlJobContext.HANDLE_COCE_SUCCESS == xxlJobLog.getHandleCode()) { + if (XxlJobContext.HANDLE_CODE_SUCCESS == xxlJobLog.getHandleCode()) { XxlJobInfo xxlJobInfo = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().loadById(xxlJobLog.getJobId()); - if (xxlJobInfo!=null && xxlJobInfo.getChildJobId()!=null && xxlJobInfo.getChildJobId().trim().length()>0) { - triggerChildMsg = "

>>>>>>>>>>>"+ I18nUtil.getString("jobconf_trigger_child_run") +"<<<<<<<<<<<
"; + if (xxlJobInfo != null && xxlJobInfo.getChildJobId() != null && xxlJobInfo.getChildJobId().trim().length() > 0) { + triggerChildMsg = "

>>>>>>>>>>>" + I18nUtil.getString("jobconf_trigger_child_run") + "<<<<<<<<<<<
"; String[] childJobIds = xxlJobInfo.getChildJobId().split(","); for (int i = 0; i < childJobIds.length; i++) { - int childJobId = (childJobIds[i]!=null && childJobIds[i].trim().length()>0 && isNumeric(childJobIds[i]))?Integer.valueOf(childJobIds[i]):-1; + int childJobId = (childJobIds[i] != null && childJobIds[i].trim().length() > 0 && isNumeric(childJobIds[i])) ? Integer.valueOf(childJobIds[i]) : -1; if (childJobId > 0) { JobTriggerPoolHelper.trigger(childJobId, TriggerTypeEnum.PARENT, -1, null, null, null); @@ -62,16 +62,16 @@ public class XxlJobCompleter { // add msg triggerChildMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg1"), - (i+1), - childJobIds.length, - childJobIds[i], - (triggerChildResult.getCode()==ReturnT.SUCCESS_CODE?I18nUtil.getString("system_success"):I18nUtil.getString("system_fail")), - triggerChildResult.getMsg()); + (i + 1), + childJobIds.length, + childJobIds[i], + (triggerChildResult.getCode() == ReturnT.SUCCESS_CODE ? I18nUtil.getString("system_success") : I18nUtil.getString("system_fail")), + triggerChildResult.getMsg()); } else { triggerChildMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg2"), - (i+1), - childJobIds.length, - childJobIds[i]); + (i + 1), + childJobIds.length, + childJobIds[i]); } } @@ -79,7 +79,7 @@ public class XxlJobCompleter { } if (triggerChildMsg != null) { - xxlJobLog.setHandleMsg( xxlJobLog.getHandleMsg() + triggerChildMsg ); + xxlJobLog.setHandleMsg(xxlJobLog.getHandleMsg() + triggerChildMsg); } // 2、fix_delay trigger next @@ -87,7 +87,7 @@ public class XxlJobCompleter { } - private static boolean isNumeric(String str){ + private static boolean isNumeric(String str) { try { int result = Integer.valueOf(str); return true; diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java index 380b8a59..6e40cb76 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java @@ -23,6 +23,7 @@ import java.util.Arrays; public class XxlJobAdminConfig implements InitializingBean, DisposableBean { private static XxlJobAdminConfig adminConfig = null; + public static XxlJobAdminConfig getAdminConfig() { return adminConfig; } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/cron/CronExpression.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/cron/CronExpression.java index fce23524..0b594d75 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/cron/CronExpression.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/cron/CronExpression.java @@ -1,44 +1,35 @@ /* * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations * under the License. - * + * */ package com.xxl.job.admin.core.cron; import java.io.Serializable; import java.text.ParseException; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map; -import java.util.SortedSet; -import java.util.StringTokenizer; -import java.util.TimeZone; -import java.util.TreeSet; +import java.util.*; /** - * Provides a parser and evaluator for unix-like cron expressions. Cron + * Provides a parser and evaluator for unix-like cron expressions. Cron * expressions provide the ability to specify complex time combinations such as - * "At 8:00am every Monday through Friday" or "At 1:30am every - * last Friday of the month". + * "At 8:00am every Monday through Friday" or "At 1:30am every + * last Friday of the month". *

* Cron expressions are comprised of 6 required fields and one optional field * separated by white space. The fields respectively are described as follows: - * + * * * * @@ -98,7 +89,7 @@ import java.util.TreeSet; * *
Field Name
*

- * The '*' character is used to specify all values. For example, "*" + * The '*' character is used to specify all values. For example, "*" * in the minute field means "every minute". *

* The '?' character is allowed for the day-of-month and day-of-week fields. It @@ -113,55 +104,55 @@ import java.util.TreeSet; * Wednesday, and Friday". *

* The '/' character is used to specify increments. For example "0/15" - * in the seconds field means "the seconds 0, 15, 30, and 45". And + * in the seconds field means "the seconds 0, 15, 30, and 45". And * "5/15" in the seconds field means "the seconds 5, 20, 35, and * 50". Specifying '*' before the '/' is equivalent to specifying 0 is * the value to start with. Essentially, for each field in the expression, there - * is a set of numbers that can be turned on or off. For seconds and minutes, + * is a set of numbers that can be turned on or off. For seconds and minutes, * the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to * 31, and for months 0 to 11 (JAN to DEC). The "/" character simply helps you turn * on every "nth" value in the given set. Thus "7/6" in the - * month field only turns on month "7", it does NOT mean every 6th - * month, please note that subtlety. + * month field only turns on month "7", it does NOT mean every 6th + * month, please note that subtlety. *

* The 'L' character is allowed for the day-of-month and day-of-week fields. - * This character is short-hand for "last", but it has different - * meaning in each of the two fields. For example, the value "L" in - * the day-of-month field means "the last day of the month" - day 31 - * for January, day 28 for February on non-leap years. If used in the - * day-of-week field by itself, it simply means "7" or + * This character is short-hand for "last", but it has different + * meaning in each of the two fields. For example, the value "L" in + * the day-of-month field means "the last day of the month" - day 31 + * for January, day 28 for February on non-leap years. If used in the + * day-of-week field by itself, it simply means "7" or * "SAT". But if used in the day-of-week field after another value, it * means "the last xxx day of the month" - for example "6L" - * means "the last friday of the month". You can also specify an offset - * from the last day of the month, such as "L-3" which would mean the third-to-last - * day of the calendar month. When using the 'L' option, it is important not to + * means "the last friday of the month". You can also specify an offset + * from the last day of the month, such as "L-3" which would mean the third-to-last + * day of the calendar month. When using the 'L' option, it is important not to * specify lists, or ranges of values, as you'll get confusing/unexpected results. *

- * The 'W' character is allowed for the day-of-month field. This character - * is used to specify the weekday (Monday-Friday) nearest the given day. As an - * example, if you were to specify "15W" as the value for the + * The 'W' character is allowed for the day-of-month field. This character + * is used to specify the weekday (Monday-Friday) nearest the given day. As an + * example, if you were to specify "15W" as the value for the * day-of-month field, the meaning is: "the nearest weekday to the 15th of - * the month". So if the 15th is a Saturday, the trigger will fire on + * the month". So if the 15th is a Saturday, the trigger will fire on * Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the - * 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. + * 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. * However if you specify "1W" as the value for day-of-month, and the - * 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not - * 'jump' over the boundary of a month's days. The 'W' character can only be + * 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not + * 'jump' over the boundary of a month's days. The 'W' character can only be * specified when the day-of-month is a single day, not a range or list of days. *

- * The 'L' and 'W' characters can also be combined for the day-of-month - * expression to yield 'LW', which translates to "last weekday of the + * The 'L' and 'W' characters can also be combined for the day-of-month + * expression to yield 'LW', which translates to "last weekday of the * month". *

* The '#' character is allowed for the day-of-week field. This character is - * used to specify "the nth" XXX day of the month. For example, the - * value of "6#3" in the day-of-week field means the third Friday of - * the month (day 6 = Friday and "#3" = the 3rd one in the month). - * Other examples: "2#1" = the first Monday of the month and + * used to specify "the nth" XXX day of the month. For example, the + * value of "6#3" in the day-of-week field means the third Friday of + * the month (day 6 = Friday and "#3" = the 3rd one in the month). + * Other examples: "2#1" = the first Monday of the month and * "4#5" = the fifth Wednesday of the month. Note that if you specify * "#5" and there is not 5 of the given day-of-week in the month, then * no firing will occur that month. If the '#' character is used, there can - * only be one expression in the day-of-week field ("3#1,6#3" is + * only be one expression in the day-of-week field ("3#1,6#3" is * not valid, since there are two expressions). *

* json - * + * * @param obj * @return json string * @throws Exception */ public static String writeValueAsString(Object obj) { - try { - return getInstance().writeValueAsString(obj); - } catch (JsonGenerationException e) { - logger.error(e.getMessage(), e); - } catch (JsonMappingException e) { - logger.error(e.getMessage(), e); - } catch (IOException e) { - logger.error(e.getMessage(), e); - } + try { + return getInstance().writeValueAsString(obj); + } catch (JsonGenerationException e) { + logger.error(e.getMessage(), e); + } catch (JsonMappingException e) { + logger.error(e.getMessage(), e); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } return null; } /** * string --> bean、Map、List(array) - * + * * @param jsonStr * @param clazz * @return obj * @throws Exception */ public static T readValue(String jsonStr, Class clazz) { - try { - return getInstance().readValue(jsonStr, clazz); - } catch (JsonParseException e) { - logger.error(e.getMessage(), e); - } catch (JsonMappingException e) { - logger.error(e.getMessage(), e); - } catch (IOException e) { - logger.error(e.getMessage(), e); - } - return null; + try { + return getInstance().readValue(jsonStr, clazz); + } catch (JsonParseException e) { + logger.error(e.getMessage(), e); + } catch (JsonMappingException e) { + logger.error(e.getMessage(), e); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; } - /** - * string --> List... - * - * @param jsonStr - * @param parametrized - * @param parameterClasses - * @param - * @return - */ - public static T readValue(String jsonStr, Class parametrized, Class... parameterClasses) { - try { - JavaType javaType = getInstance().getTypeFactory().constructParametricType(parametrized, parameterClasses); - return getInstance().readValue(jsonStr, javaType); - } catch (JsonParseException e) { - logger.error(e.getMessage(), e); - } catch (JsonMappingException e) { - logger.error(e.getMessage(), e); - } catch (IOException e) { - logger.error(e.getMessage(), e); - } - return null; - } + /** + * string --> List... + * + * @param jsonStr + * @param parametrized + * @param parameterClasses + * @param + * @return + */ + public static T readValue(String jsonStr, Class parametrized, Class... parameterClasses) { + try { + JavaType javaType = getInstance().getTypeFactory().constructParametricType(parametrized, parameterClasses); + return getInstance().readValue(jsonStr, javaType); + } catch (JsonParseException e) { + logger.error(e.getMessage(), e); + } catch (JsonMappingException e) { + logger.error(e.getMessage(), e); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/LocalCacheUtil.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/LocalCacheUtil.java index fbab0613..6232afac 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/LocalCacheUtil.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/LocalCacheUtil.java @@ -11,7 +11,8 @@ import java.util.concurrent.ConcurrentMap; public class LocalCacheUtil { private static ConcurrentMap cacheRepository = new ConcurrentHashMap(); // 类型建议用抽象父类,兼容性更好; - private static class LocalCacheData{ + + private static class LocalCacheData { private String key; private Object val; private long timeoutTime; @@ -59,13 +60,13 @@ public class LocalCacheUtil { * @param cacheTime * @return */ - public static boolean set(String key, Object val, long cacheTime){ + public static boolean set(String key, Object val, long cacheTime) { // clean timeout cache, before set new cache (avoid cache too much) cleanTimeoutCache(); // set new cache - if (key==null || key.trim().length()==0) { + if (key == null || key.trim().length() == 0) { return false; } if (val == null) { @@ -86,8 +87,8 @@ public class LocalCacheUtil { * @param key * @return */ - public static boolean remove(String key){ - if (key==null || key.trim().length()==0) { + public static boolean remove(String key) { + if (key == null || key.trim().length() == 0) { return false; } cacheRepository.remove(key); @@ -100,12 +101,12 @@ public class LocalCacheUtil { * @param key * @return */ - public static Object get(String key){ - if (key==null || key.trim().length()==0) { + public static Object get(String key) { + if (key == null || key.trim().length() == 0) { return null; } LocalCacheData localCacheData = cacheRepository.get(key); - if (localCacheData!=null && System.currentTimeMillis()=localCacheData.getTimeoutTime()) { + if (localCacheData != null && System.currentTimeMillis() >= localCacheData.getTimeoutTime()) { cacheRepository.remove(key); } } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobInfoDao.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobInfoDao.java index d640efff..e01dd112 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobInfoDao.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobInfoDao.java @@ -9,41 +9,43 @@ import java.util.List; /** * job info + * * @author xuxueli 2016-1-12 18:03:45 */ @Mapper public interface XxlJobInfoDao { - public List pageList(@Param("offset") int offset, - @Param("pagesize") int pagesize, - @Param("jobGroup") int jobGroup, - @Param("triggerStatus") int triggerStatus, - @Param("jobDesc") String jobDesc, - @Param("executorHandler") String executorHandler, - @Param("author") String author); - public int pageListCount(@Param("offset") int offset, - @Param("pagesize") int pagesize, - @Param("jobGroup") int jobGroup, - @Param("triggerStatus") int triggerStatus, - @Param("jobDesc") String jobDesc, - @Param("executorHandler") String executorHandler, - @Param("author") String author); - - public int save(XxlJobInfo info); + public List pageList(@Param("offset") int offset, + @Param("pagesize") int pagesize, + @Param("jobGroup") int jobGroup, + @Param("triggerStatus") int triggerStatus, + @Param("jobDesc") String jobDesc, + @Param("executorHandler") String executorHandler, + @Param("author") String author); - public XxlJobInfo loadById(@Param("id") int id); - - public int update(XxlJobInfo xxlJobInfo); - - public int delete(@Param("id") long id); + public int pageListCount(@Param("offset") int offset, + @Param("pagesize") int pagesize, + @Param("jobGroup") int jobGroup, + @Param("triggerStatus") int triggerStatus, + @Param("jobDesc") String jobDesc, + @Param("executorHandler") String executorHandler, + @Param("author") String author); - public List getJobsByGroup(@Param("jobGroup") int jobGroup); + public int save(XxlJobInfo info); - public int findAllCount(); + public XxlJobInfo loadById(@Param("id") int id); - public List scheduleJobQuery(@Param("maxNextTime") long maxNextTime, @Param("pagesize") int pagesize ); + public int update(XxlJobInfo xxlJobInfo); - public int scheduleUpdate(XxlJobInfo xxlJobInfo); + public int delete(@Param("id") long id); + + public List getJobsByGroup(@Param("jobGroup") int jobGroup); + + public int findAllCount(); + + public List scheduleJobQuery(@Param("maxNextTime") long maxNextTime, @Param("pagesize") int pagesize); + + public int scheduleUpdate(XxlJobInfo xxlJobInfo); } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java index 62fa3b4f..7beaf755 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java @@ -10,53 +10,56 @@ import java.util.Map; /** * job log + * * @author xuxueli 2016-1-12 18:03:06 */ @Mapper public interface XxlJobLogDao { - // exist jobId not use jobGroup, not exist use jobGroup - public List pageList(@Param("offset") int offset, - @Param("pagesize") int pagesize, - @Param("jobGroup") int jobGroup, - @Param("jobId") int jobId, - @Param("triggerTimeStart") Date triggerTimeStart, - @Param("triggerTimeEnd") Date triggerTimeEnd, - @Param("logStatus") int logStatus); - public int pageListCount(@Param("offset") int offset, - @Param("pagesize") int pagesize, - @Param("jobGroup") int jobGroup, - @Param("jobId") int jobId, - @Param("triggerTimeStart") Date triggerTimeStart, - @Param("triggerTimeEnd") Date triggerTimeEnd, - @Param("logStatus") int logStatus); - - public XxlJobLog load(@Param("id") long id); + // exist jobId not use jobGroup, not exist use jobGroup + public List pageList(@Param("offset") int offset, + @Param("pagesize") int pagesize, + @Param("jobGroup") int jobGroup, + @Param("jobId") int jobId, + @Param("triggerTimeStart") Date triggerTimeStart, + @Param("triggerTimeEnd") Date triggerTimeEnd, + @Param("logStatus") int logStatus); - public long save(XxlJobLog xxlJobLog); + public int pageListCount(@Param("offset") int offset, + @Param("pagesize") int pagesize, + @Param("jobGroup") int jobGroup, + @Param("jobId") int jobId, + @Param("triggerTimeStart") Date triggerTimeStart, + @Param("triggerTimeEnd") Date triggerTimeEnd, + @Param("logStatus") int logStatus); - public int updateTriggerInfo(XxlJobLog xxlJobLog); + public XxlJobLog load(@Param("id") long id); - public int updateHandleInfo(XxlJobLog xxlJobLog); - - public int delete(@Param("jobId") int jobId); + public long save(XxlJobLog xxlJobLog); - public Map findLogReport(@Param("from") Date from, - @Param("to") Date to); + public int updateTriggerInfo(XxlJobLog xxlJobLog); - public List findClearLogIds(@Param("jobGroup") int jobGroup, - @Param("jobId") int jobId, - @Param("clearBeforeTime") Date clearBeforeTime, - @Param("clearBeforeNum") int clearBeforeNum, - @Param("pagesize") int pagesize); - public int clearLog(@Param("logIds") List logIds); + public int updateHandleInfo(XxlJobLog xxlJobLog); - public List findFailJobLogIds(@Param("pagesize") int pagesize); + public int delete(@Param("jobId") int jobId); - public int updateAlarmStatus(@Param("logId") long logId, - @Param("oldAlarmStatus") int oldAlarmStatus, - @Param("newAlarmStatus") int newAlarmStatus); + public Map findLogReport(@Param("from") Date from, + @Param("to") Date to); - public List findLostJobIds(@Param("losedTime") Date losedTime); + public List findClearLogIds(@Param("jobGroup") int jobGroup, + @Param("jobId") int jobId, + @Param("clearBeforeTime") Date clearBeforeTime, + @Param("clearBeforeNum") int clearBeforeNum, + @Param("pagesize") int pagesize); + + public int clearLog(@Param("logIds") List logIds); + + public List findFailJobLogIds(@Param("pagesize") int pagesize); + + public int updateAlarmStatus(@Param("logId") long logId, + @Param("oldAlarmStatus") int oldAlarmStatus, + @Param("newAlarmStatus") int newAlarmStatus); + + public List findLostJobIds(@Param("losedTime") Date losedTime); } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogGlueDao.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogGlueDao.java index 3028aed2..8b2b414c 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogGlueDao.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogGlueDao.java @@ -8,17 +8,18 @@ import java.util.List; /** * job log for glue + * * @author xuxueli 2016-5-19 18:04:56 */ @Mapper public interface XxlJobLogGlueDao { - - public int save(XxlJobLogGlue xxlJobLogGlue); - - public List findByJobId(@Param("jobId") int jobId); - public int removeOld(@Param("jobId") int jobId, @Param("limit") int limit); + public int save(XxlJobLogGlue xxlJobLogGlue); + + public List findByJobId(@Param("jobId") int jobId); + + public int removeOld(@Param("jobId") int jobId, @Param("limit") int limit); + + public int deleteByJobId(@Param("jobId") int jobId); - public int deleteByJobId(@Param("jobId") int jobId); - } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogReportDao.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogReportDao.java index f4b3dc81..d4e0381a 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogReportDao.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogReportDao.java @@ -9,18 +9,19 @@ import java.util.List; /** * job log + * * @author xuxueli 2019-11-22 */ @Mapper public interface XxlJobLogReportDao { - public int save(XxlJobLogReport xxlJobLogReport); + public int save(XxlJobLogReport xxlJobLogReport); - public int update(XxlJobLogReport xxlJobLogReport); + public int update(XxlJobLogReport xxlJobLogReport); - public List queryLogReport(@Param("triggerDayFrom") Date triggerDayFrom, - @Param("triggerDayTo") Date triggerDayTo); + public List queryLogReport(@Param("triggerDayFrom") Date triggerDayFrom, + @Param("triggerDayTo") Date triggerDayTo); - public XxlJobLogReport queryLogReportTotal(); + public XxlJobLogReport queryLogReportTotal(); } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobRegistryDao.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobRegistryDao.java index 1005c46c..a68e12c3 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobRegistryDao.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobRegistryDao.java @@ -32,7 +32,7 @@ public interface XxlJobRegistryDao { @Param("updateTime") Date updateTime); public int registryDelete(@Param("registryGroup") String registryGroup, - @Param("registryKey") String registryKey, - @Param("registryValue") String registryValue); + @Param("registryKey") String registryKey, + @Param("registryValue") String registryValue); } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobUserDao.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobUserDao.java index e8404947..064ce19f 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobUserDao.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobUserDao.java @@ -3,6 +3,7 @@ package com.xxl.job.admin.dao; import com.xxl.job.admin.core.model.XxlJobUser; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; + import java.util.List; /** @@ -11,21 +12,22 @@ import java.util.List; @Mapper public interface XxlJobUserDao { - public List pageList(@Param("offset") int offset, + public List pageList(@Param("offset") int offset, @Param("pagesize") int pagesize, @Param("username") String username, - @Param("role") int role); - public int pageListCount(@Param("offset") int offset, - @Param("pagesize") int pagesize, - @Param("username") String username, - @Param("role") int role); + @Param("role") int role); - public XxlJobUser loadByUserName(@Param("username") String username); + public int pageListCount(@Param("offset") int offset, + @Param("pagesize") int pagesize, + @Param("username") String username, + @Param("role") int role); - public int save(XxlJobUser xxlJobUser); + public XxlJobUser loadByUserName(@Param("username") String username); - public int update(XxlJobUser xxlJobUser); - - public int delete(@Param("id") int id); + public int save(XxlJobUser xxlJobUser); + + public int update(XxlJobUser xxlJobUser); + + public int delete(@Param("id") int id); } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/service/LoginService.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/service/LoginService.java index 960aedd9..0937b8e9 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/service/LoginService.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/service/LoginService.java @@ -26,12 +26,13 @@ public class LoginService { private XxlJobUserDao xxlJobUserDao; - private String makeToken(XxlJobUser xxlJobUser){ + private String makeToken(XxlJobUser xxlJobUser) { String tokenJson = JacksonUtil.writeValueAsString(xxlJobUser); String tokenHex = new BigInteger(tokenJson.getBytes()).toString(16); return tokenHex; } - private XxlJobUser parseToken(String tokenHex){ + + private XxlJobUser parseToken(String tokenHex) { XxlJobUser xxlJobUser = null; if (tokenHex != null) { String tokenJson = new String(new BigInteger(tokenHex, 16).toByteArray()); // username_password(md5) @@ -41,10 +42,10 @@ public class LoginService { } - public ReturnT login(HttpServletRequest request, HttpServletResponse response, String username, String password, boolean ifRemember){ + public ReturnT login(HttpServletRequest request, HttpServletResponse response, String username, String password, boolean ifRemember) { // param - if (username==null || username.trim().length()==0 || password==null || password.trim().length()==0){ + if (username == null || username.trim().length() == 0 || password == null || password.trim().length() == 0) { return new ReturnT(500, I18nUtil.getString("login_param_empty")); } @@ -71,7 +72,7 @@ public class LoginService { * @param request * @param response */ - public ReturnT logout(HttpServletRequest request, HttpServletResponse response){ + public ReturnT logout(HttpServletRequest request, HttpServletResponse response) { CookieUtil.remove(request, response, LOGIN_IDENTITY_KEY); return ReturnT.SUCCESS; } @@ -82,7 +83,7 @@ public class LoginService { * @param request * @return */ - public XxlJobUser ifLogin(HttpServletRequest request, HttpServletResponse response){ + public XxlJobUser ifLogin(HttpServletRequest request, HttpServletResponse response) { String cookieToken = CookieUtil.getValue(request, LOGIN_IDENTITY_KEY); if (cookieToken != null) { XxlJobUser cookieUser = null; @@ -103,8 +104,5 @@ public class LoginService { return null; } - public static void main(String[] args) { - System.out.println("121312"); - } } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/service/XxlJobService.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/service/XxlJobService.java index 61da3a27..43c2eff6 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/service/XxlJobService.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/service/XxlJobService.java @@ -9,78 +9,79 @@ import java.util.Map; /** * core job action for xxl-job - * + * * @author xuxueli 2016-5-28 15:30:33 */ public interface XxlJobService { - /** - * page list - * - * @param start - * @param length - * @param jobGroup - * @param jobDesc - * @param executorHandler - * @param author - * @return - */ - public Map pageList(int start, int length, int jobGroup, int triggerStatus, String jobDesc, String executorHandler, String author); + /** + * page list + * + * @param start + * @param length + * @param jobGroup + * @param jobDesc + * @param executorHandler + * @param author + * @return + */ + public Map pageList(int start, int length, int jobGroup, int triggerStatus, String jobDesc, String executorHandler, String author); - /** - * add job - * - * @param jobInfo - * @return - */ - public ReturnT add(XxlJobInfo jobInfo); + /** + * add job + * + * @param jobInfo + * @return + */ + public ReturnT add(XxlJobInfo jobInfo); - /** - * update job - * - * @param jobInfo - * @return - */ - public ReturnT update(XxlJobInfo jobInfo); + /** + * update job + * + * @param jobInfo + * @return + */ + public ReturnT update(XxlJobInfo jobInfo); - /** - * remove job - * * - * @param id - * @return - */ - public ReturnT remove(int id); + /** + * remove job + * * + * + * @param id + * @return + */ + public ReturnT remove(int id); - /** - * start job - * - * @param id - * @return - */ - public ReturnT start(int id); + /** + * start job + * + * @param id + * @return + */ + public ReturnT start(int id); - /** - * stop job - * - * @param id - * @return - */ - public ReturnT stop(int id); + /** + * stop job + * + * @param id + * @return + */ + public ReturnT stop(int id); - /** - * dashboard info - * - * @return - */ - public Map dashboardInfo(); + /** + * dashboard info + * + * @return + */ + public Map dashboardInfo(); - /** - * chart info - * - * @param startDate - * @param endDate - * @return - */ - public ReturnT> chartInfo(Date startDate, Date endDate); + /** + * chart info + * + * @param startDate + * @param endDate + * @return + */ + public ReturnT> chartInfo(Date startDate, Date endDate); } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java index 530ee41c..454610c2 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java @@ -25,410 +25,411 @@ import java.util.*; /** * core job action for xxl-job + * * @author xuxueli 2016-5-28 15:30:33 */ @Service public class XxlJobServiceImpl implements XxlJobService { - private static Logger logger = LoggerFactory.getLogger(XxlJobServiceImpl.class); + private static Logger logger = LoggerFactory.getLogger(XxlJobServiceImpl.class); - @Resource - private XxlJobGroupDao xxlJobGroupDao; - @Resource - private XxlJobInfoDao xxlJobInfoDao; - @Resource - public XxlJobLogDao xxlJobLogDao; - @Resource - private XxlJobLogGlueDao xxlJobLogGlueDao; - @Resource - private XxlJobLogReportDao xxlJobLogReportDao; - - @Override - public Map pageList(int start, int length, int jobGroup, int triggerStatus, String jobDesc, String executorHandler, String author) { + @Resource + private XxlJobGroupDao xxlJobGroupDao; + @Resource + private XxlJobInfoDao xxlJobInfoDao; + @Resource + public XxlJobLogDao xxlJobLogDao; + @Resource + private XxlJobLogGlueDao xxlJobLogGlueDao; + @Resource + private XxlJobLogReportDao xxlJobLogReportDao; - // page list - List list = xxlJobInfoDao.pageList(start, length, jobGroup, triggerStatus, jobDesc, executorHandler, author); - int list_count = xxlJobInfoDao.pageListCount(start, length, jobGroup, triggerStatus, jobDesc, executorHandler, author); - - // package result - Map maps = new HashMap(); - maps.put("recordsTotal", list_count); // 总记录数 - maps.put("recordsFiltered", list_count); // 过滤后的总记录数 - maps.put("data", list); // 分页列表 - return maps; - } + @Override + public Map pageList(int start, int length, int jobGroup, int triggerStatus, String jobDesc, String executorHandler, String author) { - @Override - public ReturnT add(XxlJobInfo jobInfo) { + // page list + List list = xxlJobInfoDao.pageList(start, length, jobGroup, triggerStatus, jobDesc, executorHandler, author); + int list_count = xxlJobInfoDao.pageListCount(start, length, jobGroup, triggerStatus, jobDesc, executorHandler, author); - // valid base - XxlJobGroup group = xxlJobGroupDao.load(jobInfo.getJobGroup()); - if (group == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_choose")+I18nUtil.getString("jobinfo_field_jobgroup")) ); - } - if (jobInfo.getJobDesc()==null || jobInfo.getJobDesc().trim().length()==0) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_jobdesc")) ); - } - if (jobInfo.getAuthor()==null || jobInfo.getAuthor().trim().length()==0) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_author")) ); - } + // package result + Map maps = new HashMap(); + maps.put("recordsTotal", list_count); // 总记录数 + maps.put("recordsFiltered", list_count); // 过滤后的总记录数 + maps.put("data", list); // 分页列表 + return maps; + } - // valid trigger - ScheduleTypeEnum scheduleTypeEnum = ScheduleTypeEnum.match(jobInfo.getScheduleType(), null); - if (scheduleTypeEnum == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type")+I18nUtil.getString("system_unvalid")) ); - } - if (scheduleTypeEnum == ScheduleTypeEnum.CRON) { - if (jobInfo.getScheduleConf()==null || !CronExpression.isValidExpression(jobInfo.getScheduleConf())) { - return new ReturnT(ReturnT.FAIL_CODE, "Cron"+I18nUtil.getString("system_unvalid")); - } - } else if (scheduleTypeEnum == ScheduleTypeEnum.FIX_RATE/* || scheduleTypeEnum == ScheduleTypeEnum.FIX_DELAY*/) { - if (jobInfo.getScheduleConf() == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type")) ); - } - try { - int fixSecond = Integer.valueOf(jobInfo.getScheduleConf()); - if (fixSecond < 1) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type")+I18nUtil.getString("system_unvalid")) ); - } - } catch (Exception e) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type")+I18nUtil.getString("system_unvalid")) ); - } - } + @Override + public ReturnT add(XxlJobInfo jobInfo) { - // valid job - if (GlueTypeEnum.match(jobInfo.getGlueType()) == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_gluetype")+I18nUtil.getString("system_unvalid")) ); - } - if (GlueTypeEnum.BEAN==GlueTypeEnum.match(jobInfo.getGlueType()) && (jobInfo.getExecutorHandler()==null || jobInfo.getExecutorHandler().trim().length()==0) ) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+"JobHandler") ); - } - // 》fix "\r" in shell - if (GlueTypeEnum.GLUE_SHELL==GlueTypeEnum.match(jobInfo.getGlueType()) && jobInfo.getGlueSource()!=null) { - jobInfo.setGlueSource(jobInfo.getGlueSource().replaceAll("\r", "")); - } + // valid base + XxlJobGroup group = xxlJobGroupDao.load(jobInfo.getJobGroup()); + if (group == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_choose") + I18nUtil.getString("jobinfo_field_jobgroup"))); + } + if (jobInfo.getJobDesc() == null || jobInfo.getJobDesc().trim().length() == 0) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_field_jobdesc"))); + } + if (jobInfo.getAuthor() == null || jobInfo.getAuthor().trim().length() == 0) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_field_author"))); + } - // valid advanced - if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy")+I18nUtil.getString("system_unvalid")) ); - } - if (MisfireStrategyEnum.match(jobInfo.getMisfireStrategy(), null) == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("misfire_strategy")+I18nUtil.getString("system_unvalid")) ); - } - if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy")+I18nUtil.getString("system_unvalid")) ); - } + // valid trigger + ScheduleTypeEnum scheduleTypeEnum = ScheduleTypeEnum.match(jobInfo.getScheduleType(), null); + if (scheduleTypeEnum == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type") + I18nUtil.getString("system_unvalid"))); + } + if (scheduleTypeEnum == ScheduleTypeEnum.CRON) { + if (jobInfo.getScheduleConf() == null || !CronExpression.isValidExpression(jobInfo.getScheduleConf())) { + return new ReturnT(ReturnT.FAIL_CODE, "Cron" + I18nUtil.getString("system_unvalid")); + } + } else if (scheduleTypeEnum == ScheduleTypeEnum.FIX_RATE/* || scheduleTypeEnum == ScheduleTypeEnum.FIX_DELAY*/) { + if (jobInfo.getScheduleConf() == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type"))); + } + try { + int fixSecond = Integer.valueOf(jobInfo.getScheduleConf()); + if (fixSecond < 1) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type") + I18nUtil.getString("system_unvalid"))); + } + } catch (Exception e) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type") + I18nUtil.getString("system_unvalid"))); + } + } - // 》ChildJobId valid - if (jobInfo.getChildJobId()!=null && jobInfo.getChildJobId().trim().length()>0) { - String[] childJobIds = jobInfo.getChildJobId().split(","); - for (String childJobIdItem: childJobIds) { - if (childJobIdItem!=null && childJobIdItem.trim().length()>0 && isNumeric(childJobIdItem)) { - XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.parseInt(childJobIdItem)); - if (childJobInfo==null) { - return new ReturnT(ReturnT.FAIL_CODE, - MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem)); - } - } else { - return new ReturnT(ReturnT.FAIL_CODE, - MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_unvalid")), childJobIdItem)); - } - } + // valid job + if (GlueTypeEnum.match(jobInfo.getGlueType()) == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_gluetype") + I18nUtil.getString("system_unvalid"))); + } + if (GlueTypeEnum.BEAN == GlueTypeEnum.match(jobInfo.getGlueType()) && (jobInfo.getExecutorHandler() == null || jobInfo.getExecutorHandler().trim().length() == 0)) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input") + "JobHandler")); + } + // 》fix "\r" in shell + if (GlueTypeEnum.GLUE_SHELL == GlueTypeEnum.match(jobInfo.getGlueType()) && jobInfo.getGlueSource() != null) { + jobInfo.setGlueSource(jobInfo.getGlueSource().replaceAll("\r", "")); + } - // join , avoid "xxx,," - String temp = ""; - for (String item:childJobIds) { - temp += item + ","; - } - temp = temp.substring(0, temp.length()-1); + // valid advanced + if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy") + I18nUtil.getString("system_unvalid"))); + } + if (MisfireStrategyEnum.match(jobInfo.getMisfireStrategy(), null) == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("misfire_strategy") + I18nUtil.getString("system_unvalid"))); + } + if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy") + I18nUtil.getString("system_unvalid"))); + } - jobInfo.setChildJobId(temp); - } + // 》ChildJobId valid + if (jobInfo.getChildJobId() != null && jobInfo.getChildJobId().trim().length() > 0) { + String[] childJobIds = jobInfo.getChildJobId().split(","); + for (String childJobIdItem : childJobIds) { + if (childJobIdItem != null && childJobIdItem.trim().length() > 0 && isNumeric(childJobIdItem)) { + XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.parseInt(childJobIdItem)); + if (childJobInfo == null) { + return new ReturnT(ReturnT.FAIL_CODE, + MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId") + "({0})" + I18nUtil.getString("system_not_found")), childJobIdItem)); + } + } else { + return new ReturnT(ReturnT.FAIL_CODE, + MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId") + "({0})" + I18nUtil.getString("system_unvalid")), childJobIdItem)); + } + } - // add in db - jobInfo.setAddTime(new Date()); - jobInfo.setUpdateTime(new Date()); - jobInfo.setGlueUpdatetime(new Date()); - xxlJobInfoDao.save(jobInfo); - if (jobInfo.getId() < 1) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_add")+I18nUtil.getString("system_fail")) ); - } + // join , avoid "xxx,," + String temp = ""; + for (String item : childJobIds) { + temp += item + ","; + } + temp = temp.substring(0, temp.length() - 1); - return new ReturnT(String.valueOf(jobInfo.getId())); - } + jobInfo.setChildJobId(temp); + } - private boolean isNumeric(String str){ - try { - int result = Integer.valueOf(str); - return true; - } catch (NumberFormatException e) { - return false; - } - } + // add in db + jobInfo.setAddTime(new Date()); + jobInfo.setUpdateTime(new Date()); + jobInfo.setGlueUpdatetime(new Date()); + xxlJobInfoDao.save(jobInfo); + if (jobInfo.getId() < 1) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_add") + I18nUtil.getString("system_fail"))); + } - @Override - public ReturnT update(XxlJobInfo jobInfo) { + return new ReturnT(String.valueOf(jobInfo.getId())); + } - // valid base - if (jobInfo.getJobDesc()==null || jobInfo.getJobDesc().trim().length()==0) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_jobdesc")) ); - } - if (jobInfo.getAuthor()==null || jobInfo.getAuthor().trim().length()==0) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input")+I18nUtil.getString("jobinfo_field_author")) ); - } + private boolean isNumeric(String str) { + try { + int result = Integer.valueOf(str); + return true; + } catch (NumberFormatException e) { + return false; + } + } - // valid trigger - ScheduleTypeEnum scheduleTypeEnum = ScheduleTypeEnum.match(jobInfo.getScheduleType(), null); - if (scheduleTypeEnum == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type")+I18nUtil.getString("system_unvalid")) ); - } - if (scheduleTypeEnum == ScheduleTypeEnum.CRON) { - if (jobInfo.getScheduleConf()==null || !CronExpression.isValidExpression(jobInfo.getScheduleConf())) { - return new ReturnT(ReturnT.FAIL_CODE, "Cron"+I18nUtil.getString("system_unvalid") ); - } - } else if (scheduleTypeEnum == ScheduleTypeEnum.FIX_RATE /*|| scheduleTypeEnum == ScheduleTypeEnum.FIX_DELAY*/) { - if (jobInfo.getScheduleConf() == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type")+I18nUtil.getString("system_unvalid")) ); - } - try { - int fixSecond = Integer.valueOf(jobInfo.getScheduleConf()); - if (fixSecond < 1) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type")+I18nUtil.getString("system_unvalid")) ); - } - } catch (Exception e) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type")+I18nUtil.getString("system_unvalid")) ); - } - } + @Override + public ReturnT update(XxlJobInfo jobInfo) { - // valid advanced - if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy")+I18nUtil.getString("system_unvalid")) ); - } - if (MisfireStrategyEnum.match(jobInfo.getMisfireStrategy(), null) == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("misfire_strategy")+I18nUtil.getString("system_unvalid")) ); - } - if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy")+I18nUtil.getString("system_unvalid")) ); - } + // valid base + if (jobInfo.getJobDesc() == null || jobInfo.getJobDesc().trim().length() == 0) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_field_jobdesc"))); + } + if (jobInfo.getAuthor() == null || jobInfo.getAuthor().trim().length() == 0) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_field_author"))); + } - // 》ChildJobId valid - if (jobInfo.getChildJobId()!=null && jobInfo.getChildJobId().trim().length()>0) { - String[] childJobIds = jobInfo.getChildJobId().split(","); - for (String childJobIdItem: childJobIds) { - if (childJobIdItem!=null && childJobIdItem.trim().length()>0 && isNumeric(childJobIdItem)) { - XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.parseInt(childJobIdItem)); - if (childJobInfo==null) { - return new ReturnT(ReturnT.FAIL_CODE, - MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_not_found")), childJobIdItem)); - } - } else { - return new ReturnT(ReturnT.FAIL_CODE, - MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId")+"({0})"+I18nUtil.getString("system_unvalid")), childJobIdItem)); - } - } + // valid trigger + ScheduleTypeEnum scheduleTypeEnum = ScheduleTypeEnum.match(jobInfo.getScheduleType(), null); + if (scheduleTypeEnum == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type") + I18nUtil.getString("system_unvalid"))); + } + if (scheduleTypeEnum == ScheduleTypeEnum.CRON) { + if (jobInfo.getScheduleConf() == null || !CronExpression.isValidExpression(jobInfo.getScheduleConf())) { + return new ReturnT(ReturnT.FAIL_CODE, "Cron" + I18nUtil.getString("system_unvalid")); + } + } else if (scheduleTypeEnum == ScheduleTypeEnum.FIX_RATE /*|| scheduleTypeEnum == ScheduleTypeEnum.FIX_DELAY*/) { + if (jobInfo.getScheduleConf() == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type") + I18nUtil.getString("system_unvalid"))); + } + try { + int fixSecond = Integer.valueOf(jobInfo.getScheduleConf()); + if (fixSecond < 1) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type") + I18nUtil.getString("system_unvalid"))); + } + } catch (Exception e) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type") + I18nUtil.getString("system_unvalid"))); + } + } - // join , avoid "xxx,," - String temp = ""; - for (String item:childJobIds) { - temp += item + ","; - } - temp = temp.substring(0, temp.length()-1); + // valid advanced + if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorRouteStrategy") + I18nUtil.getString("system_unvalid"))); + } + if (MisfireStrategyEnum.match(jobInfo.getMisfireStrategy(), null) == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("misfire_strategy") + I18nUtil.getString("system_unvalid"))); + } + if (ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), null) == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_executorBlockStrategy") + I18nUtil.getString("system_unvalid"))); + } - jobInfo.setChildJobId(temp); - } + // 》ChildJobId valid + if (jobInfo.getChildJobId() != null && jobInfo.getChildJobId().trim().length() > 0) { + String[] childJobIds = jobInfo.getChildJobId().split(","); + for (String childJobIdItem : childJobIds) { + if (childJobIdItem != null && childJobIdItem.trim().length() > 0 && isNumeric(childJobIdItem)) { + XxlJobInfo childJobInfo = xxlJobInfoDao.loadById(Integer.parseInt(childJobIdItem)); + if (childJobInfo == null) { + return new ReturnT(ReturnT.FAIL_CODE, + MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId") + "({0})" + I18nUtil.getString("system_not_found")), childJobIdItem)); + } + } else { + return new ReturnT(ReturnT.FAIL_CODE, + MessageFormat.format((I18nUtil.getString("jobinfo_field_childJobId") + "({0})" + I18nUtil.getString("system_unvalid")), childJobIdItem)); + } + } - // group valid - XxlJobGroup jobGroup = xxlJobGroupDao.load(jobInfo.getJobGroup()); - if (jobGroup == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_jobgroup")+I18nUtil.getString("system_unvalid")) ); - } + // join , avoid "xxx,," + String temp = ""; + for (String item : childJobIds) { + temp += item + ","; + } + temp = temp.substring(0, temp.length() - 1); - // stage job info - XxlJobInfo exists_jobInfo = xxlJobInfoDao.loadById(jobInfo.getId()); - if (exists_jobInfo == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id")+I18nUtil.getString("system_not_found")) ); - } + jobInfo.setChildJobId(temp); + } - // next trigger time (5s后生效,避开预读周期) - long nextTriggerTime = exists_jobInfo.getTriggerNextTime(); - boolean scheduleDataNotChanged = jobInfo.getScheduleType().equals(exists_jobInfo.getScheduleType()) && jobInfo.getScheduleConf().equals(exists_jobInfo.getScheduleConf()); - if (exists_jobInfo.getTriggerStatus() == 1 && !scheduleDataNotChanged) { - try { - Date nextValidTime = JobScheduleHelper.generateNextValidTime(jobInfo, new Date(System.currentTimeMillis() + JobScheduleHelper.PRE_READ_MS)); - if (nextValidTime == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type")+I18nUtil.getString("system_unvalid")) ); - } - nextTriggerTime = nextValidTime.getTime(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type")+I18nUtil.getString("system_unvalid")) ); - } - } + // group valid + XxlJobGroup jobGroup = xxlJobGroupDao.load(jobInfo.getJobGroup()); + if (jobGroup == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_jobgroup") + I18nUtil.getString("system_unvalid"))); + } - exists_jobInfo.setJobGroup(jobInfo.getJobGroup()); - exists_jobInfo.setJobDesc(jobInfo.getJobDesc()); - exists_jobInfo.setAuthor(jobInfo.getAuthor()); - exists_jobInfo.setAlarmEmail(jobInfo.getAlarmEmail()); - exists_jobInfo.setScheduleType(jobInfo.getScheduleType()); - exists_jobInfo.setScheduleConf(jobInfo.getScheduleConf()); - exists_jobInfo.setMisfireStrategy(jobInfo.getMisfireStrategy()); - exists_jobInfo.setExecutorRouteStrategy(jobInfo.getExecutorRouteStrategy()); - exists_jobInfo.setExecutorHandler(jobInfo.getExecutorHandler()); - exists_jobInfo.setExecutorParam(jobInfo.getExecutorParam()); - exists_jobInfo.setExecutorBlockStrategy(jobInfo.getExecutorBlockStrategy()); - exists_jobInfo.setExecutorTimeout(jobInfo.getExecutorTimeout()); - exists_jobInfo.setExecutorFailRetryCount(jobInfo.getExecutorFailRetryCount()); - exists_jobInfo.setChildJobId(jobInfo.getChildJobId()); - exists_jobInfo.setTriggerNextTime(nextTriggerTime); + // stage job info + XxlJobInfo exists_jobInfo = xxlJobInfoDao.loadById(jobInfo.getId()); + if (exists_jobInfo == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("jobinfo_field_id") + I18nUtil.getString("system_not_found"))); + } - exists_jobInfo.setUpdateTime(new Date()); + // next trigger time (5s后生效,避开预读周期) + long nextTriggerTime = exists_jobInfo.getTriggerNextTime(); + boolean scheduleDataNotChanged = jobInfo.getScheduleType().equals(exists_jobInfo.getScheduleType()) && jobInfo.getScheduleConf().equals(exists_jobInfo.getScheduleConf()); + if (exists_jobInfo.getTriggerStatus() == 1 && !scheduleDataNotChanged) { + try { + Date nextValidTime = JobScheduleHelper.generateNextValidTime(jobInfo, new Date(System.currentTimeMillis() + JobScheduleHelper.PRE_READ_MS)); + if (nextValidTime == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type") + I18nUtil.getString("system_unvalid"))); + } + nextTriggerTime = nextValidTime.getTime(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type") + I18nUtil.getString("system_unvalid"))); + } + } + + exists_jobInfo.setJobGroup(jobInfo.getJobGroup()); + exists_jobInfo.setJobDesc(jobInfo.getJobDesc()); + exists_jobInfo.setAuthor(jobInfo.getAuthor()); + exists_jobInfo.setAlarmEmail(jobInfo.getAlarmEmail()); + exists_jobInfo.setScheduleType(jobInfo.getScheduleType()); + exists_jobInfo.setScheduleConf(jobInfo.getScheduleConf()); + exists_jobInfo.setMisfireStrategy(jobInfo.getMisfireStrategy()); + exists_jobInfo.setExecutorRouteStrategy(jobInfo.getExecutorRouteStrategy()); + exists_jobInfo.setExecutorHandler(jobInfo.getExecutorHandler()); + exists_jobInfo.setExecutorParam(jobInfo.getExecutorParam()); + exists_jobInfo.setExecutorBlockStrategy(jobInfo.getExecutorBlockStrategy()); + exists_jobInfo.setExecutorTimeout(jobInfo.getExecutorTimeout()); + exists_jobInfo.setExecutorFailRetryCount(jobInfo.getExecutorFailRetryCount()); + exists_jobInfo.setChildJobId(jobInfo.getChildJobId()); + exists_jobInfo.setTriggerNextTime(nextTriggerTime); + + exists_jobInfo.setUpdateTime(new Date()); xxlJobInfoDao.update(exists_jobInfo); - return ReturnT.SUCCESS; - } + return ReturnT.SUCCESS; + } - @Override - public ReturnT remove(int id) { - XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id); - if (xxlJobInfo == null) { - return ReturnT.SUCCESS; - } + @Override + public ReturnT remove(int id) { + XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id); + if (xxlJobInfo == null) { + return ReturnT.SUCCESS; + } - xxlJobInfoDao.delete(id); - xxlJobLogDao.delete(id); - xxlJobLogGlueDao.deleteByJobId(id); - return ReturnT.SUCCESS; - } + xxlJobInfoDao.delete(id); + xxlJobLogDao.delete(id); + xxlJobLogGlueDao.deleteByJobId(id); + return ReturnT.SUCCESS; + } - @Override - public ReturnT start(int id) { - XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id); - - // valid - ScheduleTypeEnum scheduleTypeEnum = ScheduleTypeEnum.match(xxlJobInfo.getScheduleType(), ScheduleTypeEnum.NONE); - if (ScheduleTypeEnum.NONE == scheduleTypeEnum) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type_none_limit_start")) ); - } - - // next trigger time (5s后生效,避开预读周期) - long nextTriggerTime = 0; - try { - Date nextValidTime = JobScheduleHelper.generateNextValidTime(xxlJobInfo, new Date(System.currentTimeMillis() + JobScheduleHelper.PRE_READ_MS)); - if (nextValidTime == null) { - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type")+I18nUtil.getString("system_unvalid")) ); - } - nextTriggerTime = nextValidTime.getTime(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type")+I18nUtil.getString("system_unvalid")) ); - } - - xxlJobInfo.setTriggerStatus(1); - xxlJobInfo.setTriggerLastTime(0); - xxlJobInfo.setTriggerNextTime(nextTriggerTime); - - xxlJobInfo.setUpdateTime(new Date()); - xxlJobInfoDao.update(xxlJobInfo); - return ReturnT.SUCCESS; - } - - @Override - public ReturnT stop(int id) { + @Override + public ReturnT start(int id) { XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id); - xxlJobInfo.setTriggerStatus(0); - xxlJobInfo.setTriggerLastTime(0); - xxlJobInfo.setTriggerNextTime(0); + // valid + ScheduleTypeEnum scheduleTypeEnum = ScheduleTypeEnum.match(xxlJobInfo.getScheduleType(), ScheduleTypeEnum.NONE); + if (ScheduleTypeEnum.NONE == scheduleTypeEnum) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type_none_limit_start"))); + } - xxlJobInfo.setUpdateTime(new Date()); - xxlJobInfoDao.update(xxlJobInfo); - return ReturnT.SUCCESS; - } + // next trigger time (5s后生效,避开预读周期) + long nextTriggerTime = 0; + try { + Date nextValidTime = JobScheduleHelper.generateNextValidTime(xxlJobInfo, new Date(System.currentTimeMillis() + JobScheduleHelper.PRE_READ_MS)); + if (nextValidTime == null) { + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type") + I18nUtil.getString("system_unvalid"))); + } + nextTriggerTime = nextValidTime.getTime(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + return new ReturnT(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type") + I18nUtil.getString("system_unvalid"))); + } - @Override - public Map dashboardInfo() { + xxlJobInfo.setTriggerStatus(1); + xxlJobInfo.setTriggerLastTime(0); + xxlJobInfo.setTriggerNextTime(nextTriggerTime); - int jobInfoCount = xxlJobInfoDao.findAllCount(); - int jobLogCount = 0; - int jobLogSuccessCount = 0; - XxlJobLogReport xxlJobLogReport = xxlJobLogReportDao.queryLogReportTotal(); - if (xxlJobLogReport != null) { - jobLogCount = xxlJobLogReport.getRunningCount() + xxlJobLogReport.getSucCount() + xxlJobLogReport.getFailCount(); - jobLogSuccessCount = xxlJobLogReport.getSucCount(); - } + xxlJobInfo.setUpdateTime(new Date()); + xxlJobInfoDao.update(xxlJobInfo); + return ReturnT.SUCCESS; + } - // executor count - Set executorAddressSet = new HashSet(); - List groupList = xxlJobGroupDao.findAll(); + @Override + public ReturnT stop(int id) { + XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(id); - if (groupList!=null && !groupList.isEmpty()) { - for (XxlJobGroup group: groupList) { - if (group.getRegistryList()!=null && !group.getRegistryList().isEmpty()) { - executorAddressSet.addAll(group.getRegistryList()); - } - } - } + xxlJobInfo.setTriggerStatus(0); + xxlJobInfo.setTriggerLastTime(0); + xxlJobInfo.setTriggerNextTime(0); - int executorCount = executorAddressSet.size(); + xxlJobInfo.setUpdateTime(new Date()); + xxlJobInfoDao.update(xxlJobInfo); + return ReturnT.SUCCESS; + } - Map dashboardMap = new HashMap(); - dashboardMap.put("jobInfoCount", jobInfoCount); - dashboardMap.put("jobLogCount", jobLogCount); - dashboardMap.put("jobLogSuccessCount", jobLogSuccessCount); - dashboardMap.put("executorCount", executorCount); - return dashboardMap; - } + @Override + public Map dashboardInfo() { - @Override - public ReturnT> chartInfo(Date startDate, Date endDate) { + int jobInfoCount = xxlJobInfoDao.findAllCount(); + int jobLogCount = 0; + int jobLogSuccessCount = 0; + XxlJobLogReport xxlJobLogReport = xxlJobLogReportDao.queryLogReportTotal(); + if (xxlJobLogReport != null) { + jobLogCount = xxlJobLogReport.getRunningCount() + xxlJobLogReport.getSucCount() + xxlJobLogReport.getFailCount(); + jobLogSuccessCount = xxlJobLogReport.getSucCount(); + } - // process - List triggerDayList = new ArrayList(); - List triggerDayCountRunningList = new ArrayList(); - List triggerDayCountSucList = new ArrayList(); - List triggerDayCountFailList = new ArrayList(); - int triggerCountRunningTotal = 0; - int triggerCountSucTotal = 0; - int triggerCountFailTotal = 0; + // executor count + Set executorAddressSet = new HashSet(); + List groupList = xxlJobGroupDao.findAll(); - List logReportList = xxlJobLogReportDao.queryLogReport(startDate, endDate); + if (groupList != null && !groupList.isEmpty()) { + for (XxlJobGroup group : groupList) { + if (group.getRegistryList() != null && !group.getRegistryList().isEmpty()) { + executorAddressSet.addAll(group.getRegistryList()); + } + } + } - if (logReportList!=null && logReportList.size()>0) { - for (XxlJobLogReport item: logReportList) { - String day = DateUtil.formatDate(item.getTriggerDay()); - int triggerDayCountRunning = item.getRunningCount(); - int triggerDayCountSuc = item.getSucCount(); - int triggerDayCountFail = item.getFailCount(); + int executorCount = executorAddressSet.size(); - triggerDayList.add(day); - triggerDayCountRunningList.add(triggerDayCountRunning); - triggerDayCountSucList.add(triggerDayCountSuc); - triggerDayCountFailList.add(triggerDayCountFail); + Map dashboardMap = new HashMap(); + dashboardMap.put("jobInfoCount", jobInfoCount); + dashboardMap.put("jobLogCount", jobLogCount); + dashboardMap.put("jobLogSuccessCount", jobLogSuccessCount); + dashboardMap.put("executorCount", executorCount); + return dashboardMap; + } - triggerCountRunningTotal += triggerDayCountRunning; - triggerCountSucTotal += triggerDayCountSuc; - triggerCountFailTotal += triggerDayCountFail; - } - } else { - for (int i = -6; i <= 0; i++) { - triggerDayList.add(DateUtil.formatDate(DateUtil.addDays(new Date(), i))); - triggerDayCountRunningList.add(0); - triggerDayCountSucList.add(0); - triggerDayCountFailList.add(0); - } - } + @Override + public ReturnT> chartInfo(Date startDate, Date endDate) { - Map result = new HashMap(); - result.put("triggerDayList", triggerDayList); - result.put("triggerDayCountRunningList", triggerDayCountRunningList); - result.put("triggerDayCountSucList", triggerDayCountSucList); - result.put("triggerDayCountFailList", triggerDayCountFailList); + // process + List triggerDayList = new ArrayList(); + List triggerDayCountRunningList = new ArrayList(); + List triggerDayCountSucList = new ArrayList(); + List triggerDayCountFailList = new ArrayList(); + int triggerCountRunningTotal = 0; + int triggerCountSucTotal = 0; + int triggerCountFailTotal = 0; - result.put("triggerCountRunningTotal", triggerCountRunningTotal); - result.put("triggerCountSucTotal", triggerCountSucTotal); - result.put("triggerCountFailTotal", triggerCountFailTotal); + List logReportList = xxlJobLogReportDao.queryLogReport(startDate, endDate); - return new ReturnT>(result); - } + if (logReportList != null && logReportList.size() > 0) { + for (XxlJobLogReport item : logReportList) { + String day = DateUtil.formatDate(item.getTriggerDay()); + int triggerDayCountRunning = item.getRunningCount(); + int triggerDayCountSuc = item.getSucCount(); + int triggerDayCountFail = item.getFailCount(); + + triggerDayList.add(day); + triggerDayCountRunningList.add(triggerDayCountRunning); + triggerDayCountSucList.add(triggerDayCountSuc); + triggerDayCountFailList.add(triggerDayCountFail); + + triggerCountRunningTotal += triggerDayCountRunning; + triggerCountSucTotal += triggerDayCountSuc; + triggerCountFailTotal += triggerDayCountFail; + } + } else { + for (int i = -6; i <= 0; i++) { + triggerDayList.add(DateUtil.formatDate(DateUtil.addDays(new Date(), i))); + triggerDayCountRunningList.add(0); + triggerDayCountSucList.add(0); + triggerDayCountFailList.add(0); + } + } + + Map result = new HashMap(); + result.put("triggerDayList", triggerDayList); + result.put("triggerDayCountRunningList", triggerDayCountRunningList); + result.put("triggerDayCountSucList", triggerDayCountSucList); + result.put("triggerDayCountFailList", triggerDayCountFailList); + + result.put("triggerCountRunningTotal", triggerCountRunningTotal); + result.put("triggerCountSucTotal", triggerCountSucTotal); + result.put("triggerCountFailTotal", triggerCountFailTotal); + + return new ReturnT>(result); + } } diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/resources/i18n/message_en.properties b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/resources/i18n/message_en.properties index 8e7d8352..8b3c8014 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/resources/i18n/message_en.properties +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/resources/i18n/message_en.properties @@ -1,19 +1,19 @@ admin_name=Scheduling Center admin_name_full=Distributed Task Scheduling Platform XXL-JOB -admin_version=2.3.0 +admin_version=2.3.1 admin_i18n=en ## system system_tips=System message -system_ok=Confirm +system_ok=Confirm system_close=Close -system_save=Save +system_save=Save system_cancel=Cancel system_search=Search system_status=Status system_opt=Operate -system_please_input=please input -system_please_choose=please choose +system_please_input=please input +system_please_choose=please choose system_success=success system_fail=fail system_add_suc=add success @@ -191,7 +191,7 @@ joblog_kill_log_limit=Trigger Fail, can not kill job joblog_kill_log_byman=Manual operation, kill job joblog_lost_fail=Job result lost, marked as failure joblog_rolling_log=Rolling log -joblog_rolling_log_refresh=Refresh +joblog_rolling_log_refresh=Refresh joblog_rolling_log_triggerfail=The job trigger fail, can not view the rolling log joblog_rolling_log_failoften=The request for the Rolling log is terminated, the number of failed requests exceeds the limit, Reload the log on the refresh page joblog_logid_unvalid=Log ID is illegal diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/resources/i18n/message_zh_CN.properties b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/resources/i18n/message_zh_CN.properties index 00ca50e1..b3860e49 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/resources/i18n/message_zh_CN.properties +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/resources/i18n/message_zh_CN.properties @@ -1,6 +1,6 @@ admin_name=任务调度中心 admin_name_full=分布式任务调度平台XXL-JOB -admin_version=2.3.0 +admin_version=2.3.1 admin_i18n= ## system @@ -273,4 +273,4 @@ user_update_loginuser_limit=禁止操作当前登录账号 ## help job_help=使用教程 -job_help_document=官方文档 \ No newline at end of file +job_help_document=官方文档 diff --git a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/resources/i18n/message_zh_TC.properties b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/resources/i18n/message_zh_TC.properties index 90bfc1aa..ca069b34 100644 --- a/ruoyi-visual/ruoyi-xxl-job-admin/src/main/resources/i18n/message_zh_TC.properties +++ b/ruoyi-visual/ruoyi-xxl-job-admin/src/main/resources/i18n/message_zh_TC.properties @@ -1,6 +1,6 @@ admin_name=任務調度中心 admin_name_full=分布式任務調度平臺XXL-JOB -admin_version=2.3.0 +admin_version=2.3.1 admin_i18n= ## system @@ -273,4 +273,4 @@ user_update_loginuser_limit=禁止操作當前登入帳號 ## help job_help=使用教程 -job_help_document=官方文件 \ No newline at end of file +job_help_document=官方文件