@ResponseBody @RequestMapping(value = "/stopJob", method = RequestMethod.POST) public void stopJob(@RequestParam Map<String, Object> map) throws Exception { String selectid = (String) map.get("selectid"); AssertHelper.notEmpty_assert(selectid, "执行的任务id不能为空"); JobDefinition jobDefinition = (JobDefinition) jobDefinitionService.get(JobDefinition.class, selectid); jobDefinition.setState(JobState.stopping); jobDefinition.setEndDate(new Date()); jobDefinitionService.update(jobDefinition); try { JobHistory jobhistory = new JobHistory(); jobhistory.setEndDate(jobDefinition.getEndDate()); jobhistory.setId(IdGenerator.getUUID()); jobhistory.setJobId(selectid); jobhistory.setSuccessful(true); jobDefinitionService.save(jobhistory); } catch (Exception e) { e.printStackTrace(); JobHistory jobhistory = new JobHistory(); jobhistory.setEndDate(jobDefinition.getEndDate()); jobhistory.setStartDate(jobDefinition.getStartDate()); jobhistory.setId(IdGenerator.getUUID()); jobhistory.setJobId(selectid); jobhistory.setSuccessful(false); jobDefinitionService.save(jobhistory); } }
@ResponseBody @RequestMapping(value = "/saveJobDefinition", method = RequestMethod.POST) public JobDefinition saveJobDefinition( @ModelAttribute("jobDefinitionForm") JobDefinition inParam, HttpServletResponse response) throws Exception { if (AssertHelper.empty(inParam.getId())) { inParam.setId(IdGenerator.getUUID()); jobDefinitionService.save(inParam); } else { jobDefinitionService.update(inParam); } inParam.setId(inParam.getId()); return inParam; }
public void updateModifyJobDefinition(ClientInParam inParam) throws Exception { JobDefinition entity = (JobDefinition) jobDefinitionService.get(JobDefinition.class, inParam.getId()); ReflectUtils.copyProperties(inParam, entity); jobDefinitionService.update(entity); }