Ejemplo n.º 1
0
  /**
   * 打开打印零售单页面 pdf
   *
   * @return
   */
  public String printLsd() {
    try {
      lsd = (Lsd) lsdService.getLsd(id);

      client_name =
          StringUtils.nullToStr(lsd.getClient_name()) + "  " + StringUtils.nullToStr(lsd.getLxr());
      client_tel =
          StringUtils.nullToStr(lsd.getLxdh())
              + "  "
              + StringUtils.nullToStr(lsd.getMobile())
              + "  "
              + StringUtils.nullToStr(lsd.getMail());
      dept_name =
          StaticParamDo.getDeptNameById(((SysUser) userService.getUser(lsd.getXsry())).getDept());
      xsry_name = StaticParamDo.getRealNameById(lsd.getXsry());
      skfs = StringUtils.nullToStr(lsd.getFkfs());
      skzh_name = StaticParamDo.getAccountNameById(lsd.getSkzh());
      address = StringUtils.nullToStr(lsd.getAddress());
      remark = StringUtils.nullToStr(lsd.getMs());
      jexj_dx = MoneyUtil.toChinese(lsd.getLsdje() + "");
      creatdate = StringUtils.nullToStr(lsd.getCreatdate());

      Map map = sysInitSetService.getReportSet();

      if (map != null) {
        title_name = StringUtils.nullToStr(map.get("title_name")) + "零售单";
        foot_name = StringUtils.nullToStr(map.get("foot_name"));
      }

      lsdProducts = lsdService.getLsdProducts(id);
    } catch (Exception e) {
      log.error("打印零售单出错,原因:" + e.getMessage());
      return ERROR;
    }
    return "success";
  }
  @Override
  public void writeExcelFile(HttpServletRequest request, WritableSheet sheet) {
    try {
      String start_date = StringUtils.nullToStr(request.getParameter("start_date"));
      String end_date = StringUtils.nullToStr(request.getParameter("end_date"));
      String dept_id = StringUtils.nullToStr(request.getParameter("dept_id"));

      String clientId = StringUtils.nullToStr(request.getParameter("clientId"));
      String client_name = StringUtils.nullToStr(request.getParameter("client_name"));
      String product_name = StringUtils.nullToStr(request.getParameter("product_name"));
      String product_kind = StringUtils.nullToStr(request.getParameter("product_kind"));

      String xsry_name = StringUtils.nullToStr(request.getParameter("xsry_name"));

      String con = "";
      con = "日期:" + start_date + "至" + end_date;
      if (!clientId.equals("")) {
        con += "  客户名称:" + clientId;
      }
      if (!dept_id.equals("")) {
        con += "  部门:" + StaticParamDo.getDeptNameById(dept_id);
      }

      if (!product_kind.equals("")) {
        con += "  商品类别:" + StaticParamDo.getProductKindNameById(product_kind);
      }
      con += " 报表生成时间:" + DateComFunc.getCurTime();

      Label label = null;

      // 写统计表标题
      sheet.mergeCells(0, 0, 7, 0);
      label = new Label(0, 0, "商品序列号销售汇总", this.getFt_title());
      sheet.addCell(label);

      // 写统计条件
      sheet.mergeCells(0, 1, 7, 1);
      label = new Label(0, 1, con, this.getFt_item_center());
      sheet.addCell(label);

      // 写统计表头
      label = new Label(0, 2, "日期", this.getFt_item_center_bold());
      sheet.addCell(label);
      label = new Label(1, 2, "序列号", this.getFt_item_center_bold());
      sheet.addCell(label);
      label = new Label(2, 2, "商品名称", this.getFt_item_center_bold());
      sheet.addCell(label);
      label = new Label(3, 2, "商品规格", this.getFt_item_center_bold());
      sheet.addCell(label);
      label = new Label(4, 2, "客户名称", this.getFt_item_center_bold());
      sheet.addCell(label);
      label = new Label(5, 2, "客户电话", this.getFt_item_center_bold());
      sheet.addCell(label);
      label = new Label(6, 2, "销售员", this.getFt_item_center_bold());
      sheet.addCell(label);
      label = new Label(7, 2, "销售价格", this.getFt_item_center_bold());
      sheet.addCell(label);

      List resultList =
          productSerialNumXsHzService.getSerialNumXsList(
              start_date, end_date, product_kind, product_name, dept_id, xsry_name, clientId);

      int hj_nums = 0;
      double hj_je = 0;
      int k = 3;

      // 写统计内容
      if (resultList != null && resultList.size() > 0) {
        for (int i = 0; i < resultList.size(); i++) {
          Map map = (Map) resultList.get(i);
          double je = map.get("xsdj") == null ? 0 : ((Double) map.get("xsdj")).doubleValue();

          label =
              new Label(0, k, StringUtils.nullToStr(map.get("fs_date")), this.getFt_item_left());
          sheet.addCell(label);
          label =
              new Label(1, k, StringUtils.nullToStr(map.get("serial_num")), this.getFt_item_left());
          sheet.addCell(label);
          label =
              new Label(
                  2, k, StringUtils.nullToStr(map.get("product_name")), this.getFt_item_left());
          sheet.addCell(label);
          label =
              new Label(3, k, StringUtils.nullToStr(map.get("product_xh")), this.getFt_item_left());
          sheet.addCell(label);
          label =
              new Label(
                  4, k, StringUtils.nullToStr(map.get("client_name")), this.getFt_item_left());
          sheet.addCell(label);
          label = new Label(5, k, StringUtils.nullToStr(map.get("tel")), this.getFt_item_left());
          sheet.addCell(label);
          label = new Label(6, k, StringUtils.nullToStr(map.get("jsr")), this.getFt_item_left());
          sheet.addCell(label);
          label = new Label(7, k, JMath.round(je, 2), this.getFt_item_right());
          sheet.addCell(label);

          k++;
        }
      }

    } catch (Exception ex) {
      log.info(ex);
    }
  }
Ejemplo n.º 3
0
  /** 写Excel文件 */
  public void writeExcelFile(HttpServletRequest request, WritableSheet sheet) {

    try {
      String start_date = StringUtils.nullToStr(request.getParameter("start_date"));
      String end_date = StringUtils.nullToStr(request.getParameter("end_date"));
      String product_kind = StringUtils.nullToStr(request.getParameter("product_kind"));
      String product_name = StringUtils.nullToStr(request.getParameter("product_name"));
      String store_id = StringUtils.nullToStr(request.getParameter("store_id"));

      String isKc0 = StringUtils.nullToStr(request.getParameter("isKc0")); // 是否显示0库存商品
      String isFse0 = StringUtils.nullToStr(request.getParameter("isFse0")); // 是否显示0发生额商品

      String conStr = "";

      conStr += "日期:" + start_date + "至" + end_date;

      if (!store_id.equals("")) {
        conStr += " 库房:" + StaticParamDo.getStoreNameById(store_id);
      }
      if (!product_kind.equals("")) {
        conStr += " 商品类别:" + StaticParamDo.getProductKindNameById(product_kind);
      }

      Label label = null;

      // 写统计表标题
      sheet.mergeCells(0, 0, 7, 0);
      label = new Label(0, 0, "库存数量汇总", this.getFt_title());
      sheet.addCell(label);

      // 写统计条件
      sheet.mergeCells(0, 1, 7, 1);
      label = new Label(0, 1, conStr, this.getFt_item_center());
      sheet.addCell(label);

      // 写统计表头
      label = new Label(0, 2, "商品编码", this.getFt_item_center_bold());
      sheet.addCell(label);
      label = new Label(1, 2, "商品名称", this.getFt_item_center_bold());
      sheet.addCell(label);
      label = new Label(2, 2, "规格", this.getFt_item_center_bold());
      sheet.addCell(label);
      label = new Label(3, 2, "单位", this.getFt_item_center_bold());
      sheet.addCell(label);
      label = new Label(4, 2, "期初数量", this.getFt_item_center_bold());
      sheet.addCell(label);
      label = new Label(5, 2, "收入数量", this.getFt_item_center_bold());
      sheet.addCell(label);
      label = new Label(6, 2, "发出数量", this.getFt_item_center_bold());
      sheet.addCell(label);
      label = new Label(7, 2, "期末结存", this.getFt_item_center_bold());
      sheet.addCell(label);

      List productKcList = kcMxReportService.getProductKcList(product_kind, product_name, store_id);

      int hj_qc_nums = 0; // 期初数量合计
      int hj_ck_nums = 0; // 出库数量合计
      int hj_rk_nums = 0; // 入库数量合计
      int hj_jc_nums = 0; // 合计结存数量(库存总商品数)

      if (productKcList != null && productKcList.size() > 0) {

        int xh = 0;

        int k = 3;
        for (int i = 0; i < productKcList.size(); i++) {
          Map map = (Map) productKcList.get(i);

          String product_id = StringUtils.nullToStr(map.get("product_id"));
          String product_name2 = StringUtils.nullToStr(map.get("product_name"));
          String product_xh = StringUtils.nullToStr(map.get("product_xh"));
          String dw = StringUtils.nullToStr(map.get("dw"));

          // 根据商品编号、开始时间、库房编号取库存期初情况
          Map qcMap = kcMxReportService.getKcqcMxMap(product_id, start_date, store_id);

          String strNums = "0"; // 期初数
          if (qcMap != null) {
            strNums = StringUtils.nullToStr(qcMap.get("nums"));
            if (strNums.equals("")) {
              strNums = "0";
            }
          }

          int qc_nums = new Integer(strNums).intValue(); // 期初数
          int rk_nums =
              kcMxReportService.getRkNums(product_id, start_date, end_date, store_id); // 收入数量
          int ck_nums =
              kcMxReportService.getCkNums(product_id, start_date, end_date, store_id); // 发出数量

          int jc_nums = qc_nums + rk_nums - ck_nums;

          boolean is_kc = true;
          if (isKc0.equals("否")) { // 显示0库存商品
            if (jc_nums == 0) {
              is_kc = false;
            }
          }

          boolean is_fs = true;
          if (isFse0.equals("否")) { // 显示0发生额商品
            if (rk_nums == 0 && ck_nums == 0) {
              is_fs = false;
            }
          }

          if (is_kc && is_fs) {

            hj_qc_nums += qc_nums;
            hj_rk_nums += rk_nums;
            hj_ck_nums += ck_nums;
            hj_jc_nums += jc_nums;

            xh++;

            label = new Label(0, k, product_id, this.getFt_item_center());
            sheet.addCell(label);
            label = new Label(1, k, product_name2, this.getFt_item_left());
            sheet.addCell(label);
            label = new Label(2, k, product_xh, this.getFt_item_left());
            sheet.addCell(label);
            label = new Label(3, k, dw, this.getFt_item_center());
            sheet.addCell(label);
            label = new Label(4, k, qc_nums + "", this.getFt_item_right());
            sheet.addCell(label);
            label = new Label(5, k, rk_nums + "", this.getFt_item_right());
            sheet.addCell(label);
            label = new Label(6, k, ck_nums + "", this.getFt_item_right());
            sheet.addCell(label);
            label = new Label(7, k, jc_nums + "", this.getFt_item_right());
            sheet.addCell(label);

            k++;
          }
        }

        label = new Label(0, k, "合计", this.getFt_item_center_bold());
        sheet.addCell(label);
        label = new Label(1, k, "", this.getFt_item_left());
        sheet.addCell(label);
        label = new Label(2, k, "", this.getFt_item_left());
        sheet.addCell(label);
        label = new Label(3, k, "", this.getFt_item_center());
        sheet.addCell(label);
        label = new Label(4, k, hj_qc_nums + "", this.getFt_item_right());
        sheet.addCell(label);
        label = new Label(5, k, hj_rk_nums + "", this.getFt_item_right());
        sheet.addCell(label);
        label = new Label(6, k, hj_ck_nums + "", this.getFt_item_right());
        sheet.addCell(label);
        label = new Label(7, k, hj_jc_nums + "", this.getFt_item_right());
        sheet.addCell(label);
      }
    } catch (Exception ex) {
      log.info(ex);
    }
  }