?? classinfobuild.java
字號:
package com.saas.biz.sortMgr;
import java.util.*;
import tools.util.StringUtil;
import com.saas.sys.exp.SaasApplicationException;
import com.saas.sys.log.Logger;
import com.saas.biz.dao.productclassDAO.*;
import java.lang.StringBuilder;
import tools.util.StrReplace;
public class ClassInfoBuild
{
Logger log;
public ClassInfoBuild()
{
log = new Logger(this);
}
/*
* 獲取企業的分類信息 +1 次重載 @author: 潘曉峰 @Date: 2007-9-2 @FileName: custSortMgr.java
* @PackageName: com.saas.biz.sort @Method Name: getSortItems
*
* 形 參: parent 父分類 ID 編號,獲取頂級分類可以傳遞 null 零長度字符串或 000000000000000
*
* 返回值: 若成功返回子分類信息,子分類信息被裝載在 ArrayList 實例中
*/
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;
}
// 劉陽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");// 企業分類
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;
}
/*
* 獲取指定企業分類是否有子分類 @author: 潘曉峰 @Date: 2007-9-2 @FileName: custSortMgr.java
* @PackageName: com.saas.biz.sort @Method Name: hasSubItems
*
* 形 參: parent 父分類 ID 編號,獲取頂級分類可以傳遞 null 零長度字符串或 000000000000000
*
* 返回值: 若成功返回子分類信息,子分類信息被裝載在 ArrayList 實例中
*/
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;
}
/**
* 取出分類信息
*/
public List getClassInfoByLimit(String up_class_id, String class_type, int limit) throws SaasApplicationException {
List resultList = new ArrayList();
ProductclassExt prodExt = new ProductclassExt();
prodExt.setParam(":VUP_CLASS_ID", up_class_id);
prodExt.setParam(":VCLASS_TYPE", class_type);
resultList = prodExt.selByList("SEL_BY_UP_TYPE",0,limit);
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;
}
/**
* 生成一級、二級分類和三級分類的代碼 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分類信息(二級list)
public String cteateHtmlClassInfo(List list, String linkUrl, String type) throws SaasApplicationException {
String 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 main_Html;
}
// 生成三級分類信息
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;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Time 2008-1-26
* @author LiuYang
* @param strFrom
* @param strTo
* @return
*/// "000000000000000","3","/zone_b2b/calalogList.jsp?type="
public String getHtmlTemplateStr(String up_id,String type,String linkUrl) throws SaasApplicationException
{
String html="";
ArrayList sourceList = getClassInfoByUpType(up_id,type);
//log.LOG_INFO("sourceList="+sourceList );
if( sourceList != null && sourceList.size() > 0 )
{
for (int i = 0,j=0; i < 14 && j < 7; i = i + 2,j++ )
{
String temp="",tt="";
// log.LOG_INFO("開始獲取一級分類.."+up_id+"|"+type+"| loop====" );
HashMap map1=( HashMap )sourceList.get(i);
String idx1 = map1.get( "class_id" ).toString();
String name1 = map1.get( "class_name" ).toString();
HashMap map2=(HashMap)sourceList.get( i + 1 );
String idx2 = map2.get("class_id").toString();
String name2 = map2.get("class_name").toString();
if( j%2 == 0 )
{
tt = replaceTop1( idx1,name1,idx2,name2,linkUrl,type);
}
else
{
tt = replaceTop2( idx1,name1,idx2,name2,linkUrl,type);
}
html = html + tt;
}
}
return html;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -