Browse Source

feat(all): 修改金牌接收订单数据处理逻辑

dist.1.3.0
zhaoqiaobo 11 months ago
parent
commit
8699674c72
  1. 56
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/aspect/AnnotationAspect.java
  2. 79
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/config/ExecutorConfig.java
  3. 32
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/config/InterceptorAdapterConfig.java
  4. 74
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/config/XxlJobConfig.java
  5. 31
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/controller/OrderController.java
  6. 16
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/entity/DeliveryNoteEntity.java
  7. 4
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/entity/FactoryOrderLogEntity.java
  8. 32
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/entity/FactoryToken.java
  9. 2
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/entity/PackageInfoEntity.java
  10. 109
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/entity/PushOrderDetailEntity.java
  11. 62
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/entity/PushOrderEntity.java
  12. 24
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/enums/BusSourceEnums.java
  13. 87
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/interceptor/FactoryAccountsInterceptor.java
  14. 100
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/interceptor/LocalServerLoginAccountsInterceptor.java
  15. 300
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/job/AdvanceJob.java
  16. 6
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/DeliveryNoteMapper.java
  17. 5
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/FactoryNodeOrderMapper.xml
  18. 31
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/FactoryTokenMapper.java
  19. 20
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/FactoryTokenMapper.xml
  20. 1
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/OrderInfoMapper.java
  21. 16
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/PushOrderDetailMapper.java
  22. 5
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/PushOrderDetailMapper.xml
  23. 16
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/PushOrderMapper.java
  24. 5
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/PushOrderMapper.xml
  25. 657
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mq/FactoryOrderListener.java
  26. 14
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/DeliveryNoteService.java
  27. 15
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/IFactoryTokenService.java
  28. 14
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/PushOrderDetailService.java
  29. 14
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/PushOrderService.java
  30. 41
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/impl/DeliveryNoteServiceImpl.java
  31. 62
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/impl/FactoryTokenServiceImpl.java
  32. 22
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/impl/PushOrderDetailServiceImpl.java
  33. 22
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/impl/PushOrderServiceImpl.java
  34. 43
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/util/ThreadPoolUtil.java
  35. 26
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/vo/PackageCategoryVO.java
  36. 28
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/vo/PushOrderDetailVO.java
  37. 25
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/vo/PushOrderVO.java
  38. 32
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/vo/ThirdPlWarehouseMappingVO.java
  39. 38
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/wrapper/CustomHttpServletRequestWrapper.java
  40. 75
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/wrapper/RequestWrapper.java
  41. 12
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/resources/application-dev.yml
  42. 12
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/resources/application-prod.yml
  43. 12
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/resources/application-test.yml

56
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/aspect/AnnotationAspect.java

@ -8,19 +8,22 @@ import lombok.AllArgsConstructor;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springblade.common.cache.CacheNames; import org.springblade.common.cache.CacheNames;
import org.springblade.common.constant.LauncherConstant; import org.springblade.common.constant.LauncherConstant;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.redis.cache.BladeRedis; import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.core.tool.utils.ThreadLocalUtil; import org.springblade.core.tool.utils.ThreadLocalUtil;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import java.lang.reflect.Method;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -31,6 +34,39 @@ import java.util.Objects;
public class AnnotationAspect { public class AnnotationAspect {
private final BladeRedis bladeRedis; private final BladeRedis bladeRedis;
private final Environment environment; private final Environment environment;
/**
* 定义一个切点匹配所有带有@Async("asyncExecutor")注解的方法
* 注意实际上Spring Framework自带对@Async("asyncExecutor")的处理直接这样配置可能会导致预期之外的行为
*/
@Around("@annotation(org.springframework.scheduling.annotation.Async)")
public Object asyncAroundAsyncMethods(ProceedingJoinPoint joinPoint) throws Throwable {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
Async myAsync = method.getAnnotation(Async.class);
String annotationValue = myAsync.value();
if (StringUtil.isNotBlank(annotationValue) && annotationValue.equals("asyncExecutor")) {
// 在方法执行前的操作
String tenantId = AuthUtil.getTenantId();
DynamicDataSourceContextHolder.push(tenantId);
// 执行原方法
Object result = joinPoint.proceed();
// 在方法执行后的操作
DynamicDataSourceContextHolder.poll();
return result;
} else {
return joinPoint.proceed();
}
}
/** /**
* 该方法为一个切面用于对标记了@RabbitListener注解的方法进行增强主要增加了日志记录和数据源上下文处理的功能 * 该方法为一个切面用于对标记了@RabbitListener注解的方法进行增强主要增加了日志记录和数据源上下文处理的功能
* *
@ -68,12 +104,12 @@ public class AnnotationAspect {
JSONObject jsonObject = mockLogin(); JSONObject jsonObject = mockLogin();
MockHttpServletRequest mockRequest = new MockHttpServletRequest(); MockHttpServletRequest mockRequest = new MockHttpServletRequest();
mockRequest.addHeader("Blade-Auth", "bearer "+jsonObject.get("access_token")); mockRequest.addHeader("Blade-Auth", "bearer " + jsonObject.get("access_token"));
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(mockRequest)); RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(mockRequest));
HttpHeaders httpHeaders = new HttpHeaders(); HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add("Blade-Auth","bearer "+jsonObject.get("access_token") ); httpHeaders.add("Blade-Auth", "bearer " + jsonObject.get("access_token"));
httpHeaders.add( "Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0"); httpHeaders.add("Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0");
ThreadLocalUtil.put("bladeContext", httpHeaders); ThreadLocalUtil.put("bladeContext", httpHeaders);
DynamicDataSourceContextHolder.push(jsonObject.getString("tenant_id")); DynamicDataSourceContextHolder.push(jsonObject.getString("tenant_id"));
@ -87,12 +123,12 @@ public class AnnotationAspect {
} }
private JSONObject mockLogin(){ private JSONObject mockLogin() {
String account ="shujutongbu"; String account = "shujutongbu";
JSONObject data =bladeRedis.get(CacheNames.LOCAL_SERVER_USER+account); JSONObject data = bladeRedis.get(CacheNames.LOCAL_SERVER_USER + account);
if(Objects.isNull(data)){ if (Objects.isNull(data)) {
String url = "http://"+ LauncherConstant.loginAddr(Objects.requireNonNull(environment.getActiveProfiles()[0]))+"/blade-auth/oauth/token"; String url = "http://" + LauncherConstant.loginAddr(Objects.requireNonNull(environment.getActiveProfiles()[0])) + "/blade-auth/oauth/token";
HttpRequest urlRequest = HttpRequest.post(url); HttpRequest urlRequest = HttpRequest.post(url);
urlRequest.header("Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0"); urlRequest.header("Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0");
urlRequest.header("Tenant-Id", "627683"); urlRequest.header("Tenant-Id", "627683");
@ -105,7 +141,7 @@ public class AnnotationAspect {
HttpResponse execute = urlRequest.form(params).execute(); HttpResponse execute = urlRequest.form(params).execute();
String body = execute.body(); String body = execute.body();
data = JSONObject.parseObject(body); data = JSONObject.parseObject(body);
bladeRedis.setEx(CacheNames.LOCAL_SERVER_USER+account,data,3200L); bladeRedis.setEx(CacheNames.LOCAL_SERVER_USER + account, data, 3200L);
} }
return data; return data;
} }

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

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

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

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

74
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/config/XxlJobConfig.java

@ -0,0 +1,74 @@
package com.logpm.factorydata.jinpai.config;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* xxl-job config
*
* @author xuxueli 2017-04-28
*/
@Configuration(proxyBeanMethods = false)
public class XxlJobConfig {
private final Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
@Value("${xxl.job.admin.addresses}")
private String adminAddresses;
@Value("${xxl.job.executor.appname}")
private String appName;
@Value("${xxl.job.executor.ip}")
private String ip;
@Value("${xxl.job.executor.port}")
private int port;
@Value("${xxl.job.accessToken}")
private String accessToken;
@Value("${xxl.job.executor.logpath}")
private String logPath;
@Value("${xxl.job.executor.logretentiondays}")
private int logRetentionDays;
@Bean
public XxlJobSpringExecutor xxlJobExecutor() {
logger.info(">>>>>>>>>>> xxl-job config init.");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
xxlJobSpringExecutor.setAppName(appName);
xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setPort(port);
xxlJobSpringExecutor.setAccessToken(accessToken);
xxlJobSpringExecutor.setLogPath(logPath);
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
return xxlJobSpringExecutor;
}
/**
* 针对多网卡容器内部署等情况可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP
*
* 1引入依赖
* <dependency>
* <groupId>org.springframework.cloud</groupId>
* <artifactId>spring-cloud-commons</artifactId>
* <version>${version}</version>
* </dependency>
*
* 2配置文件或者容器启动变量
* spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
*
* 3获取IP
* String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
*/
}

31
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/controller/OrderController.java

@ -1,5 +1,6 @@
package com.logpm.factorydata.jinpai.controller; package com.logpm.factorydata.jinpai.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
@ -7,6 +8,7 @@ import com.logpm.factorydata.jinpai.service.DeliveryNoteService;
import com.logpm.factorydata.jinpai.vo.DeliveryNoteVO; import com.logpm.factorydata.jinpai.vo.DeliveryNoteVO;
import com.logpm.factorydata.jinpai.vo.OrderInfoVO; import com.logpm.factorydata.jinpai.vo.OrderInfoVO;
import com.logpm.factorydata.jinpai.vo.PackageInfoVO; import com.logpm.factorydata.jinpai.vo.PackageInfoVO;
import com.logpm.factorydata.jinpai.vo.PushOrderVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -18,6 +20,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* 工厂订单 前端控制器 * 工厂订单 前端控制器
* *
@ -37,11 +41,11 @@ public class OrderController {
@PostMapping @PostMapping
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "工厂订单", notes = "工厂订单") @ApiOperation(value = "工厂订单", notes = "工厂订单")
public R order(@RequestBody DeliveryNoteVO vo) { public R order(@RequestBody List<DeliveryNoteVO> vo) {
log.info("接收工厂订单:{} ", JSONUtil.toJsonStr(vo)); log.info("接收工厂订单:{} ", JSONUtil.toJsonStr(vo));
String res = ""; String res = "";
try { try {
if (ObjectUtil.isNotEmpty(vo)) { if (CollUtil.isNotEmpty(vo)) {
res = service.order(vo); res = service.order(vo);
} }
} catch (Exception e) { } catch (Exception e) {
@ -55,11 +59,11 @@ public class OrderController {
@PostMapping("orderInfo") @PostMapping("orderInfo")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
@ApiOperation(value = "工厂订单明细", notes = "工厂订单明细") @ApiOperation(value = "工厂订单明细", notes = "工厂订单明细")
public R detail(@RequestBody OrderInfoVO vo) { public R detail(@RequestBody List<OrderInfoVO> vo) {
log.info("接收工厂订单明细:{} ", JSONUtil.toJsonStr(vo)); log.info("接收工厂订单明细:{} ", JSONUtil.toJsonStr(vo));
String res = ""; String res = "";
try { try {
if (ObjectUtil.isNotEmpty(vo)) { if (CollUtil.isNotEmpty(vo)) {
res = service.detail(vo); res = service.detail(vo);
} }
} catch (Exception e) { } catch (Exception e) {
@ -72,11 +76,11 @@ public class OrderController {
@PostMapping("packageInfo") @PostMapping("packageInfo")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
@ApiOperation(value = "工厂包件信息", notes = "工厂包件信息") @ApiOperation(value = "工厂包件信息", notes = "工厂包件信息")
public R packageInfo(@RequestBody PackageInfoVO vo) { public R packageInfo(@RequestBody List<PackageInfoVO> vo) {
log.info("接收工厂包件信息:{} ", JSONUtil.toJsonStr(vo)); log.info("接收工厂包件信息:{} ", JSONUtil.toJsonStr(vo));
String res = ""; String res = "";
try { try {
if (ObjectUtil.isNotEmpty(vo)) { if (CollUtil.isNotEmpty(vo)) {
res = service.packageInfo(vo); res = service.packageInfo(vo);
} }
} catch (Exception e) { } catch (Exception e) {
@ -85,5 +89,20 @@ public class OrderController {
} }
return R.success(res); return R.success(res);
} }
@ResponseBody
@PostMapping("pushOrder")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "工厂下单接口", notes = "工厂下单接口")
public R pushOrder(@RequestBody PushOrderVO vo) {
log.info("接收工厂下单接口信息:{} ", JSONUtil.toJsonStr(vo));
String res = "";
try {
res = service.pushOrder(vo);
} catch (Exception e) {
log.error("接收工厂下单接口信息异常:{} ", e);
return R.success("服务器异常");
}
return R.success(res);
}
} }

16
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/entity/DeliveryNoteEntity.java

@ -111,6 +111,22 @@ public class DeliveryNoteEntity extends BaseEntity {
private String trackingStatus; private String trackingStatus;
@ApiModelProperty(name = "运输车牌") @ApiModelProperty(name = "运输车牌")
private String vehicleNo; private String vehicleNo;
@ApiModelProperty(name = "承运运输单位")
private String carrierUnit;
@ApiModelProperty(name = "承运商单号")
private String carrierOrderId;
@ApiModelProperty(name = "备注")
private String departRemark;
@ApiModelProperty(name = "异常签收类型(0:货损,1:少货,2:串货,)")
private String wrongSignType;
@ApiModelProperty(name = "签收状态:wqs=未签收 ycqs=异常签收 zcqs=正常签收")
private String orderSignStatus;
@ApiModelProperty(name = "回单状态 0 未回单 1 已回单")
private String receiptFlag;
@ApiModelProperty(name = "回单份数")
private String receiptNum;
@ApiModelProperty(name = "发货基地: 1=厦门基地,2=泗阳基地,4=橙鸟厦门仓,5=橙鸟佛山仓,6=成都基地")
private String busSource;
@ApiModelProperty(name = "预留1", notes = "") @ApiModelProperty(name = "预留1", notes = "")
private String reserve1; private String reserve1;

4
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/entity/FactoryOrderLogEntity.java

@ -44,9 +44,9 @@ public class FactoryOrderLogEntity extends BaseEntity {
@ApiModelProperty(name = "日志文件存放地址", notes = "") @ApiModelProperty(name = "日志文件存放地址", notes = "")
private String logUrl; private String logUrl;
/** /**
* 数据类型 1.入库数据 * 数据类型 1.拉取数据 2推送数据
*/ */
@ApiModelProperty(name = "数据类型 1.入库数据", notes = "") @ApiModelProperty(name = "数据类型 1.拉取数据 2。推送数据", notes = "")
private Integer type; private Integer type;
/** /**
* 数据维度1 订单 2 订单明细 3 包件 * 数据维度1 订单 2 订单明细 3 包件

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

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

2
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/entity/PackageInfoEntity.java

@ -19,6 +19,8 @@ import org.springblade.core.mp.base.BaseEntity;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class PackageInfoEntity extends BaseEntity { public class PackageInfoEntity extends BaseEntity {
@ApiModelProperty(name = "推送状态 0 未推 1 已推")
private Integer sendStatus;
@ApiModelProperty(name = "日志id") @ApiModelProperty(name = "日志id")
private String logId; private String logId;
@ApiModelProperty(name = "订单明细id") @ApiModelProperty(name = "订单明细id")

109
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/entity/PushOrderDetailEntity.java

@ -0,0 +1,109 @@
package com.logpm.factorydata.jinpai.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("jp_push_order_detail")
@ApiModel(value = "金牌订单明细", description = "金牌订单明细")
@EqualsAndHashCode(callSuper = true)
public class PushOrderDetailEntity extends BaseEntity {
@ApiModelProperty(name = "订单id")
private String orderId;
@ApiModelProperty(name = "日志id")
private String logId;
@ApiModelProperty(name = "明细编号")
private String itemId;
@ApiModelProperty(name = "发运类型(gx:干线, zy:直运, db:短驳)")
private String transportType;
@ApiModelProperty(name = "发站")
private String sendSite;
@ApiModelProperty(name = "到站")
private String endSite;
@ApiModelProperty(name = "收货联系人名称")
private String recvLinker;
@ApiModelProperty(name = "收货联系人手机")
private String recvMobile;
@ApiModelProperty(name = "收货联系人电话")
private String recvPhone;
@ApiModelProperty(name = "收货地址")
private String recvAddr;
@ApiModelProperty(name = "代收款")
private String codAmount;
@ApiModelProperty(name = "物品名称")
private String goodsName;
@ApiModelProperty(name = "物品数量(件)")
private String goodsNumber;
@ApiModelProperty(name = "物品重量(吨)")
private String goodsWeight;
@ApiModelProperty(name = "物品毛重(吨)")
private String goodsGrossWeight;
@ApiModelProperty(name = "物品净重(吨)")
private String goodsNetWeight;
@ApiModelProperty(name = "物品体积(方)")
private String goodsVolume;
@ApiModelProperty(name = "货品类型")
private String goodsType;
@ApiModelProperty(name = "货品包装说明")
private String goodsPack;
@ApiModelProperty(name = "长")
private String carLength;
@ApiModelProperty(name = "宽")
private String carWidth;
@ApiModelProperty(name = "高")
private String carHeight;
@ApiModelProperty(name = "订单类型(1-零售正单、2-普通零售单、3-样块单、4-增补单、5-返修单、6-缺件单、7-售后单、8-精板或其他)")
private String orderType;
@ApiModelProperty(name = "承运类型编码(编码含义:sfwl- 三方物流;sczp- 干仓配)")
private String shipType;
@ApiModelProperty(name = "送货模式编码(编码含义:gc-wf-基地-外发;sc-zt-干仓配-自提;sc-ps-干仓配-2C;sc-wf-干仓配-2B)")
private String transType;
@ApiModelProperty(name = "门店名称")
private String shopName;
@ApiModelProperty(name = "门店编码")
private String shopCode;
@ApiModelProperty(name = "门店电话")
private String shopPhone;
@ApiModelProperty(name = "门店地址")
private String shopAddr;
@ApiModelProperty(name = "预约送货时间")
private String appointmentTime;
@ApiModelProperty(name = "安装地址")
private String installAddr;
@ApiModelProperty(name = "安装联系人")
private String installLinker;
@ApiModelProperty(name = "安装联系电话")
private String installPhone;
@ApiModelProperty(name = "客户单号(YS单号)")
private String customOrderNo;
@ApiModelProperty(name = "客户明细单号(DD单号)")
private String customItemNo;
@ApiModelProperty(name = "箱码列表")
private String boxCodeList;
@ApiModelProperty(name = "包件品类")
private String boxDetailList;
@ApiModelProperty(name = "预留1", notes = "")
private String reserve1;
@ApiModelProperty(name = "预留2", notes = "")
private String reserve2;
@ApiModelProperty(name = "预留3", notes = "")
private String reserve3;
@ApiModelProperty(name = "预留4", notes = "")
private String reserve4;
@ApiModelProperty(name = "预留5", notes = "")
private String reserve5;
}

62
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/entity/PushOrderEntity.java

@ -0,0 +1,62 @@
package com.logpm.factorydata.jinpai.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("jp_push_order")
@ApiModel(value = "金牌订单", description = "金牌订单")
@EqualsAndHashCode(callSuper = true)
public class PushOrderEntity extends BaseEntity {
@ApiModelProperty(name = "日志id")
private String logId;
@ApiModelProperty(name = "装车单号")
private String transportNo;
@ApiModelProperty(name = "计划发车时间(yyyy-MM-dd HH:mm:ss)")
private String planBeginTime;
@ApiModelProperty(name = "计划到达时间(yyyy-MM-dd HH:mm:ss)")
private String planEndTime;
@ApiModelProperty(name = "货品总重量(吨)")
private String goodsTotalWeight;
@ApiModelProperty(name = "货品总数量(件)")
private String goodsTotalNumber;
@ApiModelProperty(name = "货品总体积(方)")
private String goodsTotalVolume;
@ApiModelProperty(name = "始发站")
private String sendSite;
@ApiModelProperty(name = "途经站")
private String passSite;
@ApiModelProperty(name = "终点站")
private String endSite;
@ApiModelProperty(name = "车型")
private String carType;
@ApiModelProperty(name = "车长")
private String carSize;
@ApiModelProperty(name = "制单人")
private String userName;
@ApiModelProperty(name = "基地")
private String orgName;
@ApiModelProperty(name = "预留1", notes = "")
private String reserve1;
@ApiModelProperty(name = "预留2", notes = "")
private String reserve2;
@ApiModelProperty(name = "预留3", notes = "")
private String reserve3;
@ApiModelProperty(name = "预留4", notes = "")
private String reserve4;
@ApiModelProperty(name = "预留5", notes = "")
private String reserve5;
}

24
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/enums/BusSourceEnums.java

@ -0,0 +1,24 @@
package com.logpm.factorydata.jinpai.enums;
import org.springblade.common.model.IDict;
/**
* 金牌基地枚举
*
* @author zhaoqiaobo
* @create 2024-04-28
*/
public enum BusSourceEnums implements IDict<String> {
XIAMEN("1", "厦门基地"),
SIYANG("2", "泗阳基地"),
OB_XIAMEN("4", "橙鸟厦门仓"),
OB_FOSHAN("5", "橙鸟佛山仓"),
CHENGDU("6", "成都基地"),
;
BusSourceEnums(String code, String text) {
init(code, text);
}
}

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

@ -0,0 +1,87 @@
package com.logpm.factorydata.jinpai.interceptor;
import com.alibaba.fastjson.JSONObject;
import com.logpm.factorydata.jinpai.wrapper.RequestWrapper;
import com.logpm.factorydata.jinpai.service.IFactoryTokenService;
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(203,"认证不通过,token有误")));
return false;
}
if(!StringUtil.hasLength(corpId)){
returnJson(response,JSONObject.toJSONString(R.fail(203,"认证不通过,corpId有误")));
return false;
}
log.info("##########preHandle: token={}",token);
//验证token
boolean b = factoryTokenService.verifyToken(token,corpId);
if(!b){
returnJson(response,JSONObject.toJSONString(R.fail(203,"认证不通过,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-jinpai/src/main/java/com/logpm/factorydata/jinpai/interceptor/LocalServerLoginAccountsInterceptor.java

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

300
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/job/AdvanceJob.java

@ -0,0 +1,300 @@
package com.logpm.factorydata.jinpai.job;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
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.feign.IFactoryDataClient;
import com.logpm.factorydata.jinpai.entity.DeliveryNoteEntity;
import com.logpm.factorydata.jinpai.entity.OrderInfoEntity;
import com.logpm.factorydata.jinpai.entity.PackageInfoEntity;
import com.logpm.factorydata.jinpai.enums.BusSourceEnums;
import com.logpm.factorydata.jinpai.service.DeliveryNoteService;
import com.logpm.factorydata.jinpai.service.OrderInfoService;
import com.logpm.factorydata.jinpai.service.PackageInfoService;
import com.logpm.factorydata.jinpai.vo.ThirdPlWarehouseMappingVO;
import com.logpm.factorydata.vo.SendMsg;
import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity;
import com.logpm.trunkline.entity.TrunklineAdvanceEntity;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.HttpConstants;
import org.springblade.common.constant.factorydata.FactoryDataConstants;
import org.springblade.common.model.IDict;
import org.springblade.core.tool.api.R;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author zhaoqiaobo
* @create 2024-04-02
*/
@AllArgsConstructor
@Component
@Slf4j
public class AdvanceJob {
private final DeliveryNoteService deliveryNoteService;
private final OrderInfoService orderInfoService;
private final PackageInfoService packageInfoService;
private final IFactoryDataBaseClient baseClient;
private final IFactoryDataClient factoryDataClient;
/**
* 定时扫描数据库保存所有齐套未推送的数据
*
* @param param
* @return
* @throws Exception
*/
@XxlJob("createAdvance")
public ReturnT<String> createAdvance(String param) throws Exception {
// 查询出齐套未生成暂存单的订单数据
Map<String, DeliveryNoteEntity> deliveryNoteEntityMap = new HashMap<>();
Map<String, OrderInfoEntity> orderInfoEntityMap = new HashMap<>();
Map<String, List<PackageInfoEntity>> packageInfoEntityMap = new HashMap<>();
Set<String> deliveryNoteSet = new HashSet<>();
Set<String> orderInfoSet = new HashSet<>();
// 按dd编号分组
List<PackageInfoEntity> list = packageInfoService.list(Wrappers.<PackageInfoEntity>lambdaQuery().eq(PackageInfoEntity::getSendStatus, 0));
if (CollUtil.isNotEmpty(list)) {
for (PackageInfoEntity entity : list) {
deliveryNoteSet.add(entity.getOrderId());
orderInfoSet.add(entity.getOmsExtOrderNo());
// 将数据封装到packageInfoEntityMap中 其中omsExtOrderNo为key
packageInfoEntityMap.computeIfAbsent(entity.getOmsExtOrderNo(), k -> new ArrayList<>()).add(entity);
}
// 根据订单数据查询出所有订单明细和包件信息
List<DeliveryNoteEntity> deliveryNoteEntities = deliveryNoteService.list(Wrappers.<DeliveryNoteEntity>lambdaQuery().in(DeliveryNoteEntity::getOrderId, deliveryNoteSet));
if (CollUtil.isNotEmpty(deliveryNoteEntities)) {
for (DeliveryNoteEntity entity : deliveryNoteEntities) {
deliveryNoteEntityMap.put(entity.getOrderId(), entity);
}
}
List<OrderInfoEntity> orderInfoEntities = orderInfoService.list(Wrappers.<OrderInfoEntity>lambdaQuery().in(OrderInfoEntity::getOmsExtOrderNo, orderInfoSet));
if (CollUtil.isNotEmpty(orderInfoEntities)) {
for (OrderInfoEntity entity : orderInfoEntities) {
orderInfoEntityMap.put(entity.getOmsExtOrderNo(), entity);
}
}
// 组装数据,然后生成暂存单
buildAdvance(packageInfoEntityMap, deliveryNoteEntityMap, orderInfoEntityMap);
// 修改包件的发送状态 TODO 后面修改为暂存单消费完成之后回调更新状态
List<PackageInfoEntity> updatePackageList = new ArrayList<>();
for (PackageInfoEntity entity : list) {
PackageInfoEntity updateEntity = new PackageInfoEntity();
updateEntity.setSendStatus(1);
updateEntity.setId(entity.getId());
updatePackageList.add(updateEntity);
}
if (CollUtil.isNotEmpty(updatePackageList)) {
packageInfoService.updateBatchById(updatePackageList);
}
}
return ReturnT.SUCCESS;
}
@Async("asyncExecutor")
public void buildAdvance(Map<String, List<PackageInfoEntity>> packageMap, Map<String, DeliveryNoteEntity> deliveryMap,
Map<String, OrderInfoEntity> orderInfoMap) {
// 新起线程构建暂存单发送mq
// 获取非干线仓库映射表数据
Map<String, ThirdPlWarehouseMappingVO> thirdPlWarehouseMapping = new HashMap<>();
List<ThirdPlWarehouseMappingVO> warehouseMappingVOList = deliveryNoteService.getThirdPlWarehouseMappingVO();
if (CollUtil.isNotEmpty(warehouseMappingVOList)) {
warehouseMappingVOList.forEach(vo -> {
thirdPlWarehouseMapping.put(vo.getArriveOrgName(), vo);
});
}
Map<String, FactoryWarehouseBindVO> warehouseBindVOMap = new HashMap<>();
if (CollUtil.isNotEmpty(deliveryMap)) {
for (Map.Entry<String, DeliveryNoteEntity> entry : deliveryMap.entrySet()) {
DeliveryNoteEntity deliveryNoteEntity = entry.getValue();
if (ObjectUtil.isNotEmpty(deliveryNoteEntity)) {
// 获取工厂基地绑定的始发仓信息
String textByCode = IDict.getTextByCode(BusSourceEnums.class, deliveryNoteEntity.getBusSource());
R<FactoryWarehouseBindVO> warehouseByBrandAndSiteName = baseClient.getWarehouseByBrandAndSiteName(BrandEnums.JP.getValue(), textByCode);
if (ObjectUtil.equal(HttpConstants.HTTP.HTTP_RESOURCE_CODE.SUCCESS_CODE, warehouseByBrandAndSiteName.getCode())) {
FactoryWarehouseBindVO data = warehouseByBrandAndSiteName.getData();
if (ObjectUtil.isNotNull(data)) {
warehouseBindVOMap.put(deliveryNoteEntity.getBusSource(), data);
}
}
}
}
}
// 组装暂存单数据
List<JSONObject> advances = new ArrayList<>();
for (Map.Entry<String, List<PackageInfoEntity>> stringListEntry : packageMap.entrySet()) {
String key = stringListEntry.getKey();
OrderInfoEntity orderInfo = orderInfoMap.get(key);
if (ObjectUtil.isEmpty(orderInfo)) {
log.error("订单明细信息不存在,dd单号:{}", key);
continue;
}
DeliveryNoteEntity order = deliveryMap.get(orderInfo.getOrderId());
if (ObjectUtil.isEmpty(order)) {
log.error("订单信息不存在,订单号:{}", orderInfo.getOrderId());
continue;
}
List<PackageInfoEntity> value = stringListEntry.getValue();
TrunklineAdvanceEntity advanceEntity = new TrunklineAdvanceEntity();
// 承运商是汇通的数据 走干线,不是汇通的直接走仓配。
String carrierName = order.getCarrierName();
Long warehouseId = null;
String warehouseName = "";
String tenantId = "";
if (ObjectUtil.equal(carrierName, "广州市汇通运输有限公司")) {
if (ObjectUtil.isNotNull(warehouseBindVOMap.get(order.getBusSource()))) {
warehouseId = warehouseBindVOMap.get(order.getBusSource()).getWarehouseId();
warehouseName = warehouseBindVOMap.get(order.getBusSource()).getWarehouseName();
tenantId = warehouseBindVOMap.get(order.getBusSource()).getTenantId();
}
} else {
if (ObjectUtil.isNotNull(thirdPlWarehouseMapping.get(order.getArriveOrgName()))) {
if (ObjectUtil.isNotEmpty(thirdPlWarehouseMapping.get(order.getArriveOrgName()).getWarehouseId())) {
warehouseId = Convert.toLong(thirdPlWarehouseMapping.get(order.getArriveOrgName()).getWarehouseId());
}
warehouseName = thirdPlWarehouseMapping.get(order.getArriveOrgName()).getWarehouseName();
tenantId = thirdPlWarehouseMapping.get(order.getArriveOrgName()).getTenantId();
}
}
advanceEntity.setTenantId(tenantId);
advanceEntity.setStatus(0);
advanceEntity.setIsDeleted(0);
advanceEntity.setHasPackage(CollUtil.isNotEmpty(value) ? 1 : 0);
advanceEntity.setOrderType(orderInfo.getYjOrderType());
advanceEntity.setBrand(BrandEnums.JP.getValue());
advanceEntity.setSiteName(IDict.getTextByCode(BusSourceEnums.class, order.getBusSource()));
advanceEntity.setArea("");
advanceEntity.setTotalNum(CollUtil.isNotEmpty(value) ? value.size() : 0);
advanceEntity.setPackName("");
advanceEntity.setPackCode("");
advanceEntity.setWarehouseId(warehouseId);
advanceEntity.setWarehouseName(warehouseName);
if (StrUtil.equals("sczp", order.getDistributionMode())) {
advanceEntity.setIsGcp(1);
} else {
advanceEntity.setIsGcp(0);
}
advanceEntity.setCarrierName(carrierName);
advanceEntity.setSystemType("线上");
advanceEntity.setMatingType("1");
advanceEntity.setSenderName(order.getConsignerName());
advanceEntity.setSenderPhone(order.getConsignerMobile());
advanceEntity.setSenderAddress(order.getConsignerAddr());
advanceEntity.setWaybillStatus("0");
advanceEntity.setWaybillNo("");
advanceEntity.setTrainNumber("");
advanceEntity.setFreezeStatus("0");
advanceEntity.setSenderFactory(IDict.getTextByCode(BusSourceEnums.class, order.getBusSource()));
advanceEntity.setOrderCode(orderInfo.getOmsExtOrderNo());
advanceEntity.setDealerCode(orderInfo.getShopCode());
advanceEntity.setDealerName(orderInfo.getShopName());
advanceEntity.setStoreCode(orderInfo.getShopCode());
advanceEntity.setStoreName(orderInfo.getShopName());
advanceEntity.setServiceNum(orderInfo.getOmsExtYsId());
// 安装
advanceEntity.setCustomerName(orderInfo.getYjInstallLinker());
advanceEntity.setCustomerPhone(orderInfo.getYjInstallPhone());
advanceEntity.setCustomerAddress(orderInfo.getYjInstallAddr());
advanceEntity.setConsigneePerson(order.getReceiverContacts());
advanceEntity.setConsigneeMobile(order.getReceiverMobile());
advanceEntity.setConsigneeAddress(order.getReceiverMobile());
List<JSONObject> packageList = new ArrayList<>();
for (PackageInfoEntity orderPackageDTO : value) {
// 封装包件
TrunklineAdvanceDetailEntity advanceDetailEntity = new TrunklineAdvanceDetailEntity();
advanceDetailEntity.setWarehouseId(warehouseId);
advanceDetailEntity.setWarehouseName(warehouseName);
// 根据的一流单标识赋值
advanceEntity.setLegacyStatus("0");
advanceDetailEntity.setOrderCode(orderPackageDTO.getOmsExtOrderNo());
advanceDetailEntity.setBrand(BrandEnums.JP.getValue());
advanceDetailEntity.setSystemType("线上");
String boxType1 = orderPackageDTO.getBoxType1();
String boxType2 = orderPackageDTO.getBoxType2();
String boxType3 = orderPackageDTO.getBoxType3();
if (StrUtil.isNotEmpty(boxType1)) {
advanceDetailEntity.setFirstPackName(orderPackageDTO.getBoxType1());
}
if (StrUtil.isNotEmpty(boxType2)) {
advanceDetailEntity.setSecondPackName(orderPackageDTO.getBoxType2());
} else {
advanceDetailEntity.setSecondPackName(orderPackageDTO.getBoxType1());
}
if (StrUtil.isNotEmpty(boxType3)) {
advanceDetailEntity.setThirdPackName(orderPackageDTO.getBoxType3());
} else {
if (StrUtil.isNotEmpty(boxType2)) {
advanceDetailEntity.setThirdPackName(orderPackageDTO.getBoxType2());
} else {
advanceDetailEntity.setThirdPackName(orderPackageDTO.getBoxType1());
}
}
advanceDetailEntity.setSiteName(IDict.getTextByCode(BusSourceEnums.class, order.getBusSource()));
advanceDetailEntity.setSiteCode("");
String planQty = orderPackageDTO.getGoodsNum();
advanceDetailEntity.setQuantity((StrUtil.isNotBlank(planQty) && NumberUtil.isNumber(planQty)) ? Convert.toInt(planQty) : 0);
advanceDetailEntity.setOrderPackageCode(orderPackageDTO.getExtBoxCode());
advanceDetailEntity.setTrainNumber("");
advanceDetailEntity.setServiceNum(orderInfo.getOmsExtYsId());
advanceDetailEntity.setWaybillNo("");
advanceDetailEntity.setPackageStatus("0");
advanceDetailEntity.setWeight(StrUtil.isNotBlank(orderPackageDTO.getGoodsWeight()) ? new BigDecimal(orderPackageDTO.getGoodsWeight()) : BigDecimal.ZERO);
advanceDetailEntity.setVolume(StrUtil.isNotBlank(orderPackageDTO.getGoodsVolume()) ? new BigDecimal(orderPackageDTO.getGoodsVolume()) : BigDecimal.ZERO);
// advanceDetailEntity.setChargeType(0);
advanceDetailEntity.setSupple("");
advanceDetailEntity.setManifest("");
advanceDetailEntity.setReturnNum("");
advanceDetailEntity.setSendDateStr(StrUtil.isNotBlank(order.getDepartTime()) ? order.getDepartTime() : DateUtil.formatLocalDateTime(LocalDateTime.now()));
advanceDetailEntity.setCarNumber(order.getCarNo());
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);
}
}
}
}

6
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/DeliveryNoteMapper.java

@ -2,7 +2,11 @@ package com.logpm.factorydata.jinpai.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factorydata.jinpai.entity.DeliveryNoteEntity; import com.logpm.factorydata.jinpai.entity.DeliveryNoteEntity;
import com.logpm.factorydata.jinpai.vo.ThirdPlWarehouseMappingVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 发货单 mapper * 发货单 mapper
@ -13,4 +17,6 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface DeliveryNoteMapper extends BaseMapper<DeliveryNoteEntity> { public interface DeliveryNoteMapper extends BaseMapper<DeliveryNoteEntity> {
List<ThirdPlWarehouseMappingVO> getThirdPlWarehouseMappingVO();
} }

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

@ -2,4 +2,9 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.logpm.factorydata.jinpai.mapper.DeliveryNoteMapper"> <mapper namespace="com.logpm.factorydata.jinpai.mapper.DeliveryNoteMapper">
<select id="getThirdPlWarehouseMappingVO"
resultType="com.logpm.factorydata.jinpai.vo.ThirdPlWarehouseMappingVO">
select arrive_org_name, warehouse_id, warehouse_name, tenant_id
from jp_third_pl_warehouse_mapping
</select>
</mapper> </mapper>

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

20
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/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.jinpai.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>

1
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/OrderInfoMapper.java

@ -2,6 +2,7 @@ package com.logpm.factorydata.jinpai.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factorydata.jinpai.entity.OrderInfoEntity; import com.logpm.factorydata.jinpai.entity.OrderInfoEntity;
import com.logpm.factorydata.jinpai.entity.PushOrderEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**

16
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/PushOrderDetailMapper.java

@ -0,0 +1,16 @@
package com.logpm.factorydata.jinpai.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factorydata.jinpai.entity.PushOrderDetailEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 订单信息 mapper
*
* @author zqb
* @since 2024-03-26
*/
@Mapper
public interface PushOrderDetailMapper extends BaseMapper<PushOrderDetailEntity> {
}

5
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/PushOrderDetailMapper.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.jinpai.mapper.PushOrderDetailMapper">
</mapper>

16
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/PushOrderMapper.java

@ -0,0 +1,16 @@
package com.logpm.factorydata.jinpai.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factorydata.jinpai.entity.PushOrderEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 订单信息 mapper
*
* @author zqb
* @since 2024-03-26
*/
@Mapper
public interface PushOrderMapper extends BaseMapper<PushOrderEntity> {
}

5
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/PushOrderMapper.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.jinpai.mapper.PushOrderMapper">
</mapper>

657
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mq/FactoryOrderListener.java

@ -1,28 +1,65 @@
package com.logpm.factorydata.jinpai.mq; package com.logpm.factorydata.jinpai.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.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.factorydata.base.feign.IFactoryDataBaseClient; 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.feign.IFactoryDataClient;
import com.logpm.factorydata.jinpai.entity.DeliveryNoteEntity;
import com.logpm.factorydata.jinpai.entity.FactoryOrderLogEntity; import com.logpm.factorydata.jinpai.entity.FactoryOrderLogEntity;
import com.logpm.factorydata.jinpai.entity.OrderInfoEntity;
import com.logpm.factorydata.jinpai.entity.PackageInfoEntity;
import com.logpm.factorydata.jinpai.entity.PushOrderDetailEntity;
import com.logpm.factorydata.jinpai.entity.PushOrderEntity;
import com.logpm.factorydata.jinpai.enums.DimensionEnums;
import com.logpm.factorydata.jinpai.service.DeliveryNoteService;
import com.logpm.factorydata.jinpai.service.FactoryOrderLogService;
import com.logpm.factorydata.jinpai.service.OrderInfoService;
import com.logpm.factorydata.jinpai.service.PackageInfoService;
import com.logpm.factorydata.jinpai.service.PushOrderDetailService;
import com.logpm.factorydata.jinpai.service.PushOrderService;
import com.logpm.factorydata.jinpai.vo.DeliveryNoteVO;
import com.logpm.factorydata.jinpai.vo.OrderInfoVO;
import com.logpm.factorydata.jinpai.vo.PackageCategoryVO;
import com.logpm.factorydata.jinpai.vo.PackageInfoVO;
import com.logpm.factorydata.jinpai.vo.PushOrderDetailVO;
import com.logpm.factorydata.jinpai.vo.PushOrderVO;
import com.logpm.factorydata.vo.SendMsg;
import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity;
import com.logpm.trunkline.entity.TrunklineAdvanceEntity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.PatternConstant; import org.springblade.common.constant.HttpConstants;
import org.springblade.common.constant.factorydata.FactoryDataConstants; import org.springblade.common.constant.factorydata.FactoryDataConstants;
import org.springblade.core.redis.cache.BladeRedis; import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.tool.api.R;
import org.springframework.amqp.core.ExchangeTypes; import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange; import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue; import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding; import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.HashSet; import java.time.LocalDateTime;
import java.util.Set; import java.util.ArrayList;
import java.util.regex.Matcher; import java.util.HashMap;
import java.util.regex.Pattern; import java.util.List;
import java.util.Map;
/** /**
* 监听索菲亚订单数据 * 监听索菲亚订单数据
@ -35,6 +72,13 @@ import java.util.regex.Pattern;
@AllArgsConstructor @AllArgsConstructor
public class FactoryOrderListener { public class FactoryOrderListener {
private final PushOrderService pushOrderService;
private final PushOrderDetailService pushOrderDetailService;
private final DeliveryNoteService deliveryNoteService;
private final OrderInfoService orderInfoService;
private final PackageInfoService packageInfoService;
private final FactoryOrderLogService logService;
private final BladeRedis bladeRedis; private final BladeRedis bladeRedis;
private final IFactoryDataBaseClient baseClient; private final IFactoryDataBaseClient baseClient;
private final IFactoryDataClient factoryDataClient; private final IFactoryDataClient factoryDataClient;
@ -51,284 +95,347 @@ public class FactoryOrderListener {
log.error("消息内容为空"); log.error("消息内容为空");
return; return;
} }
FactoryOrderLogEntity vo = JSONUtil.toBean(msg, FactoryOrderLogEntity.class); FactoryOrderLogEntity logEntity = JSONUtil.toBean(msg, FactoryOrderLogEntity.class);
if (ObjectUtil.isEmpty(vo)) { if (ObjectUtil.isEmpty(logEntity)) {
log.error("消息内容为空"); log.error("消息内容为空");
return; return;
} }
// 幂等控制,同一个入库单号只能入一次 // 去 minio 下载文件到本地,然后解析文件内容为实体对象
List<DeliveryNoteVO> deliveryNoteVOS = null;
List<OrderInfoVO> orderInfoVOS = null;
List<PackageInfoVO> packageInfoVOS = null;
PushOrderVO pushOrderVO = null;
Long logId = logEntity.getId();
String logUrl = logEntity.getLogUrl();
// 1 订单 2 订单明细 3 包件
Integer dimension = logEntity.getDimension();
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)) {
// 拉取的数据
if (ObjectUtil.equal(logEntity.getType(), 1)) {
if (ObjectUtil.equal(dimension, DimensionEnums.ORDER.getCode())) {
deliveryNoteVOS = new JSONArray(content).toList(DeliveryNoteVO.class);
}
if (ObjectUtil.equal(dimension, DimensionEnums.ORDER_DETAIL.getCode())) {
orderInfoVOS = new JSONArray(content).toList(OrderInfoVO.class);
}
if (ObjectUtil.equal(dimension, DimensionEnums.PACKAGE.getCode())) {
packageInfoVOS = new JSONArray(content).toList(PackageInfoVO.class);
}
} else if (ObjectUtil.equal(logEntity.getType(), 2)) {
// 推送的数据
pushOrderVO = JSONUtil.toBean(content, PushOrderVO.class);
}
}
}
}
if (ObjectUtil.equal(logEntity.getType(), 1)) {
pullData(deliveryNoteVOS, orderInfoVOS, packageInfoVOS, logEntity);
} else if (ObjectUtil.equal(logEntity.getType(), 2)) {
pushData(pushOrderVO, logEntity);
}
}
// if (CollUtil.isNotEmpty(receiptService.list(Wrappers.<ZbReceiptEntity>lambdaQuery().eq(ZbReceiptEntity::getTaskCode, code)))) { private void pushData(PushOrderVO vo, FactoryOrderLogEntity logEntity) {
// log.error("渠道单号已推送过了"); if (ObjectUtil.isNotEmpty(vo)) {
// return; // 1 解析数据保存入库
// } // 装车单号唯一
// 查询当前这次推送的数据中的所有包件,校验其是否在数据库中已存在,存在则不保存 Long logId = logEntity.getId();
Set<String> packageCode = new HashSet<>(); String truckNo = vo.getTransportNo();
// List<OrderPackageDTO> details = vo.getDetails(); List<PushOrderEntity> list = pushOrderService.list(Wrappers.<PushOrderEntity>lambdaQuery().eq(PushOrderEntity::getTransportNo, truckNo));
// if (CollUtil.isNotEmpty(details)) { if (CollUtil.isNotEmpty(list)) {
// // 收集包件编码 log.error("装车单号{} 数据已经处理过了, logId: {}", truckNo, logId);
// List<String> collect = details.stream().map(OrderPackageDTO::getPackageCode).collect(Collectors.toList()); return;
// if (CollUtil.isNotEmpty(collect)) { }
// List<OrderPackageDTO> packageCodes = orderPackageService.findByPackageCodes(collect); vo.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null);
// if (CollUtil.isNotEmpty(packageCodes)) { pushOrderService.save(vo);
// // 将packageCodes中的数据存到packageCode中 List<PushOrderDetailVO> orderInfos = vo.getItems();
// packageCodes.forEach(item -> { if (CollUtil.isNotEmpty(orderInfos)) {
// packageCode.add(item.getPackageCode()); List<PushOrderDetailEntity> infoEntities = new ArrayList<>();
// }); for (PushOrderDetailVO orderInfo : orderInfos) {
// } PushOrderDetailEntity orderInfoEntity = new PushOrderDetailEntity();
// } BeanUtil.copyProperties(orderInfo, orderInfoEntity);
// } orderInfoEntity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null);
// ZbReceiptEntity zbReceiptEntity = new ZbReceiptEntity(); orderInfoEntity.setOrderId(vo.getId().toString());
// BeanUtil.copyProperties(vo, zbReceiptEntity); List<String> boxCodes = orderInfo.getBoxCodes();
// // 保存订单数据 if (CollUtil.isNotEmpty(boxCodes)) {
// receiptService.save(zbReceiptEntity); orderInfoEntity.setBoxCodeList(JSONUtil.toJsonStr(boxCodes));
// if (CollUtil.isNotEmpty(details)) { }
// List<ZbOrderPackageEntity> packageEntities = new ArrayList<>(); List<PackageCategoryVO> boxDetails = orderInfo.getBoxDetails();
// List<ZbPackageInfoEntity> packageInfoEntities = new ArrayList<>(); if (CollUtil.isNotEmpty(boxDetails)) {
// for (OrderPackageDTO detail : details) { orderInfoEntity.setBoxDetailList(JSONUtil.toJsonStr(boxDetails));
// if (packageCode.contains(detail.getPackageCode())) { }
// log.info(" 接收志邦数据:包条码 {} 已存在数据库中,不保存。", detail.getPackageCode()); infoEntities.add(orderInfoEntity);
// continue; }
// } pushOrderDetailService.saveBatch(infoEntities);
// ZbOrderPackageEntity packageEntity = new ZbOrderPackageEntity(); }
// BeanUtil.copyProperties(detail, packageEntity); // 2 构建暂存单,发送 mq 消息
// packageEntity.setReceiptId(zbReceiptEntity.getId()); FactoryOrderLogEntity logEntity1 = new FactoryOrderLogEntity();
// packageEntities.add(packageEntity); logEntity1.setSaxStatus(SaxStatusEnums.SUCCESS.getCode());
// } logEntity1.setId(logId);
// // 保存包件数据 logService.saveOrUpdate(logEntity1);
// orderPackageService.saveBatch(packageEntities); // 处理暂存单
// for (OrderPackageDTO detail : details) { buildAdvance(vo);
// if (packageCode.contains(detail.getPackageCode())) { }
// continue;
// }
// Long detailId = null;
// for (ZbOrderPackageEntity packageEntity : packageEntities) {
// if (ObjectUtil.equal(packageEntity.getPackageCode(), detail.getPackageCode())) {
// detailId = packageEntity.getId();
// }
// }
// List<PackageInfoDTO> items = detail.getItems();
// if (CollUtil.isNotEmpty(items)) {
// for (PackageInfoDTO item : items) {
// ZbPackageInfoEntity packageInfoEntity = new ZbPackageInfoEntity();
// BeanUtil.copyProperties(item, packageInfoEntity);
// packageInfoEntity.setPackageId(detailId);
// packageInfoEntities.add(packageInfoEntity);
// }
// }
// }
// // 保存物料数据
// packageInfoService.saveBatch(packageInfoEntities);
// }
// 处理暂存单
// buildAdvance(vo, packageCode);
} }
// private void buildAdvance(DeliveryNoteVO vo, Set packageCode) { @Async("asyncExecutor")
// // 新起线程构建暂存单发送mq public void buildAdvance(PushOrderVO vo) {
// ThreadPoolUtil.getThreadPool().submit(() -> { // 新起线程构建暂存单发送mq
// Long startWarehouseId = null; Long startWarehouseId = null;
// String startWarehouseName = null; String startWarehouseName = null;
// String tenantId = null; String tenantId = null;
// // 获取工厂基地绑定的始发仓信息 // 获取工厂基地绑定的始发仓信息
// R<FactoryWarehouseBindVO> warehouseByBrandAndSiteName = baseClient.getWarehouseByBrandAndSiteName(vo.getSenderName(), vo.getSenderName()); List<PushOrderDetailVO> details = vo.getItems();
// if (ObjectUtil.equal(HttpConstants.HTTP.HTTP_RESOURCE_CODE.SUCCESS_CODE, warehouseByBrandAndSiteName.getCode())) { if (CollUtil.isEmpty(details)) {
// FactoryWarehouseBindVO data = warehouseByBrandAndSiteName.getData(); return;
// if (ObjectUtil.isNotNull(data)) { }
// startWarehouseId = data.getWarehouseId(); R<FactoryWarehouseBindVO> warehouseByBrandAndSiteName = baseClient.getWarehouseByBrandAndSiteName(BrandEnums.JP.getValue(), vo.getOrgName());
// startWarehouseName = data.getWarehouseName(); if (ObjectUtil.equal(HttpConstants.HTTP.HTTP_RESOURCE_CODE.SUCCESS_CODE, warehouseByBrandAndSiteName.getCode())) {
// tenantId = data.getTenantId(); FactoryWarehouseBindVO data = warehouseByBrandAndSiteName.getData();
// } if (ObjectUtil.isNotNull(data)) {
// } startWarehouseId = data.getWarehouseId();
// Map<String, List<OrderPackageDTO>> advanceMap = new HashMap<>(); startWarehouseName = data.getWarehouseName();
// List<OrderPackageDTO> details = vo.getDetails(); tenantId = data.getTenantId();
// // 入库单号 + 订单自编号 + 发车单号 一个暂存单 }
// for (OrderPackageDTO detail : details) { }
// if (packageCode.contains(detail.getPackageCode())) { Map<String, List<PackageInfoVO>> advanceMap = new HashMap<>();
// log.info(" 接收志邦数据:包条码 {} 已存在数据库中,不生成暂存单。", detail.getPackageCode()); // 一个dd单号 一个暂存单
// continue; // 组装暂存单数据
// } List<JSONObject> advances = new ArrayList<>();
// String taskCode = vo.getTaskCode(); for (PushOrderDetailVO orderInfoVO : details) {
// String departCode = vo.getDepartCode(); List<JSONObject> packageList = new ArrayList<>();
// String platformOrderCode = detail.getPlatformOrderCode(); TrunklineAdvanceEntity advanceEntity = new TrunklineAdvanceEntity();
// String advanceKey = taskCode + departCode + platformOrderCode; List<String> boxCodes = orderInfoVO.getBoxCodes();
// if (advanceMap.containsKey(advanceKey)) { advanceEntity.setTenantId(tenantId);
// advanceMap.get(advanceKey).add(detail); advanceEntity.setStatus(0);
// } else { advanceEntity.setIsDeleted(0);
// ArrayList<OrderPackageDTO> orderPackageDTOS = new ArrayList<>(); advanceEntity.setHasPackage(CollUtil.isNotEmpty(boxCodes) ? 1 : 0);
// orderPackageDTOS.add(detail); advanceEntity.setOrderType("");
// advanceMap.put(advanceKey, orderPackageDTOS); advanceEntity.setBrand(BrandEnums.JP.getValue());
// } advanceEntity.setSiteName(vo.getOrgName());
// } advanceEntity.setArea("");
// // 组装暂存单数据 advanceEntity.setTotalNum(StrUtil.isNotEmpty(orderInfoVO.getGoodsNumber()) ? Convert.toInt(orderInfoVO.getGoodsNumber()) : 0);
// List<JSONObject> advances = new ArrayList<>(); advanceEntity.setPackName("");
// for (Map.Entry<String, List<OrderPackageDTO>> stringListEntry : advanceMap.entrySet()) { advanceEntity.setPackCode("");
// List<OrderPackageDTO> value = stringListEntry.getValue(); advanceEntity.setWarehouseId(startWarehouseId);
// TrunklineAdvanceEntity advanceEntity = new TrunklineAdvanceEntity(); advanceEntity.setWarehouseName(startWarehouseName);
// advanceEntity.setTenantId(tenantId);
// advanceEntity.setStatus(0); advanceEntity.setIsGcp(0);
// advanceEntity.setIsDeleted(0); advanceEntity.setCarrierName("");
// advanceEntity.setHasPackage(CollUtil.isNotEmpty(vo.getDetails()) ? 1 : 0); advanceEntity.setSystemType("线上");
// advanceEntity.setOrderType(vo.getOrderType()); advanceEntity.setMatingType("1");
// advanceEntity.setBrand(vo.getSenderName()); advanceEntity.setSenderName("");
// advanceEntity.setSiteName(""); advanceEntity.setSenderPhone("");
// advanceEntity.setArea(""); advanceEntity.setSenderAddress("");
// advanceEntity.setTotalNum(CollUtil.isNotEmpty(value) ? value.size() : 0); advanceEntity.setWaybillStatus("0");
// advanceEntity.setPackName(""); advanceEntity.setWaybillNo("");
// advanceEntity.setPackCode(""); advanceEntity.setTrainNumber(vo.getTransportNo());
// advanceEntity.setWarehouseId(startWarehouseId); advanceEntity.setFreezeStatus("0");
// advanceEntity.setWarehouseName(startWarehouseName); advanceEntity.setOrderCode(orderInfoVO.getCustomItemNo());
// advanceEntity.setServiceNum(orderInfoVO.getCustomOrderNo());
// advanceEntity.setIsGcp(0); advanceEntity.setSenderFactory(vo.getOrgName());
// advanceEntity.setCarrierName(vo.getVendorName()); // 门店是商场
// advanceEntity.setSystemType("线上"); advanceEntity.setDealerCode(orderInfoVO.getShopCode());
// advanceEntity.setMatingType(""); advanceEntity.setDealerName(orderInfoVO.getShopName());
// advanceEntity.setSenderName(vo.getSenderName()); advanceEntity.setStoreCode(orderInfoVO.getShopCode());
// advanceEntity.setSenderPhone(vo.getSenderTel()); advanceEntity.setStoreName(orderInfoVO.getShopName());
// advanceEntity.setSenderAddress(vo.getSenderAddress()); // 安装是客户
// advanceEntity.setWaybillStatus("0"); advanceEntity.setCustomerName(orderInfoVO.getInstallLinker());
// advanceEntity.setWaybillNo(""); advanceEntity.setCustomerPhone(orderInfoVO.getInstallPhone());
// advanceEntity.setTrainNumber(vo.getDepartCode()); advanceEntity.setCustomerAddress(orderInfoVO.getInstallAddr());
// advanceEntity.setFreezeStatus("0"); // 收货人就是商场收货人
// advanceEntity.setConsigneePerson(orderInfoVO.getRecvLinker());
// advanceEntity.setSenderFactory(vo.getSenderName()); advanceEntity.setConsigneeMobile(orderInfoVO.getRecvPhone());
// List<JSONObject> packageList = new ArrayList<>(); advanceEntity.setConsigneeAddress(orderInfoVO.getRecvAddr());
// for (OrderPackageDTO orderPackageDTO : value) { // 根据遗留单标识赋值
// advanceEntity.setOrderCode(orderPackageDTO.getPlatformOrderCode()); advanceEntity.setLegacyStatus("0");
// advanceEntity.setDealerCode(orderPackageDTO.getCustomerCode()); if (StrUtil.contains(orderInfoVO.getCustomItemNo(), "遗")) {
// advanceEntity.setDealerName(orderPackageDTO.getCustomerName()); advanceEntity.setLegacyStatus("1");
// advanceEntity.setStoreCode(orderPackageDTO.getCustomerCode()); }
// advanceEntity.setStoreName(orderPackageDTO.getCustomerName()); // 封装包件品类信息
// advanceEntity.setServiceNum(orderPackageDTO.getRelationOrderCode()); Map<String, PackageCategoryVO> categoryVOMap = new HashMap<>();
// advanceEntity.setCustomerName(orderPackageDTO.getReceiverName()); List<PackageCategoryVO> boxDetails = orderInfoVO.getBoxDetails();
// advanceEntity.setCustomerPhone(orderPackageDTO.getReceiverMobile()); if (CollUtil.isNotEmpty(boxDetails)) {
// advanceEntity.setCustomerAddress(orderPackageDTO.getReceiverAddress()); for (PackageCategoryVO packageCategoryVO : boxDetails) {
// categoryVOMap.put(packageCategoryVO.getExtBoxCode(), packageCategoryVO);
// // 封装包件 }
// TrunklineAdvanceDetailEntity advanceDetailEntity = new TrunklineAdvanceDetailEntity(); }
// advanceDetailEntity.setWarehouseId(startWarehouseId); for (String packageCode : boxCodes) {
// advanceDetailEntity.setWarehouseName(startWarehouseName); // 封装包件
//// advanceDetailEntity.setIncomingWarehouseId(0L); TrunklineAdvanceDetailEntity advanceDetailEntity = new TrunklineAdvanceDetailEntity();
//// advanceDetailEntity.setIncomingWarehouseName(""); advanceDetailEntity.setWarehouseId(startWarehouseId);
// // 根据志邦的一流单标识赋值 advanceDetailEntity.setWarehouseName(startWarehouseName);
// advanceEntity.setLegacyStatus("0");
// if (ObjectUtil.equal(orderPackageDTO.getLegacyFlag(), "Y")) {
// advanceEntity.setLegacyStatus("1");
// }
//
// advanceDetailEntity.setOrderCode(orderPackageDTO.getPlatformOrderCode());
// advanceDetailEntity.setBrand(vo.getSenderName());
// advanceDetailEntity.setSystemType("线上");
// advanceDetailEntity.setFirstPackName(orderPackageDTO.getPackageTypeName());
// advanceDetailEntity.setFirstPackCode(orderPackageDTO.getPackageType());
// // 获取映射志邦映射品类信息
// ZbCategoryContrastEntity zbCategoryContrastEntity = buildZbCategoryContrastEntityCache(orderPackageDTO.getPackageClass());
// if (zbCategoryContrastEntity != null) {
// advanceDetailEntity.setSecondPackName(zbCategoryContrastEntity.getSecondName());//二级品类名称
// advanceDetailEntity.setSecondPackCode(zbCategoryContrastEntity.getSecondCode());//二级品类
// advanceDetailEntity.setThirdPackName(zbCategoryContrastEntity.getThirdName());//三级品类名称
// advanceDetailEntity.setThirdPackCode(zbCategoryContrastEntity.getThirdCode());//三级品类
// } else {
// advanceDetailEntity.setSecondPackName(StringUtil.isBlank(orderPackageDTO.getPackageClass()) ? "" : orderPackageDTO.getPackageClass());//二级品类名称
// advanceDetailEntity.setSecondPackCode("");//二级品类
// advanceDetailEntity.setThirdPackName(StringUtil.isBlank(orderPackageDTO.getPackageClass()) ? "" : orderPackageDTO.getPackageClass());//三级品类名称
// advanceDetailEntity.setThirdPackCode("");//三级品类
// }
// advanceDetailEntity.setSiteName("");
// advanceDetailEntity.setSiteCode("");
// String planQty = orderPackageDTO.getPlanQty();
// advanceDetailEntity.setQuantity((StrUtil.isNotBlank(planQty) && NumberUtil.isNumber(planQty)) ? Convert.toInt(planQty) : 0);
// advanceDetailEntity.setOrderPackageCode(orderPackageDTO.getPackageCode());
// advanceDetailEntity.setTrainNumber(vo.getDepartCode());
// advanceDetailEntity.setServiceNum(orderPackageDTO.getRelationOrderCode());
// advanceDetailEntity.setWaybillNo("");
// advanceDetailEntity.setPackageStatus("0");
// advanceDetailEntity.setWeight(StrUtil.isNotBlank(orderPackageDTO.getTotalGrossWeight()) ? new BigDecimal(orderPackageDTO.getTotalGrossWeight()) : BigDecimal.ZERO);
// advanceDetailEntity.setVolume(StrUtil.isNotBlank(orderPackageDTO.getTotalVolume()) ? new BigDecimal(orderPackageDTO.getTotalVolume()) : 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);
// List<JSONObject> itemJsons = new ArrayList<>();
// List<PackageInfoDTO> items = orderPackageDTO.getItems();
// for (PackageInfoDTO item : items) {
// TrunklineDetailProductEntity detailProductEntity = new TrunklineDetailProductEntity();
// detailProductEntity.setTenantId(tenantId);
// detailProductEntity.setWarehouseId(startWarehouseId);
// detailProductEntity.setWarehouseName(startWarehouseName);
// detailProductEntity.setUnitNo(orderPackageDTO.getPackageCode());
// detailProductEntity.setProductCode(item.getItemCode());
// detailProductEntity.setProductName(item.getItemName());
// detailProductEntity.setQuantity(item.getPlanQty());
// detailProductEntity.setTenantId(TenantNum.HUITONGCODE);
// detailProductEntity.setStatus(0);
// detailProductEntity.setIsDeleted(0);
// itemJsons.add(JSONUtil.parseObj(detailProductEntity));
// }
// JSONObject entries = JSONUtil.parseObj(advanceDetailEntity);
// entries.set("items", itemJsons);
// 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);
// }
// }
// });
// }
//
// private ZbCategoryContrastEntity buildZbCategoryContrastEntityCache(String packageClass) {
//
//
// if (StringUtil.isBlank(packageClass)) {
// return null;
// }
// if (containsChinese(packageClass)) {
// return null;
// }
//
// String key = TenantNum.HUITONGCODE + ":" + ZbCategoryContrastEntity.class.getName() + ":" + packageClass;
// ZbCategoryContrastEntity zbCategoryContrastEntity = bladeRedis.get(key);
// if (zbCategoryContrastEntity == null) {
// QueryWrapper<ZbCategoryContrastEntity> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("source_code", packageClass);
// queryWrapper.eq("status", "1");
// zbCategoryContrastEntity = zbCategoryContrastMapper.selectOne(queryWrapper);
// if (!Objects.isNull(zbCategoryContrastEntity)) {
// // 缓存起来
// bladeRedis.setEx(key, zbCategoryContrastEntity, 3600 * 24L);
// }
// }
// return zbCategoryContrastEntity;
//
//
// }
/** advanceDetailEntity.setOrderCode(orderInfoVO.getCustomItemNo());
* 验证参数中是否包含中文 advanceDetailEntity.setBrand(BrandEnums.JP.getValue());
* advanceDetailEntity.setSystemType("线上");
* @param str 匹配参数 // 获取映射品类信息
* @return true 包含中文 false 不包含中文 PackageCategoryVO categoryVO = categoryVOMap.get(packageCode);
*/ if (ObjectUtil.isNotEmpty(categoryVO)) {
private boolean containsChinese(String str) { // 一级品类名称
Pattern pattern = Pattern.compile(PatternConstant.REGEX_CHINESE); if (StrUtil.isNotEmpty(categoryVO.getTypea())) {
Matcher matcher = pattern.matcher(str); advanceDetailEntity.setFirstPackName(categoryVO.getTypea());
return matcher.find(); advanceDetailEntity.setMaterialName(categoryVO.getTypea());
}
// 二级品类名称
if (StrUtil.isNotEmpty(categoryVO.getTypeb())) {
advanceDetailEntity.setSecondPackName(categoryVO.getTypeb());
} else {
advanceDetailEntity.setSecondPackName(categoryVO.getTypea());
}
// 三级品类名称
if (StrUtil.isNotEmpty(categoryVO.getTypec())) {
advanceDetailEntity.setThirdPackName(categoryVO.getTypec());
} else {
if (StrUtil.isNotEmpty(categoryVO.getTypeb())) {
advanceDetailEntity.setThirdPackName(categoryVO.getTypeb());
} else {
advanceDetailEntity.setThirdPackName(categoryVO.getTypea());
}
}
}
advanceDetailEntity.setSiteName(vo.getOrgName());
advanceDetailEntity.setSiteCode("");
advanceDetailEntity.setQuantity(1);
advanceDetailEntity.setOrderPackageCode(packageCode);
advanceDetailEntity.setTrainNumber(vo.getTransportNo());
advanceDetailEntity.setServiceNum(orderInfoVO.getCustomOrderNo());
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);
}
}
}
private void pullData(List<DeliveryNoteVO> deliveryNoteVOS, List<OrderInfoVO> orderInfoVOS, List<PackageInfoVO> packageInfoVOS, FactoryOrderLogEntity logEntity) {
if (CollUtil.isNotEmpty(deliveryNoteVOS)) {
List<DeliveryNoteEntity> entities = new ArrayList<>();
List<String> orderCodes = new ArrayList<>();
for (DeliveryNoteVO deliveryNoteVO : deliveryNoteVOS) {
orderCodes.add(deliveryNoteVO.getOrderId());
}
List<DeliveryNoteEntity> list = deliveryNoteService.list(Wrappers.<DeliveryNoteEntity>lambdaQuery()
.in(DeliveryNoteEntity::getOrderId, orderCodes));
Map<String, String> map = new HashMap<>();
if (CollUtil.isNotEmpty(list)) {
// 将list中的数据封装到map中
list.forEach(item -> {
map.put(item.getOrderId(), item.getOrderId());
});
}
for (DeliveryNoteVO deliveryNoteVO : deliveryNoteVOS) {
if (map.containsKey(deliveryNoteVO.getOrderId())) {
log.error("订单号:{},已推送过了", deliveryNoteVO.getOrderId());
continue;
}
DeliveryNoteEntity deliveryNoteEntity = new DeliveryNoteEntity();
BeanUtil.copyProperties(deliveryNoteVO, deliveryNoteEntity);
deliveryNoteEntity.setLogId(ObjectUtil.isNotEmpty(logEntity.getId()) ? logEntity.getId().toString() : null);
entities.add(deliveryNoteEntity);
}
if (CollUtil.isNotEmpty(entities)) {
deliveryNoteService.saveBatch(entities);
}
}
if (CollUtil.isNotEmpty(orderInfoVOS)) {
List<OrderInfoEntity> entities = new ArrayList<>();
List<String> orderCodes = new ArrayList<>();
for (OrderInfoVO orderInfoVO : orderInfoVOS) {
orderCodes.add(orderInfoVO.getOrderId());
}
List<OrderInfoEntity> list = orderInfoService.list(Wrappers.<OrderInfoEntity>lambdaQuery()
.in(OrderInfoEntity::getOmsExtOrderNo, orderCodes));
Map<String, String> map = new HashMap<>();
if (CollUtil.isNotEmpty(list)) {
// 将list中的数据封装到map中
list.forEach(item -> {
map.put(item.getOmsExtOrderNo(), item.getOmsExtOrderNo());
});
}
for (OrderInfoVO vo : orderInfoVOS) {
if (map.containsKey(vo.getOmsExtOrderNo())) {
log.error("DD单号:{},已推送过了", vo.getOmsExtOrderNo());
continue;
}
OrderInfoEntity deliveryNoteEntity = new OrderInfoEntity();
BeanUtil.copyProperties(vo, deliveryNoteEntity);
deliveryNoteEntity.setLogId(ObjectUtil.isNotEmpty(logEntity.getId()) ? logEntity.getId().toString() : null);
entities.add(deliveryNoteEntity);
}
if (CollUtil.isNotEmpty(entities)) {
orderInfoService.saveBatch(entities);
}
}
if (CollUtil.isNotEmpty(packageInfoVOS)) {
List<PackageInfoEntity> entities = new ArrayList<>();
List<String> orderCodes = new ArrayList<>();
List<String> packageCodes = new ArrayList<>();
for (PackageInfoVO orderInfoVO : packageInfoVOS) {
orderCodes.add(orderInfoVO.getOmsExtOrderNo());
packageCodes.add(orderInfoVO.getExtBoxCode());
}
List<PackageInfoEntity> list = packageInfoService.list(Wrappers.<PackageInfoEntity>lambdaQuery()
.in(PackageInfoEntity::getOmsExtOrderNo, orderCodes)
.in(PackageInfoEntity::getExtBoxCode, packageCodes)
);
Map<String, String> map = new HashMap<>();
if (CollUtil.isNotEmpty(list)) {
// 将list中的数据封装到map中
list.forEach(item -> {
map.put(item.getOmsExtOrderNo() + item.getExtBoxCode(), item.getOmsExtOrderNo());
});
}
for (PackageInfoVO vo : packageInfoVOS) {
if (map.containsKey(vo.getOmsExtOrderNo() + vo.getExtBoxCode())) {
log.error("DD单号:{} + 箱码:{},已推送过了", vo.getOmsExtOrderNo(), vo.getExtBoxCode());
continue;
}
PackageInfoEntity entity = new PackageInfoEntity();
BeanUtil.copyProperties(vo, entity);
entity.setLogId(ObjectUtil.isNotEmpty(logEntity.getId()) ? logEntity.getId().toString() : null);
entities.add(entity);
}
if (CollUtil.isNotEmpty(entities)) {
packageInfoService.saveBatch(entities);
}
}
// 处理暂存单 通过定时任务扫描的方式判定是否齐套 然后创建暂存单
FactoryOrderLogEntity logEntity1 = new FactoryOrderLogEntity();
logEntity1.setSaxStatus(SaxStatusEnums.SUCCESS.getCode());
logEntity1.setId(logEntity.getId());
logService.saveOrUpdate(logEntity1);
} }
} }

14
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/DeliveryNoteService.java

@ -4,8 +4,12 @@ import com.logpm.factorydata.jinpai.entity.DeliveryNoteEntity;
import com.logpm.factorydata.jinpai.vo.DeliveryNoteVO; import com.logpm.factorydata.jinpai.vo.DeliveryNoteVO;
import com.logpm.factorydata.jinpai.vo.OrderInfoVO; import com.logpm.factorydata.jinpai.vo.OrderInfoVO;
import com.logpm.factorydata.jinpai.vo.PackageInfoVO; import com.logpm.factorydata.jinpai.vo.PackageInfoVO;
import com.logpm.factorydata.jinpai.vo.PushOrderVO;
import com.logpm.factorydata.jinpai.vo.ThirdPlWarehouseMappingVO;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import java.util.List;
/** /**
* 索菲亚发货单 服务类 * 索菲亚发货单 服务类
* *
@ -14,9 +18,13 @@ import org.springblade.core.mp.base.BaseService;
**/ **/
public interface DeliveryNoteService extends BaseService<DeliveryNoteEntity> { public interface DeliveryNoteService extends BaseService<DeliveryNoteEntity> {
String order(DeliveryNoteVO vo); String order(List<DeliveryNoteVO> vo);
String detail(List<OrderInfoVO> vo);
String packageInfo(List<PackageInfoVO> vo);
String detail(OrderInfoVO vo); List<ThirdPlWarehouseMappingVO> getThirdPlWarehouseMappingVO();
String packageInfo(PackageInfoVO vo); String pushOrder(PushOrderVO vo);
} }

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

@ -0,0 +1,15 @@
package com.logpm.factorydata.jinpai.service;
import com.logpm.factorydata.jinpai.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-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/PushOrderDetailService.java

@ -0,0 +1,14 @@
package com.logpm.factorydata.jinpai.service;
import com.logpm.factorydata.jinpai.entity.PushOrderDetailEntity;
import org.springblade.core.mp.base.BaseService;
/**
* 订单 服务类
*
* @Author zqb
* @Date 2024/4/26
**/
public interface PushOrderDetailService extends BaseService<PushOrderDetailEntity> {
}

14
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/PushOrderService.java

@ -0,0 +1,14 @@
package com.logpm.factorydata.jinpai.service;
import com.logpm.factorydata.jinpai.entity.PushOrderEntity;
import org.springblade.core.mp.base.BaseService;
/**
* 订单 服务类
*
* @Author zqb
* @Date 2024/4/26
**/
public interface PushOrderService extends BaseService<PushOrderEntity> {
}

41
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/impl/DeliveryNoteServiceImpl.java

@ -14,6 +14,8 @@ import com.logpm.factorydata.jinpai.service.FactoryOrderLogService;
import com.logpm.factorydata.jinpai.vo.DeliveryNoteVO; import com.logpm.factorydata.jinpai.vo.DeliveryNoteVO;
import com.logpm.factorydata.jinpai.vo.OrderInfoVO; import com.logpm.factorydata.jinpai.vo.OrderInfoVO;
import com.logpm.factorydata.jinpai.vo.PackageInfoVO; import com.logpm.factorydata.jinpai.vo.PackageInfoVO;
import com.logpm.factorydata.jinpai.vo.PushOrderVO;
import com.logpm.factorydata.jinpai.vo.ThirdPlWarehouseMappingVO;
import com.logpm.factorydata.vo.SendMsg; import com.logpm.factorydata.vo.SendMsg;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -25,8 +27,10 @@ import org.springblade.common.constant.factorydata.FactoryDataConstants;
import org.springblade.common.utils.FileLogsUtil; import org.springblade.common.utils.FileLogsUtil;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.oss.model.BladeFile; import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.resource.feign.IOssClient; import org.springblade.resource.feign.IOssClient;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -36,6 +40,7 @@ import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.List;
/** /**
* 发货单 业务实现类 * 发货单 业务实现类
@ -51,11 +56,12 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl<DeliveryNoteMapper,
private final IFactoryDataClient factoryDataClient; private final IFactoryDataClient factoryDataClient;
private final FactoryOrderLogService factoryOrderLogService; private final FactoryOrderLogService factoryOrderLogService;
private final IOssClient ossClient; private final IOssClient ossClient;
private final BladeRedis bladeRedis;
@Override @Override
public String order(DeliveryNoteVO vo) { public String order(List<DeliveryNoteVO> vo) {
// 1 上传数据到 minio 获取到地址 // 1 上传数据到 minio 获取到地址
String url = uploadFile(JSONObject.toJSONString(vo)); String url = uploadFile(JSONUtil.toJsonStr(vo));
// 2 保存地址到数据库 // 2 保存地址到数据库
FactoryOrderLogEntity logEntity = new FactoryOrderLogEntity(); FactoryOrderLogEntity logEntity = new FactoryOrderLogEntity();
logEntity.setType(1); logEntity.setType(1);
@ -72,9 +78,9 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl<DeliveryNoteMapper,
} }
@Override @Override
public String detail(OrderInfoVO vo) { public String detail(List<OrderInfoVO> vo) {
// 1 上传数据到 minio 获取到地址 // 1 上传数据到 minio 获取到地址
String url = uploadFile(JSONObject.toJSONString(vo)); String url = uploadFile(JSONUtil.toJsonStr(vo));
// 2 保存地址到数据库 // 2 保存地址到数据库
FactoryOrderLogEntity logEntity = new FactoryOrderLogEntity(); FactoryOrderLogEntity logEntity = new FactoryOrderLogEntity();
logEntity.setType(1); logEntity.setType(1);
@ -91,9 +97,9 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl<DeliveryNoteMapper,
} }
@Override @Override
public String packageInfo(PackageInfoVO vo) { public String packageInfo(List<PackageInfoVO> vo) {
// 1 上传数据到 minio 获取到地址 // 1 上传数据到 minio 获取到地址
String url = uploadFile(JSONObject.toJSONString(vo)); String url = uploadFile(JSONUtil.toJsonStr(vo));
// 2 保存地址到数据库 // 2 保存地址到数据库
FactoryOrderLogEntity logEntity = new FactoryOrderLogEntity(); FactoryOrderLogEntity logEntity = new FactoryOrderLogEntity();
logEntity.setType(1); logEntity.setType(1);
@ -108,6 +114,29 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl<DeliveryNoteMapper,
return "成功"; return "成功";
} }
@Override
@Cacheable(value = "blade:factory:jp:thirdPlWarehouseMapping")
public List<ThirdPlWarehouseMappingVO> getThirdPlWarehouseMappingVO() {
return this.baseMapper.getThirdPlWarehouseMappingVO();
}
@Override
public String pushOrder(PushOrderVO vo) {
// 1 上传数据到 minio 获取到地址
String url = uploadFile(JSONUtil.toJsonStr(vo));
// 2 保存地址到数据库
FactoryOrderLogEntity logEntity = new FactoryOrderLogEntity();
logEntity.setType(2);
logEntity.setSaxStatus(SaxStatusEnums.NOMAL.getCode());
logEntity.setLogUrl(url);
factoryOrderLogService.save(logEntity);
// 3 将消息发送给 mq,解析保存
SendMsg build = SendMsg.builder().exchange(FactoryDataConstants.Mq.Exchanges.FACTORY_ORDER)
.routingKey(FactoryDataConstants.Mq.RoutingKeys.JP_FACTORY_ORDER).message(JSONUtil.toJsonStr(logEntity)).build();
factoryDataClient.sendMessage(build);
return "成功";
}
private String uploadFile(String body) { private String uploadFile(String body) {
//文本内容和保存为本地文件 并上传 //文本内容和保存为本地文件 并上传
String logPath = FileLogsUtil.saveFileLogs(body); String logPath = FileLogsUtil.saveFileLogs(body);

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

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

@ -0,0 +1,22 @@
package com.logpm.factorydata.jinpai.service.impl;
import com.logpm.factorydata.jinpai.entity.PushOrderDetailEntity;
import com.logpm.factorydata.jinpai.mapper.PushOrderDetailMapper;
import com.logpm.factorydata.jinpai.service.PushOrderDetailService;
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 PushOrderDetailServiceImpl extends BaseServiceImpl<PushOrderDetailMapper, PushOrderDetailEntity> implements PushOrderDetailService {
}

22
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/impl/PushOrderServiceImpl.java

@ -0,0 +1,22 @@
package com.logpm.factorydata.jinpai.service.impl;
import com.logpm.factorydata.jinpai.entity.PushOrderEntity;
import com.logpm.factorydata.jinpai.mapper.PushOrderMapper;
import com.logpm.factorydata.jinpai.service.PushOrderService;
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 PushOrderServiceImpl extends BaseServiceImpl<PushOrderMapper, PushOrderEntity> implements PushOrderService {
}

43
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/util/ThreadPoolUtil.java

@ -1,43 +0,0 @@
package com.logpm.factorydata.jinpai.util;
import cn.hutool.core.thread.ExecutorBuilder;
import cn.hutool.core.thread.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.ExecutorService;
/**
* @author zhaoqiaobo
* @create 2024-03-14 10:26
*/
@Slf4j
public class ThreadPoolUtil {
private ThreadPoolUtil() {
}
/**
* 线程池
*/
public static ExecutorService executor = null;
static {
init();
}
synchronized public static void init() {
if (null != executor) {
executor.shutdownNow();
}
executor = ExecutorBuilder.create()
.setCorePoolSize(8)
.setMaxPoolSize(20)
.setThreadFactory(ThreadFactoryBuilder.create().setNamePrefix("logpm-factory-data-sfy-").build())
.useSynchronousQueue().build();
}
public static ExecutorService getThreadPool() {
return executor;
}
}

26
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/vo/PackageCategoryVO.java

@ -0,0 +1,26 @@
package com.logpm.factorydata.jinpai.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author zhaoqiaobo
* @create 2024-04-30
*/
@Data
public class PackageCategoryVO implements Serializable {
@ApiModelProperty(name = "一级品类")
private String typea;
@ApiModelProperty(name = "二级品类")
private String typeb;
@ApiModelProperty(name = "三级品类")
private String typec;
@ApiModelProperty(name = "包件码")
private String extBoxCode;
@ApiModelProperty(name = "包件类型")
private String extBoxType;
}

28
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/vo/PushOrderDetailVO.java

@ -0,0 +1,28 @@
package com.logpm.factorydata.jinpai.vo;
import cn.hutool.json.JSONObject;
import com.logpm.factorydata.jinpai.entity.PushOrderDetailEntity;
import com.logpm.factorydata.jinpai.entity.PushOrderEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* 金牌下单明细 实体类
*
* @author zhaoqiaobo
* @create 2024-04-26
*/
@Data
@ApiModel(value = "金牌下单明细", description = "金牌下单明细")
@EqualsAndHashCode(callSuper = true)
public class PushOrderDetailVO extends PushOrderDetailEntity {
@ApiModelProperty(name = "箱码列表")
private List<String> boxCodes;
@ApiModelProperty(name = "包件品类")
private List<PackageCategoryVO> boxDetails;
}

25
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/vo/PushOrderVO.java

@ -0,0 +1,25 @@
package com.logpm.factorydata.jinpai.vo;
import com.logpm.factorydata.jinpai.entity.PushOrderEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* 金牌下单 实体类
*
* @author zhaoqiaobo
* @create 2024-04-26
*/
@Data
@ApiModel(value = "金牌下单", description = "金牌下单")
@EqualsAndHashCode(callSuper = true)
public class PushOrderVO extends PushOrderEntity {
@ApiModelProperty(name = "订单明细")
private List<PushOrderDetailVO> items;
}

32
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/vo/ThirdPlWarehouseMappingVO.java

@ -0,0 +1,32 @@
package com.logpm.factorydata.jinpai.vo;
import lombok.Data;
import java.io.Serializable;
/**
* 金牌三方物流仓库映射表
* @author zhaoqiaobo
* @create 2024-04-30
*/
@Data
public class ThirdPlWarehouseMappingVO implements Serializable {
/**
* 到站网点
*/
private String arriveOrgName;
/**
* 仓库id
*/
private String warehouseId;
/**
* 仓库名称
*/
private String warehouseName;
/**
* 租户id
*/
private String tenantId;
}

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

@ -0,0 +1,38 @@
package com.logpm.factorydata.jinpai.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-jinpai/src/main/java/com/logpm/factorydata/jinpai/wrapper/RequestWrapper.java

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

12
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/resources/application-dev.yml

@ -59,13 +59,15 @@ spring:
url: ${blade.datasource.factorydata-jinpai.master.url} url: ${blade.datasource.factorydata-jinpai.master.url}
username: ${blade.datasource.factorydata-jinpai.master.username} username: ${blade.datasource.factorydata-jinpai.master.username}
password: ${blade.datasource.factorydata-jinpai.master.password} password: ${blade.datasource.factorydata-jinpai.master.password}
slave: 627683:
druid: druid:
#独立校验配置 #独立校验配置
validation-query: select 1 validation-query: select 1
#oracle校验 #oracle校验
#validation-query: select 1 from dual #validation-query: select 1 from dual
url: ${blade.datasource.factorydata-jinpai.slave.url} url: ${blade.datasource.factorydata-jinpai.627683.url}
username: ${blade.datasource.factorydata-jinpai.slave.username} username: ${blade.datasource.factorydata-jinpai.627683.username}
password: ${blade.datasource.factorydata-jinpai.slave.password} password: ${blade.datasource.factorydata-jinpai.627683.password}
blade:
data-scope:
enabled: false

12
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/resources/application-prod.yml

@ -33,13 +33,15 @@ spring:
url: ${blade.datasource.factorydata-jinpai.master.url} url: ${blade.datasource.factorydata-jinpai.master.url}
username: ${blade.datasource.factorydata-jinpai.master.username} username: ${blade.datasource.factorydata-jinpai.master.username}
password: ${blade.datasource.factorydata-jinpai.master.password} password: ${blade.datasource.factorydata-jinpai.master.password}
slave: 627683:
druid: druid:
#独立校验配置 #独立校验配置
validation-query: select 1 validation-query: select 1
#oracle校验 #oracle校验
#validation-query: select 1 from dual #validation-query: select 1 from dual
url: ${blade.datasource.factorydata-jinpai.slave.url} url: ${blade.datasource.factorydata-jinpai.627683.url}
username: ${blade.datasource.factorydata-jinpai.slave.username} username: ${blade.datasource.factorydata-jinpai.627683.username}
password: ${blade.datasource.factorydata-jinpai.slave.password} password: ${blade.datasource.factorydata-jinpai.627683.password}
blade:
data-scope:
enabled: false

12
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/resources/application-test.yml

@ -59,13 +59,15 @@ spring:
url: ${blade.datasource.factorydata-jinpai.master.url} url: ${blade.datasource.factorydata-jinpai.master.url}
username: ${blade.datasource.factorydata-jinpai.master.username} username: ${blade.datasource.factorydata-jinpai.master.username}
password: ${blade.datasource.factorydata-jinpai.master.password} password: ${blade.datasource.factorydata-jinpai.master.password}
slave: 627683:
druid: druid:
#独立校验配置 #独立校验配置
validation-query: select 1 validation-query: select 1
#oracle校验 #oracle校验
#validation-query: select 1 from dual #validation-query: select 1 from dual
url: ${blade.datasource.factorydata-jinpai.slave.url} url: ${blade.datasource.factorydata-jinpai.627683.url}
username: ${blade.datasource.factorydata-jinpai.slave.username} username: ${blade.datasource.factorydata-jinpai.627683.username}
password: ${blade.datasource.factorydata-jinpai.slave.password} password: ${blade.datasource.factorydata-jinpai.627683.password}
blade:
data-scope:
enabled: false

Loading…
Cancel
Save