zhuyifan

fix

...@@ -247,12 +247,12 @@ public class MealOrderGrpcService extends MealOrderServiceRpcGrpc.MealOrderServi ...@@ -247,12 +247,12 @@ public class MealOrderGrpcService extends MealOrderServiceRpcGrpc.MealOrderServi
247 queryWrapper.eq(MealOrder::getEnterpriseId, request.getEnterpriseId()); 247 queryWrapper.eq(MealOrder::getEnterpriseId, request.getEnterpriseId());
248 queryWrapper.in(!request.getDinerIdsList().isEmpty(), MealOrder::getDinerId, request.getDinerIdsList()); 248 queryWrapper.in(!request.getDinerIdsList().isEmpty(), MealOrder::getDinerId, request.getDinerIdsList());
249 LocalDate today = LocalDate.now(); 249 LocalDate today = LocalDate.now();
250 - LocalDate nextMonday = today.with(TemporalAdjusters.next(DayOfWeek.MONDAY)); 250 + LocalDate thisMonday = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
251 - LocalDateTime nextMondayStart = LocalDateTime.of(nextMonday, LocalTime.MIN); 251 + LocalDateTime thisMondayStart = LocalDateTime.of(thisMonday, LocalTime.MIN);
252 - LocalDate nextSunday = nextMonday.plusDays(6); 252 + LocalDate thisSunday = today.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
253 - LocalDateTime nextSundayEnd = LocalDateTime.of(nextSunday, LocalTime.MAX); 253 + LocalDateTime thisSundayEnd = LocalDateTime.of(thisSunday, LocalTime.MAX);
254 - queryWrapper.ge(MealOrder::getReserveDate, nextMondayStart); 254 + queryWrapper.ge(MealOrder::getReserveDate, thisMondayStart);
255 - queryWrapper.lt(MealOrder::getReserveDate, nextSundayEnd); 255 + queryWrapper.lt(MealOrder::getReserveDate, thisSundayEnd);
256 final var mealOrders = mealOrderService.list(queryWrapper); 256 final var mealOrders = mealOrderService.list(queryWrapper);
257 if (!mealOrders.isEmpty()) { 257 if (!mealOrders.isEmpty()) {
258 for (final var mealOrder : mealOrders) { 258 for (final var mealOrder : mealOrders) {
......
...@@ -4,7 +4,6 @@ import brave.Span; ...@@ -4,7 +4,6 @@ import brave.Span;
4 import brave.Tracing; 4 import brave.Tracing;
5 import brave.baggage.BaggagePropagation; 5 import brave.baggage.BaggagePropagation;
6 import brave.propagation.Propagation; 6 import brave.propagation.Propagation;
7 -import com.tianting.infoloop.constants.ConfigConstants;
8 import io.grpc.Context; 7 import io.grpc.Context;
9 import io.grpc.ForwardingServerCall; 8 import io.grpc.ForwardingServerCall;
10 import io.grpc.Grpc; 9 import io.grpc.Grpc;
...@@ -14,6 +13,7 @@ import io.grpc.ServerCallHandler; ...@@ -14,6 +13,7 @@ import io.grpc.ServerCallHandler;
14 import io.grpc.ServerInterceptor; 13 import io.grpc.ServerInterceptor;
15 import io.grpc.Status; 14 import io.grpc.Status;
16 import lombok.extern.slf4j.Slf4j; 15 import lombok.extern.slf4j.Slf4j;
16 +import org.slf4j.MDC;
17 import org.springframework.context.annotation.Primary; 17 import org.springframework.context.annotation.Primary;
18 import org.springframework.stereotype.Component; 18 import org.springframework.stereotype.Component;
19 19
...@@ -24,6 +24,9 @@ import java.util.Objects; ...@@ -24,6 +24,9 @@ import java.util.Objects;
24 24
25 import static com.tianting.infoloop.constants.ConfigConstants.BRAVE_PROPAGATION_DEBUG_FIELD; 25 import static com.tianting.infoloop.constants.ConfigConstants.BRAVE_PROPAGATION_DEBUG_FIELD;
26 import static com.tianting.infoloop.constants.ConfigConstants.ENTERPRISE_ID_KEY; 26 import static com.tianting.infoloop.constants.ConfigConstants.ENTERPRISE_ID_KEY;
27 +import static com.tianting.infoloop.constants.ConfigConstants.LOGGING_PARENT_TRACING_ID;
28 +import static com.tianting.infoloop.constants.ConfigConstants.LOGGING_TRACING_ID;
29 +import static com.tianting.infoloop.constants.ConfigConstants.LOGGING_UNIQUE_ID;
27 import static com.tianting.infoloop.constants.ConfigConstants.SOURCE_KEY; 30 import static com.tianting.infoloop.constants.ConfigConstants.SOURCE_KEY;
28 import static com.tianting.infoloop.constants.ConfigConstants.USER_ID_KEY; 31 import static com.tianting.infoloop.constants.ConfigConstants.USER_ID_KEY;
29 32
...@@ -71,6 +74,9 @@ public class GrpcServerInterceptor implements ServerInterceptor { ...@@ -71,6 +74,9 @@ public class GrpcServerInterceptor implements ServerInterceptor {
71 span.remoteIpAndPort(remoteAddressAndPort[0], Integer.parseInt(remoteAddressAndPort[1])); 74 span.remoteIpAndPort(remoteAddressAndPort[0], Integer.parseInt(remoteAddressAndPort[1]));
72 span.name(fullMethodName); 75 span.name(fullMethodName);
73 span.start(); 76 span.start();
77 + MDC.put(LOGGING_TRACING_ID, span.context().traceIdString());
78 + MDC.put(LOGGING_UNIQUE_ID, span.context().spanIdString());
79 + MDC.put(LOGGING_PARENT_TRACING_ID, span.context().parentIdString());
74 final var scope = tracing.currentTraceContext().newScope(span.context()); 80 final var scope = tracing.currentTraceContext().newScope(span.context());
75 81
76 final var listener = next.startCall(new ForwardingServerCall.SimpleForwardingServerCall<>(call) { 82 final var listener = next.startCall(new ForwardingServerCall.SimpleForwardingServerCall<>(call) {
...@@ -106,6 +112,7 @@ public class GrpcServerInterceptor implements ServerInterceptor { ...@@ -106,6 +112,7 @@ public class GrpcServerInterceptor implements ServerInterceptor {
106 } 112 }
107 scope.close(); 113 scope.close();
108 span.finish(); 114 span.finish();
115 + MDC.clear();
109 } 116 }
110 }, headers); 117 }, headers);
111 Context context = setUserContextFromHeaders(headers, fullMethodName); 118 Context context = setUserContextFromHeaders(headers, fullMethodName);
......
...@@ -9,6 +9,7 @@ import io.grpc.Context; ...@@ -9,6 +9,7 @@ import io.grpc.Context;
9 import io.grpc.ForwardingServerCallListener; 9 import io.grpc.ForwardingServerCallListener;
10 import io.grpc.ServerCall; 10 import io.grpc.ServerCall;
11 import lombok.extern.slf4j.Slf4j; 11 import lombok.extern.slf4j.Slf4j;
12 +import org.slf4j.MDC;
12 13
13 import static com.tianting.infoloop.constants.ConfigConstants.BRAVE_PROPAGATION_DEBUG_FIELD; 14 import static com.tianting.infoloop.constants.ConfigConstants.BRAVE_PROPAGATION_DEBUG_FIELD;
14 15
...@@ -67,6 +68,7 @@ public class MyContextualizedServerCallListener<ReqT> extends ForwardingServerCa ...@@ -67,6 +68,7 @@ public class MyContextualizedServerCallListener<ReqT> extends ForwardingServerCa
67 span.error(e); 68 span.error(e);
68 scope.close(); 69 scope.close();
69 span.finish(); 70 span.finish();
71 + MDC.clear();
70 throw e; 72 throw e;
71 } finally { 73 } finally {
72 context.detach(previous); 74 context.detach(previous);
...@@ -82,6 +84,7 @@ public class MyContextualizedServerCallListener<ReqT> extends ForwardingServerCa ...@@ -82,6 +84,7 @@ public class MyContextualizedServerCallListener<ReqT> extends ForwardingServerCa
82 span.error(e); 84 span.error(e);
83 scope.close(); 85 scope.close();
84 span.finish(); 86 span.finish();
87 + MDC.clear();
85 throw e; 88 throw e;
86 } finally { 89 } finally {
87 context.detach(previous); 90 context.detach(previous);
......