获取历史图表数据异常捕获

master
chenfei 2 years ago
parent 9a9e3e3e9c
commit f3f24ab16a

@ -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<Date> dateList = records.stream().map(TRecord::getCreateTime).collect(Collectors.toList());
recordHistoryDataResp.setDateList(dateList);
List<JSONObject> 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<Integer> shezhiList = new LinkedList<>();
List<Integer> 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);

Loading…
Cancel
Save