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 ed51b6c..70043c4 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 @@ -2,6 +2,7 @@ package com.ruoyi.system.service.impl; 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; @@ -167,14 +168,14 @@ public class TRecordServiceImpl implements ITRecordService List dateList = records.stream().map(TRecord::getCreateTime).collect(Collectors.toList()); recordHistoryDataResp.setDateList(dateList); List result = records.stream().map(tRecord -> { - JSONObject jsonObject; + JSONObject jsonObject = new JSONObject(); if(StringUtils.isEmpty(tRecord.getUpdateResult2())){ jsonObject = JSONObject.parseObject(tRecord.getAiResult2()); - }else { + }else if(!StringUtils.isEmpty(tRecord.getUpdateResult2())){ jsonObject = JSONObject.parseObject(tRecord.getUpdateResult2()); } return jsonObject; - }).collect(Collectors.toList()); + }).filter(Objects::nonNull).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(result)){ List shezhiList = new LinkedList<>(); List shetaiList = new LinkedList<>(); @@ -183,9 +184,20 @@ public class TRecordServiceImpl implements ITRecordService String key1 = jsonKeyList.get(1); String key2 = jsonKeyList.get(2); result.forEach(jsonObject -> { - shezhiList.add(jsonObject.getJSONObject("shezhi").getJSONObject(keys0[0]).getInteger(keys0[1])); - shetaiList.add(jsonObject.getJSONObject("shetai").getInteger(key1)); - shexiaList.add(jsonObject.getJSONObject("shexia").getInteger(key2)); + Integer value1 ; + Integer value2 ; + Integer value3 ; + try + { + value1 = jsonObject.getJSONObject("shezhi").getJSONObject(keys0[0]).getInteger(keys0[1]); + value2 = jsonObject.getJSONObject("shetai").getInteger(key1); + value3 = jsonObject.getJSONObject("shexia").getInteger(key2); + }catch (Exception e){ + throw new ServiceException("JSON格式错误"); + } + shezhiList.add(value1); + shetaiList.add(value2); + shexiaList.add(value3); }); recordHistoryDataResp.setShezhiList(shezhiList); recordHistoryDataResp.setShetaiList(shetaiList);