下载文件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);
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,14 +193,15 @@ 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);
try{
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")
&& null != mapData.get("shezhi")){
resultBuilder.append("舌质");
resultAppend(dataObject.getString("shezhi"),resultBuilder);
JSONObject shezhiObject = JSON.parseObject(dataObject.getString("shezhi"));
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);
@ -235,27 +220,31 @@ public class TRecordController extends BaseController
}
}
//如果包含舌苔
if(StringUtils.isNotEmpty(dataObject.getString("shetai"))
&& null != JSON.parseObject(dataObject.getString("shetai"))){
if(mapData.containsKey("shetai")
&& null != mapData.get("shetai")){
resultBuilder.append("\n\n舌苔");
JSONObject shetaiObject = JSON.parseObject(dataObject.getString("shetai"));
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(dataObject.getString("shetai"),resultBuilder);
resultAppend(mapData.get("shetai").toString(),resultBuilder);
}
//如果包含舌下脉络
if(StringUtils.isNotEmpty(dataObject.getString("shexia"))
&& null != JSON.parseObject(dataObject.getString("shexia"))){
if(mapData.containsKey("shexia")
&& null != mapData.get("shexia")){
resultBuilder.append("\n\n舌下脉络");
JSONObject shexiaObject = JSON.parseObject(dataObject.getString("shexia"));
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(dataObject.getString("shexia"),resultBuilder);
resultAppend(mapData.get("shexia").toString(),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") : ""));

Loading…
Cancel
Save