From f3f24ab16ad65f3c5429f3af89cda6e2b3d2e189 Mon Sep 17 00:00:00 2001 From: chenfei <18955928961@163.com> Date: Fri, 12 Aug 2022 10:20:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=8E=86=E5=8F=B2=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8=E6=8D=95=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/TRecordServiceImpl.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) 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);