@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);
    }
  }
  private void updateTaskStatus(String taskId) {
    try {
      taskId = StringUtil.getNotNullValueString(taskId);
      if (taskId.length() > 0) {
        TodoItem todoItem = (TodoItem) commonService.load(taskId, TodoItem.class);
        todoItem.setStatus(TodoConstants.STATUS_DONE);
        commonService.update(todoItem);
      }
    } catch (Exception e) {

    }
  }
  @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);
      }
    }
  }
  /**
   * forward 业务逻辑
   *
   * @param list
   * @param params
   * @return
   */
  private DeptContactMainVo forward(List<Map<String, Object>> list, DeptContactParamVo params) {
    if (list.size() > 0) {
      String id = "";
      Map<String, Object> map = list.get(0);

      String pid = StringUtil.getNotNullValueString(map.get("p_id"));
      String cid = StringUtil.getNotNullValueString(map.get("c_id"));
      String type = StringUtil.getNotNullValueString(map.get("type"));

      // log.debug(pid + "_" +cid + "_"+ type );

      if (type.length() == 0 && cid.length() == 0 && pid.length() == 0) {
        resultInfo.addErrors(DeptContactMessage.CHECK_WRONG_PROCESS_INFO);
      } else {

        String[] c_array =
            new String[] {
              DeptContactConstants.STATUS_MAIN_STR, DeptContactConstants.STATUS_LOWER_STR
            };
        String[] p_array =
            new String[] {
              DeptContactConstants.STATUS_SUB_STR, DeptContactConstants.STATUS_MAIN_BACKSUB_STR
            };

        if (CommonUtil.targetIsInArray(type, c_array)) {
          id = cid;
        } else if (CommonUtil.targetIsInArray(type, p_array)) {
          id = pid;
        } else {
          // log.debug("no type"+type);
        }

        params.addProcessParam(DeptContactConstants.PARAMS_FLOW_TYPE, type);

        if (id.length() == 0) {
          resultInfo.addErrors(DeptContactMessage.CHECK_WRONG_PROCESS_INFO);
        } else {

          try {
            TDeptContactMain mainBo = new TDeptContactMain();
            DeptContactMainVo mainVo = new DeptContactMainVo();

            mainBo = (TDeptContactMain) commonService.load(id, TDeptContactMain.class);

            params.mainBo = mainBo;
            params.treeBo = deptContactDao.getTreeBoByMainBoId(id);

            BeanUtils.copyProperties(mainVo, mainBo);

            params.addParam("mainBo.initiatorName", mainBo.getInitiatorName());
            params.addParam("mainBo.createDeptname", mainBo.getCreateDeptname());
            params.addParam("mainBo.serial", deptContactCommonService.getSerialNumberText(mainBo));

            params.addParam(
                DeptContactConstants.PARAMS_KEY_REF_ID,
                deptContactCommonService.getReferenceIds(mainBo.getId()));

            return mainVo;
          } catch (Exception e) {
            resultInfo.addErrors(DeptContactMessage.CHECK_WRONG_PROCESS_INFO);
          }
        }
      }
    } else {
      resultInfo.addErrors(DeptContactMessage.CHECK_WRONG_PROCESS_INFO);
    }

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