52 changed files with 2619 additions and 0 deletions
@ -0,0 +1,93 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>logpm-factory-data</artifactId><groupId>org.springblade</groupId><version>3.2.0.RELEASE</version></parent> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
|
||||||
|
<groupId>com.logpm</groupId> |
||||||
|
<artifactId>logpm-factory-data-mwh</artifactId> |
||||||
|
|
||||||
|
<properties> |
||||||
|
<maven.compiler.source>8</maven.compiler.source> |
||||||
|
<maven.compiler.target>8</maven.compiler.target> |
||||||
|
</properties> |
||||||
|
|
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springblade</groupId> |
||||||
|
<artifactId>blade-core-boot</artifactId> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springblade</groupId> |
||||||
|
<artifactId>blade-core-auto</artifactId> |
||||||
|
<scope>provided</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springframework.boot</groupId> |
||||||
|
<artifactId>spring-boot-starter-amqp</artifactId> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springblade</groupId> |
||||||
|
<artifactId>logpm-factory-data-api</artifactId> |
||||||
|
<version>3.2.0.RELEASE</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>com.xuxueli</groupId> |
||||||
|
<artifactId>xxl-job-core</artifactId> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springblade</groupId> |
||||||
|
<artifactId>blade-starter-swagger</artifactId> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springblade</groupId> |
||||||
|
<artifactId>logpm-trunkline-api</artifactId> |
||||||
|
<version>3.2.0.RELEASE</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springblade</groupId> |
||||||
|
<artifactId>logpm-factory-data-base-api</artifactId> |
||||||
|
<version>${bladex.project.version}</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springblade</groupId> |
||||||
|
<artifactId>blade-starter-oss</artifactId> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>io.minio</groupId> |
||||||
|
<artifactId>minio</artifactId> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springblade</groupId> |
||||||
|
<artifactId>blade-resource-api</artifactId> |
||||||
|
<version>3.2.0.RELEASE</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
</dependencies> |
||||||
|
|
||||||
|
<build> |
||||||
|
<plugins> |
||||||
|
<plugin> |
||||||
|
<groupId>com.spotify</groupId> |
||||||
|
<artifactId>dockerfile-maven-plugin</artifactId> |
||||||
|
<configuration> |
||||||
|
<username>${docker.username}</username> |
||||||
|
<password>${docker.password}</password> |
||||||
|
<repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository> |
||||||
|
<tag>${project.version}</tag> |
||||||
|
<useMavenSettingsForAuth>true</useMavenSettingsForAuth> |
||||||
|
<buildArgs> |
||||||
|
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> |
||||||
|
</buildArgs> |
||||||
|
<skip>false</skip> |
||||||
|
</configuration> |
||||||
|
</plugin> |
||||||
|
<plugin> |
||||||
|
<groupId>org.apache.maven.plugins</groupId> |
||||||
|
<artifactId>maven-antrun-plugin</artifactId> |
||||||
|
</plugin> |
||||||
|
</plugins> |
||||||
|
</build> |
||||||
|
|
||||||
|
</project> |
@ -0,0 +1,14 @@ |
|||||||
|
FROM bladex/alpine-java:openjdk8-openj9_cn_slim |
||||||
|
|
||||||
|
MAINTAINER h5u@163.com |
||||||
|
|
||||||
|
RUN mkdir -p /logpm/logpm-factory-data-mwh |
||||||
|
|
||||||
|
WORKDIR /logpm/logpm-factory-data-mwh |
||||||
|
|
||||||
|
EXPOSE 18960 |
||||||
|
|
||||||
|
ADD ./target/logpm-factory-data-mwh.jar ./app.jar |
||||||
|
|
||||||
|
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar","-Xms128m","-Xmx512m", "app.jar"] |
||||||
|
CMD ["--spring.profiles.active=test"] |
@ -0,0 +1,20 @@ |
|||||||
|
package com.logpm.factorydata; |
||||||
|
|
||||||
|
import org.springblade.common.constant.ModuleNameConstant; |
||||||
|
import org.springblade.core.cloud.client.BladeCloudApplication; |
||||||
|
import org.springblade.core.launch.BladeApplication; |
||||||
|
|
||||||
|
/** |
||||||
|
* 曼好家工厂数据启动类 |
||||||
|
* |
||||||
|
* @author zhaoqiaobo |
||||||
|
* @create 2024-4-26 |
||||||
|
*/ |
||||||
|
@BladeCloudApplication |
||||||
|
public class FactoryDataMwhApplication { |
||||||
|
|
||||||
|
public static void main(String[] args) { |
||||||
|
BladeApplication.run(ModuleNameConstant.LOGPM_FACTORY_DATA_MWH_NAME, FactoryDataMwhApplication.class, args); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,51 @@ |
|||||||
|
package com.logpm.factorydata.mwh.aspect; |
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
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.LogpmAsync; |
||||||
|
import org.springblade.core.secure.utils.AuthUtil; |
||||||
|
import org.springframework.core.annotation.Order; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import java.lang.reflect.Method; |
||||||
|
|
||||||
|
@Aspect |
||||||
|
@Component |
||||||
|
@Slf4j |
||||||
|
@Order(-1) |
||||||
|
public class AsyncAnnotationAspect { |
||||||
|
|
||||||
|
/** |
||||||
|
* 定义一个切点,匹配所有带有@LogpmAsync("asyncExecutor")注解的方法。 |
||||||
|
* 注意:实际上Spring Framework自带对@LogpmAsync("asyncExecutor")的处理,直接这样配置可能会导致预期之外的行为。 |
||||||
|
*/ |
||||||
|
@Around("@annotation(org.springblade.common.annotations.LogpmAsync)") |
||||||
|
public Object logAroundAsyncMethods(ProceedingJoinPoint joinPoint) throws Throwable { |
||||||
|
|
||||||
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
||||||
|
Method method = signature.getMethod(); |
||||||
|
|
||||||
|
LogpmAsync myAsync = method.getAnnotation(LogpmAsync.class); |
||||||
|
String annotationValue = myAsync.value(); |
||||||
|
log.info(">>>>>>>>>>>>>>>>>> annotationValue={}",annotationValue); |
||||||
|
|
||||||
|
log.info("@LogpmAsync注解的值为asyncExecutor,进行数据源切换 "); |
||||||
|
|
||||||
|
// 在方法执行前的操作
|
||||||
|
String tenantId = AuthUtil.getTenantId(); |
||||||
|
log.info(">> tenandId {} ",tenantId); |
||||||
|
DynamicDataSourceContextHolder.push(tenantId); |
||||||
|
|
||||||
|
// 执行原方法
|
||||||
|
Object result = joinPoint.proceed(); |
||||||
|
|
||||||
|
// 在方法执行后的操作
|
||||||
|
DynamicDataSourceContextHolder.poll(); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
package com.logpm.factorydata.mwh.aspect; |
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.aspectj.lang.ProceedingJoinPoint; |
||||||
|
import org.aspectj.lang.annotation.Around; |
||||||
|
import org.aspectj.lang.annotation.Aspect; |
||||||
|
import org.springblade.core.secure.utils.AuthUtil; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
@Aspect |
||||||
|
@Component |
||||||
|
@Slf4j |
||||||
|
public class RabbitAnnotationAspect { |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 该方法为一个切面,用于对标记了@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; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,161 @@ |
|||||||
|
package com.logpm.factorydata.mwh.config; |
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil; |
||||||
|
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.AllowedListDeserializingMessageConverter; |
||||||
|
import org.springframework.amqp.support.converter.MessageConversionException; |
||||||
|
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.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author zhaoqiaobo |
||||||
|
* @create 2024-05-08 |
||||||
|
*/ |
||||||
|
@Component |
||||||
|
public class CustomMessageConverter extends AllowedListDeserializingMessageConverter implements BeanClassLoaderAware { |
||||||
|
|
||||||
|
private volatile String defaultCharset = "UTF-8"; |
||||||
|
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader(); |
||||||
|
private String codebaseUrl; |
||||||
|
|
||||||
|
@Deprecated |
||||||
|
public void setCodebaseUrl(String codebaseUrl) { |
||||||
|
this.codebaseUrl = 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<String, Object> headers = properties.getHeaders(); |
||||||
|
HttpHeaders httpHeaders = new HttpHeaders(); |
||||||
|
for (Map.Entry<String, Object> entry : headers.entrySet()) { |
||||||
|
if (StrUtil.equals("Blade-Auth", entry.getKey()) |
||||||
|
|| StrUtil.equals("Authorization", entry.getKey()) |
||||||
|
|| StrUtil.equals("blade-auth", entry.getKey()) |
||||||
|
|| StrUtil.equals("authorization", entry.getKey())) { |
||||||
|
List value = (List) entry.getValue(); |
||||||
|
for (Object o : value) { |
||||||
|
httpHeaders.add(entry.getKey(), String.valueOf(o)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
ThreadLocalUtil.put("bladeContext", httpHeaders); |
||||||
|
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 |
||||||
|
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) -> { |
||||||
|
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)); |
||||||
|
|
||||||
|
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 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; |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,79 @@ |
|||||||
|
package com.logpm.factorydata.mwh.config; |
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.slf4j.MDC; |
||||||
|
import org.springblade.core.tool.utils.ThreadLocalUtil; |
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.core.task.TaskDecorator; |
||||||
|
import org.springframework.http.HttpHeaders; |
||||||
|
import org.springframework.scheduling.annotation.EnableAsync; |
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
||||||
|
import org.springframework.web.context.request.RequestAttributes; |
||||||
|
import org.springframework.web.context.request.RequestContextHolder; |
||||||
|
|
||||||
|
import javax.annotation.Nonnull; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.concurrent.Executor; |
||||||
|
import java.util.concurrent.ThreadPoolExecutor; |
||||||
|
|
||||||
|
@Configuration |
||||||
|
@Slf4j |
||||||
|
@EnableAsync |
||||||
|
public class ExecutorConfig { |
||||||
|
|
||||||
|
@Bean |
||||||
|
public Executor asyncExecutor() { |
||||||
|
log.info("start async executor"); |
||||||
|
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); |
||||||
|
// 配置核心线程数
|
||||||
|
threadPoolTaskExecutor.setCorePoolSize(10); |
||||||
|
// 配置最大线程数
|
||||||
|
threadPoolTaskExecutor.setMaxPoolSize(20); |
||||||
|
// 配置队列大小
|
||||||
|
threadPoolTaskExecutor.setQueueCapacity(50); |
||||||
|
// 配置线程池中线程的名称前缀
|
||||||
|
threadPoolTaskExecutor.setThreadNamePrefix("ASYNC_THREAD_"); |
||||||
|
// HelloWorldServiceImpl rejection-policy: 当pool已经达到max size时,如何处理新任务:
|
||||||
|
// CallerRunsPolicy: 不在新线程中执行任务,而是由调用者所在的线程来执行;
|
||||||
|
// AbortPolicy: 拒绝执行新任务,并抛出RejectedExecutionException异常;
|
||||||
|
// DiscardPolicy:丢弃当前将要加入队列的任务;
|
||||||
|
// DiscardOldestPolicy:丢弃任务队列中最旧的任务;
|
||||||
|
threadPoolTaskExecutor.setRejectedExecutionHandler( |
||||||
|
new ThreadPoolExecutor.CallerRunsPolicy() |
||||||
|
); |
||||||
|
threadPoolTaskExecutor.setTaskDecorator(new ContextCopyingDecorator()); |
||||||
|
threadPoolTaskExecutor.initialize(); |
||||||
|
return threadPoolTaskExecutor; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
static class ContextCopyingDecorator implements TaskDecorator { |
||||||
|
@Nonnull |
||||||
|
@Override |
||||||
|
public Runnable decorate(@Nonnull Runnable runnable) { |
||||||
|
RequestAttributes context = RequestContextHolder.currentRequestAttributes(); |
||||||
|
HttpHeaders headers = (HttpHeaders) ThreadLocalUtil.get("bladeContext"); |
||||||
|
Map<String, String> mdcMap = MDC.getCopyOfContextMap(); |
||||||
|
return () -> { |
||||||
|
try { |
||||||
|
ThreadLocalUtil.put("bladeContext", headers); |
||||||
|
if (mdcMap != null && !mdcMap.isEmpty()) { |
||||||
|
MDC.setContextMap(mdcMap); |
||||||
|
} |
||||||
|
RequestContextHolder.setRequestAttributes(context); |
||||||
|
|
||||||
|
runnable.run(); |
||||||
|
} finally { |
||||||
|
RequestContextHolder.resetRequestAttributes(); |
||||||
|
if (mdcMap != null) { |
||||||
|
mdcMap.clear(); |
||||||
|
} |
||||||
|
ThreadLocalUtil.clear(); |
||||||
|
MDC.clear(); |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,40 @@ |
|||||||
|
/* |
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are met: |
||||||
|
* |
||||||
|
* Redistributions of source code must retain the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* Redistributions in binary form must reproduce the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer in the |
||||||
|
* documentation and/or other materials provided with the distribution. |
||||||
|
* Neither the name of the dreamlu.net developer nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* Author: Chill 庄骞 (smallchill@163.com) |
||||||
|
*/ |
||||||
|
package com.logpm.factorydata.mwh.config; |
||||||
|
|
||||||
|
|
||||||
|
import com.logpm.factorydata.mwh.pros.FactoryDataProperties; |
||||||
|
import org.mybatis.spring.annotation.MapperScan; |
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients; |
||||||
|
import org.springframework.context.annotation.ComponentScan; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
|
||||||
|
/** |
||||||
|
* 配置feign、mybatis包名、properties |
||||||
|
* |
||||||
|
* @author chaos |
||||||
|
*/ |
||||||
|
@Configuration(proxyBeanMethods = false) |
||||||
|
@ComponentScan({"org.springblade", "com.logpm"}) |
||||||
|
@EnableFeignClients({"org.springblade", "com.logpm"}) |
||||||
|
@MapperScan({"org.springblade.**.mapper.**", "com.logpm.**.mapper.**"}) |
||||||
|
@EnableConfigurationProperties(FactoryDataProperties.class) |
||||||
|
public class FactoryDataConfiguration { |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
package com.logpm.factorydata.mwh.config; |
||||||
|
|
||||||
|
import com.logpm.factorydata.mwh.interceptor.FactoryAccountsInterceptor; |
||||||
|
import com.logpm.factorydata.mwh.interceptor.LocalServerLoginAccountsInterceptor; |
||||||
|
import com.logpm.factorydata.mwh.service.IFactoryTokenService; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import org.springblade.core.redis.cache.BladeRedis; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.core.env.Environment; |
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||||
|
|
||||||
|
@Configuration |
||||||
|
@AllArgsConstructor |
||||||
|
public class InterceptorAdapterConfig implements WebMvcConfigurer { |
||||||
|
|
||||||
|
private final IFactoryTokenService factoryTokenService; |
||||||
|
|
||||||
|
private final BladeRedis redis; |
||||||
|
|
||||||
|
private final Environment environment; |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void addInterceptors(InterceptorRegistry interceptorRegistry) { |
||||||
|
// interceptorRegistry.addInterceptor(new FactoryAccountsInterceptor(factoryTokenService))
|
||||||
|
// .addPathPatterns("/**").order(1);
|
||||||
|
interceptorRegistry.addInterceptor(new LocalServerLoginAccountsInterceptor(redis, environment)) |
||||||
|
.addPathPatterns("/**").order(2); |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
package com.logpm.factorydata.mwh.config; |
||||||
|
|
||||||
|
import org.springframework.amqp.rabbit.connection.ConnectionFactory; |
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
|
||||||
|
@Configuration |
||||||
|
public class RabbitConfig { |
||||||
|
|
||||||
|
@Bean |
||||||
|
public RabbitTemplate rabbitTemplate(ConnectionFactory factory, CustomMessageConverter converter) { |
||||||
|
RabbitTemplate template = new RabbitTemplate(factory); |
||||||
|
template.setMessageConverter(converter); |
||||||
|
return template; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,53 @@ |
|||||||
|
package com.logpm.factorydata.mwh.controller; |
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil; |
||||||
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||||
|
import com.logpm.factorydata.mwh.service.FactoryOrderLogService; |
||||||
|
import com.logpm.factorydata.mwh.vo.DeliveryNoteVO; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springframework.web.bind.annotation.PatchMapping; |
||||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* 工厂订单 前端控制器 |
||||||
|
* |
||||||
|
* @author zhaoqiaobo |
||||||
|
* @create 2024-03-21 19:27 |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
@RestController |
||||||
|
@RequestMapping("/factory/order/v1") |
||||||
|
@AllArgsConstructor |
||||||
|
@Api(value = "工厂订单", tags = "工厂订单") |
||||||
|
public class OrderController { |
||||||
|
|
||||||
|
private final FactoryOrderLogService service; |
||||||
|
|
||||||
|
@ResponseBody |
||||||
|
@PostMapping |
||||||
|
@ApiOperationSupport(order = 1) |
||||||
|
@ApiOperation(value = "工厂订单", notes = "工厂订单") |
||||||
|
public R order(@RequestBody DeliveryNoteVO vo) { |
||||||
|
log.info("接收工厂订单:{} ", JSONUtil.toJsonStr(vo)); |
||||||
|
String res = ""; |
||||||
|
try { |
||||||
|
res = service.order(vo); |
||||||
|
} catch (Exception e) { |
||||||
|
log.error("工厂订单异常:{} ", e); |
||||||
|
return R.success("服务器异常"); |
||||||
|
} |
||||||
|
return R.success(res); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,169 @@ |
|||||||
|
package com.logpm.factorydata.mwh.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import org.springblade.core.mp.base.BaseEntity; |
||||||
|
|
||||||
|
/** |
||||||
|
* 送货单 实体类 |
||||||
|
* |
||||||
|
* @author zhaoqiaobo |
||||||
|
* @create 2024-04-26 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@TableName("mwh_delivery_note") |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
public class DeliveryNoteEntity extends BaseEntity { |
||||||
|
|
||||||
|
@ApiModelProperty("日志id") |
||||||
|
private String logId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 客户编码 |
||||||
|
*/ |
||||||
|
private String storeCode; |
||||||
|
/** |
||||||
|
* 客户编码 |
||||||
|
*/ |
||||||
|
private String storeName; |
||||||
|
/** |
||||||
|
* 客户编码 |
||||||
|
*/ |
||||||
|
private String userId; |
||||||
|
/** |
||||||
|
* 客户名称 |
||||||
|
*/ |
||||||
|
private String userName; |
||||||
|
/** |
||||||
|
* 订单来源编码 |
||||||
|
*/ |
||||||
|
private String sources; |
||||||
|
/** |
||||||
|
* 订单来源名称 |
||||||
|
*/ |
||||||
|
private String sourceName; |
||||||
|
/** |
||||||
|
* 公司编码 |
||||||
|
*/ |
||||||
|
private String companyCode; |
||||||
|
/** |
||||||
|
* 公司名称 |
||||||
|
*/ |
||||||
|
private String companyName; |
||||||
|
/** |
||||||
|
* 服务平台编码 |
||||||
|
*/ |
||||||
|
private String siteCode; |
||||||
|
/** |
||||||
|
* 服务平台编码 |
||||||
|
*/ |
||||||
|
private String siteName; |
||||||
|
/** |
||||||
|
* 交割单号/服务号 |
||||||
|
*/ |
||||||
|
private String orderNo; |
||||||
|
/** |
||||||
|
* 订单号 |
||||||
|
*/ |
||||||
|
private String orderSelfNum; |
||||||
|
/** |
||||||
|
* 计划总数量 |
||||||
|
*/ |
||||||
|
private String totalQuantity; |
||||||
|
/** |
||||||
|
* 计划总数量 |
||||||
|
*/ |
||||||
|
private String totalWeight; |
||||||
|
/** |
||||||
|
* 计划总体积 |
||||||
|
*/ |
||||||
|
private String totalCapacity; |
||||||
|
/** |
||||||
|
* 订单类型编码 |
||||||
|
*/ |
||||||
|
private String orderType; |
||||||
|
/** |
||||||
|
* 订单类型名称 |
||||||
|
*/ |
||||||
|
private String orderTypeName; |
||||||
|
/** |
||||||
|
* 服务类型编码 |
||||||
|
*/ |
||||||
|
private String serviceType; |
||||||
|
/** |
||||||
|
* 服务类型名称 |
||||||
|
*/ |
||||||
|
private String serviceTypeName; |
||||||
|
/** |
||||||
|
* 详细地址 |
||||||
|
*/ |
||||||
|
private String senderAddress; |
||||||
|
/** |
||||||
|
* 发货人城市 |
||||||
|
*/ |
||||||
|
private String senderCity; |
||||||
|
/** |
||||||
|
* 发货人联系方式 |
||||||
|
*/ |
||||||
|
private String senderMobile; |
||||||
|
/** |
||||||
|
* 发货工厂名称 |
||||||
|
*/ |
||||||
|
private String senderName; |
||||||
|
/** |
||||||
|
* 发货人省份 |
||||||
|
*/ |
||||||
|
private String senderProvince; |
||||||
|
/** |
||||||
|
* 发货人区县 |
||||||
|
*/ |
||||||
|
private String senderArea; |
||||||
|
/** |
||||||
|
* 收货人详细地址 |
||||||
|
*/ |
||||||
|
private String receiverAddress; |
||||||
|
/** |
||||||
|
* 收货人区县 |
||||||
|
*/ |
||||||
|
private String receiverArea; |
||||||
|
/** |
||||||
|
* 收货人城市 |
||||||
|
*/ |
||||||
|
private String receiverCity; |
||||||
|
/** |
||||||
|
* 收货人联系方式 |
||||||
|
*/ |
||||||
|
private String receiverMobile; |
||||||
|
/** |
||||||
|
* 加盟商 |
||||||
|
*/ |
||||||
|
private String receiverName; |
||||||
|
/** |
||||||
|
* 收货人 |
||||||
|
*/ |
||||||
|
private String consigneeName; |
||||||
|
/** |
||||||
|
* 收货人省份 |
||||||
|
*/ |
||||||
|
private String receiverProvince; |
||||||
|
/** |
||||||
|
* 业务实体 |
||||||
|
*/ |
||||||
|
private String remark1; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "预留1", notes = "") |
||||||
|
private String reserve1; |
||||||
|
@ApiModelProperty(value = "预留2", notes = "") |
||||||
|
private String reserve2; |
||||||
|
@ApiModelProperty(value = "预留3", notes = "") |
||||||
|
private String reserve3; |
||||||
|
@ApiModelProperty(value = "预留4", notes = "") |
||||||
|
private String reserve4; |
||||||
|
@ApiModelProperty(value = "预留5", notes = "") |
||||||
|
private String reserve5; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,58 @@ |
|||||||
|
package com.logpm.factorydata.mwh.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import org.springblade.core.mp.base.BaseEntity; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("mwh_factory_log") |
||||||
|
@ApiModel(value = "接收工厂订单日志", description = "接收工厂订单日志") |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
public class FactoryOrderLogEntity extends BaseEntity { |
||||||
|
|
||||||
|
/** |
||||||
|
* 预留1 |
||||||
|
*/ |
||||||
|
@ApiModelProperty(name = "预留1", notes = "") |
||||||
|
private String reserve1; |
||||||
|
/** |
||||||
|
* 预留2 |
||||||
|
*/ |
||||||
|
@ApiModelProperty(name = "预留2", notes = "") |
||||||
|
private String reserve2; |
||||||
|
/** |
||||||
|
* 预留3 |
||||||
|
*/ |
||||||
|
@ApiModelProperty(name = "预留3", notes = "") |
||||||
|
private String reserve3; |
||||||
|
/** |
||||||
|
* 预留4 |
||||||
|
*/ |
||||||
|
@ApiModelProperty(name = "预留4", notes = "") |
||||||
|
private String reserve4; |
||||||
|
/** |
||||||
|
* 预留5 |
||||||
|
*/ |
||||||
|
@ApiModelProperty(name = "预留5", notes = "") |
||||||
|
private String reserve5; |
||||||
|
/** |
||||||
|
* 日志文件存放地址 |
||||||
|
*/ |
||||||
|
@ApiModelProperty(name = "日志文件存放地址", notes = "") |
||||||
|
private String logUrl; |
||||||
|
/** |
||||||
|
* 数据类型 1.入库数据 |
||||||
|
*/ |
||||||
|
@ApiModelProperty(name = "数据类型 1.入库数据", notes = "") |
||||||
|
private Integer type; |
||||||
|
/** |
||||||
|
* 解析状态 0 未解析 1 解析失败 2 已解析 |
||||||
|
*/ |
||||||
|
@ApiModelProperty(name = "解析状态 0 未解析 1 解析失败 2 已解析", notes = "") |
||||||
|
private Integer saxStatus; |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
package com.logpm.factorydata.mwh.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import org.springblade.core.mp.base.BaseEntity; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("factory_token") |
||||||
|
@ApiModel(value = "FactoryToken对象", description = "工厂账户token") |
||||||
|
public class FactoryToken extends BaseEntity { |
||||||
|
|
||||||
|
@ApiModelProperty("token") |
||||||
|
private String token; |
||||||
|
|
||||||
|
@ApiModelProperty("token摘要") |
||||||
|
private String tokenAbst; |
||||||
|
|
||||||
|
@JsonFormat( |
||||||
|
pattern = "yyyy-MM-dd HH:mm:ss" |
||||||
|
) |
||||||
|
@ApiModelProperty("过期时间") |
||||||
|
private Date expireTime; |
||||||
|
|
||||||
|
@ApiModelProperty("企业id") |
||||||
|
private String corpid; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,64 @@ |
|||||||
|
package com.logpm.factorydata.mwh.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import org.springblade.core.mp.base.BaseEntity; |
||||||
|
|
||||||
|
/** |
||||||
|
* 装箱包信息 |
||||||
|
* |
||||||
|
* @author zhaoqiaobo |
||||||
|
* @create 2024-04-26 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@TableName("mwh_package_info") |
||||||
|
@ApiModel(value = "包件信息", description = "包件信息") |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
public class PackageInfoEntity extends BaseEntity { |
||||||
|
|
||||||
|
@ApiModelProperty(value = "日志id") |
||||||
|
private String logId; |
||||||
|
@ApiModelProperty(value = "发货单id") |
||||||
|
private String deliveryNoteId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 批次/色号:订单编号 |
||||||
|
*/ |
||||||
|
private String color; |
||||||
|
/** |
||||||
|
* 商品状态:默认为Y -良品 |
||||||
|
*/ |
||||||
|
private String skuStatus; |
||||||
|
/** |
||||||
|
* 客户编码 |
||||||
|
*/ |
||||||
|
private String storeCode; |
||||||
|
/** |
||||||
|
* 客户简称 |
||||||
|
*/ |
||||||
|
private String storeName; |
||||||
|
/** |
||||||
|
* 包件编码 |
||||||
|
*/ |
||||||
|
private String code; |
||||||
|
/** |
||||||
|
* 包件名称 |
||||||
|
*/ |
||||||
|
private String name; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "预留1", notes = "") |
||||||
|
private String reserve1; |
||||||
|
@ApiModelProperty(value = "预留2", notes = "") |
||||||
|
private String reserve2; |
||||||
|
@ApiModelProperty(value = "预留3", notes = "") |
||||||
|
private String reserve3; |
||||||
|
@ApiModelProperty(value = "预留4", notes = "") |
||||||
|
private String reserve4; |
||||||
|
@ApiModelProperty(value = "预留5", notes = "") |
||||||
|
private String reserve5; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
package com.logpm.factorydata.mwh.enums; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
import org.springblade.common.model.IDict; |
||||||
|
|
||||||
|
/** |
||||||
|
* 工厂节点枚举 |
||||||
|
* |
||||||
|
* @author zhaoqiaobo |
||||||
|
* @create 2024-03-20 15:19 |
||||||
|
*/ |
||||||
|
@Getter |
||||||
|
public enum FactoryNodeEnums implements IDict<Integer> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 已交接 |
||||||
|
*/ |
||||||
|
INITIAL_WAREHOUSE_ENTRY(20, "Deliveried"), |
||||||
|
/** |
||||||
|
* 收货完成 |
||||||
|
*/ |
||||||
|
END_WAREHOUSE_UNLOADING(170, "Received"); |
||||||
|
|
||||||
|
FactoryNodeEnums(Integer code, String text) { |
||||||
|
init(code, text); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,62 @@ |
|||||||
|
package com.logpm.factorydata.mwh.enums; |
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil; |
||||||
|
import lombok.Getter; |
||||||
|
import org.springblade.common.constant.WorkNodeEnums; |
||||||
|
|
||||||
|
/** |
||||||
|
* 系统和工厂节点映射枚举 |
||||||
|
* |
||||||
|
* @author zhaoqiaobo |
||||||
|
* @create 2024-03-20 15:19 |
||||||
|
*/ |
||||||
|
@Getter |
||||||
|
public enum NodeMappingEnums { |
||||||
|
|
||||||
|
/** |
||||||
|
* 已交接 |
||||||
|
*/ |
||||||
|
INITIAL_WAREHOUSE_ENTRY(FactoryNodeEnums.INITIAL_WAREHOUSE_ENTRY, WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY, 1), |
||||||
|
/** |
||||||
|
* 收货完成 |
||||||
|
*/ |
||||||
|
END_WAREHOUSE_UNLOADING(FactoryNodeEnums.END_WAREHOUSE_UNLOADING, WorkNodeEnums.END_WAREHOUSE_UNLOADING, 1); |
||||||
|
|
||||||
|
/** |
||||||
|
* 系统作业节点 |
||||||
|
*/ |
||||||
|
private WorkNodeEnums workNodeEnums; |
||||||
|
/** |
||||||
|
* 工厂作业节点 |
||||||
|
*/ |
||||||
|
private FactoryNodeEnums factoryNodeEnums; |
||||||
|
/** |
||||||
|
* 状态码 |
||||||
|
* 存在我们系统同一个作业节点对应工厂多个节点的情况,通过状态码区分 |
||||||
|
*/ |
||||||
|
private Integer status; |
||||||
|
|
||||||
|
NodeMappingEnums(FactoryNodeEnums factoryNodeEnums, WorkNodeEnums workNodeEnums, Integer status) { |
||||||
|
this.workNodeEnums = workNodeEnums; |
||||||
|
this.factoryNodeEnums = factoryNodeEnums; |
||||||
|
this.status = status; |
||||||
|
} |
||||||
|
|
||||||
|
public static FactoryNodeEnums getFactoryByNodeAndStatus(WorkNodeEnums workNodeEnums) { |
||||||
|
return getFactoryByNodeAndStatus(workNodeEnums, 1); |
||||||
|
} |
||||||
|
|
||||||
|
public static FactoryNodeEnums getFactoryByNodeAndStatus(WorkNodeEnums workNodeEnums, Integer status) { |
||||||
|
NodeMappingEnums[] values = values(); |
||||||
|
for (NodeMappingEnums value : values) { |
||||||
|
WorkNodeEnums workNodeEnums1 = value.getWorkNodeEnums(); |
||||||
|
Integer status1 = value.getStatus(); |
||||||
|
FactoryNodeEnums factoryNodeEnums = value.getFactoryNodeEnums(); |
||||||
|
if (ObjectUtil.equal(workNodeEnums1, workNodeEnums) && ObjectUtil.equal(status1, status)) { |
||||||
|
return factoryNodeEnums; |
||||||
|
} |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
package com.logpm.factorydata.mwh.enums; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* 作业节点枚举 |
||||||
|
* |
||||||
|
* @author zhaoqiaobo |
||||||
|
* @create 2024-03-20 15:19 |
||||||
|
*/ |
||||||
|
@Getter |
||||||
|
public enum NodeNeedEnums implements Serializable { |
||||||
|
|
||||||
|
/** |
||||||
|
* 始发仓入库 |
||||||
|
*/ |
||||||
|
INITIAL_WAREHOUSE_ENTRY(20, "始发仓入库"), |
||||||
|
/** |
||||||
|
* 末端仓卸车确认 |
||||||
|
*/ |
||||||
|
END_WAREHOUSE_UNLOADING(170, "末端仓卸车确认"), |
||||||
|
; |
||||||
|
|
||||||
|
private Integer code; |
||||||
|
private String value; |
||||||
|
|
||||||
|
NodeNeedEnums(Integer code, String value) { |
||||||
|
this.code = code; |
||||||
|
this.value = value; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,87 @@ |
|||||||
|
package com.logpm.factorydata.mwh.interceptor; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.logpm.factorydata.mwh.service.IFactoryTokenService; |
||||||
|
import com.logpm.factorydata.mwh.wrapper.RequestWrapper; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.extern.log4j.Log4j2; |
||||||
|
import org.springblade.common.exception.CustomerException; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springblade.core.tool.utils.StringUtil; |
||||||
|
import org.springframework.web.servlet.HandlerInterceptor; |
||||||
|
import org.springframework.web.servlet.ModelAndView; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
import java.io.IOException; |
||||||
|
import java.io.PrintWriter; |
||||||
|
|
||||||
|
@Log4j2 |
||||||
|
@AllArgsConstructor |
||||||
|
public class FactoryAccountsInterceptor implements HandlerInterceptor { |
||||||
|
|
||||||
|
private final IFactoryTokenService factoryTokenService; |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws CustomerException { |
||||||
|
try { |
||||||
|
|
||||||
|
RequestWrapper myRequestWrapper = new RequestWrapper(request); |
||||||
|
String body = myRequestWrapper.getBody(); |
||||||
|
JSONObject jsonObject = JSONObject.parseObject(body); |
||||||
|
//获取头中参数
|
||||||
|
String token = request.getHeader("Authorization"); |
||||||
|
String corpId = request.getHeader("corpid"); |
||||||
|
if(StringUtil.isBlank(corpId)){ |
||||||
|
corpId = jsonObject.getString("corpid"); |
||||||
|
} |
||||||
|
if(!StringUtil.hasLength(token)){ |
||||||
|
returnJson(response,JSONObject.toJSONString(R.fail(401,"认证不通过,token有误"))); |
||||||
|
return false; |
||||||
|
} |
||||||
|
if(!StringUtil.hasLength(corpId)){ |
||||||
|
returnJson(response,JSONObject.toJSONString(R.fail(401,"认证不通过,corpId有误"))); |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
log.info("##########preHandle: token={}",token); |
||||||
|
//验证token
|
||||||
|
boolean b = factoryTokenService.verifyToken(token,corpId); |
||||||
|
if(!b){ |
||||||
|
returnJson(response,JSONObject.toJSONString(R.fail(401,"认证不通过,token不存在或已过期"))); |
||||||
|
return false; |
||||||
|
} |
||||||
|
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(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { |
||||||
|
HandlerInterceptor.super.postHandle(request, response, handler, modelAndView); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { |
||||||
|
HandlerInterceptor.super.afterCompletion(request, response, handler, ex); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,100 @@ |
|||||||
|
package com.logpm.factorydata.mwh.interceptor; |
||||||
|
|
||||||
|
import cn.hutool.http.HttpRequest; |
||||||
|
import cn.hutool.http.HttpResponse; |
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.logpm.factorydata.mwh.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.redis.cache.BladeRedis; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springblade.core.tool.utils.ThreadLocalUtil; |
||||||
|
import org.springframework.core.env.Environment; |
||||||
|
import org.springframework.http.HttpHeaders; |
||||||
|
import org.springframework.web.context.request.RequestContextHolder; |
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes; |
||||||
|
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; |
||||||
|
private final Environment environment; |
||||||
|
@Override |
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws CustomerException { |
||||||
|
|
||||||
|
|
||||||
|
try { |
||||||
|
CustomHttpServletRequestWrapper wrappedRequest = new CustomHttpServletRequestWrapper(request); |
||||||
|
String account ="shujutongbu"; |
||||||
|
JSONObject data =bladeRedis.get(CacheNames.LOCAL_SERVER_USER+account); |
||||||
|
if(Objects.isNull(data)){ |
||||||
|
String url = "http://"+ LauncherConstant.loginAddr(Objects.requireNonNull(environment.getActiveProfiles()[0]))+"/blade-auth/oauth/token"; |
||||||
|
HttpRequest urlRequest = HttpRequest.post(url); |
||||||
|
urlRequest.header("Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0"); |
||||||
|
urlRequest.header("Tenant-Id", "627683"); |
||||||
|
|
||||||
|
Map<String, Object> params = new HashMap<>(); |
||||||
|
params.put("grant_type", "local_server"); |
||||||
|
params.put("scope", "all"); |
||||||
|
params.put("username", account); |
||||||
|
params.put("tenantId", "627683"); |
||||||
|
HttpResponse execute = urlRequest.form(params).execute(); |
||||||
|
String body = execute.body(); |
||||||
|
data = JSONObject.parseObject(body); |
||||||
|
bladeRedis.setEx(CacheNames.LOCAL_SERVER_USER+account,data,3200L); |
||||||
|
} |
||||||
|
|
||||||
|
// 修改或添加header
|
||||||
|
|
||||||
|
// 发送登录请求
|
||||||
|
log.info("##########preHandle: request={}", request); |
||||||
|
|
||||||
|
wrappedRequest.addHeader("Blade-Auth", "bearer "+data.getString("access_token")); |
||||||
|
HttpHeaders httpHeaders = new HttpHeaders(); |
||||||
|
httpHeaders.add("Blade-Auth","bearer "+data.get("access_token") ); |
||||||
|
httpHeaders.add( "Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0"); |
||||||
|
ThreadLocalUtil.put("bladeContext", httpHeaders); |
||||||
|
|
||||||
|
|
||||||
|
// 用包装后的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(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,60 @@ |
|||||||
|
/* |
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are met: |
||||||
|
* |
||||||
|
* Redistributions of source code must retain the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* Redistributions in binary form must reproduce the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer in the |
||||||
|
* documentation and/or other materials provided with the distribution. |
||||||
|
* Neither the name of the dreamlu.net developer nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* Author: Chill 庄骞 (smallchill@163.com) |
||||||
|
*/ |
||||||
|
package com.logpm.factorydata.mwh.launcher; |
||||||
|
|
||||||
|
import org.springblade.core.auto.service.AutoService; |
||||||
|
import org.springblade.core.launch.constant.NacosConstant; |
||||||
|
import org.springblade.core.launch.service.LauncherService; |
||||||
|
import org.springblade.core.launch.utils.PropsUtil; |
||||||
|
import org.springframework.boot.builder.SpringApplicationBuilder; |
||||||
|
|
||||||
|
import java.util.Properties; |
||||||
|
|
||||||
|
/** |
||||||
|
* 启动参数拓展 |
||||||
|
* |
||||||
|
* @author Chill |
||||||
|
*/ |
||||||
|
@AutoService(LauncherService.class) |
||||||
|
public class FactoryDataBaseLauncherServiceImpl implements LauncherService { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) { |
||||||
|
Properties props = System.getProperties(); |
||||||
|
// 开启多数据源
|
||||||
|
PropsUtil.setProperty(props, "spring.datasource.dynamic.enabled", "true"); |
||||||
|
// 指定注册配置信息
|
||||||
|
PropsUtil.setProperty(props, "spring.cloud.nacos.config.extension-configs[0].data-id", NacosConstant.dataId(appName, profile)); |
||||||
|
PropsUtil.setProperty(props, "spring.cloud.nacos.config.extension-configs[0].group", NacosConstant.NACOS_CONFIG_GROUP); |
||||||
|
PropsUtil.setProperty(props, "spring.cloud.nacos.config.extension-configs[0].refresh", NacosConstant.NACOS_CONFIG_REFRESH); |
||||||
|
// 指定注册IP
|
||||||
|
// PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.ip", "127.0.0.1");
|
||||||
|
// 指定注册端口
|
||||||
|
// PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.port", "8200");
|
||||||
|
// 自定义命名空间
|
||||||
|
// PropsUtil.setProperty(props, "spring.cloud.nacos.config.namespace", LauncherConstant.NACOS_NAMESPACE);
|
||||||
|
// PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.namespace", LauncherConstant.NACOS_NAMESPACE);
|
||||||
|
// 自定义分组
|
||||||
|
// PropsUtil.setProperty(props, "spring.cloud.nacos.config.group", NacosConstant.NACOS_CONFIG_GROUP);
|
||||||
|
// PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.group", NacosConstant.NACOS_CONFIG_GROUP);
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getOrder() { |
||||||
|
return 20; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
package com.logpm.factorydata.mwh.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.logpm.factorydata.mwh.entity.DeliveryNoteEntity; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* 发货单 mapper |
||||||
|
* |
||||||
|
* @author zqb |
||||||
|
* @since 2024-03-26 |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface DeliveryNoteMapper extends BaseMapper<DeliveryNoteEntity> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.logpm.factorydata.mwh.mapper.DeliveryNoteMapper"> |
||||||
|
|
||||||
|
</mapper> |
@ -0,0 +1,16 @@ |
|||||||
|
package com.logpm.factorydata.mwh.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.logpm.factorydata.mwh.entity.FactoryOrderLogEntity; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* 工厂订单日志 mapper |
||||||
|
* |
||||||
|
* @author zqb |
||||||
|
* @since 2024-03-26 |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface FactoryOrderLogMapper extends BaseMapper<FactoryOrderLogEntity> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.logpm.factorydata.mwh.mapper.FactoryOrderLogMapper"> |
||||||
|
|
||||||
|
</mapper> |
@ -0,0 +1,31 @@ |
|||||||
|
/* |
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are met: |
||||||
|
* |
||||||
|
* Redistributions of source code must retain the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* Redistributions in binary form must reproduce the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer in the |
||||||
|
* documentation and/or other materials provided with the distribution. |
||||||
|
* Neither the name of the dreamlu.net developer nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* Author: Chill 庄骞 (smallchill@163.com) |
||||||
|
*/ |
||||||
|
package com.logpm.factorydata.mwh.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.logpm.factorydata.mwh.entity.FactoryToken; |
||||||
|
|
||||||
|
/** |
||||||
|
* 工厂账号接口日志 Mapper 接口 |
||||||
|
* |
||||||
|
* @author zhy |
||||||
|
* @since 2023-03-28 |
||||||
|
*/ |
||||||
|
public interface FactoryTokenMapper extends BaseMapper<FactoryToken> { |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.logpm.factorydata.mwh.mapper.FactoryTokenMapper"> |
||||||
|
|
||||||
|
<!-- 通用查询映射结果 --> |
||||||
|
<!-- <resultMap id="orderLogResultMap" type="com.logpm.factory.snm.entity.FactoryOrder">--> |
||||||
|
<!-- <result column="id" property="id"/>--> |
||||||
|
<!-- <result column="req_args" property="reqArgs"/>--> |
||||||
|
<!-- <result column="res_body" property="resBody"/>--> |
||||||
|
<!-- <result column="type" property="type"/>--> |
||||||
|
<!-- <result column="create_user" property="createUser"/>--> |
||||||
|
<!-- <result column="create_time" property="createTime"/>--> |
||||||
|
<!-- <result column="update_user" property="updateUser"/>--> |
||||||
|
<!-- <result column="update_time" property="updateTime"/>--> |
||||||
|
<!-- <result column="status" property="status"/>--> |
||||||
|
<!-- <result column="is_deleted" property="isDeleted"/>--> |
||||||
|
<!-- <result column="create_dept" property="createDept"/>--> |
||||||
|
<!-- </resultMap>--> |
||||||
|
|
||||||
|
</mapper> |
@ -0,0 +1,16 @@ |
|||||||
|
package com.logpm.factorydata.mwh.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.logpm.factorydata.mwh.entity.PackageInfoEntity; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* 装箱包信息 mapper |
||||||
|
* |
||||||
|
* @author zqb |
||||||
|
* @since 2024-03-26 |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface PackageInfoMapper extends BaseMapper<PackageInfoEntity> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.logpm.factorydata.mwh.mapper.PackageInfoMapper"> |
||||||
|
|
||||||
|
</mapper> |
@ -0,0 +1,143 @@ |
|||||||
|
package com.logpm.factorydata.mwh.mq; |
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil; |
||||||
|
import cn.hutool.core.collection.CollUtil; |
||||||
|
import cn.hutool.core.io.FileUtil; |
||||||
|
import cn.hutool.core.util.CharsetUtil; |
||||||
|
import cn.hutool.core.util.ObjectUtil; |
||||||
|
import cn.hutool.core.util.StrUtil; |
||||||
|
import cn.hutool.core.util.URLUtil; |
||||||
|
import cn.hutool.json.JSONArray; |
||||||
|
import cn.hutool.json.JSONConfig; |
||||||
|
import cn.hutool.json.JSONObject; |
||||||
|
import cn.hutool.json.JSONUtil; |
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||||
|
import com.logpm.factorydata.enums.SaxStatusEnums; |
||||||
|
import com.logpm.factorydata.mwh.entity.DeliveryNoteEntity; |
||||||
|
import com.logpm.factorydata.mwh.entity.FactoryOrderLogEntity; |
||||||
|
import com.logpm.factorydata.mwh.entity.PackageInfoEntity; |
||||||
|
import com.logpm.factorydata.mwh.service.DeliveryNoteService; |
||||||
|
import com.logpm.factorydata.mwh.service.FactoryOrderLogService; |
||||||
|
import com.logpm.factorydata.mwh.service.PackageInfoService; |
||||||
|
import com.logpm.factorydata.mwh.vo.DeliveryNoteVO; |
||||||
|
import com.logpm.factorydata.mwh.vo.PackageInfoVO; |
||||||
|
import com.logpm.factorydata.mwh.vo.ReceiverVO; |
||||||
|
import com.logpm.factorydata.mwh.vo.SenderVO; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springblade.common.constant.factorydata.FactoryDataConstants; |
||||||
|
import org.springframework.amqp.core.ExchangeTypes; |
||||||
|
import org.springframework.amqp.rabbit.annotation.Exchange; |
||||||
|
import org.springframework.amqp.rabbit.annotation.Queue; |
||||||
|
import org.springframework.amqp.rabbit.annotation.QueueBinding; |
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
import org.springframework.transaction.annotation.Transactional; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 监听订单数据 |
||||||
|
* |
||||||
|
* @author zhaoqiaobo |
||||||
|
* @create 2024-03-18 |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
@Component |
||||||
|
@AllArgsConstructor |
||||||
|
public class FactoryOrderListener { |
||||||
|
|
||||||
|
private final DeliveryNoteService deliveryNoteService; |
||||||
|
private final FactoryOrderLogService logService; |
||||||
|
private final PackageInfoService packageInfoService; |
||||||
|
|
||||||
|
@RabbitListener(bindings = @QueueBinding( |
||||||
|
value = @Queue(name = FactoryDataConstants.Mq.Queues.MWH_FACTORY_ORDER), |
||||||
|
exchange = @Exchange(name = FactoryDataConstants.Mq.Exchanges.FACTORY_ORDER, type = ExchangeTypes.TOPIC), |
||||||
|
key = FactoryDataConstants.Mq.RoutingKeys.MWH_FACTORY_ORDER |
||||||
|
)) |
||||||
|
@Transactional(rollbackFor = Exception.class) |
||||||
|
public void factoryOrder(String msg) { |
||||||
|
log.info("处理曼好家订单:{}", msg); |
||||||
|
if (StrUtil.isEmpty(msg)) { |
||||||
|
log.error("消息内容为空"); |
||||||
|
return; |
||||||
|
} |
||||||
|
FactoryOrderLogEntity logEntity = JSONUtil.toBean(msg, FactoryOrderLogEntity.class); |
||||||
|
if (ObjectUtil.isEmpty(logEntity)) { |
||||||
|
log.error("消息内容为空"); |
||||||
|
return; |
||||||
|
} |
||||||
|
// 去 minio 下载文件到本地,然后解析文件内容为实体对象
|
||||||
|
DeliveryNoteVO vo = null; |
||||||
|
Long logId = logEntity.getId(); |
||||||
|
String logUrl = logEntity.getLogUrl(); |
||||||
|
if (StrUtil.isNotEmpty(logUrl)) { |
||||||
|
List<String> res = new ArrayList<>(); |
||||||
|
FileUtil.readLines(URLUtil.url(logUrl), CharsetUtil.CHARSET_UTF_8, res); |
||||||
|
if (CollUtil.isNotEmpty(res)) { |
||||||
|
String content = res.get(0); |
||||||
|
if (StrUtil.isNotEmpty(content)) { |
||||||
|
JSONConfig config = new JSONConfig(); |
||||||
|
config.setIgnoreCase(Boolean.TRUE); |
||||||
|
vo = JSONUtil.toBean(content, DeliveryNoteVO.class); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (ObjectUtil.isEmpty(vo)) { |
||||||
|
log.error("消息内容为空"); |
||||||
|
return; |
||||||
|
} |
||||||
|
// 1 解析数据保存入库
|
||||||
|
// 订单号唯一
|
||||||
|
String orderSelfNum = vo.getOrderSelfNum(); |
||||||
|
List<DeliveryNoteEntity> list = deliveryNoteService.list(Wrappers.<DeliveryNoteEntity>lambdaQuery() |
||||||
|
.eq(DeliveryNoteEntity::getOrderSelfNum, orderSelfNum)); |
||||||
|
if (CollUtil.isNotEmpty(list)) { |
||||||
|
log.error("订单号{} 数据已经处理过了, logId: {}", orderSelfNum, logId); |
||||||
|
return; |
||||||
|
} |
||||||
|
DeliveryNoteEntity deliveryNoteEntity = new DeliveryNoteEntity(); |
||||||
|
BeanUtil.copyProperties(vo, deliveryNoteEntity); |
||||||
|
ReceiverVO receiver = vo.getReceiver(); |
||||||
|
if(ObjectUtil.isNotEmpty(receiver)){ |
||||||
|
BeanUtil.copyProperties(receiver, deliveryNoteEntity); |
||||||
|
} |
||||||
|
SenderVO senderVO = vo.getSender(); |
||||||
|
if(ObjectUtil.isNotEmpty(senderVO)){ |
||||||
|
BeanUtil.copyProperties(senderVO, deliveryNoteEntity); |
||||||
|
} |
||||||
|
deliveryNoteEntity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null); |
||||||
|
deliveryNoteService.save(deliveryNoteEntity); |
||||||
|
List<PackageInfoVO> orderInfos = vo.getItems(); |
||||||
|
if (CollUtil.isNotEmpty(orderInfos)) { |
||||||
|
List<PackageInfoEntity> infoEntities = new ArrayList<>(); |
||||||
|
for (PackageInfoVO orderInfo : orderInfos) { |
||||||
|
String attributes = orderInfo.getAttributes(); |
||||||
|
JSONArray objects = new JSONArray(attributes); |
||||||
|
for (Object object : objects) { |
||||||
|
PackageInfoEntity orderInfoEntity = new PackageInfoEntity(); |
||||||
|
BeanUtil.copyProperties(orderInfo, orderInfoEntity); |
||||||
|
JSONObject object1 = (JSONObject) object; |
||||||
|
String code = object1.getStr("code"); |
||||||
|
String name = object1.getStr("name"); |
||||||
|
orderInfoEntity.setCode(code); |
||||||
|
orderInfoEntity.setName(name); |
||||||
|
orderInfoEntity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null); |
||||||
|
orderInfoEntity.setDeliveryNoteId(deliveryNoteEntity.getId().toString()); |
||||||
|
infoEntities.add(orderInfoEntity); |
||||||
|
} |
||||||
|
} |
||||||
|
packageInfoService.saveBatch(infoEntities); |
||||||
|
} |
||||||
|
// 2 构建暂存单,发送 mq 消息
|
||||||
|
FactoryOrderLogEntity logEntity1 = new FactoryOrderLogEntity(); |
||||||
|
logEntity1.setSaxStatus(SaxStatusEnums.SUCCESS.getCode()); |
||||||
|
logEntity1.setId(logId); |
||||||
|
logService.saveOrUpdate(logEntity1); |
||||||
|
// 处理暂存单
|
||||||
|
deliveryNoteService.buildAdvance(vo); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
package com.logpm.factorydata.mwh.pros; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||||
|
|
||||||
|
/** |
||||||
|
* FactoryProperties |
||||||
|
* |
||||||
|
* @author pref |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ConfigurationProperties(prefix = "logpm") |
||||||
|
public class FactoryDataProperties { |
||||||
|
/** |
||||||
|
* 名称 |
||||||
|
*/ |
||||||
|
private String name; |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
package com.logpm.factorydata.mwh.service; |
||||||
|
|
||||||
|
import com.logpm.factorydata.mwh.entity.DeliveryNoteEntity; |
||||||
|
import com.logpm.factorydata.mwh.vo.DeliveryNoteVO; |
||||||
|
import org.springblade.core.mp.base.BaseService; |
||||||
|
|
||||||
|
/** |
||||||
|
* 索菲亚发货单 服务类 |
||||||
|
* |
||||||
|
* @Author zqb |
||||||
|
* @Date 2024/4/26 |
||||||
|
**/ |
||||||
|
public interface DeliveryNoteService extends BaseService<DeliveryNoteEntity> { |
||||||
|
|
||||||
|
|
||||||
|
void buildAdvance(DeliveryNoteVO entities); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
package com.logpm.factorydata.mwh.service; |
||||||
|
|
||||||
|
import com.logpm.factorydata.mwh.entity.FactoryOrderLogEntity; |
||||||
|
import com.logpm.factorydata.mwh.vo.DeliveryNoteVO; |
||||||
|
import org.springblade.core.mp.base.BaseService; |
||||||
|
|
||||||
|
/** |
||||||
|
* 工厂订单日志 服务类 |
||||||
|
* |
||||||
|
* @Author zqb |
||||||
|
* @Date 2024/4/26 |
||||||
|
**/ |
||||||
|
public interface FactoryOrderLogService extends BaseService<FactoryOrderLogEntity> { |
||||||
|
|
||||||
|
String order(DeliveryNoteVO vo); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
package com.logpm.factorydata.mwh.service; |
||||||
|
|
||||||
|
import com.logpm.factorydata.mwh.entity.FactoryToken; |
||||||
|
import org.springblade.core.mp.base.BaseService; |
||||||
|
|
||||||
|
import java.security.NoSuchAlgorithmException; |
||||||
|
|
||||||
|
/** |
||||||
|
* 工厂推送数据接口 |
||||||
|
*/ |
||||||
|
public interface IFactoryTokenService extends BaseService<FactoryToken> { |
||||||
|
|
||||||
|
|
||||||
|
boolean verifyToken(String token, String corpId) throws NoSuchAlgorithmException; |
||||||
|
} |
@ -0,0 +1,14 @@ |
|||||||
|
package com.logpm.factorydata.mwh.service; |
||||||
|
|
||||||
|
import com.logpm.factorydata.mwh.entity.PackageInfoEntity; |
||||||
|
import org.springblade.core.mp.base.BaseService; |
||||||
|
|
||||||
|
/** |
||||||
|
* 装箱包信息 服务类 |
||||||
|
* |
||||||
|
* @Author zqb |
||||||
|
* @Date 2024/4/26 |
||||||
|
**/ |
||||||
|
public interface PackageInfoService extends BaseService<PackageInfoEntity> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,178 @@ |
|||||||
|
package com.logpm.factorydata.mwh.service.impl; |
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil; |
||||||
|
import cn.hutool.core.collection.CollUtil; |
||||||
|
import cn.hutool.core.convert.Convert; |
||||||
|
import cn.hutool.core.date.DateUtil; |
||||||
|
import cn.hutool.core.util.ObjectUtil; |
||||||
|
import cn.hutool.core.util.StrUtil; |
||||||
|
import cn.hutool.json.JSONArray; |
||||||
|
import cn.hutool.json.JSONObject; |
||||||
|
import cn.hutool.json.JSONUtil; |
||||||
|
import com.logpm.factorydata.base.feign.IFactoryDataBaseClient; |
||||||
|
import com.logpm.factorydata.base.vo.FactoryWarehouseBindVO; |
||||||
|
import com.logpm.factorydata.enums.BrandEnums; |
||||||
|
import com.logpm.factorydata.feign.IFactoryDataClient; |
||||||
|
import com.logpm.factorydata.mwh.entity.DeliveryNoteEntity; |
||||||
|
import com.logpm.factorydata.mwh.entity.PackageInfoEntity; |
||||||
|
import com.logpm.factorydata.mwh.mapper.DeliveryNoteMapper; |
||||||
|
import com.logpm.factorydata.mwh.service.DeliveryNoteService; |
||||||
|
import com.logpm.factorydata.mwh.vo.DeliveryNoteVO; |
||||||
|
import com.logpm.factorydata.mwh.vo.PackageInfoVO; |
||||||
|
import com.logpm.factorydata.mwh.vo.SenderVO; |
||||||
|
import com.logpm.factorydata.vo.SendMsg; |
||||||
|
import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity; |
||||||
|
import com.logpm.trunkline.entity.TrunklineAdvanceEntity; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springblade.common.annotations.LogpmAsync; |
||||||
|
import org.springblade.common.constant.HttpConstants; |
||||||
|
import org.springblade.common.constant.factorydata.FactoryDataConstants; |
||||||
|
import org.springblade.core.mp.base.BaseServiceImpl; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.time.LocalDateTime; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 发货单 业务实现类 |
||||||
|
* |
||||||
|
* @Author zqb |
||||||
|
* @Date 2024/4/26 |
||||||
|
**/ |
||||||
|
@Slf4j |
||||||
|
@Service |
||||||
|
@AllArgsConstructor |
||||||
|
public class DeliveryNoteServiceImpl extends BaseServiceImpl<DeliveryNoteMapper, DeliveryNoteEntity> implements DeliveryNoteService { |
||||||
|
|
||||||
|
private final IFactoryDataBaseClient baseClient; |
||||||
|
private final IFactoryDataClient factoryDataClient; |
||||||
|
|
||||||
|
@Override |
||||||
|
@LogpmAsync("asyncExecutor") |
||||||
|
public void buildAdvance(DeliveryNoteVO vo) { |
||||||
|
// 新起线程构建暂存单发送mq
|
||||||
|
Long startWarehouseId = null; |
||||||
|
String startWarehouseName = null; |
||||||
|
String tenantId = null; |
||||||
|
// 获取工厂基地绑定的始发仓信息
|
||||||
|
R<FactoryWarehouseBindVO> warehouseByBrandAndSiteName = baseClient.getWarehouseByBrandAndSiteName(BrandEnums.MHJ.getValue(), BrandEnums.MHJ.getValue()); |
||||||
|
if (ObjectUtil.equal(HttpConstants.HTTP.HTTP_RESOURCE_CODE.SUCCESS_CODE, warehouseByBrandAndSiteName.getCode())) { |
||||||
|
FactoryWarehouseBindVO data = warehouseByBrandAndSiteName.getData(); |
||||||
|
if (ObjectUtil.isNotNull(data)) { |
||||||
|
startWarehouseId = data.getWarehouseId(); |
||||||
|
startWarehouseName = data.getWarehouseName(); |
||||||
|
tenantId = data.getTenantId(); |
||||||
|
} |
||||||
|
} |
||||||
|
List<PackageInfoVO> packages = vo.getItems(); |
||||||
|
// 组装暂存单数据
|
||||||
|
List<JSONObject> advances = new ArrayList<>(); |
||||||
|
TrunklineAdvanceEntity advanceEntity = new TrunklineAdvanceEntity(); |
||||||
|
advanceEntity.setTenantId(tenantId); |
||||||
|
advanceEntity.setStatus(0); |
||||||
|
advanceEntity.setIsDeleted(0); |
||||||
|
advanceEntity.setHasPackage(CollUtil.isNotEmpty(packages) ? 1 : 0); |
||||||
|
advanceEntity.setOrderType(vo.getOrderTypeName()); |
||||||
|
advanceEntity.setBrand(BrandEnums.MHJ.getValue()); |
||||||
|
advanceEntity.setSiteName(""); |
||||||
|
advanceEntity.setArea(""); |
||||||
|
advanceEntity.setTotalNum(StrUtil.isNotEmpty(vo.getTotalQuantity()) ? Convert.toInt(vo.getTotalQuantity()) : 0); |
||||||
|
|
||||||
|
advanceEntity.setPackCode(""); |
||||||
|
advanceEntity.setWarehouseId(startWarehouseId); |
||||||
|
advanceEntity.setWarehouseName(startWarehouseName); |
||||||
|
|
||||||
|
advanceEntity.setIsGcp(0); |
||||||
|
advanceEntity.setSystemType("线上"); |
||||||
|
advanceEntity.setMatingType("1"); |
||||||
|
advanceEntity.setWaybillStatus("0"); |
||||||
|
advanceEntity.setWaybillNo(""); |
||||||
|
advanceEntity.setFreezeStatus("0"); |
||||||
|
advanceEntity.setPackName(""); |
||||||
|
advanceEntity.setCarrierName("汇通"); |
||||||
|
SenderVO sender = vo.getSender(); |
||||||
|
if(ObjectUtil.isNotNull(sender)){ |
||||||
|
advanceEntity.setSenderName(vo.getSender().getSenderName()); |
||||||
|
advanceEntity.setSenderPhone(vo.getSender().getSenderMobile()); |
||||||
|
advanceEntity.setSenderAddress(vo.getSender().getSenderAddress()); |
||||||
|
} |
||||||
|
advanceEntity.setTrainNumber(""); |
||||||
|
advanceEntity.setSenderFactory(BrandEnums.MHJ.getValue()); |
||||||
|
advanceEntity.setOrderCode(vo.getOrderSelfNum()); |
||||||
|
advanceEntity.setDealerCode(vo.getSiteCode()); |
||||||
|
advanceEntity.setDealerName(vo.getSiteName()); |
||||||
|
advanceEntity.setStoreCode(vo.getSiteCode()); |
||||||
|
advanceEntity.setStoreName(vo.getSiteName()); |
||||||
|
advanceEntity.setServiceNum(vo.getOrderNo()); |
||||||
|
if(ObjectUtil.isNotNull(vo.getReceiver())){ |
||||||
|
advanceEntity.setCustomerName(vo.getReceiver().getReceiverName()); |
||||||
|
advanceEntity.setCustomerPhone(vo.getReceiver().getReceiverMobile()); |
||||||
|
advanceEntity.setCustomerAddress(vo.getReceiver().getReceiverAddress()); |
||||||
|
} |
||||||
|
List<JSONObject> packageList = new ArrayList<>(); |
||||||
|
if(CollUtil.isNotEmpty(packages)){ |
||||||
|
for (PackageInfoVO orderPackageDTO : packages) { |
||||||
|
String attributes = orderPackageDTO.getAttributes(); |
||||||
|
JSONArray objects = new JSONArray(attributes); |
||||||
|
for (Object object : objects) { |
||||||
|
JSONObject object1 = (JSONObject) object; |
||||||
|
String code = object1.getStr("code"); |
||||||
|
String name = object1.getStr("name"); |
||||||
|
// 封装包件
|
||||||
|
TrunklineAdvanceDetailEntity advanceDetailEntity = new TrunklineAdvanceDetailEntity(); |
||||||
|
advanceDetailEntity.setWarehouseId(startWarehouseId); |
||||||
|
advanceDetailEntity.setWarehouseName(startWarehouseName); |
||||||
|
advanceDetailEntity.setOrderCode(vo.getOrderSelfNum()); |
||||||
|
advanceDetailEntity.setBrand(BrandEnums.MHJ.getValue()); |
||||||
|
advanceDetailEntity.setSystemType("线上"); |
||||||
|
advanceDetailEntity.setFirstPackName(name); |
||||||
|
//二级品类名称
|
||||||
|
advanceDetailEntity.setSecondPackName(name); |
||||||
|
//三级品类名称
|
||||||
|
advanceDetailEntity.setThirdPackName(name); |
||||||
|
advanceDetailEntity.setMaterialName(""); |
||||||
|
advanceDetailEntity.setSiteName(""); |
||||||
|
advanceDetailEntity.setSiteCode(""); |
||||||
|
advanceDetailEntity.setQuantity(1); |
||||||
|
advanceDetailEntity.setOrderPackageCode(code); |
||||||
|
advanceDetailEntity.setTrainNumber(""); |
||||||
|
advanceDetailEntity.setServiceNum(vo.getOrderNo()); |
||||||
|
advanceDetailEntity.setWaybillNo(""); |
||||||
|
advanceDetailEntity.setPackageStatus("0"); |
||||||
|
advanceDetailEntity.setWeight(BigDecimal.ZERO); |
||||||
|
advanceDetailEntity.setVolume(BigDecimal.ZERO); |
||||||
|
// advanceDetailEntity.setChargeType(0);
|
||||||
|
advanceDetailEntity.setSupple(""); |
||||||
|
advanceDetailEntity.setManifest(""); |
||||||
|
advanceDetailEntity.setReturnNum(""); |
||||||
|
advanceDetailEntity.setSendDateStr(DateUtil.formatLocalDateTime(LocalDateTime.now())); |
||||||
|
advanceDetailEntity.setCarNumber(""); |
||||||
|
advanceDetailEntity.setGoodsMan(""); |
||||||
|
advanceDetailEntity.setTenantId(tenantId); |
||||||
|
advanceDetailEntity.setStatus(0); |
||||||
|
advanceDetailEntity.setIsDeleted(0); |
||||||
|
JSONObject entries = JSONUtil.parseObj(advanceDetailEntity); |
||||||
|
packageList.add(entries); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 转成json对象,然后将包件明细放到detail中
|
||||||
|
JSONObject entries = JSONUtil.parseObj(advanceEntity); |
||||||
|
entries.set("details", JSONUtil.toJsonStr(packageList)); |
||||||
|
advances.add(entries); |
||||||
|
// 将组装好的暂存单发送到 MQ ,由暂存单服务统一消费SendMsg.
|
||||||
|
if (CollUtil.isNotEmpty(advances)) { |
||||||
|
for (JSONObject advance : advances) { |
||||||
|
SendMsg sendMsg = SendMsg.builder().exchange(FactoryDataConstants.Mq.Exchanges.ADVANCE_ORDER) |
||||||
|
.routingKey(FactoryDataConstants.Mq.RoutingKeys.ADVANCE_ORDER).message(JSONUtil.toJsonStr(advance)).build(); |
||||||
|
factoryDataClient.sendMessage(sendMsg); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,110 @@ |
|||||||
|
package com.logpm.factorydata.mwh.service.impl; |
||||||
|
|
||||||
|
import cn.hutool.core.io.FileUtil; |
||||||
|
import cn.hutool.core.util.ObjectUtil; |
||||||
|
import cn.hutool.json.JSONUtil; |
||||||
|
import com.logpm.factorydata.enums.SaxStatusEnums; |
||||||
|
import com.logpm.factorydata.feign.IFactoryDataClient; |
||||||
|
import com.logpm.factorydata.mwh.entity.FactoryOrderLogEntity; |
||||||
|
import com.logpm.factorydata.mwh.mapper.FactoryOrderLogMapper; |
||||||
|
import com.logpm.factorydata.mwh.service.FactoryOrderLogService; |
||||||
|
import com.logpm.factorydata.mwh.vo.DeliveryNoteVO; |
||||||
|
import com.logpm.factorydata.vo.SendMsg; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.apache.commons.fileupload.FileItem; |
||||||
|
import org.apache.commons.fileupload.disk.DiskFileItemFactory; |
||||||
|
import org.apache.commons.io.IOUtils; |
||||||
|
import org.jetbrains.annotations.NotNull; |
||||||
|
import org.springblade.common.constant.factorydata.FactoryDataConstants; |
||||||
|
import org.springblade.common.utils.FileLogsUtil; |
||||||
|
import org.springblade.core.log.exception.ServiceException; |
||||||
|
import org.springblade.core.mp.base.BaseServiceImpl; |
||||||
|
import org.springblade.core.oss.model.BladeFile; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springblade.resource.feign.IOssClient; |
||||||
|
import org.springframework.http.MediaType; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
import org.springframework.web.multipart.MultipartFile; |
||||||
|
import org.springframework.web.multipart.commons.CommonsMultipartFile; |
||||||
|
|
||||||
|
import java.io.File; |
||||||
|
import java.io.InputStream; |
||||||
|
import java.io.OutputStream; |
||||||
|
import java.nio.file.Files; |
||||||
|
|
||||||
|
/** |
||||||
|
* 工厂订单日志 业务实现类 |
||||||
|
* |
||||||
|
* @Author zqb |
||||||
|
* @Date 2024/4/26 |
||||||
|
**/ |
||||||
|
@Slf4j |
||||||
|
@Service |
||||||
|
@AllArgsConstructor |
||||||
|
public class FactoryOrderLogServiceImpl extends BaseServiceImpl<FactoryOrderLogMapper, FactoryOrderLogEntity> implements FactoryOrderLogService { |
||||||
|
|
||||||
|
private final IFactoryDataClient factoryDataClient; |
||||||
|
private final IOssClient ossClient; |
||||||
|
|
||||||
|
@Override |
||||||
|
public String order(DeliveryNoteVO vo) { |
||||||
|
|
||||||
|
// 1 上传数据到 minio 获取到地址
|
||||||
|
String url = uploadFile(JSONUtil.toJsonStr(vo)); |
||||||
|
// 2 保存地址到数据库
|
||||||
|
FactoryOrderLogEntity logEntity = new FactoryOrderLogEntity(); |
||||||
|
logEntity.setType(1); |
||||||
|
logEntity.setSaxStatus(SaxStatusEnums.NOMAL.getCode()); |
||||||
|
logEntity.setLogUrl(url); |
||||||
|
this.save(logEntity); |
||||||
|
|
||||||
|
// 3 将消息发送给 mq,解析保存
|
||||||
|
SendMsg build = SendMsg.builder().exchange(FactoryDataConstants.Mq.Exchanges.FACTORY_ORDER) |
||||||
|
.routingKey(FactoryDataConstants.Mq.RoutingKeys.MWH_FACTORY_ORDER) |
||||||
|
.message(JSONUtil.toJsonStr(logEntity)).build(); |
||||||
|
factoryDataClient.sendMessage(build); |
||||||
|
return "成功"; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private String uploadFile(String body) { |
||||||
|
//文本内容和保存为本地文件 并上传
|
||||||
|
String logPath = FileLogsUtil.saveFileLogs(body); |
||||||
|
log.info(">>> 文件路径 {}", logPath); |
||||||
|
|
||||||
|
MultipartFile multi = getMultipartFile(logPath); |
||||||
|
//上传到服务器
|
||||||
|
R r = ossClient.fileUpload(multi, "mwh-order-logs"); |
||||||
|
if (r.isSuccess()) { |
||||||
|
BladeFile data = (BladeFile) r.getData(); |
||||||
|
// 删除本地文件
|
||||||
|
FileUtil.del(logPath); |
||||||
|
return data.getLink(); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@NotNull |
||||||
|
private MultipartFile getMultipartFile(String logPath) { |
||||||
|
File file = new File(logPath); |
||||||
|
|
||||||
|
// File 转 MultipartFile
|
||||||
|
FileItem item = new DiskFileItemFactory().createItem("file" |
||||||
|
, MediaType.MULTIPART_FORM_DATA_VALUE |
||||||
|
, true |
||||||
|
, file.getName()); |
||||||
|
try ( |
||||||
|
InputStream input = Files.newInputStream(file.toPath()); |
||||||
|
OutputStream os = item.getOutputStream()) { |
||||||
|
// 流转移
|
||||||
|
IOUtils.copy(input, os); |
||||||
|
} catch (Exception e) { |
||||||
|
throw new IllegalArgumentException("Invalid file: " + e, e); |
||||||
|
} |
||||||
|
|
||||||
|
return new CommonsMultipartFile(item); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,62 @@ |
|||||||
|
package com.logpm.factorydata.mwh.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||||
|
import com.logpm.factorydata.mwh.entity.FactoryToken; |
||||||
|
import com.logpm.factorydata.mwh.mapper.FactoryTokenMapper; |
||||||
|
import com.logpm.factorydata.mwh.service.IFactoryTokenService; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springblade.core.mp.base.BaseServiceImpl; |
||||||
|
import org.springblade.core.redis.cache.BladeRedis; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.security.NoSuchAlgorithmException; |
||||||
|
import java.util.Objects; |
||||||
|
|
||||||
|
@AllArgsConstructor |
||||||
|
@Service |
||||||
|
public class FactoryTokenServiceImpl extends BaseServiceImpl<FactoryTokenMapper, FactoryToken> implements IFactoryTokenService { |
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(FactoryTokenServiceImpl.class); |
||||||
|
|
||||||
|
private final BladeRedis bladeRedis; |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean verifyToken(String token, String corpId) throws NoSuchAlgorithmException { |
||||||
|
logger.info("#########verifyToken: 验证token开始"); |
||||||
|
//先生成token摘要
|
||||||
|
// String tokenAbst = MD5Utils.md5Hex(token.getBytes(StandardCharsets.UTF_8));
|
||||||
|
|
||||||
|
//编写查询条件
|
||||||
|
String key = "corpId:" + corpId; |
||||||
|
FactoryToken factoryToken = bladeRedis.get(key); |
||||||
|
|
||||||
|
if (Objects.isNull(factoryToken)) { |
||||||
|
QueryWrapper<FactoryToken> queryWrapper = new QueryWrapper<>(); |
||||||
|
queryWrapper.eq("token", token); |
||||||
|
factoryToken = baseMapper.selectOne(queryWrapper); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
if (Objects.isNull(factoryToken)) { |
||||||
|
logger.error("#########verifyToken: token1验证不通过 token={},corpid={}", token, corpId); |
||||||
|
return false; |
||||||
|
} |
||||||
|
logger.info("#########verifyToken: 验证token 传入token {} 验证token {}", token, factoryToken.getToken()); |
||||||
|
if (!factoryToken.getToken().equals(token)) { |
||||||
|
logger.error("#########verifyToken: token2验证不通过 token={},corpid={}", token, corpId); |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
Long expireTimeLong = factoryToken.getExpireTime().getTime(); |
||||||
|
Long now = System.currentTimeMillis(); |
||||||
|
//判断是否过期
|
||||||
|
if (now > expireTimeLong) { |
||||||
|
logger.error("#########verifyToken: token验证不通过 已过期 token={},corpId={}", token, corpId); |
||||||
|
return false; |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
package com.logpm.factorydata.mwh.service.impl; |
||||||
|
|
||||||
|
import com.logpm.factorydata.mwh.entity.PackageInfoEntity; |
||||||
|
import com.logpm.factorydata.mwh.mapper.PackageInfoMapper; |
||||||
|
import com.logpm.factorydata.mwh.service.PackageInfoService; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springblade.core.mp.base.BaseServiceImpl; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* 装箱包信息 业务实现类 |
||||||
|
* |
||||||
|
* @Author zqb |
||||||
|
* @Date 2024/4/26 |
||||||
|
**/ |
||||||
|
@Slf4j |
||||||
|
@Service |
||||||
|
@AllArgsConstructor |
||||||
|
public class PackageInfoServiceImpl extends BaseServiceImpl<PackageInfoMapper, PackageInfoEntity> implements PackageInfoService { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,93 @@ |
|||||||
|
package com.logpm.factorydata.mwh.vo; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||||
|
import com.logpm.factorydata.mwh.entity.DeliveryNoteEntity; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 送货单 实体类 |
||||||
|
* |
||||||
|
* @author zhaoqiaobo |
||||||
|
* @create 2024-04-26 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel(value = "曼好家发运信息", description = "曼好家发运信息") |
||||||
|
public class DeliveryNoteVO implements Serializable { |
||||||
|
|
||||||
|
@JsonProperty("StoreCode") |
||||||
|
@ApiModelProperty(value = "客户编码") |
||||||
|
private String storeCode; |
||||||
|
@JsonProperty("StoreName") |
||||||
|
@ApiModelProperty(value = "客户简称") |
||||||
|
private String storeName; |
||||||
|
@JsonProperty("UserId") |
||||||
|
@ApiModelProperty(value = "客户编码(100)") |
||||||
|
private String userId; |
||||||
|
@JsonProperty("UserName") |
||||||
|
@ApiModelProperty(value = "客户名称(汇通)") |
||||||
|
private String userName; |
||||||
|
@JsonProperty("Sources") |
||||||
|
@ApiModelProperty(value = "订单来源编码。例:品牌名称 (MWH)") |
||||||
|
private String sources; |
||||||
|
@JsonProperty("SourceName") |
||||||
|
@ApiModelProperty(value = "订单来源名称。例:品牌名称 (曼好家)") |
||||||
|
private String sourceName; |
||||||
|
@JsonProperty("CompanyCode") |
||||||
|
@ApiModelProperty(value = "公司编码") |
||||||
|
private String companyCode; |
||||||
|
@JsonProperty("CompanyName") |
||||||
|
@ApiModelProperty(value = "公司名称") |
||||||
|
private String companyName; |
||||||
|
@JsonProperty("SiteCode") |
||||||
|
@ApiModelProperty(value = "服务平台编码") |
||||||
|
private String siteCode; |
||||||
|
@JsonProperty("SiteName") |
||||||
|
@ApiModelProperty(value = "服务平台编码") |
||||||
|
private String siteName; |
||||||
|
@JsonProperty("OrderNo") |
||||||
|
@ApiModelProperty(value = "交割单号/服务号") |
||||||
|
private String orderNo; |
||||||
|
@JsonProperty("OrderSelfNum") |
||||||
|
@ApiModelProperty(value = "订单号") |
||||||
|
private String orderSelfNum; |
||||||
|
@JsonProperty("TotalQuantity") |
||||||
|
@ApiModelProperty(value = "计划总数量") |
||||||
|
private String totalQuantity; |
||||||
|
@JsonProperty("TotalWeight") |
||||||
|
@ApiModelProperty(value = "计划总数量") |
||||||
|
private String totalWeight; |
||||||
|
@JsonProperty("TotalCapacity") |
||||||
|
@ApiModelProperty(value = "计划总体积") |
||||||
|
private String totalCapacity; |
||||||
|
@JsonProperty("OrderType") |
||||||
|
@ApiModelProperty(value = "订单类型编码:测试环境传“RI”") |
||||||
|
private String orderType; |
||||||
|
@JsonProperty("OrderTypeName") |
||||||
|
@ApiModelProperty(value = "订单类型名称:测试环境传“采购入库单”") |
||||||
|
private String orderTypeName; |
||||||
|
@JsonProperty("ServiceType") |
||||||
|
@ApiModelProperty(value = "服务类型编码:测试环境传“00”") |
||||||
|
private String serviceType; |
||||||
|
@JsonProperty("ServiceTypeName") |
||||||
|
@ApiModelProperty(value = "服务类型名称:测试环境传“入库”") |
||||||
|
private String serviceTypeName; |
||||||
|
@JsonProperty("remark1") |
||||||
|
@ApiModelProperty(value = "业务实体") |
||||||
|
private String remark1; |
||||||
|
|
||||||
|
@ApiModelProperty("包件列表") |
||||||
|
@JsonProperty("Items") |
||||||
|
private List<PackageInfoVO> items; |
||||||
|
@ApiModelProperty("发货人") |
||||||
|
@JsonProperty("Sender") |
||||||
|
private SenderVO sender; |
||||||
|
@ApiModelProperty("发货人") |
||||||
|
@JsonProperty("Receiver") |
||||||
|
private ReceiverVO receiver; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
package com.logpm.factorydata.mwh.vo; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||||
|
import com.logpm.factorydata.mwh.entity.PackageInfoEntity; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* 装箱包信息 |
||||||
|
* |
||||||
|
* @author zhaoqiaobo |
||||||
|
* @create 2024-04-26 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel(value = "装箱包信息", description = "装箱包信息") |
||||||
|
public class PackageInfoVO implements Serializable { |
||||||
|
|
||||||
|
@JsonProperty("Color") |
||||||
|
@ApiModelProperty(value = "批次/色号:订单编号") |
||||||
|
private String color; |
||||||
|
@JsonProperty("SkuStatus") |
||||||
|
@ApiModelProperty(value = "商品状态:默认为Y -良品") |
||||||
|
private String skuStatus; |
||||||
|
@JsonProperty("StoreCode") |
||||||
|
@ApiModelProperty(value = "客户编码") |
||||||
|
private String storeCode; |
||||||
|
@JsonProperty("StoreName") |
||||||
|
@ApiModelProperty(value = "客户简称") |
||||||
|
private String storeName; |
||||||
|
@JsonProperty("Attributes") |
||||||
|
@ApiModelProperty(value = "包件明细") |
||||||
|
private String attributes; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
package com.logpm.factorydata.mwh.vo; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||||
|
import com.logpm.factorydata.mwh.entity.DeliveryNoteEntity; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* 收货人 |
||||||
|
* |
||||||
|
* @author zhaoqiaobo |
||||||
|
* @create 2024-04-26 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel(value = "曼好家订单收货人", description = "曼好家订单收货人") |
||||||
|
public class ReceiverVO implements Serializable { |
||||||
|
|
||||||
|
@JsonProperty("ReceiverAddress") |
||||||
|
@ApiModelProperty(value = "收货人详细地址") |
||||||
|
private String receiverAddress; |
||||||
|
@JsonProperty("ReceiverArea") |
||||||
|
@ApiModelProperty(value = "收货人区县") |
||||||
|
private String receiverArea; |
||||||
|
@JsonProperty("ReceiverCity") |
||||||
|
@ApiModelProperty(value = "收货人城市") |
||||||
|
private String receiverCity; |
||||||
|
@JsonProperty("ReceiverMobile") |
||||||
|
@ApiModelProperty(value = "收货人联系方式") |
||||||
|
private String receiverMobile; |
||||||
|
@JsonProperty("ReceiverName") |
||||||
|
@ApiModelProperty(value = "加盟商") |
||||||
|
private String receiverName; |
||||||
|
@JsonProperty("ConsigneeName") |
||||||
|
@ApiModelProperty(value = "收货人") |
||||||
|
private String consigneeName; |
||||||
|
@JsonProperty("ReceiverProvince") |
||||||
|
@ApiModelProperty(value = "收货人省份") |
||||||
|
private String receiverProvince; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,41 @@ |
|||||||
|
package com.logpm.factorydata.mwh.vo; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||||
|
import com.logpm.factorydata.mwh.entity.DeliveryNoteEntity; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 发货人 |
||||||
|
* |
||||||
|
* @author zhaoqiaobo |
||||||
|
* @create 2024-04-26 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel(value = "曼好家订单发货人", description = "曼好家订单发货人") |
||||||
|
public class SenderVO implements Serializable { |
||||||
|
|
||||||
|
@JsonProperty("SenderAddress") |
||||||
|
@ApiModelProperty(value = "发货人详细地址") |
||||||
|
private String senderAddress; |
||||||
|
@JsonProperty("SenderCity") |
||||||
|
@ApiModelProperty(value = "发货人城市") |
||||||
|
private String senderCity; |
||||||
|
@JsonProperty("SenderMobile") |
||||||
|
@ApiModelProperty(value = "发货人联系方式") |
||||||
|
private String senderMobile; |
||||||
|
@JsonProperty("SenderName") |
||||||
|
@ApiModelProperty(value = "发货工厂名称") |
||||||
|
private String senderName; |
||||||
|
@JsonProperty("SenderProvince") |
||||||
|
@ApiModelProperty(value = "发货人省份") |
||||||
|
private String senderProvince; |
||||||
|
@JsonProperty("SenderArea") |
||||||
|
@ApiModelProperty(value = "发货人区县") |
||||||
|
private String senderArea; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
package com.logpm.factorydata.mwh.wrapper; |
||||||
|
|
||||||
|
import org.springframework.http.HttpHeaders; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletRequestWrapper; |
||||||
|
import java.util.Collections; |
||||||
|
import java.util.Enumeration; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
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<String> getHeaderNames() { |
||||||
|
List<String> 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); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,75 @@ |
|||||||
|
package com.logpm.factorydata.mwh.wrapper; |
||||||
|
|
||||||
|
import javax.servlet.ReadListener; |
||||||
|
import javax.servlet.ServletInputStream; |
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletRequestWrapper; |
||||||
|
import java.io.BufferedReader; |
||||||
|
import java.io.ByteArrayInputStream; |
||||||
|
import java.io.IOException; |
||||||
|
import java.io.InputStream; |
||||||
|
import java.io.InputStreamReader; |
||||||
|
|
||||||
|
public class RequestWrapper extends HttpServletRequestWrapper { |
||||||
|
private final String body; |
||||||
|
public RequestWrapper(HttpServletRequest request) throws IOException { |
||||||
|
super(request); |
||||||
|
StringBuilder stringBuilder = new StringBuilder(); |
||||||
|
BufferedReader bufferedReader = null; |
||||||
|
try { |
||||||
|
InputStream inputStream = request.getInputStream(); |
||||||
|
if (inputStream != null) { |
||||||
|
bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); |
||||||
|
char[] charBuffer = new char[128]; |
||||||
|
int bytesRead = -1; |
||||||
|
while ((bytesRead = bufferedReader.read(charBuffer)) > 0) { |
||||||
|
stringBuilder.append(charBuffer, 0, bytesRead); |
||||||
|
} |
||||||
|
} else { |
||||||
|
stringBuilder.append(""); |
||||||
|
} |
||||||
|
} catch (IOException ex) { |
||||||
|
throw ex; |
||||||
|
} finally { |
||||||
|
if (bufferedReader != null) { |
||||||
|
try { |
||||||
|
bufferedReader.close(); |
||||||
|
} catch (IOException ex) { |
||||||
|
throw ex; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
body = stringBuilder.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ServletInputStream getInputStream() throws IOException { |
||||||
|
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes()); |
||||||
|
ServletInputStream servletInputStream = new ServletInputStream() { |
||||||
|
@Override |
||||||
|
public boolean isFinished() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
@Override |
||||||
|
public boolean isReady() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
@Override |
||||||
|
public void setReadListener(ReadListener readListener) {} |
||||||
|
@Override |
||||||
|
public int read() throws IOException { |
||||||
|
return byteArrayInputStream.read(); |
||||||
|
} |
||||||
|
}; |
||||||
|
return servletInputStream; |
||||||
|
|
||||||
|
} |
||||||
|
@Override |
||||||
|
public BufferedReader getReader() throws IOException { |
||||||
|
return new BufferedReader(new InputStreamReader(this.getInputStream())); |
||||||
|
} |
||||||
|
public String getBody() { |
||||||
|
return this.body; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,73 @@ |
|||||||
|
#服务器端口 |
||||||
|
server: |
||||||
|
port: 18960 |
||||||
|
|
||||||
|
#数据源配置 |
||||||
|
#spring: |
||||||
|
# datasource: |
||||||
|
# url: ${blade.datasource.dev.url} |
||||||
|
# username: ${blade.datasource.dev.username} |
||||||
|
# password: ${blade.datasource.dev.password} |
||||||
|
|
||||||
|
spring: |
||||||
|
#rabbitmq配置 |
||||||
|
rabbitmq: |
||||||
|
host: 192.168.2.46 |
||||||
|
port: 5672 |
||||||
|
username: admin |
||||||
|
password: admin |
||||||
|
#虚拟host 可以不设置,使用server默认host |
||||||
|
virtual-host: / |
||||||
|
#确认消息已发送到队列(Queue) |
||||||
|
publisher-returns: true |
||||||
|
publisher-confirm-type: correlated |
||||||
|
# 手动提交消息 |
||||||
|
listener: |
||||||
|
simple: |
||||||
|
acknowledge-mode: auto |
||||||
|
default-requeue-rejected: false |
||||||
|
retry: |
||||||
|
enabled: true # 开启消费者失败重试 |
||||||
|
initial-interval: 1000 # 初识的失败等待时长为1秒 |
||||||
|
multiplier: 1 # 失败的等待时长倍数,下次等待时长 = multiplier * last-interval |
||||||
|
max-attempts: 3 # 最大重试次数 |
||||||
|
stateless: true # true无状态;false有状态。如果业务中包含事务,这里改为false |
||||||
|
direct: |
||||||
|
acknowledge-mode: manual |
||||||
|
template: |
||||||
|
mandatory: true |
||||||
|
#排除DruidDataSourceAutoConfigure |
||||||
|
autoconfigure: |
||||||
|
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure,com.alibaba.cloud.seata.feign.SeataFeignClientAutoConfiguration |
||||||
|
datasource: |
||||||
|
dynamic: |
||||||
|
druid: |
||||||
|
#通用校验配置 |
||||||
|
validation-query: select 1 |
||||||
|
#启用sql日志拦截器 |
||||||
|
proxy-filters: |
||||||
|
- sqlLogInterceptor |
||||||
|
#设置默认的数据源或者数据源组,默认值即为master |
||||||
|
primary: master |
||||||
|
datasource: |
||||||
|
master: |
||||||
|
druid: |
||||||
|
#独立校验配置 |
||||||
|
validation-query: select 1 |
||||||
|
#oracle校验 |
||||||
|
#validation-query: select 1 from dual |
||||||
|
url: ${blade.datasource.factorydata-mwh.master.url} |
||||||
|
username: ${blade.datasource.factorydata-mwh.master.username} |
||||||
|
password: ${blade.datasource.factorydata-mwh.master.password} |
||||||
|
627683: |
||||||
|
druid: |
||||||
|
#独立校验配置 |
||||||
|
validation-query: select 1 |
||||||
|
#oracle校验 |
||||||
|
#validation-query: select 1 from dual |
||||||
|
url: ${blade.datasource.factorydata-mwh.627683.url} |
||||||
|
username: ${blade.datasource.factorydata-mwh.627683.username} |
||||||
|
password: ${blade.datasource.factorydata-mwh.627683.password} |
||||||
|
blade: |
||||||
|
data-scope: |
||||||
|
enabled: false |
@ -0,0 +1,47 @@ |
|||||||
|
#服务器端口 |
||||||
|
server: |
||||||
|
port: 18960 |
||||||
|
|
||||||
|
#数据源配置 |
||||||
|
#spring: |
||||||
|
# datasource: |
||||||
|
# url: ${blade.datasource.dev.url} |
||||||
|
# username: ${blade.datasource.dev.username} |
||||||
|
# password: ${blade.datasource.dev.password} |
||||||
|
|
||||||
|
spring: |
||||||
|
#排除DruidDataSourceAutoConfigure |
||||||
|
autoconfigure: |
||||||
|
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure,com.alibaba.cloud.seata.feign.SeataFeignClientAutoConfiguration |
||||||
|
datasource: |
||||||
|
dynamic: |
||||||
|
druid: |
||||||
|
#通用校验配置 |
||||||
|
validation-query: select 1 |
||||||
|
#启用sql日志拦截器 |
||||||
|
proxy-filters: |
||||||
|
- sqlLogInterceptor |
||||||
|
#设置默认的数据源或者数据源组,默认值即为master |
||||||
|
primary: master |
||||||
|
datasource: |
||||||
|
master: |
||||||
|
druid: |
||||||
|
#独立校验配置 |
||||||
|
validation-query: select 1 |
||||||
|
#oracle校验 |
||||||
|
#validation-query: select 1 from dual |
||||||
|
url: ${blade.datasource.factorydata-mwh.master.url} |
||||||
|
username: ${blade.datasource.factorydata-mwh.master.username} |
||||||
|
password: ${blade.datasource.factorydata-mwh.master.password} |
||||||
|
627683: |
||||||
|
druid: |
||||||
|
#独立校验配置 |
||||||
|
validation-query: select 1 |
||||||
|
#oracle校验 |
||||||
|
#validation-query: select 1 from dual |
||||||
|
url: ${blade.datasource.factorydata-mwh.627683.url} |
||||||
|
username: ${blade.datasource.factorydata-mwh.627683.username} |
||||||
|
password: ${blade.datasource.factorydata-mwh.627683.password} |
||||||
|
blade: |
||||||
|
data-scope: |
||||||
|
enabled: false |
@ -0,0 +1,73 @@ |
|||||||
|
#服务器端口 |
||||||
|
server: |
||||||
|
port: 18960 |
||||||
|
|
||||||
|
#数据源配置 |
||||||
|
#spring: |
||||||
|
# datasource: |
||||||
|
# url: ${blade.datasource.dev.url} |
||||||
|
# username: ${blade.datasource.dev.username} |
||||||
|
# password: ${blade.datasource.dev.password} |
||||||
|
|
||||||
|
spring: |
||||||
|
#rabbitmq配置 |
||||||
|
rabbitmq: |
||||||
|
host: 192.168.2.110 |
||||||
|
port: 5672 |
||||||
|
username: admin |
||||||
|
password: Slwk@123654 |
||||||
|
#虚拟host 可以不设置,使用server默认host |
||||||
|
virtual-host: / |
||||||
|
#确认消息已发送到队列(Queue) |
||||||
|
publisher-returns: true |
||||||
|
publisher-confirm-type: correlated |
||||||
|
# 手动提交消息 |
||||||
|
listener: |
||||||
|
simple: |
||||||
|
acknowledge-mode: auto |
||||||
|
default-requeue-rejected: false |
||||||
|
retry: |
||||||
|
enabled: true # 开启消费者失败重试 |
||||||
|
initial-interval: 1000 # 初识的失败等待时长为1秒 |
||||||
|
multiplier: 1 # 失败的等待时长倍数,下次等待时长 = multiplier * last-interval |
||||||
|
max-attempts: 3 # 最大重试次数 |
||||||
|
stateless: true # true无状态;false有状态。如果业务中包含事务,这里改为false |
||||||
|
direct: |
||||||
|
acknowledge-mode: manual |
||||||
|
template: |
||||||
|
mandatory: true |
||||||
|
#排除DruidDataSourceAutoConfigure |
||||||
|
autoconfigure: |
||||||
|
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure,com.alibaba.cloud.seata.feign.SeataFeignClientAutoConfiguration |
||||||
|
datasource: |
||||||
|
dynamic: |
||||||
|
druid: |
||||||
|
#通用校验配置 |
||||||
|
validation-query: select 1 |
||||||
|
#启用sql日志拦截器 |
||||||
|
proxy-filters: |
||||||
|
- sqlLogInterceptor |
||||||
|
#设置默认的数据源或者数据源组,默认值即为master |
||||||
|
primary: master |
||||||
|
datasource: |
||||||
|
master: |
||||||
|
druid: |
||||||
|
#独立校验配置 |
||||||
|
validation-query: select 1 |
||||||
|
#oracle校验 |
||||||
|
#validation-query: select 1 from dual |
||||||
|
url: ${blade.datasource.factorydata-mwh.master.url} |
||||||
|
username: ${blade.datasource.factorydata-mwh.master.username} |
||||||
|
password: ${blade.datasource.factorydata-mwh.master.password} |
||||||
|
627683: |
||||||
|
druid: |
||||||
|
#独立校验配置 |
||||||
|
validation-query: select 1 |
||||||
|
#oracle校验 |
||||||
|
#validation-query: select 1 from dual |
||||||
|
url: ${blade.datasource.factorydata-mwh.627683.url} |
||||||
|
username: ${blade.datasource.factorydata-mwh.627683.username} |
||||||
|
password: ${blade.datasource.factorydata-mwh.627683.password} |
||||||
|
blade: |
||||||
|
data-scope: |
||||||
|
enabled: false |
@ -0,0 +1,31 @@ |
|||||||
|
#mybatis-plus配置 |
||||||
|
mybatis-plus: |
||||||
|
mapper-locations: classpath:com/logpm/**/mapper/*Mapper.xml |
||||||
|
#实体扫描,多个package用逗号或者分号分隔 |
||||||
|
typeAliasesPackage: com.logpm.**.entity |
||||||
|
|
||||||
|
#swagger扫描路径配置 |
||||||
|
swagger: |
||||||
|
base-packages: |
||||||
|
- org.springblade |
||||||
|
- com.logpm |
||||||
|
|
||||||
|
#oss配置 |
||||||
|
oss: |
||||||
|
enabled: true |
||||||
|
name: minio |
||||||
|
tenant-mode: false |
||||||
|
endpoint: http://8.137.14.82:9000 |
||||||
|
access-key: minio |
||||||
|
secret-key: 123123123 |
||||||
|
bucket-name: bladex |
||||||
|
|
||||||
|
|
||||||
|
logging: |
||||||
|
config: classpath:logback.xml |
||||||
|
|
||||||
|
|
||||||
|
spring: |
||||||
|
main: |
||||||
|
allow-circular-references: true |
||||||
|
|
@ -0,0 +1,40 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<configuration scan="false" debug="false"> |
||||||
|
|
||||||
|
<contextName>logback</contextName> |
||||||
|
<property name="log.path" value="./data/logpm-basic/logs/logs.log"/> |
||||||
|
|
||||||
|
<!-- 彩色日志依赖的渲染类 --> |
||||||
|
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/> |
||||||
|
<conversionRule conversionWord="wex" |
||||||
|
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/> |
||||||
|
<conversionRule conversionWord="wEx" |
||||||
|
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/> |
||||||
|
<!-- 彩色日志格式 --> |
||||||
|
<property name="CONSOLE_LOG_PATTERN" |
||||||
|
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> |
||||||
|
<!-- 控制台输出 --> |
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender"> |
||||||
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> |
||||||
|
<pattern>${CONSOLE_LOG_PATTERN}</pattern> |
||||||
|
<charset>utf8</charset> |
||||||
|
</encoder> |
||||||
|
</appender> |
||||||
|
|
||||||
|
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||||
|
<file>${log.path}</file> |
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||||
|
<fileNamePattern>${log.path}.%d{yyyy-MM-dd}.zip</fileNamePattern> |
||||||
|
</rollingPolicy> |
||||||
|
<encoder> |
||||||
|
<pattern>%date %level [%thread] %logger{36} [%file : %line] %msg%n |
||||||
|
</pattern> |
||||||
|
</encoder> |
||||||
|
</appender> |
||||||
|
|
||||||
|
<root level="info"> |
||||||
|
<appender-ref ref="console"/> |
||||||
|
<appender-ref ref="file"/> |
||||||
|
</root> |
||||||
|
|
||||||
|
</configuration> |
Loading…
Reference in new issue