@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); } }