|
@@ -7,6 +7,7 @@ import com.lantone.qc.pub.util.PropertiesUtil;
|
|
|
|
|
|
import java.sql.*;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.Properties;
|
|
|
|
|
@@ -21,11 +22,11 @@ public class DataTest {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public static JSONArray loadHomePage(String patientId) {
|
|
|
+ public static Map<String, String> loadHomePage(String patientId) {
|
|
|
Connection conn = null;
|
|
|
Statement stmt = null;
|
|
|
ResultSet rs = null;
|
|
|
- JSONArray js = null;
|
|
|
+ Map<String, String> js = null;
|
|
|
try {
|
|
|
PropertiesUtil propertiesUtil = new PropertiesUtil("kernel.properties");
|
|
|
Class.forName(propertiesUtil.getProperty("oracle.test.driver"));
|
|
@@ -47,7 +48,7 @@ public class DataTest {
|
|
|
DatabaseMetaData dmd = conn.getMetaData();
|
|
|
ResultSet dmdRs = dmd.getColumns(null, null, "BR_RECHOME", null);
|
|
|
|
|
|
- Map<String, String> colMap = new HashMap<>();
|
|
|
+ Map<String, String> colMap = new LinkedHashMap<>();
|
|
|
while(dmdRs.next()){
|
|
|
colMap.put(dmdRs.getString(4), dmdRs.getString("REMARKS"));
|
|
|
}
|
|
@@ -80,25 +81,21 @@ public class DataTest {
|
|
|
return js;
|
|
|
}
|
|
|
|
|
|
- public static JSONArray resultSetToJson(ResultSet rs, Map<String, String> map) throws SQLException, JSONException {
|
|
|
- // json数组
|
|
|
- JSONArray array = new JSONArray();
|
|
|
+ public static Map<String, String> resultSetToJson(ResultSet rs, Map<String, String> map) throws SQLException, JSONException {
|
|
|
// 获取列数
|
|
|
ResultSetMetaData metaData = (ResultSetMetaData) rs.getMetaData();
|
|
|
int columnCount = metaData.getColumnCount();
|
|
|
// 遍历ResultSet中的每条数据
|
|
|
+ Map<String, String> result = new LinkedHashMap<>();
|
|
|
while (rs.next()) {
|
|
|
- JSONObject jsonObj = new JSONObject();
|
|
|
// 遍历每一列
|
|
|
for (int i = 1; i <= columnCount; i++) {
|
|
|
String columnName = metaData.getColumnLabel(i);
|
|
|
String value = rs.getString(columnName) == null ? "" : rs.getString(columnName);
|
|
|
- jsonObj.put(map.get(columnName), value);
|
|
|
+ result.put(map.get(columnName), value);
|
|
|
}
|
|
|
- array.add(jsonObj);
|
|
|
}
|
|
|
-
|
|
|
- return array;
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
}
|