⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 createstockinfohtml.java

📁 java阿里巴巴代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
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 + -