历史数据特殊字段取值问题

master
gongzhenkun 2 years ago
parent 393cf8ee2d
commit 624b6e3897

@ -40,7 +40,28 @@ public class TRecordServiceImpl implements ITRecordService
add("sz_avg_purple");
add("sz_avg_red");
add("sx_vein_avg_purple");
}};;
}};
/**
* vbase64key
*/
private static final List<String> ignoreKeys = new ArrayList<String>(){{
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");
}};
/**
* key
*/
private static final List<String> getQuantificationKeys = new ArrayList<String>(){{
add("sx_vein_width");
add("sx_vein_length");
}};
@Autowired
private TRecordMapper tRecordMapper;
@ -155,20 +176,11 @@ public class TRecordServiceImpl implements ITRecordService
return AjaxResult.success();
}
List<TRecord> records = tRecords.stream().sorted(Comparator.comparing(TRecord::getCreateTime)).collect(Collectors.toList());
List<String> jsonKeyList = new ArrayList<String>(){{
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);
RecordHistoryDataResp recordHistoryDataRespMap = getDataList(records);
return AjaxResult.success(recordHistoryDataRespMap);
}
private RecordHistoryDataResp getDataList(List<TRecord> records, List<String> jsonKeyList)
private RecordHistoryDataResp getDataList(List<TRecord> records)
{
RecordHistoryDataResp recordHistoryDataResp = new RecordHistoryDataResp();
// 构造时间轴坐标值
@ -193,7 +205,7 @@ public class TRecordServiceImpl implements ITRecordService
if (!CollectionUtils.isEmpty(result)){
HashMap<String, ArrayList<Object>> map = new HashMap<>();
result.forEach(jsonObject -> {
getJsonData(jsonObject.getJSONObject("data"), "data", map, jsonKeyList);
getJsonData(jsonObject.getJSONObject("data"), "data", map, ignoreKeys);
});
recordHistoryDataResp.setHistoryDataMap(map);
}
@ -206,9 +218,9 @@ public class TRecordServiceImpl implements ITRecordService
* @param obj obj
* @param listName
* @param historyDataMap
* @param removeKeyList
* @param ignoreKeyList
*/
private 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> ignoreKeyList) {
// aiResult结果集中只包括JSONObject,不包括JSONArray
if (obj instanceof JSONObject) {
// "sx_vein_avg_purple": {}
@ -219,19 +231,23 @@ public class TRecordServiceImpl implements ITRecordService
doSetHistoryData(historyDataMap, listName, "0");
}
for (Map.Entry<String, Object> entry : ((JSONObject) obj).entrySet()) {
// 忽略带图片字段
if (ignoreKeyList.contains(listName)) {
continue;
}
if ((entry.getValue() instanceof JSONObject)) {
getJsonData(entry.getValue(), entry.getKey(), historyDataMap, removeKeyList);
// 递归调用
getJsonData(entry.getValue(), entry.getKey(), historyDataMap, ignoreKeyList);
} else {
// 忽略带图片字段
if (removeKeyList.contains(listName)) {
continue;
// sx_vein_length和sx_vein_width使用quantification量化字段
if (getQuantificationKeys.contains(listName) && "quantification".equals(entry.getKey())) {
doSetHistoryData(historyDataMap, listName, entry.getValue());
}
//sz_avg_purple: { "anomaly": 0, "v": "正常" }
// anomaly属于预留字段暂时无用; 各个任务中的字段v是任务实际值
if (!"v".equals(entry.getKey())) {
continue;
if (!getQuantificationKeys.contains(listName) && "v".equals(entry.getKey())) {
doSetHistoryData(historyDataMap, listName, entry.getValue());
}
doSetHistoryData(historyDataMap, listName, entry.getValue());
}
}
}

Loading…
Cancel
Save