Browse Source

feat(all): 增加林氏工厂的订单数据接收

dist.1.3.0
zhaoqiaobo 11 months ago
parent
commit
ccb701579c
  1. 4
      blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java
  2. 8
      blade-biz-common/src/main/java/org/springblade/common/constant/factorydata/FactoryDataConstants.java
  3. 4
      blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/enums/BrandEnums.java
  4. 2
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/vo/DeliveryNoteVO.java
  5. 97
      blade-service/logpm-factory-data/logpm-factory-data-linsy/pom.xml
  6. 14
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/Dockerfile
  7. 20
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/FactoryDataLinSyApplication.java
  8. 51
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/aspect/AsyncAnnotationAspect.java
  9. 48
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/aspect/RabbitAnnotationAspect.java
  10. 161
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/config/CustomMessageConverter.java
  11. 79
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/config/ExecutorConfig.java
  12. 40
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/config/FactoryDataOloConfiguration.java
  13. 32
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/config/InterceptorAdapterConfig.java
  14. 17
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/config/RabbitConfig.java
  15. 71
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/controller/OrderController.java
  16. 23
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/dto/PushOrderDTO.java
  17. 21
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/dto/PushPackageDTO.java
  18. 89
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/DeliveryNoteEntity.java
  19. 58
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/FactoryOrderLogEntity.java
  20. 32
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/FactoryToken.java
  21. 70
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/PackageInfoEntity.java
  22. 27
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/PushStatusEnums.java
  23. 87
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/interceptor/FactoryAccountsInterceptor.java
  24. 100
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/interceptor/LocalServerLoginAccountsInterceptor.java
  25. 60
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/launcher/FactoryDataBaseLauncherServiceImpl.java
  26. 16
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/DeliveryNoteMapper.java
  27. 5
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryNodeOrderMapper.xml
  28. 16
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryOrderLogMapper.java
  29. 5
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryOrderLogMapper.xml
  30. 31
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryTokenMapper.java
  31. 20
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryTokenMapper.xml
  32. 16
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/PackageInfoMapper.java
  33. 5
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/PackageInfoMapper.xml
  34. 141
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/FactoryOrderListener.java
  35. 20
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/pros/FactoryDataProperties.java
  36. 20
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/DeliveryNoteService.java
  37. 19
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/FactoryOrderLogService.java
  38. 15
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/IFactoryTokenService.java
  39. 14
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/PackageInfoService.java
  40. 164
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/DeliveryNoteServiceImpl.java
  41. 120
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/FactoryOrderLogServiceImpl.java
  42. 62
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/FactoryTokenServiceImpl.java
  43. 22
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/PackageInfoServiceImpl.java
  44. 24
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/vo/CancelOrderVO.java
  45. 24
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/vo/DeliveryNoteVO.java
  46. 18
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/vo/PackageInfoVO.java
  47. 38
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/wrapper/CustomHttpServletRequestWrapper.java
  48. 75
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/wrapper/RequestWrapper.java
  49. 73
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/resources/application-dev.yml
  50. 47
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/resources/application-prod.yml
  51. 73
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/resources/application-test.yml
  52. 31
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/resources/application.yml
  53. 40
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/resources/logback.xml
  54. 1
      blade-service/logpm-factory-data/pom.xml

4
blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java

@ -105,6 +105,10 @@ public interface ModuleNameConstant {
* 我乐工厂数据模块
*/
String LOGPM_FACTORY_DATA_OLO_NAME = "logpm-factory-data-olo" + DEVAUTH;
/**
* 林氏工厂数据模块
*/
String LOGPM_FACTORY_DATA_LINSY_NAME = "logpm-factory-data-linsy" + DEVAUTH;
/**
* 金牌工厂数据模块
*/

8
blade-biz-common/src/main/java/org/springblade/common/constant/factorydata/FactoryDataConstants.java

@ -65,6 +65,10 @@ public abstract class FactoryDataConstants {
* 我乐工厂订单
*/
String OLO_FACTORY_ORDER = "factory.data.queue.olo.factoryOrder" + DEVAUTH;
/**
* 林氏工厂订单
*/
String LINSY_FACTORY_ORDER = "factory.data.queue.linsy.factoryOrder" + DEVAUTH;
/**
* 金牌工厂订单
*/
@ -104,6 +108,10 @@ public abstract class FactoryDataConstants {
* 我乐工厂订单
*/
String OLO_FACTORY_ORDER = "olo.factoryOrder" + DEVAUTH;
/**
* 林氏工厂订单
*/
String LINSY_FACTORY_ORDER = "linsy.factoryOrder" + DEVAUTH;
/**
* 金牌工厂订单
*/

4
blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/enums/BrandEnums.java

@ -22,7 +22,9 @@ public enum BrandEnums implements Serializable {
SFY(6, "索菲亚"),
JP(7, "金牌"),
OLO(8, "我乐"),
MHJ(9, "曼好家");
MHJ(9, "曼好家"),
LINSY(10, "林氏家居"),
;
private Integer code;
private String value;

2
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/vo/DeliveryNoteVO.java

@ -21,4 +21,6 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true)
public class DeliveryNoteVO extends DeliveryNoteEntity {
}

97
blade-service/logpm-factory-data/logpm-factory-data-linsy/pom.xml

@ -0,0 +1,97 @@
<?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>
<artifactId>logpm-factory-data-linsy</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>

14
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/Dockerfile

@ -0,0 +1,14 @@
FROM bladex/alpine-java:openjdk8-openj9_cn_slim
MAINTAINER h5u@163.com
RUN mkdir -p /logpm/logpm-factory-data-linsy
WORKDIR /logpm/logpm-factory-data-linsy
EXPOSE 18950
ADD ./target/logpm-factory-data-linsy.jar ./app.jar
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar","-Xms128m","-Xmx512m", "app.jar"]
CMD ["--spring.profiles.active=test"]

20
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/FactoryDataLinSyApplication.java

@ -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 FactoryDataLinSyApplication {
public static void main(String[] args) {
BladeApplication.run(ModuleNameConstant.LOGPM_FACTORY_DATA_LINSY_NAME, FactoryDataLinSyApplication.class, args);
}
}

51
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/aspect/AsyncAnnotationAspect.java

@ -0,0 +1,51 @@
package com.logpm.factorydata.linsy.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;
}
}

48
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/aspect/RabbitAnnotationAspect.java

@ -0,0 +1,48 @@
package com.logpm.factorydata.linsy.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;
}
}

161
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/config/CustomMessageConverter.java

@ -0,0 +1,161 @@
package com.logpm.factorydata.linsy.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;
}
};
}
}

79
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/config/ExecutorConfig.java

@ -0,0 +1,79 @@
package com.logpm.factorydata.linsy.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();
}
};
}
}
}

40
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/config/FactoryDataOloConfiguration.java

@ -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.linsy.config;
import com.logpm.factorydata.linsy.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;
/**
* 配置feignmybatis包名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 FactoryDataOloConfiguration {
}

32
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/config/InterceptorAdapterConfig.java

@ -0,0 +1,32 @@
package com.logpm.factorydata.linsy.config;
import com.logpm.factorydata.linsy.interceptor.FactoryAccountsInterceptor;
import com.logpm.factorydata.linsy.interceptor.LocalServerLoginAccountsInterceptor;
import com.logpm.factorydata.linsy.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);
}
}

17
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/config/RabbitConfig.java

@ -0,0 +1,17 @@
package com.logpm.factorydata.linsy.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;
}
}

71
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/controller/OrderController.java

@ -0,0 +1,71 @@
package com.logpm.factorydata.linsy.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.logpm.factorydata.linsy.service.DeliveryNoteService;
import com.logpm.factorydata.linsy.service.FactoryOrderLogService;
import com.logpm.factorydata.linsy.vo.CancelOrderVO;
import com.logpm.factorydata.linsy.vo.DeliveryNoteVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
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;
import java.util.stream.Collectors;
/**
* 工厂订单 前端控制器
*
* @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);
}
@ResponseBody
@PatchMapping
@ApiOperationSupport(order = 2)
@ApiOperation(value = "取消订单", notes = "取消订单")
public R cancelOrder(@RequestBody CancelOrderVO vo) {
log.info("取消订单:{} ", JSONUtil.toJsonStr(vo));
String res = "";
res = service.cancelOrder(vo);
return R.success(res);
}
}

23
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/dto/PushOrderDTO.java

@ -0,0 +1,23 @@
package com.logpm.factorydata.linsy.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 回传订单状态
*
* @author zhaoqiaobo
* @create 2024-05-16
*/
@Data
public class PushOrderDTO implements Serializable {
private String billCode;
private String status;
private List<PushPackageDTO> packages;
}

21
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/dto/PushPackageDTO.java

@ -0,0 +1,21 @@
package com.logpm.factorydata.linsy.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 回传包件
*
* @author zhaoqiaobo
* @create 2024-05-16
*/
@Data
public class PushPackageDTO implements Serializable {
/**
* 包条码
*/
private String barcode;
}

89
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/DeliveryNoteEntity.java

@ -0,0 +1,89 @@
package com.logpm.factorydata.linsy.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;
/**
* 送货单 实体类
*
* @author zhaoqiaobo
* @create 2024-04-26
*/
@Data
@TableName("linsy_delivery_note")
@ApiModel(value = "林氏发运单", description = "林氏发运单")
@EqualsAndHashCode(callSuper = true)
public class DeliveryNoteEntity extends BaseEntity {
@ApiModelProperty("日志id")
private String logId;
@ApiModelProperty(value = "单据编号")
private String billCode;
@ApiModelProperty(value = "单据日期")
private String billDate;
@ApiModelProperty(value = "总包件数")
private String totalPackage;
@ApiModelProperty(value = "总体积")
private String totalVolume;
@ApiModelProperty(value = "经销商")
private String agencyName;
@ApiModelProperty(value = "定制单号")
private String customizedBillCode;
@ApiModelProperty(value = "供应商")
private String supplierName;
@ApiModelProperty(value = "店铺")
private String shopName;
@ApiModelProperty(value = "收货人")
private String receiverName;
@ApiModelProperty(value = "电话")
private String receiverTelephone;
@ApiModelProperty(value = "收货省")
private String receiverProvinceName;
@ApiModelProperty(value = "收货市")
private String receiverCityName;
@ApiModelProperty(value = "收货区")
private String receiverDistrictName;
@ApiModelProperty(value = "收货街道")
private String receiverStreetName;
@ApiModelProperty(value = "收货详细地址")
private String receiverDetailAddress;
@ApiModelProperty(value = "业务员")
private String customerSalesman;
@ApiModelProperty(value = "业务联系电话")
private String customerSalesmanTelephone;
@ApiModelProperty(value = "发货省")
private String senderProvinceName;
@ApiModelProperty(value = "发货市")
private String senderCityName;
@ApiModelProperty(value = "发货区")
private String senderDistrictName;
@ApiModelProperty(value = "发货详细地址")
private String senderDetailAddress;
@ApiModelProperty(value = "发货人")
private String senderName;
@ApiModelProperty(value = "发货人电话")
private String senderTelephone;
@ApiModelProperty(value = "创建时间")
private String createdTime;
@ApiModelProperty(value = "原单编号")
private String sourceBillCode;
@ApiModelProperty(value = "合并单号")
private String mergeOrderCode;
@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;
}

58
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/FactoryOrderLogEntity.java

@ -0,0 +1,58 @@
package com.logpm.factorydata.linsy.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("linsy_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;
}

32
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/FactoryToken.java

@ -0,0 +1,32 @@
package com.logpm.factorydata.linsy.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;
}

70
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/PackageInfoEntity.java

@ -0,0 +1,70 @@
package com.logpm.factorydata.linsy.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;
/**
* 装箱包信息
*
* @author zhaoqiaobo
* @create 2024-04-26
*/
@Data
@TableName("linsy_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;
@ApiModelProperty(value = "父项物料编码")
private String parentMaterialCode;
@ApiModelProperty(value = "父项物料名称")
private String parentMaterialName;
@ApiModelProperty(value = "检验单号")
private String checkBillCode;
@ApiModelProperty(value = "采购单号")
private String sellerBillCode;
@ApiModelProperty(value = "批号")
private String lotCode;
@ApiModelProperty(value = "客户业务员")
private String customerSalesman;
@ApiModelProperty(value = "外部原单行号")
private String outSourceCode;
@ApiModelProperty(value = "定制单号")
private String customizedBillCode;
@ApiModelProperty(value = "物料编码")
private String materialCode;
@ApiModelProperty(value = "物料名称")
private String materialName;
@ApiModelProperty(value = "包件条码")
private String barcode;
@ApiModelProperty(value = "体积")
private String volume;
@ApiModelProperty(value = "重量")
private String weight;
@ApiModelProperty(value = "长度")
private String length;
@ApiModelProperty(value = "宽度")
private String width;
@ApiModelProperty(value = "高度")
private String height;
@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;
}

27
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/PushStatusEnums.java

@ -0,0 +1,27 @@
package com.logpm.factorydata.linsy.enums;
import org.springblade.common.model.IDict;
/**
* 回传状态码表
*
* @author zhaoqiaobo
* @create 2024-04-01
*/
public enum PushStatusEnums implements IDict<String> {
/**
* 已交接
*/
DELIVERIED("Deliveried", "已交接"),
/**
* 收货完成
*/
RECEIVED("Received", "收货完成"),
;
PushStatusEnums(String code, String text) {
init(code, text);
}
}

87
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/interceptor/FactoryAccountsInterceptor.java

@ -0,0 +1,87 @@
package com.logpm.factorydata.linsy.interceptor;
import com.alibaba.fastjson.JSONObject;
import com.logpm.factorydata.linsy.service.IFactoryTokenService;
import com.logpm.factorydata.linsy.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);
}
}

100
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/interceptor/LocalServerLoginAccountsInterceptor.java

@ -0,0 +1,100 @@
package com.logpm.factorydata.linsy.interceptor;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import com.logpm.factorydata.linsy.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();
}
}
}
}

60
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/launcher/FactoryDataBaseLauncherServiceImpl.java

@ -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.linsy.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;
}
}

16
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/DeliveryNoteMapper.java

@ -0,0 +1,16 @@
package com.logpm.factorydata.linsy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factorydata.linsy.entity.DeliveryNoteEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 发货单 mapper
*
* @author zqb
* @since 2024-03-26
*/
@Mapper
public interface DeliveryNoteMapper extends BaseMapper<DeliveryNoteEntity> {
}

5
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryNodeOrderMapper.xml

@ -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.linsy.mapper.DeliveryNoteMapper">
</mapper>

16
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryOrderLogMapper.java

@ -0,0 +1,16 @@
package com.logpm.factorydata.linsy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factorydata.linsy.entity.FactoryOrderLogEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 工厂订单日志 mapper
*
* @author zqb
* @since 2024-03-26
*/
@Mapper
public interface FactoryOrderLogMapper extends BaseMapper<FactoryOrderLogEntity> {
}

5
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryOrderLogMapper.xml

@ -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.linsy.mapper.FactoryOrderLogMapper">
</mapper>

31
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryTokenMapper.java

@ -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.linsy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factorydata.linsy.entity.FactoryToken;
/**
* 工厂账号接口日志 Mapper 接口
*
* @author zhy
* @since 2023-03-28
*/
public interface FactoryTokenMapper extends BaseMapper<FactoryToken> {
}

20
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryTokenMapper.xml

@ -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.linsy.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>

16
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/PackageInfoMapper.java

@ -0,0 +1,16 @@
package com.logpm.factorydata.linsy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factorydata.linsy.entity.PackageInfoEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 装箱包信息 mapper
*
* @author zqb
* @since 2024-03-26
*/
@Mapper
public interface PackageInfoMapper extends BaseMapper<PackageInfoEntity> {
}

5
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/PackageInfoMapper.xml

@ -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.linsy.mapper.PackageInfoMapper">
</mapper>

141
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/FactoryOrderListener.java

@ -0,0 +1,141 @@
package com.logpm.factorydata.linsy.mq;
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.io.FileUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
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.base.feign.IFactoryDataBaseClient;
import com.logpm.factorydata.base.vo.FactoryWarehouseBindVO;
import com.logpm.factorydata.enums.BrandEnums;
import com.logpm.factorydata.enums.SaxStatusEnums;
import com.logpm.factorydata.feign.IFactoryDataClient;
import com.logpm.factorydata.linsy.entity.DeliveryNoteEntity;
import com.logpm.factorydata.linsy.entity.FactoryOrderLogEntity;
import com.logpm.factorydata.linsy.entity.PackageInfoEntity;
import com.logpm.factorydata.linsy.service.DeliveryNoteService;
import com.logpm.factorydata.linsy.service.FactoryOrderLogService;
import com.logpm.factorydata.linsy.service.PackageInfoService;
import com.logpm.factorydata.linsy.vo.DeliveryNoteVO;
import com.logpm.factorydata.linsy.vo.PackageInfoVO;
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.redis.cache.BladeRedis;
import org.springblade.core.tool.api.R;
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.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 监听订单数据
*
* @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.LINSY_FACTORY_ORDER),
exchange = @Exchange(name = FactoryDataConstants.Mq.Exchanges.FACTORY_ORDER, type = ExchangeTypes.TOPIC),
key = FactoryDataConstants.Mq.RoutingKeys.LINSY_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 billCode = vo.getBillCode();
List<DeliveryNoteEntity> list = deliveryNoteService.list(Wrappers.<DeliveryNoteEntity>lambdaQuery()
.eq(DeliveryNoteEntity::getBillCode, billCode));
if (CollUtil.isNotEmpty(list)) {
log.error("单号{} 数据已经处理过了, logId: {}", billCode, logId);
return;
}
vo.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null);
deliveryNoteService.save(vo);
List<PackageInfoVO> orderInfos = vo.getPackages();
if (CollUtil.isNotEmpty(orderInfos)) {
List<PackageInfoEntity> infoEntities = new ArrayList<>();
for (PackageInfoVO orderInfo : orderInfos) {
PackageInfoEntity orderInfoEntity = new PackageInfoEntity();
BeanUtil.copyProperties(orderInfo, orderInfoEntity);
orderInfoEntity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null);
orderInfoEntity.setDeliveryNoteId(vo.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);
}
}

20
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/pros/FactoryDataProperties.java

@ -0,0 +1,20 @@
package com.logpm.factorydata.linsy.pros;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* FactoryProperties
*
* @author pref
*/
@Data
@ConfigurationProperties(prefix = "logpm")
public class FactoryDataProperties {
/**
* 名称
*/
private String name;
}

20
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/DeliveryNoteService.java

@ -0,0 +1,20 @@
package com.logpm.factorydata.linsy.service;
import com.logpm.factorydata.linsy.entity.DeliveryNoteEntity;
import com.logpm.factorydata.linsy.vo.DeliveryNoteVO;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
/**
* 索菲亚发货单 服务类
*
* @Author zqb
* @Date 2024/4/26
**/
public interface DeliveryNoteService extends BaseService<DeliveryNoteEntity> {
void buildAdvance(DeliveryNoteVO entities);
}

19
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/FactoryOrderLogService.java

@ -0,0 +1,19 @@
package com.logpm.factorydata.linsy.service;
import com.logpm.factorydata.linsy.entity.FactoryOrderLogEntity;
import com.logpm.factorydata.linsy.vo.CancelOrderVO;
import com.logpm.factorydata.linsy.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);
String cancelOrder(CancelOrderVO vo);
}

15
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/IFactoryTokenService.java

@ -0,0 +1,15 @@
package com.logpm.factorydata.linsy.service;
import com.logpm.factorydata.linsy.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;
}

14
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/PackageInfoService.java

@ -0,0 +1,14 @@
package com.logpm.factorydata.linsy.service;
import com.logpm.factorydata.linsy.entity.PackageInfoEntity;
import org.springblade.core.mp.base.BaseService;
/**
* 装箱包信息 服务类
*
* @Author zqb
* @Date 2024/4/26
**/
public interface PackageInfoService extends BaseService<PackageInfoEntity> {
}

164
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/DeliveryNoteServiceImpl.java

@ -0,0 +1,164 @@
package com.logpm.factorydata.linsy.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
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.linsy.entity.DeliveryNoteEntity;
import com.logpm.factorydata.linsy.mapper.DeliveryNoteMapper;
import com.logpm.factorydata.linsy.service.DeliveryNoteService;
import com.logpm.factorydata.linsy.vo.DeliveryNoteVO;
import com.logpm.factorydata.linsy.vo.PackageInfoVO;
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.LINSY.getValue(), vo.getSupplierName());
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.getPackages();
// 组装暂存单数据
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("");
advanceEntity.setBrand(BrandEnums.LINSY.getValue());
advanceEntity.setSiteName(vo.getSupplierName());
advanceEntity.setArea("");
advanceEntity.setTotalNum(CollUtil.isNotEmpty(packages) ? packages.size() : 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("汇通");
advanceEntity.setSenderName("");
advanceEntity.setSenderPhone("");
advanceEntity.setSenderAddress("");
advanceEntity.setTrainNumber(StrUtil.replace(DateUtil.today(), "-", ""));
advanceEntity.setSenderFactory(BrandEnums.LINSY.getValue());
advanceEntity.setOrderCode(vo.getBillCode());
advanceEntity.setDealerCode("");
advanceEntity.setDealerName(vo.getShopName());
advanceEntity.setStoreCode("");
advanceEntity.setStoreName(vo.getShopName());
advanceEntity.setServiceNum(vo.getCustomizedBillCode());
advanceEntity.setCustomerName(vo.getReceiverName());
advanceEntity.setCustomerPhone(vo.getReceiverTelephone());
advanceEntity.setCustomerAddress(vo.getReceiverDetailAddress());
advanceEntity.setSenderName(vo.getSenderName());
advanceEntity.setSenderPhone(vo.getSenderTelephone());
advanceEntity.setSenderAddress(vo.getSenderDetailAddress());
List<JSONObject> packageList = new ArrayList<>();
for (PackageInfoVO orderPackageDTO : packages) {
// 封装包件
TrunklineAdvanceDetailEntity advanceDetailEntity = new TrunklineAdvanceDetailEntity();
advanceDetailEntity.setWarehouseId(startWarehouseId);
advanceDetailEntity.setWarehouseName(startWarehouseName);
// advanceDetailEntity.setIncomingWarehouseId(0L);
// advanceDetailEntity.setIncomingWarehouseName("");
advanceDetailEntity.setOrderCode(vo.getBillCode());
advanceDetailEntity.setBrand(BrandEnums.LINSY.getValue());
advanceDetailEntity.setSystemType("线上");
advanceDetailEntity.setFirstPackName(orderPackageDTO.getMaterialName());
//二级品类名称
advanceDetailEntity.setSecondPackName(orderPackageDTO.getMaterialName());
//三级品类名称
advanceDetailEntity.setThirdPackName(orderPackageDTO.getMaterialName());
advanceDetailEntity.setMaterialName(orderPackageDTO.getMaterialName());
advanceDetailEntity.setMaterialCode(orderPackageDTO.getMaterialCode());
advanceDetailEntity.setSiteName(vo.getSupplierName());
advanceDetailEntity.setSiteCode("");
advanceDetailEntity.setQuantity(1);
advanceDetailEntity.setOrderPackageCode(orderPackageDTO.getBarcode());
advanceDetailEntity.setTrainNumber(StrUtil.replace(DateUtil.today(), "-", ""));
advanceDetailEntity.setServiceNum(vo.getCustomizedBillCode());
advanceDetailEntity.setWaybillNo("");
advanceDetailEntity.setPackageStatus("0");
advanceDetailEntity.setWeight(StrUtil.isNotBlank(orderPackageDTO.getWeight()) ? new BigDecimal(orderPackageDTO.getWeight()) : BigDecimal.ZERO);
advanceDetailEntity.setVolume(StrUtil.isNotBlank(orderPackageDTO.getVolume()) ? new BigDecimal(orderPackageDTO.getVolume()) : 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);
}
}
}
}

120
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/FactoryOrderLogServiceImpl.java

@ -0,0 +1,120 @@
package com.logpm.factorydata.linsy.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.linsy.entity.FactoryOrderLogEntity;
import com.logpm.factorydata.linsy.mapper.FactoryOrderLogMapper;
import com.logpm.factorydata.linsy.service.FactoryOrderLogService;
import com.logpm.factorydata.linsy.vo.CancelOrderVO;
import com.logpm.factorydata.linsy.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.LINSY_FACTORY_ORDER)
.message(JSONUtil.toJsonStr(logEntity)).build();
factoryDataClient.sendMessage(build);
return "成功";
}
@Override
public String cancelOrder(CancelOrderVO vo) {
// TODO 取消订单逻辑后续实现 同步接口,实时返回取消状态
if (ObjectUtil.equal(vo.getSourceCode(), "1")) {
return "取消成功";
} else {
throw new ServiceException("取消失败");
}
}
private String uploadFile(String body) {
//文本内容和保存为本地文件 并上传
String logPath = FileLogsUtil.saveFileLogs(body);
log.info(">>> 文件路径 {}", logPath);
MultipartFile multi = getMultipartFile(logPath);
//上传到服务器
R r = ossClient.fileUpload(multi, "olo-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);
}
}

62
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/FactoryTokenServiceImpl.java

@ -0,0 +1,62 @@
package com.logpm.factorydata.linsy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.logpm.factorydata.linsy.entity.FactoryToken;
import com.logpm.factorydata.linsy.mapper.FactoryTokenMapper;
import com.logpm.factorydata.linsy.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;
}
}

22
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/PackageInfoServiceImpl.java

@ -0,0 +1,22 @@
package com.logpm.factorydata.linsy.service.impl;
import com.logpm.factorydata.linsy.entity.PackageInfoEntity;
import com.logpm.factorydata.linsy.mapper.PackageInfoMapper;
import com.logpm.factorydata.linsy.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 {
}

24
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/vo/CancelOrderVO.java

@ -0,0 +1,24 @@
package com.logpm.factorydata.linsy.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
/**
* 取消订单 实体类
*
* @author zhaoqiaobo
* @create 2024-04-26
*/
@Data
@ApiModel(value = "取消订单", description = "取消订单")
public class CancelOrderVO implements Serializable {
@ApiModelProperty("订单编号")
@NotEmpty(message = "订单编号不能为空")
private String sourceCode;
}

24
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/vo/DeliveryNoteVO.java

@ -0,0 +1,24 @@
package com.logpm.factorydata.linsy.vo;
import com.logpm.factorydata.linsy.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 extends DeliveryNoteEntity {
@ApiModelProperty("包件列表")
private List<PackageInfoVO> packages;
}

18
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/vo/PackageInfoVO.java

@ -0,0 +1,18 @@
package com.logpm.factorydata.linsy.vo;
import com.logpm.factorydata.linsy.entity.PackageInfoEntity;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 装箱包信息
*
* @author zhaoqiaobo
* @create 2024-04-26
*/
@Data
@ApiModel(value = "装箱包信息", description = "装箱包信息")
@EqualsAndHashCode(callSuper = true)
public class PackageInfoVO extends PackageInfoEntity {
}

38
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/wrapper/CustomHttpServletRequestWrapper.java

@ -0,0 +1,38 @@
package com.logpm.factorydata.linsy.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);
}
}

75
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/wrapper/RequestWrapper.java

@ -0,0 +1,75 @@
package com.logpm.factorydata.linsy.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;
}
}

73
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/resources/application-dev.yml

@ -0,0 +1,73 @@
#服务器端口
server:
port: 18950
#数据源配置
#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-linsy.master.url}
username: ${blade.datasource.factorydata-linsy.master.username}
password: ${blade.datasource.factorydata-linsy.master.password}
627683:
druid:
#独立校验配置
validation-query: select 1
#oracle校验
#validation-query: select 1 from dual
url: ${blade.datasource.factorydata-linsy.627683.url}
username: ${blade.datasource.factorydata-linsy.627683.username}
password: ${blade.datasource.factorydata-linsy.627683.password}
blade:
data-scope:
enabled: false

47
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/resources/application-prod.yml

@ -0,0 +1,47 @@
#服务器端口
server:
port: 18950
#数据源配置
#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-linsy.master.url}
username: ${blade.datasource.factorydata-linsy.master.username}
password: ${blade.datasource.factorydata-linsy.master.password}
627683:
druid:
#独立校验配置
validation-query: select 1
#oracle校验
#validation-query: select 1 from dual
url: ${blade.datasource.factorydata-linsy.627683.url}
username: ${blade.datasource.factorydata-linsy.627683.username}
password: ${blade.datasource.factorydata-linsy.627683.password}
blade:
data-scope:
enabled: false

73
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/resources/application-test.yml

@ -0,0 +1,73 @@
#服务器端口
server:
port: 18950
#数据源配置
#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-linsy.master.url}
username: ${blade.datasource.factorydata-linsy.master.username}
password: ${blade.datasource.factorydata-linsy.master.password}
627683:
druid:
#独立校验配置
validation-query: select 1
#oracle校验
#validation-query: select 1 from dual
url: ${blade.datasource.factorydata-linsy.627683.url}
username: ${blade.datasource.factorydata-linsy.627683.username}
password: ${blade.datasource.factorydata-linsy.627683.password}
blade:
data-scope:
enabled: false

31
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/resources/application.yml

@ -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

40
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/resources/logback.xml

@ -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>

1
blade-service/logpm-factory-data/pom.xml

@ -17,6 +17,7 @@
<module>logpm-factory-data-suofeiya</module>
<module>logpm-factory-data-olo</module>
<module>logpm-factory-data-jinpai</module>
<module>logpm-factory-data-linsy</module>
</modules>
<properties>

Loading…
Cancel
Save