查询患者历史数据图表调整,没有值应该补”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);
/**
* 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
private TRecordMapper tRecordMapper;
@ -160,8 +170,8 @@ public class TRecordServiceImpl implements ITRecordService
private RecordHistoryDataResp getDataList(List<TRecord> records, List<String> jsonKeyList)
{
RecordHistoryDataResp recordHistoryDataResp = new RecordHistoryDataResp();
// 构造时间轴坐标值
List<Date> dateList = records.stream().map(TRecord -> {
if (null != TRecord.getUploadTime()) {
return TRecord.getUploadTime();
@ -170,6 +180,7 @@ public class TRecordServiceImpl implements ITRecordService
}
}).collect(Collectors.toList());
recordHistoryDataResp.setDateList(dateList);
// 构造纵坐标值
List<JSONObject> result = records.stream().map(tRecord -> {
JSONObject jsonObject = new JSONObject();
if(StringUtils.isEmpty(tRecord.getUpdateResult())){
@ -197,14 +208,21 @@ public class TRecordServiceImpl implements ITRecordService
* @param historyDataMap
* @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
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()) {
if ((entry.getValue() instanceof JSONObject)) {
getJsonData(entry.getValue(), entry.getKey(), historyDataMap, removeKeyList);
} else {
// 去除带图片字段
// 忽略带图片字段
if (removeKeyList.contains(listName)) {
continue;
}
@ -213,18 +231,29 @@ public class TRecordServiceImpl implements ITRecordService
if (!"v".equals(entry.getKey())) {
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;
if (null == historyDataMap.get(listName)) {
list = new ArrayList<>();
} else {
list = historyDataMap.get(listName);
}
list.add(entry.getValue());
list.add(val);
historyDataMap.put(listName, list);
}
}
}
}
/**
*

Loading…
Cancel
Save