AI接口返回值色条保存到本地

master
gongzhenkun 2 years ago
parent e2870a44c3
commit 18d835c529

@ -629,6 +629,10 @@ public class AppController extends BaseController
add("img_st"); add("img_st");
add("img_sx"); add("img_sx");
add("img_sx_vein"); add("img_sx_vein");
add("sz_avg_red");
add("sz_avg_purple");
add("st_avg_yellow");
add("sx_vein_avg_purple");
}}; }};
try { try {
doRemoveBase64Image(jsonObject.getJSONObject("data"), "data", jsonKeyList, recordId); doRemoveBase64Image(jsonObject.getJSONObject("data"), "data", jsonKeyList, recordId);
@ -639,7 +643,7 @@ public class AppController extends BaseController
tRecord.setId(recordId); tRecord.setId(recordId);
tRecord.setStatus("0"); tRecord.setStatus("0");
tRecordService.updateTRecord(tRecord); tRecordService.updateTRecord(tRecord);
throw new ServiceException("JSON解析错误:" + jsonObject.toJSONString()); throw new ServiceException("JSON解析错误:" + e.getMessage());
} }
return jsonObject; return jsonObject;
} }
@ -665,24 +669,26 @@ public class AppController extends BaseController
// 如果key包含在图片 // 如果key包含在图片
if (imageKeys.contains(entry.getKey())) { if (imageKeys.contains(entry.getKey())) {
String imageStr = null; String imageStr = null;
String imageKey = null;
if (entry.getValue() instanceof JSONObject) { if (entry.getValue() instanceof JSONObject) {
String v = ((JSONObject) entry.getValue()).getString("v"); if (null != ((JSONObject) entry.getValue()).getString("bar")) {
if (null != v) { imageStr = ((JSONObject) entry.getValue()).getString("bar");
imageStr = v; imageKey = "bar";
} else {
imageStr = ((JSONObject) entry.getValue()).getString("v");
imageKey = "v";
} }
} else {
imageStr = (String) entry.getValue();
} }
if (null != imageStr) { if (null != imageStr && !"".equals(imageStr) && null != imageKey && !"".equals(imageKey)) {
// 将base64转为图片存在服务器并将返回值置空 // 将base64转为图片存在服务器并将返回值置空
String path=FileUtils.GenerateImage(imageStr, entry.getKey()); String path = FileUtils.GenerateImage(imageStr, entry.getKey());
TImage tImage = new TImage(); TImage tImage = new TImage();
tImage.setName(entry.getKey()); tImage.setName(entry.getKey());
tImage.setPath(path); tImage.setPath(path);
tImage.setCreateTime(new Date()); tImage.setCreateTime(new Date());
tImage.setThirdId(recordId); tImage.setThirdId(recordId);
imageService.insertTImage(tImage); imageService.insertTImage(tImage);
((JSONObject) entry.getValue()).put("v", ""); ((JSONObject) entry.getValue()).put(imageKey, "");
} }
} }
if (!(entry.getValue() instanceof String)) { if (!(entry.getValue() instanceof String)) {

Loading…
Cancel
Save