@Override
  public void flowStepUpdate(DeptContactParamVo params) {
    if (resultInfo.getOperateFlag()) {
      DeptContactMainVo mainVo = params.mainVo;

      TDeptContactMain mainBo =
          (TDeptContactMain) commonService.load(mainVo.getId(), TDeptContactMain.class);

      String taskUserLoginName = userInfo.getLoginName();

      try {
        BeanUtils.copyProperties(mainBo, mainVo);
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      } catch (InvocationTargetException e) {
        e.printStackTrace();
      }

      mainBo.setUpdateTime(time);

      mainBo.setOperateDate(time);
      mainBo.setOperateUser(taskUserLoginName);
      mainBo.setOperateName(userInfo.getUserName());

      params.mainBo = mainBo;
      deptContactCommonService.saveReferences(params);

      commonService.update(mainBo);
    }
  }
  @Override
  public void flowStepApply(DeptContactParamVo params) {
    if (resultInfo.getOperateFlag()) {
      String taskUserLoginName = LoginUtil.getUserLoginName(userInfo);
      // mainBo = (TDeptContactMain) params.get("mainBo");
      mainBo = (TDeptContactMain) commonService.load(operateVo.getId(), TDeptContactMain.class);
      params.addProcessParam("cname", mainBo.getProcessname());
      params.addProcessParam("cincident", mainBo.getIncidentno());

      boolean flag = flowApply();

      if (flag) {
        /** 相关资料 */
        params.mainBo = mainBo;
        deptContactCommonService.saveReferences(params);

        /** 取消 */
        if (DeptContactConstants.CHOICE_APPLY_TO_CANCEL.equals(operateVo.getChoice())) {
          mainBo.setRemoved(1);
        }

        /** 更新操作人及更新信息 */
        mainBo.setUpdateTime(time);
        mainBo.setOperateDate(time);
        mainBo.setOperateUser(taskUserLoginName);
        mainBo.setOperateName(userInfo.getUserName());
        commonService.update(mainBo);

        /** 保存意见 */
        deptContactCommonService.saveApprovedInfo(params);

        /** 更新待办事项状态 */
        updateTaskStatus(params.operateVo.getTaskId());

        /** 跳转URL */
        resultInfo.url = TextUtil.generateDeptContactUrl(mainBo, operateVo.getSteplabel());
      } else {
        resultInfo.addErrors(DeptContactMessage.FAIL_TO_COMPLETE_STEP);
        throw new RuntimeException(DeptContactMessage.FAIL_TO_COMPLETE_STEP.textCn);
      }
    }
  }
  @Override
  public void flowStepSign(DeptContactParamVo params) {
    if (resultInfo.getOperateFlag()) {
      mainBo = (TDeptContactMain) commonService.load(operateVo.getId(), TDeptContactMain.class);

      // log.debug("id:"+operateVo.getId());
      // log.debug(params);

      params.addProcessParam("cname", mainBo.getProcessname());
      params.addProcessParam("cincident", mainBo.getIncidentno());

      boolean flag = flowSign();

      if (flag) {
        String taskUserLoginName = LoginUtil.getUserLoginName(userInfo);

        /** 更新操作人及更新信息 */
        mainBo.setUpdateTime(time);
        mainBo.setOperateDate(time);
        mainBo.setOperateUser(taskUserLoginName);
        mainBo.setOperateName(userInfo.getUserName());
        commonService.update(mainBo);

        /** 保存意见 */
        deptContactCommonService.saveApprovedInfo(params);

        /** 更新待办事项状态 */
        updateTaskStatus(params.operateVo.getTaskId());

        /** 跳转URL */
        resultInfo.url = TextUtil.generateDeptContactUrl(mainBo, operateVo.getSteplabel());
      } else {
        resultInfo.addErrors(DeptContactMessage.FAIL_TO_COMPLETE_STEP);
        throw new RuntimeException(DeptContactMessage.FAIL_TO_COMPLETE_STEP.textCn);
      }
    }
  }
  /**
   * Begin节点
   *
   * @param mainVo
   * @param userInfo
   * @param params_dc
   * @throws Exception
   */
  public int flowBegin() {
    String taskUserLoginName = LoginUtil.getUserLoginName(userInfo);

    Map<String, Object> map = new HashMap<String, Object>();

    String sign_leader =
        StringUtil.getNotNullValueString(
            params.getParamObject(DeptContactConstants.PARAMS_KEY_SIGN_LEADER));

    String ip = IpUtil.getIpByStartString(DeptContactConstants.IP_PREFIX);
    String port =
        StringUtil.getNotNullValueString(params.getParamObject(DeptContactConstants.IP_PORT));
    String contextPath =
        StringUtil.getNotNullValueString(
            params.getParamObject(DeptContactConstants.IP_CONTEXT_PATH));

    map.put(DeptContactFlowConstants.SERVERIP, "http://" + ip + ":" + port + "/" + contextPath);

    map.put(DeptContactFlowConstants.USER_BEGIN, taskUserLoginName);
    map.put(DeptContactFlowConstants.USER_APPLY, taskUserLoginName);
    map.put(DeptContactFlowConstants.USER_SIGN, sign_leader);

    map.put(DeptContactFlowConstants.DEPTID, userInfo.getDeptId());
    map.put(DeptContactFlowConstants.TARGET, DeptContactFlowConstants.STEP_SIGN);
    map.put("短信内容", mainBo.getTheme());

    // log.debug("发起流程开始");
    map.put(DeptContactFlowConstants.LINK_PROCESS_KEY, params.treeBo.getId());

    int incidentNo =
        this.launchProcess(mainBo.getProcessname(), taskUserLoginName, mainBo.getTheme(), map);

    log.debug("发起流程结束,incidentNo=" + incidentNo);

    return incidentNo;
  }
  @Override
  public void flowStepAdd(DeptContactParamVo params) {
    // log.debug(resultInfo.checkFlag+" "+resultInfo.checkOnly);
    if (resultInfo.getOperateFlag()) {

      String taskUserLoginName = LoginUtil.getUserLoginName(userInfo);
      String processName = DeptContactConstants.PROCESSNAME;

      /** 创建mainBo */
      mainBo = new TDeptContactMain();
      try {
        BeanUtils.copyProperties(mainBo, mainVo);
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      } catch (InvocationTargetException e) {
        e.printStackTrace();
      }

      mainBo.setCreateDeptid(userInfo.getDeptId());
      mainBo.setCreateDeptname(userInfo.getDeptName());

      mainBo.setInitiator(userInfo.getLoginName());
      mainBo.setInitiatorName(userInfo.getUserName());

      mainBo.setStartTime(time);

      mainBo.setOperateDate(time);
      mainBo.setOperateUser(taskUserLoginName);
      mainBo.setOperateName(userInfo.getUserName());

      mainBo.setProcessname(processName);

      /** 添加关联信息 */
      TDeptContactTree treeBo = DeptContactUtil.generateTreeBo();
      params.treeBo = treeBo;

      treeBo.setCname(processName);
      treeBo.setType(DeptContactConstants.STATUS_MAIN);

      commonService.save(treeBo);

      /** 发起流程 */
      int incidentNo = flowBegin();

      if (incidentNo > 0) {

        String incidentNoStr = String.valueOf(incidentNo);
        mainBo.setIncidentno(incidentNoStr);
        commonService.save(mainBo);

        String id = StringUtil.getNotNullValueString(mainBo.getId());
        if (id.length() == 0) {
          log.warn(DeptContactMessage.FAIL_TO_SAVE_DATA);
          resultInfo.addErrors(DeptContactMessage.FAIL_TO_SAVE_DATA);
          throw new RuntimeException(DeptContactMessage.FAIL_TO_SAVE_DATA.textCn);
        }

        DeptContactUtil.copyOperateInfo(treeBo, mainBo);
        /** 更新关联信息 */
        treeBo.setCId(id);
        treeBo.setCincident(incidentNoStr);
        commonService.update(treeBo);

        try {

          params.addProcessParam("cname", mainBo.getProcessname());
          params.addProcessParam("cincident", mainBo.getIncidentno());

          params.mainBo = mainBo;
          deptContactCommonService.saveReferences(params);

          deptContactCommonService.saveApprovedInfo(params);

        } catch (Exception e) {
          e.printStackTrace();
        }

        /** 跳转URL */
        resultInfo.url =
            TextUtil.generateDeptContactUrl(
                mainBo.getProcessname(), incidentNoStr, mainBo.getProcessname(), incidentNoStr, "");
      } else {
        log.warn(DeptContactMessage.FAIL_TO_LAUNCH_PROCESS);
        resultInfo.addErrors(DeptContactMessage.FAIL_TO_LAUNCH_PROCESS);
        throw new RuntimeException(DeptContactMessage.FAIL_TO_LAUNCH_PROCESS.textCn);
      }
    }
  }