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

📄 createstockinfohtml.java

📁 java阿里巴巴代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		
		
		// 生成采购信息
		StockInfo stock = new StockInfo();
		ArrayList list = stock.getStockInfoList(iStart, 5, "3");
		String stocks = getStockHtmlByList(list);
		str = StrReplace.replace(str, "{#stock-gener-5#}", stocks);
		// 生成最新采购信息
		ArrayList newList = stock.getNewStockInfoByList(iStart, 5);
		String newStock = getStockHtmlByList(list);
		str = StrReplace.replace(str, "{#stock-new-5#}", newStock);
		// 生成专区信息
		String select = getClassInfoByType();
		str = StrReplace.replace(str, "{#calalog-stock#}", select);
		FileIO.SaveToFile(str, filepath);
		return 0;
	}
	
	
	
	// 专区信息
	public String getClassInfoByType() throws SaasApplicationException {

		Productclass product = new Productclass();
		String select = product.getSelectedByComm("4", "1");
		return select;
	}
	
	
	
	// 替换省份信息
	public String getProvinceInfo() throws SaasApplicationException {

		String province = "";
		AreaInfo area = new AreaInfo();
		province = area.getCountrySelect("5J2mc0X0G85BH");
		return province;
	}
	
	
	
	// 生成采购信息
	public String getStockHtmlByList(ArrayList list) throws SaasApplicationException {

		String defaultImg = "/zone_b2b/images/cp.gif";
		String source = "";
		String resource = "<tr>                                                                                                                                        " +
		// " <td height=30 width=28> "+
				// " &nbsp; "+
				// " </td> "+
				"		<td height=130 width=100>                                                                                                                " + "			<img src={#stock-img#} width=100 height=100 alt={#alt-title-1#} />                                                                              " + "		</td>                                                                                                                                    " + "		<td align=left width=280>                                                                                                                 " + "			<a href=/zone_b2b/stock/stockInquiry.jsp?stock_id={#stock-idx#} target=_blank class=cpbt>{#stock-title#}</a>                                           " + "			  <br>{#stock-cust#}   {#pub-date#}                                                                                                    " + "			<br>                                                                                                                                   " + "			{#stock-desc#}                                                                                                                         " + "		</td>                                                                                                                                    " + "		<td align=center width=94>                                                                                                               " + "			{#stock-addr#}                                                                                                                         " + "		</td>                                                                                                                                    " + "		<td width=116>                                                                                                                           " + "			<a href=stockInquiry.jsp?stock_id={#stock-id#}><img src=/zone_b2b/images/zx.gif border=0 width=75 height=21 alt={#alt-title#}></a>     " + "		</td>" + "</tr>";
		if (list != null && list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				HashMap map = (HashMap) list.get(i);
				String stock_id = map.get("stock_id").toString();
				String title = "", pub_date = "", content = "", addr = "", cust_name = "";
				if (map.get("title") != null) {
					title = map.get("title").toString();
				}
				if (map.get("cust_name") != null) {
					cust_name = map.get("cust_name").toString();
				}
				if (map.get("stock_addr") != null) {
					addr = map.get("stock_addr").toString();
				}
				if (map.get("content") != null) {
					content = map.get("content").toString();
					content = content.replaceAll("<[^<>]+>", "");
					if (content.length() > 40) {
						content = content.substring(0, 40) + "...";
					}
				}
				if (map.get("publish_date") != null) {
					pub_date = map.get("publish_date").toString();
					if (pub_date.length() > 10) {
						pub_date = pub_date.substring(0, 10);
					}
				}
				String file_path = "";
				if (map.get("file_path") != null) {
					file_path = map.get("file_path").toString();
					file_path = file_path.substring(23);
				}
				else {
					file_path = defaultImg;
				}
				source = source + StrReplace.replace(resource, "{#stock-img#}", file_path);
				source = StrReplace.replace(source, "{#alt-title-1#}", title);
				source = StrReplace.replace(source, "{#stock-idx#}", stock_id);
				source = StrReplace.replace(source, "{#stock-title#}", title);
				
				source = StrReplace.replace(source, "{#stock-cust#}", cust_name);
				source = StrReplace.replace(source, "{#pub-date#}", pub_date);
				
				source = StrReplace.replace(source, "{#stock-desc#}", content);
				source = StrReplace.replace(source, "{#stock-addr#}", addr);
				source = StrReplace.replace(source, "{#stock-id#}", stock_id);
				source = StrReplace.replace(source, "{#alt-title#}", title);
			}
		}
		return source;
	}
	
	
	public String getHtmlTemplateStr(String up_id, String type, String linkUrl) throws SaasApplicationException {

		String html = "";
		ArrayList sourceList = getClassInfoByUpType(up_id, type);
		if (sourceList != null && sourceList.size() > 0) {
			for (int i = 0; i < 1; i++) {
				String temp = "", tt = "";
				HashMap map1 = (HashMap) sourceList.get(i);
				String idx1 = map1.get("class_id").toString();
				String name1 = map1.get("class_name").toString();
				
				HashMap map2 = (HashMap) sourceList.get(i + 1);
				String idx2 = map2.get("class_id").toString();
				String name2 = map2.get("class_name").toString();
				
				tt = replaceProduct(idx1, name1, idx2, name2, linkUrl, type);
				
				html = html + tt;
			}
		}
		
		return html;
	}
	
	
	public String replaceProduct(String idx1, String name1, String idx2, String name2, String linkUrl, String type) throws SaasApplicationException {

		String title = "<table width=\"96%\" border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"0\">  " + "<tr> " + "  <td height=\"30\"><img src=\"/zone_b2b/images/d_tb.gif\" width=\"5\" height=\"9\"> " + " 	 <a href=\"" + linkUrl + type + "&class_id=" + idx1 + "\"><strong>" + name1 + "</strong></a> " + "  </td> " + "</tr>  " + "<tr> " + "  <td class=\"xian\" height=\"1\"></td>  " + "</tr>" + "<tr> " + "  <td>  " + createHtmlTemplate(idx1, name1, linkUrl, type) + "  </td>  " + "</tr> " + "</table> " + "<table width=\"96%\" border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"0\">" + "<tr>" + "  <td height=\"30\"><img src=\"/zone_b2b/images/d_tb.gif\" width=\"5\" height=\"9\">" + "  	 <a href=\"" + linkUrl + type + "&class_id=" + idx2 + "\"><strong>" + name2 + "</strong></a> " + "  </td>" + "</tr> " + "<tr> " + "  <td class=\"xian\" height=\"1\"></td> " + "</tr>" + "<tr>  " + "  <td> " + createHtmlTemplate(idx2, name2, linkUrl, type) + "  </td>   " + "</tr> " + "</table>";
		
		return title;
	}
	
	
	public String createHtmlTemplate(String id, String name, String linkUrl, String type) throws SaasApplicationException {

		String classHtml = "";
		ArrayList secondList = getClassInfoByUpType(id, type);
		classHtml = classHtml + replaceTwo(secondList, linkUrl, type);
		
		return classHtml;
	}
	
	
	public String replaceTwo(ArrayList secondList, String linkUrl, String type) throws SaasApplicationException {

		String title = "";
		for (int i = 0; i < 12; i++) {
			HashMap map = (HashMap) secondList.get(i);
			String id = map.get("class_id").toString();
			String name = "", allName = "";
			if (map.get("class_name") != null) {
				allName = map.get("class_name").toString();
				if (allName.length() > 3) {
					name = StringUtil.getLimitLengthString(allName, "", 8);
				}
				else {
					name = allName;
					for (int j = 0; j < 6 - allName.length(); j++) {
						name = name + "&nbsp";
					}
				}
			}
			title = title + "<a href=\"" + linkUrl + type + "&class_id=" + id + "\" title=\"" + allName + "\"class=\"cp_list\">" + name + " |</a> ";
		}
		return title;
	}
	
	
	public ArrayList getClassInfoByUpType(String up_id, String type) throws SaasApplicationException {

		ArrayList list = new ArrayList();
		ProductclassExt pe = new ProductclassExt();
		pe.setParam(":VCLASS_TYPE", type);
		pe.setParam(":VUP_CLASS_ID", up_id);
		list = pe.selByList("SEL_BY_PARENTID");
		return list;
	}
}

⌨️ 快捷键说明

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