Index: forgon-core/src/main/java/com/forgon/directory/action/OrgUnitAction.java =================================================================== diff -u -r18004 -r18022 --- forgon-core/src/main/java/com/forgon/directory/action/OrgUnitAction.java (.../OrgUnitAction.java) (revision 18004) +++ forgon-core/src/main/java/com/forgon/directory/action/OrgUnitAction.java (.../OrgUnitAction.java) (revision 18022) @@ -33,6 +33,7 @@ import com.forgon.tools.StrutsResponseUtils; import com.forgon.tools.hibernate.ObjectDao; import com.forgon.tools.json.JsonPropertyFilter; +import com.forgon.tools.string.StringTools; import com.forgon.tools.util.StrutsUtils; import com.forgon.treenode.ext.model.ExtTreeNode; import com.forgon.treenode.model.THTreeNode; @@ -134,9 +135,11 @@ public void treeLoad() { String parentId = StrutsParamUtils.getPraramValue("parentId", ""); - String json = orgUnitManager.getJsonChildrenNode(Long + if (StringTools.isNotBlank(parentId)) { + String json = orgUnitManager.getJsonChildrenNode(Long .valueOf(parentId)); - StrutsResponseUtils.output(json); + StrutsResponseUtils.output(json); + } } /** * 根据名字,查找到节点,返回根节点到当前节点的路径 Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/operationRoom/operationRoomView.js =================================================================== diff -u -r18007 -r18022 --- ssts-web/src/main/webapp/disinfectsystem/basedatamanager/operationRoom/operationRoomView.js (.../operationRoomView.js) (revision 18007) +++ ssts-web/src/main/webapp/disinfectsystem/basedatamanager/operationRoom/operationRoomView.js (.../operationRoomView.js) (revision 18022) @@ -55,7 +55,7 @@ alert("请选择要删除的手术间!"); return false; } - Ext.MessageBox.confirm("请确认","是否确定要删除选中的组织机构?",function(button, text){ + Ext.MessageBox.confirm("请确认","是否确定要删除选中的手术间?",function(button, text){ if("yes" == button){ Ext.Ajax.request({ url : WWWROOT + '/disinfectSystem/baseData/operationRoomAction!deleteOperationRoomByIds.do', @@ -217,7 +217,9 @@ treeLoader.baseParams.id = node.id; }); - //组织机构Store + /** + * 手术间的Store + */ var operationRoomStore = new Ext.data.Store({ proxy : new Ext.data.HttpProxy({ url : WWWROOT + '/disinfectSystem/baseData/operationRoomAction!searchOperationRoom.do', Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/operationroom/service/OperationRoomManagerImpl.java =================================================================== diff -u -r18004 -r18022 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/operationroom/service/OperationRoomManagerImpl.java (.../OperationRoomManagerImpl.java) (revision 18004) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/operationroom/service/OperationRoomManagerImpl.java (.../OperationRoomManagerImpl.java) (revision 18022) @@ -32,65 +32,55 @@ this.objectDao = objectDao; } @Override - public String getJsonChildrenNode(Long parentId) { - List children = findSubordinateOperationRoomById(parentId); + public String getJsonChildrenNode(Long id) { + List children = findSubordinateOperationRoomById(id); - //获取是否该部门为叶子节点 - ArrayList parentIds = new ArrayList(); if (CollectionUtils.isNotEmpty(children)) { + //所有子节点的id集合 + ArrayList ids = new ArrayList(); for (OperationRoom operationRoom : children) { - parentIds.add(operationRoom.getId()); + ids.add(operationRoom.getId()); } - } - - String parentIdString = ""; - for (Long id : parentIds){ - parentIdString += "," + id ; - } - - if (parentIdString.startsWith(",")){ - parentIdString = parentIdString.substring(1); - } - - String sql = "select parentOperationRoomId, count(*) from OperationRoom where parentOperationRoomId in (" + parentIdString + ") group by parentOperationRoomId"; - - // 子节点数量的Map - Map subNodesCountMap = new HashMap(); - - ResultSet rs = objectDao.executeSql(sql); - try { - while (rs.next()) { - Long myId = rs.getLong(1); - Long subNodesCount = rs.getLong(2); - subNodesCountMap.put(myId, subNodesCount); + + //获取为叶子节点的子节点 + String inMember = SqlUtils.getNonStringFieldInCollectionsPredicate("parentOperationRoomId", ids); + String sql = "select parentOperationRoomId, count(*) from OperationRoom where " + inMember + " group by parentOperationRoomId"; + ResultSet rs = objectDao.executeSql(sql); + + //叶子节点的id和数量的Map + Map subLeafNodesCountMap = new HashMap(); + try { + while (rs.next()) { + Long myId = rs.getLong(1); + Long subNodesCount = rs.getLong(2); + subLeafNodesCountMap.put(myId, subNodesCount); + } + } catch (SQLException e) { + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(rs); } - } catch (SQLException e) { - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(rs); - } - - List operationRoomTreeNodes = new ArrayList(); //kfj - if (CollectionUtils.isNotEmpty(children)) { + + List operationRoomTreeNodes = new ArrayList(); for (OperationRoom thTreeNode : children) { OperationRoomTreeNode operationRoomTreeNode = new OperationRoomTreeNode(); - Long id = thTreeNode.getId(); + Long operationRoomId = thTreeNode.getId(); String orgUnitName = thTreeNode.getOrgUnitName(); String orgUnitCoding = thTreeNode.getOrgUnitCoding(); String isInvoice = thTreeNode.getIsInvoice(); String operationRoomName = thTreeNode.getOperationRoomName(); - operationRoomTreeNode.setId(id); + operationRoomTreeNode.setId(operationRoomId); operationRoomTreeNode.setText(operationRoomName); - operationRoomTreeNode.setHref(String.format("javascript:reloadGrid(%s,'%s','%s','%s','%s');", id, operationRoomName, orgUnitName,orgUnitCoding, isInvoice)); + operationRoomTreeNode.setHref(String.format("javascript:reloadGrid(%s,'%s','%s','%s','%s');", operationRoomId, operationRoomName, orgUnitName,orgUnitCoding, isInvoice)); operationRoomTreeNode.setHrefTarget("_self"); operationRoomTreeNode.setOperationRoomName(operationRoomName); operationRoomTreeNode.setOrgUnitName(orgUnitName); operationRoomTreeNode.setOrgUnitCoding(orgUnitCoding); operationRoomTreeNode.setIsInvoice(isInvoice); - Long subNodesCount = subNodesCountMap.get(id); + Long subNodesCount = subLeafNodesCountMap.get(operationRoomId); boolean isLeaf = true; if (subNodesCount == null || subNodesCount == 0) { isLeaf = true; @@ -100,9 +90,11 @@ operationRoomTreeNode.setLeaf(isLeaf); operationRoomTreeNodes.add(operationRoomTreeNode); } + + JSONArray jsonArray = JSONArray.fromObject(operationRoomTreeNodes); + return jsonArray.toString(); } - JSONArray jsonArray = JSONArray.fromObject(operationRoomTreeNodes); - return jsonArray.toString(); + return null; } /** Index: forgon-core/src/main/java/com/forgon/directory/service/OrgUnitManagerImpl.java =================================================================== diff -u -r18004 -r18022 --- forgon-core/src/main/java/com/forgon/directory/service/OrgUnitManagerImpl.java (.../OrgUnitManagerImpl.java) (revision 18004) +++ forgon-core/src/main/java/com/forgon/directory/service/OrgUnitManagerImpl.java (.../OrgUnitManagerImpl.java) (revision 18022) @@ -307,8 +307,6 @@ } public String getJsonChildrenNode(long parentId) { - List extTreeNodes = new ArrayList(); - List children = null; if (parentId == 0) { String companyId = AcegiHelper.getLoginUser().getCurrentCompanyId(); @@ -328,71 +326,57 @@ OrgUnit.class.getName(), parentId); } - // 获取是否该部门为叶子节点 - ArrayList parentIds = new ArrayList(); - - if (CollectionUtils.isNotEmpty(children)){ + if (CollectionUtils.isNotEmpty(children)) { + // 获取是否该部门为叶子节点 + ArrayList parentIds = new ArrayList(); for (THTreeNode orgUnit : children) { parentIds.add(orgUnit.getId()); } - } - - String parentIdString = ""; - for (Long id : parentIds){ - parentIdString += "," + id ; - } - - if (parentIdString.startsWith(",")){ - parentIdString = parentIdString.substring(1); - } - - String sql = "select parentId, count(*) from OrgUnit where parentId in (" + parentIdString + ") group by parentId"; - - // 子节点数量的Map - Map subNodesCountMap = new HashMap(); - - ResultSet rs = objectDao.executeSql(sql); - try { - while (rs.next()) { - Long myId = rs.getLong(1); - Long subNodesCount = rs.getLong(2); - subNodesCountMap.put(myId, subNodesCount); - + + //获取为叶子节点的子节点 + String inMember = SqlUtils.getNonStringFieldInCollectionsPredicate("parentId", parentIds); + String sql = "select parentId, count(*) from OrgUnit where " + inMember + " group by parentId"; + ResultSet rs = objectDao.executeSql(sql); + + //叶子节点的id和数量的Map + Map subLeafNodesCountMap = new HashMap(); + try { + while (rs.next()) { + Long myId = rs.getLong(1); + Long subNodesCount = rs.getLong(2); + subLeafNodesCountMap.put(myId, subNodesCount); + + } + } catch (SQLException e) { + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(rs); } - } catch (SQLException e) { - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(rs); - } - - - if (CollectionUtils.isNotEmpty(children)) { + + List extTreeNodes = new ArrayList(); for (THTreeNode thTreeNode : children) { ExtTreeNode extTreeNode = new ExtTreeNode(); Long id = thTreeNode.getId(); extTreeNode.setId(id); extTreeNode.setText(thTreeNode.getName()); - extTreeNode.setHref("javascript:reloadGrid(" - + id + ");"); - + extTreeNode.setHref("javascript:reloadGrid(" + id + ");"); extTreeNode.setHrefTarget("_self"); - Long subNodesCount = subNodesCountMap.get(id); + Long subNodesCount = subLeafNodesCountMap.get(id); boolean isLeaf = true; - if (subNodesCount == null || subNodesCount == 0) { isLeaf = true; } else if (subNodesCount > 0) { isLeaf = false; } extTreeNode.setLeaf(isLeaf); - extTreeNodes.add(extTreeNode); } + JSONArray jsonArray = JSONArray.fromObject(extTreeNodes); + return jsonArray.toString(); } - JSONArray jsonArray = JSONArray.fromObject(extTreeNodes); - return jsonArray.toString(); + return null; } public void saveOrUpdata(OrgUnit orgUnit) {