public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    JObject jobject = new JObject();
    try {

      String pin = (String) request.getAttribute("pin");
      Staff staff = StaffDao.verify(Integer.parseInt(pin));

      String reason = request.getParameter("reason");
      CancelReason.InsertBuilder builder = new InsertBuilder(staff.getRestaurantId(), reason);
      CancelReasonDao.insert(staff, builder);
      jobject.initTip(true, "操作成功, 已添加退菜原因信息.");
    } catch (BusinessException e) {
      e.printStackTrace();
      jobject.initTip(e);
    } catch (Exception e) {
      e.printStackTrace();
      jobject.initTip4Exception(e);
    } finally {
      response.getWriter().print(jobject.toString());
    }
    return null;
  }
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    JObject jobject = new JObject();
    SystemSetting set = null;
    try {

      String pin = (String) request.getAttribute("pin");
      StaffDao.verify(Integer.parseInt(pin));

      String restaurantID = (String) request.getAttribute("restaurantID");
      String priceTail = request.getParameter("priceTail");
      String eraseQuota = request.getParameter("eraseQuota");

      if (restaurantID == null || restaurantID.trim().isEmpty()) {
        jobject.initTip(false, "操作失败, 获取餐厅信息失败.");
        return null;
      }

      if (priceTail == null || priceTail.trim().isEmpty()) {
        jobject.initTip(false, "操作失败, 获取收款金额尾数处理方式失败.");
        return null;
      }
      if (eraseQuota == null || eraseQuota.trim().isEmpty()) {
        jobject.initTip(false, "操作失败, 获取抹数金额上限失败.");
        return null;
      }

      set = new SystemSetting();
      set.getSetting().setPriceTail(Integer.parseInt(priceTail));
      set.getSetting().setEraseQuota(Integer.parseInt(eraseQuota));
      set.setRestaurantID(Integer.parseInt(restaurantID));

      SystemDao.updatePriceTail(set);
      jobject.initTip(true, "操作成功, 已修改收款设置.");

    } catch (BusinessException e) {
      e.printStackTrace();
      jobject.initTip(e);

    } catch (Exception e) {
      e.printStackTrace();
      jobject.initTip4Exception(e);
    } finally {
      response.getWriter().print(jobject.toString());
    }

    return null;
  }
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    JObject jobject = new JObject();
    List<PrintFunc> root;
    try {
      String pin = (String) request.getAttribute("pin");
      String printerId = request.getParameter("printerId");
      Staff staff = StaffDao.verify(Integer.parseInt(pin));
      root =
          PrintFuncDao.getByCond(
              staff, new PrintFuncDao.ExtraCond().setPrinter(Integer.parseInt(printerId)));
      List<PrintFunc> roots = new ArrayList<PrintFunc>();

      boolean detail = true;
      for (PrintFunc printFunc : root) {
        if (printFunc.getType() == PType.PRINT_ORDER_DETAIL
            || printFunc.getType() == PType.PRINT_CANCELLED_FOOD_DETAIL) {
          if (printFunc.getType() == PType.PRINT_ORDER_DETAIL) {
            if (detail) {
              roots.add(printFunc);
              detail = false;
            }
          } else if (printFunc.getType() == PType.PRINT_CANCELLED_FOOD_DETAIL) {
            if (detail) {
              printFunc.setType(PType.PRINT_ORDER_DETAIL);
              roots.add(printFunc);
              detail = false;
            }
          }
        } else {
          roots.add(printFunc);
        }
      }

      jobject.setTotalProperty(roots.size());
      jobject.setRoot(roots);

    } catch (BusinessException e) {
      jobject.initTip(e);
      e.printStackTrace();

    } catch (Exception e) {
      jobject.initTip4Exception(e);
      e.printStackTrace();
    } finally {

      response.getWriter().print(jobject.toString());
    }
    return null;
  }
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    final String pin = (String) request.getAttribute("pin");
    final String branchId = request.getParameter("branchId");
    final String beginDate = request.getParameter("beginDate");
    final String opening = request.getParameter("opening");
    final String ending = request.getParameter("ending");
    final String endDate = request.getParameter("endDate");
    final String orderID = request.getParameter("orderID");
    final String tableID = request.getParameter("tableID");
    final String deptID = request.getParameter("deptID");
    final String kitchenId = request.getParameter("kitchenID");
    final String queryType = request.getParameter("queryType");
    final String staffId = request.getParameter("staffID");
    final String isPaging = request.getParameter("isPaging");
    final String start = request.getParameter("start");
    final String limit = request.getParameter("limit");
    final String foodId = request.getParameter("foodId");
    final String regionId = request.getParameter("regionId");
    final String calcByDuty = request.getParameter("calcByDuty");
    final JObject jObject = new JObject();

    try {

      Staff staff = StaffDao.verify(Integer.parseInt(pin));

      if (branchId != null && !branchId.isEmpty() && Integer.parseInt(branchId) > 0) {
        staff = StaffDao.getAdminByRestaurant(Integer.parseInt(branchId));
      }

      List<OrderFood> list = null;

      if (queryType.equalsIgnoreCase("TodayByTbl")) {
        list = OrderFoodDao.getSingleDetailByTableId(staff, Integer.parseInt(tableID));
        if (orderID != null && !orderID.trim().isEmpty()) {
          final float totalPrice =
              OrderDao.getById(staff, Integer.parseInt(orderID), DateType.TODAY).calcTotalPrice();
          jObject.setExtra(
              new Jsonable() {

                @Override
                public JsonMap toJsonMap(int flag) {
                  JsonMap jm = new JsonMap();
                  jm.putFloat("detailTotalPrice", totalPrice);
                  return jm;
                }

                @Override
                public void fromJsonMap(JsonMap jsonMap, int flag) {}
              });
        }
      } else {
        final OrderFoodDao.ExtraCond extraCond;
        if (queryType.equalsIgnoreCase("today")) {
          extraCond = new OrderFoodDao.ExtraCond(DateType.TODAY);
        } else {
          extraCond = new OrderFoodDao.ExtraCond(DateType.HISTORY);
        }

        if (foodId != null && !foodId.isEmpty()) {
          extraCond.setFood(Integer.parseInt(foodId));
        }

        if (kitchenId != null && !kitchenId.isEmpty() && Integer.parseInt(kitchenId) > 0) {
          extraCond.setKitchen(Integer.parseInt(kitchenId));
        }

        if (regionId != null && !regionId.isEmpty() && Integer.parseInt(regionId) > 0) {
          extraCond.setRegionId(Region.RegionId.valueOf(Integer.parseInt(regionId)));
        }

        if (staffId != null && !staffId.isEmpty() && Integer.parseInt(staffId) > 0) {
          extraCond.setStaffId(Integer.parseInt(staffId));
        }

        if (beginDate != null && !beginDate.isEmpty() && endDate != null && !endDate.isEmpty()) {
          if (calcByDuty != null && !calcByDuty.isEmpty() && Boolean.parseBoolean(calcByDuty)) {
            DutyRange range = DutyRangeDao.exec(staff, beginDate, endDate);
            if (range != null) {
              extraCond.setDutyRange(range);
            } else {
              extraCond.setDutyRange(beginDate, endDate);
            }
          } else {
            extraCond.setDutyRange(beginDate, endDate);
          }
        }

        if (opening != null && !opening.isEmpty() && ending != null && !ending.isEmpty()) {
          HourRange range = new HourRange(opening, ending);
          extraCond.setHourRange(range);
        }

        if (deptID != null && !deptID.isEmpty() && !deptID.equals("-1")) {
          extraCond.setDeptId(DeptId.valueOf(Integer.parseInt(deptID)));
        }

        if (orderID != null && !orderID.isEmpty()) {
          extraCond.setOrder(Integer.parseInt(orderID));
        }

        list = OrderFoodDao.getSingleDetail(staff, extraCond, " ORDER BY OF.order_date ");
      }

      if (start != null && !start.isEmpty() && limit != null && !limit.isEmpty()) {
        list = DataPaging.getPagingData(list, Boolean.parseBoolean(isPaging), start, limit);
      }
      jObject.setRoot(list);

    } catch (BusinessException | SQLException e) {
      e.printStackTrace();
      jObject.initTip(e);

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

    } finally {
      response.getWriter().print(jObject.toString());
    }

    return null;
  }