?? createstockinfohtml.java
字號:
package com.buildhtml;
import com.base.config.ProjectConfig;
import tools.util.FileIO;
import tools.util.StrReplace;
import tools.util.StringUtil;
import com.saas.sys.exp.SaasApplicationException;
import com.saas.biz.productclassMgr.Productclass;
import com.saas.biz.stockorderMgr.StockInfo;
import com.saas.biz.stockorderMgr.Stockorderinfo;
import com.saas.biz.dao.productclassDAO.*;
import com.saas.biz.AreaInfoMgr.AreaInfo;
import com.saas.biz.custMgr.Custinfo;
import java.util.*;
import com.saas.sys.log.Logger;
/**
* Created by liuyang Date: 2007-11-21 Time: 11:23:44
*/
public class CreateStockInfoHtml {
FileAndString FileString = new FileAndString();
Logger log = new Logger(this);
public void buildStockIndex(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 = buildStockIndex(rootpath, i, file_name);
log.LOG_INFO(file_name + ">>>>>>>>>>>" + result);
}
}
public int buildStockIndex(String rootpath, int iStart, String file_name) throws SaasApplicationException {
String str = "";
String strTemp = "";
String filepath = rootpath + "/" + "/stock/" + file_name;
String templatePath = rootpath + "/" + "templates/stock.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.html"));
/*
* 最新求購信息 {#ProductCatalog#}
*/
log.LOG_INFO("最新求購");
String initStr = "<tr><td width=\"56%\"><a href=\"{#link#}\">· {#title#}</a></td><td width=\"27%\">{#date#}</td><td width=\"17%\" class=\"zi\">[{#addr#}]</td></tr>";
strTemp = "";
Stockorderinfo stockinfo = new Stockorderinfo();
ArrayList stockList = stockinfo.genStockorderLimit(10);
if (stockList != null && stockList.size() > 0) {
for (int i = 0; i < stockList.size(); i++) {
HashMap map = (HashMap) stockList.get(i);
String stock_id = "";
String title = "";
String end_date = "";
String stock_addr = "";
if (map.get("stock_id") != null) {
stock_id = map.get("stock_id").toString();
}
if (map.get("title") != null) {
title = map.get("title").toString();
if (title.length() > 6)
title = StringUtil.getLimitLengthString(title, "", 12) + "...";
}
if (map.get("end_date") != null) {
end_date = map.get("end_date").toString();
if (end_date.length() > 10) {
end_date = end_date.substring(0, 10);
}
}
if (map.get("stock_addr") != null) {
stock_addr = map.get("stock_addr").toString();
if (stock_addr.length() > 2) {
stock_addr = StringUtil.getLimitLengthString(stock_addr, "", 4);
}
}
strTemp = strTemp + initStr;
strTemp = StrReplace.replace(strTemp, "{#link#}", "/zone_b2b/stock/stockInquiry.jsp?stock_id=" + stock_id);// /////////////////////////////////////////////////////////
strTemp = StrReplace.replace(strTemp, "{#title#}", title);
strTemp = StrReplace.replace(strTemp, "{#date#}", end_date);
strTemp = StrReplace.replace(strTemp, "{#addr#}", stock_addr);
}
}
str = StrReplace.replace(str, "{#ProductCatalog#}", strTemp);
/*
* 緊急求購 genStockEmergency
*/
initStr = "<td width=\"35%\" height=\"100\"><img src=\"{#src#}\" width=\"83\" height=\"53\" /></td>";
String initStr1 = "<tr><td height=\"30\"><strong><a href=\"{#href1#}\" >{#title1#}</a></strong></td></tr>";
String initStr2 = "<tr>" + " <td height=\"24\"><a href=\"{#href2#}\" >{#title2#}</a></td>" + " <td class=\"zi\">[{#addr2#}]</td>" + "</tr>";
strTemp = "";
String strTemp1 = "";
String strTemp2 = "";
ArrayList skList = new Stockorderinfo().genStockEmergency(10);
if (skList != null && skList.size() > 0) {
for (int i = 0; i < skList.size(); i++) {
HashMap skmap = (HashMap) skList.get(i);
String stock_id = "";
String title = "";
String end_date = "";
String stock_addr = "";
if (skmap.get("stock_id") != null) {
stock_id = skmap.get("stock_id").toString();
}
if (skmap.get("title") != null) {
title = skmap.get("title").toString();
if (title.length() > 6)
title = StringUtil.getLimitLengthString(title, "", 12) + "...";
}
if (skmap.get("end_date") != null) {
end_date = skmap.get("end_date").toString();
if (end_date.length() > 10) {
end_date = end_date.substring(0, 10);
}
}
if (skmap.get("stock_addr") != null) {
stock_addr = skmap.get("stock_addr").toString();
if (stock_addr.length() > 2) {
stock_addr = StringUtil.getLimitLengthString(stock_addr, "", 4);
}
}
if (i == 0) {
String filePath = new Custinfo().getCustAttachPath(stock_id, "0");
if (filePath == "" || filePath == null) {
filePath = "/upload/default.gif";
}
strTemp = strTemp + initStr;
strTemp = StrReplace.replace(strTemp, "{#src#}", filePath);
strTemp1 = strTemp1 + initStr1;
strTemp1 = StrReplace.replace(strTemp1, "{#href1#}", "/zone_b2b/stock/stockInquiry.jsp?stock_id=" + stock_id); // ////////////////////////////////////////////////////////////////////////////////
strTemp1 = StrReplace.replace(strTemp1, "{#title1#}", title);
}
else if (i >= 1 && i < skList.size()) {
strTemp2 = strTemp2 + initStr2;
strTemp2 = StrReplace.replace(strTemp2, "{#href2#}", "/zone_b2b/stock/stockInquiry.jsp?stock_id=" + stock_id); // ////////////////////////////////////////////////////////////////////////////////
strTemp2 = StrReplace.replace(strTemp2, "{#title2#}", title);
strTemp2 = StrReplace.replace(strTemp2, "{#addr2#}", stock_addr);
}
}
}
str = StrReplace.replace(str, "{#Emergency:picture:1#}", strTemp);
str = StrReplace.replace(str, "{#Emergency:title:1#}", strTemp1);
str = StrReplace.replace(str, "{#Emergency:title:2#}", strTemp2);
/*
* 求購信息分類導航 {#CategoryNavigation#}
*/
log.LOG_INFO("求購信息分類導航");
try {
str = StrReplace.replace(str, "{#CategoryNavigation#}", getHtmlTemplateStr("000000000000000", "4", "/zone_b2b/calalogList.jsp?&stock=1&type="));
}
catch (SaasApplicationException e) {
e.printStackTrace();
}
// 生成省份信息
String province = getProvinceInfo();
str = StrReplace.replace(str, "{#provice#}", province);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -