|
@ -58,10 +58,38 @@ public class InspectionService extends BaseService {
|
|
|
public String getInspectionAndChecking(String strSSID, String startNum, String endNum) throws Exception {
|
|
|
JSONArray total = new JSONArray();
|
|
|
JSONArray check = getChecking(strSSID, startNum, endNum);
|
|
|
if (!check.isNull(0)) {
|
|
|
JSONObject jsonObject = check.getJSONObject(0);
|
|
|
if (!StringUtils.isEmpty(jsonObject.get("error"))) {
|
|
|
return jsonObject.get("error").toString();
|
|
|
}
|
|
|
}
|
|
|
JSONArray inspect = getInspection(strSSID, startNum, endNum);
|
|
|
if (!inspect.isNull(0)) {
|
|
|
JSONObject jsonObject = inspect.getJSONObject(0);
|
|
|
if (!StringUtils.isEmpty(jsonObject.get("error"))) {
|
|
|
return jsonObject.get("error").toString();
|
|
|
}
|
|
|
}
|
|
|
//TODO 检查检验数据合并
|
|
|
total.put(check);
|
|
|
total.put(inspect);
|
|
|
for (int i = 0; i < check.length(); i++) {
|
|
|
total.put(check.getJSONObject(i));
|
|
|
}
|
|
|
for (int i = 0; i < inspect.length(); i++) {
|
|
|
total.put(inspect.getJSONObject(i));
|
|
|
}
|
|
|
JSONObject temp;
|
|
|
for (int i = 0; i < total.length(); i++) {
|
|
|
for (int j = i+1; j < total.length(); j++) {
|
|
|
String endTimeNew = total.getJSONObject(j).get("END_TIME").toString();
|
|
|
String endTimeOld = total.getJSONObject(i).get("END_TIME").toString();
|
|
|
if (endTimeNew.compareTo(endTimeOld) > 0) {
|
|
|
temp = total.getJSONObject(i);
|
|
|
total.put(i, total.getJSONObject(j));
|
|
|
total.put(j, temp); // 两个数交换位置
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return total.toString();
|
|
|
}
|
|
|
|
|
@ -87,12 +115,18 @@ public class InspectionService extends BaseService {
|
|
|
systemDictMap.put(systemDict.getCode(), systemDict.getValue());
|
|
|
}
|
|
|
|
|
|
if (!org.apache.commons.lang3.StringUtils.isEmpty(response)){
|
|
|
if (!StringUtils.isEmpty(response)){
|
|
|
JSONObject responseObject = new JSONObject(response);
|
|
|
int status = responseObject.getInt("status");
|
|
|
if (status == 200){
|
|
|
String data = responseObject.getString("data");
|
|
|
if (!org.apache.commons.lang3.StringUtils.isEmpty(data)){
|
|
|
if (!StringUtils.isEmpty(data)){
|
|
|
if (data.startsWith("error")) {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("error", data);
|
|
|
resultArray.put(jsonObject);
|
|
|
return resultArray ;
|
|
|
}
|
|
|
JSONObject jsonData = new JSONObject(data);
|
|
|
JSONArray jsonArray = jsonData.getJSONArray("EhrList");
|
|
|
if (!jsonArray.isNull(0) && jsonArray.getJSONObject(0).length() != 0) {
|
|
@ -105,14 +139,20 @@ public class InspectionService extends BaseService {
|
|
|
String key = patientId + eventNo + orgId;
|
|
|
JSONObject catalogObject = new JSONObject();
|
|
|
String catalogCode = jsonObject.get("CATALOG_CODE").toString();
|
|
|
String endTimeNew = jsonObject.get("END_TIME").toString();
|
|
|
String catalogValue = systemDictMap.get(catalogCode);
|
|
|
jsonObject.remove("CATALOG_CODE");
|
|
|
if (jsonObjectMap.containsKey(key)) {
|
|
|
jsonObject = jsonObjectMap.get(key);
|
|
|
String endTimeOld = jsonObject.get("END_TIME").toString();
|
|
|
if (endTimeNew.compareTo(endTimeOld) < 0) {
|
|
|
endTimeNew = endTimeOld;
|
|
|
}
|
|
|
catalogObject = jsonObject.getJSONObject("CATALOG");
|
|
|
}
|
|
|
catalogObject.put(catalogCode, catalogValue);
|
|
|
jsonObject.put("CATALOG", catalogObject);
|
|
|
jsonObject.put("END_TIME", endTimeNew);
|
|
|
jsonObjectMap.put(key, jsonObject);
|
|
|
}
|
|
|
|