diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java index ecdfdd0..e2c0436 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java @@ -40,7 +40,28 @@ public class TRecordServiceImpl implements ITRecordService add("sz_avg_purple"); add("sz_avg_red"); add("sx_vein_avg_purple"); - }};; + }}; + + /** + * 字段对应v的值为图片base64的key + */ + private static final List ignoreKeys = new ArrayList(){{ + 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 getQuantificationKeys = new ArrayList(){{ + 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 records = tRecords.stream().sorted(Comparator.comparing(TRecord::getCreateTime)).collect(Collectors.toList()); - List jsonKeyList = new ArrayList(){{ - 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 records, List jsonKeyList) + private RecordHistoryDataResp getDataList(List records) { RecordHistoryDataResp recordHistoryDataResp = new RecordHistoryDataResp(); // 构造时间轴坐标值 @@ -193,7 +205,7 @@ public class TRecordServiceImpl implements ITRecordService if (!CollectionUtils.isEmpty(result)){ HashMap> 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> historyDataMap, List removeKeyList) { + private void getJsonData(Object obj, String listName, HashMap> historyDataMap, List 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 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()); } } }