?? custsortmgr.java
字號(hào):
package com.saas.biz.sortMgr;
import java.util.*;
import com.saas.sys.exp.SaasApplicationException;
import com.saas.sys.log.Logger;
import com.saas.biz.dao.productclassDAO.*;
import java.lang.StringBuilder;
public class custSortMgr{
/*
* 獲取企業(yè)的分類信息 +1 次重載 @author: 潘曉峰 @Date: 2007-9-2 @FileName: custSortMgr.java
* @PackageName: com.saas.biz.sort @Method Name: getSortItems
*
* 形 參: parent 父分類 ID 編號(hào),獲取頂級(jí)分類可以傳遞 null 零長(zhǎng)度字符串或 000000000000000
*
* 返回值: 若成功返回子分類信息,子分類信息被裝載在 ArrayList 實(shí)例中
*/
public ArrayList getSortItems() {
return this.getSortItems("000000000000000");
}
public ArrayList getSortItems(String parent) {
if (parent == null || parent.length() == 0)
parent = "000000000000000";
ProductclassExt pe = new ProductclassExt();
pe.setParam(":VCLASS_TYPE", "0");
pe.setParam(":VUP_CLASS_ID", parent);
ArrayList result = pe.selByList("SEL_CHILD_CLASS");
return result;
}
// 劉陽(yáng)2007.12.26
public Map getClassByParentId(String parent) {
Map<String, String> classMap = new LinkedHashMap<String, String>();
ProductclassExt pe = new ProductclassExt();
pe.setParam(":VCLASS_TYPE", "3");// 企業(yè)分類
pe.setParam(":VUP_CLASS_ID", parent);
ArrayList result = pe.selByList("SEL_BY_PARENTID");
if (result != null && result.size() > 0) {
for (int i = 0; i < result.size(); i++) {
HashMap map = (HashMap) result.get(i);
String keys = map.get("class_id").toString();
String value = map.get("class_name").toString();
classMap.put(keys, value);
}
}
return classMap;
}
/*
* 獲取指定企業(yè)分類是否有子分類 @author: 潘曉峰 @Date: 2007-9-2 @FileName: custSortMgr.java
* @PackageName: com.saas.biz.sort @Method Name: hasSubItems
*
* 形 參: parent 父分類 ID 編號(hào),獲取頂級(jí)分類可以傳遞 null 零長(zhǎng)度字符串或 000000000000000
*
* 返回值: 若成功返回子分類信息,子分類信息被裝載在 ArrayList 實(shí)例中
*/
public boolean hasSubItems(String parent) {
if (parent == null || parent.length() == 0)
parent = "000000000000000";
ProductclassExt pe = new ProductclassExt();
pe.setParam(":VCLASS_TYPE", "0");
pe.setParam(":VUP_CLASS_ID", parent);
ArrayList result = pe.selByList("SEL_HASCHILD_CLASS");
if (result == null || result.get(0) == null || "0".equals(((HashMap) result.get(0)).get("class_total").toString()))
return false;
else
return true;
}
/**
* 取出分類信息
*
* @class_Type
* @up_Class_Id
* @class_Name
*/
public List getClassInfoByLimit(String up_class_id, String class_type, int limit) throws SaasApplicationException {
List<HashMap> resultList = new ArrayList<HashMap>();
List list = new ArrayList();
ProductclassExt prodExt = new ProductclassExt();
prodExt.setParam(":VUP_CLASS_ID", up_class_id);
prodExt.setParam(":VCLASS_TYPE", class_type);
prodExt.setParam(":VNUM", limit);
list = prodExt.selByList("SEL_BY_UP_TYPE",0,limit);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
HashMap obj = (HashMap) list.get(i);
HashMap<String, String> map = new HashMap<String, String>();
String id = obj.get("class_id").toString();
String name = obj.get("class_name").toString();
map.put("id", id);
map.put("name", name);
resultList.add(map);
}
}
return resultList;
}
// 取出分類
public ArrayList getClassInfoByUpType(String up_id, String type) throws SaasApplicationException {
ArrayList list = new ArrayList();
ProductclassExt pe = new ProductclassExt();
pe.setParam(":VCLASS_TYPE", type);
pe.setParam(":VUP_CLASS_ID", up_id);
list = pe.selByList("SEL_BY_PARENTID");
return list;
}
/**
* @主方法 生成所有分類模板
*/
public List getHtmlTemplateInfo(String up_id, String type,String linkUrl)throws SaasApplicationException{
List list=new ArrayList();
List lists =new ArrayList();
list=getClassInfoByUpType(up_id,type);
if(list != null && list.size()>0){
lists=getHTMLCodeByHead(list,linkUrl,type);
}
return lists;
}
/**
* 生成一級(jí)、二級(jí)分類和三級(jí)分類的代碼 LinkUrl=/enterprise/e_list.jsp?p_class=
*
* @param R_list
* @param linkUrl
* @return
* @throws SaasApplicationException
*/
@SuppressWarnings("unchecked")
public List getHTMLCodeByHead(List R_list, String linkUrl, String type) throws SaasApplicationException {
List resultList = new ArrayList();
if (R_list != null && R_list.size() > 0) {
for (int i = 0; i < R_list.size(); i++) {
HashMap map = (HashMap) R_list.get(i);
String id = map.get("class_id").toString();
String name = map.get("class_name").toString();
resultList.add(createHtmlTemplate(id, name, linkUrl, type));
}
}
return resultList;
}
// 生成分類HTML
@SuppressWarnings( { "unused", "unchecked" })
public List createHtmlTemplate(String id, String name, String linkUrl, String type) throws SaasApplicationException {
String htmlString = "", classOneName = "";
classOneName = "<a href=" + linkUrl + ">" + name + "</a>";
List resultList = new ArrayList();
// 取出二級(jí)數(shù)據(jù)
ArrayList secendList = getClassInfoByUpType(id, type);
if (secendList != null && secendList.size() > 0) {
int counter = secendList.size();// 二級(jí)的記錄總數(shù)
List list_1 = new ArrayList();
List list_2 = new ArrayList();
List list_3 = new ArrayList();
if (counter % 2 == 0) {
// 偶數(shù)
list_1.addAll(secendList.subList(0, counter / 2));
list_2.addAll(secendList.subList(counter / 2, counter));
}
else {
// 奇數(shù)
int subIni = counter / 2;
list_1.addAll(secendList.subList(0, subIni));
list_2.addAll(secendList.subList(subIni, counter - 1));
list_3.addAll(secendList.subList(counter - 1, counter));
}
// 開始生成二級(jí)和三級(jí)HTML
htmlString = cteateHtmlClassInfo(list_1, linkUrl, type);
htmlString = htmlString + cteateHtmlClassInfo(list_2, linkUrl, type);
htmlString = htmlString + cteateHtmlClassInfo(list_3, linkUrl, type);
}
resultList.add(classOneName);
resultList.add(htmlString);
return resultList;
}
// 生成二級(jí)和三級(jí)HTML分類信息(二級(jí)list)
public String cteateHtmlClassInfo(List list, String linkUrl, String type) throws SaasApplicationException {
String Html = "", main_Html = "", temp_Html = "", three_Html = "";
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
HashMap map = (HashMap) list.get(i);
String id = map.get("class_id").toString();
String name = map.get("class_name").toString();
if (i > 0 && i % 3 == 0) {
main_Html = main_Html + temp_Html + three_Html;
temp_Html = "";
three_Html = "";
}
temp_Html = temp_Html + "<a href=" + linkUrl + id + "><strong>" + name + "</strong></a>";
three_Html = three_Html + createThreeClassInfo(id, linkUrl, type);
}
}
return Html;
}
// 生成三級(jí)分類信息
public String createThreeClassInfo(String id, String linkUrl, String type) throws SaasApplicationException {
String Html = "";
ArrayList threeList = getClassInfoByUpType(id, type);
if (threeList != null && threeList.size() > 0) {
for (int i = 0; i < threeList.size() && i < 10; i++) {
HashMap map = (HashMap) threeList.get(i);
String idx = map.get("class_id").toString();
String name = map.get("class_name").toString();
Html = Html + "<a href=" + linkUrl + idx + ">" + name + "</a> | ";
}
}
return Html;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -