查询患者历史数据图表调整,没有值应该补”0“

master
gongzhenkun 2 years ago
parent a0c9c9fe89
commit 3bc38afb94

@ -32,6 +32,16 @@ public class TRecordServiceImpl implements ITRecordService
{ {
private static final Logger logger = LoggerFactory.getLogger(TRecordServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(TRecordServiceImpl.class);
/**
* AIkey
*/
private static final List<String> nullValKeys = new ArrayList<String>(){{
add("st_avg_yellow");
add("sz_avg_purple");
add("sz_avg_red");
add("sx_vein_avg_purple");
}};;
@Autowired @Autowired
private TRecordMapper tRecordMapper; private TRecordMapper tRecordMapper;
@ -160,8 +170,8 @@ public class TRecordServiceImpl implements ITRecordService
private RecordHistoryDataResp getDataList(List<TRecord> records, List<String> jsonKeyList) private RecordHistoryDataResp getDataList(List<TRecord> records, List<String> jsonKeyList)
{ {
RecordHistoryDataResp recordHistoryDataResp = new RecordHistoryDataResp(); RecordHistoryDataResp recordHistoryDataResp = new RecordHistoryDataResp();
// 构造时间轴坐标值
List<Date> dateList = records.stream().map(TRecord -> { List<Date> dateList = records.stream().map(TRecord -> {
if (null != TRecord.getUploadTime()) { if (null != TRecord.getUploadTime()) {
return TRecord.getUploadTime(); return TRecord.getUploadTime();
@ -170,6 +180,7 @@ public class TRecordServiceImpl implements ITRecordService
} }
}).collect(Collectors.toList()); }).collect(Collectors.toList());
recordHistoryDataResp.setDateList(dateList); recordHistoryDataResp.setDateList(dateList);
// 构造纵坐标值
List<JSONObject> result = records.stream().map(tRecord -> { List<JSONObject> result = records.stream().map(tRecord -> {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
if(StringUtils.isEmpty(tRecord.getUpdateResult())){ if(StringUtils.isEmpty(tRecord.getUpdateResult())){
@ -197,14 +208,21 @@ public class TRecordServiceImpl implements ITRecordService
* @param historyDataMap * @param historyDataMap
* @param removeKeyList * @param removeKeyList
*/ */
private static void getJsonData(Object obj, String listName, HashMap<String, ArrayList<Object>> historyDataMap, List<String> removeKeyList) { private void getJsonData(Object obj, String listName, HashMap<String, ArrayList<Object>> historyDataMap, List<String> removeKeyList) {
// aiResult结果集中只包括JSONObject,不包括JSONArray // aiResult结果集中只包括JSONObject,不包括JSONArray
if (obj instanceof JSONObject) { if (obj instanceof JSONObject) {
// "sx_vein_avg_purple": {}
// "sx_vein_avg_purple": {"anomaly": 0}
// 这两种情况应该添加默认值
if (nullValKeys.contains(listName) && null == ((JSONObject) obj).get("v")) {
// 加默认值
doSetHistoryData(historyDataMap, listName, "0");
}
for (Map.Entry<String, Object> entry : ((JSONObject) obj).entrySet()) { for (Map.Entry<String, Object> entry : ((JSONObject) obj).entrySet()) {
if ((entry.getValue() instanceof JSONObject)) { if ((entry.getValue() instanceof JSONObject)) {
getJsonData(entry.getValue(), entry.getKey(), historyDataMap, removeKeyList); getJsonData(entry.getValue(), entry.getKey(), historyDataMap, removeKeyList);
} else { } else {
// 去除带图片字段 // 忽略带图片字段
if (removeKeyList.contains(listName)) { if (removeKeyList.contains(listName)) {
continue; continue;
} }
@ -213,18 +231,29 @@ public class TRecordServiceImpl implements ITRecordService
if (!"v".equals(entry.getKey())) { if (!"v".equals(entry.getKey())) {
continue; continue;
} }
doSetHistoryData(historyDataMap, listName, entry.getValue());
}
}
}
}
/**
*
*
* @param historyDataMap map
* @param listName
* @param val
*/
private void doSetHistoryData(HashMap<String, ArrayList<Object>> historyDataMap, String listName, Object val) {
ArrayList<Object> list; ArrayList<Object> list;
if (null == historyDataMap.get(listName)) { if (null == historyDataMap.get(listName)) {
list = new ArrayList<>(); list = new ArrayList<>();
} else { } else {
list = historyDataMap.get(listName); list = historyDataMap.get(listName);
} }
list.add(entry.getValue()); list.add(val);
historyDataMap.put(listName, list); historyDataMap.put(listName, list);
} }
}
}
}
/** /**
* *

Loading…
Cancel
Save