diff --git a/ruoyi-admin/src/main/java/com/ruoyi/api/controller/ToErpApiController.java b/ruoyi-admin/src/main/java/com/ruoyi/api/controller/ToErpApiController.java index da955af..4002f80 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/api/controller/ToErpApiController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/api/controller/ToErpApiController.java @@ -32,7 +32,7 @@ public class ToErpApiController { /** * 回传其他出入库单 */ - @Scheduled(fixedDelay = 1500) +// @Scheduled(fixedDelay = 1500) public void callbackTransferBill() { toErpService.callbackTransferBill(); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/log/service/impl/RequestLogServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/log/service/impl/RequestLogServiceImpl.java index eaf7e63..cf4ef50 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/log/service/impl/RequestLogServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/log/service/impl/RequestLogServiceImpl.java @@ -125,6 +125,16 @@ public class RequestLogServiceImpl implements IRequestLogService requestLog.setRequestUrl(url); try { String resStr = HttpUtil.post(url, param); + + // 判断resStr的状态码,如果不是200抛出异常让catch捕获 + if (!JSONUtil.isJsonObj(resStr)) { + throw new RuntimeException("返回结果不是有效的JSON对象"); + } + cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(resStr); + Object codeObj = jsonObject.get("code"); + if (codeObj == null || !codeObj.toString().equals("200")) { + throw new RuntimeException("请求失败,状态码: " + (codeObj != null ? codeObj.toString() : "null")); + } requestLog.setResponseBody(resStr); requestLog.setResponseTime(DateUtil.formatDateTime(new Date())); requestLog.setResponseStatus("1");