|
|
|
@ -436,7 +436,8 @@ public class AppController extends BaseController
|
|
|
|
|
String result;
|
|
|
|
|
Date start;
|
|
|
|
|
Date end;
|
|
|
|
|
try {
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
start = new Date();
|
|
|
|
|
if (aiPostReq.getUsr() != null) {
|
|
|
|
|
aiPostReq.getUsr().setTs_submit_ai(start.getTime());
|
|
|
|
@ -444,24 +445,36 @@ public class AppController extends BaseController
|
|
|
|
|
logger.info("ai param is {}", aiPostReq);
|
|
|
|
|
result = HttpUtils.sendPost(URL, mapper.writeValueAsString(delNullData(aiPostReq)));
|
|
|
|
|
end = new Date();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("AI interface return exception, message is {}", e.getMessage());
|
|
|
|
|
throw new ServiceException("AI interface return exception, message is " + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isEmpty(result)) {
|
|
|
|
|
return AjaxResult.error("AI interface return null, please contact administrator");
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
throw new ServiceException(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
if (!StringUtils.isEmpty(result))
|
|
|
|
|
{
|
|
|
|
|
JSONObject data = JSONObject.parseObject(result);
|
|
|
|
|
Integer code = data.getInteger("code");
|
|
|
|
|
if(code != 200 && code != 204){
|
|
|
|
|
TRecord tRecord1 = new TRecord();
|
|
|
|
|
tRecord1.setId(recordId);
|
|
|
|
|
tRecord1.setStatus("0");
|
|
|
|
|
tRecordService.updateTRecord(tRecord1);
|
|
|
|
|
throw new ServiceException(data.getString("msg"));
|
|
|
|
|
}
|
|
|
|
|
JSONObject returnData = JSONObject.parseObject(result);
|
|
|
|
|
Integer code = returnData.getInteger("code");
|
|
|
|
|
if (code != 200) {
|
|
|
|
|
return AjaxResult.error(code, returnData.getString("msg"));
|
|
|
|
|
if (code == 204) {
|
|
|
|
|
TRecord tRecord1 = new TRecord();
|
|
|
|
|
tRecord1.setId(recordId);
|
|
|
|
|
tRecord1.setStatus("0");
|
|
|
|
|
tRecordService.updateTRecord(tRecord1);
|
|
|
|
|
return AjaxResult.error(code, data.getString("msg"));
|
|
|
|
|
}
|
|
|
|
|
jsonObject = removeBase64Image(returnData, recordId);
|
|
|
|
|
jsonObject = removeBase64Image(data,recordId);
|
|
|
|
|
tRecord.setUploadTime(start);
|
|
|
|
|
tRecord.setAiResultReturnTime(end);
|
|
|
|
|
tRecord.setAiResult(JSONObject.toJSONString(jsonObject, SerializerFeature.WriteMapNullValue));
|
|
|
|
|
tRecord.setAiResult2(JSONObject.toJSONString(jsonObject, SerializerFeature.WriteMapNullValue));
|
|
|
|
|
tRecordService.updateTRecord(tRecord);
|
|
|
|
|
}
|
|
|
|
|
Map<String,Object> data = new HashMap<>();
|
|
|
|
|
data.put("result",jsonObject);
|
|
|
|
|
TImage tImage = new TImage();
|
|
|
|
|