コード例 #1
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);
  }
コード例 #2
0
  private void loadCompany(Connection con, String unit_code) throws Exception {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String qry = null;

    JCompany obj = null;

    qry =
        " select unit_id, unit_code, unit_name, biz_lx, biz_ym, biz_fl, biz_yx, biz_ch, "
            + "        company_fullName, company_addr,company_district,unit_created "
            + "   from t_unit "
            + "  where unit_code=? ";
    pstmt = con.prepareStatement(qry);
    pstmt.setString(1, unit_code.toUpperCase());
    rs = pstmt.executeQuery();
    if (rs.next()) {
      Set<String> bizSet = null;
      String[] bizTypes = null;
      String szId, szCode, szName;

      bizSet = new HashSet<String>();
      szId = rs.getString("unit_id");
      szCode = rs.getString("unit_code");
      szName = JUtil.convertNull(rs.getString("unit_name"));

      {
        if (rs.getInt("biz_lx") == 1) bizSet.add("留学");
        if (rs.getInt("biz_ym") == 1) bizSet.add("移民");
        if (rs.getInt("biz_yx") == 1) bizSet.add("团组");
        if (rs.getInt("biz_fl") == 1) bizSet.add("外语");
        if (rs.getInt("biz_ch") == 1) bizSet.add("华文");
        bizTypes = new String[bizSet.size()];
        int i = 0;
        for (String biz : bizSet) {
          bizTypes[i++] = biz;
        }
      }

      obj = new JCompany(szId, szCode, szName, bizTypes);

      obj.setCompany_fullName(rs.getString("company_fullName"));
      obj.setCompany_address(rs.getString("company_addr"));
      obj.setCompany_district(rs.getString("company_district"));
      obj.setUnit_created(rs.getDate("unit_created"));
      obj.setBranch(getChildBranch(con, szCode));
    }
    rs.close();
    pstmt.close();

    if (obj == null) return;

    /** ******** 放到 列表 中 ****************** */
    String szId = obj.getCompany_id();
    String szCode = obj.getCompany_code();

    lsBizCompany.remove(szId);
    if (!szCode.startsWith("XT_NB.")) lsBizCompany.add(szId);

    lsOACompany.contains(szId);
    lsOACompany.add(szId);

    mapCompany.put(obj.getCompany_code(), obj);
    int idx = lsCompany.size();
    for (int i = 0; i < lsCompany.size(); i++) {
      JCompany com = lsCompany.get(i);
      if (com.getCompany_id().equals(szId)) {
        idx = i;
        lsCompany.remove(i);
        break;
      }
    }
    lsCompany.add(idx, obj);
  }
コード例 #3
0
  public JCompany getCompanyByCode(String code) throws Exception {
    JCompany obj = mapCompany.get(code.toUpperCase());
    if (obj == null) JLog.getLogger().info("公司没找到code=" + code);

    return obj;
  }