public ArrayList searchGysZl(String f_gysbm,String f_spmc,String selectfs,String f_bm,String zybm){
DataBaseOperator oper = null;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
ResultSetMetaData rsmd = null;
StringBuffer sql = new StringBuffer();
ArrayList list = new ArrayList();
sql.append("select f_Csz from tbsysmsg where f_csmc='dqny'");
try{
oper = new DataBaseOperator();
conn = oper.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(sql.toString());
String f_rq="";
if(rs.next())f_rq= rs.getString(1);
sql.setLength(0);
sql.append("select s.f_spbm,s.f_sphh,s.f_spmc,(select top 1 f_sptm from tb").append(f_rq).append("_sptm ");
sql.append(" where f_xh>9 and f_spbm=s.f_spbm order by f_xh) f_sptm, f_jdrq,f_bzq,f_ggxh,f_sppp,f_sl,f_xxsl,f_jldw,s.f_xsdj, f_xjbz,f_jhkz,f_zpbz");
sql.append(" from tb").append(f_rq).append("_spda s ").append(" inner join tb").append(f_rq).append("_gysdz z ");
sql.append(" on z.f_spbm=s.f_spbm and f_xh=1 inner join tbzysxcs g on g.f_zybm='").append(zybm).append("' and g.f_csbm=z.f_gysbm where ");
sql.append("(g.f_csbm like '%").append(f_gysbm).append("') and s.f_spmc like '%").append(f_spmc).append("%' ");
if("0".equals(selectfs))sql.append(" and s.f_spbm like '").append(f_bm).append("%'");
if("1".equals(selectfs))sql.append("s.f_sphh like '%").append(f_bm).append("%'");
if("2".equals(selectfs))sql.append("exists(select f_spbm from tb").append(f_rq).append("_sptm where f_sptm='%").append(f_bm).append("%' and f_spbm=s.f_spbm)");
sql.append(" order by s.f_spbm");
rs = stmt.executeQuery(sql.toString());
rsmd = rs.getMetaData();
Class gysZl = Class.forName("cn.com.flor.gys.entity.GysSearchBean");
Object obj = null;
String[] names = null;
Method method = null;
int j = rsmd.getColumnCount();
names = new String[j];
for(int i = 0;i < j;i++) {
String name = rsmd.getColumnName(i+1).toLowerCase();
names[i] = "set" + name.substring(0,1).toUpperCase() + name.substring(1);
}
String value = "";
while(rs.next()){
obj = gysZl.newInstance();//产生一个新的对象
for(int i = 0; i < j; i++){
value = rs.getString(i+1);
method = gysZl.getMethod(names[i],new Class[]{value.getClass()});
method.invoke(obj,value);
}
list.add(obj);
}
}catch(Exception ex){
System.out.println(ex.getMessage());
}finally{
oper.freeConnection(conn, stmt, rs);
}
return list;
}
DataBaseOperator oper = null;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
ResultSetMetaData rsmd = null;
StringBuffer sql = new StringBuffer();
ArrayList list = new ArrayList();
sql.append("select f_Csz from tbsysmsg where f_csmc='dqny'");
try{
oper = new DataBaseOperator();
conn = oper.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(sql.toString());
String f_rq="";
if(rs.next())f_rq= rs.getString(1);
sql.setLength(0);
sql.append("select s.f_spbm,s.f_sphh,s.f_spmc,(select top 1 f_sptm from tb").append(f_rq).append("_sptm ");
sql.append(" where f_xh>9 and f_spbm=s.f_spbm order by f_xh) f_sptm, f_jdrq,f_bzq,f_ggxh,f_sppp,f_sl,f_xxsl,f_jldw,s.f_xsdj, f_xjbz,f_jhkz,f_zpbz");
sql.append(" from tb").append(f_rq).append("_spda s ").append(" inner join tb").append(f_rq).append("_gysdz z ");
sql.append(" on z.f_spbm=s.f_spbm and f_xh=1 inner join tbzysxcs g on g.f_zybm='").append(zybm).append("' and g.f_csbm=z.f_gysbm where ");
sql.append("(g.f_csbm like '%").append(f_gysbm).append("') and s.f_spmc like '%").append(f_spmc).append("%' ");
if("0".equals(selectfs))sql.append(" and s.f_spbm like '").append(f_bm).append("%'");
if("1".equals(selectfs))sql.append("s.f_sphh like '%").append(f_bm).append("%'");
if("2".equals(selectfs))sql.append("exists(select f_spbm from tb").append(f_rq).append("_sptm where f_sptm='%").append(f_bm).append("%' and f_spbm=s.f_spbm)");
sql.append(" order by s.f_spbm");
rs = stmt.executeQuery(sql.toString());
rsmd = rs.getMetaData();
Class gysZl = Class.forName("cn.com.flor.gys.entity.GysSearchBean");
Object obj = null;
String[] names = null;
Method method = null;
int j = rsmd.getColumnCount();
names = new String[j];
for(int i = 0;i < j;i++) {
String name = rsmd.getColumnName(i+1).toLowerCase();
names[i] = "set" + name.substring(0,1).toUpperCase() + name.substring(1);
}
String value = "";
while(rs.next()){
obj = gysZl.newInstance();//产生一个新的对象
for(int i = 0; i < j; i++){
value = rs.getString(i+1);
method = gysZl.getMethod(names[i],new Class[]{value.getClass()});
method.invoke(obj,value);
}
list.add(obj);
}
}catch(Exception ex){
System.out.println(ex.getMessage());
}finally{
oper.freeConnection(conn, stmt, rs);
}
return list;
}