fix:工单同步相关逻辑

This commit is contained in:
zhangzq
2026-07-11 09:50:11 +08:00
parent 8fa31ae2e6
commit 58bb49bf8d
34 changed files with 338 additions and 336 deletions

View File

@@ -1,6 +1,8 @@
package org.nl.common.aspect;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
@@ -12,9 +14,12 @@ import org.nl.wms.system_manage.mock.service.dao.MockConfig;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@Aspect
@@ -60,6 +65,27 @@ public class MockAspect {
return null;
}
Type genericReturnType = method.getGenericReturnType();
if (returnType == ResponseEntity.class) {
// 先解析成 JSONObject
JSONObject jsonObject = JSON.parseObject(responseData);
Integer statusCode = jsonObject.getInteger("status");
Object body = jsonObject.get("body");
// 获取 ResponseEntity 的泛型参数(body 的类型)
Type bodyType = null;
if (genericReturnType instanceof ParameterizedType) {
ParameterizedType pt = (ParameterizedType) genericReturnType;
Type[] actualTypeArgs = pt.getActualTypeArguments();
if (actualTypeArgs.length > 0) {
bodyType = actualTypeArgs[0];
}
}
// 解析 body
Object parsedBody = bodyType != null && body != null
? JSON.parseObject(body.toString(), bodyType)
: body;
return new ResponseEntity<>(parsedBody, HttpStatus.valueOf(statusCode));
}
return JSON.parseObject(responseData, genericReturnType);
}
}