Exemplo n.º 1
0
  public static String getCountP041(String id) throws Exception {
    String ret = "";
    DB db = new DB();
    try {
      DeliveryExhibitItem dei = new DeliveryExhibitItem(db);

      String sql = "";
      sql += " select count(distinct api.track_no) count_qty";
      sql += " from delivery_exhibit_item dei ";
      sql += " inner join app_arrest_prove_exhibit api on api.id=dei.app_arrest_prove_exhibit_id";
      sql += " where dei.delivery_exhibit_id = '" + id + "' ";

      List<Map<String, Object>> list = dei.findBySql(sql);
      if (list != null) {
        ret = list.get(0).get("count_qty") + " ราย";
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      db.closedb();
    }

    return ret;
  }
Exemplo n.º 2
0
  public static String getSumP041(String id, String rtType) throws Exception {
    String ret = "";
    String ret_qty = "";
    String ret_prove = "";
    String ret_remain = "";
    DB db = new DB();
    try {
      DeliveryExhibitItem dei = new DeliveryExhibitItem(db);

      String sql = "";
      sql +=
          "select sum(dei.qty) qty, sum(dei.prove_qty) prove_qty, count(dei.id) count_qty, nvl(dei.qty_unit_name,u.thname) unit_name";
      sql += " from delivery_exhibit_item dei ";
      sql += " left join unit u on u.unit_code = dei.unit_code";
      sql += " where dei.delivery_exhibit_id = '" + id + "' ";
      sql += " group by nvl(dei.qty_unit_name,u.thname) ";
      List<Map<String, Object>> list = dei.findBySql(sql);
      if (list.size() > 1) {
        int qty = 0;
        for (int i = 0; i < list.size(); i++) {
          qty +=
              (list.get(i).get("count_qty") != null
                  ? new Integer(list.get(i).get("count_qty").toString())
                  : null);
        }
        ret = Integer.toString(qty) + " รายการ";

      } else {
        for (int i = 0; i < list.size(); i++) {
          String qty =
              NumberUtil.getNumberFormat(new Double(list.get(i).get("qty").toString()), 0, "0");
          String prove_qty =
              NumberUtil.getNumberFormat(
                  new Double(list.get(i).get("prove_qty").toString()), 0, "0");
          double remain =
              new Double(list.get(i).get("qty").toString())
                  - new Double(list.get(i).get("prove_qty").toString());
          String remain_qty = NumberUtil.getNumberFormat(remain, 0, "0");
          if (!ret_qty.equals("")) {
            ret_qty += "\n" + qty + " " + list.get(i).get("unit_name").toString();
          } else {
            ret_qty = qty + " " + list.get(i).get("unit_name").toString();
          }

          if (!ret_prove.equals("")) {
            ret_prove += "\n" + prove_qty + " " + list.get(i).get("unit_name").toString();
          } else {
            ret_prove += prove_qty + " " + list.get(i).get("unit_name").toString();
          }

          if (!ret_remain.equals("")) {
            ret_remain += "\n" + remain_qty + " " + list.get(i).get("unit_name").toString();
          } else {
            ret_remain += remain_qty + " " + list.get(i).get("unit_name").toString();
          }
        }
        if (rtType.equals("QTY")) ret = ret_qty;
        else if (rtType.equals("PROVE_QTY")) ret = ret_prove;
        else ret = ret_remain;
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      db.closedb();
    }

    return ret;
  }