public String dispatchTemp(HttpServletRequest request, ActionForm form) throws Exception {
    String forward = "resultMessage";

    RepairSearchForm searchForm = (RepairSearchForm) form;
    RepairHandleBo rhb = RepairHandleBo.getInstance();
    Long userId = (Long) request.getSession().getAttribute("userId");

    searchForm.setCurrentStatus("T"); // 准备派工
    searchForm.setUpdateBy(userId);
    searchForm.setUpdateDate(new Date());

    String repairMans = request.getParameter("repairMans");

    if (repairMans != null && repairMans.startsWith("@")) {
      repairMans = repairMans.substring(1) + " ";
    }
    rhb.dispatch(searchForm, repairMans);

    String tempAttache = request.getParameter("attacheIds");
    if (tempAttache != null && !tempAttache.equals("")) {
      rhb.updateAttacheByAttacheIdsAndSheetNo(
          tempAttache.split(","), searchForm.getRepairNo(), userId);
    }
    request.setAttribute("tag", "1");
    request.setAttribute("businessFlag", "repairDispatch");

    return forward;
  }
  /**
   * 修复提交审批
   *
   * @param request
   * @param form
   * @return
   * @throws Exception
   */
  public String repairEnd(HttpServletRequest request, ActionForm form) throws Exception {
    String forward = "resultMessage";

    RepairSearchForm searchForm = (RepairSearchForm) form;
    RepairHandleBo rhb = RepairHandleBo.getInstance();
    Long userId = (Long) request.getSession().getAttribute("userId");

    searchForm.setCurrentStatus("F"); // 提交审批
    searchForm.setUpdateBy(userId);
    searchForm.setUpdateDate(new Date());

    try {
      rhb.repairEnd(searchForm);
    } catch (VersionException ve) {
      return "versionErr";
    }
    String tempAttache = request.getParameter("attacheIds");
    if (tempAttache != null && !tempAttache.equals("")) {
      rhb.updateAttacheByAttacheIdsAndSheetNo(
          tempAttache.split(","), searchForm.getRepairNo(), userId);
    }
    request.setAttribute("tag", "1");
    request.setAttribute("businessFlag", "repairEnd");

    return forward;
  }
  /**
   * 返还 -- 返还完成
   *
   * @param request
   * @param form
   * @return
   * @throws Exception
   */
  public String repairReturnEnd(HttpServletRequest request, ActionForm form) throws Exception {
    String forward = "resultMessage";

    RepairSearchForm searchForm = (RepairSearchForm) form;
    RepairHandleBo rhb = RepairHandleBo.getInstance();
    Long userId = (Long) request.getSession().getAttribute("userId");

    searchForm.setCurrentStatus("R"); // 已返还
    searchForm.setUpdateBy(userId);
    searchForm.setUpdateDate(new Date());

    String[] arrivalDate = request.getParameterValues("arrivalDate");
    String[] returnDate = request.getParameterValues("returnDate");
    String[] travelFee = request.getParameterValues("travelFee");
    String[] laborCosts = request.getParameterValues("laborCosts");
    String[] repairCondition = request.getParameterValues("repairCondition");
    String[] travelId = request.getParameterValues("travelId");

    String[] travelIdAjaxAdd = request.getParameterValues("travelIdAjaxAdd");
    String[] repairManAjaxAdd = request.getParameterValues("repairManAjaxAdd");
    String[] departDateAjaxAdd = request.getParameterValues("departDateAjaxAdd");
    String[] arrivalDateAjaxAdd = request.getParameterValues("arrivalDateAjaxAdd");
    String[] returnDateAjaxAdd = request.getParameterValues("returnDateAjaxAdd");
    String[] travelFeeAjaxAdd = request.getParameterValues("travelFeeAjaxAdd");
    String[] laborCostsAjaxAdd = request.getParameterValues("laborCostsAjaxAdd");
    String[] repairConditionAjaxAdd = request.getParameterValues("repairConditionAjaxAdd");
    String[] remarkAjaxAdd = request.getParameterValues("remarkAjaxAdd");

    if (travelId == null) {
      throw new Exception("travelId null!");
    }

    ArrayList<String[]> repairManInfo = new ArrayList<String[]>();
    repairManInfo.add(travelId);
    repairManInfo.add(arrivalDate);
    repairManInfo.add(returnDate);
    repairManInfo.add(travelFee);
    repairManInfo.add(laborCosts);
    repairManInfo.add(repairCondition);

    ArrayList<String[]> repairManInfoAdd = new ArrayList<String[]>();
    repairManInfoAdd.add(travelIdAjaxAdd);
    repairManInfoAdd.add(repairManAjaxAdd);
    repairManInfoAdd.add(departDateAjaxAdd);
    repairManInfoAdd.add(arrivalDateAjaxAdd);
    repairManInfoAdd.add(returnDateAjaxAdd);
    repairManInfoAdd.add(travelFeeAjaxAdd);
    repairManInfoAdd.add(laborCostsAjaxAdd);
    repairManInfoAdd.add(repairConditionAjaxAdd);
    repairManInfoAdd.add(remarkAjaxAdd);

    rhb.returnEnd(searchForm, repairManInfo, repairManInfoAdd);

    request.setAttribute("tag", "1");
    request.setAttribute("businessFlag", "repairReturnEnd");

    return forward;
  }
  /**
   * 电诊--不修理
   *
   * @param request
   * @param form
   * @return
   * @throws Exception
   */
  public String doNotRepair(HttpServletRequest request, ActionForm form) throws Exception {

    RepairSearchForm searchForm = (RepairSearchForm) form;
    RepairHandleBo rhb = RepairHandleBo.getInstance();
    Long userId = (Long) request.getSession().getAttribute("userId");

    searchForm.setCurrentStatus("N");
    searchForm.setUpdateBy(userId);
    searchForm.setUpdateDate(new Date());

    rhb.repairOperate(searchForm);

    String tempAttache = request.getParameter("attacheIds");
    if (tempAttache != null && !tempAttache.equals("")) {
      rhb.updateAttacheByAttacheIdsAndSheetNo(
          tempAttache.split(","), searchForm.getRepairNo(), userId);
    }
    request.setAttribute("tag", "1");
    request.setAttribute("businessFlag", "doNotRepair");

    return "resultMessage";
  }
  /**
   * 维修单录入
   *
   * @param request HttpServletRequest
   * @param form ActionForm
   * @return
   */
  public String serviceAdd(HttpServletRequest request, ActionForm form) throws Exception {
    String forward = "resultMessage";

    String tempAttache = request.getParameter("attacheIds");

    RepairHandleBo rhb = RepairHandleBo.getInstance();
    Long userId = (Long) request.getSession().getAttribute("userId");

    RepairSearchForm searchForm = (RepairSearchForm) form;
    searchForm.setCurrentStatus("A");
    // searchForm.setOperaterId(userId);
    searchForm.setCreateBy(userId);
    searchForm.setCreateDate(new Date());

    searchForm.setPurchaseDate(Operate.toDate(searchForm.getPurchaseDateStr()));
    searchForm.setCustomerVisitDate(Operate.toDate(searchForm.getCustomerVisitDateStr()));
    searchForm.setEstimateRepairDate(Operate.toDate(searchForm.getEstimateRepairDateStr()));
    searchForm.setActualOnsiteDate(Operate.toDate(searchForm.getActualOnsiteDateStr()));
    searchForm.setActualRepairedDate(Operate.toDate(searchForm.getActualRepairedDateStr()));
    // searchForm.setExtendedWarrantyDate(Operate.toDate(searchForm.getExtendedWarrantyDateStr()));

    RepairServiceForm rsf = null;
    try {
      rsf = rhb.addService(searchForm);
    } catch (ComException ce) {
      ce.printStackTrace();
      request.setAttribute("tag", "-1");
      request.setAttribute("tempData", ce.getMessage());
      request.setAttribute("businessFlag", "RR90Err");
      return forward;
    }
    // 保存单据
    Long repairNo = rsf.getRepairNo();

    if (tempAttache != null && !tempAttache.equals("")) {
      rhb.updateAttacheByAttacheIdsAndSheetNo(tempAttache.split(","), repairNo, userId);
    }

    // 提交后不再显示打印也页面
    // request.setAttribute("partsList",SaleInfoBo.getInstance().getSalePartsListByNo(searchForm.getSaleNo()));
    // request.setAttribute("repair", rsf);
    request.setAttribute("tag", "1");
    request.setAttribute("businessFlag", "receiveAdd");

    return forward;
  }