Forráskód Böngészése

ts添加动态查询条件

yanguofeng 2 éve
szülő
commit
43b535c087

+ 6 - 2
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/interceptor/AppContextConfig.java

@@ -1,16 +1,20 @@
 package com.persagy.adm.server.custom.interceptor;
 
-import org.springframework.context.annotation.Configuration;
+import org.springframework.stereotype.Component;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
-@Configuration
+@Component
 public class AppContextConfig implements WebMvcConfigurer {
 
     @Override
     public void addInterceptors(InterceptorRegistry registry) {
         InterceptorRegistration registration = registry.addInterceptor(new AppContextInterceptor());
         registration.addPathPatterns("/adm/adm-file/**");
+
+        InterceptorRegistration registration1 = registry.addInterceptor(new TraceIdInterceptor());
+        registration1.addPathPatterns("/**");
+
     }
 }

+ 23 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/interceptor/TraceIdInterceptor.java

@@ -0,0 +1,23 @@
+package com.persagy.adm.server.custom.interceptor;
+
+import org.slf4j.MDC;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Objects;
+import java.util.UUID;
+
+@Component
+public class TraceIdInterceptor extends HandlerInterceptorAdapter {
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        String traceId = request.getHeader("traceId");
+        if (!Objects.nonNull(traceId)){
+            traceId = UUID.randomUUID().toString();
+        }
+        MDC.put("traceId",traceId);
+        return super.preHandle(request, response, handler);
+    }
+}

+ 1 - 1
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/SyncAppImpl.java

@@ -287,7 +287,7 @@ public class SyncAppImpl implements ISyncApp {
 		List<AdmProblem> problems = problemMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<>(),projectId,buildingId,operator,admDownloadTs));
 
 		// 下载ADM图纸
-		List<AdmCad> admCads = admCadMapper.selectList(new LambdaQueryWrapper<AdmCad>().eq(AdmCad::getProjectId,projectId).eq(AdmCad::getBuildingId,buildingId).gt(AdmCad::getTs,admDownloadTs));
+		List<AdmCad> admCads = admCadMapper.selectList(new LambdaQueryWrapper<AdmCad>().eq(AdmCad::getProjectId,projectId).eq(AdmCad::getBuildingId,buildingId).gt(admDownloadTs != null && admDownloadTs != 0,AdmCad::getTs,admDownloadTs));
 
 		List<AdmFile> file = fileMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmFile>(), projectId, buildingId, operator, admDownloadTs));
 		List<AdmQrCode> qrCode = qrCodeMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmQrCode>(), projectId, buildingId, operator, admDownloadTs));