📄 createindexhtml.java
字号:
package com.buildhtml;
import tools.util.FileIO;
import tools.util.StrReplace;
import tools.util.StringUtil;
import com.saas.sys.log.Logger;
import com.saas.biz.sortMgr.ClassInfoBuild;
import com.saas.sys.exp.SaasApplicationException;
import com.saas.biz.custMgr.Custinfo;
import com.saas.biz.stockorderMgr.Stockorderinfo;
import com.saas.biz.saleMgr.*;
import com.saas.biz.productMgr.ProductInfo;
import com.saas.biz.productclassMgr.Productclass;
import com.saas.biz.newsMgr.NewsInfo;
import com.saas.biz.repositoryMgr.RepositoryInfo;
import com.saas.biz.commen.ParamethodMgr;
import com.saas.biz.propertyuMgr.PropertyuInfo;
import com.saas.biz.JobMgr.JobInfo;
import com.saas.biz.resumeMgr.ResumeInfo;
import com.saas.biz.commen.ParamethodMgr;
import com.saas.biz.ProcessMgr.ProcessInfo;
import com.saas.biz.attachMgr.Attachinfo;
import com.saas.biz.commen.config;
import java.util.*;
/**
* Created by caiwch
* Date: 2008-7-2
* Time: 16:31:20
*/
public class CreateIndexHtml
{
FileAndString FileString =new FileAndString();
ClassInfoBuild classBuild=new ClassInfoBuild();
Logger log = new Logger(this);
public void buildIndex( String rootpath) throws SaasApplicationException
{
config configFile = new config();
configFile.init();
String projpath = configFile.getString("mysqlbase.projpath");
String str = "";
String strTemp = "";
String filepath = projpath + "index.html";
String templatePath = rootpath +"/" + "templates/index.html";
String templateStr = FileIO.LoadFile( templatePath );
String []tab = { "{#include:top#}", "{#include:bottom#}"};
str = StrReplace.replace( templateStr,tab[0],FileString.f2s( rootpath + "/top.html" ) );
str = StrReplace.replace( str,tab[1],FileString.f2s( rootpath + "/footer.jsp" ) );
/*
*行业分类 {#CategoryList#}
*/
log.LOG_INFO( "行业分类" );
try
{
str = StrReplace.replace(str,"{#CategoryList#}",classBuild.getHtmlTemplateStr("000000000000000","2","/zone_b2b/calalogList.jsp?type=" ) );
}
catch (SaasApplicationException e)
{
e.printStackTrace();
}
log.LOG_INFO("最新企业");
/*
*最新企业 {#LatestEnterprise:picture:name:1#} {#LatestEnterprise:6#} {#LatestEnterprise:12#}
*/
String initStr = "<tr><td align=\"center\"><img src={#src#} width=\"100\" height=\"100\" alt={#alt#} /></td></tr><tr><td align=\"center\"><a href=\"{#link#}\" title=\"{#detail:title_long#}\" >{#title#}</a></td></tr>";
String initStr1 = "<li>·<a href=\"{#href#}\" title=\"{#detail:title_long#}\" class=\"news\">{#cust_name#}</a></li>";
strTemp = "";
String strTemp1 = "";
String strTemp2 = "";
Custinfo custinfo = new Custinfo();
ArrayList enterprise = custinfo.getCustomerList( 19 );
if( enterprise != null && enterprise.size() > 0 )
{
for( int i = 0; i < enterprise.size(); i++ )
{
HashMap map = (HashMap) enterprise.get(i);
String cust_id = "";
String cust_name = "";
String sub_custName="";
if( map.get( "cust_id" ) != null )
{
cust_id = map.get( "cust_id" ).toString();
}
if( map.get( "cust_name" ) != null )
{
cust_name = map.get( "cust_name" ).toString();
}
if( cust_name.length()>8 )
{
sub_custName = StringUtil.getLimitLengthString(cust_name,"",14);
}
else
{
sub_custName = cust_name;
}
if( i == 0 )
{
String filePath = new Custinfo().getCustAttachPath( cust_id, "0");
if( filePath == "" || filePath == null )
{
filePath = "/upload/default.gif";
}
strTemp = strTemp + initStr;
strTemp = StrReplace.replace( strTemp, "{#src#}", filePath );
strTemp = StrReplace.replace( strTemp, "{#alt#}", cust_name );
strTemp = StrReplace.replace( strTemp, "{#link#}", "/zone_b2b/enterprise/customer/" + cust_id ); //////////////////////////////////////////////////////////////////////////////////
strTemp = StrReplace.replace( strTemp, "{#detail:title_long#}", cust_name );
strTemp = StrReplace.replace( strTemp, "{#title#}", sub_custName );
}
else if( i > 0 && i < 7 )
{
strTemp1 = strTemp1 + initStr1;
strTemp1 = StrReplace.replace( strTemp1, "{#href#}", "/zone_b2b/enterprise/customer/" + cust_id ); ///////////////////////////////////////////////////////////////////////////////////
strTemp1 = StrReplace.replace( strTemp1, "{#detail:title_long#}", cust_name );
strTemp1 = StrReplace.replace( strTemp1, "{#cust_name#}", sub_custName );
}
else if( i >= 7 && i < enterprise.size() )
{
strTemp2 = strTemp2 + initStr1;
strTemp2 = StrReplace.replace( strTemp2, "{#href#}", "/zone_b2b/enterprise/customer/" + cust_id ); ///////////////////////////////////////////////////////////////////////////////////
strTemp2 = StrReplace.replace( strTemp2, "{#detail:title_long#}", cust_name );
strTemp2 = StrReplace.replace( strTemp2, "{#cust_name#}", sub_custName );
}
}
}
str = StrReplace.replace(str,"{#LatestEnterprise:picture:name:1#}", strTemp );
str = StrReplace.replace(str,"{#LatestEnterprise:6#}", strTemp1 );
str = StrReplace.replace(str,"{#LatestEnterprise:12#}", strTemp2 );
/*
*滚动信息
*
*/
log.LOG_INFO( "滚动信息" );
initStr = "[<span class=\"zi\">供应</span>] <a href=\"{#href1#}\">{#supply:title#}</a> {#date1#} {#company1#} <br>"+
"[<span class=\"zi\">求购</span>] <a href=\"{#href2#}\">{#stock:title#}</a> {#date2#} {#company2#} <br>";
strTemp = "";
SaleInfo saleinfo1 = new SaleInfo();
ArrayList saleList1 = saleinfo1.genSaleList( 4 );
Stockorderinfo stockinfo1 = new Stockorderinfo();
ArrayList stockList1 = stockinfo1.genStockorderLimit( 4 );
if( saleList1 != null && saleList1.size() > 0 && stockList1 != null && stockList1.size() > 0 )
{
for( int i = 0; i < saleList1.size()&&i < stockList1.size(); i++ )
{
HashMap map = ( HashMap )saleList1.get( i );
String cust_id1 = "",cust_name1="";
String sale_id1 ="";
String title1 ="";
String publish_date1 = "";
if( map.get( "sale_id" ) != null )
{
sale_id1 = map.get( "sale_id" ).toString();
}
if( map.get( "sale_unit" ) != null )
{
cust_id1 = map.get( "sale_unit" ).toString();
}
if( map.get( "title" ) != null )
{
title1 = map.get( "title" ).toString();
if( title1.length() > 10 )
title1 = StringUtil.getLimitLengthString(title1,"",20);
}
if( map.get( "publish_date" ) != null )
{
publish_date1 = map.get( "publish_date" ).toString();
if( publish_date1.length() > 10 )
publish_date1 = publish_date1.substring( 6,10 );
}
cust_name1 = new Custinfo().getCustCompany( cust_id1 );
strTemp = strTemp + initStr;
strTemp = StrReplace.replace( strTemp, "{#href1#}", "/zone_b2b/supply/saleInquiry.jsp?sale_id="+sale_id1 );///////////////////////////////////////////////////////////
strTemp = StrReplace.replace( strTemp, "{#supply:title#}", title1 );
strTemp = StrReplace.replace( strTemp, "{#date1#}", publish_date1 );
strTemp = StrReplace.replace( strTemp, "{#company1#}", cust_name1 );
HashMap map2 = ( HashMap )stockList1.get( i );
String cust_id2 = "",cust_name2="";
String stock_id2 ="";
String title2 ="";
String publish_date2 = "";
if( map2.get( "stock_id" ) != null )
{
stock_id2 = map2.get( "stock_id" ).toString();
}
if( map2.get( "cust_id" ) != null )
{
cust_id2 = map2.get( "cust_id" ).toString();
}
if( map2.get( "title" ) != null )
{
title2 = map2.get( "title" ).toString();
if( title2.length() > 10 )
title2 = StringUtil.getLimitLengthString(title2,"",20);
}
if( map2.get( "publish_date" ) != null )
{
publish_date2 = map2.get( "publish_date" ).toString();
if( publish_date2.length() > 10 )
publish_date2 = publish_date2.substring( 6,10 );
}
cust_name2 = new Custinfo().getCustCompany( cust_id2 );
strTemp = StrReplace.replace( strTemp, "{#href2#}", "/zone_b2b/stock/stockInquiry.jsp?stock_id=" + stock_id2 );///////////////////////////////////////////////////////////
strTemp = StrReplace.replace( strTemp, "{#stock:title#}", title2 );
strTemp = StrReplace.replace( strTemp, "{#date2#}", publish_date2 );
strTemp = StrReplace.replace( strTemp, "{#company2#}", cust_name2 );
}
}
str = StrReplace.replace(str,"{#roll:info#}", strTemp );
/*
* 中间新闻图片
*
*/
log.LOG_INFO( "中间新闻图片" );
String []images = { "{#image:1#}","{#image:2#}","{#image:3#}","{#image:4#}","{#image:5#}" };
Attachinfo attach = new Attachinfo();
ArrayList attachList = attach.getAttachInfo();
if( attachList != null && attachList.size() > 0 )
{
for( int i = 0; i < attachList.size(); i++ )
{
HashMap attMap = ( HashMap )attachList.get( i );
String attach_id = attMap.get( "attach_id" ).toString();
String attach_name = "";
String file_path = "";
if( attMap.get( "attach_name" ) != null )
{
attach_name = attMap.get( "attach_name" ).toString();
}
if( attMap.get( "file_path" ) != null )
{
file_path = attMap.get( "file_path" ).toString();
file_path = file_path.substring(23);
}
str = StrReplace.replace(str,images[i], file_path );
}
}
/*
* 推广中心
*/
log.LOG_INFO("推广中心");
initStr = "<tr> "+
"<td class=\"rencei_table_xian\"><span class=\"STYLE2\">主营:{#product#}...</span><br /> "+
"<a href = \"{#link#}\"> {#custName#}</a> "+
"<span class=\"zi\">[{#province#}-{#city#}]</span> "+
"<img src=\"/zone_b2b/images/Max.gif\" align=\"absmiddle\" /> "+
"</td>"+
"</tr>"+
"<tr>"+
" <td height=\"1\" class=\"xian\"></td>"+
"</tr> ";
strTemp = "";
ArrayList promotList = new Custinfo().getPromotionCustList();
if( promotList != null && promotList.size() > 0 )
{
for( int i = 0; i < promotList.size(); i++ )
{
HashMap promap = ( HashMap )promotList.get( i );
String class_id = "";
String class_name = "";
String cust_id = "";
String cust_name = "";
String province = "";
String city = "";
if( promap.get( "class_id" ) != null )
{
class_id = promap.get( "class_id" ).toString();
}
if( promap.get( "class_name" ) != null )
{
class_name = promap.get( "class_name" ).toString();
}
if( promap.get( "cust_id" ) != null )
{
cust_id = promap.get( "cust_id" ).toString();
}
if( promap.get( "cust_name" ) != null )
{
cust_name = promap.get( "cust_name" ).toString();
}
if( promap.get( "province" ) != null )
{
province = promap.get( "province" ).toString();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -