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

📄 createcustomerhtml.java

📁 java阿里巴巴代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
package com.buildhtml;

import java.util.ArrayList;
import java.util.HashMap;
import tools.util.FileIO;
import tools.util.StrReplace;
import com.saas.biz.JobMgr.JobInfo;
import com.saas.biz.biddingMgr.Biddinginfo;
import com.saas.biz.commen.ParamethodMgr;
import com.saas.biz.creditMgr.CreditInfo;
import com.saas.biz.custMgr.Custinfo;
import com.saas.biz.custlinkMgr.CustlinkInfo;
import com.saas.biz.newsMgr.NewsInfo;
import com.saas.biz.productMgr.ProductInfo;
import com.saas.biz.repositoryMgr.RepositoryInfo;
import com.saas.biz.saleMgr.SaleInfo;
import com.saas.biz.stockorderMgr.Stockorderinfo;
import com.saas.sys.exp.SaasApplicationException;
import com.saas.sys.log.Logger;
import com.saas.biz.commen.config;

/**
 * Created by IntelliJ IDEA. User: caiwch Date: 2008-7-11 Time: 09:25:03 To change this template use File | Settings | File Templates.
 */
public class CreateCustomerHtml 
{
	Logger log;
	FileAndString FileString = new FileAndString();
	public CreateCustomerHtml() 
	{
		log = new Logger(this);
	}
	
	
	
	/*
	 * 生成企业介绍
	 */
	public int createCustomerIntroduce(String rootpath) throws SaasApplicationException 
	{
		log.LOG_INFO("生成企业介绍");
		config configFile = new config();
	  configFile.init();
	  String webtitle = configFile.getString("mysqlbase.webtitle");
		int error = 0;
		String str = "", cust_id = "";
		String filepath = rootpath + "enterprise/customer";
		String temppath = filepath;
		String filename = "index.htm";
		String templatePath = rootpath + "templates/enterprise/default/ym_introduce.html";
		String[] tab = { "{#include:bottom#}", "{#cust:name#}", "{#cust:scope#}", "{#company_logo#}", "{#juristic#}", "{#mail#}", "{#telephone#}", "{#fax#}", "{#address#}", "{#postcode#}", "{#website#}", "{#linker#}", "{#product_list#}", "{#cust_id#}" ,"{#WebTitle#}"};
		str = FileIO.LoadFile(templatePath);
		String tempStr = "";
		Custinfo custInfo = new Custinfo(); // ArrayList getAllCust()
		ArrayList custList = custInfo.getAllCust();
		try 
		{
			if (custList != null && custList.size() > 0) 
			{
				for (int i = 0; i < custList.size(); i++) 
				{
					tempStr = str;
					HashMap info = (HashMap) custList.get(i);
					cust_id = info.get("cust_id").toString();
					String cust_name = "";
					String cust_scope = "";
					String email = "";
					String juristic = "";
					String group_contact_phone = "";
					String fax_nbr = "";
					String company_address = "";
					String post_code = "";
					String website = "";
					if (info.get("cust_name") != null) {
						cust_name = info.get("cust_name").toString();
					}
					if (info.get("juristic") != null) {
						juristic = info.get("juristic").toString();
					}
					if (info.get("scope") != null) {
						cust_scope = info.get("scope").toString();
					}
					if (info.get("email") != null) {
						email = info.get("email").toString();
					}
					if (info.get("group_contact_phone") != null) {
						group_contact_phone = info.get("group_contact_phone").toString();
					}
					if (info.get("fax_nbr") != null) {
						fax_nbr = info.get("fax_nbr").toString();
					}
					if (info.get("company_address") != null) {
						company_address = info.get("company_address").toString();
					}
					if (info.get("post_code") != null) {
						post_code = info.get("post_code").toString();
					}
					if (info.get("website") != null) {
						website = info.get("website").toString();
					}
					filepath = temppath + "/" + cust_id + "/";
					String LinkStrTemp = FriendlyLink(cust_id);
					String ProductStrTemp = ProductList(cust_id);
					String file_path = new Custinfo().getCustAttachPath(cust_id, "0");
					if (file_path == null || file_path == "") {
						file_path = "/upload/default.gif";
					}
					// log.LOG_INFO("cust_id = " + cust_id + "file_path = " + file_path );
					tempStr = StrReplace.replace(tempStr, tab[0], FileString.f2s(rootpath + "/footer.jsp"));
					tempStr = StrReplace.replace(tempStr, tab[1], cust_name);
					tempStr = StrReplace.replace(tempStr, tab[2], cust_scope);
					tempStr = StrReplace.replace(tempStr, tab[3], file_path);
					tempStr = StrReplace.replace(tempStr, tab[4], juristic);
					tempStr = StrReplace.replace(tempStr, tab[5], email);
					tempStr = StrReplace.replace(tempStr, tab[6], group_contact_phone);
					tempStr = StrReplace.replace(tempStr, tab[7], fax_nbr);
					tempStr = StrReplace.replace(tempStr, tab[8], company_address);
					tempStr = StrReplace.replace(tempStr, tab[9], post_code);
					tempStr = StrReplace.replace(tempStr, tab[10], website);
					tempStr = StrReplace.replace(tempStr, tab[11], LinkStrTemp);
					tempStr = StrReplace.replace(tempStr, tab[12], ProductStrTemp);
					tempStr = StrReplace.replace(tempStr, tab[13], cust_id);
					tempStr = StrReplace.replace(tempStr, tab[14], webtitle);
					if (FileIO.ExistFloder(filepath)) {
						FileIO.SaveToFile(tempStr, filepath + filename);
					}
					else {
						FileIO.CreateFloder(filepath);
					}
				}
			}
		}
		catch (Exception e) {
			log.LOG_INFO(e.getMessage());
		}
		log.LOG_INFO("生成企业介绍结束");
		return error;
	}
	// ///////////////企业介绍生成结束///////////////////////
	
	
	
	/*
	 * 替换友情链接函数
	 */
	public String FriendlyLink(String cust_id) throws SaasApplicationException {

		String linkTemp = "";
		String initStr = "<li><a href={#link:url#} target=_self>{#link:name#}</a></li>";
		CustlinkInfo link = new CustlinkInfo();
		ArrayList linkList = link.genCustCustlink(cust_id);
		if (linkList != null && linkList.size() > 0) {
			for (int i = 0; i < linkList.size(); i++) {
				HashMap linkInfo = (HashMap) linkList.get(i);
				String link_name = "";
				String link_url = "";
				if (linkInfo.get("link_name") != null) {
					link_name = linkInfo.get("link_name").toString();
				}
				if (linkInfo.get("link_url") != null) {
					link_url = linkInfo.get("link_url").toString();
				}
				
				linkTemp = linkTemp + initStr;
				linkTemp = StrReplace.replace(linkTemp, "{#link:name#}", link_name);
				linkTemp = StrReplace.replace(linkTemp, "{#link:url#}", link_url);
			}
		}
		return linkTemp;
	}
	
	
	
	/*
	 * 替换产品展示方法
	 */
	public String ProductList(String cust_id) throws SaasApplicationException {

		String prodTemp = "";
		String initStr = "<td width=\"25%\"><div class=\"new-ym-right52\"><a href={#pic:link#}>{#prod:pict#}</a></div><div class=\"new-ym-right51\"><a href={#prod:link#}>{#prod:title#}</a></div></td>";
		ProductInfo product = new ProductInfo();
		ArrayList prodList = product.getproductListByLimit(cust_id, 4);
		if (prodList != null && prodList.size() > 0) {
			for (int i = 0; i < prodList.size(); i++) {
				HashMap prodInfo = (HashMap) prodList.get(i);
				String product_id = prodInfo.get("product_id").toString();
				String product_name = "";
				if (prodInfo.get("product_name") != null) {
					product_name = prodInfo.get("product_name").toString();
				}
				
				prodTemp = prodTemp + initStr;
				prodTemp = StrReplace.replace(prodTemp, "{#prod:title#}", product_name);
				prodTemp = StrReplace.replace(prodTemp, "{#prod:link#}", "/zone_b2b/enterprise/productInfo.jsp?product_id=" + product_id+"&cust_id=" + cust_id);
				String pict_path = new ProductInfo().getCustAttachPath(product_id, "0");
				if (pict_path == null) {
					pict_path = "/upload/default.gif";
				}
				prodTemp = StrReplace.replace(prodTemp, "{#pic:link#}", "/zone_b2b/enterprise/productInfo.jsp?product_id=" + product_id+"&cust_id=" + cust_id);
				prodTemp = StrReplace.replace(prodTemp, "{#prod:pict#}", "<img src=" + pict_path + " width=\"140\" height=\"110\" border=\"0\"/>");
			}
		}
		return prodTemp;
	}
	
	
	
	/*
	 * 生成企业供应
	 *
	 */
	public int createCustomerSupply(String rootpath) throws SaasApplicationException {

		log.LOG_INFO("生成企业供应");
		int err = 0;
		config configFile = new config();
	  configFile.init();
	  String webtitle = configFile.getString("mysqlbase.webtitle");
		String str = "", cust_id = "";
		String filepath = rootpath + "enterprise/customer";
		String temppath = filepath;
		String filename = "supply.htm";
		String templatePath = rootpath + "templates/enterprise/default/ym_sale.html";
		String[] tab = { "{#include:bottom#}", "{#cust:name#}", "{#cust:scope#}", "{#company_logo#}", "{#juristic#}", "{#mail#}", "{#telephone#}", "{#fax#}", "{#address#}", "{#postcode#}", "{#website#}", "{#linker#}", "{#product_list#}", "{#sale_list#}", "{#cust_id#}","{#WebTitle#}" };
		str = FileIO.LoadFile(templatePath);
		Custinfo custInfo = new Custinfo();
		String tempStr = "";
		ArrayList custList = custInfo.getAllCust();
		try {
			if (custList != null && custList.size() > 0) {
				for (int i = 0; i < custList.size(); i++) {
					tempStr = str;
					HashMap info = (HashMap) custList.get(i);
					cust_id = info.get("cust_id").toString();
					String cust_name = "";
					String cust_scope = "";
					String email = "";
					String juristic = "";
					String group_contact_phone = "";
					String fax_nbr = "";
					String company_address = "";
					String post_code = "";
					String website = "";
					if (info.get("cust_name") != null) {
						cust_name = info.get("cust_name").toString();
					}
					if (info.get("juristic") != null) {
						juristic = info.get("juristic").toString();
					}
					if (info.get("scope") != null) {
						cust_scope = info.get("scope").toString();
					}
					if (info.get("email") != null) {
						email = info.get("email").toString();
					}
					if (info.get("group_contact_phone") != null) {
						group_contact_phone = info.get("group_contact_phone").toString();
					}
					if (info.get("fax_nbr") != null) {
						fax_nbr = info.get("fax_nbr").toString();
					}
					if (info.get("company_address") != null) {
						company_address = info.get("company_address").toString();
					}
					if (info.get("post_code") != null) {
						post_code = info.get("post_code").toString();
					}
					if (info.get("website") != null) {
						website = info.get("website").toString();
					}
					filepath = temppath + "/" + cust_id + "/";
					String LinkStrTemp = FriendlyLink(cust_id);
					String ProductStrTemp = ProductList(cust_id);
					String saleStrTemp = SaleList(cust_id);
					String file_path = new Custinfo().getCustAttachPath(cust_id, "0");
					if (file_path == null || file_path == "") {
						file_path = "/upload/default.gif";
					}
					tempStr = StrReplace.replace(tempStr, tab[0], FileString.f2s(rootpath + "/footer.jsp"));
					tempStr = StrReplace.replace(tempStr, tab[1], cust_name);
					tempStr = StrReplace.replace(tempStr, tab[2], cust_scope);
					tempStr = StrReplace.replace(tempStr, tab[3], file_path);
					tempStr = StrReplace.replace(tempStr, tab[4], juristic);
					tempStr = StrReplace.replace(tempStr, tab[5], email);
					tempStr = StrReplace.replace(tempStr, tab[6], group_contact_phone);
					tempStr = StrReplace.replace(tempStr, tab[7], fax_nbr);
					tempStr = StrReplace.replace(tempStr, tab[8], company_address);
					tempStr = StrReplace.replace(tempStr, tab[9], post_code);
					tempStr = StrReplace.replace(tempStr, tab[10], website);
					tempStr = StrReplace.replace(tempStr, tab[11], LinkStrTemp);
					tempStr = StrReplace.replace(tempStr, tab[12], ProductStrTemp);
					tempStr = StrReplace.replace(tempStr, tab[13], saleStrTemp);
					tempStr = StrReplace.replace(tempStr, tab[14], cust_id);
					tempStr = StrReplace.replace(tempStr, tab[15], webtitle);
					if (FileIO.ExistFloder(filepath)) 
					{
						FileIO.SaveToFile(tempStr, filepath + filename);
					}
					else 
					{
						FileIO.CreateFloder(filepath);
						FileIO.SaveToFile(tempStr, filepath + filename);
					}
				}
			}
		}
		catch (Exception e) {
			log.LOG_INFO(e.getMessage());
		}
		log.LOG_INFO("生成企业供应结束");
		return err;
	}
	
	
	
	// ///////////////企业供应生成结束///////////////////////
	
	/*
	 * 替换产品详细信息方法
	 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -