From 5f867093c6483e8fd2a59519a92b27adc7e400ee Mon Sep 17 00:00:00 2001 From: gongzhenkun <1658878546@qq.com> Date: Tue, 28 Feb 2023 11:35:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=96=87=E4=BB=B6json?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/pc/TRecordController.java | 110 ++++++++---------- 1 file changed, 51 insertions(+), 59 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TRecordController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TRecordController.java index e4a9f54..17df833 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TRecordController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TRecordController.java @@ -72,14 +72,6 @@ public class TRecordController extends BaseController List list = tRecordService.selectTRecordListWithoutResult(tRecord); if(CollectionUtils.isNotEmpty(list)){ list.stream().forEach(tRecordResp -> { - StringBuilder updateResult2 = new StringBuilder(); - if(StringUtils.isNotEmpty(tRecordResp.getUpdateResult2()) - && null != JSON.parseObject(tRecordResp.getUpdateResult2())){ - typeAppend(tRecordResp.getUpdateResult2(),updateResult2); - } - if(updateResult2.length() != 0){ - tRecordResp.setUpdateResult2(updateResult2.toString()); - } StringBuilder updateResult = new StringBuilder(); if(StringUtils.isNotEmpty(tRecordResp.getUpdateResult()) && null != JSON.parseObject(tRecordResp.getUpdateResult())){ @@ -88,14 +80,6 @@ public class TRecordController extends BaseController if(updateResult.length() != 0){ tRecordResp.setUpdateResult(updateResult.toString()); } - StringBuilder aiResult2 = new StringBuilder(); - if(StringUtils.isNotEmpty(tRecordResp.getAiResult2()) - && null != JSON.parseObject(tRecordResp.getAiResult2())){ - typeAppend(tRecordResp.getAiResult2(),aiResult2); - } - if(aiResult2.length() != 0){ - tRecordResp.setAiResult2(aiResult2.toString()); - } StringBuilder aiResult = new StringBuilder(); if(StringUtils.isNotEmpty(tRecordResp.getAiResult()) && null != JSON.parseObject(tRecordResp.getAiResult())){ @@ -209,53 +193,58 @@ public class TRecordController extends BaseController public void typeAppend(String type,StringBuilder resultBuilder){ //获取json字符data中的数据 String dataString = JSON.parseObject(type).getString("data"); - if(StringUtils.isNotEmpty(dataString) && null != JSON.parseObject(dataString)){ - JSONObject dataObject = JSON.parseObject(dataString); - //如果包含舌质 - if(StringUtils.isNotEmpty(dataObject.getString("shezhi")) - && null != JSON.parseObject(dataObject.getString("shezhi"))){ - resultBuilder.append("舌质"); - resultAppend(dataObject.getString("shezhi"),resultBuilder); - JSONObject shezhiObject = JSON.parseObject(dataObject.getString("shezhi")); - if(StringUtils.isNotEmpty(shezhiObject.getString("sz_color")) - && null != JSON.parseObject(shezhiObject.getString("sz_color"))){ - resultAppend(shezhiObject.getString("sz_color"),resultBuilder); - } - if(StringUtils.isNotEmpty(shezhiObject.getString("sz_yuban")) - && null != JSON.parseObject(shezhiObject.getString("sz_yuban"))){ - resultAppend(shezhiObject.getString("sz_yuban"),resultBuilder); + try{ + if(StringUtils.isNotEmpty(dataString) && !JSON.parseObject(dataString,Map.class).isEmpty()){ + Map mapData = JSON.parseObject(dataString,Map.class); + //如果包含舌质 + if(mapData.containsKey("shezhi") + && null != mapData.get("shezhi")){ + resultBuilder.append("舌质"); + resultAppend(mapData.get("shezhi").toString(),resultBuilder); + JSONObject shezhiObject = mapData.get("shezhi"); + if(StringUtils.isNotEmpty(shezhiObject.getString("sz_color")) + && null != JSON.parseObject(shezhiObject.getString("sz_color"))){ + resultAppend(shezhiObject.getString("sz_color"),resultBuilder); + } + if(StringUtils.isNotEmpty(shezhiObject.getString("sz_yuban")) + && null != JSON.parseObject(shezhiObject.getString("sz_yuban"))){ + resultAppend(shezhiObject.getString("sz_yuban"),resultBuilder); + } + if(StringUtils.isNotEmpty(shezhiObject.getString("sz_yudian")) + && null != JSON.parseObject(shezhiObject.getString("sz_yudian"))){ + resultAppend(shezhiObject.getString("sz_yudian"),resultBuilder); + } + if(StringUtils.isNotEmpty(shezhiObject.getString("sz_liewen")) + && null != JSON.parseObject(shezhiObject.getString("sz_liewen"))){ + resultAppend(shezhiObject.getString("sz_liewen"),resultBuilder); + } } - if(StringUtils.isNotEmpty(shezhiObject.getString("sz_yudian")) - && null != JSON.parseObject(shezhiObject.getString("sz_yudian"))){ - resultAppend(shezhiObject.getString("sz_yudian"),resultBuilder); + //如果包含舌苔 + if(mapData.containsKey("shetai") + && null != mapData.get("shetai")){ + resultBuilder.append("\n\n舌苔"); + JSONObject shetaiObject = mapData.get("shetai"); + if(StringUtils.isNotEmpty(shetaiObject.getString("st_color")) + && null != JSON.parseObject(shetaiObject.getString("st_color"))){ + resultAppend(shetaiObject.getString("st_color"),resultBuilder); + } + resultAppend(mapData.get("shetai").toString(),resultBuilder); } - if(StringUtils.isNotEmpty(shezhiObject.getString("sz_liewen")) - && null != JSON.parseObject(shezhiObject.getString("sz_liewen"))){ - resultAppend(shezhiObject.getString("sz_liewen"),resultBuilder); - } - } - //如果包含舌苔 - if(StringUtils.isNotEmpty(dataObject.getString("shetai")) - && null != JSON.parseObject(dataObject.getString("shetai"))){ - resultBuilder.append("\n\n舌苔"); - JSONObject shetaiObject = JSON.parseObject(dataObject.getString("shetai")); - if(StringUtils.isNotEmpty(shetaiObject.getString("st_color")) - && null != JSON.parseObject(shetaiObject.getString("st_color"))){ - resultAppend(shetaiObject.getString("st_color"),resultBuilder); - } - resultAppend(dataObject.getString("shetai"),resultBuilder); - } - //如果包含舌下脉络 - if(StringUtils.isNotEmpty(dataObject.getString("shexia")) - && null != JSON.parseObject(dataObject.getString("shexia"))){ - resultBuilder.append("\n\n舌下脉络"); - JSONObject shexiaObject = JSON.parseObject(dataObject.getString("shexia")); - if(StringUtils.isNotEmpty(shexiaObject.getString("sx_vein_color")) - && null != JSON.parseObject(shexiaObject.getString("sx_vein_color"))){ - resultAppend(shexiaObject.getString("sx_vein_color"),resultBuilder); + //如果包含舌下脉络 + if(mapData.containsKey("shexia") + && null != mapData.get("shexia")){ + resultBuilder.append("\n\n舌下脉络"); + JSONObject shexiaObject = mapData.get("shexia"); + if(StringUtils.isNotEmpty(shexiaObject.getString("sx_vein_color")) + && shexiaObject.getString("sx_vein_color").contains("{") + && null != JSON.parseObject(shexiaObject.getString("sx_vein_color"))){ + resultAppend(shexiaObject.getString("sx_vein_color"),resultBuilder); + } + resultAppend(mapData.get("shexia").toString(),resultBuilder); } - resultAppend(dataObject.getString("shexia"),resultBuilder); } + }catch (Exception e){ + logger.error("方法:/system/record/export报错,json字符串:"+type,e.getMessage()); } } @@ -389,16 +378,19 @@ public class TRecordController extends BaseController resultBuilder.append("\n黄度平均值:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); } if(StringUtils.isNotEmpty(typeObject.getString("sx_vein_width")) + && typeObject.getString("sx_vein_width").contains("{") && null != JSON.parseObject(typeObject.getString("sx_vein_width"))){ JSONObject valObject = JSON.parseObject(typeObject.getString("sx_vein_width")); resultBuilder.append("\n脉络粗细:"+(StringUtils.isNotEmpty(valObject.getString("quantification")) ? valObject.getString("quantification") : "")); } if(StringUtils.isNotEmpty(typeObject.getString("sx_vein_length")) + && typeObject.getString("sx_vein_length").contains("{") && null != JSON.parseObject(typeObject.getString("sx_vein_length"))){ JSONObject valObject = JSON.parseObject(typeObject.getString("sx_vein_length")); resultBuilder.append("\n脉络长度:"+(StringUtils.isNotEmpty(valObject.getString("quantification")) ? valObject.getString("quantification") : "")); } if(StringUtils.isNotEmpty(typeObject.getString("sx_vein_type")) + && typeObject.getString("sx_vein_type").contains("{") && null != JSON.parseObject(typeObject.getString("sx_vein_type"))){ JSONObject valObject = JSON.parseObject(typeObject.getString("sx_vein_type")); resultBuilder.append("\n脉络形态:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : ""));