下载文件json解析问题

master
gongzhenkun 2 years ago
parent 3d5847f95b
commit 5f867093c6

@ -72,14 +72,6 @@ public class TRecordController extends BaseController
List<TRecordResp> list = tRecordService.selectTRecordListWithoutResult(tRecord); List<TRecordResp> list = tRecordService.selectTRecordListWithoutResult(tRecord);
if(CollectionUtils.isNotEmpty(list)){ if(CollectionUtils.isNotEmpty(list)){
list.stream().forEach(tRecordResp -> { 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(); StringBuilder updateResult = new StringBuilder();
if(StringUtils.isNotEmpty(tRecordResp.getUpdateResult()) if(StringUtils.isNotEmpty(tRecordResp.getUpdateResult())
&& null != JSON.parseObject(tRecordResp.getUpdateResult())){ && null != JSON.parseObject(tRecordResp.getUpdateResult())){
@ -88,14 +80,6 @@ public class TRecordController extends BaseController
if(updateResult.length() != 0){ if(updateResult.length() != 0){
tRecordResp.setUpdateResult(updateResult.toString()); 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(); StringBuilder aiResult = new StringBuilder();
if(StringUtils.isNotEmpty(tRecordResp.getAiResult()) if(StringUtils.isNotEmpty(tRecordResp.getAiResult())
&& null != JSON.parseObject(tRecordResp.getAiResult())){ && null != JSON.parseObject(tRecordResp.getAiResult())){
@ -209,53 +193,58 @@ public class TRecordController extends BaseController
public void typeAppend(String type,StringBuilder resultBuilder){ public void typeAppend(String type,StringBuilder resultBuilder){
//获取json字符data中的数据 //获取json字符data中的数据
String dataString = JSON.parseObject(type).getString("data"); String dataString = JSON.parseObject(type).getString("data");
if(StringUtils.isNotEmpty(dataString) && null != JSON.parseObject(dataString)){ try{
JSONObject dataObject = JSON.parseObject(dataString); if(StringUtils.isNotEmpty(dataString) && !JSON.parseObject(dataString,Map.class).isEmpty()){
//如果包含舌质 Map<String,JSONObject> mapData = JSON.parseObject(dataString,Map.class);
if(StringUtils.isNotEmpty(dataObject.getString("shezhi")) //如果包含舌质
&& null != JSON.parseObject(dataObject.getString("shezhi"))){ if(mapData.containsKey("shezhi")
resultBuilder.append("舌质"); && null != mapData.get("shezhi")){
resultAppend(dataObject.getString("shezhi"),resultBuilder); resultBuilder.append("舌质");
JSONObject shezhiObject = JSON.parseObject(dataObject.getString("shezhi")); resultAppend(mapData.get("shezhi").toString(),resultBuilder);
if(StringUtils.isNotEmpty(shezhiObject.getString("sz_color")) JSONObject shezhiObject = mapData.get("shezhi");
&& null != JSON.parseObject(shezhiObject.getString("sz_color"))){ if(StringUtils.isNotEmpty(shezhiObject.getString("sz_color"))
resultAppend(shezhiObject.getString("sz_color"),resultBuilder); && 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"))){ if(StringUtils.isNotEmpty(shezhiObject.getString("sz_yuban"))
resultAppend(shezhiObject.getString("sz_yuban"),resultBuilder); && 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"))){ if(mapData.containsKey("shetai")
resultAppend(shezhiObject.getString("sz_yudian"),resultBuilder); && 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"))){ if(mapData.containsKey("shexia")
resultAppend(shezhiObject.getString("sz_liewen"),resultBuilder); && null != mapData.get("shexia")){
} resultBuilder.append("\n\n舌下脉络");
} JSONObject shexiaObject = mapData.get("shexia");
//如果包含舌苔 if(StringUtils.isNotEmpty(shexiaObject.getString("sx_vein_color"))
if(StringUtils.isNotEmpty(dataObject.getString("shetai")) && shexiaObject.getString("sx_vein_color").contains("{")
&& null != JSON.parseObject(dataObject.getString("shetai"))){ && null != JSON.parseObject(shexiaObject.getString("sx_vein_color"))){
resultBuilder.append("\n\n舌苔"); resultAppend(shexiaObject.getString("sx_vein_color"),resultBuilder);
JSONObject shetaiObject = JSON.parseObject(dataObject.getString("shetai")); }
if(StringUtils.isNotEmpty(shetaiObject.getString("st_color")) resultAppend(mapData.get("shexia").toString(),resultBuilder);
&& 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);
} }
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") : "")); resultBuilder.append("\n黄度平均值:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : ""));
} }
if(StringUtils.isNotEmpty(typeObject.getString("sx_vein_width")) if(StringUtils.isNotEmpty(typeObject.getString("sx_vein_width"))
&& typeObject.getString("sx_vein_width").contains("{")
&& null != JSON.parseObject(typeObject.getString("sx_vein_width"))){ && null != JSON.parseObject(typeObject.getString("sx_vein_width"))){
JSONObject valObject = 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") : "")); resultBuilder.append("\n脉络粗细:"+(StringUtils.isNotEmpty(valObject.getString("quantification")) ? valObject.getString("quantification") : ""));
} }
if(StringUtils.isNotEmpty(typeObject.getString("sx_vein_length")) if(StringUtils.isNotEmpty(typeObject.getString("sx_vein_length"))
&& typeObject.getString("sx_vein_length").contains("{")
&& null != JSON.parseObject(typeObject.getString("sx_vein_length"))){ && null != JSON.parseObject(typeObject.getString("sx_vein_length"))){
JSONObject valObject = 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") : "")); resultBuilder.append("\n脉络长度:"+(StringUtils.isNotEmpty(valObject.getString("quantification")) ? valObject.getString("quantification") : ""));
} }
if(StringUtils.isNotEmpty(typeObject.getString("sx_vein_type")) if(StringUtils.isNotEmpty(typeObject.getString("sx_vein_type"))
&& typeObject.getString("sx_vein_type").contains("{")
&& null != JSON.parseObject(typeObject.getString("sx_vein_type"))){ && null != JSON.parseObject(typeObject.getString("sx_vein_type"))){
JSONObject valObject = 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") : "")); resultBuilder.append("\n脉络形态:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : ""));

Loading…
Cancel
Save