From 2de57980109d9c79c0ea2cae4c5ed5368004ee96 Mon Sep 17 00:00:00 2001 From: gongzhenkun <1658878546@qq.com> Date: Thu, 27 Oct 2022 17:40:49 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"AI=E6=8E=A5=E5=8F=A3=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=97=B6=E7=8A=B6=E6=80=81=E9=97=AE=E9=A2=98"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 24404705600453ff7ecafcad38a599e589a9afdc. --- .../web/controller/api/AppController.java | 45 ++++++++++++------- .../web/service/SysLoginService.java | 1 - 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java index ff5ebc6..4ec562c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java @@ -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()); } - JSONObject returnData = JSONObject.parseObject(result); - Integer code = returnData.getInteger("code"); - if (code != 200) { - return AjaxResult.error(code, returnData.getString("msg")); + 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")); + } + 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 data = new HashMap<>(); data.put("result",jsonObject); TImage tImage = new TImage(); diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java index 3cd8ed9..5866da0 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -128,7 +128,6 @@ public class SysLoginService // 验证密码 if (!SecurityUtils.matchesPassword(password, sysUser.getPassword())) { log.info("登录用户:{} 密码不正确.", username); - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"))); throw new ServiceException("登录失败!"); } LoginUser loginUser = new LoginUser();