AI接口调用时状态问题

master
gongzhenkun 2 years ago
parent c94dd28400
commit 2440470560

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

@ -127,6 +127,7 @@ public class SysLoginService
// 验证密码 // 验证密码
if (!SecurityUtils.matchesPassword(password, sysUser.getPassword())) { if (!SecurityUtils.matchesPassword(password, sysUser.getPassword())) {
log.info("登录用户:{} 密码不正确.", username); log.info("登录用户:{} 密码不正确.", username);
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
throw new ServiceException("登录失败!"); throw new ServiceException("登录失败!");
} }
LoginUser loginUser = new LoginUser(); LoginUser loginUser = new LoginUser();

Loading…
Cancel
Save