📄 organizeinfo.java
字号:
HashMap<String, String> orgMap = new HashMap<String, String>();
OrganizeExt orgExt = new OrganizeExt();
orgExt.setParam(":VCUST_ID", cust_id);
orgExt.setParam(":VUP_ORG_ID", up_org_id);
list = orgExt.selByList("SEL_BY_UP_ORG");
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
HashMap map = (HashMap) list.get(i);
String org_id = map.get("org_id").toString();
String org_name = map.get("org_name").toString();
orgMap.put(org_id, org_name);
}
}
return orgMap;
}
// 取出下级组织
public List getOrganizeByUpIdMap(String cust_id, String up_org_id) throws SaasApplicationException {
ArrayList list = new ArrayList();
List<HashMap<String, String>> Treelist = new ArrayList<HashMap<String, String>>();
try {
OrganizeExt orgExt = new OrganizeExt();
orgExt.setParam(":VCUST_ID", cust_id);
orgExt.setParam(":VUP_ORG_ID", up_org_id);
list = orgExt.selByList("SEL_BY_UP_ORG");
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
HashMap map = (HashMap) list.get(i);
String org_id = map.get("org_id").toString();
String org_name = map.get("org_name").toString();
HashMap<String, String> orgMap = new HashMap<String, String>();
orgMap.put(org_id, org_name);
Treelist.add(orgMap);
}
}
}
catch (RuntimeException e) {
log.LOG_INFO(e.getMessage());
}
return Treelist;
}
// 判断是否有下级
public int checkChildren(String cust_id, String up_org_id) throws SaasApplicationException {
HashMap map = getOrganizeByUpId(cust_id, up_org_id);
int size = 0;
if (map != null && map.size() > 0) {
size = 1;
}
return size;
}
public ArrayList getOrganizeByUpIdList(String cust_id, String up_org_id) throws SaasApplicationException {
ArrayList list = new ArrayList();
OrganizeExt orgExt = new OrganizeExt();
orgExt.setParam(":VCUST_ID", cust_id);
orgExt.setParam(":VUP_ORG_ID", up_org_id);
list = orgExt.selByList("SEL_BY_UP_ORG");
return list;
}
// 取出单个组织
public HashMap getOrganizeByOrgId(String org_id) throws SaasApplicationException {
ArrayList list = new ArrayList();
HashMap<String, String> orgMap = new HashMap<String, String>();
OrganizeExt orgExt = new OrganizeExt();
orgExt.setParam(":VORG_ID", org_id);
list = orgExt.selByList("SEL_BY_ID");
String name = "", desc = "", remark = "";
if (list != null && list.size() > 0) {
HashMap map = (HashMap) list.get(0);
if (map.get("org_name") != null) {
name = map.get("org_name").toString();
}
if (map.get("org_desc") != null) {
desc = map.get("org_desc").toString();
}
if (map.get("remark") != null) {
remark = map.get("remark").toString();
}
}
orgMap.put("org_id", org_id);
orgMap.put("org_name", name);
orgMap.put("org_desc", desc);
orgMap.put("remark", remark);
return orgMap;
}
public String getOrgnaizeById(String depart_code) throws SaasApplicationException {
String org_name = "";
ArrayList list = getOrgnaizeByOrg_id(depart_code);
if (list != null && list.size() > 0) {
HashMap map = (HashMap) list.get(0);
if (map.get("org_name") != null) {
org_name = map.get("org_name").toString();
}
}
return org_name;
}
public String getCustNameById(String cust_id) throws SaasApplicationException {
String cust_name = "";
ArrayList itemsList = new ArrayList();
CustomerExt customerExt = new CustomerExt();
customerExt.setParam(":VCUST_ID", cust_id);
itemsList = customerExt.selByList("SEL_SPEC_CUST");
if (itemsList != null && itemsList.size() > 0) {
HashMap map = (HashMap) itemsList.get(0);
if (map.get("cust_name") != null) {
cust_name = map.get("cust_name").toString();
}
}
return cust_name;
}
/**
* 返回Json数据
*
* @param cust_id
* @param up_org_id
* @param iconImg
* @return
* @throws SaasApplicationException
*/
public String getJsonDataForTree(String cust_id, String up_org_id, String iconImg) throws SaasApplicationException {
StringBuffer jsonObj = new StringBuffer();
log.LOG_INFO("进入getJsonDataForTree方法 cust_id=" + cust_id + " up_org_id=" + up_org_id);
jsonObj.append("[");
String json = "", text = "", id = "";
ArrayList list = getOrganizeByUpIdList(cust_id, up_org_id);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
HashMap map = (HashMap) list.get(i);
text = map.get("org_name").toString();
id = map.get("org_id").toString();
jsonObj.append("{text:'" + text + "',id:'" + id + "',iconCls:'" + iconImg + "',");
boolean leaf = hasNextNode(cust_id, id);
if (leaf) {
jsonObj.append("leaf:false,children:[");
StringBuffer childrenJson = new StringBuffer();
String nextNode = getChildrenJsonData(childrenJson, cust_id, id, iconImg);
jsonObj.append(nextNode);
jsonObj.append("]},");
}
else {
jsonObj.append("leaf:true},");
}
}
jsonObj.deleteCharAt(jsonObj.lastIndexOf(","));
jsonObj.append("]");
json = jsonObj.toString();
}
return json;
}
/**
* 递归生成子节点
*
* @param jsonObj
* @param cust_id
* @param up_org_id
* @param iconImg
* @return JSON_Object
* @throws SaasApplicationException
*/
public String getChildrenJsonData(StringBuffer jsonObj, String cust_id, String up_org_id, String iconImg) throws SaasApplicationException {
String childrenJson = "", text = "", id = "";
ArrayList list = getOrganizeByUpIdList(cust_id, up_org_id);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
HashMap map = (HashMap) list.get(i);
text = map.get("org_name").toString();
id = map.get("org_id").toString();
jsonObj.append("{text:'" + text + "',id:'" + id + "',iconCls:'" + iconImg + "',");
boolean leaf = hasNextNode(cust_id, id);
if (leaf) {
jsonObj.append("leaf:false,children:[");
StringBuffer nextJson = new StringBuffer();
String nextNode = getChildrenJsonData(nextJson, cust_id, id, iconImg);
jsonObj.append(nextNode);
jsonObj.append("]},");
}
else {
jsonObj.append("leaf:true},");
}
}
jsonObj.deleteCharAt(jsonObj.lastIndexOf(","));
childrenJson = jsonObj.toString();
}
return childrenJson;
}
/**
* 判断是否有子节点
*
* @param cust_id
* @param up_org_id
* @return Boolean
* @throws SaasApplicationException
*/
public boolean hasNextNode(String cust_id, String up_org_id) throws SaasApplicationException {
boolean result = false;
ArrayList list = getOrganizeByUpIdList(cust_id, up_org_id);
if (list != null && list.size() > 0) {
result = true;
}
return result;
}
/** ************************************************************************************************ */
/**
* 生成多选树
*/
public String getJSONCheckBoxTreeData(String cust_id, String up_org_id, String iconImg) throws SaasApplicationException {
JSONArray array = new JSONArray();
String json = "";
ArrayList list = getOrganizeByUpIdList(cust_id, up_org_id);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
HashMap map = (HashMap) list.get(i);
String text = map.get("org_name").toString();
String id = map.get("org_id").toString();
CheckTreeObject tree = new CheckTreeObject();
tree.setText(text);
tree.setId(id);
tree.setChecked(false);
TreeNode node = isLeaf(cust_id, 0, id);
tree.setDepth(0);
tree.setIconCls(iconImg);
tree.setLeaf(node.isLeaf());
tree.setChildren(node.getChildren());
array.add(tree);
}
json = array.toString();
}
return json;
}
/**
* @param cust_id
* @param root_id
* @param nextList
* @return children
* @throws SaasApplicationException
*/
public JSONArray getChildrenNodes(String cust_id, String root_id, int depth, ArrayList nextList) throws SaasApplicationException {
JSONArray children = new JSONArray();
if (nextList != null && nextList.size() > 0) {
for (int i = 0; i < nextList.size(); i++) {
HashMap map = (HashMap) nextList.get(i);
CheckTreeObject tree = new CheckTreeObject();
String text = map.get("org_name").toString();
String id = map.get("org_id").toString();
tree.setId(id);
tree.setText(text);
tree.setDepth(depth);
TreeNode node = isLeaf(cust_id, depth, id);
tree.setChildren(node.getChildren());
tree.setLeaf(node.isLeaf());
children.add(tree);
}
}
return children;
}
/**
* @param cust_id
* @param up_id
* @return TreeNode
* @throws SaasApplicationException
*/
public TreeNode isLeaf(String cust_id, int depth, String up_id) throws SaasApplicationException {
depth = depth + 1;
ArrayList nextList = getOrganizeByUpIdList(cust_id, up_id);
TreeNode node = new TreeNode();
if (nextList != null && nextList.size() > 0) {
node.setLeaf(false);
JSONArray children = getChildrenNodes(cust_id, up_id, depth, nextList);
node.setChildren(children);
}
return node;
}
public String getSelectOrg(String cust_id) throws SaasApplicationException {
ArrayList list = new ArrayList();
HashMap map = new HashMap();
try {
OrganizeExt orgExt = new OrganizeExt();
orgExt.setParam(":VCUST_ID", cust_id);
list = orgExt.selByList("SEL_BY_CUST");
}
catch (RuntimeException e) {
log.LOG_INFO(e.getMessage());
}
String org_id="",org_name="",str="";
if(list!=null && list.size()>0){
for(int i=0;i<list.size();i++){
map = (HashMap)list.get(i);
org_id=map.get("org_id").toString();
org_name=map.get("org_name").toString();
str+="<option value="+org_id+">"+org_name+"</option>";
}
}
return str;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -