From 7c29f5b8a8602539e427ef9681880f4f1778998f Mon Sep 17 00:00:00 2001
From: "pref_mail@163.com" <123456>
Date: Wed, 26 Jul 2023 10:51:46 +0800
Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9MQ=E6=89=BE=E4=B8=8D?=
=?UTF-8?q?=E5=88=B0=E9=98=9F=E5=88=97=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
blade-service/logpm-distribution/pom.xml | 5 ++
.../src/main/resources/application-test.yml | 27 +++++++++
.../test/com/logpm/distribution/MyTest.java | 45 ++++++++++++++
.../DistributionLauncherServiceImpl.java | 60 +++++++++++++++++++
.../factory/receiver/ReceiveInfoHandler.java | 1 -
.../receiver/WaybillDataHandler.java | 2 +-
6 files changed, 138 insertions(+), 2 deletions(-)
create mode 100644 blade-service/logpm-distribution/src/test/com/logpm/distribution/MyTest.java
create mode 100644 blade-service/logpm-distribution/src/test/com/logpm/distribution/launch/DistributionLauncherServiceImpl.java
diff --git a/blade-service/logpm-distribution/pom.xml b/blade-service/logpm-distribution/pom.xml
index 5667fd746..11a822f98 100644
--- a/blade-service/logpm-distribution/pom.xml
+++ b/blade-service/logpm-distribution/pom.xml
@@ -62,6 +62,11 @@
org.springframework.boot
spring-boot-starter-amqp
+
+ org.springblade
+ blade-core-test
+ test
+
diff --git a/blade-service/logpm-distribution/src/main/resources/application-test.yml b/blade-service/logpm-distribution/src/main/resources/application-test.yml
index 21d6c573d..fbd1b96ae 100644
--- a/blade-service/logpm-distribution/src/main/resources/application-test.yml
+++ b/blade-service/logpm-distribution/src/main/resources/application-test.yml
@@ -10,6 +10,33 @@ server:
# password: ${blade.datasource.dev.password}
spring:
+ #rabbitmq配置
+ rabbitmq:
+ host: 172.16.128.146
+ port: 5672
+ username: admin
+ password: Slwk@123654
+ #虚拟host 可以不设置,使用server默认host
+ virtual-host: /
+ #确认消息已发送到队列(Queue)
+ publisher-returns: true
+ publisher-confirm-type: correlated
+ # 手动提交消息
+ listener:
+ simple:
+ acknowledge-mode: auto
+ default-requeue-rejected: false
+ retry:
+ enabled: true # 开启消费者失败重试
+ initial-interval: 1000 # 初识的失败等待时长为1秒
+ multiplier: 1 # 失败的等待时长倍数,下次等待时长 = multiplier * last-interval
+ max-attempts: 3 # 最大重试次数
+ stateless: true # true无状态;false有状态。如果业务中包含事务,这里改为false
+ direct:
+ acknowledge-mode: manual
+ template:
+ mandatory: true
+
#排除DruidDataSourceAutoConfigure
autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
diff --git a/blade-service/logpm-distribution/src/test/com/logpm/distribution/MyTest.java b/blade-service/logpm-distribution/src/test/com/logpm/distribution/MyTest.java
new file mode 100644
index 000000000..f9e9a8fa7
--- /dev/null
+++ b/blade-service/logpm-distribution/src/test/com/logpm/distribution/MyTest.java
@@ -0,0 +1,45 @@
+//package com.logpm.distribution;
+//
+//
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.logpm.distribution.dto.app.StockupDTO;
+//import com.logpm.distribution.entity.DistributionBillLadingScanEntity;
+//import com.logpm.distribution.service.*;
+//import org.junit.jupiter.api.Test;
+//import org.junit.jupiter.api.extension.ExtendWith;
+//import org.springblade.core.test.BladeBootTest;
+//import org.springblade.core.test.BladeSpringExtension;
+//import org.springframework.beans.factory.annotation.Autowired;
+//
+//import java.util.List;
+//
+//import static org.springblade.common.constant.ModuleNameConstant.APPLICATION_DISTRIBUTION_NAME;
+//
+//@ExtendWith(BladeSpringExtension.class)
+//@BladeBootTest(appName = APPLICATION_DISTRIBUTION_NAME, enableLoader = true)
+//public class MyTest {
+//
+//
+// @Autowired
+// private IDistributionStockupService distributionStockupService;
+//
+// @Autowired
+// private IDistributionReservationService distributionReservationService;
+//
+// @Autowired
+// private IDistributionParcelListService distributionParcelListService;
+//
+// @Autowired
+// private IDistributionStockListService distributionStockListService;
+//
+//
+// @Test
+// public void te(){
+//
+// Long id =1682676882390781953L;
+// List packageAllocation = distributionParcelListService.selectWarehouseAreaByReservationId(id);
+// //2.通过预约单查询所有库存品的库位信息
+// List stockListAllocation = distributionStockListService.selectWarehouseAreaByReservationId(id);
+// }
+//
+//}
diff --git a/blade-service/logpm-distribution/src/test/com/logpm/distribution/launch/DistributionLauncherServiceImpl.java b/blade-service/logpm-distribution/src/test/com/logpm/distribution/launch/DistributionLauncherServiceImpl.java
new file mode 100644
index 000000000..3b87ba4a6
--- /dev/null
+++ b/blade-service/logpm-distribution/src/test/com/logpm/distribution/launch/DistributionLauncherServiceImpl.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.logpm.distribution.launch;
+
+import org.springblade.core.auto.service.AutoService;
+import org.springblade.core.launch.constant.NacosConstant;
+import org.springblade.core.launch.service.LauncherService;
+import org.springblade.core.launch.utils.PropsUtil;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+
+import java.util.Properties;
+
+/**
+ * 启动参数拓展
+ *
+ * @author Chill
+ */
+@AutoService(LauncherService.class)
+public class DistributionLauncherServiceImpl implements LauncherService {
+
+ @Override
+ public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) {
+ Properties props = System.getProperties();
+ // 开启多数据源
+ PropsUtil.setProperty(props, "spring.datasource.dynamic.enabled", "true");
+ // 指定注册配置信息
+ PropsUtil.setProperty(props, "spring.cloud.nacos.config.extension-configs[0].data-id", NacosConstant.dataId("factory", profile));
+ PropsUtil.setProperty(props, "spring.cloud.nacos.config.extension-configs[0].group", NacosConstant.NACOS_CONFIG_GROUP);
+ PropsUtil.setProperty(props, "spring.cloud.nacos.config.extension-configs[0].refresh", NacosConstant.NACOS_CONFIG_REFRESH);
+ // 指定注册IP
+ // PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.ip", "127.0.0.1");
+ // 指定注册端口
+ // PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.port", "8200");
+ // 自定义命名空间
+ // PropsUtil.setProperty(props, "spring.cloud.nacos.config.namespace", LauncherConstant.NACOS_NAMESPACE);
+ // PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.namespace", LauncherConstant.NACOS_NAMESPACE);
+ // 自定义分组
+ // PropsUtil.setProperty(props, "spring.cloud.nacos.config.group", NacosConstant.NACOS_CONFIG_GROUP);
+ // PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.group", NacosConstant.NACOS_CONFIG_GROUP);
+ }
+
+ @Override
+ public int getOrder() {
+ return 20;
+ }
+}
diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ReceiveInfoHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ReceiveInfoHandler.java
index d91bb8074..25a418e84 100644
--- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ReceiveInfoHandler.java
+++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ReceiveInfoHandler.java
@@ -44,7 +44,6 @@ public class ReceiveInfoHandler {
@Autowired
private IMtFactoryOrderMainService mtFactoryOrderMainService;
- private Integer retryCount = 1;
@RabbitHandler
public void receiveInfoHandler(Map map, Message message, Channel channel) throws IOException, NoSuchAlgorithmException {
diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/receiver/WaybillDataHandler.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/receiver/WaybillDataHandler.java
index b119b187b..0e4a9b8fd 100644
--- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/receiver/WaybillDataHandler.java
+++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/receiver/WaybillDataHandler.java
@@ -22,7 +22,7 @@ import java.util.Objects;
*/
@Slf4j
@AllArgsConstructor
-@RabbitListener(queues = RabbitConstant.WAYBILL_DATA_TEST_QUEUE)
+@RabbitListener(queues = RabbitConstant.WAYBILL_DATA_QUEUE)
@Component
public class WaybillDataHandler {