Browse Source

Merge branch '主线开发' into 主线测试

dev
jianjun 4 years ago
parent
commit
de5dfdc878
  1. 30
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java
  2. 4
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java

30
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java

@ -51,24 +51,24 @@ public interface ResultDataResolver {
// 考虑到:上游服务抛出的异常代码和错误消息并不一定适用于当前服务,并且上有服务的错误消息弹出之后可能给用户造成困扰,
// 因此,当前服务抛出异常的时候,不再继承上游服务返回的错误码和错误消息
if (!result.success()) {
Integer finalErrorCode = errorCode == null ? result.getCode() : errorCode;
String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? result.getInternalMsg() : errorInternalMsg;
throw new RenException(finalErrorCode, finalErrorInternalMsg, showMsg, RenException.MessageMode.CODE_INTERNAL_EXTERNAL);
}
// if (!result.success()) {
// String j = JSON.toJSONString(result);
// logger.info("远程调用出错,返回结果:{}", j);
//
// // 如果不通过参数指定code,则默认使用8000服务器开小差
// Integer finalErrorCode = errorCode == null ? EpmetErrorCode.SERVER_ERROR.getCode() : errorCode;
// String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? "" : errorInternalMsg;
// String finalShowMsg = StringUtils.isBlank(showMsg) ? "" : showMsg;
//
// throw new EpmetException(finalErrorCode, finalErrorInternalMsg, finalShowMsg);
// Integer finalErrorCode = errorCode == null ? result.getCode() : errorCode;
// String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? result.getInternalMsg() : errorInternalMsg;
// throw new RenException(finalErrorCode, finalErrorInternalMsg, showMsg, RenException.MessageMode.CODE_INTERNAL_EXTERNAL);
// }
if (!result.success()) {
String j = JSON.toJSONString(result);
logger.info("远程调用出错,返回结果:{}", j);
// 如果不通过参数指定code,则默认使用8000服务器开小差
Integer finalErrorCode = errorCode == null ? EpmetErrorCode.SERVER_ERROR.getCode() : errorCode;
String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? "" : errorInternalMsg;
String finalShowMsg = StringUtils.isBlank(showMsg) ? "" : showMsg;
throw new EpmetException(finalErrorCode, finalErrorInternalMsg, finalShowMsg);
}
return result.getData();
}

4
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java

@ -6,6 +6,7 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.classic.spi.StackTraceElementProxy;
import ch.qos.logback.core.spi.FilterReply;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.ThreadLocalConstant;
import com.epmet.commons.tools.dto.form.DingTalkTextMsg;
import com.epmet.commons.tools.enums.EnvEnum;
@ -15,6 +16,7 @@ import com.epmet.commons.tools.utils.SpringContextUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.cloud.commons.util.InetUtils;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
@ -77,7 +79,7 @@ public class LogMsgSendFilter extends LevelFilter {
stringBuilder.append("故障时间:").append(DateUtils.format(new Date(event.getTimeStamp()),DateUtils.DATE_TIME_PATTERN));
stringBuilder.append("\n");
stringBuilder.append("TraceId:").append(Thread.currentThread().getName());
stringBuilder.append("TraceId:").append(MDC.get(AppClientConstant.TRANSACTION_SERIAL_KEY));
stringBuilder.append("\n");
HttpServletRequest request = getRequest();

Loading…
Cancel
Save