@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 = "/removeJobDefinition")
 public void removeJobDefinition(
     @RequestParam("id") String clientKeys, HttpServletResponse response) throws Exception {
   AssertHelper.notEmpty_assert(clientKeys, "需要删除的job数据不能为空");
   for (String clientId : clientKeys.split(",")) {
     JobDefinition entity =
         (JobDefinition) jobDefinitionService.get(JobDefinition.class, clientId);
     jobDefinitionService.remove(entity);
   }
   JSONObject object = new JSONObject();
   object.put("result", "true");
   object.put("success", "true");
   object.put("msg", "删除成功");
   retJson(response, object);
 }
  /**
   * 立即执行
   *
   * @param map
   * @throws Exception
   */
  @ResponseBody
  @RequestMapping(value = "/exeJob", method = RequestMethod.POST)
  public void exeJob(@RequestParam Map<String, Object> map, HttpServletResponse response)
      throws Exception {
    String selectid = (String) map.get("selectid");
    AssertHelper.notEmpty_assert(selectid, "执行的任务id不能为空");
    JobDefinition jobDefinition =
        (JobDefinition) jobDefinitionService.get(JobDefinition.class, selectid);
    AssertHelper.notEmpty_assert(jobDefinition, "id为" + selectid + "的job定义没有找到");
    String beanId = jobDefinition.getBeanId();
    AssertHelper.notEmpty_assert(jobDefinition, "id为" + selectid + "的job没有定义beanId");
    Object job = SpringUtil.getBean(beanId);
    AssertHelper.notEmpty_assert(job, "beanId为" + beanId + "的bean没有找到");
    if (!((job instanceof Job) && (job instanceof JobTest))) {
      throw new BusinessException("beanId为" + beanId + "的bean必须实现的是org.quartz.Job和JobTest接口");
    }
    JobTest jobTest = (JobTest) job;
    JSONObject object = new JSONObject();
    object.put("success", "true");
    try {
      jobTest.execute();
      JobHistory jobhistory = new JobHistory();
      jobhistory.setEndDate(jobDefinition.getEndDate());
      jobhistory.setStartDate(jobDefinition.getStartDate());
      jobhistory.setId(IdGenerator.getUUID());
      jobhistory.setJobId(beanId);
      jobhistory.setSuccessful(true);
      jobDefinitionService.save(jobhistory);
      retJson(response, object);
    } catch (Exception e) {

      e.printStackTrace();
      JobHistory jobhistory = new JobHistory();
      jobhistory.setEndDate(jobDefinition.getEndDate());
      jobhistory.setStartDate(jobDefinition.getStartDate());
      jobhistory.setId(IdGenerator.getUUID());
      jobhistory.setJobId(beanId);
      jobhistory.setSuccessful(false);
      jobDefinitionService.save(jobhistory);
      object.put("errorMsg", e.getMessage());
      object.put("success", "false");
      retJson(response, object);
    }
  }
  @ResponseBody
  @RequestMapping(value = "/loadModifyJobDefinition")
  public void loadModifyJobDefinition(
      @RequestParam Map<String, Object> map, HttpServletResponse response) throws Exception {
    Object id = map.get("id");
    JSONObject jsonObject = new JSONObject();
    if (!AssertHelper.isOrNotEmpty_assert(id)) {
      AssertHelper.notEmpty_assert(id, "需要删除的数据不能为空");
      jsonObject.put("success", "false");
      jsonObject.put("errorMsg", "编辑的主键不能为空");
    } else {
      JobDefinition entity =
          (JobDefinition) jobDefinitionService.get(JobDefinition.class, id.toString());
      jsonObject.put("success", "true");
      JobDefinitionInParam aa = new JobDefinitionInParam();

      ReflectUtils.copyProperties(entity, aa);
      jsonObject.put("taskShceduleForm", aa);
      retJson(response, jsonObject);
    }
  }
 public void updateModifyJobDefinition(ClientInParam inParam) throws Exception {
   JobDefinition entity =
       (JobDefinition) jobDefinitionService.get(JobDefinition.class, inParam.getId());
   ReflectUtils.copyProperties(inParam, entity);
   jobDefinitionService.update(entity);
 }