⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 entityclassinfo.java

📁 java阿里巴巴代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				String class_name = classMap.get("class_name").toString();
				map.put(class_id, class_name);
			}
		}
		return map;
	}
	
	
	
	// 找出归属于客户的实体分类
	public Map getClassByUpClassAndEntity(String cust_id, String up_class_id, String entity) throws SaasApplicationException {

		ArrayList list = new ArrayList();
		Map<String, String> map = new LinkedHashMap<String, String>();
		ClassExt classExt = new ClassExt();
		classExt.setParam(":VUP_CLASS_ID", up_class_id);
		classExt.setParam(":VCUST_ID", cust_id);
		classExt.setParam(":VENTITY_TYPE", entity);
		list = classExt.selByList("SEL_BY_ENTITY");
		if (list != null && list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				HashMap classMap = (HashMap) list.get(i);
				String class_id = classMap.get("class_id").toString();
				String class_name = classMap.get("class_name").toString();
				map.put(class_id, class_name);
			}
		}
		return map;
	}
	
	
	public ArrayList getEntityByUpClassAndEntity(String cust_id, String up_class_id, String entity) throws SaasApplicationException {

		ArrayList list = new ArrayList();
		ClassExt classExt = new ClassExt();
		classExt.setParam(":VUP_CLASS_ID", up_class_id);
		classExt.setParam(":VCUST_ID", cust_id);
		classExt.setParam(":VENTITY_TYPE", entity);
		list = classExt.selByList("SEL_BY_ENTITY");
		return list;
	}
	
	
	@SuppressWarnings("unchecked")
	public ArrayList getEntityByUpClassMap(String cust_id, String up_class_id, String entity) throws SaasApplicationException {

		ArrayList list = new ArrayList();
		ClassExt classExt = new ClassExt();
		classExt.setParam(":VUP_CLASS_ID", up_class_id);
		classExt.setParam(":VCUST_ID", cust_id);
		classExt.setParam(":VENTITY_TYPE", entity);
		ArrayList classList = classExt.selByList("SEL_BY_ENTITY");
		if (classList != null && classList.size() > 0) {
			for (int i = 0; i < classList.size(); i++) {
				HashMap c_Map = (HashMap) classList.get(i);
				String id = c_Map.get("class_id").toString();
				String name = c_Map.get("class_name").toString();
				HashMap<String, String> map = new HashMap<String, String>();
				map.put(id, name);
				list.add(map);
			}
		}
		return list;
	}
	
	
	
	/**
	 * 通过下级ID找出所有上级的ID和名称
	 * 
	 * @return Map<id,name>
	 */
	public Map getUpClassIdAndName(String class_id, String cust_id, String entity) throws SaasApplicationException {

		Map<String, String> map = new HashMap<String, String>();
		String org_Class_Name = "", org_Class_Id = "";
		ArrayList list = getUpClassByDown(class_id, cust_id, entity);
		if (list != null && list.size() > 0) {
			Map class_Map = (HashMap) list.get(0);
			String class_idx = class_Map.get("class_id").toString();
			String class_name = class_Map.get("class_name").toString();
			String up_class_id = class_Map.get("up_class_id").toString();
			org_Class_Name = class_name + org_Class_Name;
			org_Class_Id = class_idx + org_Class_Id;
			map = getClassNameAndId(up_class_id, cust_id, entity, org_Class_Name, org_Class_Id);
		}
		return map;
	}
	
	
	
	// 找出上级分类
	public ArrayList getUpClassByDown(String down_id, String cust_id, String entity) throws SaasApplicationException {

		ClassExt classExt = new ClassExt();
		classExt.setParam(":VCLASS_ID", down_id);
		classExt.setParam(":VCUST_ID", cust_id);
		classExt.setParam(":VENTITY_TYPE", entity);
		ArrayList list = classExt.selByList("SEL_BY_DOWN");
		return list;
	}
	
	
	public Map<String, String> getClassNameAndId(String class_id, String cust_id, String entity, String org_Class_Name, String org_Class_Id) throws SaasApplicationException {

		ArrayList list = getUpClassByDown(class_id, cust_id, entity);
		Map<String, String> map = new HashMap<String, String>();
		if (list != null && list.size() > 0) {
			Map class_Map = (HashMap) list.get(0);
			String class_idx = class_Map.get("class_id").toString();
			String class_name = class_Map.get("class_name").toString();
			String up_class_id = class_Map.get("up_class_id").toString();
			org_Class_Name = class_name + "|" + org_Class_Name;
			org_Class_Id = class_idx + "|" + org_Class_Id;
			Map maps = getClassNameAndId(up_class_id, cust_id, entity, org_Class_Name, org_Class_Id);
			Entry ent = (Entry) maps.entrySet().iterator().next();
			org_Class_Id = String.valueOf(ent.getKey());
			org_Class_Name = String.valueOf(ent.getValue());
		}
		map.put(org_Class_Id, org_Class_Name);
		return map;
		
	}
	
	
	
	/**
	 * 返回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, String entity) throws SaasApplicationException {

		StringBuffer jsonObj = new StringBuffer();
		jsonObj.append("[");
		String json = "", text = "", id = "";
		ArrayList list = getEntityByUpClassAndEntity(cust_id, up_org_id, entity);
		if (list != null && list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				HashMap map = (HashMap) list.get(i);
				text = map.get("class_name").toString();
				id = map.get("class_id").toString();
				jsonObj.append("{text:'" + text + "',id:'" + id + "',iconCls:'" + iconImg + "',");
				boolean leaf = hasNextNode(cust_id, id, entity);
				if (leaf) {
					jsonObj.append("leaf:false,children:[");
					StringBuffer childrenJson = new StringBuffer();
					String nextNode = getChildrenJsonData(childrenJson, cust_id, id, iconImg, entity);
					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, String entity) throws SaasApplicationException {

		String childrenJson = "", text = "", id = "";
		ArrayList list = getEntityByUpClassAndEntity(cust_id, up_org_id, entity);
		if (list != null && list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				HashMap map = (HashMap) list.get(i);
				text = map.get("class_name").toString();
				id = map.get("class_id").toString();
				jsonObj.append("{text:'" + text + "',id:'" + id + "',iconCls:'" + iconImg + "',");
				boolean leaf = hasNextNode(cust_id, id, entity);
				if (leaf) {
					jsonObj.append("leaf:false,children:[");
					StringBuffer nextJson = new StringBuffer();
					String nextNode = getChildrenJsonData(nextJson, cust_id, id, iconImg, entity);
					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, String entity) throws SaasApplicationException {

		boolean result = false;
		ArrayList list = getEntityByUpClassAndEntity(cust_id, up_org_id, entity);
		if (list != null && list.size() > 0) {
			result = true;
		}
		return result;
	}
	
	/** ************************************************************************************************ */
	/**
	 * 生成多选树
	 */
	public String getJSONCheckBoxTreeData(String cust_id, String up_org_id, String entity, String iconImg) throws SaasApplicationException {

		JSONArray array = new JSONArray();
		String json = "";
		ArrayList list = getEntityByUpClassAndEntity(cust_id, up_org_id, entity);
		if (list != null && list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				HashMap map = (HashMap) list.get(i);
				String text = map.get("class_name").toString();
				String id = map.get("class_id").toString();
				CheckTreeObject tree = new CheckTreeObject();
				tree.setText(text);
				tree.setId(id);
				tree.setChecked(false);
				TreeNode node = isLeaf(cust_id, 0, id, entity);
				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, String entity) 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("class_name").toString();
				String id = map.get("class_id").toString();
				tree.setId(id);
				tree.setText(text);
				tree.setDepth(depth);
				TreeNode node = isLeaf(cust_id, depth, id, entity);
				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, String entity) throws SaasApplicationException {

		depth = depth + 1;
		ArrayList nextList = getEntityByUpClassAndEntity(cust_id, up_id, entity);
		TreeNode node = new TreeNode();
		if (nextList != null && nextList.size() > 0) {
			node.setLeaf(false);
			JSONArray children = getChildrenNodes(cust_id, up_id, depth, nextList, entity);
			node.setChildren(children);
		}
		return node;
	}
	
	
	public ArrayList getAllClassByEntityType(String cust_id,String entity_type) throws SaasApplicationException {
		ArrayList list = new ArrayList();
		ClassExt classExt = new ClassExt();
		classExt.setParam(":VCUST_ID", cust_id);
		classExt.setParam(":VENTITY_TYPE", entity_type);
		list = classExt.selByList("SEL_ALL_BY_ENTITY_TYPE");
		return list;
	}
	
	public ArrayList getAllOppEntityType(String cust_id,String entity_type) throws SaasApplicationException {
		ArrayList list = new ArrayList();
		ClassExt classExt = new ClassExt();
		classExt.setParam(":VCUST_ID", cust_id);
		classExt.setParam(":VENTITY_TYPE","2");
		list = classExt.selByList("SEL_ALL_BY_ENTITY_TYPE");
		return list;
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -