📄 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 + -