示例#1
0
  /**
   * 获得公司的分部
   *
   * @param con
   * @param company_code
   * @return
   * @throws SQLException
   */
  private static java.util.List<JUnit> getChildBranch(Connection con, String company_code)
      throws SQLException {
    java.util.List<JUnit> lsBranch = new java.util.ArrayList<JUnit>();
    java.sql.PreparedStatement pstmt = null;
    ResultSet rs = null;
    String sql = null;

    sql =
        "select unit_id from t_unit "
            + " where (parent_code =? or parent_code =?) and is_branch = 1 "
            + " order by unit_index ";
    pstmt = con.prepareStatement(sql);
    pstmt.setString(1, company_code);
    pstmt.setString(2, company_code + ".LX");
    rs = pstmt.executeQuery();
    while (rs.next()) {
      JUnit uObj = JUnit.getUnit(rs.getString("unit_id"));
      lsBranch.add(uObj);
    }
    /*
    if(lsBranch.size() == 0)
    {
    	lsBranch.add(JUnit.getUnitByCode(company_code));
    }*/
    rs.close();
    pstmt.close();
    return lsBranch;
  }
示例#2
0
  public JCompany getCompanyById(String com_id) {
    if (com_id == null || com_id.length() == 0) return null;

    if (JUnit.getUnit(com_id) == null) {
      Exception e = new Exception("部门没找到 com_id=" + com_id);
      JLog.getLogger().error("", e);
      return null;
    }
    String code = JUnit.getUnit(com_id).getUnit_code();

    if (mapCompany.get(code) == null) {
      try {
        loadCompany(code);
      } catch (Exception e) {
        JLog.getLogger().error("", e);
      }
    }
    return mapCompany.get(code);
  }