|
楼主 |
发表于 2017-5-25 09:13:05
|
显示全部楼层
本帖最后由 dykiss 于 2017-5-25 09:14 编辑
//////提取本班日期
public static JSONObject sp_tdlist(JSONObject params,ActionContext context)throws SQLException, NamingException, java.sql.SQLException{
String zmlm = params.getString("zmlm");
String gwm = params.getString("gwm");
String wfcode = params.getString("wfcode");
JSONObject ret = new JSONObject();
Connection conn = context.getConnection(db);
try {
CallableStatement proc =null;
proc = conn.prepareCall("{call ccgl_pda.sp_tdlist(?,?,?,?)}");
proc.setString(1, zmlm);//站名代码
proc.setString(2, gwm);//岗位名
proc.setString(3, wfcode);//sl/fl
proc.registerOutParameter(4, OracleTypes.CURSOR);//返回结果集
proc.execute();
ResultSet rs = (ResultSet) proc.getObject(4);
StringBuilder output = new StringBuilder();
Table table = ResultSetToTable(rs,0,5);
return Transform.tableToJson(table);
} catch(Exception e){
return null;
}
finally {
conn.close();
}
}
public static Table ResultSetToTable(ResultSet rs,Integer offset,Integer limit) throws java.sql.SQLException {
Object columns = null;
Table table = null;
try {
try {
if (limit != null && offset != null) {
for (int i = 0; i < offset; i++) {
rs.next();
}
}
if (columns instanceof JSONObject) {
table = Transform.createTableByColumnsDefine((JSONObject) columns);
} else {
table = Transform.createTableByResultSet(rs, (String) columns);
}
Transform.loadRowsFromResultSet(table, rs, limit);
return table;
} finally {
}
} catch (SQLException e) {
String msg = "SQL执行失败,SQL:"+e.getMessage();
throw new com.justep.baas.data.sql.SQLException(msg,e);
}
}
现在可以转换了,问题是怎么分页??就返回了我传入的limit值5,总记录肯定是大于5的了 |
|