From f62f129f5761bc01fbc1f8ca5e5e0c675594e04f Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Wed, 8 May 2024 01:32:57 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0=E5=B7=A5=E5=8E=82?= =?UTF-8?q?=E6=8B=A6=E6=88=AA=E5=99=A8=20=E9=BB=98=E8=AE=A4=E7=99=BB?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/annotations/LocalServerUser.java | 22 ++++ .../springblade/common/cache/CacheNames.java | 5 + .../common/constant/LauncherConstant.java | 25 +++++ .../common/constant/ModuleNameConstant.java | 2 +- .../common/launch/LauncherServiceImpl.java | 8 +- .../LocalServerTenantIdAnnotationAspect.java | 59 +++++++++++ .../controller/FactoryAuthController.java | 2 + .../controller/FactoryCommonController.java | 1 + .../config/InterceptorAdapterConfig.java | 12 ++- .../factory/filer/HttpServletFilter.java | 6 ++ .../LocalServerLoginAccountsInterceptor.java | 100 ++++++++++++++++++ .../CustomHttpServletRequestWrapper.java | 36 +++++++ .../src/main/resources/application-dev.yml | 8 +- 13 files changed, 276 insertions(+), 10 deletions(-) create mode 100644 blade-biz-common/src/main/java/org/springblade/common/annotations/LocalServerUser.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/aspect/LocalServerTenantIdAnnotationAspect.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/interceptor/LocalServerLoginAccountsInterceptor.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/wrapper/CustomHttpServletRequestWrapper.java diff --git a/blade-biz-common/src/main/java/org/springblade/common/annotations/LocalServerUser.java b/blade-biz-common/src/main/java/org/springblade/common/annotations/LocalServerUser.java new file mode 100644 index 000000000..00f2276be --- /dev/null +++ b/blade-biz-common/src/main/java/org/springblade/common/annotations/LocalServerUser.java @@ -0,0 +1,22 @@ +package org.springblade.common.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 特俗标记 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.METHOD}) +public @interface LocalServerUser { + /**‘ + * 匹配值 + * factory:工厂系统 + * 6278683: 租户 + * factory-data: 租户 + * @return + */ + String ds() default ""; +} diff --git a/blade-biz-common/src/main/java/org/springblade/common/cache/CacheNames.java b/blade-biz-common/src/main/java/org/springblade/common/cache/CacheNames.java index 8fd2da967..b2f1599ab 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/cache/CacheNames.java +++ b/blade-biz-common/src/main/java/org/springblade/common/cache/CacheNames.java @@ -78,4 +78,9 @@ public interface CacheNames { * 用户能操作的仓库 */ String USER_WAREHOUSE_OWN = "logpm:user:warehouse:own:"; + + /** + * 模拟登录缓存对象 + */ + String LOCAL_SERVER_USER = "logpm:user:local:user:"; } diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/LauncherConstant.java b/blade-biz-common/src/main/java/org/springblade/common/constant/LauncherConstant.java index fa94f125b..95ab83869 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/LauncherConstant.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/LauncherConstant.java @@ -90,6 +90,20 @@ public interface LauncherConstant { */ String SEATA_TEST_ADDR = "192.168.2.110:8091"; + /** + * 本地登录 dev地址 + */ + String APPLICATION_DEV_LOGIN_ADDR = "192.168.5.6:13000"; + /** + * 本地登录 test地址 + */ + String APPLICATION_TEST_LOGIN_ADDR = "192.168.5.6:13000"; + + /** + * 本地登录 pord地址 + */ + String APPLICATION_PROD_LOGIN_ADDR = "192.168.5.6:13000"; + /** * dbuuo提供者 @@ -221,4 +235,15 @@ public interface LauncherConstant { } } + static String loginAddr(String profile) { + switch (profile) { + case (AppConstant.PROD_CODE): + return APPLICATION_DEV_LOGIN_ADDR; + case (AppConstant.TEST_CODE): + return APPLICATION_TEST_LOGIN_ADDR; + default: + return APPLICATION_PROD_LOGIN_ADDR; + } + } + } diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java b/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java index f3c9d0a48..025046feb 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java @@ -9,7 +9,7 @@ public interface ModuleNameConstant { /** * 如果不需要 "" */ - public static final String DEVAUTH =""; + public static final String DEVAUTH ="-pref"; /** * 工厂对接服务名称 diff --git a/blade-biz-common/src/main/java/org/springblade/common/launch/LauncherServiceImpl.java b/blade-biz-common/src/main/java/org/springblade/common/launch/LauncherServiceImpl.java index eb7a75c87..23a0734e0 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/launch/LauncherServiceImpl.java +++ b/blade-biz-common/src/main/java/org/springblade/common/launch/LauncherServiceImpl.java @@ -44,10 +44,10 @@ public class LauncherServiceImpl implements LauncherService { PropsUtil.setProperty(props, "spring.cloud.sentinel.transport.dashboard", LauncherConstant.sentinelAddr(profile)); - PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.username","nacos"); - PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.password","Nacos123123"); - PropsUtil.setProperty(props, "spring.cloud.nacos.config.username","nacos"); - PropsUtil.setProperty(props, "spring.cloud.nacos.config.password","Nacos123123"); +// PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.username","nacos"); +// PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.password","Nacos123123"); +// PropsUtil.setProperty(props, "spring.cloud.nacos.config.username","nacos"); +// PropsUtil.setProperty(props, "spring.cloud.nacos.config.password","Nacos123123"); // dubbo注册 PropsUtil.setProperty(props, "dubbo.application.name", appName); PropsUtil.setProperty(props, "dubbo.application.qos.enable", "false"); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/aspect/LocalServerTenantIdAnnotationAspect.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/aspect/LocalServerTenantIdAnnotationAspect.java new file mode 100644 index 000000000..6e41c6cbb --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/aspect/LocalServerTenantIdAnnotationAspect.java @@ -0,0 +1,59 @@ +//package com.logpm.factory.aspect; +// +//import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +//import org.aspectj.lang.ProceedingJoinPoint; +//import org.aspectj.lang.annotation.Around; +//import org.aspectj.lang.annotation.Aspect; +//import org.aspectj.lang.reflect.MethodSignature; +//import org.springblade.common.annotations.LocalServerUser; +//import org.springblade.core.secure.BladeUser; +//import org.springblade.core.secure.utils.AuthUtil; +//import org.springblade.core.tool.utils.StringUtil; +//import org.springblade.core.tool.utils.WebUtil; +//import org.springblade.system.cache.UserCache; +//import org.springblade.system.entity.User; +//import org.springframework.core.annotation.Order; +//import org.springframework.scheduling.annotation.Async; +//import org.springframework.stereotype.Component; +// +//import javax.servlet.http.HttpServletRequest; +//import java.lang.reflect.Method; +// +//@Aspect +//@Component +//public class LocalServerTenantIdAnnotationAspect { +// +// +// /** +// * 定义一个切点,匹配所有带有@Async("asyncExecutor")注解的方法。 +// * 注意:实际上Spring Framework自带对@Async("asyncExecutor")的处理,直接这样配置可能会导致预期之外的行为。 +// */ +// +// // 定义一个 +// @Around("@annotation(org.springblade.common.annotations.LocalServerUser)") +// public Object logAroundAsyncMethods(ProceedingJoinPoint joinPoint) throws Throwable { +// +// MethodSignature signature = (MethodSignature) joinPoint.getSignature(); +// Method method = signature.getMethod(); +// +// LocalServerUser myAsync = method.getAnnotation(LocalServerUser.class); +// String annotationValue = myAsync.ds(); +// +// if(StringUtil.isNotBlank(annotationValue) ){ +// // 在方法执行前的操作 +// DynamicDataSourceContextHolder.push(annotationValue); +// +// // 执行原方法 +// Object result = joinPoint.proceed(); +// +// // 在方法执行后的操作 +// DynamicDataSourceContextHolder.poll(); +// +// return result; +// }else{ +// return joinPoint.proceed(); +// } +// +// } +// +//} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryAuthController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryAuthController.java index b2a90050a..fd821a727 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryAuthController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryAuthController.java @@ -26,6 +26,7 @@ import lombok.AllArgsConstructor; import lombok.extern.log4j.Log4j2; import org.springblade.common.exception.CustomerException; import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tenant.annotation.NonDS; import org.springblade.core.tool.api.R; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -39,6 +40,7 @@ import javax.servlet.http.HttpServletResponse; * @since 2023-06-06 */ @Log4j2 +@NonDS @RestController @AllArgsConstructor @RequestMapping("/factory/auth") diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java index 43927134f..ae871ff8c 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java @@ -10,6 +10,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import lombok.extern.log4j.Log4j2; +import org.springblade.common.annotations.LocalServerUser; import org.springblade.common.constant.RabbitConstant; import org.springblade.common.exception.CustomerException; import org.springblade.common.utils.CommonUtil; diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/InterceptorAdapterConfig.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/InterceptorAdapterConfig.java index c775cf98a..2dbc0319d 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/InterceptorAdapterConfig.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/InterceptorAdapterConfig.java @@ -2,8 +2,10 @@ package com.logpm.factory.config; import com.logpm.factory.comfac.service.IFactoryTokenService; import com.logpm.factory.interceptor.FactoryAccountsInterceptor; +import com.logpm.factory.interceptor.LocalServerLoginAccountsInterceptor; import com.logpm.factory.interceptor.ZbFactoryAccountsInterceptor; import com.logpm.factory.props.ZbFactoryProperties; +import org.springblade.core.redis.cache.BladeRedis; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistration; @@ -15,8 +17,10 @@ public class InterceptorAdapterConfig implements WebMvcConfigurer { @Autowired IFactoryTokenService factoryTokenService; + @Autowired - ZbFactoryProperties zbFactoryProperties; + private BladeRedis redis; + @Override public void addInterceptors(InterceptorRegistry interceptorRegistry) { @@ -26,6 +30,12 @@ public class InterceptorAdapterConfig implements WebMvcConfigurer { excludePathPatterns("/factory/oupai/**"). excludePathPatterns("/factory/zb/**") .excludePathPatterns("/factory/common/**"); + registry=interceptorRegistry.addInterceptor(new LocalServerLoginAccountsInterceptor(redis)); +// registry.addPathPatterns("/factory/**"). +// excludePathPatterns("/factory/auth/token"). +// excludePathPatterns("/factory/oupai/**"). +// excludePathPatterns("/factory/zb/**") +// .excludePathPatterns("/factory/common/**"); // InterceptorRegistration registryZbFactory = interceptorRegistry.addInterceptor(new ZbFactoryAccountsInterceptor(zbFactoryProperties)); // registryZbFactory.addPathPatterns("/factory/zb/**"); } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/filer/HttpServletFilter.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/filer/HttpServletFilter.java index e0efd0d83..de486416c 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/filer/HttpServletFilter.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/filer/HttpServletFilter.java @@ -11,8 +11,14 @@ import java.io.IOException; public class HttpServletFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { + System.out.println("****************************1"); } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + + + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 执行这里"); + + ServletRequest requestWrapper = null; if(request instanceof HttpServletRequest) { requestWrapper = new RequestWrapper((HttpServletRequest) request); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/interceptor/LocalServerLoginAccountsInterceptor.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/interceptor/LocalServerLoginAccountsInterceptor.java new file mode 100644 index 000000000..56863f10d --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/interceptor/LocalServerLoginAccountsInterceptor.java @@ -0,0 +1,100 @@ +package com.logpm.factory.interceptor; + +import cn.hutool.core.map.MapUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSONObject; +import com.logpm.factory.comfac.service.IFactoryTokenService; +import com.logpm.factory.config.RequestWrapper; +import com.logpm.factory.wrapper.CustomHttpServletRequestWrapper; +import lombok.AllArgsConstructor; +import lombok.extern.log4j.Log4j2; +import org.springblade.common.cache.CacheNames; +import org.springblade.common.constant.LauncherConstant; +import org.springblade.common.exception.CustomerException; +import org.springblade.core.launch.constant.AppConstant; +import org.springblade.core.redis.cache.BladeRedis; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@Log4j2 +@AllArgsConstructor +public class LocalServerLoginAccountsInterceptor extends HandlerInterceptorAdapter { + + private final BladeRedis bladeRedis; + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws CustomerException { + + + try { + JSONObject data =bladeRedis.get(CacheNames.LOCAL_SERVER_USER); + CustomHttpServletRequestWrapper wrappedRequest = new CustomHttpServletRequestWrapper(request); + if(Objects.isNull(data)){ + String url = "http://"+ LauncherConstant.loginAddr(AppConstant.DEV_CODE)+"/blade-auth/oauth/token"; + cn.hutool.http.HttpRequest urlRequest = HttpRequest.post(url); + urlRequest.header("Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0"); + urlRequest.header("Tenant-Id", "627683"); + + Map params = new HashMap<>(); + params.put("grant_type", "local_server"); + params.put("scope", "all"); + params.put("username", "admin"); + params.put("tenantId", "627683"); + HttpResponse execute = urlRequest.form(params).execute(); + String body = execute.body(); + data = JSONObject.parseObject(body); + bladeRedis.setEx(CacheNames.LOCAL_SERVER_USER,data,3200L); + } + + // 修改或添加header + + // 发送登录请求 + log.info("##########preHandle: request={}", request); + + wrappedRequest.addHeader("Blade-Auth", "bearer "+data.getString("access_token")); + + // 用包装后的request替换原始request + request = wrappedRequest; + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); + return true; + } catch (Exception e) { + returnJson(response, JSONObject.toJSONString(R.fail(500, "服务异常,请联系管理员"))); + return false; + } + } + + private void returnJson(HttpServletResponse response, String json) { + PrintWriter writer = null; + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/json"); + try { + writer = response.getWriter(); + writer.print(json); + + } catch (IOException e) { + System.out.println(e.getMessage()); + } finally { + if (writer != null) { + writer.close(); + } + } + } + + +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/wrapper/CustomHttpServletRequestWrapper.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/wrapper/CustomHttpServletRequestWrapper.java new file mode 100644 index 000000000..82b344eab --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/wrapper/CustomHttpServletRequestWrapper.java @@ -0,0 +1,36 @@ +package com.logpm.factory.wrapper; + +import org.springframework.http.HttpHeaders; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import java.util.*; + +public class CustomHttpServletRequestWrapper extends HttpServletRequestWrapper { + + private final HttpHeaders headers; + + public CustomHttpServletRequestWrapper(HttpServletRequest request) { + super(request); + headers = new HttpHeaders(); + } + + @Override + public String getHeader(String name) { + String headerValue = headers.getFirst(name); + return headerValue != null ? headerValue : super.getHeader(name); + } + + @Override + public Enumeration getHeaderNames() { + List names = Collections.list(super.getHeaderNames()); + headers.forEach((key, value) -> names.add(key)); + return Collections.enumeration(names); + } + + // 其他需要覆盖的方法... + + public void addHeader(String name, String value) { + headers.add(name, value); + } +} diff --git a/blade-service/logpm-old-project/src/main/resources/application-dev.yml b/blade-service/logpm-old-project/src/main/resources/application-dev.yml index 68d1f4215..2b684605a 100644 --- a/blade-service/logpm-old-project/src/main/resources/application-dev.yml +++ b/blade-service/logpm-old-project/src/main/resources/application-dev.yml @@ -34,12 +34,12 @@ spring: url: ${blade.datasource.oldproject.master.url} username: ${blade.datasource.oldproject.master.username} password: ${blade.datasource.oldproject.master.password} - slave: + 627683: druid: #独立校验配置 validation-query: select 1 #oracle校验 #validation-query: select 1 from dual - url: ${blade.datasource.oldproject.slave.url} - username: ${blade.datasource.oldproject.slave.username} - password: ${blade.datasource.oldproject.slave.password} + url: ${blade.datasource.oldproject.627683.url} + username: ${blade.datasource.oldproject.627683.username} + password: ${blade.datasource.oldproject.627683.password} From ef6862d575ee1d24010e350680bcdecbbb55ea8c Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Wed, 8 May 2024 15:24:15 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=E5=AE=8C=E5=96=84=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?=E7=99=BB=E9=99=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/LauncherConstant.java | 6 +++--- .../comfac/controller/FactoryCommonController.java | 12 +++++++++++- .../LocalServerLoginAccountsInterceptor.java | 4 ++-- .../factory/mt/mapper/MtFactoryOrderMainMapper.java | 1 + 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/LauncherConstant.java b/blade-biz-common/src/main/java/org/springblade/common/constant/LauncherConstant.java index 95ab83869..8687a94c6 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/LauncherConstant.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/LauncherConstant.java @@ -93,16 +93,16 @@ public interface LauncherConstant { /** * 本地登录 dev地址 */ - String APPLICATION_DEV_LOGIN_ADDR = "192.168.5.6:13000"; + String APPLICATION_DEV_LOGIN_ADDR = "192.168.5.14:13000"; /** * 本地登录 test地址 */ - String APPLICATION_TEST_LOGIN_ADDR = "192.168.5.6:13000"; + String APPLICATION_TEST_LOGIN_ADDR = "192.168.5.14:13000"; /** * 本地登录 pord地址 */ - String APPLICATION_PROD_LOGIN_ADDR = "192.168.5.6:13000"; + String APPLICATION_PROD_LOGIN_ADDR = "192.168.5.14:13000"; /** diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java index ae871ff8c..2d8f74865 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java @@ -14,14 +14,19 @@ import org.springblade.common.annotations.LocalServerUser; import org.springblade.common.constant.RabbitConstant; import org.springblade.common.exception.CustomerException; import org.springblade.common.utils.CommonUtil; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.utils.WebUtil; import org.springframework.amqp.rabbit.connection.CorrelationData; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import javax.servlet.http.HttpServletRequest; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -178,8 +183,13 @@ public class FactoryCommonController { map.put("messageData", receiveInfoDTO); map.put("createTime", new Date().getTime()); map.put("flagType", "OrderStatusLog"); + //将消息携带绑定键值 - rabbitTemplate.convertAndSend(RabbitConstant.UNLOAD_CAR_COM_INFO_EXCHANGE, RabbitConstant.UNLOAD_CAR_COM_INFO_ROUTING, map); + rabbitTemplate.convertAndSend(RabbitConstant.UNLOAD_CAR_COM_INFO_EXCHANGE, RabbitConstant.UNLOAD_CAR_COM_INFO_ROUTING, map,message -> { + HttpServletRequest request = WebUtil.getRequest(); + message.getMessageProperties().setHeader("Blade-Auth",request.getHeader("Blade-Auth")); + return message; + }); return R.success("调用成功"); } catch (CustomerException e) { diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/interceptor/LocalServerLoginAccountsInterceptor.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/interceptor/LocalServerLoginAccountsInterceptor.java index 56863f10d..d602b0a44 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/interceptor/LocalServerLoginAccountsInterceptor.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/interceptor/LocalServerLoginAccountsInterceptor.java @@ -43,7 +43,7 @@ public class LocalServerLoginAccountsInterceptor extends HandlerInterceptorAdapt try { - JSONObject data =bladeRedis.get(CacheNames.LOCAL_SERVER_USER); + JSONObject data =bladeRedis.get(CacheNames.LOCAL_SERVER_USER+"admin"); CustomHttpServletRequestWrapper wrappedRequest = new CustomHttpServletRequestWrapper(request); if(Objects.isNull(data)){ String url = "http://"+ LauncherConstant.loginAddr(AppConstant.DEV_CODE)+"/blade-auth/oauth/token"; @@ -59,7 +59,7 @@ public class LocalServerLoginAccountsInterceptor extends HandlerInterceptorAdapt HttpResponse execute = urlRequest.form(params).execute(); String body = execute.body(); data = JSONObject.parseObject(body); - bladeRedis.setEx(CacheNames.LOCAL_SERVER_USER,data,3200L); + bladeRedis.setEx(CacheNames.LOCAL_SERVER_USER+"admin",data,3200L); } // 修改或添加header diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/mapper/MtFactoryOrderMainMapper.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/mapper/MtFactoryOrderMainMapper.java index 4d0573c5c..f115e5530 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/mapper/MtFactoryOrderMainMapper.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/mapper/MtFactoryOrderMainMapper.java @@ -1,5 +1,6 @@ package com.logpm.factory.mt.mapper; +import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.factory.mt.entity.MtFactoryOrderMain; From 505da3a19c7c12f55d6797bec6f07470d64c6fea Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Wed, 8 May 2024 18:18:52 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0=E5=90=84=E4=B8=AA?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=9A=84=E6=8B=A6=E6=88=AA=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/LauncherConstant.java | 4 +- .../common/constant/ModuleNameConstant.java | 2 +- .../aspect/AsyncAnnotationAspect.java | 31 +++++++++ .../basic/aspect/AsyncAnnotationAspect.java | 31 +++++++++ .../aspect/AsyncAnnotationAspect.java | 31 +++++++++ .../aspect/AsyncAnnotationAspect.java | 31 +++++++++ .../config/CustomMessageConverter.java | 67 +++++++++++++++++++ .../config/RabbitMqConfiguration.java | 1 + .../factory/aspect/AsyncAnnotationAspect.java | 50 ++++++++++++++ .../controller/FactoryCommonController.java | 6 +- .../config/CustomMessageConverter.java | 67 +++++++++++++++++++ .../factory/config/RabbitMqConfiguration.java | 3 +- .../LocalServerLoginAccountsInterceptor.java | 2 +- .../aspect/AsyncAnnotationAspect.java | 31 +++++++++ .../aspect/AsyncAnnotationAspect.java | 31 +++++++++ .../config/CustomMessageConverter.java | 67 +++++++++++++++++++ .../config/RabbitMqConfiguration.java | 1 + .../aspect/AsyncAnnotationAspect.java | 31 +++++++++ .../config/CustomMessageConverter.java | 67 +++++++++++++++++++ .../config/RabbitMqConfiguration.java | 1 + 20 files changed, 545 insertions(+), 10 deletions(-) create mode 100644 blade-service/logpm-distribution/src/main/java/com/logpm/distribution/config/CustomMessageConverter.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/aspect/AsyncAnnotationAspect.java create mode 100644 blade-service/logpm-factory/src/main/java/com/logpm/factory/config/CustomMessageConverter.java create mode 100644 blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/config/CustomMessageConverter.java create mode 100644 blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/config/CustomMessageConverter.java diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/LauncherConstant.java b/blade-biz-common/src/main/java/org/springblade/common/constant/LauncherConstant.java index 8687a94c6..dd664ddb0 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/LauncherConstant.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/LauncherConstant.java @@ -93,11 +93,11 @@ public interface LauncherConstant { /** * 本地登录 dev地址 */ - String APPLICATION_DEV_LOGIN_ADDR = "192.168.5.14:13000"; + String APPLICATION_DEV_LOGIN_ADDR = "192.168.3.2:13000"; /** * 本地登录 test地址 */ - String APPLICATION_TEST_LOGIN_ADDR = "192.168.5.14:13000"; + String APPLICATION_TEST_LOGIN_ADDR = "192.168.2.110:9999"; /** * 本地登录 pord地址 diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java b/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java index 025046feb..f3c9d0a48 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java @@ -9,7 +9,7 @@ public interface ModuleNameConstant { /** * 如果不需要 "" */ - public static final String DEVAUTH ="-pref"; + public static final String DEVAUTH =""; /** * 工厂对接服务名称 diff --git a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/aspect/AsyncAnnotationAspect.java b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/aspect/AsyncAnnotationAspect.java index 8667f57d1..ab25d4441 100644 --- a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/aspect/AsyncAnnotationAspect.java +++ b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/aspect/AsyncAnnotationAspect.java @@ -47,4 +47,35 @@ public class AsyncAnnotationAspect { } + /** + * 该方法为一个切面,用于对标记了@RabbitListener注解的方法进行增强,主要增加了日志记录和数据源上下文处理的功能。 + * + * @param joinPoint 切面的连接点,表示当前被拦截的方法。 + * @return 返回被拦截方法的执行结果。 + * @throws Throwable 如果执行过程中发生异常,则抛出。 + */ + @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitListener)") + public Object rabbitMethods(ProceedingJoinPoint joinPoint) throws Throwable { + // 在方法执行前,获取当前租户ID并设置到数据源上下文中 + String tenantId = AuthUtil.getTenantId(); + DynamicDataSourceContextHolder.push(tenantId); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + return result; + } + @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitHandler)") + public Object rabbitHandlerMethods(ProceedingJoinPoint joinPoint) throws Throwable { + // 在方法执行前,获取当前租户ID并设置到数据源上下文中 + String tenantId = AuthUtil.getTenantId(); + DynamicDataSourceContextHolder.push(tenantId); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + return result; + } + + } diff --git a/blade-service/logpm-basic/src/main/java/com/logpm/basic/aspect/AsyncAnnotationAspect.java b/blade-service/logpm-basic/src/main/java/com/logpm/basic/aspect/AsyncAnnotationAspect.java index 6e328c88a..e83358e9d 100644 --- a/blade-service/logpm-basic/src/main/java/com/logpm/basic/aspect/AsyncAnnotationAspect.java +++ b/blade-service/logpm-basic/src/main/java/com/logpm/basic/aspect/AsyncAnnotationAspect.java @@ -47,4 +47,35 @@ public class AsyncAnnotationAspect { } + /** + * 该方法为一个切面,用于对标记了@RabbitListener注解的方法进行增强,主要增加了日志记录和数据源上下文处理的功能。 + * + * @param joinPoint 切面的连接点,表示当前被拦截的方法。 + * @return 返回被拦截方法的执行结果。 + * @throws Throwable 如果执行过程中发生异常,则抛出。 + */ +// @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitListener)") +// public Object rabbitMethods(ProceedingJoinPoint joinPoint) throws Throwable { +// // 在方法执行前,获取当前租户ID并设置到数据源上下文中 +// String tenantId = AuthUtil.getTenantId(); +// DynamicDataSourceContextHolder.push(tenantId); +// // 执行原方法 +// Object result = joinPoint.proceed(); +// // 在方法执行后,从数据源上下文中移除租户ID +// DynamicDataSourceContextHolder.poll(); +// return result; +// } + +// @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitHandler)") +// public Object rabbitHandlerMethods(ProceedingJoinPoint joinPoint) throws Throwable { +// // 在方法执行前,获取当前租户ID并设置到数据源上下文中 +// String tenantId = AuthUtil.getTenantId(); +// DynamicDataSourceContextHolder.push(tenantId); +// // 执行原方法 +// Object result = joinPoint.proceed(); +// // 在方法执行后,从数据源上下文中移除租户ID +// DynamicDataSourceContextHolder.poll(); +// return result; +// } + } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/aspect/AsyncAnnotationAspect.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/aspect/AsyncAnnotationAspect.java index add535589..68683962b 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/aspect/AsyncAnnotationAspect.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/aspect/AsyncAnnotationAspect.java @@ -47,4 +47,35 @@ public class AsyncAnnotationAspect { } + /** + * 该方法为一个切面,用于对标记了@RabbitListener注解的方法进行增强,主要增加了日志记录和数据源上下文处理的功能。 + * + * @param joinPoint 切面的连接点,表示当前被拦截的方法。 + * @return 返回被拦截方法的执行结果。 + * @throws Throwable 如果执行过程中发生异常,则抛出。 + */ +// @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitListener)") +// public Object rabbitMethods(ProceedingJoinPoint joinPoint) throws Throwable { +// // 在方法执行前,获取当前租户ID并设置到数据源上下文中 +// String tenantId = AuthUtil.getTenantId(); +// DynamicDataSourceContextHolder.push(tenantId); +// // 执行原方法 +// Object result = joinPoint.proceed(); +// // 在方法执行后,从数据源上下文中移除租户ID +// DynamicDataSourceContextHolder.poll(); +// return result; +// } + +// @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitHandler)") +// public Object rabbitHandlerMethods(ProceedingJoinPoint joinPoint) throws Throwable { +// // 在方法执行前,获取当前租户ID并设置到数据源上下文中 +// String tenantId = AuthUtil.getTenantId(); +// DynamicDataSourceContextHolder.push(tenantId); +// // 执行原方法 +// Object result = joinPoint.proceed(); +// // 在方法执行后,从数据源上下文中移除租户ID +// DynamicDataSourceContextHolder.poll(); +// return result; +// } + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/aspect/AsyncAnnotationAspect.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/aspect/AsyncAnnotationAspect.java index aaa8612a2..bf2be94c1 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/aspect/AsyncAnnotationAspect.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/aspect/AsyncAnnotationAspect.java @@ -47,4 +47,35 @@ public class AsyncAnnotationAspect { } + /** + * 该方法为一个切面,用于对标记了@RabbitListener注解的方法进行增强,主要增加了日志记录和数据源上下文处理的功能。 + * + * @param joinPoint 切面的连接点,表示当前被拦截的方法。 + * @return 返回被拦截方法的执行结果。 + * @throws Throwable 如果执行过程中发生异常,则抛出。 + */ + @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitListener)") + public Object rabbitMethods(ProceedingJoinPoint joinPoint) throws Throwable { + // 在方法执行前,获取当前租户ID并设置到数据源上下文中 + String tenantId = AuthUtil.getTenantId(); + DynamicDataSourceContextHolder.push(tenantId); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + return result; + } + + @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitHandler)") + public Object rabbitHandlerMethods(ProceedingJoinPoint joinPoint) throws Throwable { + // 在方法执行前,获取当前租户ID并设置到数据源上下文中 + String tenantId = AuthUtil.getTenantId(); + DynamicDataSourceContextHolder.push(tenantId); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + return result; + } + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/config/CustomMessageConverter.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/config/CustomMessageConverter.java new file mode 100644 index 000000000..9f2771ac5 --- /dev/null +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/config/CustomMessageConverter.java @@ -0,0 +1,67 @@ +package com.logpm.distribution.config; + +import cn.hutool.json.JSONUtil; +import org.springblade.core.secure.BladeUser; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.utils.ThreadLocalUtil; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.core.MessageProperties; +import org.springframework.amqp.support.converter.MessageConversionException; +import org.springframework.amqp.support.converter.MessageConverter; +import org.springframework.http.HttpHeaders; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.util.Map; + +/** + * @author zhaoqiaobo + * @create 2024-05-08 + */ +@Component +public class CustomMessageConverter implements MessageConverter { + private String name; + + @Override + public Message toMessage(Object o, MessageProperties messageProperties) throws MessageConversionException { + HttpHeaders headers = (HttpHeaders) ThreadLocalUtil.get("bladeContext"); + if (headers != null && !headers.isEmpty()) { + headers.forEach((key, values) -> { + values.forEach((value) -> { + messageProperties.setHeader(key, new String[]{value}); + }); + }); + } + BladeUser user = AuthUtil.getUser(); + BladeUser bladeUser = new BladeUser(); + bladeUser.setTenantId(user.getTenantId()); + bladeUser.setUserId(user.getUserId()); + bladeUser.setAccount(user.getAccount()); + bladeUser.setRoleId(user.getRoleId()); + messageProperties.setHeader("bladeUser", JSONUtil.toJsonStr(bladeUser)); + return new Message(o.toString().getBytes(), messageProperties); + } + + @Override + public Object fromMessage(Message message) throws MessageConversionException { + MessageProperties messageProperties = message.getMessageProperties(); + Map headers = messageProperties.getHeaders(); + ThreadLocalUtil.put("bladeContext", headers); + Object bladeUser = headers.get("bladeUser"); + MockHttpServletRequest request = new MockHttpServletRequest(); + BladeUser bladeUser1 = JSONUtil.toBean(bladeUser.toString(), BladeUser.class); + request.setAttribute("_BLADE_USER_REQUEST_ATTR_", bladeUser1); + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); + return new String(message.getBody()); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/config/RabbitMqConfiguration.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/config/RabbitMqConfiguration.java index 4e7c30da7..43aa0f74a 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/config/RabbitMqConfiguration.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/config/RabbitMqConfiguration.java @@ -28,6 +28,7 @@ public class RabbitMqConfiguration { RabbitTemplate template = new RabbitTemplate(); template.setConnectionFactory(connectionFactory); template.setMandatory(true); + template.setMessageConverter(new CustomMessageConverter()); template.setConfirmCallback(new RabbitTemplate.ConfirmCallback() { @Override public void confirm(CorrelationData correlationData, boolean b, String s) { diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/aspect/AsyncAnnotationAspect.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/aspect/AsyncAnnotationAspect.java new file mode 100644 index 000000000..18e888ab9 --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/aspect/AsyncAnnotationAspect.java @@ -0,0 +1,50 @@ +package com.logpm.factory.aspect; + +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.reflect.MethodSignature; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; + +import java.lang.reflect.Method; + +@Aspect +@Component +public class AsyncAnnotationAspect { + + /** + * 该方法为一个切面,用于对标记了@RabbitListener注解的方法进行增强,主要增加了日志记录和数据源上下文处理的功能。 + * + * @param joinPoint 切面的连接点,表示当前被拦截的方法。 + * @return 返回被拦截方法的执行结果。 + * @throws Throwable 如果执行过程中发生异常,则抛出。 + */ + @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitListener)") + public Object rabbitMethods(ProceedingJoinPoint joinPoint) throws Throwable { + // 在方法执行前,获取当前租户ID并设置到数据源上下文中 + String tenantId = AuthUtil.getTenantId(); + DynamicDataSourceContextHolder.push(tenantId); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + return result; + } + + @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitHandler)") + public Object rabbitHandlerMethods(ProceedingJoinPoint joinPoint) throws Throwable { + // 在方法执行前,获取当前租户ID并设置到数据源上下文中 + String tenantId = AuthUtil.getTenantId(); + DynamicDataSourceContextHolder.push(tenantId); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + return result; + } + +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java index 2d8f74865..413dc8406 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/controller/FactoryCommonController.java @@ -185,11 +185,7 @@ public class FactoryCommonController { map.put("flagType", "OrderStatusLog"); //将消息携带绑定键值 - rabbitTemplate.convertAndSend(RabbitConstant.UNLOAD_CAR_COM_INFO_EXCHANGE, RabbitConstant.UNLOAD_CAR_COM_INFO_ROUTING, map,message -> { - HttpServletRequest request = WebUtil.getRequest(); - message.getMessageProperties().setHeader("Blade-Auth",request.getHeader("Blade-Auth")); - return message; - }); + rabbitTemplate.convertAndSend(RabbitConstant.UNLOAD_CAR_COM_INFO_EXCHANGE, RabbitConstant.UNLOAD_CAR_COM_INFO_ROUTING, map); return R.success("调用成功"); } catch (CustomerException e) { diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/CustomMessageConverter.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/CustomMessageConverter.java new file mode 100644 index 000000000..f9fa6ac12 --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/CustomMessageConverter.java @@ -0,0 +1,67 @@ +package com.logpm.factory.config; + +import cn.hutool.json.JSONUtil; +import org.springblade.core.secure.BladeUser; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.utils.ThreadLocalUtil; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.core.MessageProperties; +import org.springframework.amqp.support.converter.MessageConversionException; +import org.springframework.amqp.support.converter.MessageConverter; +import org.springframework.http.HttpHeaders; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.util.Map; + +/** + * @author zhaoqiaobo + * @create 2024-05-08 + */ +@Component +public class CustomMessageConverter implements MessageConverter { + private String name; + + @Override + public Message toMessage(Object o, MessageProperties messageProperties) throws MessageConversionException { + HttpHeaders headers = (HttpHeaders) ThreadLocalUtil.get("bladeContext"); + if (headers != null && !headers.isEmpty()) { + headers.forEach((key, values) -> { + values.forEach((value) -> { + messageProperties.setHeader(key, new String[]{value}); + }); + }); + } + BladeUser user = AuthUtil.getUser(); + BladeUser bladeUser = new BladeUser(); + bladeUser.setTenantId(user.getTenantId()); + bladeUser.setUserId(user.getUserId()); + bladeUser.setAccount(user.getAccount()); + bladeUser.setRoleId(user.getRoleId()); + messageProperties.setHeader("bladeUser", JSONUtil.toJsonStr(bladeUser)); + return new Message(o.toString().getBytes(), messageProperties); + } + + @Override + public Object fromMessage(Message message) throws MessageConversionException { + MessageProperties messageProperties = message.getMessageProperties(); + Map headers = messageProperties.getHeaders(); + ThreadLocalUtil.put("bladeContext", headers); + Object bladeUser = headers.get("bladeUser"); + MockHttpServletRequest request = new MockHttpServletRequest(); + BladeUser bladeUser1 = JSONUtil.toBean(bladeUser.toString(), BladeUser.class); + request.setAttribute("_BLADE_USER_REQUEST_ATTR_", bladeUser1); + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); + return new String(message.getBody()); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java index 8913215e2..c3bc207c4 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java @@ -27,10 +27,11 @@ import static io.protostuff.MapSchema.MessageFactories.HashMap; public class RabbitMqConfiguration { @Bean - public RabbitTemplate createRabbitTemplate(ConnectionFactory connectionFactory) { + public RabbitTemplate createRabbitTemplate(ConnectionFactory connectionFactory,CustomMessageConverter converter) { RabbitTemplate template = new RabbitTemplate(); template.setConnectionFactory(connectionFactory); template.setMandatory(true); + template.setMessageConverter(converter); template.setConfirmCallback(new RabbitTemplate.ConfirmCallback() { @Override public void confirm(CorrelationData correlationData, boolean b, String s) { diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/interceptor/LocalServerLoginAccountsInterceptor.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/interceptor/LocalServerLoginAccountsInterceptor.java index d602b0a44..a0d700005 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/interceptor/LocalServerLoginAccountsInterceptor.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/interceptor/LocalServerLoginAccountsInterceptor.java @@ -54,7 +54,7 @@ public class LocalServerLoginAccountsInterceptor extends HandlerInterceptorAdapt Map params = new HashMap<>(); params.put("grant_type", "local_server"); params.put("scope", "all"); - params.put("username", "admin"); + params.put("username", "shujutongbu"); params.put("tenantId", "627683"); HttpResponse execute = urlRequest.form(params).execute(); String body = execute.body(); diff --git a/blade-service/logpm-supervise/src/main/java/com/logpm/supervise/aspect/AsyncAnnotationAspect.java b/blade-service/logpm-supervise/src/main/java/com/logpm/supervise/aspect/AsyncAnnotationAspect.java index a7f415596..d85373d55 100644 --- a/blade-service/logpm-supervise/src/main/java/com/logpm/supervise/aspect/AsyncAnnotationAspect.java +++ b/blade-service/logpm-supervise/src/main/java/com/logpm/supervise/aspect/AsyncAnnotationAspect.java @@ -47,4 +47,35 @@ public class AsyncAnnotationAspect { } + /** + * 该方法为一个切面,用于对标记了@RabbitListener注解的方法进行增强,主要增加了日志记录和数据源上下文处理的功能。 + * + * @param joinPoint 切面的连接点,表示当前被拦截的方法。 + * @return 返回被拦截方法的执行结果。 + * @throws Throwable 如果执行过程中发生异常,则抛出。 + */ + @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitListener)") + public Object rabbitMethods(ProceedingJoinPoint joinPoint) throws Throwable { + // 在方法执行前,获取当前租户ID并设置到数据源上下文中 + String tenantId = AuthUtil.getTenantId(); + DynamicDataSourceContextHolder.push(tenantId); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + return result; + } + + @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitHandler)") + public Object rabbitHandlerMethods(ProceedingJoinPoint joinPoint) throws Throwable { + // 在方法执行前,获取当前租户ID并设置到数据源上下文中 + String tenantId = AuthUtil.getTenantId(); + DynamicDataSourceContextHolder.push(tenantId); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + return result; + } + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/aspect/AsyncAnnotationAspect.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/aspect/AsyncAnnotationAspect.java index d920a9373..e06a9efc8 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/aspect/AsyncAnnotationAspect.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/aspect/AsyncAnnotationAspect.java @@ -47,4 +47,35 @@ public class AsyncAnnotationAspect { } + /** + * 该方法为一个切面,用于对标记了@RabbitListener注解的方法进行增强,主要增加了日志记录和数据源上下文处理的功能。 + * + * @param joinPoint 切面的连接点,表示当前被拦截的方法。 + * @return 返回被拦截方法的执行结果。 + * @throws Throwable 如果执行过程中发生异常,则抛出。 + */ + @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitListener)") + public Object rabbitMethods(ProceedingJoinPoint joinPoint) throws Throwable { + // 在方法执行前,获取当前租户ID并设置到数据源上下文中 + String tenantId = AuthUtil.getTenantId(); + DynamicDataSourceContextHolder.push(tenantId); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + return result; + } + + @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitHandler)") + public Object rabbitHandlerMethods(ProceedingJoinPoint joinPoint) throws Throwable { + // 在方法执行前,获取当前租户ID并设置到数据源上下文中 + String tenantId = AuthUtil.getTenantId(); + DynamicDataSourceContextHolder.push(tenantId); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + return result; + } + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/config/CustomMessageConverter.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/config/CustomMessageConverter.java new file mode 100644 index 000000000..60166a221 --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/config/CustomMessageConverter.java @@ -0,0 +1,67 @@ +package com.logpm.trunkline.config; + +import cn.hutool.json.JSONUtil; +import org.springblade.core.secure.BladeUser; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.utils.ThreadLocalUtil; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.core.MessageProperties; +import org.springframework.amqp.support.converter.MessageConversionException; +import org.springframework.amqp.support.converter.MessageConverter; +import org.springframework.http.HttpHeaders; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.util.Map; + +/** + * @author zhaoqiaobo + * @create 2024-05-08 + */ +@Component +public class CustomMessageConverter implements MessageConverter { + private String name; + + @Override + public Message toMessage(Object o, MessageProperties messageProperties) throws MessageConversionException { + HttpHeaders headers = (HttpHeaders) ThreadLocalUtil.get("bladeContext"); + if (headers != null && !headers.isEmpty()) { + headers.forEach((key, values) -> { + values.forEach((value) -> { + messageProperties.setHeader(key, new String[]{value}); + }); + }); + } + BladeUser user = AuthUtil.getUser(); + BladeUser bladeUser = new BladeUser(); + bladeUser.setTenantId(user.getTenantId()); + bladeUser.setUserId(user.getUserId()); + bladeUser.setAccount(user.getAccount()); + bladeUser.setRoleId(user.getRoleId()); + messageProperties.setHeader("bladeUser", JSONUtil.toJsonStr(bladeUser)); + return new Message(o.toString().getBytes(), messageProperties); + } + + @Override + public Object fromMessage(Message message) throws MessageConversionException { + MessageProperties messageProperties = message.getMessageProperties(); + Map headers = messageProperties.getHeaders(); + ThreadLocalUtil.put("bladeContext", headers); + Object bladeUser = headers.get("bladeUser"); + MockHttpServletRequest request = new MockHttpServletRequest(); + BladeUser bladeUser1 = JSONUtil.toBean(bladeUser.toString(), BladeUser.class); + request.setAttribute("_BLADE_USER_REQUEST_ATTR_", bladeUser1); + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); + return new String(message.getBody()); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/config/RabbitMqConfiguration.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/config/RabbitMqConfiguration.java index b4f10143c..e80874941 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/config/RabbitMqConfiguration.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/config/RabbitMqConfiguration.java @@ -21,6 +21,7 @@ public class RabbitMqConfiguration { RabbitTemplate template = new RabbitTemplate(); template.setConnectionFactory(connectionFactory); template.setMandatory(true); + template.setMessageConverter(new CustomMessageConverter()); template.setConfirmCallback(new RabbitTemplate.ConfirmCallback() { @Override public void confirm(CorrelationData correlationData, boolean b, String s) { diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/aspect/AsyncAnnotationAspect.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/aspect/AsyncAnnotationAspect.java index 552ed3607..2b99cee7d 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/aspect/AsyncAnnotationAspect.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/aspect/AsyncAnnotationAspect.java @@ -47,4 +47,35 @@ public class AsyncAnnotationAspect { } + /** + * 该方法为一个切面,用于对标记了@RabbitListener注解的方法进行增强,主要增加了日志记录和数据源上下文处理的功能。 + * + * @param joinPoint 切面的连接点,表示当前被拦截的方法。 + * @return 返回被拦截方法的执行结果。 + * @throws Throwable 如果执行过程中发生异常,则抛出。 + */ + @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitListener)") + public Object rabbitMethods(ProceedingJoinPoint joinPoint) throws Throwable { + // 在方法执行前,获取当前租户ID并设置到数据源上下文中 + String tenantId = AuthUtil.getTenantId(); + DynamicDataSourceContextHolder.push(tenantId); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + return result; + } + + @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitHandler)") + public Object rabbitHandlerMethods(ProceedingJoinPoint joinPoint) throws Throwable { + // 在方法执行前,获取当前租户ID并设置到数据源上下文中 + String tenantId = AuthUtil.getTenantId(); + DynamicDataSourceContextHolder.push(tenantId); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + return result; + } + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/config/CustomMessageConverter.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/config/CustomMessageConverter.java new file mode 100644 index 000000000..294612690 --- /dev/null +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/config/CustomMessageConverter.java @@ -0,0 +1,67 @@ +package com.logpm.warehouse.config; + +import cn.hutool.json.JSONUtil; +import org.springblade.core.secure.BladeUser; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.utils.ThreadLocalUtil; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.core.MessageProperties; +import org.springframework.amqp.support.converter.MessageConversionException; +import org.springframework.amqp.support.converter.MessageConverter; +import org.springframework.http.HttpHeaders; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.util.Map; + +/** + * @author zhaoqiaobo + * @create 2024-05-08 + */ +@Component +public class CustomMessageConverter implements MessageConverter { + private String name; + + @Override + public Message toMessage(Object o, MessageProperties messageProperties) throws MessageConversionException { + HttpHeaders headers = (HttpHeaders) ThreadLocalUtil.get("bladeContext"); + if (headers != null && !headers.isEmpty()) { + headers.forEach((key, values) -> { + values.forEach((value) -> { + messageProperties.setHeader(key, new String[]{value}); + }); + }); + } + BladeUser user = AuthUtil.getUser(); + BladeUser bladeUser = new BladeUser(); + bladeUser.setTenantId(user.getTenantId()); + bladeUser.setUserId(user.getUserId()); + bladeUser.setAccount(user.getAccount()); + bladeUser.setRoleId(user.getRoleId()); + messageProperties.setHeader("bladeUser", JSONUtil.toJsonStr(bladeUser)); + return new Message(o.toString().getBytes(), messageProperties); + } + + @Override + public Object fromMessage(Message message) throws MessageConversionException { + MessageProperties messageProperties = message.getMessageProperties(); + Map headers = messageProperties.getHeaders(); + ThreadLocalUtil.put("bladeContext", headers); + Object bladeUser = headers.get("bladeUser"); + MockHttpServletRequest request = new MockHttpServletRequest(); + BladeUser bladeUser1 = JSONUtil.toBean(bladeUser.toString(), BladeUser.class); + request.setAttribute("_BLADE_USER_REQUEST_ATTR_", bladeUser1); + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); + return new String(message.getBody()); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/config/RabbitMqConfiguration.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/config/RabbitMqConfiguration.java index 4779c8bf5..b2bb6db12 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/config/RabbitMqConfiguration.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/config/RabbitMqConfiguration.java @@ -27,6 +27,7 @@ public class RabbitMqConfiguration { public RabbitTemplate createRabbitTemplate(ConnectionFactory connectionFactory){ RabbitTemplate template = new RabbitTemplate(); template.setConnectionFactory(connectionFactory); + template.setMessageConverter(new CustomMessageConverter()); template.setMandatory(true); template.setConfirmCallback(new RabbitTemplate.ConfirmCallback() { @Override From af239126cd0a1d4c7896ed84212b4dc6af5b7861 Mon Sep 17 00:00:00 2001 From: zhaoqiaobo Date: Wed, 8 May 2024 18:29:14 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feat(all):=20=E4=BF=AE=E6=94=B9mq=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=B6=88=E6=81=AF=E6=A0=B9=E6=8D=AE=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../olo/config/CustomMessageConverter.java | 113 +++++++++++++++--- 1 file changed, 99 insertions(+), 14 deletions(-) diff --git a/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/config/CustomMessageConverter.java b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/config/CustomMessageConverter.java index b63f5038f..ffa9e4a7e 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/config/CustomMessageConverter.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/config/CustomMessageConverter.java @@ -6,14 +6,25 @@ import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.utils.ThreadLocalUtil; import org.springframework.amqp.core.Message; import org.springframework.amqp.core.MessageProperties; +import org.springframework.amqp.support.converter.AllowedListDeserializingMessageConverter; import org.springframework.amqp.support.converter.MessageConversionException; -import org.springframework.amqp.support.converter.MessageConverter; +import org.springframework.amqp.utils.SerializationUtils; +import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.http.HttpHeaders; import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.remoting.rmi.CodebaseAwareObjectInputStream; import org.springframework.stereotype.Component; +import org.springframework.util.ClassUtils; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectStreamClass; +import java.io.Serializable; +import java.io.UnsupportedEncodingException; import java.util.Map; /** @@ -21,9 +32,74 @@ import java.util.Map; * @create 2024-05-08 */ @Component -public class CustomMessageConverter implements MessageConverter { +public class CustomMessageConverter extends AllowedListDeserializingMessageConverter implements BeanClassLoaderAware { + + private volatile String defaultCharset = "UTF-8"; + private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader(); + private String codebaseUrl; + + @Override + public Object fromMessage(Message message) throws MessageConversionException { + Object content = null; + MessageProperties properties = message.getMessageProperties(); + if (properties != null) { + String contentType = properties.getContentType(); + if (contentType != null && contentType.startsWith("text")) { + String encoding = properties.getContentEncoding(); + if (encoding == null) { + encoding = "UTF-8"; + } + + try { + content = new String(message.getBody(), encoding); + } catch (UnsupportedEncodingException var8) { + throw new MessageConversionException("failed to convert text-based Message content", var8); + } + } else if (contentType != null && contentType.equals("application/x-java-serialized-object")) { + try { + content = SerializationUtils.deserialize(this.createObjectInputStream(new ByteArrayInputStream(message.getBody()), this.codebaseUrl)); + } catch (IllegalArgumentException | IllegalStateException | IOException var7) { + throw new MessageConversionException("failed to convert serialized Message content", var7); + } + } + } + Map headers = properties.getHeaders(); + ThreadLocalUtil.put("bladeContext", headers); + Object bladeUser = headers.get("bladeUser"); + MockHttpServletRequest request = new MockHttpServletRequest(); + BladeUser bladeUser1 = JSONUtil.toBean(bladeUser.toString(), BladeUser.class); + request.setAttribute("_BLADE_USER_REQUEST_ATTR_", bladeUser1); + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); + if (content == null) { + content = message.getBody(); + } + return content; + } + @Override - public Message toMessage(Object o, MessageProperties messageProperties) throws MessageConversionException { + protected Message createMessage(Object object, MessageProperties messageProperties) throws MessageConversionException { + byte[] bytes = null; + if (object instanceof byte[]) { + bytes = (byte[]) object; + messageProperties.setContentType("application/octet-stream"); + } else if (object instanceof String) { + try { + bytes = ((String) object).getBytes(this.defaultCharset); + } catch (UnsupportedEncodingException var6) { + throw new MessageConversionException("failed to convert to Message content", var6); + } + + messageProperties.setContentType("text/plain"); + messageProperties.setContentEncoding(this.defaultCharset); + } else if (object instanceof Serializable) { + try { + bytes = SerializationUtils.serialize(object); + } catch (IllegalArgumentException var5) { + throw new MessageConversionException("failed to convert to serialized Message content", var5); + } + + messageProperties.setContentType("application/x-java-serialized-object"); + } HttpHeaders headers = (HttpHeaders) ThreadLocalUtil.get("bladeContext"); if (headers != null && !headers.isEmpty()) { headers.forEach((key, values) -> { @@ -39,19 +115,28 @@ public class CustomMessageConverter implements MessageConverter { bladeUser.setAccount(user.getAccount()); bladeUser.setRoleId(user.getRoleId()); messageProperties.setHeader("bladeUser", JSONUtil.toJsonStr(bladeUser)); - return new Message(o.toString().getBytes(), messageProperties); + + if (bytes != null) { + messageProperties.setContentLength((long) bytes.length); + return new Message(bytes, messageProperties); + } else { + throw new IllegalArgumentException(this.getClass().getSimpleName() + " only supports String, byte[] and Serializable payloads, received: " + object.getClass().getName()); + } } @Override - public Object fromMessage(Message message) throws MessageConversionException { - MessageProperties messageProperties = message.getMessageProperties(); - Map headers = messageProperties.getHeaders(); - ThreadLocalUtil.put("bladeContext", headers); - Object bladeUser = headers.get("bladeUser"); - MockHttpServletRequest request = new MockHttpServletRequest(); - BladeUser bladeUser1 = JSONUtil.toBean(bladeUser.toString(), BladeUser.class); - request.setAttribute("_BLADE_USER_REQUEST_ATTR_", bladeUser1); - RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); - return new String(message.getBody()); + public void setBeanClassLoader(ClassLoader classLoader) { + this.beanClassLoader = beanClassLoader; + } + + protected ObjectInputStream createObjectInputStream(InputStream is, String codebaseUrl) throws IOException { + return new CodebaseAwareObjectInputStream(is, this.beanClassLoader, codebaseUrl) { + @Override + protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException { + Class clazz = super.resolveClass(classDesc); + CustomMessageConverter.this.checkAllowedList(clazz); + return clazz; + } + }; } } From 97a481703cd7aaecf7f97972deb091c04c645684 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Wed, 8 May 2024 18:32:26 +0800 Subject: [PATCH 5/5] =?UTF-8?q?1.=E5=B9=B2=E7=BA=BFbug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/IDistributionParcelListClient.java | 9 + .../logpm/trunkline/dto/BillladingDTO.java | 2 + .../com/logpm/trunkline/dto/LoadCarsDTO.java | 12 + .../com/logpm/trunkline/dto/OpenOrderDTO.java | 6 + .../entity/TrunklineCarsLoadEntity.java | 9 + .../entity/TrunklineCarsLoadScanEntity.java | 4 + .../entity/WarehouseWaybillEntity.java | 15 + .../feign/IWarehouseWaybillClient.java | 12 + .../feign/BasicdataDriverArteryClient.java | 1 + .../mapper/BasicdataClientMapper.xml | 1 + .../feign/DistributionParcelListClient.java | 15 + .../mapper/DistributionParcelListMapper.java | 7 + .../mapper/DistributionParcelListMapper.xml | 32 ++ .../IDistributionParcelListService.java | 6 + .../DistributionParcelListServiceImpl.java | 15 + .../controller/BillladingController.java | 23 +- .../controller/OpenOrderController.java | 120 ++++++- .../mapper/TrunklineAdvanceDetailMapper.java | 1 + .../mapper/TrunklineAdvanceDetailMapper.xml | 14 +- .../mapper/TrunklineBillladingMapper.java | 3 + .../mapper/TrunklineBillladingMapper.xml | 11 + .../mapper/TrunklineCarsLoadMapper.xml | 3 + .../mapper/TrunklineCarsLoadScanMapper.java | 7 +- .../mapper/TrunklineCarsLoadScanMapper.xml | 71 ++++- .../mapper/TrunklineCarsOrderMapper.xml | 8 +- .../mapper/TrunklineWaybillOrderMapper.java | 2 + .../mapper/TrunklineWaybillOrderMapper.xml | 11 + .../service/ICarsLoadAsyncService.java | 3 + .../trunkline/service/IOpenOrderService.java | 5 + .../ITrunklineAdvanceDetailService.java | 1 + .../service/ITrunklineBillladingService.java | 3 + .../ITrunklineCarsLoadScanService.java | 7 +- .../ITrunklineWaybillOrderService.java | 2 + .../impl/CarsLoadAsyncServiceImpl.java | 31 +- .../service/impl/InComingServiceImpl.java | 16 +- .../service/impl/OpenOrderServiceImpl.java | 299 +++++++++++++++--- .../TrunklineAdvanceDetailServiceImpl.java | 5 + .../impl/TrunklineAdvanceServiceImpl.java | 11 +- .../impl/TrunklineBillladingServiceImpl.java | 84 ++++- .../TrunklineCarsLoadScanServiceImpl.java | 14 +- .../impl/TrunklineCarsLoadServiceImpl.java | 53 +++- .../TrunklineWaybillOrderServiceImpl.java | 5 + .../warehouse/dto/WarehouseWaybillDTO.java | 12 + .../feign/WarehouseWaybillClient.java | 31 ++ .../mapper/WarehouseWayBillDetailMapper.java | 3 + .../mapper/WarehouseWaybillDetailMapper.xml | 9 + .../mapper/WarehouseWaybillMapper.java | 2 + .../mapper/WarehouseWaybillMapper.xml | 94 +++++- .../IWarehouseWayBillDetailService.java | 1 + .../service/IWarehouseWaybillService.java | 2 + .../WarehouseWayBillDetailServiceImpl.java | 5 + .../impl/WarehouseWaybillServiceImpl.java | 36 ++- 52 files changed, 1045 insertions(+), 109 deletions(-) diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java index 8f7f99ffa..f679fa9f1 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java @@ -155,4 +155,13 @@ public interface IDistributionParcelListClient { @PostMapping(API_PREFIX+"/updateList") void updateList(@RequestBody List updateParcelList); + + @PostMapping(API_PREFIX+"/updateFreezeStatusByWaybillIds") + void updateFreezeStatusByWaybillIds(@RequestBody List waybillIds); + + @PostMapping(API_PREFIX+"/updateUnFreezeStatusByWaybillIds") + void updateUnFreezeStatusByWaybillIds(@RequestBody List waybillIds); + + @PostMapping(API_PREFIX+"/clearParceListWaybillByAdvanceIds") + void clearParceListWaybillByAdvanceIds(@RequestBody List advanceIds); } diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/BillladingDTO.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/BillladingDTO.java index a48af901c..1b16a83b2 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/BillladingDTO.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/BillladingDTO.java @@ -53,4 +53,6 @@ public class BillladingDTO extends TrunklineBillladingEntity { private String remark;//备注 private String destinationWarehouseName;//目的仓 + private Long billladingId; + } diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/LoadCarsDTO.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/LoadCarsDTO.java index a4832855f..d91e7c82d 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/LoadCarsDTO.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/LoadCarsDTO.java @@ -55,9 +55,11 @@ public class LoadCarsDTO implements Serializable { private String orderCode; private String trayCode; + private String trayName; private String trayType; private Integer isZero; private String scanCode; + private String scanStatus; private List packageList = new ArrayList<>(); private List zeroList = new ArrayList<>(); @@ -123,4 +125,14 @@ public class LoadCarsDTO implements Serializable { private Integer isTransfer = 0; + private String loadingUserName; + private String finalNodeName; + private String unloadNodeName; + private String unloadUserName; + + private Integer isData; + private Integer loadingAbnormal; + private Integer unloadAbnormal; + private Integer isSupple; + } diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/OpenOrderDTO.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/OpenOrderDTO.java index 5ad7ed68d..291de11cc 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/OpenOrderDTO.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/OpenOrderDTO.java @@ -149,4 +149,10 @@ public class OpenOrderDTO implements Serializable { private List warehouseIds; + + private List waybillIds; + + private Integer isEdit; + + } diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/TrunklineCarsLoadEntity.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/TrunklineCarsLoadEntity.java index 96f5d8b40..a3ac3b560 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/TrunklineCarsLoadEntity.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/TrunklineCarsLoadEntity.java @@ -202,4 +202,13 @@ public class TrunklineCarsLoadEntity extends TenantEntity { /** 直发商家个数 */ @ApiModelProperty(name = "直发商家个数",notes = "") private Integer customerNum; + + /** 司机类型 1-自有,2-加盟,3-外调,4-临调*/ + @ApiModelProperty(name = "直发商家个数",notes = "") + private String driverType; + + /** 外请人*/ + @ApiModelProperty(name = "外请人",notes = "") + private String outDriverPerson; + } diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/TrunklineCarsLoadScanEntity.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/TrunklineCarsLoadScanEntity.java index 908ed6403..7871388b3 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/TrunklineCarsLoadScanEntity.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/TrunklineCarsLoadScanEntity.java @@ -127,4 +127,8 @@ public class TrunklineCarsLoadScanEntity extends TenantEntity { @ApiModelProperty(name = "卸车人名称",notes = "") private String unloadUserName; + /** 卸车时间 */ + @ApiModelProperty(name = "卸车时间",notes = "") + private Date unloadTime; + } diff --git a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseWaybillEntity.java b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseWaybillEntity.java index 344aba1e8..e50c2211a 100644 --- a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseWaybillEntity.java +++ b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseWaybillEntity.java @@ -469,4 +469,19 @@ public class WarehouseWaybillEntity extends TenantEntity { @ApiModelProperty(value = "提货车型 ") private String pickupVehicleType; + @ApiModelProperty(value = "作废状态 0否 1是 ") + private Integer abolishStatus; + + @ApiModelProperty(value = "作废人名称 ") + private String abolishUserName; + + @ApiModelProperty(value = "作废时间 ") + private Date abolishTime; + + @ApiModelProperty(value = "冻结人名称 ") + private String freezeUserName; + + @ApiModelProperty(value = "冻结时间 ") + private Date freezeTime; + } diff --git a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/feign/IWarehouseWaybillClient.java b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/feign/IWarehouseWaybillClient.java index 00c198ab5..bf7f08f66 100644 --- a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/feign/IWarehouseWaybillClient.java +++ b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/feign/IWarehouseWaybillClient.java @@ -71,4 +71,16 @@ public interface IWarehouseWaybillClient { @GetMapping(API_PREFIX + "/findLastData") Long findLastData(@RequestParam String waybillNo); + + @PostMapping(API_PREFIX + "/findListByWaybillIds") + List findListByWaybillIds(@RequestBody List waybillIds); + + @PostMapping(API_PREFIX + "/updateList") + void updateList(@RequestBody List waybillEntities); + + @PostMapping(API_PREFIX + "/findFreezeOrAbolishByWaybillNos") + List findFreezeOrAbolishByWaybillNos(@RequestBody List waybillNos); + + @PostMapping(API_PREFIX + "/updateWaybillFreezeStatusByWaybillIds") + void updateWaybillFreezeStatusByWaybillIds(@RequestBody List waybillIds); } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataDriverArteryClient.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataDriverArteryClient.java index bc7d5621d..52c4e2936 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataDriverArteryClient.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataDriverArteryClient.java @@ -76,6 +76,7 @@ public class BasicdataDriverArteryClient implements IBasicdataDriverArteryClient jsonObject.put("driverId",driverArteryEntity.getId()); jsonObject.put("driverName",driverArteryEntity.getName()); jsonObject.put("driverPhone",driverArteryEntity.getPhone()); + jsonObject.put("driverType",driverArteryEntity.getType()); list.add(jsonObject); } return list; diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataClientMapper.xml b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataClientMapper.xml index c54fbce3e..66a072ba7 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataClientMapper.xml +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataClientMapper.xml @@ -88,6 +88,7 @@ lbc.blade_region_province_id bladeRegionProvinceId, lbc.blade_region_city_id bladeRegionCityId, lbc.blade_region_area_id bladeRegionAreaId, + lbc.default_payment_methods defaultPaymentMethods, lbsc.linkman linkman, lbsc.phone phone, lbc.detailedly detailedly diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java index 4bcaea615..bac72f0c1 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java @@ -361,4 +361,19 @@ public class DistributionParcelListClient implements IDistributionParcelListClie }); } + + @Override + public void updateFreezeStatusByWaybillIds(List waybillIds) { + distributionParcelListService.updateFreezeStatusByWaybillIds(waybillIds); + } + + @Override + public void updateUnFreezeStatusByWaybillIds(List waybillIds) { + distributionParcelListService.updateUnFreezeStatusByWaybillIds(waybillIds); + } + + @Override + public void clearParceListWaybillByAdvanceIds(List advanceIds) { + distributionParcelListService.clearParceListWaybillByAdvanceIds(advanceIds); + } } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java index f7eded8b2..4edc0db58 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java @@ -263,4 +263,11 @@ public interface DistributionParcelListMapper extends BaseMapper orderPackageCodes, @Param("warehouseId") Long warehouseId, @Param("packageStatus") String packageStatus); List findListByOrderPackageCode(@Param("orderPackageCodes") List orderPackageCodes, @Param("warehouseId") Long warehouseId); + + void updateFreezeStatusByWaybillIds(@Param("waybillIds") List waybillIds); + + void updateUnFreezeStatusByWaybillIds(@Param("waybillIds") List waybillIds); + + void clearParceListWaybillByAdvanceIds(@Param("advanceIds") List advanceIds); + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml index 2ffd15749..4f9c2eb53 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml @@ -1507,5 +1507,37 @@ and warehouse_id = #{warehouseId} + + update logpm_distribution_parcel_list + set order_package_freeze_status = '20' + where waybill_id in + + #{item} + + + + + update logpm_distribution_parcel_list + set order_package_freeze_status = '10' + where waybill_id in + + #{item} + + + + + update logpm_distribution_parcel_list + set waybill_id = null, + waybill_number = null, + send_warehouse_id = null, + send_warehouse_name = null, + accept_warehouse_id = null, + accept_warehouse_name = null, + is_transfer = 1 + where advance_id in + + #{item} + + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java index de27bd71b..5405bfe7d 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java @@ -223,4 +223,10 @@ public interface IDistributionParcelListService extends BaseService orderPackageCodes, Long warehouseId, String packageStatus); List findListByOrderPackageCode(List orderPackageCodes, Long warehouseId); + + void updateFreezeStatusByWaybillIds(List waybillIds); + + void updateUnFreezeStatusByWaybillIds(List waybillIds); + + void clearParceListWaybillByAdvanceIds(List advanceIds); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java index f7030cece..db9312070 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java @@ -1235,4 +1235,19 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl waybillIds) { + baseMapper.updateFreezeStatusByWaybillIds(waybillIds); + } + + @Override + public void updateUnFreezeStatusByWaybillIds(List waybillIds) { + baseMapper.updateUnFreezeStatusByWaybillIds(waybillIds); + } + + @Override + public void clearParceListWaybillByAdvanceIds(List advanceIds) { + baseMapper.clearParceListWaybillByAdvanceIds(advanceIds); + } + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/BillladingController.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/BillladingController.java index 2f990ec59..0be7cb163 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/BillladingController.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/BillladingController.java @@ -492,7 +492,7 @@ public class BillladingController { } @ResponseBody - @PostMapping("/findDriverListByName") + @PostMapping("/findDriverListByName") @ApiOperationSupport(order = 1) @ApiOperation(value = "通过名称查司机", notes = "传入waybillDTO") public R findDriverListByName(@RequestBody BillladingDTO billladingDTO) { @@ -551,6 +551,27 @@ public class BillladingController { } + @ResponseBody + @PostMapping("/findBillladingLogList") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "查询提货单日志", notes = "传入waybillDTO") + public R findBillladingLogList(@RequestBody BillladingDTO billladingDTO) { + String method = "############findBillladingLogList: "; + log.info(method + "请求参数{}", billladingDTO); + Long billladingId = billladingDTO.getBillladingId(); + + try{ + return trunklineBillladingService.findBillladingLogList(billladingId); + }catch (CustomerException e){ + log.error(e.message,e); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error("############sendOrders: 系统异常",e); + return R.fail(500,"############sendOrders: 系统异常"); + } + } + + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/OpenOrderController.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/OpenOrderController.java index 31adb51ef..e2d95ba27 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/OpenOrderController.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/OpenOrderController.java @@ -1,7 +1,6 @@ package com.logpm.trunkline.controller; import cn.hutool.core.collection.CollUtil; -import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.logpm.basicdata.entity.BasicdataWarehouseEntity; @@ -11,6 +10,7 @@ import com.logpm.trunkline.dto.OpenLabelDTO; import com.logpm.trunkline.dto.OpenOrderDTO; import com.logpm.trunkline.dto.WaybillDetailDTO; import com.logpm.trunkline.entity.TrunklineAdvanceEntity; +import com.logpm.trunkline.service.ICarsLoadAsyncService; import com.logpm.trunkline.service.IOpenOrderService; import com.logpm.trunkline.service.ITrunklineCarsLoadService; import com.logpm.trunkline.vo.TrunklineAdvanceDetailVO; @@ -40,6 +40,7 @@ public class OpenOrderController { private final IBasicdataWarehouseClient warehouseClient; private final IOpenOrderService openOrderService; private final ITrunklineCarsLoadService carsLoadService; + private final ICarsLoadAsyncService carsLoadAsyncService; @ResponseBody @PostMapping("/advancePageList") @@ -1089,9 +1090,7 @@ public class OpenOrderController { R> listR = openOrderService.openLabelHasPacakage(myCurrentWarehouse.getId(),myCurrentWarehouse.getName(),file); List data = listR.getData(); if(!CollUtil.isEmpty(data)){ - for (TrunklineAdvanceEntity datum : data) { - carsLoadService.sendRabbitMessageLoadScanData(JSONUtil.toJsonStr(datum)); - } + carsLoadAsyncService.sendRabbitMessageLoadScanData(data); } return listR; @@ -1160,9 +1159,7 @@ public class OpenOrderController { R> listR = openOrderService.importCustomizedOuPai(myCurrentWarehouse.getId(), myCurrentWarehouse.getName(), file); List data = listR.getData(); if(!CollUtil.isEmpty(data)){ - for (TrunklineAdvanceEntity datum : data) { - carsLoadService.sendRabbitMessageLoadScanData(JSONUtil.toJsonStr(datum)); - } + carsLoadAsyncService.sendRabbitMessageLoadScanData(data); } return listR; }catch (CustomerException e){ @@ -1194,9 +1191,7 @@ public class OpenOrderController { R> listR = openOrderService.importStandardOuPai(myCurrentWarehouse.getId(),myCurrentWarehouse.getName(),file); List data = listR.getData(); if(!CollUtil.isEmpty(data)){ - for (TrunklineAdvanceEntity datum : data) { - carsLoadService.sendRabbitMessageLoadScanData(JSONUtil.toJsonStr(datum)); - } + carsLoadAsyncService.sendRabbitMessageLoadScanData(data); } return listR; }catch (CustomerException e){ @@ -1217,7 +1212,7 @@ public class OpenOrderController { String method = "############findWaybillDetail: "; log.info(method + "请求参数{}", openOrderDTO); Long waybillId = openOrderDTO.getWaybillId(); - + Integer isEdit = openOrderDTO.getIsEdit(); try{ //当前登录人选择的仓库 @@ -1234,6 +1229,11 @@ public class OpenOrderController { return R.fail(403,"运单号id为空"); } + if (Objects.isNull(isEdit)){ + log.warn(method+"查看类型为空 isEdit={}",isEdit); + return R.fail(403,"查看类型为空"); + } + return openOrderService.findWaybillDetail(openOrderDTO); }catch (CustomerException e){ log.error(e.message,e); @@ -1285,7 +1285,7 @@ public class OpenOrderController { @PostMapping("/updateWaybill") @ApiOperationSupport(order = 1) @ApiOperation(value = "改单", notes = "传入openOrderDTO") - public R updateWaybill(@RequestBody OpenOrderDTO openOrderDTO) { + public R updateWaybill(@RequestBody OpenOrderDTO openOrderDTO) { String method = "############updateWaybill: "; log.info(method + "请求参数{}", openOrderDTO); Long waybillId = openOrderDTO.getWaybillId(); @@ -1613,4 +1613,100 @@ public class OpenOrderController { } } + + @ResponseBody + @PostMapping("/freezeWaybill") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "冻结运单", notes = "传入openOrderDTO") + public R freezeWaybill(@RequestBody OpenOrderDTO openOrderDTO) { + String method = "############freezeWaybill: "; + log.info(method + "请求参数{}", openOrderDTO); + List waybillIds = openOrderDTO.getWaybillIds(); + try{ + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + log.warn(method+"请选择仓库 myCurrentWarehouse={}",myCurrentWarehouse); + return R.fail(405,"请选择仓库"); + } + + + if(CollUtil.isEmpty(waybillIds)){ + log.warn(method+"运单ids为空 waybillIds={}",waybillIds); + return R.fail(405,"运单ids为空"); + } + + return openOrderService.freezeWaybill(waybillIds,myCurrentWarehouse.getId(),myCurrentWarehouse.getName()); + }catch (CustomerException e){ + log.error(e.message,e); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常",e); + return R.fail(500,"系统异常"); + } + } + + @ResponseBody + @PostMapping("/unFreezeWaybill") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "解冻运单", notes = "传入openOrderDTO") + public R unFreezeWaybill(@RequestBody OpenOrderDTO openOrderDTO) { + String method = "############unFreezeWaybill: "; + log.info(method + "请求参数{}", openOrderDTO); + List waybillIds = openOrderDTO.getWaybillIds(); + try{ + + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + log.warn(method+"请选择仓库 myCurrentWarehouse={}",myCurrentWarehouse); + return R.fail(405,"请选择仓库"); + } + + if(CollUtil.isEmpty(waybillIds)){ + log.warn(method+"运单ids为空 waybillIds={}",waybillIds); + return R.fail(405,"运单ids为空"); + } + + return openOrderService.unFreezeWaybill(waybillIds,myCurrentWarehouse.getId(),myCurrentWarehouse.getName()); + }catch (CustomerException e){ + log.error(e.message,e); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常",e); + return R.fail(500,"系统异常"); + } + } + + + @ResponseBody + @PostMapping("/abolishWaybill") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "作废运单", notes = "传入openOrderDTO") + public R abolishWaybill(@RequestBody OpenOrderDTO openOrderDTO) { + String method = "############abolishWaybill: "; + log.info(method + "请求参数{}", openOrderDTO); + List waybillIds = openOrderDTO.getWaybillIds(); + try{ + + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + log.warn(method+"请选择仓库 myCurrentWarehouse={}",myCurrentWarehouse); + return R.fail(405,"请选择仓库"); + } + + if(CollUtil.isEmpty(waybillIds)){ + log.warn(method+"运单ids为空 waybillIds={}",waybillIds); + return R.fail(405,"运单ids为空"); + } + + return openOrderService.abolishWaybill(waybillIds,myCurrentWarehouse.getId(),myCurrentWarehouse.getName()); + }catch (CustomerException e){ + log.error(e.message,e); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常",e); + return R.fail(500,"系统异常"); + } + } + + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java index fdcc4320f..f1157dc66 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java @@ -59,4 +59,5 @@ public interface TrunklineAdvanceDetailMapper extends BaseMapper findOrderDetails(IPage page, @Param("param") OrderDetailsDTO orderDetailsDTO); + void updateWaybillNoIsNullByAdvanceIds(@Param("advanceIds") List advanceIds); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml index 336624d44..92afe2a98 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml @@ -260,7 +260,7 @@ and LOCATE(#{param.orderCode}, pl.order_code) > 0 - and ad.waybill_no = #{param.waybill} + and ad.waybill_no = #{param.waybillNo} and ad.train_number = #{param.trainNumber} @@ -289,7 +289,7 @@ and LOCATE(#{param.orderCode}, ltad.order_code) > 0 - and ltad.waybill_no = #{param.waybill} + and ltad.waybill_no = #{param.waybillNo} and ltad.train_number = #{param.trainNumber} @@ -336,4 +336,14 @@ + + update logpm_trunkline_advance_detail + set waybill_no = null, + waybill_id = null + where advance_id in + + #{advanceId} + + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineBillladingMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineBillladingMapper.java index abea12e70..909e95f15 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineBillladingMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineBillladingMapper.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.trunkline.dto.BillladingDTO; import com.logpm.trunkline.entity.TrunklineBillladingEntity; +import com.logpm.trunkline.entity.TrunklineBillladingLogEntity; import com.logpm.trunkline.vo.TrunklineBillladingDetailListVO; import com.logpm.trunkline.vo.TrunklineBillladingDetailVO; import com.logpm.trunkline.vo.TrunklineBillladingVO; @@ -29,4 +30,6 @@ public interface TrunklineBillladingMapper extends BaseMapper findAdvanceDetailList(@Param("orderCode") String orderCode); Map billladingNum(@Param("warehouseId") Long warehouseId, @Param("startByDateStr") Date startByDateStr, @Param("endByDateStr") Date endByDateStr); + + List findBillladingLogList(@Param("billladingId") Long billladingId); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineBillladingMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineBillladingMapper.xml index 08dab4520..6b8d462fb 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineBillladingMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineBillladingMapper.xml @@ -177,4 +177,15 @@ + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml index 6c498d271..e66373e36 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml @@ -202,9 +202,12 @@ ltwo.order_code, sum(ltwo.total_number) total_number from logpm_trunkline_waybill_order ltwo + where ltwo.is_deleted = 0 group by ltwo.waybill_no, ltwo.order_code) m on m.order_code = t.order_code and m.waybill_no = t.waybill_number where IFNULL( t.stock_num, 0 )-IFNULL( l.planNum,0) > 0 + and lww.abolish_status = 0 + and lww.freeze_status = 0 and lww.create_time >= #{param.openTimeStart} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java index 4eee1a277..a432b9d9f 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java @@ -12,6 +12,7 @@ import com.logpm.warehouse.entity.WarehouseWaybillEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.Date; import java.util.List; import java.util.Map; @@ -90,7 +91,7 @@ public interface TrunklineCarsLoadScanMapper extends BaseMapper findUnloadGoods(@Param("loadId") Long loadId, @Param("warehouseId") Long warehouseId, @Param("orderCode") String orderCode, @Param("waybillNo") String waybillNo); - void updateScanStatus(@Param("loadScanIds") List loadScanIds, @Param("scanStatus") String scanStatus); + void updateScanStatusAndTime(@Param("loadScanIds") List loadScanIds, @Param("scanStatus") String scanStatus, @Param("unloadTime") Date unloadTime); List findLoadScanWaybillList(@Param("loadId") Long loadId, @Param("nodeId") Long nodeId); @@ -116,7 +117,7 @@ public interface TrunklineCarsLoadScanMapper extends BaseMapper findUnloadByLoadIdAndWarehouseId(@Param("loadId") Long loadId, @Param("warehouseId") Long warehouseId); - void updateScanStatusByLoadId(@Param("loadId") Long loadId, @Param("scanStatus") String scanStatus); + void updateScanStatusByLoadId(@Param("loadId") Long loadId, @Param("scanStatus") String scanStatus, @Param("unloadTime") Date unloadTime); List findSignListOrderPackageCodes(@Param("loadId") Long loadId); @@ -147,4 +148,6 @@ public interface TrunklineCarsLoadScanMapper extends BaseMapper findIncomingOrdeCodesByCarsLoadScanIds(@Param("carsLoadScanIds") List carsLoadScanIds, @Param("warehouseId") Long warehouseId); List findListHasSignOrderIdByIds(@Param("carsLoadScanIds") List loadScanIds); + + List findCarsLoadScanIdsByWaybillIds(@Param("waybillIds") List waybillIds); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml index eaab6ba90..7dcf09cf8 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml @@ -83,6 +83,58 @@ select * from logpm_trunkline_cars_load_scan where load_id = #{param.loadId} + + and Locate(#{param.waybillNo},waybill_no) > 0 + + + and Locate(#{param.orderCode},order_code) > 0 + + + and Locate(#{param.scanCode},scan_code) > 0 + + + and Locate(#{param.loadingUserName},loading_user_name) > 0 + + + and Locate(#{param.warehouseName},warehouse_name) > 0 + + + and Locate(#{param.finalNodeName},final_node_name) > 0 + + + and Locate(#{param.finalNodeName},final_node_name) > 0 + + + and scan_status = #{param.scanStatus} + + + and Locate(#{param.trayName},tray_name) > 0 + + + and Locate(#{param.trayCode},tray_code) > 0 + + + and Locate(#{param.unloadNodeName},unload_node_name) > 0 + + + and Locate(#{param.unloadUserName},unload_user_name) > 0 + + + and `type` = #{param.type} + + + and is_data = #{param.isData} + + + and loading_abnormal = #{param.loadingAbnormal} + + + and unload_abnormal = #{param.unloadAbnormal} + + + and is_supple = #{param.isSupple} + + @@ -400,9 +452,10 @@ ltco.unload_num - + update logpm_trunkline_cars_load_scan - set scan_status = #{scanStatus} + set scan_status = #{scanStatus}, + sign_time = #{unloadTime} where 1=1 and id in @@ -513,7 +566,8 @@ update logpm_trunkline_cars_load_scan - set scan_status = #{scanStatus} + set scan_status = #{scanStatus}, + sign_time = #{unloadTime} where load_id = #{loadId} @@ -714,4 +768,15 @@ + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml index a36f50728..a8b25e335 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml @@ -135,9 +135,9 @@ select ltco.order_code orderCode, IFNULL(ltco.plan_num,0) planNum, t.loadingNum, - lww.total_freight orderFreight, lww.check_user_name checkUserName, IFNULL(ltco.unload_num,0) unloadNum, + IFNULL(lww.total_freight/lww.total_count*ltwo.total_number,0) orderFreight, IFNULL(lww.total_freight/lww.total_count*t.unloadNum,0) unloadIncome, m.costPiece, m.costZhang, @@ -159,7 +159,7 @@ group by ltcsr.waybill_no, ltcsr.order_code) m on m.waybillNo = t.waybillNo and m.orderCode = t.orderCode left join logpm_trunkline_cars_order ltco on ltco.waybill_no = t.waybillNo and ltco.order_code = t.orderCode - left join logpm_trunkline_waybill_order ltwo on ltwo.order_code = ltco.order_code and ltwo.waybill_no = ltco.waybill_no + left join logpm_trunkline_waybill_order ltwo on ltwo.order_code = ltco.order_code and ltwo.waybill_no = ltco.waybill_no and ltwo.is_deleted = 0 left join logpm_warehouse_waybill lww on lww.waybill_no = ltwo.waybill_no where ltco.load_id = #{loadId} and ltco.waybill_no = #{waybillNo} @@ -171,14 +171,14 @@ select ltco.order_code orderCode, ltco.plan_num planNum, ltco.real_num loadingNum, - lww.total_freight orderFreight, lww.check_user_name checkUserName, IFNULL(ltco.unload_num,0) unloadNum, + IFNULL(lww.total_freight/lww.total_count*ltwo.total_number,0) orderFreight, IFNULL(lww.total_freight/lww.total_count*ltco.unload_num,0) unloadIncome, IFNULL(lww.total_freight/lww.total_count*ltco.plan_num,0) orderLineCost, sum(ltwo.total_number) orderNum from logpm_trunkline_cars_order ltco - left join logpm_trunkline_waybill_order ltwo on ltwo.order_code = ltco.order_code and ltwo.waybill_no = ltco.waybill_no + left join logpm_trunkline_waybill_order ltwo on ltwo.order_code = ltco.order_code and ltwo.waybill_no = ltco.waybill_no and ltwo.is_deleted = 0 left join logpm_warehouse_waybill lww on lww.waybill_no = ltwo.waybill_no where ltco.load_id = #{loadId} and ltco.waybill_no = #{waybillNo} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillOrderMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillOrderMapper.java index 57696d095..6e21b432b 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillOrderMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillOrderMapper.java @@ -20,4 +20,6 @@ public interface TrunklineWaybillOrderMapper extends BaseMapper findAdvanceIdsByWaybillIds(@Param("waybillIds") List waybillIds); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillOrderMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillOrderMapper.xml index cf13328b0..39563f1e9 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillOrderMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillOrderMapper.xml @@ -36,4 +36,15 @@ and ltwo.order_code = #{orderCode} + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ICarsLoadAsyncService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ICarsLoadAsyncService.java index c8a5d3ee4..ee8ea20a8 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ICarsLoadAsyncService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ICarsLoadAsyncService.java @@ -1,5 +1,6 @@ package com.logpm.trunkline.service; +import com.logpm.trunkline.entity.TrunklineAdvanceEntity; import com.logpm.trunkline.entity.TrunklineCarsLoadEntity; import com.logpm.trunkline.entity.TrunklineCarsLoadLineEntity; import com.logpm.trunkline.entity.TrunklineCarsUnloadLogEntity; @@ -23,4 +24,6 @@ public interface ICarsLoadAsyncService { void dealwithAfterAbnormalPackage(String orderPackageCode, Long warehouseId, String warehouseName, String carsNo, Long userId, Long aLong, String nickName); void savaUnloadLogBatch(List unloadLogList); + + void sendRabbitMessageLoadScanData(List data); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderService.java index 2fef79294..71779d5fd 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderService.java @@ -82,6 +82,11 @@ public interface IOpenOrderService { R findUpdateWaybillList(OpenOrderDTO openOrderDTO); + R freezeWaybill(List waybillIds, Long warehouseId, String warehouseName); + + R unFreezeWaybill(List waybillIds, Long warehouseId, String warehouseName); + + R abolishWaybill(List waybillIds, Long warehouseId, String warehouseName); // R findWaybillInfo(String waybillNo); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java index 4aec741b7..191aad0ce 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java @@ -73,4 +73,5 @@ public interface ITrunklineAdvanceDetailService extends BaseService advanceIds); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineBillladingService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineBillladingService.java index cc771b06e..1b0b6eef1 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineBillladingService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineBillladingService.java @@ -44,4 +44,7 @@ public interface ITrunklineBillladingService extends BaseService findAdvanceDetailList(BillladingDTO billladingDTO); + + R findBillladingLogList(Long billladingId); + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java index 86757923d..dd53635e0 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java @@ -10,6 +10,7 @@ import com.logpm.trunkline.vo.*; import com.logpm.warehouse.entity.WarehouseWaybillEntity; import org.springblade.core.mp.base.BaseService; +import java.util.Date; import java.util.List; import java.util.Map; @@ -85,7 +86,7 @@ public interface ITrunklineCarsLoadScanService extends BaseService findUnloadGoods(Long loadId, Long warehouseId, String orderCode, String waybillNo); - void updateScanStatus(List loadScanIds, String scanStatus); + void updateScanStatusAndTime(List loadScanIds, String scanStatus,Date unloadTime); List findLoadScanWaybillList(Long loadId, Long nodeId); @@ -111,7 +112,7 @@ public interface ITrunklineCarsLoadScanService extends BaseService findUnloadByLoadIdAndWarehouseId(Long loadId, Long warehouseId); - void updateScanStatusByLoadId(Long loadId, String scanStatus); + void updateScanStatusByLoadId(Long loadId, String scanStatus, Date unloadTime); List findSignListOrderPackageCodes(Long loadId); @@ -142,4 +143,6 @@ public interface ITrunklineCarsLoadScanService extends BaseService findIncomingOrdeCodesByCarsLoadScanIds(List carsLoadScanIds, Long warehouseId); List findListHasSignOrderIdByIds(List loadScanIds); + + List findCarsLoadScanIdsByWaybillIds(List waybillIds); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineWaybillOrderService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineWaybillOrderService.java index c1e0a47fb..dd934d1ca 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineWaybillOrderService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineWaybillOrderService.java @@ -19,4 +19,6 @@ public interface ITrunklineWaybillOrderService extends BaseService findAdvanceIdsByWaybillIds(List waybillIds); + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java index aec2b6783..c4cd092a9 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java @@ -1,5 +1,7 @@ package com.logpm.trunkline.service.impl; +import cn.hutool.core.util.IdUtil; +import cn.hutool.json.JSONUtil; import com.logpm.aftersales.entity.AftersalesAbnormalRecordEntity; import com.logpm.aftersales.feign.IAftersalesAbnormalRecordClient; import com.logpm.aftersales.feign.IAftersalesWorkOrderClient; @@ -14,11 +16,14 @@ import com.logpm.warehouse.entity.WarehouseWaybillEntity; import com.logpm.warehouse.feign.IWarehouseWaybillClient; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.DictBizConstant; +import org.springblade.common.constant.RabbitConstant; import org.springblade.common.constant.TenantNum; import org.springblade.common.constant.carsload.CarsLoadLogTypeConstant; import org.springblade.common.exception.CustomerException; import org.springblade.common.utils.CommonUtil; import org.springblade.system.cache.DictBizCache; +import org.springframework.amqp.rabbit.connection.CorrelationData; +import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.scheduling.annotation.Async; @@ -26,9 +31,7 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.math.RoundingMode; -import java.util.Date; -import java.util.List; -import java.util.Objects; +import java.util.*; @Slf4j @Service @@ -55,6 +58,8 @@ public class CarsLoadAsyncServiceImpl implements ICarsLoadAsyncService { private IAftersalesWorkOrderClient aftersalesWorkOrderClient; @Autowired private ITrunklineCarsUnloadLogService trunklineCarsUnloadLogService; + @Autowired + private RabbitTemplate rabbitTemplate; @Async("asyncExecutor") @Override @@ -518,4 +523,24 @@ public class CarsLoadAsyncServiceImpl implements ICarsLoadAsyncService { trunklineCarsUnloadLogService.savaUnloadLogBatch(unloadLogList); } + @Async("asyncExecutor") + @Override + public void sendRabbitMessageLoadScanData(List data) { + String queue = RabbitConstant.INCOMING_TO_LOAD_QUEUE; + String exchange = RabbitConstant.INCOMING_TO_LOAD_EXCHANGE; + String routing = RabbitConstant.INCOMING_TO_LOAD_ROUTING; + + String msgId = IdUtil.simpleUUID(); + for (TrunklineAdvanceEntity datum : data) { + Map map = new HashMap<>(); + map.put("messageId", CommonUtil.getUUID()); + map.put("logId", msgId); + map.put("messageData", JSONUtil.toJsonStr(datum)); + map.put("createTime", new Date().getTime()); + map.put("flagType", "OrderStatusLog"); + //将消息携带绑定键值 + rabbitTemplate.convertAndSend(exchange, routing, map, new CorrelationData(msgId)); + } + } + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java index 92fc73c71..a8b3a103b 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java @@ -136,14 +136,16 @@ public class InComingServiceImpl implements IInComingService { Integer incomingType = inComingDTO.getIncomingType(); if(incomingType == 5){ String incomingCode = inComingDTO.getIncomingCode(); - incomingCode = incomingCode.replaceAll(",",","); - List orderCodes = new ArrayList<>(); - if(incomingCode.contains(",")){ - orderCodes.addAll(Arrays.asList(incomingCode.split(","))); - }else{ - orderCodes.add(incomingCode); + if(!StringUtil.isBlank(incomingCode)){ + incomingCode = incomingCode.replaceAll(",",","); + List orderCodes = new ArrayList<>(); + if(incomingCode.contains(",")){ + orderCodes.addAll(Arrays.asList(incomingCode.split(","))); + }else{ + orderCodes.add(incomingCode); + } + inComingDTO.setOrderCodes(orderCodes); } - inComingDTO.setOrderCodes(orderCodes); } List ls = advanceService.findIncomingOrderList(inComingDTO); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java index a5cb12287..a9525d33e 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java @@ -1,5 +1,6 @@ package com.logpm.trunkline.service.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSON; @@ -89,6 +90,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { private final ITrunklineWaybillReturnService trunklineWaybillReturnService; private final IBasicdataOpenIncomingClient basicdataOpenIncomingClient; private final ITrunklineCarsLoadService carsLoadService; + private final ITrunklineCarsLoadScanService trunklineCarsLoadScanService; private final IBasicdataStoreContactClient basicdataStoreContactClient; private final IAsyncService asyncService; @@ -383,6 +385,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { waybillEntity.setTotalWeight(openOrderDTO.getTotalWeghit()); waybillEntity.setDealerCode(openOrderDTO.getDealerCode()); waybillEntity.setDealerName(openOrderDTO.getDealerName()); + waybillEntity.setWaybillStatus("0"); //统计当前订单的在库数 List advanceIds = openOrderDTO.getAdvanceIds(); AdvanceDetailStockNumVO advanceDetailStockNumVO = advanceDetailService.findStockNumByAdvanceIds(advanceIds); @@ -420,13 +423,15 @@ public class OpenOrderServiceImpl implements IOpenOrderService { waybillEntity.setReceipt(openOrderDTO.getReceipt()); waybillEntity.setRemark(openOrderDTO.getRemark()); waybillEntity.setWaybillType(openOrderDTO.getWaybillType()); - waybillEntity.setAgent(AuthUtil.getUserName()); + waybillEntity.setAgent(AuthUtil.getNickName()); waybillEntity.setAgentId(AuthUtil.getUserId()); waybillEntity.setDocumentMakingTime(CommonUtil.StringToDate(openOrderDTO.getOpenOrderDate())); waybillEntity.setPickupCompleteOrNot(openOrderDTO.getPickupCompleteOrNot()); waybillEntity.setTrunklineCompleteOrNot(openOrderDTO.getTrunklineCompleteOrNot()); waybillEntity.setTrunklineVehicleType(openOrderDTO.getTrunklineVehicleType()); waybillEntity.setPickupVehicleType(openOrderDTO.getPickupVehicleType()); + waybillEntity.setAbolishStatus(0); + waybillEntity.setFreezeStatus(0); Long waybillId = warehouseWaybillClient.addEnntity(waybillEntity); if (!Objects.isNull(waybillId)) { @@ -567,6 +572,9 @@ public class OpenOrderServiceImpl implements IOpenOrderService { Boolean aBoolean = basicdataOpenIncomingClient.checkOpenIncoming(warehouseId, brandId); if (Boolean.TRUE.equals(aBoolean)) { openOrderAsyncService.incomingPackageBatch(advanceIds, AuthUtil.getUserId(), Func.firstLong(AuthUtil.getDeptId()), AuthUtil.getTenantId(), AuthUtil.getNickName(), IncomingTypeEnum.OPEN_TO_IN.getCode(),warehouseId,warehouseName); + waybillEntity.setStockCount(waybillEntity.getTotalCount()); + waybillEntity.setWaybillStatus("20"); + warehouseWaybillClient.updateEntity(waybillEntity); } //异步存入日志 @@ -700,8 +708,10 @@ public class OpenOrderServiceImpl implements IOpenOrderService { waybillEntity.setRemark(openOrderDTO.getRemark()); waybillEntity.setWaybillType(openOrderDTO.getWaybillType()); waybillEntity.setWaybillStatus("20"); - waybillEntity.setAgent(AuthUtil.getUserName()); + waybillEntity.setAgent(AuthUtil.getNickName()); waybillEntity.setAgentId(AuthUtil.getUserId()); + waybillEntity.setAbolishStatus(0); + waybillEntity.setFreezeStatus(0); Long waybillId = warehouseWaybillClient.addEnntity(waybillEntity); waybillEntity.setId(waybillId); @@ -948,7 +958,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { advanceEntity.setOrderCode(openLabelDTO.getOrderCode()); advanceEntity.setSiteName(openLabelDTO.getSiteName()); advanceEntity.setArea(openLabelDTO.getArea()); - advanceEntity.setOrderType("Label"); +// advanceEntity.setOrderType("Label"); advanceEntity.setBrand(openLabelDTO.getBrand()); Integer totalNumber = openLabelDTO.getTotalNumber(); advanceEntity.setTotalNum(totalNumber); @@ -1043,7 +1053,15 @@ public class OpenOrderServiceImpl implements IOpenOrderService { List advanceIds = new ArrayList<>(); - List detailEntities = advanceService.findListByExistsAndOrderCodeSet(orderCodeSet); + List detailEntities = new ArrayList<>(); + //把orderCodeSet分成每2000个元素为一组 + List> orderCodeSets = orderCodeSet.parallelStream().collect(Collectors.groupingBy(a -> a.hashCode() % 2000)).values().stream().map(a -> new HashSet<>(a)).collect(Collectors.toList()); + for (int i = 0; i < orderCodeSets.size(); i++) { + Set set1 = orderCodeSets.get(i); + List entities = advanceService.findListByExistsAndOrderCodeSet(orderCodeSet); + detailEntities.addAll(entities); + } + //把detailEntities转化成以orderCode和trainNumber为key的map detailEntities.forEach(advanceEntity -> { String orderCode = advanceEntity.getOrderCode(); @@ -1053,7 +1071,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { }); - Map> advanceMap = detailEntities.parallelStream().collect(Collectors.groupingBy(a -> a.getOrderCode() + "&" + a.getTrainNumber())); +// Map> advanceMap = detailEntities.parallelStream().collect(Collectors.groupingBy(a -> a.getOrderCode() + "&" + a.getTrainNumber())); listMap.keySet().forEach(str -> { String[] split = str.split("&"); @@ -1071,12 +1089,24 @@ public class OpenOrderServiceImpl implements IOpenOrderService { advanceEntity.setWarehouseName(warehouseName); advanceEntity.setOrderCode(orderCode); advanceEntity.setArea(pacakgeDetailExcelDTO.getArea()); - advanceEntity.setBrand(pacakgeDetailExcelDTO.getBrand()); + String brand = pacakgeDetailExcelDTO.getBrand(); + advanceEntity.setBrand(brand); advanceEntity.setTotalNum(excelDTOS.size()); String firsts = pacakgeDetailExcelDTO.getFirsts(); advanceEntity.setPackName(firsts); advanceEntity.setDealerCode(pacakgeDetailExcelDTO.getDealerCode()); - advanceEntity.setDealerName(pacakgeDetailExcelDTO.getDealerName()); + + String dealerName = pacakgeDetailExcelDTO.getDealerName(); + if(StringUtil.isBlank(dealerName)){ + if(StringUtil.equals(brand,"欧派")){ + //获取orderCode数字第一次出现的前面字符串截取 + int firstDigitIndex = findFirstDigitIndex(orderCode); + if(firstDigitIndex != -1){ + dealerName = orderCode.substring(0,firstDigitIndex); + } + } + } + advanceEntity.setDealerName(dealerName); advanceEntity.setConsigneePerson(pacakgeDetailExcelDTO.getConsigneePerson()); advanceEntity.setConsigneeMobile(pacakgeDetailExcelDTO.getConsigneeMobile()); advanceEntity.setConsigneeAddress(pacakgeDetailExcelDTO.getConsigneeAddress()); @@ -1231,6 +1261,16 @@ public class OpenOrderServiceImpl implements IOpenOrderService { return R.data(advanceEntityList); } + public int findFirstDigitIndex(String str) { + for (int i = 0; i < str.length(); i++) { + char c = str.charAt(i); + if (Character.isDigit(c)) { + return i; + } + } + return -1; // 如果没有找到数字,返回-1 + } + @Transactional(rollbackFor = Exception.class) @Override public R> importCustomizedOuPai(Long warehouseId, String warehouseName, MultipartFile file) throws IOException { @@ -1513,8 +1553,21 @@ public class OpenOrderServiceImpl implements IOpenOrderService { @Override public R findWaybillDetail(OpenOrderDTO openOrderDTO) { Long waybillId = openOrderDTO.getWaybillId(); + Integer isEdit = openOrderDTO.getIsEdit(); WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillId(waybillId); + if(Objects.isNull(waybillEntity)){ + log.warn("#############findWaybillDetail: 运单信息不存在 waybillId={}",waybillId); + return R.fail(405,"运单信息不存在"); + } + + if(isEdit.equals(1)){ + Integer abolishStatus = waybillEntity.getAbolishStatus(); + if(abolishStatus.equals(1)){ + log.warn("#############findWaybillDetail: 运单已作废 waybillId={}",waybillId); + return R.fail(405,"运单已作废"); + } + } WarehouseWaybillVO warehouseWaybillVO = new WarehouseWaybillVO(); BeanUtil.copy(waybillEntity, warehouseWaybillVO); @@ -1550,6 +1603,13 @@ public class OpenOrderServiceImpl implements IOpenOrderService { log.warn("#############updateWaybill: 运单信息不存在 waybillId={}", waybillId); return R.fail(405, "运单信息不存在"); } + Integer abolishStatus = waybillEntity.getAbolishStatus(); + if(abolishStatus.equals(1)){ + log.warn("#############updateWaybill: 运单已作废 waybillId={}", waybillId); + return R.fail(405, "运单已作废"); + } + + String updateMsg = verifyUpdateData(openOrderDTO, waybillEntity); warehouseWaybillClient.updateEntity(waybillEntity); @@ -1569,6 +1629,13 @@ public class OpenOrderServiceImpl implements IOpenOrderService { log.warn("#############updateWaybill: 运单信息不存在 waybillId={}", waybillId); return R.fail(405, "运单信息不存在"); } + Integer abolishStatus = waybillEntity.getAbolishStatus(); + if(abolishStatus.equals(1)){ + log.warn("#############updateWaybill: 运单已作废 waybillId={}", waybillId); + return R.fail(405, "运单已作废"); + } + + // String updateMsg = verifyData(openOrderDTO,waybillEntity); List list = verifyData(openOrderDTO,waybillEntity); @@ -1750,6 +1817,17 @@ public class OpenOrderServiceImpl implements IOpenOrderService { log.warn("##############checkWaybill: 运单信息不存在"); return R.fail(405, "运单信息不存在"); } + Integer abolishStatus = warehouseWaybillEntity.getAbolishStatus(); + if(abolishStatus.equals(1)){ + log.warn("#############checkWaybill: 运单已作废 waybillId={}",waybillId); + return R.fail(405,"运单已作废"); + } + + Long checkUserId = warehouseWaybillEntity.getCheckUserId(); + if(!Objects.isNull(checkUserId)){ + log.warn("##############checkWaybill: 运单已经审核 waybillId={}",waybillId); + return R.fail(405, "运单已经审核"); + } warehouseWaybillEntity.setCheckUserId(AuthUtil.getUserId()); warehouseWaybillEntity.setCheckUserName(AuthUtil.getNickName()); @@ -2252,6 +2330,135 @@ public class OpenOrderServiceImpl implements IOpenOrderService { return R.data(pageList); } + @Override + public R freezeWaybill(List waybillIds, Long warehouseId, String warehouseName) { + List waybillEntities = warehouseWaybillClient.findListByWaybillIds(waybillIds); + waybillEntities.forEach(waybillEntity -> { + String waybillNo = waybillEntity.getWaybillNo(); + Integer abolishStatus = waybillEntity.getAbolishStatus(); + Integer freezeStatus = waybillEntity.getFreezeStatus(); + if(abolishStatus.equals(1)){ + log.warn("##############freezeWaybill: {}运单已经作废",waybillNo); + throw new CustomerException(405,waybillNo+"运单已经作废,不能冻结"); + } + + if(freezeStatus.equals(1)){ + log.warn("##############freezeWaybill: {}运单已冻结",waybillNo); + throw new CustomerException(405,waybillNo+"运单已冻结,不能冻结"); + } + + waybillEntity.setFreezeStatus(1); + waybillEntity.setFreezeTime(new Date()); + waybillEntity.setFreezeUserName(AuthUtil.getNickName()); + }); + warehouseWaybillClient.updateList(waybillEntities); + + //修改所有该运单的包件状态为已冻结 + distributionParcelListClient.updateFreezeStatusByWaybillIds(waybillIds); + + + waybillEntities.forEach(waybillEntity -> { + String createOperationRemark = "冻结运单" + waybillEntity.getWaybillNo() + ",时间:" + CommonUtil.dateToString(new Date()); + openOrderAsyncService.saveLog(waybillEntity.getId(), waybillEntity.getWaybillNo(), "990", "冻结运单", createOperationRemark, AuthUtil.getNickName(), AuthUtil.getUserId(), warehouseId, warehouseName); + }); + + return R.success("修改成功"); + } + + @Override + public R unFreezeWaybill(List waybillIds, Long warehouseId, String warehouseName) { + List waybillEntities = warehouseWaybillClient.findListByWaybillIds(waybillIds); + waybillEntities.forEach(waybillEntity -> { + String waybillNo = waybillEntity.getWaybillNo(); + Integer abolishStatus = waybillEntity.getAbolishStatus(); + Integer freezeStatus = waybillEntity.getFreezeStatus(); + if(abolishStatus.equals(1)){ + log.warn("##############unFreezeWaybill: {}运单已经作废",waybillNo); + throw new CustomerException(405,waybillNo+"运单已经作废,不能解冻"); + } + if(freezeStatus.equals(0)){ + log.warn("##############unFreezeWaybill: {}运单未冻结",waybillNo); + throw new CustomerException(405,waybillNo+"运单未冻结,不能解冻"); + } + + waybillEntity.setFreezeStatus(0); + waybillEntity.setFreezeTime(null); + waybillEntity.setFreezeUserName(null); + }); + warehouseWaybillClient.updateWaybillFreezeStatusByWaybillIds(waybillIds); + + //修改所有该运单的包件状态为已冻结 + distributionParcelListClient.updateUnFreezeStatusByWaybillIds(waybillIds); + + waybillEntities.forEach(waybillEntity -> { + String createOperationRemark = "解冻运单" + waybillEntity.getWaybillNo() + ",时间:" + CommonUtil.dateToString(new Date()); + openOrderAsyncService.saveLog(waybillEntity.getId(), waybillEntity.getWaybillNo(), "991", "解冻运单", createOperationRemark, AuthUtil.getNickName(), AuthUtil.getUserId(), warehouseId, warehouseName); + }); + + return R.success("修改成功"); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public R abolishWaybill(List waybillIds, Long warehouseId, String warehouseName) { + List waybillList = warehouseWaybillClient.findListByWaybillIds(waybillIds); + List waybillEntities = warehouseWaybillClient.findListByWaybillIds(waybillIds); + waybillList.forEach(waybillEntity -> { + String waybillNo = waybillEntity.getWaybillNo(); + String waybillStatus = waybillEntity.getWaybillStatus(); + if(StringUtil.isBlank(waybillStatus)){ + log.warn("##############abolishWaybill: {}运单为旧数据不能作废",waybillNo); + throw new CustomerException(405,waybillNo+"运单为旧数据不能作废"); + } + Integer waybillStatusNum = Integer.parseInt(waybillStatus); + if(waybillStatusNum >= 30){ + log.warn("##############abolishWaybill: {}运单已经进入配载不能进行作废",waybillNo); + throw new CustomerException(405,waybillNo+"运单已经进入配载不能进行作废"); + } + Integer abolishStatus = waybillEntity.getAbolishStatus(); + if(abolishStatus.equals(1)){ + log.warn("##############abolishWaybill: {}运单已经作废",waybillNo); + throw new CustomerException(405,waybillNo+"运单已经作废,不能重复作废"); + } + waybillEntity.setAbolishStatus(1); + waybillEntity.setAbolishUserName(AuthUtil.getNickName()); + waybillEntity.setAbolishTime(new Date()); + }); + warehouseWaybillClient.updateList(waybillEntities); + + //把装了车的包件取消装车 + List carsLoadScanIds = trunklineCarsLoadScanService.findCarsLoadScanIdsByWaybillIds(waybillIds); + + if(!CollUtil.isEmpty(carsLoadScanIds)){ + //把carsLoadScanIds中的元素用,拼接起来成为一个字符串 + String carsLoadScanIdsStr = CollUtil.join(carsLoadScanIds, ","); + carsLoadService.removeCarsLoadScan(carsLoadScanIdsStr,warehouseId); + } + + List advanceIds = trunklineWaybillOrderService.findAdvanceIdsByWaybillIds(waybillIds); + + trunklineWaybillOrderService.remove(new QueryWrapper().in("waybill_id",waybillIds)); + + if(!advanceIds.isEmpty()){ + List advanceEntities = advanceService.findListByIds(advanceIds); + advanceEntities.forEach(advanceEntity -> { + advanceEntity.setWaybillStatus("0"); + advanceEntity.setWaybillNo(null); + }); + advanceService.updateBatchById(advanceEntities); + + advanceDetailService.updateWaybillNoIsNullByAdvanceIds(advanceIds); + + distributionParcelListClient.clearParceListWaybillByAdvanceIds(advanceIds); + } + + waybillEntities.forEach(waybillEntity -> { + String createOperationRemark = "作废运单" + waybillEntity.getWaybillNo() + ",时间:" + CommonUtil.dateToString(new Date()); + openOrderAsyncService.saveLog(waybillEntity.getId(), waybillEntity.getWaybillNo(), "1000", "作废运单", createOperationRemark, AuthUtil.getNickName(), AuthUtil.getUserId(), warehouseId, warehouseName); + }); + return R.success("作废成功"); + } + private List verifyData(OpenOrderDTO openOrderDTO, WarehouseWaybillEntity waybillEntity) { log.info("###################verifyData: 验证改单数据"); StringBuilder stringBuilder = new StringBuilder(); @@ -2361,7 +2568,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService { String newShipperName = openOrderDTO.getShipperName(); String shipperName = waybillEntity.getShipperName(); - shipperName = StringUtil.isBlank(shipperName)?"":shipperName; if(!ObjectUtil.equals(shipperName,newShipperName)){ // stringBuilder.append("发货人:").append(shipperName).append("-->").append(newShipperName).append(";"); EditOrderMsgVO editOrderMsgVO = new EditOrderMsgVO(); @@ -2373,7 +2579,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService { String newShipperMobile = openOrderDTO.getShipperMobile(); String shipperMobile = waybillEntity.getShipperMobile(); - shipperMobile = StringUtil.isBlank(shipperMobile)?"":shipperMobile; if(!ObjectUtil.equals(shipperMobile,newShipperMobile)){ // stringBuilder.append("发货人电话:").append(shipperMobile).append("-->").append(newShipperMobile).append(";"); EditOrderMsgVO editOrderMsgVO = new EditOrderMsgVO(); @@ -2385,11 +2590,10 @@ public class OpenOrderServiceImpl implements IOpenOrderService { String newShipperAddress = openOrderDTO.getShipperAddress(); String shipperAddress = waybillEntity.getShipperAddress(); - shipperAddress = StringUtil.isBlank(shipperAddress)?"":shipperAddress; if(!ObjectUtil.equals(shipperAddress,newShipperAddress)){ // stringBuilder.append("发货人地址:").append(shipperAddress).append("-->").append(newShipperAddress).append(";"); EditOrderMsgVO editOrderMsgVO = new EditOrderMsgVO(); - editOrderMsgVO.setItemName("发货人电话"); + editOrderMsgVO.setItemName("发货人地址"); editOrderMsgVO.setOldValue(shipperAddress); editOrderMsgVO.setNewValue(newShipperAddress); msgList.add(editOrderMsgVO); @@ -2410,7 +2614,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService { String newConsigneeName = openOrderDTO.getConsigneeName(); String consigneeName = waybillEntity.getConsigneeName(); - consigneeName = StringUtil.isBlank(consigneeName)?"":consigneeName; if(!ObjectUtil.equals(consigneeName,newConsigneeName)){ // stringBuilder.append("收货人:").append(consigneeName).append("-->").append(newConsigneeName).append(";"); EditOrderMsgVO editOrderMsgVO = new EditOrderMsgVO(); @@ -2422,7 +2625,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService { String newConsigneeMobile = openOrderDTO.getConsigneeMobile(); String consigneeMobile = waybillEntity.getConsigneeMobile(); - consigneeMobile = StringUtil.isBlank(consigneeMobile)?"":consigneeMobile; if(!ObjectUtil.equals(consigneeMobile,newConsigneeMobile)){ // stringBuilder.append("收货人电话:").append(consigneeMobile).append("-->").append(newConsigneeMobile).append(";"); EditOrderMsgVO editOrderMsgVO = new EditOrderMsgVO(); @@ -2434,13 +2636,12 @@ public class OpenOrderServiceImpl implements IOpenOrderService { String newConsigneeAddress = openOrderDTO.getConsigneeAddress(); String consigneeAddress = waybillEntity.getConsigneeAddress(); - consigneeAddress = StringUtil.isBlank(consigneeAddress)?"":consigneeAddress; - if(!ObjectUtil.equals(shipperAddress,newShipperAddress)){ -// stringBuilder.append("发货人地址:").append(consigneeAddress).append("-->").append(newConsigneeAddress).append(";"); + if(!ObjectUtil.equals(consigneeAddress,newConsigneeAddress)){ +// stringBuilder.append("收货人地址:").append(consigneeAddress).append("-->").append(newConsigneeAddress).append(";"); EditOrderMsgVO editOrderMsgVO = new EditOrderMsgVO(); - editOrderMsgVO.setItemName("发货人地址"); - editOrderMsgVO.setOldValue(shipperAddress); - editOrderMsgVO.setNewValue(newShipperAddress); + editOrderMsgVO.setItemName("收货人地址"); + editOrderMsgVO.setOldValue(consigneeAddress); + editOrderMsgVO.setNewValue(newConsigneeAddress); msgList.add(editOrderMsgVO); } @@ -2525,6 +2726,18 @@ public class OpenOrderServiceImpl implements IOpenOrderService { editOrderMsgVO.setNewValue(DictBizCache.getValue(DictBizConstant.OPEN_ORDER_CHARGE_TYPE,newChargeType+"")); msgList.add(editOrderMsgVO); } + + BigDecimal newSubtotalFreight = waybillDetailDTO.getSubtotalFreight(); + BigDecimal subtotalFreight = warehouseWayBillDetail.getSubtotalFreight(); + if(subtotalFreight.compareTo(newSubtotalFreight) != 0){ +// stringBuilder.append("明细更新:").append(warehouseWayBillDetail.getProductName()).append(" 单价修改").append(price).append("-->").append(newPrice).append(";"); + EditOrderMsgVO editOrderMsgVO = new EditOrderMsgVO(); + editOrderMsgVO.setItemName("明细更新 "+warehouseWayBillDetail.getProductName() +" 运费小计修改 "); + editOrderMsgVO.setOldValue(subtotalFreight.toPlainString()); + editOrderMsgVO.setNewValue(newSubtotalFreight.toPlainString()); + msgList.add(editOrderMsgVO); + } + } } @@ -2863,7 +3076,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { String newDestination = openOrderDTO.getDestination(); String destination = waybillEntity.getDestination(); - if (!destination.equals(newDestination)) { + if (!ObjectUtil.equals(destination,newDestination)) { stringBuilder.append("到站:").append(destination).append("-->").append(newDestination).append(";"); waybillEntity.setDestination(newDestination); waybillEntity.setDestinationCode(openOrderDTO.getDestinationCode()); @@ -2872,7 +3085,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { String newDestinationWarehouseName = openOrderDTO.getDestinationWarehouseName(); Long destinationWarehouseId = waybillEntity.getDestinationWarehouseId(); String departureWarehouseName = waybillEntity.getDepartureWarehouseName(); - if (!destinationWarehouseId.equals(newDestinationWarehouseId)) { + if (!ObjectUtil.equals(destinationWarehouseId,newDestinationWarehouseId)) { stringBuilder.append("目的仓:").append(departureWarehouseName).append("-->").append(newDestinationWarehouseName).append(";"); waybillEntity.setDestinationWarehouseId(newDestinationWarehouseId); waybillEntity.setDestinationWarehouseName(newDestinationWarehouseName); @@ -2881,31 +3094,28 @@ public class OpenOrderServiceImpl implements IOpenOrderService { String newShipper = openOrderDTO.getShipper(); Long shipperId = waybillEntity.getShipperId(); String shipper = waybillEntity.getShipper(); - if (!shipperId.equals(newShipperId)) { + if (!ObjectUtil.equals(shipperId,newShipperId)) { stringBuilder.append("发货单位:").append(shipper).append("-->").append(newShipper).append(";"); waybillEntity.setShipper(newShipper); waybillEntity.setShipperId(newShipperId); } String newShipperName = openOrderDTO.getShipperName(); String shipperName = waybillEntity.getShipperName(); - shipperName = StringUtil.isBlank(shipperName) ? "" : shipperName; - if (!shipperName.equals(newShipperName)) { + if (!ObjectUtil.equals(shipperName,newShipperName)) { stringBuilder.append("发货人:").append(shipperName).append("-->").append(newShipperName).append(";"); waybillEntity.setShipperName(newShipperName); } String newShipperMobile = openOrderDTO.getShipperMobile(); String shipperMobile = waybillEntity.getShipperMobile(); - shipperMobile = StringUtil.isBlank(shipperMobile) ? "" : shipperMobile; - if (!shipperMobile.equals(newShipperMobile)) { + if (!ObjectUtil.equals(shipperMobile,newShipperMobile)) { stringBuilder.append("发货人电话:").append(shipperMobile).append("-->").append(newShipperMobile).append(";"); waybillEntity.setShipperMobile(newShipperMobile); } String newShipperAddress = openOrderDTO.getShipperAddress(); String shipperAddress = waybillEntity.getShipperAddress(); - shipperAddress = StringUtil.isBlank(shipperAddress) ? "" : shipperAddress; - if (!shipperAddress.equals(newShipperAddress)) { + if (!ObjectUtil.equals(shipperAddress,newShipperAddress)) { stringBuilder.append("发货人地址:").append(shipperAddress).append("-->").append(newShipperAddress).append(";"); waybillEntity.setShipperAddress(newShipperAddress); } @@ -2914,7 +3124,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { String newConsignee = openOrderDTO.getConsignee(); Long consigneeId = waybillEntity.getConsigneeId(); String consignee = waybillEntity.getConsignee(); - if (!consigneeId.equals(newConsigneeId)) { + if (!ObjectUtil.equals(consigneeId,newConsigneeId)) { stringBuilder.append("收货单位:").append(consignee).append("-->").append(newConsignee).append(";"); waybillEntity.setConsignee(newConsignee); waybillEntity.setConsigneeId(newConsigneeId); @@ -2922,24 +3132,21 @@ public class OpenOrderServiceImpl implements IOpenOrderService { String newConsigneeName = openOrderDTO.getConsigneeName(); String consigneeName = waybillEntity.getConsigneeName(); - consigneeName = StringUtil.isBlank(consigneeName) ? "" : consigneeName; - if (!consigneeName.equals(newConsigneeName)) { + if (!ObjectUtil.equals(consigneeName,newConsigneeName)) { stringBuilder.append("收货人:").append(consigneeName).append("-->").append(newConsigneeName).append(";"); waybillEntity.setConsigneeName(newConsigneeName); } String newConsigneeMobile = openOrderDTO.getConsigneeMobile(); String consigneeMobile = waybillEntity.getConsigneeMobile(); - consigneeMobile = StringUtil.isBlank(consigneeMobile) ? "" : consigneeMobile; - if (!consigneeMobile.equals(newConsigneeMobile)) { + if (!ObjectUtil.equals(consigneeMobile,newConsigneeName)) { stringBuilder.append("收货人电话:").append(consigneeMobile).append("-->").append(newConsigneeMobile).append(";"); waybillEntity.setConsigneeMobile(newConsigneeMobile); } String newConsigneeAddress = openOrderDTO.getConsigneeAddress(); String consigneeAddress = waybillEntity.getConsigneeAddress(); - consigneeAddress = StringUtil.isBlank(consigneeAddress) ? "" : consigneeAddress; - if (!shipperAddress.equals(newShipperAddress)) { + if (!ObjectUtil.equals(consigneeAddress,newConsigneeAddress)) { stringBuilder.append("收货人地址:").append(consigneeAddress).append("-->").append(newConsigneeAddress).append(";"); waybillEntity.setConsigneeAddress(newConsigneeAddress); } @@ -2999,7 +3206,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { } Integer newNum = waybillDetailDTO.getNum(); Integer num = warehouseWayBillDetail.getNum(); - if (!num.equals(newNum)) { + if (!ObjectUtil.equals(num,newNum)) { stringBuilder.append("明细更新:").append(warehouseWayBillDetail.getProductName()).append(" 数量修改").append(num).append("-->").append(newNum).append(";"); warehouseWayBillDetail.setNum(newNum); } @@ -3013,17 +3220,25 @@ public class OpenOrderServiceImpl implements IOpenOrderService { Integer newChargeType = waybillDetailDTO.getChargeType(); Integer chargeType = warehouseWayBillDetail.getChargeType(); - if (!chargeType.equals(newChargeType)) { + if (!ObjectUtil.equals(chargeType,newChargeType)) { stringBuilder.append("明细更新:").append(warehouseWayBillDetail.getProductName()).append(" 计价方式修改").append(chargeType).append("-->").append(newChargeType).append(";"); warehouseWayBillDetail.setChargeType(newChargeType); } + + BigDecimal newSubtotalFreight = waybillDetailDTO.getSubtotalFreight(); + BigDecimal subtotalFreight = warehouseWayBillDetail.getSubtotalFreight(); + if(subtotalFreight.compareTo(newSubtotalFreight) != 0){ + stringBuilder.append("明细更新:").append(warehouseWayBillDetail.getProductName()).append(" 运费小计修改").append(subtotalFreight).append("-->").append(newSubtotalFreight).append(";"); + warehouseWayBillDetail.setSubtotalFreight(newSubtotalFreight); + } + warehouseWaybillDetailClient.updateEntityById(warehouseWayBillDetail); } } Integer newTotalCount = openOrderDTO.getTotalCount(); Integer totalCount = waybillEntity.getTotalCount(); - if (!totalCount.equals(newTotalCount)) { + if (!ObjectUtil.equals(totalCount,newTotalCount)) { stringBuilder.append("货物总数:").append(totalCount).append("-->").append(newTotalCount).append(";"); waybillEntity.setTotalCount(newTotalCount); } @@ -3100,14 +3315,14 @@ public class OpenOrderServiceImpl implements IOpenOrderService { String newPayType = openOrderDTO.getPayType(); String payType = waybillEntity.getPayType(); - if (!payType.equals(newPayType)) { + if (!ObjectUtil.equals(payType,newPayType)) { stringBuilder.append("支付方式:").append(payType).append("-->").append(newPayType).append(";"); waybillEntity.setPayType(newPayType); } String newPayWay = openOrderDTO.getPayWay(); String payWay = waybillEntity.getPayWay(); - if (!payWay.equals(newPayWay)) { + if (!ObjectUtil.equals(payType,newPayType)) { stringBuilder.append("付款方式:").append(payWay).append("-->").append(newPayWay).append(";"); waybillEntity.setPayWay(newPayWay); } @@ -3149,14 +3364,14 @@ public class OpenOrderServiceImpl implements IOpenOrderService { String newdeliveryWay = openOrderDTO.getDeliveryWay(); String deliveryWay = waybillEntity.getDeliveryWay(); - if (!deliveryWay.equals(newdeliveryWay)) { + if (!ObjectUtil.equals(deliveryWay,newdeliveryWay)) { stringBuilder.append("送货方式:").append(deliveryWay).append("-->").append(newdeliveryWay).append(";"); waybillEntity.setDeliveryWay(newdeliveryWay); } String newurgency = openOrderDTO.getUrgency(); String urgency = waybillEntity.getUrgency(); - if (!urgency.equals(newurgency)) { + if (!ObjectUtil.equals(urgency,newurgency)) { stringBuilder.append("紧急度:").append(urgency).append("-->").append(newurgency).append(";"); waybillEntity.setUrgency(newurgency); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java index c9e8c04f9..0e93914f5 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java @@ -266,4 +266,9 @@ public class TrunklineAdvanceDetailServiceImpl extends BaseServiceImpl pageList = baseMapper.findOrderDetails(page,orderDetailsDTO); return R.data(pageList); } + + @Override + public void updateWaybillNoIsNullByAdvanceIds(List advanceIds) { + baseMapper.updateWaybillNoIsNullByAdvanceIds(advanceIds); + } } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java index bbc4a5d7b..717a07dfd 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java @@ -555,18 +555,24 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl").append(newCarNumber).append(";"); + } + + String driverName = billladingEntity.getDriverName(); + String newDriverName = billladingDTO.getDriverName(); + if(!StringUtil.equals(driverName,newDriverName)){ + stringBuilder.append("司机:").append(driverName).append("-->").append(newDriverName).append(";"); + } + + String driverPhone = billladingEntity.getDriverPhone(); + String newDriverPhone = billladingDTO.getDriverPhone(); + if(!StringUtil.equals(driverPhone,newDriverPhone)){ + stringBuilder.append("司机电话:").append(driverPhone).append("-->").append(newDriverPhone).append(";"); + } + + String carrierName = billladingEntity.getCarrierName(); + String newCarrierName = billladingDTO.getCarrierName(); + if(!StringUtil.equals(carrierName,newCarrierName)){ + stringBuilder.append("承运商:").append(carrierName).append("-->").append(newCarrierName).append(";"); + } + + Integer planNum = billladingEntity.getPlanNum(); + Integer newPlanNum = billladingDTO.getPlanNum(); + if(!ObjectUtil.equals(planNum,newPlanNum)){ + stringBuilder.append("预计件数:").append(planNum).append("-->").append(newPlanNum).append(";"); + } + + BigDecimal planWeight = billladingEntity.getPlanWeight(); + BigDecimal newPlanWeight = billladingDTO.getPlanWeight(); + if(!ObjectUtil.equals(planWeight,newPlanWeight)){ + stringBuilder.append("预计重量:").append(planWeight).append("-->").append(newPlanWeight).append(";"); + } + + BigDecimal planVolume = billladingEntity.getPlanVolume(); + BigDecimal newPlanVolume = billladingDTO.getPlanVolume(); + if(!ObjectUtil.equals(planVolume,newPlanVolume)){ + stringBuilder.append("预计重量:").append(planWeight).append("-->").append(newPlanWeight).append(";"); + } + + String chargeType = billladingEntity.getChargeType(); + String newChargeType = billladingDTO.getChargeType(); + if(!StringUtil.equals(chargeType,newChargeType)){ + stringBuilder.append("计费模式:").append(DictBizCache.getValue(DictBizConstant.BILLLADING_CHARGE_TYPE,chargeType)).append("-->").append(DictBizCache.getValue(DictBizConstant.BILLLADING_CHARGE_TYPE,newChargeType)).append(";"); + } + + BigDecimal totalFee = billladingEntity.getTotalFee(); + BigDecimal newTotalFee = billladingDTO.getTotalFee(); + if(!ObjectUtil.equals(totalFee,newTotalFee)){ + stringBuilder.append("提货费用:").append(totalFee.toPlainString()).append("-->").append(newTotalFee.toPlainString()).append(";"); + } + + String remark = billladingEntity.getRemark(); + String newRemark = billladingDTO.getRemark(); + if(!StringUtil.equals(remark,newRemark)){ + stringBuilder.append("备注:").append(remark).append("-->").append(newRemark).append(";"); + } + + return stringBuilder.toString(); + } + @Override public void updateBillladingStatus(Long billladingId, Integer type,Long warehouseId,String warehouseName) { log.info("#############updateBillladingStatus: 更新提货单状态 type={}",type); @@ -558,4 +629,13 @@ public class TrunklineBillladingServiceImpl extends BaseServiceImpl list = baseMapper.findBillladingLogList(billladingId); + + return R.data(list); + } } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java index f8ee26bd0..118f20aa7 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java @@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; import org.springframework.stereotype.Service; +import java.util.Date; import java.util.List; import java.util.Map; @@ -202,8 +203,8 @@ public class TrunklineCarsLoadScanServiceImpl extends BaseServiceImpl loadScanIds, String scanStatus) { - baseMapper.updateScanStatus(loadScanIds,scanStatus); + public void updateScanStatusAndTime(List loadScanIds, String scanStatus,Date unloadTime) { + baseMapper.updateScanStatusAndTime(loadScanIds,scanStatus,unloadTime); } @Override @@ -267,8 +268,8 @@ public class TrunklineCarsLoadScanServiceImpl extends BaseServiceImpl findCarsLoadScanIdsByWaybillIds(List waybillIds) { + return baseMapper.findCarsLoadScanIdsByWaybillIds(waybillIds); + } + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java index 46bca6fb1..ed4bfe45a 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java @@ -1094,6 +1094,13 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl lineCarsOrderList = carsLoadLineDTO.getAddList(); + //把lineCarsOrderList中的所有运单号合并成一个集合 + List waybillNos = lineCarsOrderList.stream().map(TrunklineCarsOrderDTO::getWaybillNo).collect(Collectors.toList()); + List freezeOrAbolishWaybillList = warehouseWaybillClient.findFreezeOrAbolishByWaybillNos(waybillNos); + if(!CollUtil.isEmpty(freezeOrAbolishWaybillList)){ + log.warn("##########saveNew: 运单有变动,请重新做计划"); + throw new CustomerException(400, "运单有变动,请重新做计划"); + } for (TrunklineCarsOrderDTO carsOrderDTO : lineCarsOrderList) { Integer planNum = carsOrderDTO.getPlanNum(); String orderCode = carsOrderDTO.getOrderCode(); @@ -1286,6 +1293,8 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl addCarsLoadLineList = carsLoadDTO.getAddCarsLoadLineList(); List removeCarsLoadLineList = carsLoadDTO.getRemoveCarsLoadLineList(); @@ -1325,6 +1334,8 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl waybillNos = addList.stream().map(TrunklineCarsOrderDTO::getWaybillNo).collect(Collectors.toList()); + List freezeOrAbolishWaybillList = warehouseWaybillClient.findFreezeOrAbolishByWaybillNos(waybillNos); + if(!CollUtil.isEmpty(freezeOrAbolishWaybillList)){ + log.warn("##########saveNew: 运单有变动,请重新做计划"); + throw new CustomerException(400, "运单有变动,请重新做计划"); + } + for (TrunklineCarsOrderDTO trunklineCarsOrderDTO : addList) { TrunklineCarsOrderEntity trunklineCarsOrderEntity = new TrunklineCarsOrderEntity(); BeanUtil.copy(trunklineCarsOrderDTO, trunklineCarsOrderEntity); @@ -1985,7 +2004,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl orderPackageCodes = trunklineCarsLoadScanService.findSignListOrderPackageCodes(loadId); @@ -2284,7 +2303,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl orderPackageCodes = new ArrayList<>(); orderPackageCodes.add(orderPackageCode); - String content = "包件在 " + warehouseName + "装车,配载计划目的仓 " + carsLoadScanEntity.getFinalNodeName() + ",数据来源仓库 " + fromWarehouseName; + String content = "包件在 " + warehouseName + " "+(StringUtil.isBlank(trayName)?"扫码": "托盘("+trayName+")")+" 装车,配载计划目的仓 " + carsLoadScanEntity.getFinalNodeName() + ",数据来源仓库 " + fromWarehouseName; packageTrackLogAsyncService.addPackageTrackLog(AuthUtil.getTenantId(), AuthUtil.getUserId(), Func.firstLong(AuthUtil.getDeptId()), AuthUtil.getNickName(), orderPackageCodes, warehouseId, warehouseName, WorkNodeEnums.INITIAL_WAREHOUSE_LOADING.getCode(), content); trunklineCarsLoadingLogService.savaLoadingLog(warehouseId, warehouseName, loadId, loadCode, waybillId, waybillNo, orderCode, orderPackageCode, 1, @@ -3174,6 +3193,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl parcelList = parcelListMap.get(scanCode); @@ -4589,7 +4619,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl orderPackageCodes = trunklineCarsLoadScanService.findSignListOrderPackageCodesByIds(loadScanIds); @@ -5436,6 +5466,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl findAdvanceIdsByWaybillIds(List waybillIds) { + return baseMapper.findAdvanceIdsByWaybillIds(waybillIds); + } } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/WarehouseWaybillDTO.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/WarehouseWaybillDTO.java index 35da651d1..4878f926a 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/WarehouseWaybillDTO.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/WarehouseWaybillDTO.java @@ -20,6 +20,7 @@ import com.logpm.warehouse.entity.WarehouseWaybillEntity; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.Date; import java.util.List; /** @@ -44,5 +45,16 @@ public class WarehouseWaybillDTO extends WarehouseWaybillEntity { private List waybillNoList; + private String documentMakingTimeStartStr; + private String documentMakingTimeEndStr; + + private Date documentMakingTimeStartDate; + private Date documentMakingTimeEndDate; + + private String createTimeStartStr; + private String createTimeEndStr; + + private Date createTimeStartDate; + private Date createTimeEndDate; } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/feign/WarehouseWaybillClient.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/feign/WarehouseWaybillClient.java index 46cf3ec8f..57233e107 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/feign/WarehouseWaybillClient.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/feign/WarehouseWaybillClient.java @@ -1,5 +1,7 @@ package com.logpm.warehouse.feign; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.warehouse.entity.WarehouseWaybillEntity; import com.logpm.warehouse.service.IWarehouseWaybillService; @@ -73,4 +75,33 @@ public class WarehouseWaybillClient implements IWarehouseWaybillClient { public Long findLastData(String waybillNo) { return warehouseWaybillService.findLastData(waybillNo); } + + @Override + public List findListByWaybillIds(List waybillIds) { + //通过waybillIds查询List + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.in("id", waybillIds); + return warehouseWaybillService.list(queryWrapper); + } + + @Override + public void updateList(List waybillEntities) { + warehouseWaybillService.updateBatchById(waybillEntities); + } + + @Override + public List findFreezeOrAbolishByWaybillNos(List waybillNos) { + return warehouseWaybillService.findFreezeOrAbolishByWaybillNos(waybillNos); + } + + @Override + public void updateWaybillFreezeStatusByWaybillIds(List waybillIds) { + + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.set("freeze_user_name",null) + .set("freeze_time",null) + .set("freeze_status",0) + .in("id",waybillIds); + warehouseWaybillService.update(updateWrapper); + } } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWayBillDetailMapper.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWayBillDetailMapper.java index 941362836..460c6e44e 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWayBillDetailMapper.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWayBillDetailMapper.java @@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.logpm.warehouse.entity.WarehouseWayBillDetail; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + @Mapper public interface WarehouseWayBillDetailMapper extends BaseMapper { + List findByWaybillIds(List ids); } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillDetailMapper.xml b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillDetailMapper.xml index bd8eec929..d5192d72f 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillDetailMapper.xml +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillDetailMapper.xml @@ -2,5 +2,14 @@ + diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.java index cddf742b1..49bb389a9 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.java @@ -56,4 +56,6 @@ public interface WarehouseWaybillMapper extends BaseMapper findWaybillBillladingList(@Param("waybillNo") String waybillNo,@Param("warehouseId") Long warehouseId); + + List findFreezeOrAbolishByWaybillNos(@Param("waybillNos") List waybillNos); } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.xml b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.xml index 8f9fc585a..a55b29270 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.xml +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.xml @@ -155,9 +155,88 @@ and (departure_warehouse_id = #{param.warehouseId} or destination_warehouse_id = #{param.warehouseId}) - - and waybill_no = #{param.waybillNo} + + and Locate(#{param.waybillNo},waybill_no) > 0 + + and Locate(#{param.orderNo},order_no) > 0 + + + and Locate(#{param.destinationWarehouseName},destination_warehouse_name) > 0 + + + and Locate(#{param.departureWarehouseName},departure_warehouse_name) > 0 + + + and Locate(#{param.customerTrain},customer_train) > 0 + + + and Locate(#{param.brand},brand) > 0 + + + and Locate(#{param.shipper},shipper) > 0 + + + and Locate(#{param.shipperName},shipper_name) > 0 + + + and Locate(#{param.shipperMobile},shipper_mobile) > 0 + + + and Locate(#{param.consignee},consignee) > 0 + + + and Locate(#{param.consigneeName},consignee_name) > 0 + + + and Locate(#{param.consigneeMobile},consignee_mobile) > 0 + + + and Locate(#{param.destination},destination) > 0 + + + and Locate(#{param.departure},departure) > 0 + + + and pay_type = #{param.payType} + + + and pay_way = #{param.payWay} + + + and delivery_way = #{param.deliveryWay} + + + and urgency = #{param.urgency} + + + and transport_type = #{param.transportType} + + + and transport_type = #{param.transportType} + + + and waybill_status = #{param.waybillStatus} + + + and pickup_complete_or_not = #{param.pickupCompleteOrNot} + + + and trunkline_complete_or_not = #{param.trunklineCompleteOrNot} + + + and document_making_time >= #{param.documentMakingTimeStartDate} + + + and document_making_time <= #{param.documentMakingTimeEndDate} + + + and create_time >= #{param.createTimeStartDate} + + + and create_time <= #{param.createTimeEndDate} + + order by create_time desc @@ -183,4 +262,15 @@ limit 10 + + diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseWayBillDetailService.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseWayBillDetailService.java index 6372703e1..0dd9d8ad5 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseWayBillDetailService.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseWayBillDetailService.java @@ -23,4 +23,5 @@ public interface IWarehouseWayBillDetailService { void deleteByWaybillDetailId(Long waybillDetailId); + List findByWaybillIds(List ids); } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseWaybillService.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseWaybillService.java index 99cca29ec..f82d0aba9 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseWaybillService.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseWaybillService.java @@ -67,4 +67,6 @@ public interface IWarehouseWaybillService extends BaseService printBatch(String ids, String tempId) throws Exception; + + List findFreezeOrAbolishByWaybillNos(List waybillNos); } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWayBillDetailServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWayBillDetailServiceImpl.java index f6214bf14..c21fefacf 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWayBillDetailServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWayBillDetailServiceImpl.java @@ -69,4 +69,9 @@ public class WarehouseWayBillDetailServiceImpl implements IWarehouseWayBillDetai public void deleteByWaybillDetailId(Long waybillDetailId) { warehouseWayBillDetailMapper.deleteById(waybillDetailId); } + + @Override + public List findByWaybillIds(List ids) { + return warehouseWayBillDetailMapper.findByWaybillIds(ids); + } } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWaybillServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWaybillServiceImpl.java index 1a38acac4..8d5946f1d 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWaybillServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseWaybillServiceImpl.java @@ -45,6 +45,7 @@ import org.springblade.common.constant.OldSystemDataPushConfig; import org.springblade.common.constant.TenantNum; import org.springblade.common.constant.order.*; import org.springblade.common.exception.CustomerException; +import org.springblade.common.utils.CommonUtil; import org.springblade.common.utils.TemplateUtil; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; @@ -669,22 +670,28 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl pageList = baseMapper.pageList(page, waybillDTO); List records = pageList.getRecords(); - for (WarehouseWaybillVO record : records) { -// Integer waybillType = record.getWaybillType(); -// if(waybillType.equals(2)){ -// String orderCode = record.getWaybillNo(); -// DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); -// record.setHandleNum(stockArticleEntity.getHandQuantity()); -// } - Long waybillId = record.getId(); - List wayBillDetailList = warehouseWayBillDetailService.findByWaybillId(waybillId); - record.setDetailList(wayBillDetailList); + + if(!records.isEmpty()){ + //把records中的id取出作为一个集合 + List ids = records.stream().map(WarehouseWaybillVO::getId).collect(Collectors.toList()); + List wayBillDetailList = warehouseWayBillDetailService.findByWaybillIds(ids); + //把wayBillDetailList通过waibillId分组 + Map> map = wayBillDetailList.stream().collect(Collectors.groupingBy(WarehouseWayBillDetail::getWaybillId)); + + for (WarehouseWaybillVO record : records) { + Long waybillId = record.getId(); + record.setDetailList(map.get(waybillId)); + } + pageList.setRecords(records); } - pageList.setRecords(records); + return pageList; } @@ -786,6 +793,11 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl findFreezeOrAbolishByWaybillNos(List waybillNos) { + return baseMapper.findFreezeOrAbolishByWaybillNos(waybillNos); + } + private PrintPreviewVO buildPrintWallet(WarehouseWaybillEntity warehouseWaybillEntity, List warehouseWayBillDetails, BasicPrintTemplateEntity template) throws Exception { PrintPreviewVO printPreviewVO = new PrintPreviewVO(); String html = TemplateUtil.getTemplateByUrl(template.getTemplateUrl());