?? createsupplyinfohtml.java
字號:
package com.buildhtml;
import com.saas.sys.exp.SaasApplicationException;
import tools.util.StringUtil;
import com.base.config.ProjectConfig;
import tools.util.FileIO;
import tools.util.StrReplace;
import java.util.Vector;
import java.util.Iterator;
import com.saas.sys.log.Logger;
import com.saas.biz.commen.PageTools;
import com.saas.biz.custMgr.Custinfo;
import com.saas.biz.AreaInfoMgr.AreaInfo;
import com.saas.biz.dao.productclassDAO.*;
import com.saas.biz.productclassMgr.Productclass;
import com.saas.biz.saleMgr.SupplyInfo;
import java.util.*;
/**
* @author:caiwch
* @desc: 供應(yīng)信息主頁
* @2008-7-11
*/
public class CreateSupplyInfoHtml {
FileAndString FileString = new FileAndString();
Logger log = new Logger(this);
public void buildSupplyIndex(String rootpath) throws SaasApplicationException {
String file_name = "";
for (int i = 1; i <= 10; i++) {
if (i == 1) {
file_name = "index.html";
}
else {
file_name = "index" + i + ".html";
}
int result = buildSupplyIndex(rootpath, i, file_name);
log.LOG_INFO(file_name + ">>>>>>>>>>>" + result);
}
}
public int buildSupplyIndex(String rootpath, int iStart, String file_name) throws SaasApplicationException {
String str = "";
String strTemp = "";
String filepath = rootpath + "/" + "/supply/" + file_name;
String templatePath = rootpath + "/" + "templates/supply.html";
String templateStr = FileIO.LoadFile(templatePath);
String[] tab = { "{#include:top#}", "{#include:bottom#}" };
log.LOG_INFO(filepath);
log.LOG_INFO(templatePath);
str = StrReplace.replace(templateStr, tab[0], FileString.f2s(rootpath + "/top.html"));
str = StrReplace.replace(str, tab[1], FileString.f2s(rootpath + "/footer.html"));
log.LOG_INFO("最新企業(yè)");
// 最新企業(yè) {#LatestEnterprise:picture:name:1#} {#LatestEnterprise:picture:name:2#} {#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>[{#province#}]<a href=\"{#href#}\" title=\"{#detail:title_long#}\" class=\"news\">{#cust_name#}</a>[{#date#}]</li>";
strTemp = "";
String strTemp1 = "";
String strTemp2 = "";
// getCustAttachPath( cust_id, flag)
Custinfo custinfo = new Custinfo();
ArrayList enterprise = custinfo.getCustomerList(14);
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 = "";
String province = "", province_code = "";
String publish_date = "";
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() > 4) {
sub_custName = StringUtil.getLimitLengthString(cust_name, "", 8) + "..";
}
else {
sub_custName = cust_name;
}
if (map.get("province") != null && !map.get("province").equals("")) {
province_code = map.get("province").toString();
log.LOG_INFO("province_code = " + province_code);
if (province_code == "0" || province_code.equals("0")) {
log.LOG_INFO("province_code = " + province_code);
province = "";
}
else {
province = new AreaInfo().getAreaNameByCode(province_code);
}
}
if (map.get("publish_date") != null) {
publish_date = map.get("publish_date").toString();
if (publish_date.length() > 10) {
publish_date = publish_date.substring(6, 10);
}
}
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 == 1) {
String filePath1 = new Custinfo().getCustAttachPath(cust_id, "0");
if (filePath1 == "" || filePath1 == null) {
filePath1 = "/upload/default.gif";
}
strTemp1 = strTemp1 + initStr;
strTemp1 = StrReplace.replace(strTemp1, "{#src#}", filePath1);
strTemp1 = StrReplace.replace(strTemp1, "{#alt#}", cust_name);
strTemp1 = StrReplace.replace(strTemp1, "{#link#}", "/zone_b2b/enterprise/customer/" + cust_id); // ////////////////////////////////////////////////////////////////////////////////
strTemp1 = StrReplace.replace(strTemp1, "{#detail:title_long#}", cust_name);
strTemp1 = StrReplace.replace(strTemp1, "{#title#}", sub_custName);
}
else if (i > 1 && 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, "{#province#}", province);
strTemp2 = StrReplace.replace(strTemp2, "{#cust_name#}", sub_custName);
strTemp2 = StrReplace.replace(strTemp2, "{#date#}", publish_date);
}
}
}
str = StrReplace.replace(str, "{#LatestEnterprise:picture:name:1#}", strTemp);
str = StrReplace.replace(str, "{#LatestEnterprise:picture:name:2#}", strTemp1);
str = StrReplace.replace(str, "{#LatestEnterprise:12#}", strTemp2);
// 新品推薦
log.LOG_INFO("新品推薦");
try {
str = StrReplace.replace(str, "{#NewProducts#}", getHtmlTemplateStr("000000000000000", "5", "/zone_b2b/calalogList.jsp?&supply=1&type="));
}
catch (SaasApplicationException e) {
e.printStackTrace();
}
// 省份信息
String province = getProvinceInfo();
str = StrReplace.replace(str, "{#provice#}", province);
str = StrReplace.replace(str, "{#provice-1#}", province);
// 生成供應(yīng)列表
SupplyInfo sale = new SupplyInfo();
ArrayList list = sale.getSupplyInfoList(iStart, 5, "3");
String salesinfo = getSaleHtmlInfo(list, 1, "sale_", "s_size", "0", "saleCompare()");
str = StrReplace.replace(str, "{#sale-list-5#}", salesinfo);
// 生成新最供應(yīng)列表
ArrayList newList = sale.getNewSaleInfoList(iStart, 5);
String newSaleString = getSaleHtmlInfo(newList, iStart, "sale_n", "n_size", "1", "orderCompare()");
str = StrReplace.replace(str, "{#new-sale-list-5#}", newSaleString);
FileIO.SaveToFile(str, filepath);
// 生成專區(qū)信息
String select = getClassInfoByType();
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -