📄 getcodingtable.java
字号:
/**
* 获取组成形式编码表的值
* @ ArrayList 类型编码表
*/
public static ArrayList getCodingZcxs(){
String sql = "select * from a_bm_zcxs order by bm";
return getCoding(sql);
}
/**
* 获取组成形式编码表的值
* @ ArrayList
*/
public static String getCodingZcxs(String bm){
String sql = "select * from a_bm_zcxs where bm='" + bm + "' order by bm";
String resultStr = null;
EnterpriseCoding eCode = null;
ArrayList al = getCoding(sql);
if(0 < al.size()){
eCode = (EnterpriseCoding) al.get(0);
resultStr = eCode.getContent();
}
return resultStr;
}
public static ArrayList getCodeBySql(String sql){
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
ArrayList map = new ArrayList();
try{
conn = Common.getConnection();
stmt = conn.createStatement();
Debug.println("[GetCodingTable-->getCoding]SQL--" + sql);
rs = stmt.executeQuery(sql);
while(rs.next()){
String key = rs.getString(1);
String value = rs.getString(2);
String remark = null;
try{
remark = rs.getString(3);
} catch(Exception ex){
}
if(key != null && value != null && key.length() > 0 && value.length() > 0){
EnterpriseCoding eCode = new EnterpriseCoding(key,value,remark);
map.add(eCode);
}
}
} catch(Exception e){
Debug.print("访问编码表失败:" + e.getMessage());
} finally{
cleanup(rs,stmt,conn);
}
return map;
}
private static ArrayList getCoding(String sql){
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
ArrayList map = new ArrayList();
try{
conn = Common.getConnection();
stmt = conn.createStatement();
Debug.println("[GetCodingTable-->getCoding]SQL--" + sql);
rs = stmt.executeQuery(sql);
while(rs.next()){
String key = rs.getString(1);
String value = rs.getString(2);
String remark = null;
try{
remark = rs.getString(3);
} catch(Exception ex){
}
if(key != null && value != null && key.length() > 0 && value.length() > 0){
EnterpriseCoding eCode = new EnterpriseCoding(key,value,remark);
map.add(eCode);
}
}
} catch(Exception e){
Debug.print("访问编码表失败:" + e.getMessage());
} finally{
cleanup(rs,stmt,conn);
}
return map;
}
/**
* 获取健康状况编码表的值
* @ ArrayList 类型编码表
*/
public static ArrayList getCodingJkzk(){
String sql = "select * from a_bm_jkzk order by bm";
return getCoding(sql);
}
/**
*
* @ ArrayList 获取健康状况编码表的值
*/
public static String getCodingJkzk(String bm){
String sql = "select * from a_bm_jkzk where bm='" + bm + "' order by bm";
String resultStr = null;
EnterpriseCoding eCode = null;
ArrayList al = getCoding(sql);
if(0 < al.size()){
eCode = (EnterpriseCoding) al.get(0);
resultStr = eCode.getContent();
}
return resultStr;
}
/**
* 获取业务类型编码表
* @ ArrayList业务类型编码表
* add by glt 2004-04-09
*/
public static ArrayList getCodingYWLX(){
String sql = "select * from a_bm_ywlx order by bm";
return getCoding(sql);
}
/**
* 获取业务类型名称
* @ string 业务类型名称
* add by glt 2004-04-09
*/
public static String getCodingYWLX(String bm){
String sql = "select * from a_bm_ywlx where bm like'" + bm + "' order by bm";
String resultStr = null;
EnterpriseCoding eCode = null;
ArrayList al = getCoding(sql);
if(0 < al.size()){
eCode = (EnterpriseCoding) al.get(0);
resultStr = eCode.getContent();
}
return resultStr;
}
/**
* 获取出资期别编码表
* @ ArrayList出资期别编码表
* add by glt 2004-04-20
*/
public static ArrayList getCodingCZQB(){
String sql = "select * from a_bm_czqb order by bm";
return getCoding(sql);
}
/**
* 获取出资期别名称
* @ string 出资期别名称
* add by glt 2004-04-20
*/
public static String getCodingCZQB(String bm){
String sql = "select * from a_bm_czqb where bm like'" + bm + "' order by bm";
String resultStr = null;
EnterpriseCoding eCode = null;
ArrayList al = getCoding(sql);
if(0 < al.size()){
eCode = (EnterpriseCoding) al.get(0);
resultStr = eCode.getContent();
}
return resultStr;
}
/**
*获取行业门类、行业代码的ArrayList
* @return ArrayList
* @author glt 2004-05-17
*/
public static ArrayList getCodingCateTrade(){
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
ArrayList resultAL = new ArrayList();
String sql = "select b.coding,a.coding,a.content "
+ "from gsgsjout_coding_trade a,(select * from gsgsjout_coding_trade where typee='1') b "
+ "where a.coding like b.coding||'%' "
+ "and a.typee<>'1' "
+ "order by b.coding,a.coding";
try{
conn = Common.getConnection();
stmt = conn.createStatement();
Debug.println("[GetCodingTable-->getCodingCateTrade]SQL--" + sql);
rs = stmt.executeQuery(sql);
String cateKeyP = "";
ArrayList tempAL2 = new ArrayList();
int i = 0;
while(rs.next()){
String cateKey = rs.getString(1);
String tradeKey = rs.getString(2);
String tradeValue = rs.getString(3);
if(!cateKey.equals(cateKeyP) && !"".equals(cateKeyP)){
ArrayList tempAL = new ArrayList();
ArrayList tempAL1 = new ArrayList();
tempAL.add(cateKeyP);
tempAL1.add(tempAL);
tempAL1.add(tempAL2);
resultAL.add(tempAL1);
tempAL2 = new ArrayList();
}
if(tradeKey != null && tradeValue != null && tradeKey.length() > 0 && tradeValue.length() > 0){
ArrayList tempAL3 = new ArrayList();
tempAL3.add(tradeKey);
tempAL3.add(tradeValue);
tempAL2.add(tempAL3);
i++;
}
cateKeyP = cateKey;
}
if(i>0){
ArrayList tempAL = new ArrayList();
ArrayList tempAL1 = new ArrayList();
tempAL.add(cateKeyP);
tempAL1.add(tempAL);
tempAL1.add(tempAL2);
resultAL.add(tempAL1);
}
} catch(Exception e){
Debug.print("访问编码表失败:" + e.getMessage());
} finally{
cleanup(rs,stmt,conn);
}
return resultAL;
}
/**
* 获取实物出资列表的应过户出资者名称的值
* @ ArrayList 类型编码表
*/
public static ArrayList getCodingSwcz(String SN,String SUB,String fl1,String fl2){
String sql = "select field007,field007 from gsgsjout_sub01 where field001='" + SN + "' and field002='" + SUB + "' and " + "field005='" + fl1 +
"' and field006='" + fl2 + "' order by field001,field002,field003,field005,field006";
ArrayList al = getCoding(sql);
return al;
}
//getCodingHtml
public static String getHtmlSelect(ArrayList code,String selectItemValue) throws Exception{
StringBuffer codingHtml = new StringBuffer();
codingHtml.append("<option value=''>请选择</option>");
int i = 0;
String coding = null,codingContent = null;
if(code == null || code.size() == 0){
return codingHtml.toString();
}
for(i = 0;i < code.size();i++){
EnterpriseCoding ec = (EnterpriseCoding) code.get(i);
coding = ec.getCode();
codingContent = ec.getContent();
if(selectItemValue.equals(coding)){
codingHtml.append("<option value='" + PubFunc.toShowForm(coding) + "' selected>" + PubFunc.toShowRTrim(codingContent) + "</option>");
} else{
codingHtml.append("<option value='" + PubFunc.toShowForm(coding) + "'>" + PubFunc.toShowRTrim(codingContent) + "</option>");
}
}
return codingHtml.toString();
}
//getCodingHtml
public static String getHtmlSelectCode(ArrayList code) throws Exception{
StringBuffer codingHtml = new StringBuffer();
codingHtml.append("<option value=''>请选择</option>");
int i = 0;
String coding = "",codingContent = "";
if(code == null || code.size() == 0){
return codingHtml.toString();
}
for(i = 0;i < code.size();i++){
EnterpriseCoding ec = (EnterpriseCoding) code.get(i);
coding = ec.getCode();
codingContent = ec.getContent();
codingHtml.append("<option value='" + coding + "'>" +
PubFunc.decodeGB(ec.getCode()) + " " +
PubFunc.decodeGB(ec.getContent()) + "</option>");
}
return codingHtml.toString();
}
//getCodingHtml
public static String getHtmlSelect(ArrayList code) throws Exception{
StringBuffer codingHtml = new StringBuffer();
codingHtml.append("<option value=''>请选择</option>");
int i = 0;
String coding = null,codingContent = null;
if(code == null || code.size() == 0){
return codingHtml.toString();
}
for(i = 0;i < code.size();i++){
EnterpriseCoding ec = (EnterpriseCoding) code.get(i);
coding = ec.getCode();
codingContent = ec.getContent();
codingHtml.append("<option value='" + PubFunc.toShowForm(coding) + "'>" + PubFunc.toShowRTrim(codingContent) + "</option>");
}
return codingHtml.toString();
}
private static ArrayList getCoding(String sql,boolean flag){
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
ArrayList map = new ArrayList();
try{
conn = Common.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next()){
String key = rs.getString(1);
String value = rs.getString(2);
String remark = null;
EnterpriseCoding eCode = null;
if(key != null && value != null && key.length() > 0 &&
value.length() > 0){
if(flag){
eCode = new EnterpriseCoding(key.trim(),
key.trim() + " " + value.trim(),remark);
}
map.add(eCode);
}
}
} catch(Exception e){
Debug.print("访问编码表失败:" + e.getMessage());
} finally{
cleanup(rs,stmt,conn);
}
return map;
}
/**
* 取得编码表中的一项记录值
* @param table 表名
* @param key 关键字
* @param value 关键字段的值
* @return HashMap 结果结合
*/
public static HashMap getRecord(String table,String key,String value){
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
HashMap map = new HashMap();
String sql = "SELECT * FROM " + table + " WHERE " + key + "='" + value + "'";
Debug.println("[GetCodingTable-->getRecord]SQL--" + sql);
try{
conn = Common.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
java.sql.ResultSetMetaData meta = rs.getMetaData();
int column = meta.getColumnCount();
if(rs.next()){
for(int i = 1;i <= column;i++){
String field = meta.getColumnName(i);
if(field != null){
map.put(field.toLowerCase(),rs.getString(i));
}
}
}
} catch(Exception e){
Debug.print("访问编码表失败:" + e.getMessage());
} finally{
cleanup(rs,stmt,conn);
}
return map;
}
//得到编码的content
public static String getDTContent(ArrayList codeAL,String code){
String str = null;
if(codeAL == null){
str = "";
}
for(int i = 0;i < codeAL.size();i++){
EnterpriseCoding eCode = (EnterpriseCoding) codeAL.get(i);
if(code.equals(eCode.getCode())){
str = eCode.getContent();
break;
}
}
return str;
}
/**
* 用户
* @ ArrayList 用户
*/
public static ArrayList getUserName(){
String sql = "select * from universal_user order by coding";
return getCoding(sql);
}
/**
* 用户
* @ ArrayList 用户
*/
public static ArrayList getYearList(){
String sql = "select * from DICT_YEAR where bm <= '" + PubFunc.getYear(Calendar.getInstance()) + "' order by bm desc";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -