App端诊断记录上传JSON解析异常处理

master
gongzhenkun 2 years ago
parent bb7a0257d1
commit f8d10f2702

@ -1,5 +1,6 @@
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
@ -13,6 +14,8 @@ import com.ruoyi.system.domain.resp.TRecordResp;
import com.ruoyi.system.mapper.TRecordMapper; import com.ruoyi.system.mapper.TRecordMapper;
import com.ruoyi.system.service.ITRecordService; import com.ruoyi.system.service.ITRecordService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -28,6 +31,8 @@ import java.util.stream.Collectors;
@Service @Service
public class TRecordServiceImpl implements ITRecordService public class TRecordServiceImpl implements ITRecordService
{ {
private static final Logger logger = LoggerFactory.getLogger(TRecordServiceImpl.class);
@Autowired @Autowired
private TRecordMapper tRecordMapper; private TRecordMapper tRecordMapper;
@ -78,6 +83,7 @@ public class TRecordServiceImpl implements ITRecordService
public int updateTRecord(TRecord tRecord) public int updateTRecord(TRecord tRecord)
{ {
// 处理无图片信息 // 处理无图片信息
try {
if (tRecord.getAiResult() != null) { if (tRecord.getAiResult() != null) {
JSONObject jsonObject = JSONObject.parseObject(tRecord.getAiResult()); JSONObject jsonObject = JSONObject.parseObject(tRecord.getAiResult());
tRecord.setAiResult2(noPicture(jsonObject)); tRecord.setAiResult2(noPicture(jsonObject));
@ -86,6 +92,10 @@ public class TRecordServiceImpl implements ITRecordService
JSONObject jsonObject = JSONObject.parseObject(tRecord.getUpdateResult()); JSONObject jsonObject = JSONObject.parseObject(tRecord.getUpdateResult());
tRecord.setUpdateResult2(noPicture(jsonObject)); tRecord.setUpdateResult2(noPicture(jsonObject));
} }
} catch (JSONException jsonException) {
logger.error("Json 解析异常,请检查入参。");
throw new ServiceException("Json 解析异常,请检查入参。");
}
tRecord.setUpdateTime(DateUtils.getNowDate()); tRecord.setUpdateTime(DateUtils.getNowDate());
return tRecordMapper.updateTRecord(tRecord); return tRecordMapper.updateTRecord(tRecord);
} }

Loading…
Cancel
Save