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

📄 createschoolhtml.java

📁 java阿里巴巴代码
💻 JAVA
字号:
package com.buildhtml;

import java.util.ArrayList;
import java.util.HashMap;

import tools.util.FileIO;
import tools.util.StrReplace;

import com.saas.biz.attachMgr.Attachinfo;
import com.saas.biz.enquirydealMgr.EnquirydInfo;
import com.saas.biz.repositoryMgr.RepositoryInfo;
import com.saas.biz.sortMgr.ClassInfoBuild;
import com.saas.sys.exp.SaasApplicationException;
import com.saas.sys.log.Logger;

/**
 * @author:xsaas
 * @desc: 学院首页生成
 * @2008-7-9
 */
public class CreateSchoolHtml {
	
	
	FileAndString FileString = new FileAndString();
	
	
	ClassInfoBuild classBuild = new ClassInfoBuild();
	
	
	Logger log = new Logger(this);
	
	
	
	public void buildIndex(String rootpath) throws SaasApplicationException {

		String str = "";
		String filepath = rootpath + "/" + "/school/index.html";
		String templatePath = rootpath + "/" + "templates/school.html";
		String templateStr = FileIO.LoadFile(templatePath);
		log.LOG_INFO("filepath" + filepath);
		log.LOG_INFO("templatePath" + templatePath);
		
		String[] tab = { "{#include-top#}", "{#include-bottom#}", "{#repost-list-8#}", "{#sale-list-8#}", "{#glass-img-2#}", "{#tech-list-13#}", "{#wait-list-13#}", "{#aread-list13#}" };
		str = StrReplace.replace(templateStr, tab[0], FileString.f2s(rootpath + "/school/sch_top.html"));
		str = StrReplace.replace(str, tab[1], FileString.f2s(rootpath + "/footer.html"));
		// 玻璃知识
		String glassInfo = getGlassString("4", 0, 8);
		str = StrReplace.replace(str, tab[2], glassInfo);
		log.LOG_INFO("玻璃知识");
		// 销售经验
		String saleInfo = getGlassString("2", 0, 8);
		str = StrReplace.replace(str, tab[3], saleInfo);
		log.LOG_INFO("销售经验");
		// 玻璃图库
		String images = getGlassImgage(0, 6);
		str = StrReplace.replace(str, tab[4], images);
		log.LOG_INFO("玻璃图库");
		// 技术成果
		String technology = getTechnologyString("3", 0, 13);
		str = StrReplace.replace(str, tab[5], technology);
		log.LOG_INFO("技术成果");
		// 待决问题
		String wintString=getEnquiryByWaitList(0,13);
		str = StrReplace.replace(str, tab[6], wintString);
		log.LOG_INFO("待决问题");
        //已决问题
		String alreadString=getEnquiryOffed(0,13);
		str = StrReplace.replace(str, tab[7], alreadString);
		log.LOG_INFO("已决问题");
		FileIO.SaveToFile(str, filepath);
	}
	
	
	
	/**
	 * 取出玻璃知识
	 */
	public String getGlassString(String type, int iStart, int limit) throws SaasApplicationException {

		String source = "";
		String resource = "<tr>" + "<td width=209 class=rencei_table_xian>" + "  ·<a href=sch_knowlist_con.jsp?repository_id={#rep-id#} target=_blank class=lanse>{#rep-title#}</a>" + "</td>" + "</tr>";
		RepositoryInfo reposInfo = new RepositoryInfo();
		ArrayList list = reposInfo.getRepositoryByType(type, iStart, limit);
		if (list != null && list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				HashMap map = (HashMap) list.get(i);
				String repository_id = "", title = "";
				if (map.get("repository_id") != null) {
					repository_id = map.get("repository_id").toString();
				}
				if (map.get("title") != null) {
					title = map.get("title").toString();
				}
				source = source + StrReplace.replace(resource, "{#rep-id#}", repository_id);
				source = StrReplace.replace(source, "{#rep-title#}", title);
			}
		}else{
			source = source + StrReplace.replace(resource, "{#rep-id#}","");
			source = StrReplace.replace(source, "{#rep-title#}", "");
		}
		return source;
	}
	
	/**
	 * 取出技术成果
	 */
	public String getTechnologyString(String type, int iStart, int limit) throws SaasApplicationException {

		String source = "";
		String resource = "<tr>" + "<td width=82%>" + "  ·<a href=sch_knowlist_con.jsp?repository_id={#rep-id#} target=_blank class=lanse>{#rep-title#}</a>" + "</td>" + "<td width=18%>" + "{#pub-date#}" + "</td>" + "</tr>";
		RepositoryInfo reposInfo = new RepositoryInfo();
		ArrayList list = reposInfo.getRepositoryByType(type, iStart, limit);
		if (list != null && list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				HashMap map = (HashMap) list.get(i);
				String repository_id = "", title = "", publish_date = "";
				if (map.get("repository_id") != null) {
					repository_id = map.get("repository_id").toString();
				}
				if (map.get("title") != null) {
					title = map.get("title").toString();
				}
				if (map.get("publish_date") != null) {
					publish_date = map.get("publish_date").toString();
					if (publish_date.length() > 10) {
						publish_date = publish_date.substring(0, 10);
					}
				}
				source = source + StrReplace.replace(resource, "{#rep-id#}", repository_id);
				source = StrReplace.replace(source, "{#rep-title#}", title);
				source = StrReplace.replace(source, "{#pub-date#}", publish_date);
			}
		}else{
			source = source + StrReplace.replace(resource, "{#rep-id#}", "");
			source = StrReplace.replace(source, "{#rep-title#}", "");
			source = StrReplace.replace(source, "{#pub-date#}", "");
		}
		return source;
	}
	
	/**
	 * 玻璃图库
	 */
	public String getGlassImgage(int iStart, int limit) throws SaasApplicationException {

		String source = "";
		String root_id = "000000000000000";
		// 默认图片
		String defaultImg = "/zone_b2b/images/cp.gif";
		String resource = "<tr>" + "	<td width=130 align=center>" + "		<a href=/zone_b2b/school/sch_knowlist_con.jsp?repository_id={#rep-id1#}><img  src={#image1#} width=110 height=90 alt={#title1#}></a>" + "		<br>{#title1#}" + "	</td>" + "	<td width=130 align=center>" + "		<a href=/zone_b2b/school/sch_knowlist_con.jsp?repository_id={#rep-id2#}><img  src={#image2#} width=110 height=90 alt={#title2#}></a>" + "		<br>{#title2#}" + "	</td>" + "	<td width=132 align=center>" + "		<a href=/zone_b2b/school/sch_knowlist_con.jsp?repository_id={#rep-id3#}><img  src={#image3#} width=110 height=90 alt={#title3#}></a>" + "		<br>{#title3#}" + "	</td>" + "</tr>" + "<tr>" + "	<td width=130 align=center>" + "		<a href=/zone_b2b/school/sch_knowlist_con.jsp?repository_id={#rep-id4#}><img  src={#image4#} width=110 height=90 alt={#title4#}></a>" + "		<br>{#title4#}" + "	</td>" + "	<td width=130 align=center>" + "		<a href=/zone_b2b/school/sch_knowlist_con.jsp?repository_id={#rep-id5#}><img  src={#image5#} width=110 height=90 alt={#title5#}></a>" + "		<br>{#title5#}" + "	</td>" + "	<td width=132 align=center>" + "		<a href=/zone_b2b/school/sch_knowlist_con.jsp?repository_id={#rep-id6#}><img  src={#image6#} width=110 height=90 alt={#title6#}></a>" + "		<br>{#title6#}" + "	</td>" + "</tr>";
		Attachinfo attach = new Attachinfo();
		ArrayList list = attach.getAttachInfoByImage(root_id, 0, 6);
		int index = 1;
		if (list != null && list.size() > 0) {
			for (int i = 0; i < 6; i++) {
				HashMap map = new HashMap();
				if (list.size() > i) {
					map = (HashMap) list.get(i);
				}
				String repository_id="";
				if (map.get("repository_id") != null) {
					repository_id = map.get("repository_id").toString();
				}
				String file_path = "", attach_name = "";
				if (map.get("file_path") != null) {
					file_path = map.get("file_path").toString();
					file_path = file_path.substring(23);
				}
				else {
					file_path = defaultImg;
				}
				if (map.get("attach_name") != null) {
					attach_name = map.get("attach_name").toString();
					attach_name=attach_name.substring(0,attach_name.length()-4);
				}
				if (index == 1) {
					source = StrReplace.replace(resource, "{#image".trim() + index + "#}".trim(), file_path);
				}
				else {
					source = StrReplace.replace(source, "{#image".trim() + index + "#}".trim(), file_path);
				}
				source = StrReplace.replace(source, "{#title" + index + "#}", attach_name);
				source = StrReplace.replace(source, "{#rep-id"+index+"#}", repository_id);
				index++;
			}
		}
		else {
			for (int i = 0; i < 6; i++) {
				String file_path = "", attach_name = "未命名";
				file_path = defaultImg;
				if (index == 1) {
					source = StrReplace.replace(resource, "{#image".trim() + index + "#}".trim(), file_path);
				}
				else {
					source = StrReplace.replace(source, "{#image".trim() + index + "#}".trim(), file_path);
				}
				source = StrReplace.replace(source, "{#title".trim() + index + "#}".trim(), attach_name);
				index++;
			}
		}
		return source;
	}
	
	
	
	// 取出待解决信息
	public String getEnquiryByWaitList(int iStart, int limit) throws SaasApplicationException {

		EnquirydInfo enquiry = new EnquirydInfo();
		String source = "";
		String resource = "<tr>"+
	    "<td width=80%>"+
		"<a href=/zone_b2b/school/sch_list_content.jsp?trade_id={#trade-id#} class=lanse>{#title#}</a>"+
	    "</td>"+
	    "<td width=20%>"+
		 "{#pub-date#}"+
	    "</td>"+
        "</tr>";
		ArrayList list = enquiry.getEnquiryByList(iStart, limit);
		if(list !=null && list.size()>0){
			for(int i=0;i<list.size();i++){
				HashMap map=(HashMap)list.get(i);
				String trade_id="",title="",enquiry_date="";
				if(map.get("trade_id")!=null){
					trade_id=map.get("trade_id").toString();
				}
				if(map.get("rsrv_str3")!=null){
					title=map.get("rsrv_str3").toString();
				}
				if(map.get("enquiry_date")!=null){
					enquiry_date=map.get("enquiry_date").toString();
					if(enquiry_date.length()>10){
						enquiry_date=enquiry_date.substring(0,10);
					}
				}
				source = source + StrReplace.replace(resource, "{#trade-id#}", trade_id);
				source = StrReplace.replace(source, "{#title#}", title);
				source = StrReplace.replace(source, "{#pub-date#}", enquiry_date);
			}
		}else{
			source = source + StrReplace.replace(resource, "{#trade-id#}", "");
			source = StrReplace.replace(source, "{#title#}", "");
			source = StrReplace.replace(source, "{#pub-date#}", "");
		}
		return source;
	}
	
	// 取出已解决信息
	public String getEnquiryOffed(int iStart, int limit) throws SaasApplicationException {

		EnquirydInfo enquiry = new EnquirydInfo();
		String source = "";
		String resource = "<tr>"+
	    "<td width=80%>"+
		"<a href=/zone_b2b/school/sch_list_content.jsp?trade_id={#trade-id#} class=lanse>{#title#}</a>"+
	    "</td>"+
	    "<td width=20%>"+
		 "{#pub-date#}"+
	    "</td>"+
        "</tr>";
		ArrayList list = enquiry.getOffEnquiryByList(iStart, limit);
		if(list !=null && list.size()>0){
			for(int i=0;i<list.size();i++){
				HashMap map=(HashMap)list.get(i);
				String trade_id="",title="",enquiry_date="";
				if(map.get("trade_id")!=null){
					trade_id=map.get("trade_id").toString();
				}
				if(map.get("rsrv_str3")!=null){
					title=map.get("rsrv_str3").toString();
				}
				if(map.get("enquiry_date")!=null){
					enquiry_date=map.get("enquiry_date").toString();
					if(enquiry_date.length()>10){
						enquiry_date=enquiry_date.substring(0,10);
					}
				}
				source = source + StrReplace.replace(resource, "{#trade-id#}", trade_id);
				source = StrReplace.replace(source, "{#title#}", title);
				source = StrReplace.replace(source, "{#pub-date#}", enquiry_date);
			}
		}else{
			source = source + StrReplace.replace(resource, "{#trade-id#}", "");
			source = StrReplace.replace(source, "{#title#}", "");
			source = StrReplace.replace(source, "{#pub-date#}", "");
		}
		return source;
	}
}

⌨️ 快捷键说明

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