修改接口

This commit is contained in:
张怡蓉
2025-12-19 15:23:36 +08:00
parent e2bb851e37
commit ff64b90d0a
2 changed files with 11 additions and 1 deletions

View File

@@ -32,7 +32,7 @@ public class ToErpApiController {
/**
* 回传其他出入库单
*/
@Scheduled(fixedDelay = 1500)
// @Scheduled(fixedDelay = 1500)
public void callbackTransferBill() {
toErpService.callbackTransferBill();
}

View File

@@ -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");