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

📄 commmethodmgr.java

📁 java阿里巴巴代码
💻 JAVA
字号:
/*
 * Created on 2006-6-28
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package com.ahbay.commenMgr;

import com.ahbay.mysite.*;
import java.text.*;
import java.util.*;
import java.sql.*;
import java.io.*;
import org.apache.struts.upload.FormFile;
/**
 * @author: Wangrc
 * @Date: 2006-6-28 15:02:58
 * @Method Name: 
 */
public class commMethodMgr
{
	public commMethodMgr(){}
	DataBaseCommMgr DBQuery = new DataBaseCommMgr();
	
	/**
	 * 
	 * @author: Wangrc
	 * @Date: 2006-6-28 15:03:58
	 * @Method Name: GenTradeId
	 */
	
	public String GenTradeId()
	{
		String tradeId = "";
		RandomStrg.setCharset("a-zA-Z0-9");		 
		RandomStrg.setLength("15");	  
		try
		{
			RandomStrg.generateRandomObject();
			tradeId=RandomStrg.getRandom();			 
		}
		catch (Exception e)
		{		 	
		}
		return tradeId;		
	}
	
	/**
	 * 
	 * @author: Wangrc
	 * @Date: 2006-6-28 15:06:46
	 * @Method Name: GenSysdate
	 */
	public String GenSysdate(String X_Tag)
	{
		Calendar cal = Calendar.getInstance();
		SimpleDateFormat tradeTime = null;
		String result = "";
		if (X_Tag.equalsIgnoreCase("1"))
		{
			tradeTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		}
		else if (X_Tag.equalsIgnoreCase("2"))
		{
			tradeTime = new SimpleDateFormat("yyyy-MM-dd");
		}	
		else
		{	
			tradeTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		}
		result=tradeTime.format(cal.getTime());
		return result;		
	}
	/**
	 * 
	 * @author: 王仁超
	 * @Date: 2005-7-2
	 * @FileName: newsMgr.java
	 * @PackageName: com.ahbay.newsMgr
	 * @Method Name: splitStr
	 */

	public String splitStr(String str,int len)  
	{ 
		
		int strlen = str.length(); 
		if(len>=strlen) {
			return str;
		} 
		int i = 0; 
		int fixlen = 0; 
		while(i<len){ 
			char chr = str.charAt(i); 
			i++; 
			if(chr<0x80) fixlen++; 
			else if(i<len){ 
				i++; 
				fixlen += 2; 
			}
		} 
		return str.substring(0,fixlen); 
	}
	/**
	 * 
	 * @author: 王仁超
	 * @Date: 2005-7-2
	 * @FileName: newsMgr.java
	 * @PackageName: com.ahbay.newsMgr
	 * @Method Name: convetStrToWeb
	 */

	public String convetStrToWeb(String str)  
	{ 
		String outstr = "";
		if (str == null)
		{
			 outstr ="";
		}
		else
		{
			try
			{	
				outstr =new String(str.getBytes("GB2312"),"ISO8859_1"); 
			} 
			catch (Exception e)
			{	
				System.out.println("SQLERROR:"+e.getMessage());				
			}		
		}
		return outstr; 
	}
	
	/**
	 * 
	 * @author: 王仁超
	 * @Date: 2005-7-2
	 * @FileName: newsMgr.java
	 * @PackageName: com.ahbay.newsMgr
	 * @Method Name: convetStrToDb
	 */

	public String convetStrToDb(String instr)  
	{ 
		String outstr = "";
		if (instr == null)
		{
				outstr ="";
		}
		else
		{		
			try
			{	
				outstr =new String(instr.getBytes("ISO8859_1"),"GB2312"); 
			} 
			catch (Exception e)
			{	
				System.out.println("SQLERROR:"+e.getMessage());				
			}
		}		
		 
		return outstr; 
	}
	/**
	 * 
	 * @author: Wangrc
	 * @Date: 2006-7-25 11:03:40
	 * @Method Name: ConvertCodeToName()
	 */	
	public String ConvertCodeToName(String strCodeType,String strCode)  
	{
		String strResultName = "";
		String sql = "";
		
		/******************代码实现**************************/
		if (strCodeType.equalsIgnoreCase("sex"))
		{
			if (strCode.equalsIgnoreCase("0")) strResultName = "男性";
			if (strCode.equalsIgnoreCase("1")) strResultName = "女性";
		}
		if (strCodeType.equalsIgnoreCase("bookstate"))
		{
			if (strCode.equalsIgnoreCase("0")) strResultName = "正常库存";
			if (strCode.equalsIgnoreCase("1")) strResultName = "已经借出";
		}
		else if (strCodeType.equalsIgnoreCase("custname"))
		{
			sql = "select cust_name from custperson where cust_id='"+strCode+"' union all " +
				  "select cust_name from custgroup where cust_id='"+strCode+"'";
			strResultName = GetNameForCode(sql);
			 
		}
		else if (strCodeType.equalsIgnoreCase("staffname"))
		{
			sql = "select staff_name from staffinfo where staff_id='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("casetype"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='casetype'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("querytype"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='querytype'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("custrole"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='custrole'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("agentstage"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='agentstage'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("agenttype"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='agenttype'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("filestype"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='filestype'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("booktype"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='booktype'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("booksize"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='booksize'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("itemstate"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='itemstate'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("secretlevel"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='secretlevel'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("itemkind"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='itemkind'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("itemmedia"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='itemmedia'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("goodsstate"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='goodsstate'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("docustate"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='docustate'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("infotype"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='infotype'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("mailtype"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='mailtype'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("warntype"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='warntype'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("opentype"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='opentype'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("proofunit"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='proofunit'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("proofmedia"))
		{
			sql = "select para_code1 from commpara where subsys_code='WEB' and param_attr='proofmedia'" +
				"and param_code='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("itemowndepart"))
		{
			sql = "select depart_name from departinfo where depart_id='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("casersrvstr2"))
		{
			sql = "select rsrv_str2 from caseinfo where case_id='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("modulename"))
		{
			sql = "select module_name from moduleinfo where module_id='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("menuname"))
		{
			sql = "select menu_name from menuinfo where menu_id='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		else if (strCodeType.equalsIgnoreCase("webname"))
		{
			sql = "select lmmc from lmxxb where lmbs='"+strCode+"'";
			strResultName = GetNameForCode(sql);			
		}
		/******************编码转换**************************/
		/**try
		{	
			strResultName =new String(strResultName.getBytes("GB2312"),"ISO8859_1"); 
		} 
		catch (Exception e)
		{	
			System.out.println("SQLERROR:"+e.getMessage());				
		}
		 **/
		return strResultName;
	}
	/**
	  *从td_b_productclass表中获取数据
	  *2007.9.30刘阳
	  */
	public String getClassNameByClassId(String class_id)
	{
		String class_name="";
		String sql = "select class_name from td_b_productclass where class_id='"+class_id+"'";
		try
		{
		    class_name = GetNameForCode(sql);	
		}catch(Exception e)
		{
			return "";
		}
		return class_name;
	}
	/**
	  *从menuinfo表中获取数据
	  *2007.11.3刘阳
	  */
	public String getMenuNameById(String menu_id)
	{
		String class_name="";
		String sql = "select menu_name from menuinfo where menu_id='"+menu_id+"'";
		try
		{
		    class_name = GetNameForCode(sql);	
		}catch(Exception e)
		{
			return "";
		}
		return class_name;
	}
	/**
	 * 
	 * @author: Wangrc
	 * @Date: 2006-7-25 11:17:12
	 * @Method Name: GetNameForCode
	 */
	public String GetNameForCode(String strGetSql)  
	{
		ResultSet rst = null;
		String strResult = "";
		DBQuery.setStrQuery(strGetSql);
		rst = DBQuery.SelBizQuery();
		try
		{
			while (rst.next())
			{
				strResult = rst.getString(1);
				if(rst.wasNull()) strResult = "null";
			}
			
		}
		catch (Exception e)
		{	 	
		}
		
		
		return strResult;
	}
	public String Savefiles(FormFile file,String path)
	{		
		String fileName= file.getFileName();
		String contentType = file.getContentType();
		String size = (file.getFileSize() + " bytes");
		try 
		{
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			InputStream stream = file.getInputStream();
			OutputStream bos = new FileOutputStream(path+fileName);
			int bytesRead = 0;
			byte[] buffer = new byte[8192];
			while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
				bos.write(buffer, 0, bytesRead);
			}
			bos.close();		 			
			stream.close();		 
		}
		catch (IOException e) {
			return e.getMessage();
		}
		return "1";
	}
}

⌨️ 快捷键说明

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