患者历史数据图表接口调整

master
gongzhenkun 2 years ago
parent d209f2b1b0
commit 0543087b0e

@ -1,8 +1,6 @@
package com.ruoyi.system.domain.resp;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
public class RecordHistoryDataResp
{
@ -11,10 +9,20 @@ public class RecordHistoryDataResp
private List<Integer> shexiaList;
private List<Date> dateList;
private HashMap<String, ArrayList<String>> historyDataMap;
public RecordHistoryDataResp()
{
}
public HashMap<String, ArrayList<String>> getHistoryDataMap() {
return historyDataMap;
}
public void setHistoryDataMap(HashMap<String, ArrayList<String>> historyDataMap) {
this.historyDataMap = historyDataMap;
}
public List<Integer> getShezhiList()
{
return shezhiList;

@ -1,9 +1,7 @@
package com.ruoyi.system.service.impl;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.TPatientHospitalDoctor;
@ -147,9 +145,13 @@ public class TRecordServiceImpl implements ITRecordService
}
List<TRecord> records = tRecords.stream().sorted(Comparator.comparing(TRecord::getCreateTime)).collect(Collectors.toList());
List<String> jsonKeyList = new ArrayList<String>(){{
add("shemian-img_sz");
add("img_sz");
add("img_sz_yudian");
add("img_sz_yuban");
add("img_sz_liewen");
add("img_st");
add("img_sx");
add("img_sx_vein");
}};
RecordHistoryDataResp recordHistoryDataRespMap = getDataList(records,jsonKeyList);
return AjaxResult.success(recordHistoryDataRespMap);
@ -171,35 +173,47 @@ public class TRecordServiceImpl implements ITRecordService
return jsonObject;
}).filter(Objects::nonNull).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(result)){
List<Integer> shezhiList = new LinkedList<>();
List<Integer> shetaiList = new LinkedList<>();
List<Integer> shexiaList = new LinkedList<>();
String[] keys0 = jsonKeyList.get(0).split("-");
String key1 = jsonKeyList.get(1);
String key2 = jsonKeyList.get(2);
HashMap<String, ArrayList<String>> map = new HashMap<>();
result.forEach(jsonObject -> {
Integer value1 ;
Integer value2 ;
Integer value3 ;
try
{
value1 = jsonObject.getJSONObject("data").getJSONObject("shezhi").getJSONObject(keys0[0]).getJSONObject(keys0[1]).getInteger("anomaly");
value2 = jsonObject.getJSONObject("data").getJSONObject("shetai").getJSONObject(key1).getInteger("anomaly");
value3 = jsonObject.getJSONObject("data").getJSONObject("shexia").getJSONObject(key2).getInteger("anomaly");
}catch (Exception e){
throw new ServiceException("JSON格式错误");
}
shezhiList.add(value1);
shetaiList.add(value2);
shexiaList.add(value3);
getJsonData(jsonObject.getJSONObject("data"), "data", map, jsonKeyList);
});
recordHistoryDataResp.setShezhiList(shezhiList);
recordHistoryDataResp.setShetaiList(shetaiList);
recordHistoryDataResp.setShexiaList(shexiaList);
recordHistoryDataResp.setHistoryDataMap(map);
}
return recordHistoryDataResp;
}
/**
* json
*
* @param obj obj
* @param listName
* @param historyDataMap
* @param removeKeyList
*/
private static void getJsonData(Object obj, String listName, HashMap<String, ArrayList<String>> historyDataMap, List<String> removeKeyList) {
// aiResult结果集中只包括JSONObject,不包括JSONArray
if (obj instanceof JSONObject) {
for (Map.Entry<String, Object> entry : ((JSONObject) obj).entrySet()) {
if (!(entry.getValue() instanceof String)) {
getJsonData(entry.getValue(), entry.getKey(), historyDataMap, removeKeyList);
} else {
// 去除
if (removeKeyList.contains(listName)) {
continue;
}
ArrayList<String> list;
if (null == historyDataMap.get(listName)) {
list = new ArrayList<>();
} else {
list = historyDataMap.get(listName);
}
list.add((String) entry.getValue());
historyDataMap.put(listName, list);
}
}
}
}
/**
*
*

Loading…
Cancel
Save