📄 dbprofilemanager.java~4~
字号:
sqle.printStackTrace();
}
finally {
try {
pstmt.close();
}
catch (Exception e) {
e.printStackTrace();
}
try {
con.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
return groupList;
}
///////////////////////////
public int[] getUnderUsers(int userid) { //得到我的直接下级用户
Unit[] units = getUnitsExistManager(userid);
int[] users = null;
ArrayList userList = new ArrayList();
Unit unit = null;
Iterator groups = null;
Group group = null;
User user = null;
Iterator userItr = null;
//////////////////////////////位于同单位的属于我的下级的用户//////////////
for (int i = 0; i < units.length; i++) {
try {
unit = units[i];
}
catch (Exception e) {}
groups = unit.getAssociateGroupsIterator();
while (groups.hasNext()) {
group = (Group) groups.next();
if (group.getPriority() > 0) {
userItr = group.members();
while (userItr.hasNext()) {
user = (User) userItr.next();
userList.add(new Integer(user.getID()));
}
}
}
}
//////////////////////////////////////////////////////////////////
//////////////////////////在我的直接下级单位中的用户//////////////////////////////////////////
for (int i = 0; i < units.length; i++) {
String[] subunits = null;
try {
unit = units[i];
}
catch (Exception e) {}
subunits = unit.getSubUnits();
for (int j = 0; j < subunits.length; j++) {
try {
unit = getUnit(subunits[j]);
}
catch (UnitNotFoundException e) {}
groups = unit.getAssociateGroupsIterator();
while (groups.hasNext()) {
group = (Group) groups.next();
userItr = group.members();
while (userItr.hasNext()) {
user = (User) userItr.next();
userList.add(new Integer(user.getID()));
}
}
}
}
/////////////////////////////过滤掉重复的用户////////////////////////////////////////////////
ArrayList userList_temp = userList;
int users_temp, us;
int count = -1;
int test = 0;
for (int i = 0; i < userList.size(); i++) {
test = userList.size();
us = ( (Integer) userList.get(i)).intValue();
for (int j = 0; j < userList_temp.size(); j++) {
users_temp = ( (Integer) userList_temp.get(j)).intValue();
if (us == users_temp) {
count = count + 1;
}
}
if (count > 0) {
userList.remove(i);
userList_temp = userList;
i = 0;
}
count = -1;
}
//////////////////////////////////////////////////////////////////////////////
users = new int[userList.size()];
for (int i = 0; i < userList.size(); i++) {
users[i] = ( (Integer) userList.get(i)).intValue();
}
return users;
}
public Unit[] getUnitsExistUserID(int userid) {
Unit[] units = null;
HashMap table = new HashMap();
ArrayList groupsList = getGroupsExistUserID_new(userid);
Group group = null;
Unit unit = null;
for (int i = 0; i < groupsList.size(); i++) {
try {
group = this.getGroup( ( (Integer) groupsList.get(i)).intValue());
unit = group.getAssociateUnit();
if (unit != null) {
table.put(unit.getID(), unit);
}
}
catch (GroupNotFoundException e) {}
}
units = new Unit[table.size()];
Iterator iterator = table.keySet().iterator();
int j = 0;
while (iterator.hasNext()) {
String s_ID = (String) iterator.next();
units[j] = (Unit) table.get(s_ID);
j++;
}
return units;
}
public Properties getTopPriAndUnit(int userid) {
Properties prp = new Properties();
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(GET_TOPLEVEL_UNIT_AND_PRI_BY_USER);
pstmt.setString(1,userid+"");
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
String s_pri = rs.getString(1);
String s_unitID = rs.getString(2);
prp.put("pri",s_pri);
prp.put("unitID",s_unitID.trim());
}
}
catch (SQLException sqle) {
sqle.printStackTrace();
}
finally {
try {
pstmt.close();
}
catch (Exception e) {
e.printStackTrace();
}
try {
con.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
return prp;
}
/////////////////////////////
///////////////////////////////
public Unit[] getUnitsExistManager(int userid) { //该用户为高级负责人的单位
Unit[] units = null;
ArrayList groups = getGroupsExistUserID_new(userid);
Group group = null;
Unit unit = null;
HashMap table = new HashMap();
for (int i = 0; i < groups.size(); i++) {
try {
group = this.getGroup( ( (Integer) groups.get(i)).intValue());
unit = group.getAssociateUnit();
if (group.getPriority() == 0 && unit != null) {
table.put(unit.getID(), unit);
}
}
catch (GroupNotFoundException e) {}
}
units = new Unit[table.size()];
Iterator iterator = table.keySet().iterator();
int j = 0;
while (iterator.hasNext()) {
String s_ID = (String) iterator.next();
units[j] = (Unit) table.get(s_ID);
j++;
}
return units;
}
///////////////////////////////////////
public ArrayList getUnitsExistManager_new(int userid) { //该用户为高级负责人的单位
ArrayList groupList = getGroupsExistUserID_new(userid);
Group group = null;
Unit unit = null;
ArrayList unitList = new ArrayList();
for (int i = 0; i < groupList.size(); i++) {
try {
group = getGroup( ( (Integer) groupList.get(i)).intValue());
unit = group.getAssociateUnit();
if (group.getPriority() == 0 && unit != null) {
unitList.add(new Integer(unit.getID()));
}
}
catch (GroupNotFoundException e) {}
}
return unitList;
}
////////////////////////////////////
public User[] getUnderUsers_byunit(int userid, String unitid) {
HashMap table = new HashMap();
Unit unit = null;
Iterator groups = null;
Group group = null;
User user = null;
Iterator userItr = null;
User[] users = null;
try {
unit = getUnit(unitid);
}
catch (UnitNotFoundException e) {}
/////////////////////////////////////////////////////
groups = unit.getAssociateGroupsIterator();
while (groups.hasNext()) {
group = (Group) groups.next();
if (group.getPriority() > 0) {
userItr = group.members();
while (userItr.hasNext()) {
user = (User) userItr.next();
table.put(user.getID() + "", user);
}
}
}
Iterator iterator = table.keySet().iterator();
int j = 0;
users = new User[table.size()];
while (iterator.hasNext()) {
String s_ID = (String) iterator.next();
users[j] = (User) table.get(s_ID);
j++;
}
return users;
}
public int[] getUnderUsers_bysubunit(int userid, String unitid) {
ArrayList userList = new ArrayList();
Unit unit = null;
Iterator groups = null;
Group group = null;
User user = null;
Iterator userItr = null;
int[] users = null;
try {
unit = getUnit(unitid);
}
catch (UnitNotFoundException e) {}
//////////////////////////在我的直接下级单位中的用户//////////////////////////////////////////
String[] subunits = null;
subunits = unit.getSubUnits();
for (int j = 0; j < subunits.length; j++) {
try {
unit = getUnit(subunits[j]);
}
catch (UnitNotFoundException e) {}
groups = unit.getAssociateGroupsIterator();
while (groups.hasNext()) {
group = (Group) groups.next();
userItr = group.members();
while (userItr.hasNext()) {
user = (User) userItr.next();
userList.add(new Integer(user.getID()));
}
}
}
/////////////////////////////////////////////////////////////////////////////
users = new int[userList.size()];
for (int i = 0; i < userList.size(); i++) {
if ( ( (Integer) userList.get(i)).intValue() != 1) {
users[i] = ( (Integer) userList.get(i)).intValue();
}
}
return users;
}
public boolean isPrincipalInUnit(int userid, String unitid, int PRI) {
ArrayList unitsList = getUnitsExistManager_new(userid);
for (int i = 0; i < unitsList.size(); i++) {
if ( ( (String) unitsList.get(i)).equalsIgnoreCase(unitid)) {
return true;
}
}
return false;
}
public String[] getEmails_byUserID(int[] userIDs) {
return new String[10];
}
/**
* Find all the group not linked with any unit
*
* @return the IDs of the Groups
*/
public String[] getAllUnits() {
Connection con = null;
PreparedStatement pstmt = null;
String[] units = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(SELECT_ALL_UNITS);
ResultSet rs = pstmt.executeQuery();
ArrayList unitList = new ArrayList();
while (rs.next()) {
unitList.add(new Integer(rs.getInt(1)));
}
units = new String[unitList.size()];
for (int i = 0; i < units.length; i++) {
units[i] = (String) unitList.get(i);
}
}
catch (SQLException sqle) {
sqle.printStackTrace();
}
finally {
try {
pstmt.close();
}
catch (Exception e) {
e.printStackTrace();
}
try {
con.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
return units;
}
public HashMap getOutSideUnits() {
Connection con = null;
PreparedStatement pstmt = null;
HashMap unitList = new HashMap();
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(GET_OUTSIDE_UNITS);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
String s_djjg = rs.getString(1);
unitList.put(s_djjg.trim(),rs.getString(2));
}
}
catch (SQLException sqle) {
sqle.printStackTrace();
}
finally {
try {
pstmt.close();
}
catch (Exception e) {
e.printStackTrace();
}
try {
con.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
return unitList;
}
public ArrayList getUnitsExistUserID_new(int userid) {
ArrayList groupsList = getGroupsExistUserID_new(userid);
Group group = null;
Unit unit = null;
int unitid;
ArrayList unitList = new ArrayList();
for (int i = 0; i < groupsList.size(); i++) {
try {
group = this.getGroup( ( (Integer) groupsList.get(i)).intValue());
unit = group.getAssociateUnit();
if (unit != null) {
unitList.add(new Integer(unit.getID()));
}
}
catch (GroupNotFoundException e) {}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -