?? createcustomerweb.java
字號:
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.commen.config;
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;
/**
* @author:B2B
* @desc:生成個人企業站
* @2008-7-17
*/
public class CreateCustomerWeb {
Logger log;
FileAndString FileString;
/**
* 默認構造方法
*/
public CreateCustomerWeb() {
log = new Logger(this);
FileString = new FileAndString();
}
/**
* @return 生成個人企業站
* @throws SaasApplicationException
*/
public int createCustomerWeb(String rootpath, String cust_id) throws SaasApplicationException {
this.createCustomerIntroduce(rootpath, cust_id);
this.createCustomerSupply(rootpath, cust_id);
this.createCustomerCredit(rootpath, cust_id);
this.createCustomerStock(rootpath, cust_id);
this.createCustomerNews(rootpath, cust_id);
this.createCustomerBidding(rootpath, cust_id);
this.createCustomerTech(rootpath, cust_id);
this.createCustomerProduct(rootpath, cust_id);
this.createCustomerResume(rootpath, cust_id);
this.createCustomerLeave(rootpath, cust_id);
return 0;
}
// 生成企業介紹
public int createCustomerIntroduce(String rootpath, String cust_id) throws SaasApplicationException {
log.LOG_INFO("生成企業介紹");
config configFile = new config();
configFile.init();
String webtitle = configFile.getString("mysqlbase.webtitle");
int error = 0;
String str = "";
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 custList = custInfo.genSpecCustInfo(cust_id);
try {
if (custList != null && custList.size() > 0) {
for (int i = 0; i < custList.size(); i++) {
tempStr = str;
HashMap info = (HashMap) custList.get(i);
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) {
}
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, String cust_id) throws SaasApplicationException {
log.LOG_INFO("生成企業供應");
int err = 0;
config configFile = new config();
configFile.init();
String webtitle = configFile.getString("mysqlbase.webtitle");
String str = "";
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.genSpecCustInfo(cust_id);
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);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -